mirror of
https://github.com/jeremysrand/mocklib.git
synced 2024-06-26 04:29:34 +00:00
Move to using cc65's interrupt handler support now that I have it working correctly.
This commit is contained in:
parent
21325bbb0f
commit
787e743e0e
|
@ -10,6 +10,7 @@
|
||||||
.export _mockingBoardSpeechInit, _mockingBoardSpeechShutdown, _mockingBoardSpeakPriv
|
.export _mockingBoardSpeechInit, _mockingBoardSpeechShutdown, _mockingBoardSpeakPriv
|
||||||
.export _mockingBoardSpeechData, _mockingBoardSpeechLen
|
.export _mockingBoardSpeechData, _mockingBoardSpeechLen
|
||||||
.export _mockingBoardSpeechBusy, _mockingBoardSpeechPlaying
|
.export _mockingBoardSpeechBusy, _mockingBoardSpeechPlaying
|
||||||
|
.interruptor mock_irq
|
||||||
|
|
||||||
|
|
||||||
TMPPTR := $FB ; Temporary pointer used in interrupt handler
|
TMPPTR := $FB ; Temporary pointer used in interrupt handler
|
||||||
|
@ -36,15 +37,9 @@ _endptr: .byte $00, $00
|
||||||
_mockingBoardSpeechBusy: .byte $00
|
_mockingBoardSpeechBusy: .byte $00
|
||||||
_mockingBoardSpeechPlaying: .byte $00
|
_mockingBoardSpeechPlaying: .byte $00
|
||||||
|
|
||||||
; This is a JMP instruction followed by the address of the old interrupt vector.
|
mock_irq: .byte $60
|
||||||
; It serves two purposes:
|
.lobytes _mockInterrupt
|
||||||
; - The interrupt handler in this file can jump to this location to jump to the
|
.hibytes _mockInterrupt
|
||||||
; old interrupt vector
|
|
||||||
; - This code can restore the old vector when the speech code is shutdown
|
|
||||||
; Better would be to intergrate into the cc65 IRQ functionality but I found I couldn't
|
|
||||||
; make that work for some unknown reason. Instead, this interrupt service routine
|
|
||||||
; chains the cc65 one.
|
|
||||||
_irqLandingPad: .byte $4C, $00, $00
|
|
||||||
|
|
||||||
|
|
||||||
.CODE
|
.CODE
|
||||||
|
@ -69,18 +64,10 @@ readChip:
|
||||||
sta writeChip+2
|
sta writeChip+2
|
||||||
sta readChip+2
|
sta readChip+2
|
||||||
|
|
||||||
; Save the old interrupt vector
|
; Write a jump instruction at mock_irq to turn on our handler
|
||||||
lda IRQL
|
lda #$4c
|
||||||
sta _irqLandingPad+1
|
sta mock_irq
|
||||||
lda IRQH
|
|
||||||
sta _irqLandingPad+2
|
|
||||||
|
|
||||||
; Set the interrupt vector to point to the interrupt service
|
|
||||||
; routine.
|
|
||||||
lda #<_interr
|
|
||||||
sta IRQL
|
|
||||||
lda #>_interr
|
|
||||||
sta IRQH
|
|
||||||
cli
|
cli
|
||||||
rts
|
rts
|
||||||
.endproc
|
.endproc
|
||||||
|
@ -89,11 +76,10 @@ readChip:
|
||||||
.proc _mockingBoardSpeechShutdown
|
.proc _mockingBoardSpeechShutdown
|
||||||
sei
|
sei
|
||||||
|
|
||||||
; Restore the old interrupt vector
|
; Write a RTS instruction at mock_irq to disable our handler
|
||||||
lda _irqLandingPad+1
|
lda #$60
|
||||||
sta IRQL
|
sta mock_irq
|
||||||
lda _irqLandingPad+2
|
|
||||||
sta IRQH
|
|
||||||
cli
|
cli
|
||||||
rts
|
rts
|
||||||
.endproc
|
.endproc
|
||||||
|
@ -161,29 +147,19 @@ readChip:
|
||||||
.endproc
|
.endproc
|
||||||
|
|
||||||
|
|
||||||
.proc _interr
|
|
||||||
; Save the accumulator and X registers
|
|
||||||
pha
|
|
||||||
txa
|
|
||||||
pha
|
|
||||||
|
|
||||||
|
.proc _mockInterrupt
|
||||||
; If we have a 6522 interrupt, jump to L4.
|
; If we have a 6522 interrupt, jump to L4.
|
||||||
ldx #IFR
|
ldx #IFR
|
||||||
jsr readChip
|
jsr readChip
|
||||||
bmi @L4
|
bmi @L4
|
||||||
|
|
||||||
; Otherwise restore the accumulator and X registers and jump
|
; Otherwise clear the carry to indicate we didn't handle the interrupt
|
||||||
; to the old interrupt handler.
|
; and return to the caller.
|
||||||
pla
|
clc
|
||||||
tax
|
rts
|
||||||
pla
|
|
||||||
jmp _irqLandingPad
|
|
||||||
|
|
||||||
@L4:
|
@L4:
|
||||||
; Save the Y register also
|
|
||||||
tya
|
|
||||||
pha
|
|
||||||
|
|
||||||
; Clear the interrupt flag
|
; Clear the interrupt flag
|
||||||
lda #$02
|
lda #$02
|
||||||
ldx #IFR
|
ldx #IFR
|
||||||
|
@ -227,15 +203,9 @@ readChip:
|
||||||
jsr writeChip
|
jsr writeChip
|
||||||
|
|
||||||
@L2:
|
@L2:
|
||||||
; Restore registers
|
; Set the carry flag to indicate we handled the interrupt and return to the caller.
|
||||||
pla
|
sec
|
||||||
tay
|
rts
|
||||||
pla
|
|
||||||
tax
|
|
||||||
pla
|
|
||||||
|
|
||||||
; Return from interrupt
|
|
||||||
rti
|
|
||||||
|
|
||||||
@L1:
|
@L1:
|
||||||
|
|
||||||
|
@ -294,4 +264,3 @@ readChip:
|
||||||
; Finish the interrupt handler
|
; Finish the interrupt handler
|
||||||
jmp @L2
|
jmp @L2
|
||||||
.endproc
|
.endproc
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user