]> git.sur5r.net Git - cc65/blobdiff - libsrc/atmos/crt0.s
fix comments
[cc65] / libsrc / atmos / crt0.s
index cb1b5a14eabd6a45ddf9638f4583fad8e0f9de33..4fe9d5cbc1b913e61b01734d9390556d2ff2000a 100644 (file)
@@ -2,31 +2,59 @@
 ; Startup code for cc65 (Oric version)
 ;
 ; By Debrune Jérôme <jede@oric.org> and Ullrich von Bassewitz <uz@cc65.org>
-;
-; This must be the *first* file on the linker command line
 ;
 
        .export         _exit
+        .export         __STARTUP__ : absolute = 1      ; Mark as startup
        .import         initlib, donelib
-       .import         push0, callmain, zerobss
-       .import         __RAM_START__, __RAM_SIZE__     ; Linker generated
+       .import         callmain, zerobss
+               .import         __RAM_START__, __RAM_SIZE__, __BSS_LOAD__
+
+        .include        "zeropage.inc"
+        .include        "atmos.inc"
 
-        .importzp       sp
 
 ; ------------------------------------------------------------------------
-; Create an empty LOWCODE segment to avoid linker warnings
+; Oric tape header
+
+.segment        "TAPEHDR"
 
-.segment        "LOWCODE"
+        .byte   $16, $16, $16   ; Sync bytes
+        .byte   $24             ; End of header marker
+
+        .byte   $00                             ; $2B0
+        .byte   $00                             ; $2AF
+        .byte   $80                             ; $2AE Machine code flag
+        .byte   $C7                             ; $2AD Autoload flag
+        .dbyt   __BSS_LOAD__                    ; $2AB
+        .dbyt   __RAM_START__                   ; $2A9
+        .byte   $00                             ; $2A8
+        .byte   $00                             ; Zero terminated name
 
 ; ------------------------------------------------------------------------
 ; Place the startup code in a special segment.
 
 .segment               "STARTUP"
 
+; Save the zero page area we're about to use
+
+       ldx     #zpspace-1
+L1:    lda     sp,x
+       sta     zpsave,x        ; Save the zero page locations we need
+       dex
+               bpl     L1
+
 ; Clear the BSS data
 
        jsr     zerobss
 
+; Unprotect columns 0 and 1
+
+        lda     STATUS
+        sta     stsave
+        and     #%11011111
+        sta     STATUS
+
 ; Save system stuff and setup the stack
 
                tsx
@@ -53,6 +81,16 @@ _exit:       jsr     donelib         ; Run module destructors
 
        ldx     spsave
        txs
+        lda     stsave
+        sta     STATUS
+
+; Copy back the zero page stuff
+
+               ldx     #zpspace-1
+L2:    lda     zpsave,x
+       sta     sp,x
+       dex
+               bpl     L2
 
 ; Back to BASIC
 
@@ -61,7 +99,12 @@ _exit:       jsr     donelib         ; Run module destructors
 ; ------------------------------------------------------------------------
 ; Data
 
+.segment        "ZPSAVE"
+
+zpsave:        .res    zpspace
+
 .bss
 spsave:        .res    1
+stsave: .res    1