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
+2 -2
View File
@@ -14,8 +14,8 @@ BIOS_ROM_START := 0x0080
BIOS_ROM_SIZE := 0x0780
BASIC_ROM_START := 0x0800
BASIC_ROM_SIZE := 0x2000
BASIC_ROM_SIZE := 0x2200
BIOS_RAM_START := 0xc000
BIOS_WP_RAM_START := 0xc800
BASIC_RAM_START := 0xcc00
BASIC_RAM_START := 0xce00
+6 -4
View File
@@ -636,7 +636,7 @@ gen_byte:
; -------------------------------------------------------
gen_leader:
; short leader
ld b,50 ; generate 50 short pulses
ld b,100 ; generate 100 short pulses
1$:
call gen_short
dec b
@@ -644,7 +644,7 @@ gen_leader:
cp 0
jr nz,1$ ; repeat if not done
; long leader
ld b,50 ; generate 50 long pulses
ld b,100 ; generate 100 long pulses
2$:
call gen_long
dec b
@@ -669,8 +669,9 @@ gen_leader:
; Writes the block stored in the block buffer
; -------------------------------------------------------
write_block:
push de
push bc
push de
push hl
; calculate the crc16 over the block
ld hl, BLOCK_BUFFER
ld a, BLOCK_SIZE-2 ; dont use crc value in block
@@ -706,8 +707,9 @@ write_block:
ld a,200
call delay_ms
pop bc
pop hl
pop de
pop bc
ret
; -------------------------------------------------------
; Strings