Skip to content

Commit

Permalink
better debug build
Browse files Browse the repository at this point in the history
  • Loading branch information
remy committed Apr 7, 2021
1 parent ebe8202 commit 05da43a
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 19 deletions.
24 changes: 24 additions & 0 deletions example/capture-esp.bas.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#program capture-esp
1 RUN AT 3
10 LAYER 0
20 BANK 20 ERASE
30 ON ERROR GO SUB 9000
40 CLS : PRINT INVERSE 1;"HTTP 4k debug"; INVERSE 0
145 t$="4k":u$="/10":%r=1: GO SUB 1000
900 ON ERROR
910 PRINT FLASH 1;"All OK"
920 STOP
1010 PRINT AT %r,0;t$+" test..."
1020 t$=t$+".bin"
1030 IF %e=1 THEN GO TO 7000: ; banking
1040 REM file test logic
1200 ../http-debug.dot -h data.remysharp.com -u u$ -f t$ -v 6
5090 PRINT AT %r,11;"done. Verifying: "
5100 c$=t$+" -1 -mb 20"
5110 .$ extract c$
5120 %i=% BANK 20 PEEK 0
5130 SAVE "4k-esp-bank.bin" BANK 20,%$2000,%$2000
8000 IF %i=$FF THEN PRINT AT %r,27; INVERSE 1;"OK"; INVERSE 0: ELSE PRINT AT %r,27; FLASH 1;"BAD": PAUSE 0: STOP
8010 RETURN
9000 ON ERROR
9050 PRINT FLASH 1;"ERROR": ERROR : PAUSE 0: STOP
Binary file added example/verify7.bas
Binary file not shown.
37 changes: 37 additions & 0 deletions example/verify7.bas.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#program verify7
1 RUN AT 3
10 LAYER 0
20 BANK 20 ERASE
30 ON ERROR GO SUB 9000
40 CLS : PRINT INVERSE 1;"HTTP 7bit bank tests"; INVERSE 0:%e=1
145 t$="4k":%l=%$1000:u$="/12":%r=1: GO SUB 1000
150 t$="8k":%l=%$2000:u$="/13":%r=2: GO SUB 1000
160 t$="16k":%l=%$4000:u$="/14":%r=3: GO SUB 1000
500 PRINT INVERSE 1;"HTTP 7bit file tests"; INVERSE 0:%e=2
510 t$="4k":u$="/12":%r=5: GO SUB 1000
520 t$="8k":u$="/13":%r=6: GO SUB 1000
530 t$="16k":u$="/14":%r=7: GO SUB 1000
540 ; t$="32k":u$="/14":%r=7: GO SUB 1000
900 ON ERROR
910 PRINT FLASH 1;"7bit - All OK"
920 STOP
1010 PRINT AT %r,0;t$+" test..."
1020 t$=t$+".bin"
1030 IF %e=1 THEN GO TO 7000: ; banking
1040 REM file test logic
1200 .http -h data.remysharp.com -u u$ -f t$ -v 6 -7
5090 PRINT AT %r,11;"done. Verifying: "
5100 c$=t$+" -1 -mb 20"
5110 .$ extract c$
5120 %i=% BANK 20 PEEK 0
5130 GO TO 8000
5140 REM bank testing logic
7000 .http -h data.remysharp.com -u u$ -b 20 -v 5 -7
7090 PRINT AT %r,11;"done. Verifying: "
7120 %i=% BANK 20 PEEK (l-1)

8000 IF %i=$FF THEN PRINT AT %r,27; INVERSE 1;"OK"; INVERSE 0: ELSE PRINT AT %r,27; FLASH 1;"BAD": PAUSE 0: STOP
8010 RETURN

9000 ON ERROR
9050 PRINT FLASH 1;"ERROR": ERROR : PAUSE 0: STOP
Binary file modified http-debug.dot
Binary file not shown.
10 changes: 9 additions & 1 deletion src/bank.asm
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,13 @@ init:
ld (userBank), a
nextreg pageA, a ; set bank to A

IFDEF TESTING
ld a, $29 ; 2nd half of bank 20 @ $2000
ELSE
call allocPage
ENDIF
ld (userBank+1), a
nextreg pageB, a ; set bank to A
nextreg pageB, a ; set bank to B

ret
erase:
Expand Down Expand Up @@ -84,9 +88,13 @@ restore:
ld e, a
call freePage

;; only release the 2nd page if we're not testing - if we're
;; testing then this preserves 2nd part of bank 20
IFNDEF TESTING
ld a, (userBank+1)
ld e, a
call freePage
ENDIF

.done
pop af
Expand Down
7 changes: 2 additions & 5 deletions src/main.asm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
SLDOPT COMMENT WPMEM, LOGPOINT, ASSERTION
OPT reset --zxnext --syntax=abfw

; DEFINE TESTING
DEFINE TESTING

INCLUDE "version.inc.asm"
INCLUDE "macros.inc.asm"
Expand All @@ -16,9 +16,6 @@
CSPECTMAP "http.map"
DISPLAY "Adding jump to ",/H,testStart
testStart:
; exx
; ld hl, $9FFF
; exx
; ld hl, testFakeArgumentsLine
call start
ret
Expand All @@ -32,7 +29,7 @@ testFakeArgumentsLine
; DZ "get -f demo.scr -h data.remysharp.com -u /5 -v 2"
; DZ "get -b 5 -o -0 -h data.remysharp.com -u /5 -v 2"
; DZ "get -f http-demo.tap -h zxdb.remysharp.com -u /get/18840 -v 2"
DZ "get -f output.bin -h 192.168.1.118 -u /output.bin -p 5000 -v 3"
; DZ "get -f output.bin -h 192.168.1.118 -u /output.bin -p 5000 -v 3"
; DZ "post -b 21 -h data.remysharp.com -u /1 -f 3 -l 16384 -7"

ENDIF
Expand Down
35 changes: 22 additions & 13 deletions src/uart.asm
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,34 @@ read:
ld bc, UART_RxD
in a, (c)
IFDEF TESTING
;; write to the debug bank - $A000
call debug
ENDIF
call Border
ret
.checkTimeout
call CheckESPTimeout
jr .wait

IFDEF TESTING
debug:
;; write to the debug bank - $A000 and no further
push hl
push af
ld hl, (Bank.debug)
ld a, h
cp $c0
jr z, .outOfMemory
pop af
ld (hl), a
inc hl
ld (Bank.debug), hl
pop hl
ENDIF
call Border
ret
.checkTimeout
call CheckESPTimeout
jr .wait
.outOfMemory
pop af
pop hl
ret
ENDIF

; A = byte to write
; Modifies: BC, DE
Expand All @@ -87,13 +102,7 @@ write:
call InitESPTimeout
ld d, a
IFDEF TESTING
;; write to the debug bank - $A000
push hl
ld hl, (Bank.debug)
ld (hl), a
inc hl
ld (Bank.debug), hl
pop hl
call debug
ENDIF

ld bc, UART_GetStatus
Expand Down

0 comments on commit 05da43a

Please sign in to comment.