]> git.sur5r.net Git - cc65/blob - libsrc/c128/mou/callback.inc
Back-migrated some phantom-key rejection optimizations.
[cc65] / libsrc / c128 / mou / callback.inc
1 ;
2 ; Callback routine called from the IRQ handler after the ROM IRQ handler
3 ; had been run.
4 ;
5 ; Christian Groessler, 24.04.2014
6 ;
7 ; Check if there was button/joystick activity before and/or after the ROM handler.
8 ; If there was activity, discard the key presses since they are most
9 ; probably "phantom" key presses.
10
11 callback:
12         ldx     old_key_count
13         cpx     KEY_COUNT
14         beq     @nokey
15
16         lda     OLD_BUTTONS             ; keypress before?
17         bne     @discard_key            ; yes, discard key
18
19         lda     #$7F
20         sta     CIA1_PRA
21         lda     CIA1_PRB                ; Read joystick #0
22         and     #$1F
23         eor     #$1F                    ; keypress after
24         beq     @nokey                  ; no, probably a real key press
25
26 @discard_key:
27         stx     KEY_COUNT               ; set old keyboard buffer fill level
28
29 @nokey: rts