2 ; Startup code for cc65 (ATARI version)
4 ; Contributing authors:
12 .export __STARTUP__ : absolute = 1 ; Mark as startup
14 .import initlib, donelib
15 .import callmain, zerobss
16 .import __STARTUP_LOAD__, __BSS_LOAD__
17 .import __RESERVED_MEMORY__
18 .import __RAM_START__, __RAM_SIZE__
24 .include "save_area.inc"
27 .include "zeropage.inc"
30 ; ------------------------------------------------------------------------
39 .word __STARTUP_LOAD__
40 .word __BSS_LOAD__ - 1
42 ; ------------------------------------------------------------------------
47 rts ; fix for SpartaDOS / OS/A+
48 ; they first call the entry point from AUTOSTRT and
49 ; then the load addess (this rts here).
50 ; We point AUTOSTRT directly after the rts.
74 sta APPMHI_save ; remember old APPMHI value
80 sbc #<__RESERVED_MEMORY__
81 sta APPMHI ; initialize our APPMHI value
82 sta sp ; setup runtime stack part 1
84 sbc #>__RESERVED_MEMORY__
86 sta sp+1 ; setup runtime stack part 2
90 lda #<(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
92 lda #>(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
97 ; Call module constructors
101 ; Set left margin to 0
108 ; Set keyb to upper/lowercase mode
114 ; Initialize conio stuff
119 ; Push arguments and call main
123 ; Call module destructors. This is also the _exit entry.
125 _exit: jsr donelib ; Run module destructors
127 ; Restore system stuff
130 txs ; Restore stack pointer
132 ; Restore left margin
151 ; Atari XL target stuff...
163 ; Issue a GRAPHICS 0 call (copied'n'pasted from TGI drivers) in
164 ; order to restore screen memory to its defailt location just
169 ; Reopen it in Graphics 0
185 ; No error checking here, shouldn't happen(tm), and no way to
203 ; *** end of main startup code
205 ; ------------------------------------------------------------------------
218 .word RUNAD ; defined in atari.inc