-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinit.asm
110 lines (94 loc) · 2.06 KB
/
init.asm
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
;====
; Defines a section at address 0 to initialise the system as well as any
; SMSLib modules that have been included. Once complete it will jump to an
; 'init' label that you must define in your code.
;
; This file should be included after including the other modules to ensure it
; knows which modules are active.
;====
;====
; Settings
;====
;===
; init.DISABLE_HANDLER
; If defined, disables the boot handler
;===
;====
; Dependencies
;====
.ifndef utils.vdp
.include "utils/vdp.asm"
.endif
;====
; Code
;====
;====
; Boot sequence
;====
.macro "init"
di ; disable interrupts
im 1 ; interrupt mode 1
ld sp, $dff0 ; set stack pointer
; Initialise the system
call init.smslibModules
; Jump to init label, defined by user
jp init
.endm
;====
; Boot sequence at ROM address 0
;====
.ifndef init.DISABLE_HANDLER
.bank 0 slot 0
.orga 0
.section "init.bootHandler" force
init
.ends
.endif
;====
; Initialise any SMSLib modules that are activated
;====
.macro "init.smslibModules"
; initialise paging registers
.ifdef mapper.ENABLED
.ifeq mapper.ENABLED 1
mapper.init
.endif
.endif
; initialise vdp registers
.ifdef vdp.ENABLED
.ifeq vdp.ENABLED 1
vdp.init
.endif
.endif
; initialise pause handler
.ifdef pause.ENABLED
.ifeq pause.ENABLED 1
pause.init
.endif
.endif
; initialise sprite buffer
.ifdef sprites.ENABLED
.ifeq sprites.ENABLED 1
sprites.init
.endif
.endif
; initialise input handler
.ifdef input.ENABLED
.ifeq input.ENABLED 1
input.init
.endif
.endif
; initialise interrupt handler
.ifdef interrupts.ENABLED
.ifeq interrupts.ENABLED 1
interrupts.init
.endif
.endif
.endm
.section "init.smslibModules" free
init.smslibModules:
; Initialise modules
init.smslibModules
; Zeroes VRAM, then returns
jp utils.vdp.clearVram
.ends