From 6bf715e610a32a517d80851a805102764e19c0e0 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Wed, 17 Jul 2019 21:56:42 +0200 Subject: [PATCH] IEC routines can now be called with enabled IRQs --- c64/kernal/iec_rx_byte.s | 6 ++++++ c64/kernal/iec_tx_common.s | 5 +++++ c64/kernal/load.s | 12 +++--------- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/c64/kernal/iec_rx_byte.s b/c64/kernal/iec_rx_byte.s index d91a857d..4a7eb996 100644 --- a/c64/kernal/iec_rx_byte.s +++ b/c64/kernal/iec_rx_byte.s @@ -4,6 +4,10 @@ iec_rx_byte: + ;; Timing is critical here - execute on disabled IRQs + php + sei + ;; First, we wait for the talker to release the CLK line jsr iec_wait_for_clk_release @@ -95,6 +99,7 @@ iec_rx_clk_wait2: ;; Timeout jsr kernalstatus_EOI pla + plp sec ; XXX confirm that sec is really a way to report timeout here rts * @@ -112,6 +117,7 @@ iec_rx_clk_wait2: pla ;; Return no-error + plp clc rts diff --git a/c64/kernal/iec_tx_common.s b/c64/kernal/iec_tx_common.s index 8de7c891..ef9a5097 100644 --- a/c64/kernal/iec_tx_common.s +++ b/c64/kernal/iec_tx_common.s @@ -5,6 +5,10 @@ iec_tx_common: + ;; Timing is critical here - execute on disabled IRQs + php + sei + ;; Store the byte to send on a stack pha @@ -64,6 +68,7 @@ iec_tx_common_bit_is_sent: bpl iec_tx_common_nextbit pla + plp rts ; Flow continues differently for data/command iec_tx_common_nextbit: diff --git a/c64/kernal/load.s b/c64/kernal/load.s index d9097d95..e075180d 100644 --- a/c64/kernal/load.s +++ b/c64/kernal/load.s @@ -33,9 +33,6 @@ load: ;; We need our helpers to get to filenames under ROMs or IO area jsr install_ram_routines - - ;; Disable IRQs, since timing matters! - sei ;; Display SEARCHING FOR + filename lda MSGFLG @@ -162,12 +159,15 @@ load_loop: ;; to do the memory access ;; Save byte under ROMs and IO if required + php + sei ldx #$33 stx $01 ldy #0 sta (load_save_start_ptr),y ldx #$37 stx $01 + plp ;; Advance pointer inc load_save_start_ptr @@ -221,34 +221,28 @@ load_done: ldy load_save_start_ptr+1 clc - cli rts load_wrap_around_error: ;; This error is probably not even detected by C64 Kernal; ;; report BASIC error code that looks the most sane - cli lda #B_ERR_OVERFLOW sec rts - rts load_device_not_found_error: - cli jsr kernalstatus_DEVICE_NOT_FOUND jmp kernalerror_DEVICE_NOT_FOUND load_file_not_found_error: - cli jmp kernalerror_FILE_NOT_FOUND load_error: ;; XXX should we really return BASIC error code here? - cli lda kernal_load_or_verify_flag beq load_verify_error lda #B_ERR_LOAD