]> git.sur5r.net Git - cc65/commitdiff
added interruptor support
authormrdudz <mrdudz@users.noreply.github.com>
Sat, 19 Sep 2015 13:55:43 +0000 (15:55 +0200)
committermrdudz <mrdudz@users.noreply.github.com>
Sat, 19 Sep 2015 13:55:43 +0000 (15:55 +0200)
cfg/pce.cfg
libsrc/pce/clock.s
libsrc/pce/crt0.s
libsrc/pce/extzp.inc
libsrc/pce/extzp.s
libsrc/pce/irq.s [new file with mode: 0644]
libsrc/pce/ticktock.s [new file with mode: 0644]
libsrc/pce/waitvblank.s

index 2c660435a7f691aac7fc8de8121edf021d4f70c1..9128eb727fa793544b4fe8fe1f2a9cfef00fe832 100644 (file)
@@ -38,10 +38,9 @@ FEATURES {
             label   = __DESTRUCTOR_TABLE__,
             count   = __DESTRUCTOR_COUNT__,
             segment = RODATA;
-# FIXME: interruptor support is missing
-#    CONDES: type    = interruptor,
-#            label   = __INTERRUPTOR_TABLE__,
-#            count   = __INTERRUPTOR_COUNT__,
-#            segment = RODATA,
-#            import  = __CALLIRQ__;
+    CONDES: type    = interruptor,
+            label   = __INTERRUPTOR_TABLE__,
+            count   = __INTERRUPTOR_COUNT__,
+            segment = RODATA,
+            import  = __CALLIRQ__;
 }
index d92ebe89f5d751e60a1de2f46205c8d201516255..c6d6fb7fb41fd55ec15b689830226ebde90a3677 100644 (file)
@@ -5,6 +5,7 @@
         .include        "pce.inc"
         .include        "extzp.inc"
 
+        .forceimport    ticktock
         .export         _clock
         .importzp       sreg
 
index 4f886ca5a462ca07a2e0108993e9b4781cb60991..77872f32fc3dd0add639ff5e76677bba74dca46b 100644 (file)
@@ -13,7 +13,7 @@
         .import         initlib, donelib
         .import         push0, _main, zerobss
         .import         initheap
-        .import         tmp1,tmp2,tmp3
+        .import         IRQStub
 
         ; Linker generated
         .import         __RAM_START__, __RAM_SIZE__
@@ -30,6 +30,7 @@
 
         .importzp       sp
         .importzp       ptr1,ptr2
+        .importzp       tmp1,tmp2,tmp3
 
 ; ------------------------------------------------------------------------
 ; Place the startup code in a special segment.
@@ -158,39 +159,8 @@ _exit:
         ; reset the PCEngine (start over)
         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:
         rti
-_timer:
-        stz     IRQ_STATUS
-        rti
 
         .export initmainargs
 initmainargs:
@@ -201,8 +171,8 @@ initmainargs:
 ; ------------------------------------------------------------------------
         .segment "VECTORS"
 
-        .word   _irq2           ; $fff6 IRQ2 (External IRQ, BRK)
-        .word   _irq1           ; $fff8 IRQ1 (VDC)
-        .word   _timer          ; $fffa Timer
+        .word   IRQStub         ; $fff6 IRQ2 (External IRQ, BRK)
+        .word   IRQStub         ; $fff8 IRQ1 (VDC)
+        .word   IRQStub         ; $fffa Timer
         .word   _nmi            ; $fffc NMI
         .word   start           ; $fffe reset
index 2869c3a06f05a8171fdbfe419f965135645a19e5..dce91558f0a7d21a2f586c9cdb9af8865041da5a 100644 (file)
@@ -15,3 +15,4 @@
         .global         RVS: zp
         .global         BGCOLOR: zp
         .global         tickcount: zp
+        .global         vdc_flags: zp
index 516c309543262e1f7c5ffdb8271065a03359fc92..26dc589b1f5ce2e71e638d9014b8b0e3f347d30d 100644 (file)
@@ -15,3 +15,4 @@ CHARCOLOR:      .res 1
 RVS:            .res 1
 BGCOLOR:        .res 1
 tickcount:      .res 4
+vdc_flags:      .res 1
diff --git a/libsrc/pce/irq.s b/libsrc/pce/irq.s
new file mode 100644 (file)
index 0000000..f34303d
--- /dev/null
@@ -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
diff --git a/libsrc/pce/ticktock.s b/libsrc/pce/ticktock.s
new file mode 100644 (file)
index 0000000..4e4d44d
--- /dev/null
@@ -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
index d60a9ddea5a18f2e2d5db7ccc024a8140e2390e0..b9f0f902fad9bdb3d9a5ca8a04446ce0a1dd1ee1 100644 (file)
@@ -5,6 +5,7 @@
         .include        "pce.inc"
         .include        "extzp.inc"
 
+        .forceimport    ticktock
         .export         _waitvblank
 
 .proc   _waitvblank