From: cuz Date: Thu, 17 Aug 2006 19:19:55 +0000 (+0000) Subject: Added constructor support (contributed by Stefan Haubenthal). X-Git-Tag: V2.12.0~98 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=39f096b34e68fac130436c0a15832189391d23ba;p=cc65 Added constructor support (contributed by Stefan Haubenthal). git-svn-id: svn://svn.cc65.org/cc65/trunk@3757 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/doc/pet.sgml b/doc/pet.sgml index 53fc67f98..447ee56d0 100644 --- a/doc/pet.sgml +++ b/doc/pet.sgml @@ -145,7 +145,15 @@ No extended memory drivers are currently available for the PET. Joystick drivers

-No joystick drivers are currently available for the PET. + + + + Driver for the Protovision 4-player adapter contributed by Groepaz. See + for prices and + building instructions. Up to two joysticks are supported. + +

Mouse drivers

@@ -191,6 +199,15 @@ The program return code (low byte) is passed back to BASIC by use of the Interrupts

+ +The runtime for the PET uses routines marked as . + + Using extended memory

The extended memory at $9000 of the CBM 8x96 may be added to the heap by using diff --git a/libsrc/pet/crt0.s b/libsrc/pet/crt0.s index fb0377677..faf32924c 100644 --- a/libsrc/pet/crt0.s +++ b/libsrc/pet/crt0.s @@ -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 + 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