]> git.sur5r.net Git - cc65/blob - libsrc/creativision/crt0.s
Fix joystick driver. Add interruptor support.
[cc65] / libsrc / creativision / crt0.s
1 ;
2 ; Startup code for cc65 (CreatiVision version)
3 ;
4
5         .export         _exit
6         .export         __STARTUP__ : absolute = 1      ; Mark as startup
7         .export         irq2
8         .import         zerobss, copydata
9         .import         initlib, donelib, callmain
10         .import         __VECTORS_LOAD__, __VECTORS_RUN__, __VECTORS_SIZE__
11         .import         __ZP_LAST__, __STACKSIZE__, __RAM_START__
12
13         .include        "creativision.inc"
14         .include        "zeropage.inc"
15
16 ; ------------------------------------------------------------------------
17
18 entry:
19         ; Init the CPU
20         sei
21         cld
22
23         ; Copy the IRQ vectors
24         ldx     #<__VECTORS_SIZE__ - 1
25 :       lda     __VECTORS_LOAD__,x
26         sta     __VECTORS_RUN__,x
27         dex
28         bpl     :-
29
30         ; Setup the CPU stack ptr
31         ldx     #<__RAM_START__ - 1
32         txs
33
34         ; Start interrupts
35         cli
36
37         ; Clear the BSS data
38         jsr     zerobss
39
40         ; Copy data from ROM to RAM
41         jsr     copydata
42
43         ; Setup the argument stack ptr
44         lda     #<(__ZP_LAST__ + __STACKSIZE__)
45         ldx     #>(__ZP_LAST__ + __STACKSIZE__)
46         sta     sp
47         stx     sp+1
48
49         ; Call module constructors
50         jsr     initlib
51
52         ; Call main()
53         jsr     callmain
54
55         ; Call module destructors. This is also the _exit entry.
56 _exit:  jsr     donelib
57
58         ; TODO: Replace with some sort of reset
59 loop:   jmp loop
60
61 ; ------------------------------------------------------------------------
62 ; Define the IRQ vectors.
63
64 .segment        "VECTORS"
65
66 irq1:   jmp     BIOS_IRQ1_ADDR
67 irq2:   jmp     BIOS_IRQ2_ADDR
68
69 ; ------------------------------------------------------------------------
70 ; Define CART setup values for BIOS.
71
72 .segment        "SETUP"
73
74         ; BIOS Jump Start
75         ; This is where the entry point of the program needs to be
76         .addr   entry
77         .addr   irq2
78
79         .res    4
80
81         ; VDP Setup
82         ; This sets to Graphics Mode 1
83         .byte   $00             ; Register 0
84         .byte   $C0             ; Register 1 16K RAM, Active Display, Mode 1
85         .byte   $04             ; Register 2 Name Table at $1000 - $12FF
86         .byte   $60             ; Register 3 Colour Table at $1800 - $181F
87         .byte   $00             ; Register 4 Pattern Table at $0000 - $07FF
88         .byte   $10             ; Register 5 Sprite Attribute at $0800 - $087F
89         .byte   $01             ; Register 6 Sprite Pattern
90         .byte   $F1             ; Register 7 Text colour Foreground / background
91
92         .res    4
93
94         ; BIOS Vector after NMI or RESET
95         ; Keeping with retail cartridges, we jump back to BIOS ROM and have it
96         ; setup zeropage etc, and show the Creativision logo and copyright.
97         .addr BIOS_NMI_RESET_ADDR
98
99         ; BIOS Short Interrupt Handler
100         ; Vectored from BIOS ROM:FE2C. This should contain a pointer to the user's
101         ; BIOS interrupt handler.
102         .addr irq1
103
104 ; ------------------------------------------------------------------------