Mercurial > hg > index.cgi
diff src/irq.s @ 73:2d52cd154ed1
Split some code into separate files for easier management
Because the source for lwbasic is so large, split it into several
different files to make it easier to navigate and modify. This is
part one of the split.
author | William Astle <lost@l-w.ca> |
---|---|
date | Sun, 06 Aug 2023 00:12:29 -0600 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/irq.s Sun Aug 06 00:12:29 2023 -0600 @@ -0,0 +1,51 @@ + *pragmapush list + *pragma nolist +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; IRQ handler +; +; Note that the interrupt flag in the PIA is cleared at the start of the interrupt handler. That means that if it takes +; a long time to process this interrupt, or processing this interrupt was delayed somewhat, it is far less likely that +; an interrupt gets missed. In that case, we may end up re-interrupting immediately on RTI, but it should reduce the +; number of missed interrupts. +irqhandler lda PIA0.CB ; was it VSYNC? + bmi irqhandler0 ; brif so + lda PIA0.DA ; clear HSYNC flag so we don't get stuck if it gets enabled + ifdef COCO3 + lda GIME.IRQ ; clear GIME IRQ state flags + endc + rti +irqhandler0 lda PIA0.DB ; clear VSYNC flag + clra ; make sure DP is pointing to the right place + tfr a,dp + lda console_blnkdel ; is the cursor blinking? + beq irqhandler1 ; brif not + dec console_blnkdel ; time to cycle cursor? + bne irqhandler1 ; brif not + lda #console_curdel ; reset blink counter + sta console_blnkdel + lda [console_curptr] ; get character at cursor + adda #0x10 ; move to next colour + ora #0x8f ; force it to be a full 4x4 colour block + sta [console_curptr] ; update cursor on screen +irqhandler1 jsr keyb_read ; go handle the keyboard + rti +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; FIRQ handler +; +; This handler is present to prevent accidentally enabling the interrupt and thus hanging to system. It may seem to be +; a waste of code space, but consider it a self defense situation. +firqhandler pshs a ; need a scratch register + ifdef COCO3 + lda GIME.FIRQ ; clear GIME FIRQ state flags + endc + lda PIA1.DA ; clear interrupt flags + lda PIA1.DB + lda PIA1.CA ; disable interrupts to prevent system hang + anda #0xfe + sta PIA1.CA + lda PIA1.CB + anda #0xfe + sta PIA1.CB + puls a ; restore register + rti + *pragmapop list