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 ; ------------------------------------------------------------------------
41 .word __STARTUP_LOAD__
42 .word __BSS_LOAD__ - 1
44 ; ------------------------------------------------------------------------
49 rts ; fix for SpartaDOS / OS/A+
50 ; they first call the entry point from AUTOSTRT and
51 ; then the load addess (this rts here).
52 ; We point AUTOSTRT directly after the rts.
76 sta APPMHI_save ; remember old APPMHI value
82 sbc #<__RESERVED_MEMORY__
83 sta APPMHI ; initialize our APPMHI value
84 sta sp ; setup runtime stack part 1
86 sbc #>__RESERVED_MEMORY__
88 sta sp+1 ; setup runtime stack part 2
92 lda #<(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
94 lda #>(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
99 ; Call module constructors
103 ; Set left margin to 0
110 ; Set keyb to upper/lowercase mode
116 ; Initialize conio stuff
121 ; Push arguments and call main
125 ; Call module destructors. This is also the _exit entry.
127 _exit: jsr donelib ; Run module destructors
129 ; Restore system stuff
132 txs ; Restore stack pointer
134 ; Restore left margin
153 ; Atari XL target stuff...
165 ; Issue a GRAPHICS 0 call (copied'n'pasted from TGI drivers) in
166 ; order to restore screen memory to its defailt location just
171 ; Reopen it in Graphics 0
187 ; No error checking here, shouldn't happen(tm), and no way to
205 ; *** end of main startup code
207 ; ------------------------------------------------------------------------
220 .word RUNAD ; defined in atari.inc