]> git.sur5r.net Git - cc65/commitdiff
Added constructor support (contributed by Stefan Haubenthal).
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Thu, 17 Aug 2006 19:19:55 +0000 (19:19 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Thu, 17 Aug 2006 19:19:55 +0000 (19:19 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@3757 b7a2c559-68d2-44c3-8de9-860c34a00d81

doc/pet.sgml
libsrc/pet/crt0.s

index 53fc67f9814768528242ca1f69978bd026ad02c4..447ee56d0b47837e95ed1dd0f02146ee73fe2be1 100644 (file)
@@ -145,7 +145,15 @@ No extended memory drivers are currently available for the PET.
 
 <sect1>Joystick drivers<p>
 
-No joystick drivers are currently available for the PET.
+<descrip>
+
+  <tag><tt/pet-ptvjoy.joy/</tag>
+  Driver for the Protovision 4-player adapter contributed by Groepaz. See
+  <htmlurl url="http://www.protovision-online.de/hardw/hardwstart.htm"
+  name="http://www.protovision-online.de/hardw/hardwstart.htm"> for prices and
+  building instructions. Up to two joysticks are supported.
+
+</descrip><p>
 
 
 <sect1>Mouse drivers<p>
@@ -191,6 +199,15 @@ The program return code (low byte) is passed back to BASIC by use of the
 <tt/ST/ variable.
 
 
+<sect1>Interrupts<p>
+
+The runtime for the PET uses routines marked as <tt/.CONDES/ type 2 for
+interrupt handlers. Such routines must be written as simple machine language
+subroutines and will be called automatically by the interrupt handler code
+when they are linked into a program. See the discussion of the <tt/.CONDES/
+feature in the <htmlurl url="ca65.html" name="assembler manual">.
+
+
 <sect1>Using extended memory<p>
 
 The extended memory at $9000 of the CBM 8x96 may be added to the heap by using
index fb0377677548915ac83359d2838b4f30e70e9d0e..faf32924c3dd64ae991e87112e3ee378425fee07 100644 (file)
@@ -5,10 +5,11 @@
 ;
 
        .export         _exit
-       .import         initlib, donelib
+       .import         initlib, donelib, callirq
                .import         zerobss, push0
        .import         callmain
         .import         CLRCH, BSOUT
+       .import         __INTERRUPTOR_COUNT__
 
         .include        "zeropage.inc"
        .include        "pet.inc"
@@ -65,14 +66,40 @@ L1: lda     sp,x
 
        jsr     initlib
 
+; If we have IRQ functions, chain our stub into the IRQ vector
+
+       lda     #<__INTERRUPTOR_COUNT__
+       beq     NoIRQ1
+       lda     IRQVec
+       ldx     IRQVec+1
+       sta     IRQInd+1
+       stx     IRQInd+2
+       lda     #<IRQStub
+       ldx     #>IRQStub
+       sei
+       sta     IRQVec
+       stx     IRQVec+1
+       cli
+
 ; Push arguments and call main()
 
-       jsr     callmain
+NoIRQ1:        jsr     callmain
 
 ; Call module destructors. This is also the _exit entry.
 
 _exit:         pha                     ; Save the return code on stack
-       jsr     donelib         ; Run module destructors
+       lda     #<__INTERRUPTOR_COUNT__
+       beq     NoIRQ2
+       lda     IRQInd+1
+       ldx     IRQInd+2
+       sei
+       sta     IRQVec
+       stx     IRQVec+1
+       cli
+
+; Run module destructors
+
+NoIRQ2:        jsr     donelib         ; Run module destructors
 
 ; Copy back the zero page stuff
 
@@ -96,6 +123,13 @@ L2: lda     zpsave,x
 
                rts
 
+; ------------------------------------------------------------------------
+; The IRQ vector jumps here, if condes routines are defined with type 2.
+
+IRQStub:
+       cld                             ; Just to be sure
+       jsr     callirq                 ; Call the functions
+       jmp     IRQInd                  ; Jump to the saved IRQ vector
 
 ; ------------------------------------------------------------------------
 ; Data
@@ -103,6 +137,7 @@ L2: lda     zpsave,x
 .data
 
 zpsave:        .res    zpspace
+IRQInd: jmp    $0000
 
 .bss