2 ; Startup code for cc65 (ATARI version)
4 ; Contributing authors:
11 .export __STARTUP__ : absolute = 1 ; Mark as startup
14 .import initlib, donelib
15 .import callmain, zerobss
16 .import __RESERVED_MEMORY__
17 .import __RAM_START__, __RAM_SIZE__
23 .forceimport sramprep ; force inclusion of the "shadow RAM preparation" load chunk
24 .include "save_area.inc"
27 .include "zeropage.inc"
30 ; ------------------------------------------------------------------------
34 rts ; fix for SpartaDOS / OS/A+
35 ; they first call the entry point from AUTOSTRT and
36 ; then the load addess (this rts here).
37 ; We point AUTOSTRT directly after the rts.
61 sta APPMHI_save ; remember old APPMHI value
67 sbc #<__RESERVED_MEMORY__
68 sta APPMHI ; initialize our APPMHI value
69 sta sp ; setup runtime stack part 1
71 sbc #>__RESERVED_MEMORY__
73 sta sp+1 ; setup runtime stack part 2
77 lda #<(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
79 lda #>(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
84 ; Call module constructors
88 ; Set left margin to 0
95 ; Set keyb to upper/lowercase mode
101 ; Initialize conio stuff
106 ; Push arguments and call main
110 ; Call module destructors. This is also the _exit entry.
112 _exit: jsr donelib ; Run module destructors
114 ; Restore system stuff
117 txs ; Restore stack pointer
119 ; Restore left margin
138 ; Atari XL target stuff...
150 ; Issue a GRAPHICS 0 call (copied'n'pasted from TGI drivers) in
151 ; order to restore screen memory to its defailt location just
156 ; Reopen it in Graphics 0
172 ; No error checking here, shouldn't happen(tm), and no way to
190 ; *** end of main startup code
192 ; ------------------------------------------------------------------------