Here it is. It seems pretty straightforward to me, and as long as you don't STOP in the middle of a save or load, it works perfectly and repetitively. Once you hit STOP during save or load, it's like it returns to another part of the code. It never even
gets to the inc SCRCOL ($900f) code. Stepping through with VICE's monitor, the monitor totally loses track of what's going on and the monitor locks up.
Code: Select all
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; TAPE SAVE/LOAD
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
TapeSave: jsr TapeSetup ; Set up tape
beq TapeCancel ; STOP was pressed
lda #4 ; Filename is the current four-digit year,
ldx #<SCREEN+40 ; which can be scraped from the screen
ldy #>SCREEN+40 ; ,,
jsr SETNAM ; ,,
ldx #1 ; Device number
ldy #0 ; Command
jsr SETLFS ; ,,
ldx #<SCREEN ; Low byte start
stx $2b ; ,,
ldy #>SCREEN ; High byte start
sty $2c ; ,,
lda #$2b ; Set tab
iny ; 512 bytes
iny ; ,,
jsr SAVE ; SAVE
TapeClnup: inc SCRCOL ; Put color back to green border (from red)
inc SCRCOL ; ,,
inc SCRCOL ; ,,
TapeCancel: inc SCRCOL ; Put color back to blue border (from green)
jsr MusicPlay ; Restart music
lsr ACTION_FL ; Turn off Action flag
jmp cancel ; Return from tape operation cancels Action
; Tape Load
TapeLoad: jsr TapeSetup ; Set up tape
beq TapeCancel ; STOP was pressed
lda #0 ; Get whatever the next file is
jsr SETNAM ; ,,
ldx #1 ; Tape device number
ldy #1 ; Load to header location
jsr SETLFS ; ,,
lda #$00 ; Command for LOAD
jsr LOAD ; ,,
ldx #0 ; Preserve whatever came from the load
lda (PTR,x) ; under the Cursor
sta UNDER ; ,,
jsr Roads ; Re-colorize the world
jmp TapeClnup ; Clean up the operation
; Tape Setup
; - Removes the Cursor from the screen
; - Stops music
; - Changes screen border color to green
; - Waits for tape button activation or STOP
; Returns with Z=1 if operation is canceled
TapeSetup: lda UNDER ; Clear the Cursor out of the way
jsr Place ; ,,
jsr MusicStop ; Stop music during tape
dec SCRCOL ; Change screen border
-wait: jsr CS10 ; Check for Record/Play
beq rolling ; ,,
lda KEYDOWN ; Check for Stop key
cmp #$18 ; ,,
bne wait ; ,,
rts ; Return from caller with Z=1
rolling: dec SCRCOL ; Set screen color to red border
dec SCRCOL ; ,,
dec SCRCOL ; ,,
rts ; Return from caller with Z=0