From f4cb2a39b34137b49e3c000d9543746408bd7975 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Tue, 16 Jul 2019 17:09:22 +0200 Subject: [PATCH] IEC/IRQ related cleanups --- c64/kernal/iec_turnaround_to_listen.s | 2 -- c64/kernal/iec_tx_byte.s | 3 +-- c64/kernal/iec_tx_command.s | 9 ++------- c64/kernal/iec_tx_common.s | 7 +------ c64/kernal/irq_handler.s | 8 ++++---- c64/kernal/open.s | 3 --- c64/kernal/vector.s | 6 +++--- 7 files changed, 11 insertions(+), 27 deletions(-) diff --git a/c64/kernal/iec_turnaround_to_listen.s b/c64/kernal/iec_turnaround_to_listen.s index f8c6f237..964ef0ed 100644 --- a/c64/kernal/iec_turnaround_to_listen.s +++ b/c64/kernal/iec_turnaround_to_listen.s @@ -17,8 +17,6 @@ iec_turnaround_to_listen: bne - ;; Timeout - jsr printf - .byte "DBG: TURNAROUND FAILED",$0d,$00 sec rts diff --git a/c64/kernal/iec_tx_byte.s b/c64/kernal/iec_tx_byte.s index d7e2e183..946c248d 100644 --- a/c64/kernal/iec_tx_byte.s +++ b/c64/kernal/iec_tx_byte.s @@ -5,8 +5,8 @@ iec_tx_byte: + ;; Store byte to send on the stack pha - php ;; Notify all devices that we are going to send a byte ;; and it is going to be a data byte (released ATN) @@ -15,7 +15,6 @@ iec_tx_byte: ;; Common part of iec_txbyte and iec_tx_common - waits for devices ;; and transmits a byte - plp pla jsr iec_tx_common diff --git a/c64/kernal/iec_tx_command.s b/c64/kernal/iec_tx_command.s index f68764e5..7cde1dce 100644 --- a/c64/kernal/iec_tx_command.s +++ b/c64/kernal/iec_tx_command.s @@ -3,6 +3,7 @@ iec_tx_command: + ;; Store command to send on the stack pha ;; Notify all devices that we are going to send a byte @@ -20,9 +21,6 @@ iec_tx_command: ;; No devices present on the bus, so we can immediately return with device not found pla - jsr printf - .byte "DBG: NO DEVICES AT ALL", $0D, 0 - jsr iec_set_idle jmp kernalerror_DEVICE_NOT_FOUND * @@ -47,14 +45,11 @@ iec_tx_command: lda CI2PRA and #BIT_CI2PRA_DAT_IN ; XXX try to optimize this, move to separate routine beq + - + ;; XXX possible optimization of the flow above: for many commands it is enough ;; to wait for the DATA being pulled, as confirmation is expected from ;; a single device only - but not sure if it's worth the trouble - jsr printf - .byte "DBG: NO CONFIRMATION FROM DEVICE", $0D, 0 - jsr iec_set_idle jmp kernalerror_DEVICE_NOT_FOUND * diff --git a/c64/kernal/iec_tx_common.s b/c64/kernal/iec_tx_common.s index eb1ba991..8de7c891 100644 --- a/c64/kernal/iec_tx_common.s +++ b/c64/kernal/iec_tx_common.s @@ -7,16 +7,11 @@ iec_tx_common: ;; Store the byte to send on a stack pha - - ;; Store the status register - carry flag is used to determine whether - ;; this is the last byte of the stream - php - + ;; Wait till all receivers are ready, they should all release DATA jsr iec_wait_for_data_release ;; At this point a delay 256 usec or more is considered EOI - add waits if necessary - plp bcc + jsr iec_wait100us jsr iec_wait100us diff --git a/c64/kernal/irq_handler.s b/c64/kernal/irq_handler.s index 1b8b4730..82bbaac7 100644 --- a/c64/kernal/irq_handler.s +++ b/c64/kernal/irq_handler.s @@ -6,7 +6,7 @@ irq_handler: ;; $EA61 - Check keyboard, but don't update timer? https://github.com/cc65/cc65/issues/324 ;; $EA81 - https://www.lemon64.com/forum/viewtopic.php?t=2112&sid=6ea01982b26da69783120a7923ca46fb ;; Also the $0314 vector is widely used (e.g., https://www.lemon64.com/forum/viewtopic.php?t=2112&sid=6ea01982b26da69783120a7923ca46fb) - + ;; Save registers ;; Sequence according to Compute's Mapping the 64 p73 pha @@ -17,7 +17,7 @@ irq_handler: ;; Call interrupt routine ;; (but only if initialised) - lda $0314 - ora $0315 + lda CINV + ora CINV+1 beq default_irq_handler - jmp ($0314) + jmp (CINV) diff --git a/c64/kernal/open.s b/c64/kernal/open.s index e10ea78e..7875943b 100644 --- a/c64/kernal/open.s +++ b/c64/kernal/open.s @@ -95,9 +95,6 @@ open_iec: jsr iec_turnaround_to_listen bcs open_iec_error - jsr printf - .byte "DBG: TURNAROUND SUCCEEDED", $0D, 0 - ;; Indicate success lda #$00 clc diff --git a/c64/kernal/vector.s b/c64/kernal/vector.s index 2a8c6e5d..027bf14a 100644 --- a/c64/kernal/vector.s +++ b/c64/kernal/vector.s @@ -61,9 +61,9 @@ vector_restore: ;; XXX below we have quite a lot of data... should we decouple them? vector_defaults: - .word $0000 ;; CINV XXX implement this - .word $0000 ;; CBINV XXX implement this - .word $0000 ;; NMINV XXX implement this + .word default_irq_handler ;; CINV + .word $0000 ;; CBINV XXX implement this + .word $0000 ;; NMINV XXX implement this .word open ;; IOPEN .word close ;; ICLOSE