; 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__
.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
-
-.segment "MAINHDR"
-
- .word __STARTUP_LOAD__
- .word __BSS_LOAD__ - 1
-
-; ------------------------------------------------------------------------
-; Actual code
.segment "STARTUP"
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
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
; 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
.ifndef __ATARIXL__
APPMHI_save: .res 2
.endif
-
-
-.segment "AUTOSTRT"
- .word RUNAD ; defined in atari.inc
- .word RUNAD+1
- .word start