]> git.sur5r.net Git - cc65/commitdiff
Better cleanup on program exit on atarixl target
authorChristian Groessler <chris@groessler.org>
Wed, 12 Jun 2013 23:17:53 +0000 (01:17 +0200)
committerChristian Groessler <chris@groessler.org>
Wed, 12 Jun 2013 23:17:53 +0000 (01:17 +0200)
libsrc/atari/crt0.s

index 73d2167137c00d116f81dd2373c9e1c5159e0ddd..844b7036891726206eb65431568126d06b2283b2 100644 (file)
@@ -18,7 +18,9 @@
        .import         __RAM_START__, __RAM_SIZE__
        .import         zpsave
        .import         sram_init
-
+.if .defined(__ATARIXL__)
+       .import         scrdev
+.endif
 
         .include        "zeropage.inc"
         .include        "atari.inc"
@@ -167,6 +169,8 @@ _exit:  jsr     donelib         ; Run module destructors
 
        lda     PORTB_save
        sta     PORTB
+       lda     RAMTOP_save
+       sta     RAMTOP
        lda     MEMTOP_save
        sta     MEMTOP
        lda     MEMTOP_save+1
@@ -175,6 +179,33 @@ _exit:  jsr     donelib         ; Run module destructors
        sta     APPMHI
        lda     APPMHI_save+1
        sta     APPMHI+1
+
+
+
+; ... issue a GRAPHICS 0 call (copied'n'pasted from TGI drivers)
+
+
+       ldx     #$50            ; take any IOCB, hopefully free (@@@ fixme)
+
+        ; Reopen it in Graphics 0
+        lda     #OPEN
+        sta     ICCOM,x
+        lda     #OPNIN | OPNOT
+        sta     ICAX1,x
+        lda     #0
+        sta     ICAX2,x
+        lda     #<scrdev
+        sta     ICBAL,x
+        lda     #>scrdev
+        sta     ICBAH,x
+        lda     #3
+        sta     ICBLL,x
+        lda     #0
+        sta     ICBLH,x
+        jsr     CIOV_org
+
+
+
 .endif