csave-cload roundtrip irl works

This commit is contained in:
Joppe Blondel
2026-10-09 17:07:17 +02:00
parent a34ad82444
commit af3dcaf5fb
3 changed files with 52 additions and 9 deletions
+44 -3
View File
@@ -4815,10 +4815,10 @@ CSAVEB: inc hl ; skip #
inc hl
call BYTESTOBLOCKS
push bc
ld a,b ; nr of blocks low byte
ld a,c ; nr of blocks low byte
ld (hl),a
inc hl
ld a,c ; nr of blocks high byte
ld a,b ; nr of blocks high byte
ld (hl),a
inc hl
push hl
@@ -4834,6 +4834,7 @@ CSAVEB: inc hl ; skip #
inc hl
push hl
dec e ; count down str len
ld a,e
cp 0
jr nz,1$ ; repeat for the whole string
exx
@@ -4843,9 +4844,49 @@ CSAVEB: inc hl ; skip #
inc hl
; Header block complete (rest of block is accepted garbage)
call BIOS_CAS_WRITE_BLOCK
ld a,'.'
call OUTC
call BIOS_CAS_WRITE_BLOCK
ld a,'.'
call OUTC
ld a,250
call BIOS_DELAY_MS
ld a,250
call BIOS_DELAY_MS
ld a,250
call BIOS_DELAY_MS ; add a 750ms delay
pop bc ; get back block count
pop de ; get back start address
ld a,b
or c
jr z,3$ ; no data blocks for a zero length
2$:
; load data into buffer
push bc
call BIOS_CAS_GET_BUFFER
ld bc,128 ; block size
ld a,0 ; raw type
ld (hl),a
inc hl
ex de,hl ; hl=src,de=dest
ldir ; copy the bytes
ex de,hl ; de back to being the src addr
call BIOS_CAS_WRITE_BLOCK
ld a,'.'
call OUTC
call BIOS_CAS_WRITE_BLOCK
ld a,'.'
call OUTC
pop bc
dec bc
ld a,b
or c
jr nz,2$ ; repeat if not done
3$:
; All blocks are written
ld hl,CLCLRF
call PRS
pop hl
pop de