2013-07-14 20:50:38 +00:00
|
|
|
; ---------------------------------------------------------------------------
|
|
|
|
; crt0.s
|
|
|
|
; ---------------------------------------------------------------------------
|
|
|
|
;
|
|
|
|
; Startup code for Ohio Scientific Challenger 1P
|
|
|
|
|
|
|
|
.export _init, _exit
|
|
|
|
.import _main
|
|
|
|
|
|
|
|
.export __STARTUP__ : absolute = 1 ; Mark as startup
|
|
|
|
.import __RAM_START__, __RAM_SIZE__ ; Linker generated
|
|
|
|
|
2013-07-24 20:35:58 +00:00
|
|
|
.import zerobss, initlib, donelib
|
2013-07-14 20:50:38 +00:00
|
|
|
|
|
|
|
.include "zeropage.inc"
|
2014-11-23 14:32:48 +00:00
|
|
|
.include "extzp.inc"
|
2015-02-05 22:21:59 +00:00
|
|
|
.include "osic1p.inc"
|
2013-07-14 20:50:38 +00:00
|
|
|
|
|
|
|
; ---------------------------------------------------------------------------
|
|
|
|
; Place the startup code in a special segment
|
|
|
|
|
|
|
|
.segment "STARTUP"
|
|
|
|
|
|
|
|
; ---------------------------------------------------------------------------
|
|
|
|
; A little light 6502 housekeeping
|
|
|
|
|
2015-01-05 20:28:39 +00:00
|
|
|
_init: ldx #$FF ; Initialize stack pointer to $01FF
|
|
|
|
txs
|
|
|
|
cld ; Clear decimal mode
|
2013-07-14 20:50:38 +00:00
|
|
|
|
2014-11-23 14:32:48 +00:00
|
|
|
; ---------------------------------------------------------------------------
|
|
|
|
; Initialize screen width
|
|
|
|
; TODO: Can initialization be done in a more idiomatic way?
|
|
|
|
; TODO: Create function for changing screen width
|
2015-01-05 20:28:39 +00:00
|
|
|
lda #$18
|
|
|
|
sta SCR_LINELEN
|
2014-11-23 14:32:48 +00:00
|
|
|
|
2013-07-14 20:50:38 +00:00
|
|
|
; ---------------------------------------------------------------------------
|
|
|
|
; Set cc65 argument stack pointer
|
|
|
|
|
2015-01-05 20:28:39 +00:00
|
|
|
lda #<(__RAM_START__ + __RAM_SIZE__)
|
|
|
|
sta sp
|
|
|
|
lda #>(__RAM_START__ + __RAM_SIZE__)
|
|
|
|
sta sp+1
|
2013-07-14 20:50:38 +00:00
|
|
|
|
|
|
|
; ---------------------------------------------------------------------------
|
|
|
|
; Initialize memory storage
|
2013-07-15 20:45:09 +00:00
|
|
|
; copydata seems to be only necessary for special systems
|
2013-07-14 20:50:38 +00:00
|
|
|
|
2015-01-05 20:28:39 +00:00
|
|
|
jsr zerobss ; Clear BSS segment
|
|
|
|
; jsr copydata ; Initialize DATA segment
|
|
|
|
jsr initlib ; Run constructors
|
2013-07-14 20:50:38 +00:00
|
|
|
|
|
|
|
; ---------------------------------------------------------------------------
|
|
|
|
; Call main()
|
|
|
|
|
2015-01-05 20:28:39 +00:00
|
|
|
jsr _main
|
2013-07-14 20:50:38 +00:00
|
|
|
|
|
|
|
; ---------------------------------------------------------------------------
|
|
|
|
; Back from main (this is also the _exit entry): force a software break
|
|
|
|
|
2015-01-05 20:28:39 +00:00
|
|
|
_exit: jsr donelib ; Run destructors
|
2015-02-05 22:21:59 +00:00
|
|
|
jmp RESET ; Display boot menu after program exit
|