aboutsummaryrefslogtreecommitdiff
path: root/crt0_cart.s
blob: 7448e9ba095e9e0c112265230dacbb8d453eb711 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
;
; Startup code for cc65 (ATARI version)
;
; Contributing authors:
;       Mark Keates
;       Freddy Offenga
;       Christian Groessler
;       Stefan Haubenthal
;

; Modified for use with Taipan cartridge image:
; - Removed the RTS at the start of the code
; - Got rid of __ATARIXL__ conditionals
; - Don't save stuff like APPMHI and LMARGN, since the cart
;   never returns.

        .export         __STARTUP__ : absolute = 1      ; Mark as startup
        .export         _exit, start

        .import         initlib, donelib
        .import         callmain, zerobss
        .import         __RESERVED_MEMORY__
        .import         __RAM_START__, __RAM_SIZE__
        .include        "zeropage.inc"
        .include        "atari.inc"

; ------------------------------------------------------------------------

.segment        "STARTUP"

; Real entry point:

start:

; Clear the BSS data.

        jsr     zerobss

; Setup arg stack
        lda MEMTOP
        sta sp
        lda MEMTOP+1
        sta sp+1

; Call the module constructors.

        jsr     initlib

; Set the left margin to 0.

        ldy     #0
        sty     LMARGN

; Set the keyboard to upper-/lower-case mode.

        ldx     SHFLOK
        sty     SHFLOK

; Push the command-line arguments; and, call main().

        jsr     callmain

; Call the module destructors. This is also the exit() entry.

_exit:  jsr     donelib         ; Run module destructors

; Back to DOS.

        rts

; *** end of main startup code

; ------------------------------------------------------------------------