4 ; Originally by Bastian Schick
5 ; http://www.geocities.com/SiliconValley/Byte/4242/lynx/
7 ; Ported to cc65 (http://www.cc65.org) by
8 ; Shawn Jefferson, June 2004
12 ; Startup code for cc65 (Lynx version). Based on Atari 8-bit startup
13 ; code structure. The C stack is located at the end of the RAM memory
14 ; segment and grows downward. Bastian Schick's executable header is put
15 ; on the front of the fully linked binary (see EXEHDR segment.)
17 ; This must be the *first* file on the linker command line
22 .exportzp __iodat,__iodir,__viddma,__sprsys
24 .import initlib, donelib
28 .import __CODE_LOAD__, __BSS_LOAD__
29 .import __RAM_START__, __RAM_SIZE__
31 .include "zeropage.inc"
34 ; ------------------------------------------------------------------------
35 ; EXE header (BLL header)
39 .byte >__CODE_LOAD__, <__CODE_LOAD__
40 .byte >__BSS_LOAD__, <(__BSS_LOAD__ - 1)
45 ; ------------------------------------------------------------------------
46 ; Mikey and Suzy init data, reg offsets and data
50 SuzyInitReg: .byte $28,$2a,$04,$06,$92,$83,$90
51 SuzyInitData: .byte $7f,$7f,$00,$00,$24,$f3,$01
53 MikeyInitReg: .byte $00,$01,$08,$09,$20,$28,$30,$38,$44,$50,$8a,$8b,$8c,$92,$93
54 MikeyInitData: .byte $9e,$18,$68,$1f,$00,$00,$00,$00,$00,$ff,$1a,$1b,$04,$0d,$29
57 ; ------------------------------------------------------------------------
58 ; mikey and suzy shadow registers
60 .segment "EXTZP" : zeropage
68 ; ------------------------------------------------------------------------
85 ; disable all timer interrupts
96 ; disable TX/RX IRQ, set to 8E1
101 ; clear all pending interrupts
108 lda #<(__RAM_START__ + __RAM_SIZE__)
110 lda #>(__RAM_START__ + __RAM_SIZE__)
115 ldx #.sizeof(MikeyInitReg)-1
116 mloop: ldy MikeyInitReg,x
122 ; these are RAM-shadows of read only regs
133 ldx #.sizeof(SuzyInitReg)-1
134 sloop: ldy SuzyInitReg,x
147 ; Call module constructors
151 ; Push arguments and call main
155 ; Call module destructors. This is also the _exit entry.
157 _exit: jsr donelib ; Run module destructors