2002-06-03 20:23:15 +00:00
|
|
|
|
;
|
|
|
|
|
; Startup code for cc65 (Oric version)
|
|
|
|
|
;
|
|
|
|
|
; By Debrune J<>r<EFBFBD>me <jede@oric.org> and Ullrich von Bassewitz <uz@cc65.org>
|
2015-01-10 03:19:35 +00:00
|
|
|
|
; 2015-01-09, Greg King
|
2002-06-03 20:23:15 +00:00
|
|
|
|
;
|
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
|
.export _exit
|
|
|
|
|
.export __STARTUP__ : absolute = 1 ; Mark as startup
|
|
|
|
|
.import initlib, donelib
|
|
|
|
|
.import callmain, zerobss
|
2014-11-09 11:32:11 +00:00
|
|
|
|
.import __RAM_START__, __RAM_SIZE__, __STACKSIZE__
|
2003-04-13 22:12:09 +00:00
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
|
.include "zeropage.inc"
|
|
|
|
|
.include "atmos.inc"
|
2002-06-03 20:23:15 +00:00
|
|
|
|
|
|
|
|
|
; ------------------------------------------------------------------------
|
2002-11-23 11:10:50 +00:00
|
|
|
|
; Place the startup code in a special segment.
|
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
|
.segment "STARTUP"
|
2002-06-03 20:23:15 +00:00
|
|
|
|
|
2014-08-22 21:19:58 +00:00
|
|
|
|
; Save the zero-page area that we're about to use.
|
2003-04-13 22:12:09 +00:00
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
|
ldx #zpspace-1
|
|
|
|
|
L1: lda sp,x
|
2014-08-21 14:46:25 +00:00
|
|
|
|
sta zpsave,x
|
2013-05-09 11:56:54 +00:00
|
|
|
|
dex
|
|
|
|
|
bpl L1
|
2003-04-13 22:12:09 +00:00
|
|
|
|
|
2014-08-21 14:46:25 +00:00
|
|
|
|
; Clear the BSS data.
|
2002-06-03 20:23:15 +00:00
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
|
jsr zerobss
|
2002-06-03 20:23:15 +00:00
|
|
|
|
|
2015-01-08 08:51:20 +00:00
|
|
|
|
; Currently, color isn't supported on the text screen.
|
|
|
|
|
; Unprotect screen columns 0 and 1 (where each line's color codes would sit).
|
2003-04-13 22:12:09 +00:00
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
|
lda STATUS
|
|
|
|
|
sta stsave
|
|
|
|
|
and #%11011111
|
|
|
|
|
sta STATUS
|
2003-04-13 22:12:09 +00:00
|
|
|
|
|
2014-08-22 21:19:58 +00:00
|
|
|
|
; Save some system stuff; and, set up the stack.
|
2002-06-03 20:23:15 +00:00
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
|
tsx
|
|
|
|
|
stx spsave ; Save system stk ptr
|
2002-06-03 20:23:15 +00:00
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
|
lda #<(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
|
|
|
|
|
sta sp
|
|
|
|
|
lda #>(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
|
|
|
|
|
sta sp+1 ; Set argument stack ptr
|
2002-06-03 20:23:15 +00:00
|
|
|
|
|
2014-08-22 21:19:58 +00:00
|
|
|
|
; Call the module constructors.
|
2002-06-03 20:23:15 +00:00
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
|
jsr initlib
|
2002-06-03 20:23:15 +00:00
|
|
|
|
|
2014-08-22 21:19:58 +00:00
|
|
|
|
; Push the command-line arguments; and, call main().
|
2002-06-03 20:23:15 +00:00
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
|
jsr callmain
|
2002-06-03 20:23:15 +00:00
|
|
|
|
|
2014-08-22 21:19:58 +00:00
|
|
|
|
; Call the module destructors. This is also the exit() entry.
|
2002-06-03 20:23:15 +00:00
|
|
|
|
|
2014-11-09 11:32:11 +00:00
|
|
|
|
_exit: jsr donelib
|
2002-06-03 20:23:15 +00:00
|
|
|
|
|
2014-08-22 21:19:58 +00:00
|
|
|
|
; Restore the system stuff.
|
2002-06-03 20:23:15 +00:00
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
|
ldx spsave
|
|
|
|
|
txs
|
|
|
|
|
lda stsave
|
|
|
|
|
sta STATUS
|
2003-04-13 22:12:09 +00:00
|
|
|
|
|
2014-08-21 14:46:25 +00:00
|
|
|
|
; Copy back the zero-page stuff.
|
2003-04-13 22:12:09 +00:00
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
|
ldx #zpspace-1
|
|
|
|
|
L2: lda zpsave,x
|
|
|
|
|
sta sp,x
|
|
|
|
|
dex
|
|
|
|
|
bpl L2
|
2002-06-03 20:23:15 +00:00
|
|
|
|
|
2014-08-21 14:46:25 +00:00
|
|
|
|
; Back to BASIC.
|
2002-06-03 20:23:15 +00:00
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
|
rts
|
2002-06-03 20:23:15 +00:00
|
|
|
|
|
2011-06-07 21:22:02 +00:00
|
|
|
|
; ------------------------------------------------------------------------
|
|
|
|
|
|
2015-01-08 08:51:20 +00:00
|
|
|
|
.segment "ZPSAVE1"
|
2003-04-13 22:12:09 +00:00
|
|
|
|
|
2014-11-09 11:32:11 +00:00
|
|
|
|
zpsave:
|
|
|
|
|
|
|
|
|
|
; This padding is needed by a bug in the ROM.
|
|
|
|
|
; (The CLOAD command starts BASIC's variables table on top of the last byte
|
|
|
|
|
; that was loaded [instead of at the next address].)
|
2015-01-10 03:19:35 +00:00
|
|
|
|
; This is overlaid on a buffer, so that it doesn't use extra space in RAM.
|
2014-11-09 11:32:11 +00:00
|
|
|
|
|
|
|
|
|
.byte 0
|
|
|
|
|
|
2015-01-08 22:07:28 +00:00
|
|
|
|
; The segments "ZPSAVE1" and "ZPSAVE2" always must be together.
|
|
|
|
|
; They create a single object (the zpsave buffer).
|
|
|
|
|
|
2015-01-08 08:51:20 +00:00
|
|
|
|
.segment "ZPSAVE2"
|
|
|
|
|
|
2014-11-09 11:32:11 +00:00
|
|
|
|
.res zpspace - 1
|
2003-04-13 22:12:09 +00:00
|
|
|
|
|
2013-02-12 22:39:38 +00:00
|
|
|
|
; ------------------------------------------------------------------------
|
|
|
|
|
|
2002-06-03 20:23:15 +00:00
|
|
|
|
.bss
|
2011-06-07 21:22:02 +00:00
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
|
spsave: .res 1
|
|
|
|
|
stsave: .res 1
|