From 7ed9b7dc2f662148349e2e6d7a2b4092c1abef33 Mon Sep 17 00:00:00 2001 From: nihirash Date: Tue, 30 Jul 2019 21:59:22 +0300 Subject: [PATCH] uGophy v.0.7 - stack issue fixed --- software/ugophy/gopher.asm | 9 +++++-- software/ugophy/keyboard.asm | 1 + software/ugophy/main.asm | 7 ++++++ software/ugophy/render.asm | 46 +++++++++++++++++++++++++----------- software/ugophy/ring.asm | 11 ++++++++- software/ugophy/uart.asm | 12 ---------- software/ugophy/utils.asm | 12 ++++++++++ 7 files changed, 69 insertions(+), 29 deletions(-) diff --git a/software/ugophy/gopher.asm b/software/ugophy/gopher.asm index fb5f21e..51fc134 100644 --- a/software/ugophy/gopher.asm +++ b/software/ugophy/gopher.asm @@ -61,9 +61,12 @@ makeRequest: call uartWriteStringZ ld hl, cmd_open3 call okErrCmd + + pop hl cp 1 jp nz, reqErr - + push hl + ld hl, cmd_send ; Send request call uartWriteStringZ pop hl @@ -79,9 +82,11 @@ makeRequest: call uartWriteStringZ ld hl, crlf - call okErrCmd + call okErrCmd + pop hl cp 1 jp nz, reqErr + push hl wPrmt: call uartReadBlocking call pushRing diff --git a/software/ugophy/keyboard.asm b/software/ugophy/keyboard.asm index 0445bdc..d9cb26a 100644 --- a/software/ugophy/keyboard.asm +++ b/software/ugophy/keyboard.asm @@ -88,6 +88,7 @@ cleanIBuff: ldir ret iRet: + pop hl ld b, 20 ld c, 0 call gotoXY diff --git a/software/ugophy/main.asm b/software/ugophy/main.asm index 31c6795..3366f96 100644 --- a/software/ugophy/main.asm +++ b/software/ugophy/main.asm @@ -1,19 +1,26 @@ DEVICE ZXSPECTRUM128 org 24100 Start: + di + xor a call changeBank + ld sp, #5aff ld de, #4000 ld bc, eop - page_buffer ld hl, page_buffer ldir + ei + call renderHeader ld hl, connecting_wifi call printZ64 call initWifi + call wSec + ld de, path ld hl, server ld bc, port diff --git a/software/ugophy/render.asm b/software/ugophy/render.asm index 7efbc95..cd97d44 100644 --- a/software/ugophy/render.asm +++ b/software/ugophy/render.asm @@ -3,24 +3,25 @@ showPage: ld (show_offset), a ld a, 1 ld (cursor_pos), a +backToPage: call renderScreen call showCursor showLp: - call controls - xor a call changeBank + jp controls dup 5 halt edup + jr showLp controls: call inkey cp 0 - ret z + jr z, showLp cp 'q' jr z, pageCursorUp @@ -36,7 +37,8 @@ controls: cp 'o' jp z, openURI - ret + + jp showLp historyBack: ld hl, server @@ -56,7 +58,7 @@ pageCursorUp: pop af ld (cursor_pos), a call showCursor - ret + jp showLp pageCursorDown: ld a, (cursor_pos) @@ -69,7 +71,7 @@ pageCursorDown: pop af ld (cursor_pos), a call showCursor - ret + jp showLp pageScrollDn: ld hl, (show_offset) @@ -80,7 +82,7 @@ pageScrollDn: ld (cursor_pos), a call renderScreen call showCursor - ret + jp showLp pageScrollUp: ld a, (show_offset) @@ -96,7 +98,7 @@ pageScrollUp: ld (cursor_pos), a call renderScreen call showCursor - ret + jp showLp selectItem: ld a, (cursor_pos) @@ -123,7 +125,7 @@ selectItem: cp '7' jr z, userInput - ret + jp showLp userInput: call cleanIBuff @@ -172,32 +174,44 @@ downPg: cp '0' jp z, showText - ret + jp showLp downFl: call extractInfo - + call clearRing call cleanIBuff + ld hl, file_buffer call findFnme jp isOpenable dfl: ld hl, file_buffer call findFnme + ld de, iBuff ld bc, 65 ldir call input + + ld hl, iBuff + call showTypePrint + ld hl, server_buffer ld de, file_buffer ld bc, port_buffer call makeRequest + xor a + call changeBank + ld hl, iBuff call downloadData + + call hideCursor call showCursor - ret + + jp showLp isOpenable: ld a, (hl) @@ -259,7 +273,7 @@ wKey: call inkey xor a call changeBank - jp showPage + jp backToPage playMusic: ld hl, hist @@ -278,6 +292,8 @@ playMusic: xor a call changeBank + call setNoTurboMode + ld hl, page_buffer call #4003 playLp: @@ -289,6 +305,8 @@ playLp: and 15 jr z, playLp call #4008 + + call setTurbo4Mode jp historyBack findFnme: @@ -539,7 +557,7 @@ show_offset db 0 display $ cursor_pos db 1 -head db " UGophy - ZX-UNO Gopher client v. 0.6 (c) Alexander Sharikhin", 13,0 +head db " UGophy - ZX-UNO Gopher client v. 0.7 (c) Alexander Sharikhin", 13,0 cleanLine db " ",0 playing db "Playing... Hold to stop!", 0 diff --git a/software/ugophy/ring.asm b/software/ugophy/ring.asm index 2b13381..c989326 100644 --- a/software/ugophy/ring.asm +++ b/software/ugophy/ring.asm @@ -54,7 +54,16 @@ ringCmpLp djnz ringCmpLp ld a, 1 ret - + +clearRing: + xor a + ld hl, ring_buffer + ld de, ring_buffer + 1 + ld bc, 32 + ld (hl), a + ldir + ret + ring_buffer dup 33 defb 0 edup \ No newline at end of file diff --git a/software/ugophy/uart.asm b/software/ugophy/uart.asm index 4527ec3..abdc792 100644 --- a/software/ugophy/uart.asm +++ b/software/ugophy/uart.asm @@ -22,18 +22,6 @@ uartBegin: in A, (c) ret -; Pushes to UART zero-terminated string -; HL - string poiner -uartWriteStringZ: - ld a, (hl) - and a - ret z - push hl - call uartWriteByte - pop hl - inc hl - jp uartWriteStringZ - ; Blocking read one byte uartReadBlocking: call uartRead diff --git a/software/ugophy/utils.asm b/software/ugophy/utils.asm index b69ef9e..cb14b85 100644 --- a/software/ugophy/utils.asm +++ b/software/ugophy/utils.asm @@ -43,6 +43,18 @@ setTurbo4Mode: pop af ret +; Pushes to UART zero-terminated string +; HL - string poiner +uartWriteStringZ: + ld a, (hl) + and a + ret z + push hl + call uartWriteByte + pop hl + inc hl + jp uartWriteStringZ + ; Print zero-terminated string ; HL - string pointer putStringZ: