2 ; Pointer for library references by device drivers.
4 ; Helper-routines for the interrupt handler that rejects bogus keypresses
5 ; that are caused by mouse-like devices.
7 ; 2013-07-25, Greg King
8 ; 2014-04-26, Christian Groessler
13 .export mouse_libref, _pen_adjuster
17 mouse_libref: ; generic label for mouse-kernel
19 ; A program optionally can set this pointer to a function that gives
20 ; a calibration value to a driver. If this pointer isn't NULL,
21 ; then a driver that wants a value can call that function.
23 ; The function might read a value from a file; or, it might ask the user
24 ; to help calibrate the driver.
26 ; void __fastcall__ (*pen_adjuster)(unsigned char *) = NULL;
32 callback: ; callback into mouse driver after ROM IRQ handler has been run
33 .addr $0000 ; (filled in by mouse driver)
34 jmp_rom_hdlr: ; original ROM indirect IRQ handler address
35 .addr $0000 ; (filled in by mouse driver)
40 ; Called from irq.s when it thinks it chains to the original handler.
41 ; ROM is banked in again. In order to call the callback we have to
42 ; bank it out one more time.
46 ; Call ROM handler and prepare stack so that it will return to us.
48 ; setup fake IRQ stack frame which will return to "IRQCont"
55 ; mimic the contents saved on the stack by the ROM IRQ entry handler
59 lda #MMU_CFG_CC65 ; MMU configuration which will be active after the ROM handler returns
66 ; push address of ROM handler on stack and jump to it
72 sty MMU_CR ; map in ROM
73 rts ; jump to ROM handler
75 ; our MMU configuration byte we pushed on the stack before (MMU_CFG_CC65) is now active
79 ; call mouse driver callback routine
88 rts ; jump to callback routine
92 ; return from interrupt
93 ; We could just jump to $FF33, but since I don't know whether this address is valid in all
94 ; ROM versions, duplicate that code here.
97 sta MMU_CR ; MMU configuration register