diff options
Diffstat (limited to 'gba/start')
-rw-r--r-- | gba/start/pkjb_crt0.s | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/gba/start/pkjb_crt0.s b/gba/start/pkjb_crt0.s new file mode 100644 index 0000000..0d9d657 --- /dev/null +++ b/gba/start/pkjb_crt0.s | |||
@@ -0,0 +1,102 @@ | |||
1 | .section ".init" | ||
2 | .global _start | ||
3 | .align | ||
4 | .arm | ||
5 | @--------------------------------------------------------------------------------- | ||
6 | _start: | ||
7 | @--------------------------------------------------------------------------------- | ||
8 | b rom_header_end | ||
9 | |||
10 | .fill 156,1,0 @ Nintendo Logo Character Data (8000004h) | ||
11 | .fill 16,1,0 @ Game Title | ||
12 | .byte 0x30,0x31 @ Maker Code (80000B0h) | ||
13 | .byte 0x96 @ Fixed Value (80000B2h) | ||
14 | .byte 0x00 @ Main Unit Code (80000B3h) | ||
15 | .byte 0x00 @ Device Type (80000B4h) | ||
16 | .fill 7,1,0 @ unused | ||
17 | .byte 0x00 @ Software Version No (80000BCh) | ||
18 | .byte 0xf0 @ Complement Check (80000BDh) | ||
19 | .byte 0x00,0x00 @ Checksum (80000BEh) | ||
20 | |||
21 | @--------------------------------------------------------------------------------- | ||
22 | rom_header_end: | ||
23 | @--------------------------------------------------------------------------------- | ||
24 | b start_vector @ This branch must be here for proper | ||
25 | @ positioning of the following header. | ||
26 | |||
27 | .GLOBAL __boot_method, __slave_number | ||
28 | @--------------------------------------------------------------------------------- | ||
29 | __boot_method: | ||
30 | @--------------------------------------------------------------------------------- | ||
31 | .byte 0 @ boot method (0=ROM boot, 3=Multiplay boot) | ||
32 | @--------------------------------------------------------------------------------- | ||
33 | __slave_number: | ||
34 | @--------------------------------------------------------------------------------- | ||
35 | .byte 0 @ slave # (1=slave#1, 2=slave#2, 3=slave#3) | ||
36 | |||
37 | .byte 0 @ reserved | ||
38 | .byte 0 @ reserved | ||
39 | .word 0 @ reserved | ||
40 | .word 0 @ reserved | ||
41 | .word 0 @ reserved | ||
42 | .word 0 @ reserved | ||
43 | .word 0 @ reserved | ||
44 | .word 0 @ reserved | ||
45 | |||
46 | .fill 4096,1,0 @ 4kb of filler so no useful code gets overwritten when flash bytes get copied over the top. | ||
47 | .global start_vector | ||
48 | .align | ||
49 | @--------------------------------------------------------------------------------- | ||
50 | start_vector: | ||
51 | @--------------------------------------------------------------------------------- | ||
52 | |||
53 | @--------------------------------------------------------------------------------- | ||
54 | @ Enter Thumb mode | ||
55 | @--------------------------------------------------------------------------------- | ||
56 | add r0, pc, #1 | ||
57 | bx r0 | ||
58 | |||
59 | .thumb | ||
60 | @ Turn off sound | ||
61 | ldr r1, =0x4000084 | ||
62 | eor r0, r0, r0 | ||
63 | strh r0, [r1] | ||
64 | |||
65 | @--------------------------------------------------------------------------------- | ||
66 | @ set heap end | ||
67 | @--------------------------------------------------------------------------------- | ||
68 | ldr r1, =fake_heap_end | ||
69 | ldr r0, =__eheap_end | ||
70 | str r0, [r1] | ||
71 | @--------------------------------------------------------------------------------- | ||
72 | @ global constructors | ||
73 | @--------------------------------------------------------------------------------- | ||
74 | ldr r3, =__libc_init_array | ||
75 | push {lr} | ||
76 | bl _blx_r3_stub | ||
77 | @--------------------------------------------------------------------------------- | ||
78 | @ Jump to user code | ||
79 | @--------------------------------------------------------------------------------- | ||
80 | mov r0, #0 @ int argc | ||
81 | mov r1, #0 @ char *argv[] | ||
82 | ldr r3, =main | ||
83 | bl _blx_r3_stub | ||
84 | @; If we're here, turn the sound back on before we return | ||
85 | ldr r1, =0x4000084 | ||
86 | mov r0, #0x8F | ||
87 | strh r0, [r1] | ||
88 | @; Also turn interrupts back on | ||
89 | ldr r1, =0x4000208 | ||
90 | mov r0, #1 | ||
91 | str r0, [r1] | ||
92 | pop {pc} | ||
93 | |||
94 | @--------------------------------------------------------------------------------- | ||
95 | _blx_r3_stub: | ||
96 | @--------------------------------------------------------------------------------- | ||
97 | bx r3 | ||
98 | |||
99 | .align | ||
100 | .pool | ||
101 | .end | ||
102 | |||