Correctly map out ROM when needed in the "phantom keys" workaround.
This commit is contained in:
parent
54be6de9bc
commit
6307815ada
3 changed files with 55 additions and 33 deletions
|
@ -66,15 +66,6 @@ CMOVEY: jmp $0000 ; Move the cursor to Y coord
|
||||||
SCREEN_HEIGHT = 200
|
SCREEN_HEIGHT = 200
|
||||||
SCREEN_WIDTH = 320
|
SCREEN_WIDTH = 320
|
||||||
|
|
||||||
;----------------------------------------------------------------------------
|
|
||||||
; data segment
|
|
||||||
|
|
||||||
.data
|
|
||||||
|
|
||||||
chainIRQ:
|
|
||||||
.byte $4c ; JMP opcode
|
|
||||||
.word 0 ; pointer to ROM IRQ handler (will be set at runtime)
|
|
||||||
|
|
||||||
;----------------------------------------------------------------------------
|
;----------------------------------------------------------------------------
|
||||||
; Global variables. The bounding box values are sorted so that they can be
|
; Global variables. The bounding box values are sorted so that they can be
|
||||||
; written with the least effort in the SETBOX and GETBOX routines, so don't
|
; written with the least effort in the SETBOX and GETBOX routines, so don't
|
||||||
|
@ -103,6 +94,10 @@ Buttons: .res 1 ; Button mask
|
||||||
|
|
||||||
old_key_count: .res 1
|
old_key_count: .res 1
|
||||||
|
|
||||||
|
; original IRQ vector
|
||||||
|
|
||||||
|
old_irq: .res 2
|
||||||
|
|
||||||
.rodata
|
.rodata
|
||||||
|
|
||||||
; Default values for above variables
|
; Default values for above variables
|
||||||
|
@ -158,20 +153,27 @@ INSTALL:
|
||||||
|
|
||||||
; Initialize our IRQ magic
|
; Initialize our IRQ magic
|
||||||
|
|
||||||
lda IRQInd+1
|
; remember ROM IRQ continuation address
|
||||||
sta chainIRQ+1
|
|
||||||
lda IRQInd+2
|
lda IRQInd+2
|
||||||
sta chainIRQ+2
|
sta old_irq+1
|
||||||
|
lda IRQInd+1
|
||||||
|
sta old_irq
|
||||||
|
|
||||||
lda libref
|
lda libref
|
||||||
sta ptr3
|
sta ptr3
|
||||||
lda libref+1
|
lda libref+1
|
||||||
sta ptr3+1
|
sta ptr3+1
|
||||||
|
|
||||||
|
; set ROM IRQ continuation address to point to the provided routine
|
||||||
ldy #2
|
ldy #2
|
||||||
lda (ptr3),y
|
lda (ptr3),y
|
||||||
sta IRQInd+1
|
sta IRQInd+1
|
||||||
iny
|
iny
|
||||||
lda (ptr3),y
|
lda (ptr3),y
|
||||||
sta IRQInd+2
|
sta IRQInd+2
|
||||||
|
|
||||||
|
; set address of our IRQ callback routine
|
||||||
|
; since it's called via "rts" we have to use "address-1"
|
||||||
iny
|
iny
|
||||||
lda #<(callback-1)
|
lda #<(callback-1)
|
||||||
sta (ptr3),y
|
sta (ptr3),y
|
||||||
|
@ -179,10 +181,16 @@ INSTALL:
|
||||||
lda #>(callback-1)
|
lda #>(callback-1)
|
||||||
sta (ptr3),y
|
sta (ptr3),y
|
||||||
iny
|
iny
|
||||||
lda #<(chainIRQ-1)
|
|
||||||
|
; set ROM entry point vector
|
||||||
|
; since it's called via "rts" we have to decrement it by one
|
||||||
|
lda old_irq
|
||||||
|
sec
|
||||||
|
sbc #1
|
||||||
sta (ptr3),y
|
sta (ptr3),y
|
||||||
iny
|
iny
|
||||||
lda #>(chainIRQ-1)
|
lda old_irq+1
|
||||||
|
sbc #0
|
||||||
sta (ptr3),y
|
sta (ptr3),y
|
||||||
cli
|
cli
|
||||||
|
|
||||||
|
@ -197,10 +205,10 @@ INSTALL:
|
||||||
; No return code required (the driver is removed from memory on return).
|
; No return code required (the driver is removed from memory on return).
|
||||||
|
|
||||||
UNINSTALL:
|
UNINSTALL:
|
||||||
lda chainIRQ+1
|
lda old_irq
|
||||||
sei
|
sei
|
||||||
sta IRQInd+1
|
sta IRQInd+1
|
||||||
lda chainIRQ+2
|
lda old_irq+1
|
||||||
sta IRQInd+2
|
sta IRQInd+2
|
||||||
cli
|
cli
|
||||||
|
|
||||||
|
|
|
@ -73,15 +73,6 @@ SCREEN_WIDTH = 320
|
||||||
FIRE = $10
|
FIRE = $10
|
||||||
.endenum
|
.endenum
|
||||||
|
|
||||||
;----------------------------------------------------------------------------
|
|
||||||
; data segment
|
|
||||||
|
|
||||||
.data
|
|
||||||
|
|
||||||
chainIRQ:
|
|
||||||
.byte $4c ; JMP opcode
|
|
||||||
.word 0 ; pointer to ROM IRQ handler (will be set at runtime)
|
|
||||||
|
|
||||||
;----------------------------------------------------------------------------
|
;----------------------------------------------------------------------------
|
||||||
; Global variables. The bounding box values are sorted so that they can be
|
; Global variables. The bounding box values are sorted so that they can be
|
||||||
; written with the least effort in the SETBOX and GETBOX routines, so don't
|
; written with the least effort in the SETBOX and GETBOX routines, so don't
|
||||||
|
@ -108,6 +99,10 @@ Temp: .res 1
|
||||||
|
|
||||||
old_key_count: .res 1
|
old_key_count: .res 1
|
||||||
|
|
||||||
|
; original IRQ vector
|
||||||
|
|
||||||
|
old_irq: .res 2
|
||||||
|
|
||||||
.rodata
|
.rodata
|
||||||
|
|
||||||
; Default values for above variables
|
; Default values for above variables
|
||||||
|
@ -163,20 +158,27 @@ INSTALL:
|
||||||
|
|
||||||
; Initialize our IRQ magic
|
; Initialize our IRQ magic
|
||||||
|
|
||||||
lda IRQInd+1
|
; remember ROM IRQ continuation address
|
||||||
sta chainIRQ+1
|
|
||||||
lda IRQInd+2
|
lda IRQInd+2
|
||||||
sta chainIRQ+2
|
sta old_irq+1
|
||||||
|
lda IRQInd+1
|
||||||
|
sta old_irq
|
||||||
|
|
||||||
lda libref
|
lda libref
|
||||||
sta ptr3
|
sta ptr3
|
||||||
lda libref+1
|
lda libref+1
|
||||||
sta ptr3+1
|
sta ptr3+1
|
||||||
|
|
||||||
|
; set ROM IRQ continuation address to point to the provided routine
|
||||||
ldy #2
|
ldy #2
|
||||||
lda (ptr3),y
|
lda (ptr3),y
|
||||||
sta IRQInd+1
|
sta IRQInd+1
|
||||||
iny
|
iny
|
||||||
lda (ptr3),y
|
lda (ptr3),y
|
||||||
sta IRQInd+2
|
sta IRQInd+2
|
||||||
|
|
||||||
|
; set address of our IRQ callback routine
|
||||||
|
; since it's called via "rts" we have to use "address-1"
|
||||||
iny
|
iny
|
||||||
lda #<(callback-1)
|
lda #<(callback-1)
|
||||||
sta (ptr3),y
|
sta (ptr3),y
|
||||||
|
@ -184,10 +186,16 @@ INSTALL:
|
||||||
lda #>(callback-1)
|
lda #>(callback-1)
|
||||||
sta (ptr3),y
|
sta (ptr3),y
|
||||||
iny
|
iny
|
||||||
lda #<(chainIRQ-1)
|
|
||||||
|
; set ROM entry point vector
|
||||||
|
; since it's called via "rts" we have to decrement it by one
|
||||||
|
lda old_irq
|
||||||
|
sec
|
||||||
|
sbc #1
|
||||||
sta (ptr3),y
|
sta (ptr3),y
|
||||||
iny
|
iny
|
||||||
lda #>(chainIRQ-1)
|
lda old_irq+1
|
||||||
|
sbc #0
|
||||||
sta (ptr3),y
|
sta (ptr3),y
|
||||||
cli
|
cli
|
||||||
|
|
||||||
|
@ -202,10 +210,10 @@ INSTALL:
|
||||||
; No return code required (the driver is removed from memory on return).
|
; No return code required (the driver is removed from memory on return).
|
||||||
|
|
||||||
UNINSTALL:
|
UNINSTALL:
|
||||||
lda chainIRQ+1
|
lda old_irq
|
||||||
sei
|
sei
|
||||||
sta IRQInd+1
|
sta IRQInd+1
|
||||||
lda chainIRQ+2
|
lda old_irq+1
|
||||||
sta IRQInd+2
|
sta IRQInd+2
|
||||||
cli
|
cli
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ _pen_adjuster:
|
||||||
.addr IRQStub2
|
.addr IRQStub2
|
||||||
callback: ; callback into mouse driver after ROM IRQ handler has been run
|
callback: ; callback into mouse driver after ROM IRQ handler has been run
|
||||||
.addr $0000 ; (filled in by mouse driver)
|
.addr $0000 ; (filled in by mouse driver)
|
||||||
jmp_rom_hdlr: ; "trampoline" to jump to ROM IRQ handler
|
jmp_rom_hdlr: ; original ROM indirect IRQ handler address
|
||||||
.addr $0000 ; (filled in by mouse driver)
|
.addr $0000 ; (filled in by mouse driver)
|
||||||
|
|
||||||
|
|
||||||
|
@ -54,11 +54,17 @@ IRQStub2:
|
||||||
lda #MMU_CFG_CC65 ; MMU configuration which will be active after the ROM handler returns
|
lda #MMU_CFG_CC65 ; MMU configuration which will be active after the ROM handler returns
|
||||||
pha
|
pha
|
||||||
|
|
||||||
|
; map out ROM
|
||||||
|
ldy MMU_CR
|
||||||
|
sta MMU_CR
|
||||||
|
|
||||||
; push address of ROM handler on stack and jump to it
|
; push address of ROM handler on stack and jump to it
|
||||||
lda jmp_rom_hdlr+1
|
lda jmp_rom_hdlr+1
|
||||||
pha
|
pha
|
||||||
lda jmp_rom_hdlr
|
lda jmp_rom_hdlr
|
||||||
pha
|
pha
|
||||||
|
|
||||||
|
sty MMU_CR ; map in ROM
|
||||||
rts ; jump to ROM handler
|
rts ; jump to ROM handler
|
||||||
|
|
||||||
; our MMU configuration byte we pushed on the stack before (MMU_CFG_CC65) is now active
|
; our MMU configuration byte we pushed on the stack before (MMU_CFG_CC65) is now active
|
||||||
|
|
Loading…
Add table
Reference in a new issue