uGoph v. 0.9

This commit is contained in:
nihirash 2019-09-14 23:46:17 +03:00
parent 2d677e061c
commit f2d4af5a6e
4 changed files with 61 additions and 41 deletions

View File

@ -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

View File

@ -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:" , $

View File

@ -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 <SPACE> to stop!", 0

View File

@ -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