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
107 .import __RAM_BELOW_ROM_START__
108 .import __RAM_BELOW_ROM_SIZE__
109 .import __RAM_BELOW_ROM_LAST__
111 lda #<__RAM_BELOW_ROM_LAST__
112 ldx #>__RAM_BELOW_ROM_LAST__
114 lda #<(__RAM_BELOW_ROM_SIZE__ - (__RAM_BELOW_ROM_LAST__ - __RAM_BELOW_ROM_START__))
115 ldx #>(__RAM_BELOW_ROM_SIZE__ - (__RAM_BELOW_ROM_LAST__ - __RAM_BELOW_ROM_START__))
120 ; Set left margin to 0
127 ; Set keyb to upper/lowercase mode
133 ; Initialize conio stuff
138 ; Push arguments and call main
142 ; Call module destructors. This is also the _exit entry.
144 _exit: jsr donelib ; Run module destructors
146 ; Restore system stuff
149 txs ; Restore stack pointer
151 ; Restore left margin
170 ; Atari XL target stuff...
182 ; ... issue a GRAPHICS 0 call (copied'n'pasted from TGI drivers)
186 ; Reopen it in Graphics 0
202 ; add error checking here...
218 ; *** end of main startup code
220 ; ------------------------------------------------------------------------
233 .word RUNAD ; defined in atari.inc