summaryrefslogtreecommitdiff
path: root/asm/decoration_inventory.s
blob: 7a909f585354ed28bfd6484ab0e09d85eff627b5 (plain)
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
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
	.include "asm/macros.inc"
	.include "constants/constants.inc"

	.syntax unified

	.text

    
	thumb_func_start SetDecorationInventoriesPointers
SetDecorationInventoriesPointers: @ 81617F4
	push {r4,lr}
	ldr r0, =gDecorationInventories
	mov r12, r0
	ldr r0, =gSaveBlock1Ptr
	ldr r1, [r0]
	ldr r2, =0x00002734
	adds r0, r1, r2
	mov r4, r12
	str r0, [r4]
	movs r3, 0xA
	strb r3, [r4, 0x4]
	adds r2, 0xA
	adds r0, r1, r2
	str r0, [r4, 0x8]
	strb r3, [r4, 0xC]
	ldr r4, =0x00002748
	adds r0, r1, r4
	mov r2, r12
	str r0, [r2, 0x10]
	strb r3, [r2, 0x14]
	adds r4, 0xA
	adds r0, r1, r4
	str r0, [r2, 0x18]
	movs r2, 0x1E
	mov r0, r12
	strb r2, [r0, 0x1C]
	adds r4, 0x1E
	adds r0, r1, r4
	mov r4, r12
	str r0, [r4, 0x20]
	mov r0, r12
	adds r0, 0x24
	strb r2, [r0]
	ldr r2, =0x0000278e
	adds r0, r1, r2
	str r0, [r4, 0x28]
	mov r0, r12
	adds r0, 0x2C
	strb r3, [r0]
	ldr r4, =0x00002798
	adds r0, r1, r4
	mov r2, r12
	str r0, [r2, 0x30]
	adds r2, 0x34
	movs r0, 0x28
	strb r0, [r2]
	adds r4, 0x28
	adds r1, r4
	mov r0, r12
	str r1, [r0, 0x38]
	adds r0, 0x3C
	strb r3, [r0]
	bl sub_8126968
	pop {r4}
	pop {r0}
	bx r0
	.pool
	thumb_func_end SetDecorationInventoriesPointers

	thumb_func_start ClearDecorationInventory
ClearDecorationInventory: @ 8161880
	push {r4,r5,lr}
	lsls r0, 24
	movs r3, 0
	ldr r1, =gDecorationInventories
	lsrs r2, r0, 21
	adds r0, r2, r1
	ldrb r0, [r0, 0x4]
	cmp r3, r0
	bcs _081618AA
	adds r5, r1, 0
	movs r4, 0
_08161896:
	adds r0, r2, r5
	ldr r1, [r0]
	adds r1, r3
	strb r4, [r1]
	adds r1, r3, 0x1
	lsls r1, 24
	lsrs r3, r1, 24
	ldrb r0, [r0, 0x4]
	cmp r3, r0
	bcc _08161896
_081618AA:
	pop {r4,r5}
	pop {r0}
	bx r0
	.pool
	thumb_func_end ClearDecorationInventory

	thumb_func_start ClearDecorationInventories
ClearDecorationInventories: @ 81618B4
	push {r4,lr}
	movs r4, 0
_081618B8:
	adds r0, r4, 0
	bl ClearDecorationInventory
	adds r0, r4, 0x1
	lsls r0, 24
	lsrs r4, r0, 24
	cmp r4, 0x7
	bls _081618B8
	pop {r4}
	pop {r0}
	bx r0
	thumb_func_end ClearDecorationInventories

	thumb_func_start sub_81618D0
sub_81618D0: @ 81618D0
	push {r4,lr}
	lsls r0, 24
	movs r2, 0
	ldr r1, =gDecorationInventories
	lsrs r0, 21
	adds r0, r1
	movs r1, 0x4
	ldrsb r1, [r0, r1]
	cmp r2, r1
	bge _0816190C
	adds r4, r0, 0
	adds r3, r1, 0
_081618E8:
	lsls r0, r2, 24
	asrs r1, r0, 24
	ldr r0, [r4]
	adds r0, r1
	ldrb r0, [r0]
	cmp r0, 0
	bne _08161900
	adds r0, r1, 0
	b _08161910
	.pool
