Added old tape routines and started with cload
This commit is contained in:
+132
-2
@@ -15,6 +15,7 @@
|
||||
; - Unsupported functions cause FCERR, not a reset or REM
|
||||
; - modern backspace handling
|
||||
; - Added DROM/EROM/BANK0/BANK1 commands
|
||||
; - CLOAD
|
||||
;
|
||||
;==================================================================================
|
||||
; The updates to the original BASIC within this file are copyright Grant Searle
|
||||
@@ -423,8 +424,8 @@ WORDTB: .WORD PEND
|
||||
.WORD CONT
|
||||
.WORD LIST
|
||||
.WORD CLEAR
|
||||
.WORD FCERR
|
||||
.WORD FCERR
|
||||
.WORD CLOAD
|
||||
.WORD FCERR ; csave
|
||||
.WORD NEW
|
||||
|
||||
; RESERVED WORD TOKEN VALUES
|
||||
@@ -4543,4 +4544,133 @@ FULLSETTOP:
|
||||
FULLMSG:
|
||||
.BYTE "[FULL MEMORY]",CR,LF,0,0
|
||||
|
||||
CLOAD: ld a,(hl) ; get byte after "CLOAD"
|
||||
cp ZTIMES ; "*" token? ("CLOAD*")
|
||||
jp z,FCERR ; yes - array load (ARRLD1)
|
||||
cp ZPRINT ; "?" ("PRINT token") verify
|
||||
jp z,FCERR ; yes - flag "verify"
|
||||
cp '#' ; 'cload#'?
|
||||
jp z,CLOADB ; yes - load binary
|
||||
; just cload - load basic
|
||||
jp FCERR
|
||||
|
||||
CLOADB: inc hl ; skip #
|
||||
call GETNUM ; evaluate numeric expression
|
||||
call DEINT ; convert FPREG to de
|
||||
; de contains load address
|
||||
; TODO do safety check on address
|
||||
push hl
|
||||
push bc
|
||||
push de
|
||||
|
||||
ld hl,CLSTARTMSG
|
||||
call PRS
|
||||
|
||||
; Load block
|
||||
call CLREADBLOCK
|
||||
; hl contains block, check block type
|
||||
ld a,(hl)
|
||||
cp 1 ; first block needs to be a header
|
||||
jr nz,CLNOHDR ; First block is not a header
|
||||
; first block is a header, get nr of blocks
|
||||
inc hl
|
||||
ld de,(hl)
|
||||
; print number of blocks to load
|
||||
push de
|
||||
push hl
|
||||
ex de,hl
|
||||
call PRNTHL
|
||||
ld hl,CLBLOCKSMSG
|
||||
call PRS
|
||||
pop hl
|
||||
inc hl
|
||||
inc hl ; get filename
|
||||
call PRS ; print filename
|
||||
; de contains the nr of blocks to load
|
||||
; TODO check de>0
|
||||
|
||||
pop de
|
||||
1$: push de ; save repeat counter
|
||||
call CLREADBLOCK ; hl = new data
|
||||
; TODO check block type
|
||||
inc hl ; goto start of data
|
||||
pop de ; get repeat counter
|
||||
push hl ; save stored data
|
||||
|
||||
exx
|
||||
pop hl ; get stored data back
|
||||
pop de ; get destination
|
||||
ld bc,64 ; block size
|
||||
ldir ; copy data to memory
|
||||
push de ; store destination address
|
||||
exx
|
||||
|
||||
dec de
|
||||
ld a,e
|
||||
cp 0
|
||||
jr nz,1$ ; repeat if not done yet
|
||||
ld a,d
|
||||
cp 0
|
||||
jr nz,1$ ; repeat if not done yet
|
||||
|
||||
pop de
|
||||
pop bc
|
||||
pop hl
|
||||
ret
|
||||
|
||||
CLREADBLOCK:
|
||||
call BIOS_CAS_READ_BLOCK
|
||||
jr nc,1$
|
||||
call BIOS_CAS_WAIT_SILENCE
|
||||
call BIOS_CAS_READ_BLOCK
|
||||
push hl
|
||||
jr nc,2$
|
||||
; error, make sure it is silent again
|
||||
push af
|
||||
call BIOS_CAS_WAIT_SILENCE
|
||||
pop af
|
||||
jr CLERR
|
||||
1$: push hl ; save hl
|
||||
call BIOS_CAS_READ_BLOCK_DRY
|
||||
; Ignore errors on this block
|
||||
2$: ; but make sure it is silent again
|
||||
call BIOS_CAS_WAIT_SILENCE
|
||||
pop hl
|
||||
ret
|
||||
; Second block failed as well, error
|
||||
CLERR: cp 1
|
||||
jr z,CLECAL
|
||||
cp 2
|
||||
jr z,CLESYN
|
||||
cp 3
|
||||
jr z,CLERED
|
||||
cp 4
|
||||
jr z,CLECHS
|
||||
jp FCERR ; Unknown error
|
||||
CLECAL: ld hl, CLECALMSG
|
||||
jr CLEPRINT
|
||||
CLESYN: ld hl, CLESYNMSG
|
||||
jr CLEPRINT
|
||||
CLERED: ld hl, CLEREDMSG
|
||||
jr CLEPRINT
|
||||
CLECHS: ld hl, CLECHSMSG
|
||||
jr CLEPRINT
|
||||
CLNOHDR:
|
||||
ld hl,CLNOHDRMSG
|
||||
CLEPRINT:
|
||||
call PRS
|
||||
pop de
|
||||
pop bc
|
||||
pop hl
|
||||
jp FCERR
|
||||
|
||||
CLSTARTMSG: .db "Play tape...",0ah,0dh,00h
|
||||
CLECALMSG: .db "Calibration failed",0ah,0dh,00h
|
||||
CLESYNMSG: .db "Synchronization failed",0ah,0dh,00h
|
||||
CLEREDMSG: .db "Read failed",0ah,0dh,00h
|
||||
CLECHSMSG: .db "Checksum error",0ah,0dh,00h
|
||||
CLNOHDRMSG: .db "No header found", 0ah,0dh,00h
|
||||
CLBLOCKSMSG: .db " blocks to load", 0ah,0dh,00h
|
||||
CLCLRF: .db 0ah,0dh,00h
|
||||
|
||||
.end
|
||||
|
||||
Reference in New Issue
Block a user