]> git.sur5r.net Git - cc65/commitdiff
Added (again) IRQ support for the Oric Atmos by Stefan Haubenthal. This time
authoruz <uz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Tue, 7 Jun 2011 21:22:02 +0000 (21:22 +0000)
committeruz <uz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Tue, 7 Jun 2011 21:22:02 +0000 (21:22 +0000)
with the correct patch for atmos.inc.

git-svn-id: svn://svn.cc65.org/cc65/trunk@5039 b7a2c559-68d2-44c3-8de9-860c34a00d81

asminc/atmos.inc
libsrc/atmos/crt0.s

index dfbcd10de1dcab8298235a1ca32d8fdb35e4d290..446f2e11c7c360b377365d5465ad0f6c0db2f873 100644 (file)
@@ -12,6 +12,7 @@
 ; Low memory
 
 CAPSLOCK        := $20C
+IRQVec          := $245
 CURS_Y          := $268
 CURS_X          := $269
 STATUS          := $26A
index 1f5bcd568033242b2f694265184b872280558d0d..5a5d0852aee52439b077062c3a7e4df6ee570cab 100644 (file)
@@ -7,7 +7,8 @@
        .export         _exit
        .export         __STARTUP__ : absolute = 1      ; Mark as startup
        .import         initlib, donelib
-       .import         callmain, zerobss
+       .import         callmain, zerobss, callirq
+       .import         __INTERRUPTOR_COUNT__
        .import         __RAM_START__, __RAM_SIZE__
        .import         __ZPSAVE_LOAD__, __STACKSIZE__
 
@@ -69,9 +70,24 @@ L1:  lda     sp,x
        lda     #>(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
        sta     sp+1            ; Set argument stack ptr
 
+; 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
+
 ; Call module constructors
 
-       jsr     initlib
+NoIRQ1: jsr    initlib
 
 ; Push arguments and call main()
 
@@ -81,9 +97,21 @@ L1:  lda     sp,x
 
 _exit: jsr     donelib         ; Run module destructors
 
+; Reset the IRQ vector if we chained it.
+
+       pha                     ; Save the return code on stack
+       lda     #<__INTERRUPTOR_COUNT__
+       beq     NoIRQ2
+       lda     IRQInd+1
+       ldx     IRQInd+2
+       sei
+       sta     IRQVec
+       stx     IRQVec+1
+       cli
+
 ; Restore system stuff
 
-       ldx     spsave
+NoIRQ2: ldx    spsave
        txs
        lda     stsave
        sta     STATUS
@@ -100,13 +128,26 @@ 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
 
+.data
+
+IRQInd: jmp    $0000
+
 .segment       "ZPSAVE"
 
 zpsave: .res   zpspace
 
 .bss
+
 spsave: .res   1
 stsave: .res   1