2 ; Startup code for cc65 (Oric version)
4 ; By Debrune Jérôme <jede@oric.org> and Ullrich von Bassewitz <uz@cc65.org>
5 ; 2015-01-09, Greg King
9 .export __STARTUP__ : absolute = 1 ; Mark as startup
10 .import initlib, donelib
11 .import callmain, zerobss
12 .import __RAM_START__, __RAM_SIZE__, __STACKSIZE__
14 .include "zeropage.inc"
17 ; ------------------------------------------------------------------------
18 ; Place the startup code in a special segment.
22 ; Save the zero-page area that we're about to use.
34 ; Currently, color isn't supported on the text screen.
35 ; Unprotect screen columns 0 and 1 (where each line's color codes would sit).
42 ; Save some system stuff; and, set up the stack.
45 stx spsave ; Save system stk ptr
47 lda #<(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
49 lda #>(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
50 sta sp+1 ; Set argument stack ptr
52 ; Call the module constructors.
56 ; Push the command-line arguments; and, call main().
60 ; Call the module destructors. This is also the exit() entry.
64 ; Restore the system stuff.
71 ; Copy back the zero-page stuff.
83 ; ------------------------------------------------------------------------
89 ; This padding is needed by a bug in the ROM.
90 ; (The CLOAD command starts BASIC's variables table on top of the last byte
91 ; that was loaded [instead of at the next address].)
92 ; This is overlaid on a buffer, so that it doesn't use extra space in RAM.
96 ; The segments "ZPSAVE1" and "ZPSAVE2" always must be together.
97 ; They create a single object (the zpsave buffer).
103 ; ------------------------------------------------------------------------