_08161900:
	adds r0, r1, 0x1
	lsls r0, 24
	lsrs r2, r0, 24
	asrs r0, 24
	cmp r0, r3
	blt _081618E8
_0816190C:
	movs r0, 0x1
	negs r0, r0
_08161910:
	pop {r4}
	pop {r1}
	bx r1
	thumb_func_end sub_81618D0

	thumb_func_start CheckHasDecoration
CheckHasDecoration: @ 8161918
	push {r4,lr}
	lsls r0, 24
	lsrs r3, r0, 24
	ldr r1, =gDecorations
	lsls r0, r3, 5
	adds r0, r1
	ldrb r0, [r0, 0x13]
	movs r2, 0
	ldr r1, =gDecorationInventories
	lsls r0, 3
	adds r0, r1
	ldrb r1, [r0, 0x4]
	cmp r2, r1
	bcs _08161956
	ldr r4, [r0]
_08161936:
	adds r0, r4, r2
	ldrb r0, [r0]
	cmp r0, r3
	bne _0816194C
	movs r0, 0x1
	b _08161958
	.pool
_0816194C:
	adds r0, r2, 0x1
	lsls r0, 24
	lsrs r2, r0, 24
	cmp r2, r1
	bcc _08161936
_08161956:
	movs r0, 0
_08161958:
	pop {r4}
	pop {r1}
	bx r1
	thumb_func_end CheckHasDecoration

	thumb_func_start DecorationAdd
DecorationAdd: @ 8161960
	push {r4,r5,lr}
	lsls r0, 24
	lsrs r0, 24
	adds r4, r0, 0
	cmp r4, 0
	beq _081619A0
	ldr r1, =gDecorations
	lsls r0, r4, 5
	adds r0, r1
	ldrb r5, [r0, 0x13]
	adds r0, r5, 0
	bl sub_81618D0
	lsls r0, 24
	asrs r2, r0, 24
	movs r0, 0x1
	negs r0, r0
	cmp r2, r0
	beq _081619A0
	ldr r0, =gDecorationInventories
	lsls r1, r5, 3
	adds r1, r0
	ldr r0, [r1]
	adds r0, r2
	strb r4, [r0]
	movs r0, 0x1
	b _081619A2
	.pool
_081619A0:
	movs r0, 0
_081619A2:
	pop {r4,r5}
	pop {r1}
	bx r1
	thumb_func_end DecorationAdd

	thumb_func_start DecorationCheckSpace
DecorationCheckSpace: @ 81619A8
	push {lr}
	lsls r0, 24
	lsrs r0, 24
	cmp r0, 0
	beq _081619D4
	ldr r1, =gDecorations
	lsls r0, 5
	adds r0, r1
	ldrb r0, [r0, 0x13]
	bl sub_81618D0
	lsls r0, 24
	asrs r0, 24
	movs r1, 0x1
	negs r1, r1
	cmp r0, r1
	beq _081619D4
	movs r0, 0x1
	b _081619D6
	.pool
_081619D4:
	movs r0, 0
_081619D6:
	pop {r1}
	bx r1
	thumb_func_end DecorationCheckSpace

	thumb_func_start DecorationRemove
DecorationRemove: @ 81619DC
	push {r4-r6,lr}
	lsls r0, 24
	lsrs r5, r0, 24
	movs r3, 0
	cmp r5, 0
	bne _081619F8
	b _08161A26
_081619EA:
	movs r0, 0
	strb r0, [r1]
	adds r0, r6, 0
	bl sub_8161A38
	movs r0, 0x1
	b _08161A28
_081619F8:
	ldr r2, =gDecorationInventories
	ldr r1, =gDecorations
	lsls r0, r5, 5
	adds r0, r1
	ldrb r4, [r0, 0x13]
	lsls r0, r4, 3
	adds r0, r2
	ldrb r1, [r0, 0x4]
	cmp r3, r1
	bcs _08161A26
	adds r6, r4, 0
	adds r4, r0, 0
	adds r2, r1, 0
_08161A12:
	ldr r0, [r4]
	adds r1, r0, r3
	ldrb r0, [r1]
	cmp r0, r5
	beq _081619EA
	adds r0, r3, 0x1
	lsls r0, 24
	lsrs r3, r0, 24
	cmp r3, r2
	bcc _08161A12
