comparison 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
comparison
equal deleted inserted replaced
72:f492fa6f6dc8 73:2d52cd154ed1
1 *pragmapush list
2 *pragma nolist
3 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4 ; IRQ handler
5 ;
6 ; Note that the interrupt flag in the PIA is cleared at the start of the interrupt handler. That means that if it takes
7 ; a long time to process this interrupt, or processing this interrupt was delayed somewhat, it is far less likely that
8 ; an interrupt gets missed. In that case, we may end up re-interrupting immediately on RTI, but it should reduce the
9 ; number of missed interrupts.
10 irqhandler lda PIA0.CB ; was it VSYNC?
11 bmi irqhandler0 ; brif so
12 lda PIA0.DA ; clear HSYNC flag so we don't get stuck if it gets enabled
13 ifdef COCO3
14 lda GIME.IRQ ; clear GIME IRQ state flags
15 endc
16 rti
17 irqhandler0 lda PIA0.DB ; clear VSYNC flag
18 clra ; make sure DP is pointing to the right place
19 tfr a,dp
20 lda console_blnkdel ; is the cursor blinking?
21 beq irqhandler1 ; brif not
22 dec console_blnkdel ; time to cycle cursor?
23 bne irqhandler1 ; brif not
24 lda #console_curdel ; reset blink counter
25 sta console_blnkdel
26 lda [console_curptr] ; get character at cursor
27 adda #0x10 ; move to next colour
28 ora #0x8f ; force it to be a full 4x4 colour block
29 sta [console_curptr] ; update cursor on screen
30 irqhandler1 jsr keyb_read ; go handle the keyboard
31 rti
32 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
33 ; FIRQ handler
34 ;
35 ; This handler is present to prevent accidentally enabling the interrupt and thus hanging to system. It may seem to be
36 ; a waste of code space, but consider it a self defense situation.
37 firqhandler pshs a ; need a scratch register
38 ifdef COCO3
39 lda GIME.FIRQ ; clear GIME FIRQ state flags
40 endc
41 lda PIA1.DA ; clear interrupt flags
42 lda PIA1.DB
43 lda PIA1.CA ; disable interrupts to prevent system hang
44 anda #0xfe
45 sta PIA1.CA
46 lda PIA1.CB
47 anda #0xfe
48 sta PIA1.CB
49 puls a ; restore register
50 rti
51 *pragmapop list