Skip to content

Commit

Permalink
fix 7bit get (cspect support)
Browse files Browse the repository at this point in the history
Only works for smaller sizes, but importantly it works again.
  • Loading branch information
remy committed May 13, 2021
1 parent 253e96b commit 7b15f42
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 9 deletions.
Binary file modified http
Binary file not shown.
Binary file modified http-debug.dot
Binary file not shown.
37 changes: 33 additions & 4 deletions src/base64.asm
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,32 @@
INCLUDE "state.asm"
start:
di

;; decode test
ld hl, s12
ld a, 96
;; now a / 4
rra
rra

ld b, a
.loopDecode
ld de, Base64.buffer
push bc
DUP 4
ld a, (hl)
ld (de), a
inc hl
inc de
EDUP
push hl
call Base64.Decode
pop hl
pop bc
djnz .loopDecode
jr $

;; encode
ld hl, 32
call Base64.EncodedLength
; jr $
Expand All @@ -24,8 +50,6 @@ start:
push de
call Base64.Encode ; result in DE
pop de
; pop hl
; inc hl : inc hl : inc hl

ld hl, Base64.buffer
DUP 4
Expand Down Expand Up @@ -310,10 +334,12 @@ ToIndex
ld a, 63
ret

; Modifies: AF, BC
; Expects Base64.buffer to contain only 4 bytes
;
; Modifies: AF, BC
Decode:
; Convert the 4 bytes in .buffer from 7-bit encoded to 8-bit decoded bytes,

; Convert the 4 bytes in .buffer from 7-bit encoded to 8-bit decoded bytes,
; and store in .output. Once done, .output is 3 bytes long, copy it over
; the original input buffer.
.capture
Expand Down Expand Up @@ -409,5 +435,8 @@ s10: DEFB "AAAA",0

s11: DEFB "AAECAwQFBgcICQoLDA0ODxAREhMUFQ==",0

s12: DEFB "UkVNmZl4DVJFTVdGeAhKVUwiIUYIUkVNV0bUB0FCSVdGoAdSRQBw/ogHU1RTshNYB0RBRJmZVgdSRU2ZmRQHRVRTIiG4BA==",0

end:
SAVESNA "base64.sna", start
ENDIF
7 changes: 5 additions & 2 deletions src/headers.asm
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ contentLengthSub:
;
; DE=length of UART buffer
; Fc=failed to find header
; Modifies: AF, BC, DE, HL, IX
; Modifies: AF, BC, DE, HL
findContentLength
push ix
ld hl, tmpBuffer

;; process a single header
Expand Down Expand Up @@ -226,7 +227,7 @@ findContentLength
call Uart.read
dec de
scf
ret
jr .exit

.slurpToEndOfHeader
call Uart.read : dec de : cp CR : jr nz, .slurpToEndOfHeader
Expand All @@ -238,6 +239,8 @@ findContentLength
call Uart.read : dec de ; LR
call Uart.read : dec de : cp CR : jr nz, .slurpToEndOfAllHeaders
call Uart.read : dec de ; LR
.exit
pop ix
ret
Parse

Expand Down
3 changes: 2 additions & 1 deletion src/main.asm
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ testFakeArgumentsLine
; DZ "get -b 5 -h data.remysharp.com -u /2 -7 -o -0 -f 3" ; screen$
; DZ "get -b 5 -o -0 -h data.remysharp.com -u /5 -v 2" ; screen$
; DZ "get -b 20 -h data.remysharp.com -u /8 -v 2" ; 8K
DZ "get -h data.remysharp.com -u /6 -b 20 -7 -v 2" ; marbles demo

;; file based tests
; DZ "get -f 8k.bin -h data.remysharp.com -u /8 -v 2" ; 8K
Expand Down Expand Up @@ -471,7 +472,7 @@ diagBinPcLo EQU ((100*diagBinSz)%8192)*10/8192
;; delete any autoexec.bas
SHELLEXEC "(hdfmonkey rm /Applications/cspect/app/cspect-next-2gb.img /nextzxos/autoexec.bas > /dev/null) || exit 0"
SHELLEXEC "hdfmonkey put /Applications/cspect/app/cspect-next-2gb.img http-debug.dot /devel/http-debug.dot"
SHELLEXEC "mono /Applications/cspect/app/cspect.exe -r -w5 -basickeys -zxnext -nextrom -exit -brk -tv -mmc=/Applications/cspect/app/cspect-next-2gb.img -map=./http.map -sd2=/Applications/cspect/app/empty-32mb.img -com='/dev/tty.wchusbserial1430:11520'"
SHELLEXEC "mono /Applications/cspect/app/cspect.exe -r -w5 -basickeys -zxnext -nextrom -exit -brk -tv -mmc=/Applications/cspect/app/cspect-next-2gb.img -map=./http.map -sd2=/Applications/cspect/app/empty-32mb.img" ; -com='/dev/tty.wchusbserial1430:11520'
ENDIF : ENDIF
DISPLAY "TEST BUILD"
ENDIF
2 changes: 1 addition & 1 deletion src/version.inc.asm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
IFNDEF TESTING
DEFINE VERSION "1.0-25rc"
DEFINE VERSION "1.0-26rc"
ELSE
DEFINE VERSION "TEST"
ENDIF
Expand Down
4 changes: 3 additions & 1 deletion src/wifi.asm
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,8 @@ getPacket:
push hl

ld a, (firstRead)
and a : jr z, .headerProcessed
and a
jr z, .headerProcessed

.processHeader
;; we're searching for "content-length:"
Expand Down Expand Up @@ -437,6 +438,7 @@ getPacket:

push bc

; CSP_BREAK
call Base64.Decode ; modifies BC and AF only
; result is stored in Base64.output

Expand Down

0 comments on commit 7b15f42

Please sign in to comment.