mirror of
https://github.com/cc65/cc65.git
synced 2025-02-09 02:30:42 +00:00
added interruptor support
This commit is contained in:
parent
859604407b
commit
296489ba6c
11
cfg/pce.cfg
11
cfg/pce.cfg
@ -38,10 +38,9 @@ FEATURES {
|
|||||||
label = __DESTRUCTOR_TABLE__,
|
label = __DESTRUCTOR_TABLE__,
|
||||||
count = __DESTRUCTOR_COUNT__,
|
count = __DESTRUCTOR_COUNT__,
|
||||||
segment = RODATA;
|
segment = RODATA;
|
||||||
# FIXME: interruptor support is missing
|
CONDES: type = interruptor,
|
||||||
# CONDES: type = interruptor,
|
label = __INTERRUPTOR_TABLE__,
|
||||||
# label = __INTERRUPTOR_TABLE__,
|
count = __INTERRUPTOR_COUNT__,
|
||||||
# count = __INTERRUPTOR_COUNT__,
|
segment = RODATA,
|
||||||
# segment = RODATA,
|
import = __CALLIRQ__;
|
||||||
# import = __CALLIRQ__;
|
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
.include "pce.inc"
|
.include "pce.inc"
|
||||||
.include "extzp.inc"
|
.include "extzp.inc"
|
||||||
|
|
||||||
|
.forceimport ticktock
|
||||||
.export _clock
|
.export _clock
|
||||||
.importzp sreg
|
.importzp sreg
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
.import initlib, donelib
|
.import initlib, donelib
|
||||||
.import push0, _main, zerobss
|
.import push0, _main, zerobss
|
||||||
.import initheap
|
.import initheap
|
||||||
.import tmp1,tmp2,tmp3
|
.import IRQStub
|
||||||
|
|
||||||
; Linker generated
|
; Linker generated
|
||||||
.import __RAM_START__, __RAM_SIZE__
|
.import __RAM_START__, __RAM_SIZE__
|
||||||
@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
.importzp sp
|
.importzp sp
|
||||||
.importzp ptr1,ptr2
|
.importzp ptr1,ptr2
|
||||||
|
.importzp tmp1,tmp2,tmp3
|
||||||
|
|
||||||
; ------------------------------------------------------------------------
|
; ------------------------------------------------------------------------
|
||||||
; Place the startup code in a special segment.
|
; Place the startup code in a special segment.
|
||||||
@ -158,39 +159,8 @@ _exit:
|
|||||||
; reset the PCEngine (start over)
|
; reset the PCEngine (start over)
|
||||||
jmp start
|
jmp start
|
||||||
|
|
||||||
; ------------------------------------------------------------------------
|
|
||||||
; System V-Blank Interupt
|
|
||||||
; FIXME: hooks should be provided so the user can abuse the IRQ
|
|
||||||
; ------------------------------------------------------------------------
|
|
||||||
|
|
||||||
_irq1:
|
|
||||||
pha
|
|
||||||
phx
|
|
||||||
phy
|
|
||||||
|
|
||||||
; increment the system tick counter
|
|
||||||
inc tickcount
|
|
||||||
bne @s1
|
|
||||||
inc tickcount + 1
|
|
||||||
bne @s1
|
|
||||||
inc tickcount + 2
|
|
||||||
bne @s1
|
|
||||||
inc tickcount + 3
|
|
||||||
@s1:
|
|
||||||
; Acknowlege interrupt
|
|
||||||
lda a:VDC_CTRL
|
|
||||||
|
|
||||||
ply
|
|
||||||
plx
|
|
||||||
pla
|
|
||||||
rti
|
|
||||||
_irq2:
|
|
||||||
rti
|
|
||||||
_nmi:
|
_nmi:
|
||||||
rti
|
rti
|
||||||
_timer:
|
|
||||||
stz IRQ_STATUS
|
|
||||||
rti
|
|
||||||
|
|
||||||
.export initmainargs
|
.export initmainargs
|
||||||
initmainargs:
|
initmainargs:
|
||||||
@ -201,8 +171,8 @@ initmainargs:
|
|||||||
; ------------------------------------------------------------------------
|
; ------------------------------------------------------------------------
|
||||||
.segment "VECTORS"
|
.segment "VECTORS"
|
||||||
|
|
||||||
.word _irq2 ; $fff6 IRQ2 (External IRQ, BRK)
|
.word IRQStub ; $fff6 IRQ2 (External IRQ, BRK)
|
||||||
.word _irq1 ; $fff8 IRQ1 (VDC)
|
.word IRQStub ; $fff8 IRQ1 (VDC)
|
||||||
.word _timer ; $fffa Timer
|
.word IRQStub ; $fffa Timer
|
||||||
.word _nmi ; $fffc NMI
|
.word _nmi ; $fffc NMI
|
||||||
.word start ; $fffe reset
|
.word start ; $fffe reset
|
||||||
|
@ -15,3 +15,4 @@
|
|||||||
.global RVS: zp
|
.global RVS: zp
|
||||||
.global BGCOLOR: zp
|
.global BGCOLOR: zp
|
||||||
.global tickcount: zp
|
.global tickcount: zp
|
||||||
|
.global vdc_flags: zp
|
||||||
|
@ -15,3 +15,4 @@ CHARCOLOR: .res 1
|
|||||||
RVS: .res 1
|
RVS: .res 1
|
||||||
BGCOLOR: .res 1
|
BGCOLOR: .res 1
|
||||||
tickcount: .res 4
|
tickcount: .res 4
|
||||||
|
vdc_flags: .res 1
|
||||||
|
48
libsrc/pce/irq.s
Normal file
48
libsrc/pce/irq.s
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
;
|
||||||
|
; IRQ handling (PCE version)
|
||||||
|
;
|
||||||
|
|
||||||
|
.export initirq, doneirq, IRQStub
|
||||||
|
|
||||||
|
.import __INTERRUPTOR_COUNT__, callirq_y
|
||||||
|
|
||||||
|
.include "pce.inc"
|
||||||
|
.include "extzp.inc"
|
||||||
|
|
||||||
|
; ------------------------------------------------------------------------
|
||||||
|
.segment "INIT"
|
||||||
|
|
||||||
|
; a constructor
|
||||||
|
;
|
||||||
|
initirq:
|
||||||
|
rts
|
||||||
|
|
||||||
|
; ------------------------------------------------------------------------
|
||||||
|
.code
|
||||||
|
|
||||||
|
; a destructor
|
||||||
|
;
|
||||||
|
doneirq:
|
||||||
|
rts
|
||||||
|
|
||||||
|
; ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
IRQStub:
|
||||||
|
phy
|
||||||
|
|
||||||
|
; Save the display-source flags (and, release the interrupt).
|
||||||
|
;
|
||||||
|
ldy a:VDC_CTRL
|
||||||
|
sty vdc_flags
|
||||||
|
|
||||||
|
ldy #<(__INTERRUPTOR_COUNT__ * 2)
|
||||||
|
beq @L1
|
||||||
|
phx
|
||||||
|
pha
|
||||||
|
|
||||||
|
jsr callirq_y
|
||||||
|
|
||||||
|
pla
|
||||||
|
plx
|
||||||
|
@L1: ply
|
||||||
|
rti
|
18
libsrc/pce/ticktock.s
Normal file
18
libsrc/pce/ticktock.s
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
.interruptor ticktock, 24
|
||||||
|
|
||||||
|
.include "pce.inc"
|
||||||
|
.include "extzp.inc"
|
||||||
|
|
||||||
|
ticktock:
|
||||||
|
bbr5 vdc_flags,@s1 ; not vertical-blank interrupt
|
||||||
|
|
||||||
|
; Increment the system tick counter.
|
||||||
|
inc tickcount
|
||||||
|
bne @s1
|
||||||
|
inc tickcount+1
|
||||||
|
bne @s1
|
||||||
|
inc tickcount+2
|
||||||
|
bne @s1
|
||||||
|
inc tickcount+3
|
||||||
|
|
||||||
|
@s1: rts
|
@ -5,6 +5,7 @@
|
|||||||
.include "pce.inc"
|
.include "pce.inc"
|
||||||
.include "extzp.inc"
|
.include "extzp.inc"
|
||||||
|
|
||||||
|
.forceimport ticktock
|
||||||
.export _waitvblank
|
.export _waitvblank
|
||||||
|
|
||||||
.proc _waitvblank
|
.proc _waitvblank
|
||||||
|
Loading…
x
Reference in New Issue
Block a user