From 9908c4e62adf4b9256e358d82b57789e2bcfd494 Mon Sep 17 00:00:00 2001 From: Paul Gardner-Stephen Date: Fri, 19 Apr 2019 23:11:32 +0930 Subject: [PATCH] begin implementing IRQ framework --- c64/kernal/ea81.s | 17 +++++++++++++++++ c64/kernal/irq_handler.s | 26 ++++++++++++++++++++++++-- 2 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 c64/kernal/ea81.s diff --git a/c64/kernal/ea81.s b/c64/kernal/ea81.s new file mode 100644 index 00000000..431b65f0 --- /dev/null +++ b/c64/kernal/ea81.s @@ -0,0 +1,17 @@ + ;; The IRQ is a commonly messed with thing on the C64, + ;; so we need to handle entry points that are commonly + ;; relied upon, including: + ;; $EA31 - Standard IRQ routine + ;; $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) + +return_from_interrupt: + ;; Restore registers and return + pla + tay + pla + tax + pla + rti + diff --git a/c64/kernal/irq_handler.s b/c64/kernal/irq_handler.s index 34ba895b..7a1f9baf 100644 --- a/c64/kernal/irq_handler.s +++ b/c64/kernal/irq_handler.s @@ -1,3 +1,25 @@ irq_handler: - inc $d020 - rti + ;; The IRQ is a commonly messed with thing on the C64, + ;; so we need to handle entry points that are commonly + ;; relied upon, including: + ;; $EA31 - Standard IRQ routine + ;; $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 + pha + txa + pha + tya + pha + + ;; Call interrupt routine + ;; (but only if initialised) + lda $0314 + ora $0315 + beq no_handler_installed + jmp ($0314) +no_handler_installed: + + jmp return_from_interrupt