small LOAD cleanup
This commit is contained in:
1 parent
05253c3e92
commit
3d9e713f07
20 files changed
+98
-84
No files matched your search
@@ -5,18 +5,27 @@
|
||||
// Preserves .A, .X and .Y
|
||||
//
|
||||
|
||||
iec_check_devnum:
|
||||
// 0, 1, 2, or 3 are illegal - reserved for non-IEC devices on Commodore
|
||||
cmp #$04
|
||||
|
||||
iec_check_devnum_lvs: // for load/verify/save
|
||||
|
||||
cmp #$08 // below 8 are illegal for load/save
|
||||
bcs !+
|
||||
|
||||
// FALLTROUGH
|
||||
|
||||
iec_check_devnum_oc: // for open/close
|
||||
|
||||
cmp #$04 // below 4 are illegal, reserved for non-IEC devices on Commodore
|
||||
bcs !+
|
||||
|
||||
// FALLTROUGH
|
||||
|
||||
iec_check_devnum_failed:
|
||||
sec // indicate non-IEC device
|
||||
rts
|
||||
|
||||
!:
|
||||
// 31 and above are illegal too, due to IEC command encoding scheme,
|
||||
// see https://www.pagetable.com/?p=1031
|
||||
cmp #$1F
|
||||
bcs iec_check_devnum_failed
|
||||
// Carry is clear here - indicates IEC device
|
||||
cmp #$1F // sets carry for 31 or above
|
||||
rts
|
||||
@@ -17,7 +17,7 @@ LISTEN:
|
||||
jsr iec_tx_flush
|
||||
|
||||
// Check whether device number is correct
|
||||
jsr iec_check_devnum
|
||||
jsr iec_check_devnum_oc
|
||||
bcc !+
|
||||
jmp kernalerror_DEVICE_NOT_FOUND
|
||||
!:
|
||||
@@ -25,6 +25,3 @@ LISTEN:
|
||||
ora #$20
|
||||
|
||||
jmp common_talk_listen
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
|
||||
//
|
||||
// IEC part of the LOAD routine
|
||||
//
|
||||
|
||||
|
||||
load_iec:
|
||||
|
||||
// Display SEARCHING FOR + filename
|
||||
jsr lvs_display_searching_for
|
||||
|
||||
// http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf
|
||||
// p13, 16; also p16 tells us this routine does not mess with the file
|
||||
// table in the C64, only in the drive.
|
||||
|
||||
// Call device to LISTEN (p16)
|
||||
lda FA
|
||||
jsr LISTEN
|
||||
bcc !+
|
||||
jmp lvs_device_not_found_error // XXX deduplicate with other jumps in this routine
|
||||
!:
|
||||
// Open channel 0 (reserved for file reading)
|
||||
lda #$00
|
||||
jsr iec_cmd_open
|
||||
bcc !+
|
||||
jmp lvs_device_not_found_error // XXX deduplicate with other jumps in this routine
|
||||
!:
|
||||
// Send file name
|
||||
jsr lvs_send_file_name
|
||||
bcc !+
|
||||
jmp lvs_load_verify_error // XXX deduplicate with other jumps in this routine
|
||||
!:
|
||||
// Now command device to talk (p16)
|
||||
lda FA
|
||||
jsr TALK
|
||||
bcc !+
|
||||
jmp lvs_load_verify_error // XXX deduplicate with other jumps in this routine
|
||||
!:
|
||||
lda #$60 // open channel / data (p3) , required according to p13
|
||||
sta TBTCNT
|
||||
jsr iec_tx_command
|
||||
bcc !+
|
||||
jmp lvs_load_verify_error // XXX deduplicate with other jumps in this routine
|
||||
!:
|
||||
// We are currently talker, so do the IEC turn around so that we
|
||||
// are the listener (p16)
|
||||
jsr iec_turnaround_to_listen
|
||||
bcc !+
|
||||
jmp lvs_load_verify_error // XXX deduplicate with other jumps in this routine
|
||||
!:
|
||||
// Get load address and store it if secondary address is zero
|
||||
jsr iec_rx_byte
|
||||
bcc !+
|
||||
jmp kernalerror_FILE_NOT_FOUND // XXX deduplicate with other jumps in this routine
|
||||
!:
|
||||
ldx SA
|
||||
beq !+
|
||||
sta STAL+0
|
||||
!:
|
||||
jsr iec_rx_byte
|
||||
bcc !+
|
||||
jmp kernalerror_FILE_NOT_FOUND // XXX deduplicate with other jumps in this routine
|
||||
!:
|
||||
ldx SA
|
||||
beq !+
|
||||
sta STAL+1
|
||||
!:
|
||||
// Display start address
|
||||
jsr lvs_display_loading_verifying
|
||||
|
||||
iec_load_loop:
|
||||
// We are now ready to receive bytes
|
||||
jsr iec_rx_byte
|
||||
bcc !+
|
||||
jmp lvs_load_verify_error // XXX deduplicate with other jumps in this routine
|
||||
!:
|
||||
// Handle the byte (store in memory / verify)
|
||||
jsr lvs_handle_byte_load_verify
|
||||
bcc !+
|
||||
jmp lvs_load_verify_error // XXX deduplicate with other jumps in this routine
|
||||
!:
|
||||
// Advance pointer to data
|
||||
jsr lvs_advance_pointer
|
||||
bcc !+
|
||||
jmp lvs_wrap_around_error
|
||||
!:
|
||||
// Check for EOI - if so, this was the last byte
|
||||
lda IOSTATUS
|
||||
and #K_STS_EOI
|
||||
beq iec_load_loop
|
||||
|
||||
// Display end address
|
||||
jsr lvs_display_done
|
||||
|
||||
// Close file on drive
|
||||
|
||||
lda FA
|
||||
jsr close_load
|
||||
|
||||
// Return last address
|
||||
jmp lvs_return_last_address
|
||||
@@ -17,7 +17,7 @@ TALK:
|
||||
jsr iec_tx_flush
|
||||
|
||||
// Check whether device number is correct
|
||||
jsr iec_check_devnum
|
||||
jsr iec_check_devnum_oc
|
||||
bcc !+
|
||||
jmp kernalerror_DEVICE_NOT_FOUND
|
||||
!:
|
||||
@@ -28,5 +28,3 @@ common_talk_listen: // common part of TALK and LISTEN
|
||||
|
||||
sta TBTCNT
|
||||
jmp iec_tx_command
|
||||
|
||||
|
||||
Reference in new issue
Block a user