diff --git a/software/esprst/Makefile b/software/esprst/Makefile index 0d3cc0c..f694859 100644 --- a/software/esprst/Makefile +++ b/software/esprst/Makefile @@ -1,6 +1,6 @@ all: esprst -esprst: +esprst: *.asm sjasmplus main.asm clean: diff --git a/software/esprst/main.asm b/software/esprst/main.asm index f3985f3..0e277c4 100644 --- a/software/esprst/main.asm +++ b/software/esprst/main.asm @@ -6,27 +6,32 @@ Start: call uartBegin - ld hl, cmd_mode - call uartWriteStringZ - - call wait + ld hl, ent : call putS + ld hl, cmd_mode : call uartWriteStringZ + call wait : call wait - ld hl, cmd_rst - call uartWriteStringZ - - call wait - call wait + ld hl, configuring : call putS + ld hl, cmd_uart : call uartWriteStringZ + call wait : call wait - ld hl, cmd_at - call uartWriteStringZ + ld hl, reseting : call putS + ld hl, cmd_rst : call uartWriteStringZ + call wait : call wait + + ld hl, setting_m : call putS + ld hl, cmd_cwmode : call uartWriteStringZ wtlp: - call uartReadBlocking - call pushRing + call uartReadBlocking : call pushRing - ld hl,response_ok - call searchRing - cp 1 - jr nz, wtlp + ld hl,response_ok : call searchRing + cp 1 : jr nz, wtlp + + ld hl, receiv_info : call putS + ld hl, cmd_info : call uartWriteStringZ +infoLp: + call uartReadBlocking: push af : call putC : pop af : call pushRing + ld hl, response_ok : call searchRing + cp 1 : jr nz, infoLp ld hl, fin call putS @@ -48,19 +53,33 @@ putS: or 0 ret z push hl - rst #10 + call putC pop hl inc hl jr putS -init_txt defb ".EspRst v.0.1 (c) Nihirash",13,"This tool resets esp-chip",13,0 +putC: + cp 13 + ret s + rst #10 + ret -fin defb "WiFi module ready to work", 13, 0 +init_txt defb ".EspRst v.0.2 (c) Nihirash",13,"This tool resets esp-chip",13,0 +fin defb 13, "WiFi module ready to work!", 13, 0 +ent defb "Entering command mode", 13, 0 +configuring defb "Configuring UART mode", 13, 0 +reseting defb "Reseting ESP-chip", 13, 0 +setting_m defb "WiFi chip to client mode", 13, 0 +receiv_info defb "Getting ESP-chip version", 13, 0 cmd_mode defb "+++", 0 +cmd_uart defb "AT+UART_DEF=115200,8,1,0,2", 13, 10, 0 cmd_rst defb "AT+RST", 13, 10, 0 -cmd_at defb "AT", 13, 10, 0 +cmd_echo defb "ATE0", 13, 10, 0 +cmd_cwmode defb "AT+CWMODE=1", 13, 10, 0 +cmd_info defb "AT+GMR", 13, 10, 0 response_ok defb "OK", 13, 10, 0 +response_er defb "ready", 13, 10, 0 SAVEBIN "esprst", Start, $ - Start \ No newline at end of file diff --git a/software/ugophy/gopher.asm b/software/ugophy/gopher.asm index dd11e89..08e9724 100644 --- a/software/ugophy/gopher.asm +++ b/software/ugophy/gopher.asm @@ -2,19 +2,16 @@ ; de - path ; bc - port openPage: - push hl : push de : push bc - + ld (srv_ptr), hl : ld (path_ptr), de : ld (port_ptr), bc xor a : call changeBank ex hl, de : ld de, hist : ld bc, 322 : ldir - ld hl, page_buffer : xor a : ld (hl), a : ld de, page_buffer + 1 : ld bc, #ffff - page_buffer - 1 : ldir - - pop bc : pop de : pop hl - + ld hl, (srv_ptr) : ld de, (path_ptr) : ld bc, (port_ptr) call makeRequest xor a : call changeBank + ld hl, page_buffer : xor a : ld (hl), a : ld de, page_buffer + 1 : ld bc, #ffff - page_buffer - 1 : ldir ld hl, page_buffer : call loadData @@ -22,11 +19,15 @@ openPage: inc a : ld (cursor_pos), a ret +srv_ptr dw 0 +path_ptr dw 0 +port_ptr dw 0 + ; HL - domain stringZ ; DE - path stringZ ; BC - port stringZ makeRequest: - push de : push bc : push hl + ld (srv_ptr), hl : ld (path_ptr), de : ld (port_ptr), bc ld hl, downloading_msg : call showTypePrint @@ -34,34 +35,34 @@ makeRequest: ; Open TCP connection ld hl, cmd_open1 : call uartWriteStringZ - pop hl : call uartWriteStringZ + ld hl, (srv_ptr) : call uartWriteStringZ ld hl, cmd_open2 : call uartWriteStringZ - pop hl : call uartWriteStringZ + ld hl, (port_ptr) : call uartWriteStringZ ld hl, cmd_open3 : call okErrCmd - pop hl : cp 1 : jp nz, reqErr : push hl + cp 1 : jp nz, reqErr ; Send request ld hl, cmd_send : call uartWriteStringZ - pop hl : push hl + ld hl, (path_ptr) call getStringLength push bc : pop hl : inc hl : inc hl : call B2D16 ld hl, B2DBUF : call SkipWhitespace : call uartWriteStringZ ld hl, crlf : call okErrCmd - pop hl : cp 1 : jp nz, reqErr : push hl + cp 1 : jp nz, reqErr wPrmt: call uartReadBlocking : call pushRing ld hl, send_prompt : call searchRing : cp 1 : jr nz, wPrmt - pop hl : call uartWriteStringZ + ld hl, (path_ptr) : call uartWriteStringZ ld hl, crlf : call uartWriteStringZ : ld a, 1 : ld (connectionOpen), a ret -reqErr: - pop hl ; Now we won't back to same address +reqErr: + ld sp, stack_pointer ld hl, connectionError : call showTypePrint : call wSec xor a : ld (connectionOpen), a @@ -87,7 +88,7 @@ lpLoop: jp lpLoop ldEnd - xor a : ld (data_pointer), a + ld hl, 0 : ld (data_pointer), hl ret ; Download file via gopher @@ -131,6 +132,7 @@ fstream defb 0 closed_callback xor a ld (connectionOpen), a + ei ret hostTxt db 'Enter host: ', 0 diff --git a/software/ugophy/main.asm b/software/ugophy/main.asm index 1ec0a68..8f048c2 100644 --- a/software/ugophy/main.asm +++ b/software/ugophy/main.asm @@ -14,14 +14,15 @@ DEVICE ZXSPECTRUM128 org 24100 +stack_pointer EQU #5aff Start: di - + res 4, (iy+1) call checkHighMem : jp nz, noMem xor a : out (#fe), a : call changeBank - ld sp, #5aff + ld sp, stack_pointer ld de, #4000 : ld bc, eop - player : ld hl, player : ldir @@ -76,9 +77,9 @@ port db '70' db 0 page_buffer equ $ display "PAGE buffer:", $ -no128k db 13, "You're started in 48k mode!", 13 +no128k db 13, "You're in 48k mode!", 13, 13 db "Current version require full", 13 - db "128K memory access", 13 + db "128K memory access", 13, 13 db "System halted!", 0 player DISPLAY "Player starts:" , $ diff --git a/software/ugophy/render.asm b/software/ugophy/render.asm index d1afbb3..b04548f 100644 --- a/software/ugophy/render.asm +++ b/software/ugophy/render.asm @@ -2,14 +2,14 @@ showPage: xor a : ld (show_offset), a inc a :ld (cursor_pos), a backToPage: + xor a : call changeBank call renderScreen : call showCursor showLp: xor a : call changeBank - jp controls - controls: - call inkey - + xor a : ld (s_show_flag), a + + call inkey cp 0 : jr z, showLp cp 'q' : jp z, pageCursorUp cp 'a' : jp z, pageCursorDown @@ -44,7 +44,7 @@ pageCursorDown: pageScrollDn: ld hl, (show_offset) : ld de, 20 : add hl, de : ld (show_offset), hl ld a, 1 : ld (cursor_pos), a - + jp backToPage pageScrollUp: @@ -59,7 +59,7 @@ selectItem: call findLine ld a, h : or l : jp z, showLp - + ld a, (hl) cp '1' : jr z, downPg @@ -117,7 +117,7 @@ dfl: call hideCursor : call showCursor - jp showLp + jp backToPage isOpenable: ld a, (hl) : and a : jr z, checkFile @@ -139,7 +139,7 @@ checkFile: ;; Music xor a: ld (#400A), a - ld hl, pt3Ext : call searchRing : cp 1: jr z, playMusic + ld hl, pt3Ext : call searchRing : cp 1 : jr z, playMusic ld hl, pt3Ext2 : call searchRing : cp 1 : jr z, playMusic ld a, 2 : ld (#400A), a @@ -155,17 +155,30 @@ loadImage: ld hl, #c000 : call loadData - ld c, #ff : xor a : out (c), a + xor a : out (#ff), a : out (#fe), a + ld b, 255 wKey: - call inkey : or a : jr z, wKey + halt + ld a, (s_show_flag) : and a : jr z, wK2 + dec b : jp z, startNext +wK2: + call inkey + or a : jr z, wKey + cp 's' : jr z, toggleSS xor a : call changeBank jp backToPage +toggleSS: + ld a, (s_show_flag) : xor #ff : ld (s_show_flag), a + and a : jp nz, startNext + jp backToPage + playMusic: ld hl, hist : ld de, path : ld bc, 322 : ldir - ld hl, (show_offset) : push hl + ld hl, (show_offset) : ld (offset_tmp), hl + xor a : call changeBank ld hl, server_buffer : ld de, file_buffer : ld bc, port_buffer : call openPage ld hl, playing : call showTypePrint @@ -177,30 +190,30 @@ playMusic: ld a, (#400A) : or 1 : ld (#400A), a ld hl, page_buffer : call #4003 playLp: - halt : call #4005 - xor a : in a, (#fe) : cpl : and 15 : jp nz, stopPlay + halt : di : call #4005 : ei + xor a : in a, (#fe) : cpl : and 31 : jp nz, stopPlay ld a, (#400A) : rla : jr nc, playLp songEnded: - call #4008 - call setTurbo4Mode + call #4008 : call setTurbo4Mode ld hl, server : ld de, path : ld bc, port : call openPage - pop hl : ld (show_offset), hl + ld hl, (offset_tmp) : ld (show_offset), hl +startNext: ld a, (cursor_pos) : inc a : cp 21 : jr z, playNxtPg : ld (cursor_pos), a jr playContinue playNxtPg: - ld hl, (show_offset) : ld de, 20 : add hl, de : ld (show_offset), hl : ld a, 1 : ld (cursor_pos), a + ld a, (show_offset) : add 20 : ld (show_offset), a : ld a, 1 : ld (cursor_pos), a playContinue: call renderScreen : call showCursor + xor a : call changeBank jp selectItem stopPlay: - call #4008 - call setTurbo4Mode + call #4008 : call setTurbo4Mode ld hl, server : ld de, path : ld bc, port : call openPage - pop hl : ld (show_offset), hl + ld hl, (offset_tmp) : ld (show_offset), hl jp backToPage @@ -360,10 +373,12 @@ findNextBlock: inc hl jp findNextBlock +s_show_flag db 0 +offset_tmp dw 0 show_offset db 0 cursor_pos db 1 -head db " UGophy - ZX-UNO Gopher client v. 0.8 (c) Alexander Sharikhin", 13,0 +head db " UGophy - ZX-UNO Gopher client v. 0.9 (c) Alexander Sharikhin", 13,0 cleanLine db " ",0 playing db "Playing... Hold to stop!", 0 diff --git a/software/ugophy/textrender.asm b/software/ugophy/textrender.asm index 616ca53..88abffd 100644 --- a/software/ugophy/textrender.asm +++ b/software/ugophy/textrender.asm @@ -17,7 +17,9 @@ txControls: and a : ret z cp 'q' : jp z, txUp + cp 'o' : jp z, txUp cp 'a' : jp z, txDn + cp 'p' : jp z, txDn cp 'b' : jp z, historyBack cp 'n' : jp z, openURI