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 address (this rts here).
37 ; We point AUTOSTRT directly after the rts.
58 lda #<(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
60 lda #>(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
65 ; Report the memory usage.
68 sta APPMHI_save ; remember old APPMHI value
74 sbc #<__RESERVED_MEMORY__
75 sta APPMHI ; initialize our APPMHI value
76 sta sp ; set up runtime stack part 1
78 sbc #>__RESERVED_MEMORY__
80 sta sp+1 ; set up runtime stack part 2
84 ; Call the module constructors.
88 ; Set the left margin to 0.
95 ; Set the keyboard to upper-/lower-case mode.
101 ; Initialize the conio stuff.
104 sty CH ; remove keypress which might be in the input buffer
106 ; Push the command-line arguments; and, call main().
110 ; Call the module destructors. This is also the exit() entry.
112 _exit: jsr donelib ; Run module destructors
114 ; Restore the system stuff.
117 txs ; Restore stack pointer
119 ; Restore the left margin.
124 ; Restore the kb mode.
138 ; Atari XL target stuff...
150 ; Issue a GRAPHICS 0 call (copied'n'pasted from the TGI drivers), in
151 ; order to restore screen memory to its default location just
156 ; Reopen it in Graphics 0
172 ; No error checking here, shouldn't happen(TM); and, no way to
181 ; Turn on the cursor.
190 ; *** end of main startup code
192 ; ------------------------------------------------------------------------