various LOAD improvements

This commit is contained in:
FeralChild64 committed 2019-11-01 13:10:39 +01:00
1 parent e145bb6c86
commit 982b287e92
8 files changed
+232 -64

No files matched your search

+167 -14
View File
@@ -7,6 +7,10 @@
#if CONFIG_TAPE_NORMAL || CONFIG_TAPE_TURBO
//
// Check if VERIFY asked - if yes, terminate loading
//
tape_ditch_verify:
lda VERCKK
@@ -18,24 +22,52 @@ tape_ditch_verify:
jmp lvs_device_not_found_error
//
// Handle tape deck motor
//
tape_motor_off:
lda CPU_R6510
ora #$20
sta CPU_R6510
rts
bne !+ // branch always
tape_motor_on:
lda CPU_R6510
and #($FF - $20)
!:
sta CPU_R6510
rts
//
// Handle screen (visible/blanked) + tape deck motor (on/off),
// store/restore screen color
//
tape_screen_show_motor_off:
jsr tape_motor_off
lda COLSTORE
sta VIC_EXTCOL
jmp screen_show
tape_screen_hide_motor_on:
lda VIC_EXTCOL
sta COLSTORE
jsr screen_blank
jmp tape_motor_on
//
// Ask user to press PLAY on tape deck,
// Unless user cancelled loading, blank screen and start motor
//
tape_ask_play:
sei // timing is critical for tape loading
@@ -45,9 +77,18 @@ tape_ask_play:
ldx #__MSG_KERNAL_PRESS_PLAY
jsr print_kernal_message
// Clean the SID registers, we need it for sound effects
lda #$00
ldy #$1C
!:
sta __SID_BASE, y
dey
bpl !-
// FALLTROUGH
tape_wait_button_loop:
tape_wait_play_loop:
jsr udtim_keyboard
jsr STOP
@@ -61,27 +102,139 @@ tape_wait_button_loop:
!:
lda CPU_R6510
and #$10 // check for pressed button
bne tape_wait_button_loop
bne tape_wait_play_loop
jsr screen_blank
jsr tape_motor_on
jmp tape_screen_hide_motor_on
//
// Handle file header - display it, decide whether load the file or not, etc.
//
tape_handle_header:
jsr tape_screen_show_motor_off
// Header structure described here:
// - https://www.luigidifraia.com/c64/docs/tapeloaders.html#turbotape64
//
// 1 byte - file type (0 = data, odd value = relocatable, even value = non-relocatable)
// 2 bytes - start address
// 2 bytes - end address + 1
// 1 byte - if $0B (tape timing) contained at the time of saving XXX handle this
// 16 bytes - filename, padded with 0x20
//
// Out tape buffer contains header in reversed order
// Print FOUND + file name
ldx #__MSG_KERNAL_FOUND
jsr print_kernal_message
ldy #$10
!:
lda (TAPE1), y
jsr JCHROUT
dey
bpl !-
jsr print_return
// Header, wait for user decision
jsr tape_header_get_decision
bcs tape_handle_header_skip
// XXX Perform filename matching
// Setup STAL and EAL
ldy #$15
lda (TAPE1), y
sta STAL+0
dey
lda (TAPE1), y
sta STAL+1
dey
lda (TAPE1), y
sta EAL+0
dey
lda (TAPE1), y
sta EAL+1
// Print LOADING
jsr lvs_display_loading_verifying
// Load the file
jsr tape_screen_hide_motor_on
clc
rts
tape_handle_header_skip:
// Skip this file
jsr tape_screen_hide_motor_on
sec
rts
//
// Get user decision whether to load the file or not
//
tape_header_get_decision:
ldy #$00
!:
jsr udtim_keyboard
lda STKEY
bpl tape_header_wait_stop // STOP pressed
and #$10
beq tape_header_wait_space // space pressed
ldx #$80
jsr wait_x_bars // sets .X to 0
dex
jsr wait_x_bars
dey
bne !-
// FALLTROUGH - timeout
tape_header_wait_space:
clc
rts
tape_header_wait_stop:
sec
rts
//
// Report that file loading succeeded (or not)
//
tape_load_success:
jsr screen_show
jsr tape_motor_off
jsr tape_screen_show_motor_off
jsr lvs_display_done
cli
jmp lvs_success_end
tape_load_error:
jsr screen_show
jsr tape_motor_off
jsr tape_screen_show_motor_off
cli
jmp lvs_load_verify_error