_08161A26:
	movs r0, 0
_08161A28:
	pop {r4-r6}
	pop {r1}
	bx r1
	.pool
	thumb_func_end DecorationRemove

	thumb_func_start sub_8161A38
sub_8161A38: @ 8161A38
	push {r4-r7,lr}
	mov r7, r10
	mov r6, r9
	mov r5, r8
	push {r5-r7}
	sub sp, 0x4
	lsls r0, 24
	movs r6, 0
	ldr r2, =gDecorationInventories
	lsrs r0, 21
	adds r1, r0, r2
	ldrb r3, [r1, 0x4]
	cmp r6, r3
	bcs _08161ABC
	adds r7, r0, 0
	mov r10, r1
	mov r0, r10
	str r0, [sp]
_08161A5C:
	adds r1, r6, 0x1
	lsls r0, r1, 24
	lsrs r3, r0, 24
	adds r2, r7, 0
	mov r12, r1
	mov r1, r10
	ldrb r1, [r1, 0x4]
	cmp r3, r1
	bcs _08161AAE
	ldr r0, =gDecorationInventories
	mov r9, r0
	adds r1, r0, 0
	mov r8, r1
_08161A76:
	mov r0, r9
	adds r5, r2, r0
	ldr r1, [r5]
	adds r0, r1, r3
	ldrb r4, [r0]
	adds r2, r4, 0
	cmp r2, 0
	beq _08161A9C
	adds r0, r1, r6
	ldrb r1, [r0]
	cmp r1, 0
	beq _08161A92
	cmp r1, r2
	bls _08161A9C
_08161A92:
	ldrb r1, [r0]
	strb r4, [r0]
	ldr r0, [r5]
	adds r0, r3
	strb r1, [r0]
_08161A9C:
	adds r0, r3, 0x1
	lsls r0, 24
	lsrs r3, r0, 24
	adds r2, r7, 0
	mov r1, r8
	adds r0, r2, r1
	ldrb r0, [r0, 0x4]
	cmp r3, r0
	bcc _08161A76
_08161AAE:
	mov r3, r12
	lsls r0, r3, 24
	lsrs r6, r0, 24
	ldr r0, [sp]
	ldrb r0, [r0, 0x4]
	cmp r6, r0
	bcc _08161A5C
_08161ABC:
	add sp, 0x4
	pop {r3-r5}
	mov r8, r3
	mov r9, r4
	mov r10, r5
	pop {r4-r7}
	pop {r0}
	bx r0
	.pool
	thumb_func_end sub_8161A38

	thumb_func_start sub_8161AD0
sub_8161AD0: @ 8161AD0
	push {r4,r5,lr}
	lsls r0, 24
	movs r4, 0
	movs r3, 0
	ldr r2, =gDecorationInventories
	lsrs r1, r0, 21
	adds r0, r1, r2
	ldrb r0, [r0, 0x4]
	cmp r4, r0
	bcs _08161B04
	adds r5, r2, 0
_08161AE6:
	adds r2, r1, r5
	ldr r0, [r2]
	adds r0, r3
	ldrb r0, [r0]
	cmp r0, 0
	beq _08161AF8
	adds r0, r4, 0x1
	lsls r0, 24
	lsrs r4, r0, 24
_08161AF8:
	adds r0, r3, 0x1
	lsls r0, 24
	lsrs r3, r0, 24
	ldrb r2, [r2, 0x4]
	cmp r3, r2
	bcc _08161AE6
_08161B04:
	adds r0, r4, 0
	pop {r4,r5}
	pop {r1}
	bx r1
	.pool
	thumb_func_end sub_8161AD0

	thumb_func_start sub_8161B10
sub_8161B10: @ 8161B10
	push {r4,r5,lr}
	movs r5, 0
	movs r4, 0
_08161B16:
	adds r0, r4, 0
	bl sub_8161AD0
	adds r0, r5, r0
	lsls r0, 24
	lsrs r5, r0, 24
	adds r0, r4, 0x1
	lsls r0, 24
	lsrs r4, r0, 24
	cmp r4, 0x7
	bls _08161B16
	adds r0, r5, 0
	pop {r4,r5}
	pop {r1}
	bx r1
	thumb_func_end sub_8161B10

	.align 2, 0 @ Don't pad with nop.