Added start of csave command and bios write block
This commit is contained in:
+111
-1
@@ -427,7 +427,7 @@ WORDTB: .WORD PEND
|
||||
.WORD LIST
|
||||
.WORD CLEAR
|
||||
.WORD CLOAD
|
||||
.WORD FCERR ; csave
|
||||
.WORD CSAVE
|
||||
.WORD NEW
|
||||
|
||||
; RESERVED WORD TOKEN VALUES
|
||||
@@ -4772,4 +4772,114 @@ CLNOHDRMSG: .db "HE", 0ah,0dh,00h
|
||||
CLBLOCKSMSG: .db " blocks", 0ah,0dh,00h
|
||||
CLCLRF: .db 0ah,0dh,00h
|
||||
|
||||
CSAVE: ld a,(hl) ; get byte after "CSAVE"
|
||||
cp ZTIMES ; "*" token? ("CSAVE*")
|
||||
jp z,FCERR ; yes - array load (ARRLD1)
|
||||
cp ZPRINT ; "?" ("PRINT token") verify
|
||||
jp z,FCERR ; yes - flag "verify"
|
||||
cp '#' ; 'csave#'?
|
||||
jp z,CSAVEB ; yes - save binary
|
||||
; just cload - load basic
|
||||
jp FCERR
|
||||
|
||||
CSAVEB: inc hl ; skip #
|
||||
push bc ; save bc
|
||||
push de ; save de
|
||||
CALL GETNUM ; Get start address
|
||||
CALL DEINT ; Convert it to 16 bits
|
||||
PUSH DE ; Save start address
|
||||
CALL CHKSYN ; Make sure "," follows
|
||||
.BYTE ','
|
||||
CALL GETNUM ; Get length
|
||||
CALL DEINT ; Convert it to 16 bits
|
||||
PUSH DE ; Save length
|
||||
CALL CHKSYN ; Make sure "," follows
|
||||
.BYTE ','
|
||||
; hl points to the first character of the string expression
|
||||
call EVAL
|
||||
push hl ; save command buffer pos
|
||||
exx
|
||||
call GETSTR
|
||||
call LOADFP ; bc' = addr, e' = length
|
||||
exx
|
||||
pop hl ; get back command buffer pos
|
||||
pop bc ; get length
|
||||
pop de ; get start address
|
||||
push hl
|
||||
push de
|
||||
call BIOS_CAS_GET_BUFFER
|
||||
; hl=buffer, bc=lenght, de=start address
|
||||
; Write header block
|
||||
ld a,1 ; block type header
|
||||
ld (hl),a
|
||||
inc hl
|
||||
call BYTESTOBLOCKS
|
||||
push bc
|
||||
ld a,b ; nr of blocks low byte
|
||||
ld (hl),a
|
||||
inc hl
|
||||
ld a,c ; nr of blocks high byte
|
||||
ld (hl),a
|
||||
inc hl
|
||||
push hl
|
||||
exx
|
||||
1$: push bc
|
||||
pop hl ; get str addr to hl
|
||||
ld a,(hl)
|
||||
inc hl
|
||||
push hl
|
||||
pop bc ; get str addr+1 back into bc
|
||||
pop hl ; get hl to hl'
|
||||
ld (hl),a ; save character to buffer
|
||||
inc hl
|
||||
push hl
|
||||
dec e ; count down str len
|
||||
cp 0
|
||||
jr nz,1$ ; repeat for the whole string
|
||||
exx
|
||||
pop hl ; get back buffer addr
|
||||
ld a,0 ; NULL terminate string
|
||||
ld (hl),a
|
||||
inc hl
|
||||
; Header block complete (rest of block is accepted garbage)
|
||||
call BIOS_CAS_WRITE_BLOCK
|
||||
|
||||
pop bc ; get back block count
|
||||
pop de ; get back start address
|
||||
|
||||
pop hl
|
||||
pop de
|
||||
pop bc
|
||||
ret
|
||||
|
||||
; -------------------------------------------------------
|
||||
; Convert byte count to required number of 128-byte blocks
|
||||
; needs bc (length in bytes)
|
||||
; returns bc (number of blocks)
|
||||
; uses a
|
||||
; -------------------------------------------------------
|
||||
BYTESTOBLOCKS:
|
||||
ld a,c
|
||||
and 07fh ; remember partial-block remainder
|
||||
|
||||
srl b ; BC = BC / 128
|
||||
rr c
|
||||
srl b
|
||||
rr c
|
||||
srl b
|
||||
rr c
|
||||
srl b
|
||||
rr c
|
||||
srl b
|
||||
rr c
|
||||
srl b
|
||||
rr c
|
||||
srl b
|
||||
rr c
|
||||
|
||||
or a
|
||||
ret z ; exact multiple of 128
|
||||
inc bc ; include partial final block
|
||||
ret
|
||||
|
||||
.end
|
||||
|
||||
Reference in New Issue
Block a user