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 .include "save_area.inc"
26 .include "zeropage.inc"
29 ; ------------------------------------------------------------------------
33 rts ; fix for SpartaDOS / OS/A+
34 ; they first call the entry point from AUTOSTRT and
35 ; then the load addess (this rts here).
36 ; We point AUTOSTRT directly after the rts.
60 sta APPMHI_save ; remember old APPMHI value
66 sbc #<__RESERVED_MEMORY__
67 sta APPMHI ; initialize our APPMHI value
68 sta sp ; setup runtime stack part 1
70 sbc #>__RESERVED_MEMORY__
72 sta sp+1 ; setup runtime stack part 2
76 lda #<(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
78 lda #>(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
83 ; Call module constructors
87 ; Set left margin to 0
94 ; Set keyb to upper/lowercase mode
100 ; Initialize conio stuff
105 ; Push arguments and call main
109 ; Call module destructors. This is also the _exit entry.
111 _exit: jsr donelib ; Run module destructors
113 ; Restore system stuff
116 txs ; Restore stack pointer
118 ; Restore left margin
137 ; Atari XL target stuff...
149 ; Issue a GRAPHICS 0 call (copied'n'pasted from TGI drivers) in
150 ; order to restore screen memory to its defailt location just
155 ; Reopen it in Graphics 0
171 ; No error checking here, shouldn't happen(tm), and no way to
189 ; *** end of main startup code
191 ; ------------------------------------------------------------------------