<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>
<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
;
.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"
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
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
.data
zpsave: .res zpspace
+IRQInd: jmp $0000
.bss