-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrbscript.asm
310 lines (269 loc) · 4.25 KB
/
rbscript.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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
; this is what I like to call
; "taking the fun out of scripting" :P
messageid: MACRO
; \1 = text ID
ld a, \1
ld [hSpriteIndexOrTextID], a
call DisplayTextID
ENDM
changescript: MACRO
; \1 = script #
; \2 = script byte address
ld a,\1
ld [\2],a
ENDM
setflag: MACRO
; \1 = bit to set
; \2 = RAM address
ld a, [\2]
set \1,a
ld [\2],a
ENDM
setflag2: MACRO
; \1 = bit to set
; \2 = RAM address
ld hl,\2
set \1,[hl]
ENDM
testflag: MACRO
; \1 = bit to test
; \2 = RAM address
ld a, [\2]
bit \1,a
ENDM
testflag2: MACRO
; \1 = bit to test
; \2 = RAM address
ld hl,\2
bit \1,[hl]
ENDM
resetflag: MACRO
; \1 = bit to set
; \2 = RAM address
ld a, [\2]
res \1,a
ld [\2],a
ENDM
resetflag2: MACRO
; \1 = bit to set
; \2 = RAM address
ld hl,\2
res \1,[hl]
ENDM
enabletextscripts: MACRO
call EnableAutoTextBoxDrawing
ENDM
runscripts: MACRO
; \1 = script counter byte
; \2 = script pointers
ld hl,\2
ld a,[\1]
call CallFunctionInTable
ENDM
playmusicid: MACRO
; \1 = music ID
ld a, \1
call PlayMusicEntry
ENDM
playmusic: MACRO
; \1 = music ID
; \2 = bank
ld a, \1
ld c, \2
call PlayMusic
ENDM
playsound: MACRO
; \1 = sound ID
ld a, \1
call PlaySound
ENDM
showobject: MACRO
; \1 = hideable object ID
ld a, \1
ld [wcc4d], a
predef ShowObject
ENDM
hideobject: MACRO
; \1 = hideable object ID
ld a, \1
ld [wcc4d], a
predef HideObject
ENDM
showemote: MACRO
; \1 = sprite ID
; \2 = emotion
ld a, \1
ld [wcd4f],a
ld a, \2
ld [wcd50],a
predef EmotionBubble
ENDM
selectsprite: MACRO
; \1 = sprite ID
ld a, \1
ld [H_SPRITEINDEX], a
ENDM
selectsprite2: MACRO
; \1 = sprite ID
ld a, \1
ld [wSpriteIndex], a
ENDM
movesprite: MACRO
; \1 = X position on screen
; \2 = Y position on screen
; \3 = X position on map
; \4 = Y position on map
ld a, \2
ld [$ffeb], a
ld a, \1
ld [$ffec], a
ld a, \4
ld [$ffed], a
ld a, \3
ld [$ffee], a
call SetSpritePosition1
ENDM
domovement: MACRO
; \1 = movement table address
ld de, \1
call MoveSprite
ENDM
Left EQU $A0
Right EQU $C0
Down EQU $00
Up EQU $40
End EQU $FF
facesprite: MACRO
; \1 = facing byte
ld a,\1
ld [H_SPRITEOFFSET],a
call SetSpriteFacingDirectionAndDelay
ENDM
setspriteimage: MACRO
; \1 = sprite
; \2 = direction
ld a, (\1 << 4) | \2
ld [$ff8d], a
call SetSpriteImageIndexAfterSettingFacingDirection
ENDM
delay: MACRO
; \1 = no. of frames
ld c, \1
call DelayFrames
ENDM
testcoordsarray: MACRO
; \1 = coordinates array offset
ld hl, \1
call ArePlayerCoordsInArray
ret nc
ENDM
fetchcoordsindex: MACRO
; to be used with checkcoordsarray
ld a, [wWhichTrade]
ENDM
release: MACRO
xor a
ld [wJoyIgnore], a
ENDM
lock: MACRO
ld a, $FF
ld [wJoyIgnore],a
ENDM
lockcontrols: MACRO
; \1 = which controls to be locked
ld a, \1
ld [wJoyIgnore],a
ENDM
setbattle: MACRO
; \1 = trainer
; \2 = trainer instance
; \3 = afterbattle text
ld a, \1 + $C8
ld [W_CUROPPONENT], a
ld a, \2
ld [W_TRAINERNO], a
ld hl, wd72d
set 6, [hl]
set 7, [hl]
ld hl, \3
ld de, \3
call SaveEndBattleTextPointers
ENDM
setbattle2: MACRO
; \1 = trainer
; \2 = trainer instance
ld a, \1 + $C8
ld [W_CUROPPONENT], a
ld a, \2
ld [W_TRAINERNO], a
ENDM
setbattle3: MACRO
; \1 = trainer / pokemon
ld a, \1 + $C8
ld [W_CUROPPONENT], a
ENDM
playmapmusic: MACRO
call PlayDefaultMusic
ENDM
testcoordinates: MACRO
; \1 = X
; \2 = Y
ld a, [W_YCOORD]
cp \2
ret nz
ld a, [W_XCOORD]
cp \1
ret nz
ENDM
loadsprite1: MACRO
; for standing sprites
; \1 = sprite's beginning tile ID in VRAM
; \2 = sprite address
ld hl, vChars0 + (\1 * 16)
ld de, \2
ld bc, (BANK(\2)<<8) + 12
call CopyVideoData
ENDM
loadsprite2: MACRO
; for walking sprites
; \1 = sprite's beginning tile ID in VRAM
; \2 = sprite address
ld hl, vChars1 + (\1 * 16)
ld de, \2 + (12 * 16)
ld bc, (BANK(\2)<<8) + 12
call CopyVideoData
ENDM
giveitem: MACRO
; \1 = item ID
; \2 = quantity
ld bc,(\1 << 8) | \2
push de
ld d, b
ld e, c
callba GiveItem2
pop de
ENDM
givesingleitem: MACRO
; \1 = item ID
push de
ld d, \1
callba GiveSingleItem2
pop de
ENDM
giveitem2: MACRO
; \1 = item ID
; \2 = quantity
ld bc,(\1 << 8) | \2
call GiveItem
ENDM
givesingleitem2: MACRO
; \1 = item ID
ld a, \1
call GiveSingleItem
ENDM
givepokemon: MACRO
; \1 = Pokemon ID
; \2 = level
ld bc,(\1 << 8) | \2
call GivePokemon
ENDM