]> git.sur5r.net Git - cc65/blobdiff - libsrc/atari/crt0.s
Normalized style.
[cc65] / libsrc / atari / crt0.s
index f2843980217d203da85b6ec43d8423f0f3b7eb6d..f1c7b864e8ffd1d10bd189863eed957650c032dd 100644 (file)
@@ -8,12 +8,11 @@
 ;       Stefan Haubenthal
 ;
 
-        .export         _exit
         .export         __STARTUP__ : absolute = 1      ; Mark as startup
+        .export         _exit, start
 
         .import         initlib, donelib
         .import         callmain, zerobss
-        .import         __STARTUP_LOAD__, __BSS_LOAD__
         .import         __RESERVED_MEMORY__
         .import         __RAM_START__, __RAM_SIZE__
 .ifdef __ATARIXL__
@@ -21,6 +20,7 @@
         .import         sram_init
         .import         scrdev
         .import         findfreeiocb
+        .forceimport    sramprep                        ; force inclusion of the "shadow RAM preparation" load chunk
         .include        "save_area.inc"
 .endif
 
         .include        "atari.inc"
 
 ; ------------------------------------------------------------------------
-; EXE header
-
-.segment        "EXEHDR"
-
-        .word   $FFFF
-
-.ifdef __ATARIXL__
-.segment        "MAINHDR"
-.endif
-
-        .word   __STARTUP_LOAD__
-        .word   __BSS_LOAD__ - 1
-
-; ------------------------------------------------------------------------
-; Actual code
 
 .segment        "STARTUP"
 
@@ -68,7 +53,14 @@ start:
         tsx
         stx     SP_save
 
-.ifndef __ATARIXL__
+.ifdef __ATARIXL__
+
+        lda     #<(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
+        sta     sp
+        lda     #>(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
+        sta     sp+1
+
+.else
 
 ; Report memory usage
 
@@ -87,36 +79,12 @@ start:
         sta     APPMHI+1
         sta     sp+1                    ; setup runtime stack part 2
 
-.else
-
-        lda     #<(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
-        sta     sp
-        lda     #>(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
-        sta     sp+1
-
 .endif
 
 ; Call module constructors
 
         jsr     initlib
 
-.if 0
-.ifdef __ATARIXL__
-        .import __heapadd
-        .import pushax
-        .import __RAM_BELOW_ROM_START__
-        .import __RAM_BELOW_ROM_SIZE__
-        .import __RAM_BELOW_ROM_LAST__
-
-        lda     #<__RAM_BELOW_ROM_LAST__
-        ldx     #>__RAM_BELOW_ROM_LAST__
-        jsr     pushax
-        lda     #<(__RAM_BELOW_ROM_SIZE__ - (__RAM_BELOW_ROM_LAST__ - __RAM_BELOW_ROM_START__))
-        ldx     #>(__RAM_BELOW_ROM_SIZE__ - (__RAM_BELOW_ROM_LAST__ - __RAM_BELOW_ROM_START__))
-        jsr     __heapadd
-.endif
-.endif
-
 ; Set left margin to 0
 
         lda     LMARGN
@@ -132,8 +100,8 @@ start:
 
 ; Initialize conio stuff
 
-        dey                             ; Set X to $FF
-        sty     CH
+        dey                     ; Set Y to $FF
+        sty     CH              ; remove keypress which might be in the input buffer
 
 ; Push arguments and call main
 
@@ -179,7 +147,9 @@ _exit:  jsr     donelib         ; Run module destructors
         sta     MEMTOP+1
 
 
-; ... issue a GRAPHICS 0 call (copied'n'pasted from TGI drivers)
+; Issue a GRAPHICS 0 call (copied'n'pasted from TGI drivers) in
+; order to restore screen memory to its defailt location just
+; before the ROM.
 
         jsr     findfreeiocb
 
@@ -199,7 +169,9 @@ _exit:  jsr     donelib         ; Run module destructors
         lda     #0
         sta     ICBLH,x
         jsr     CIOV_org
-; add error checking here...
+; No error checking here, shouldn't happen(tm), and no way to
+; recover anyway.
+
         lda     #CLOSE
         sta     ICCOM,x
         jsr     CIOV_org
@@ -222,14 +194,8 @@ _exit:  jsr     donelib         ; Run module destructors
 .bss
 
 SP_save:        .res    1
-SHFLOK_save     .res    1
+SHFLOK_save:    .res    1
 LMARGN_save:    .res    1
 .ifndef __ATARIXL__
 APPMHI_save:    .res    2
 .endif
-
-
-.segment "AUTOSTRT"
-        .word   RUNAD                   ; defined in atari.inc
-        .word   RUNAD+1
-        .word   start