-
Notifications
You must be signed in to change notification settings - Fork 0
/
Defines.asm
149 lines (123 loc) · 2.81 KB
/
Defines.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
; ===============
; Project defines
; ===============
if !def(definesIncluded)
definesIncluded set 1
; Hardware defines
include "hardware.inc"
; ================
; Global constants
; ================
sys_DMG equ 0
sys_GBP equ 1
sys_SGB equ 2
sys_SGB2 equ 3
sys_GBC equ 4
sys_GBA equ 5
btnA equ 0
btnB equ 1
btnSelect equ 2
btnStart equ 3
btnRight equ 4
btnLeft equ 5
btnUp equ 6
btnDown equ 7
_A equ 1
_B equ 2
_Select equ 4
_Start equ 8
_Right equ 16
_Left equ 32
_Up equ 64
_Down equ 128
; ==========================
; Project-specific constants
; ==========================
; ======
; Macros
; ======
; Copy a tileset to a specified VRAM address.
; USAGE: CopyTileset [tileset],[VRAM address],[number of tiles to copy]
CopyTileset: macro
ld bc,$10*\3 ; number of tiles to copy
ld hl,\1 ; address of tiles to copy
ld de,$8000+\2 ; address to copy to
call _CopyTileset
endm
; Same as CopyTileset, but waits for VRAM accessibility.
CopyTilesetSafe: macro
ld bc,$10*\3 ; number of tiles to copy
ld hl,\1 ; address of tiles to copy
ld de,$8000+\2 ; address to copy to
call _CopyTilesetSafe
endm
; Copy a 1BPP tileset to a specified VRAM address.
; USAGE: CopyTileset1BPP [tileset],[VRAM address],[number of tiles to copy]
CopyTileset1BPP: macro
ld bc,$10*\3 ; number of tiles to copy
ld hl,\1 ; address of tiles to copy
ld de,$8000+\2 ; address to copy to
call _CopyTileset1BPP
endm
; Same as CopyTileset1BPP, but waits for VRAM accessibility.
CopyTileset1BPPSafe: macro
ld bc,$10*\3 ; number of tiles to copy
ld hl,\1 ; address of tiles to copy
ld de,$8000+\2 ; address to copy to
call _CopyTileset1BPPSafe
endm
; Loads a DMG palette.
; USAGE: SetPal <rBGP/rOBP0/rOBP1>,(color 1),(color 2),(color 3),(color 4)
SetDMGPal: macro
ld a,(\2 + (\3 << 2) + (\4 << 4) + (\5 << 6))
ldh [\1],a
endm
; Define ROM title.
romTitle: macro
.str\@
db \1
.str\@_end
rept 15-(.str\@_end-.str\@)
db 0
endr
endm
endc
; Wait for VRAM accessibility.
WaitForVRAM: macro
ldh a,[rSTAT]
and 2
jr nz,@-4
endm
RestoreStackPtr: macro
ld hl,tempSP
call PtrToHL
ld sp,hl
endm
string: macro
db \1,0
endm
; === Project-specific macros ===
; =========
; Variables
; =========
section "Variables",wram0[$c000]
SpriteBuffer: ds 40*4 ; 40 sprites, 4 bytes each
sys_GBType: ds 1
sys_CurrentFrame: ds 1
sys_btnPress: ds 1
sys_btnHold: ds 1
sys_VBlankFlag: ds 1
sys_TimerFlag: ds 1
sys_LCDCFlag: ds 1
; project-specific
ScrollerPos: ds 2
ScrollerOffset: ds 1
FadeLevel: ds 1
DemoTimer: ds 1
section "Zeropage",hram
OAM_DMA: ds 16
tempAF: ds 2
tempBC: ds 2
tempDE: ds 2
tempHL: ds 2
tempSP: ds 2