summaryrefslogtreecommitdiff
path: root/asm/text_window.s
blob: e9ce0b4a114c959c6599c470618d62f91c4b0608 (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
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
	.include "asm/macros.inc"
	.include "constants/constants.inc"

	.syntax unified

	.text

	thumb_func_start sub_8098758
sub_8098758: @ 8098758
	push {lr}
	lsls r0, 24
	lsrs r0, 24
	cmp r0, 0x13
	bhi _08098770
	lsls r0, 3
	ldr r1, =gUnknown_0851021C
	adds r0, r1
	b _08098772
	.pool
_08098770:
	ldr r0, =gUnknown_0851021C
_08098772:
	pop {r1}
	bx r1
	.pool
	thumb_func_end sub_8098758

	thumb_func_start copy_textbox_border_tile_patterns_to_vram
@ void copy_textbox_border_tile_patterns_to_vram(u8 rbox_id, u16 tile_pattern_dest_offset, u8 pal_dest_offset)
copy_textbox_border_tile_patterns_to_vram: @ 809877C
	push {r4,r5,lr}
	adds r4, r1, 0
	adds r5, r2, 0
	lsls r0, 24
	lsrs r0, 24
	lsls r4, 16
	lsrs r4, 16
	lsls r5, 24
	lsrs r5, 24
	movs r1, 0
	bl GetWindowAttribute
	lsls r0, 24
	lsrs r0, 24
	ldr r1, =gUnknown_08DDD748
	movs r2, 0xE0
	lsls r2, 1
	adds r3, r4, 0
	bl LoadBgTiles
	bl sub_8098C64
	adds r1, r5, 0
	movs r2, 0x20
	bl gpu_pal_apply
	pop {r4,r5}
	pop {r0}
	bx r0
	.pool
	thumb_func_end copy_textbox_border_tile_patterns_to_vram

	thumb_func_start box_border_load_tiles_and_pal
box_border_load_tiles_and_pal: @ 80987BC
	push {lr}
	lsls r0, 24
	lsrs r0, 24
	lsls r1, 16
	lsrs r1, 16
	lsls r2, 24
	lsrs r2, 24
	bl sub_809882C
	pop {r0}
	bx r0
	thumb_func_end box_border_load_tiles_and_pal

	thumb_func_start sub_80987D4
sub_80987D4: @ 80987D4
	push {r4-r6,lr}
	mov r6, r8
	push {r6}
	adds r4, r1, 0
	adds r6, r2, 0
	mov r8, r3
	lsls r0, 24
	lsrs r0, 24
	lsls r4, 24
	lsrs r4, 24
	lsls r6, 16
	lsrs r6, 16
	mov r1, r8
	lsls r1, 24
	lsrs r1, 24
	mov r8, r1
	movs r1, 0
	bl GetWindowAttribute
	lsls r0, 24
	lsrs r0, 24
	ldr r5, =gUnknown_0851021C
	lsls r4, 3
	adds r1, r4, r5
	ldr r1, [r1]
	movs r2, 0x90
	lsls r2, 1
	adds r3, r6, 0
	bl LoadBgTiles
	adds r5, 0x4
	adds r4, r5
	ldr r0, [r4]
	mov r1, r8
	movs r2, 0x20
	bl gpu_pal_apply
	pop {r3}
	mov r8, r3
	pop {r4-r6}
	pop {r0}
	bx r0
	.pool
	thumb_func_end sub_80987D4

	thumb_func_start sub_809882C
sub_809882C: @ 809882C
	push {r4,lr}
	adds r4, r1, 0
	adds r3, r2, 0
	lsls r0, 24
	lsrs r0, 24
	lsls r4, 16
	lsrs r4, 16
	lsls r3, 24
	lsrs r3, 24
	ldr r1, =gUnknown_03005D90
	ldr r1, [r1]
	ldrb r1, [r1, 0x14]
	lsrs r1, 3
	adds r2, r4, 0
	bl sub_80987D4
	pop {r4}
	pop {r0}
	bx r0
	.pool
	thumb_func_end sub_809882C

	thumb_func_start sub_8098858
sub_8098858: @ 8098858
	push {r4-r7,lr}
	mov r7, r10
	mov r6, r9
	mov r5, r8
	push {r5-r7}
	sub sp, 0x20
	adds r4, r0, 0
	adds r5, r1, 0
	lsls r4, 24
	lsrs r4, 24
	lsls r5, 16
	lsrs r5, 16
	lsls r2, 24
	lsrs r2, 24
	str r2, [sp, 0xC]
	adds r0, r4, 0
	movs r1, 0
	bl GetWindowAttribute
	lsls r0, 24
	lsrs r7, r0, 24
	adds r0, r4, 0
	movs r1, 0x1
	bl GetWindowAttribute
	mov r8, r0
	lsls r0, 16
	lsrs r0, 16
	mov r8, r0
	adds r0, r4, 0
	movs r1, 0x2
	bl GetWindowAttribute
	adds r6, r0, 0
	lsls r6, 16
	lsrs r6, 16
	adds r0, r4, 0
	movs r1, 0x3
	bl GetWindowAttribute
	mov r9, r0
	mov r2, r9
	lsls r2, 16
	lsrs r2, 16
	mov r9, r2
	adds r0, r4, 0
	movs r1, 0x4
	bl GetWindowAttribute
	lsls r0, 16
	lsrs r0, 16
	str r0, [sp, 0x10]
	mov r0, r8
	subs r0, 0x1
	lsls r2, r0, 24
	lsrs r2, 24
	str r2, [sp, 0x14]
	subs r4, r6, 0x1
	lsls r4, 24
	lsrs r4, 24
	movs r0, 0x1
	mov r10, r0
	str r0, [sp]
	str r0, [sp, 0x4]
	ldr r2, [sp, 0xC]
	str r2, [sp, 0x8]
	adds r0, r7, 0
	adds r1, r5, 0
	ldr r2, [sp, 0x14]
	adds r3, r4, 0
	bl FillBgTilemapBufferRect
	adds r1, r5, 0x1
	lsls r1, 16
	lsrs r1, 16
	mov r0, r8
	lsls r2, r0, 24
	lsrs r2, 24
	str r2, [sp, 0x18]
	mov r2, r9
	lsls r0, r2, 24
	lsrs r0, 24
	str r0, [sp, 0x1C]
	str r0, [sp]
	mov r0, r10
	str r0, [sp, 0x4]
	ldr r2, [sp, 0xC]
	str r2, [sp, 0x8]
	adds r0, r7, 0
	ldr r2, [sp, 0x18]
	adds r3, r4, 0
	bl FillBgTilemapBufferRect
	adds r1, r5, 0x2
	lsls r1, 16
	lsrs r1, 16
	add r8, r9
	mov r0, r8
	lsls r0, 24
	lsrs r0, 24
	mov r8, r0
	mov r2, r10
	str r2, [sp]
	str r2, [sp, 0x4]
	ldr r0, [sp, 0xC]
	str r0, [sp, 0x8]
	adds r0, r7, 0
	mov r2, r8
	adds r3, r4, 0
	bl FillBgTilemapBufferRect
	adds r1, r5, 0x3
	lsls r1, 16
	lsrs r1, 16
	lsls r2, r6, 24
	lsrs r2, 24
	mov r9, r2
	mov r0, r10
	str r0, [sp]
	ldr r2, [sp, 0x10]
	lsls r4, r2, 24
	lsrs r4, 24
	str r4, [sp, 0x4]
	ldr r0, [sp, 0xC]
	str r0, [sp, 0x8]
	adds r0, r7, 0
	ldr r2, [sp, 0x14]
	mov r3, r9
	bl FillBgTilemapBufferRect
	adds r1, r5, 0x5
	lsls r1, 16
	lsrs r1, 16
	mov r2, r10
	str r2, [sp]
	str r4, [sp, 0x4]
	ldr r0, [sp, 0xC]
	str r0, [sp, 0x8]
	adds r0, r7, 0
	mov r2, r8
	mov r3, r9
	bl FillBgTilemapBufferRect
	adds r1, r5, 0x6
	lsls r1, 16
	lsrs r1, 16
	ldr r2, [sp, 0x10]
	adds r6, r2
	lsls r6, 24
	lsrs r6, 24
	mov r0, r10
	str r0, [sp]
	str r0, [sp, 0x4]
	ldr r2, [sp, 0xC]
	str r2, [sp, 0x8]
	adds r0, r7, 0
	ldr r2, [sp, 0x14]
	adds r3, r6, 0
	bl FillBgTilemapBufferRect
	adds r1, r5, 0x7
	lsls r1, 16
	lsrs r1, 16
	ldr r0, [sp, 0x1C]
	str r0, [sp]
	mov r2, r10
	str r2, [sp, 0x4]
	ldr r0, [sp, 0xC]
	str r0, [sp, 0x8]
	adds r0, r7, 0
	ldr r2, [sp, 0x18]
	adds r3, r6, 0
	bl FillBgTilemapBufferRect
	adds r5, 0x8
	lsls r5, 16
	lsrs r5, 16
	mov r2, r10
	str r2, [sp]
	str r2, [sp, 0x4]
	ldr r0, [sp, 0xC]
	str r0, [sp, 0x8]
	adds r0, r7, 0
	adds r1, r5, 0
	mov r2, r8
	adds r3, r6, 0
	bl FillBgTilemapBufferRect
	add sp, 0x20
	pop {r3-r5}
	mov r8, r3
	mov r9, r4
	mov r10, r5
	pop {r4-r7}
	pop {r0}
	bx r0
	thumb_func_end sub_8098858

	thumb_func_start sub_80989E0
sub_80989E0: @ 80989E0
	push {r4-r7,lr}
	mov r7, r10
	mov r6, r9
	mov r5, r8
	push {r5-r7}
	sub sp, 0x1C
	adds r4, r0, 0
	mov r9, r1
	lsls r4, 24
	lsrs r4, 24
	mov r0, r9
	lsls r0, 16
	lsrs r0, 16
	mov r9, r0
	lsls r2, 24
	lsrs r2, 24
	mov r10, r2
	adds r0, r4, 0
	movs r1, 0
	bl GetWindowAttribute
	lsls r0, 24
	lsrs r7, r0, 24
	adds r0, r4, 0
	movs r1, 0x1
	bl GetWindowAttribute
	mov r8, r0
	lsls r0, 16
	lsrs r0, 16
	mov r8, r0
	adds r0, r4, 0
	movs r1, 0x2
	bl GetWindowAttribute
	adds r6, r0, 0
	lsls r6, 16
	lsrs r6, 16
	adds r0, r4, 0
	movs r1, 0x3
	bl GetWindowAttribute
	adds r5, r0, 0
	lsls r5, 16
	lsrs r5, 16
	adds r0, r4, 0
	movs r1, 0x4
	bl GetWindowAttribute
	lsls r0, 16
	lsrs r0, 16
	str r0, [sp, 0xC]
	mov r0, r8
	lsls r2, r0, 24
	lsrs r2, 24
	str r2, [sp, 0x10]
	lsls r4, r6, 24
	lsrs r4, 24
	movs r0, 0x1
	str r0, [sp]
	str r0, [sp, 0x4]
	mov r0, r10
	str r0, [sp, 0x8]
	adds r0, r7, 0
	mov r1, r9
	adds r3, r4, 0
	bl FillBgTilemapBufferRect
	mov r1, r9
	adds r1, 0x1
	lsls r1, 16
	lsrs r1, 16
	mov r0, r8
	adds r0, 0x1
	lsls r2, r0, 24
	lsrs r2, 24
	str r2, [sp, 0x14]
	subs r0, r5, 0x2
	lsls r0, 24
	lsrs r0, 24
	str r0, [sp, 0x18]
	str r0, [sp]
	movs r0, 0x1
	str r0, [sp, 0x4]
	mov r0, r10
	str r0, [sp, 0x8]
	adds r0, r7, 0
	adds r3, r4, 0
	bl FillBgTilemapBufferRect
	mov r1, r9
	adds r1, 0x2
	lsls r1, 16
	lsrs r1, 16
	add r8, r5
	movs r0, 0x1
	negs r0, r0
	add r8, r0
	mov r0, r8
	lsls r0, 24
	lsrs r0, 24
	mov r8, r0
	movs r0, 0x1
	str r0, [sp]
	str r0, [sp, 0x4]
	mov r0, r10
	str r0, [sp, 0x8]
	adds r0, r7, 0
	mov r2, r8
	adds r3, r4, 0
	bl FillBgTilemapBufferRect
	mov r1, r9
	adds r1, 0x3
	lsls r1, 16
	lsrs r1, 16
	adds r5, r6, 0x1
	lsls r5, 24
	lsrs r5, 24
	movs r0, 0x1
	str r0, [sp]
	ldr r4, [sp, 0xC]
	subs r4, 0x2
	lsls r4, 24
	lsrs r4, 24
	str r4, [sp, 0x4]
	mov r0, r10
	str r0, [sp, 0x8]
	adds r0, r7, 0
	ldr r2, [sp, 0x10]
	adds r3, r5, 0
	bl FillBgTilemapBufferRect
	mov r1, r9
	adds r1, 0x5
	lsls r1, 16
	lsrs r1, 16
	movs r0, 0x1
	str r0, [sp]
	str r4, [sp, 0x4]
	mov r0, r10
	str r0, [sp, 0x8]
	adds r0, r7, 0
	mov r2, r8
	adds r3, r5, 0
	bl FillBgTilemapBufferRect
	mov r1, r9
	adds r1, 0x6
	lsls r1, 16
	lsrs r1, 16
	ldr r0, [sp, 0xC]
	adds r6, r0
	subs r6, 0x1
	lsls r6, 24
	lsrs r6, 24
	movs r0, 0x1
	str r0, [sp]
	str r0, [sp, 0x4]
	mov r0, r10
	str r0, [sp, 0x8]
	adds r0, r7, 0
	ldr r2, [sp, 0x10]
	adds r3, r6, 0
	bl FillBgTilemapBufferRect
	mov r1, r9
	adds r1, 0x7
	lsls r1, 16
	lsrs r1, 16
	ldr r0, [sp, 0x18]
	str r0, [sp]
	movs r0, 0x1
	str r0, [sp, 0x4]
	mov r0, r10
	str r0, [sp, 0x8]
	adds r0, r7, 0
	ldr r2, [sp, 0x14]
	adds r3, r6, 0
	bl FillBgTilemapBufferRect
	movs r0, 0x8
	add r9, r0
	mov r0, r9
	lsls r0, 16
	lsrs r0, 16
	mov r9, r0
	movs r0, 0x1
	str r0, [sp]
	str r0, [sp, 0x4]
	mov r0, r10
	str r0, [sp, 0x8]
	adds r0, r7, 0
	mov r1, r9
	mov r2, r8
	adds r3, r6, 0
	bl FillBgTilemapBufferRect
	add sp, 0x1C
	pop {r3-r5}
	mov r8, r3
	mov r9, r4
	mov r10, r5
	pop {r4-r7}
	pop {r0}
	bx r0
	thumb_func_end sub_80989E0

	thumb_func_start rbox_fill_rectangle
rbox_fill_rectangle: @ 8098B7C
	push {r4-r6,lr}
	mov r6, r9
	mov r5, r8
	push {r5,r6}
	sub sp, 0xC
	adds r6, r0, 0
	lsls r6, 24
	lsrs r6, 24
	adds r0, r6, 0
	movs r1, 0
	bl GetWindowAttribute
	mov r9, r0
	lsls r0, 24
	lsrs r0, 24
	mov r9, r0
	adds r0, r6, 0
	movs r1, 0x1
	bl GetWindowAttribute
	mov r8, r0
	mov r1, r8
	lsls r1, 16
	lsrs r1, 16
	mov r8, r1
	adds r0, r6, 0
	movs r1, 0x2
	bl GetWindowAttribute
	adds r5, r0, 0
	lsls r5, 16
	lsrs r5, 16
	adds r0, r6, 0
	movs r1, 0x3
	bl GetWindowAttribute
	adds r4, r0, 0
	lsls r4, 16
	lsrs r4, 16
	adds r0, r6, 0
	movs r1, 0x4
	bl GetWindowAttribute
	movs r1, 0x1
	negs r1, r1
	add r8, r1
	mov r1, r8
	lsls r1, 24
	lsrs r1, 24
	mov r8, r1
	subs r5, 0x1
	lsls r5, 24
	lsrs r5, 24
	adds r4, 0x2
	lsls r4, 24
	lsrs r4, 24
	str r4, [sp]
	lsls r0, 24
	movs r1, 0x80
	lsls r1, 18
	adds r0, r1
	lsrs r0, 24
	str r0, [sp, 0x4]
	movs r0, 0x11
	str r0, [sp, 0x8]
	mov r0, r9
	movs r1, 0
	mov r2, r8
	adds r3, r5, 0
	bl FillBgTilemapBufferRect
	add sp, 0xC
	pop {r3,r4}
	mov r8, r3
	mov r9, r4
	pop {r4-r6}
	pop {r0}
	bx r0
	thumb_func_end rbox_fill_rectangle

	thumb_func_start stdpal_get
stdpal_get: @ 8098C18
	push {lr}
	lsls r0, 24
	lsrs r0, 24
	cmp r0, 0x4
	bhi _08098C54
	lsls r0, 2
	ldr r1, =_08098C30
	adds r0, r1
	ldr r0, [r0]
	mov pc, r0
	.pool
	.align 2, 0
_08098C30:
	.4byte _08098C44
	.4byte _08098C48
	.4byte _08098C4C
	.4byte _08098C50
	.4byte _08098C54
_08098C44:
	movs r0, 0
	b _08098C56
_08098C48:
	movs r0, 0x10
	b _08098C56
_08098C4C:
	movs r0, 0x20
	b _08098C56
_08098C50:
	movs r0, 0x30
	b _08098C56
_08098C54:
	movs r0, 0x40
_08098C56:
	lsls r0, 1
	ldr r1, =gUnknown_0851017C
	adds r0, r1
	pop {r1}
	bx r1
	.pool
	thumb_func_end stdpal_get

	thumb_func_start sub_8098C64
sub_8098C64: @ 8098C64
	ldr r0, =gUnknown_08DDD728
	bx lr
	.pool
	thumb_func_end sub_8098C64

	thumb_func_start sub_8098C6C
sub_8098C6C: @ 8098C6C
	push {r4,r5,lr}
	adds r3, r1, 0
	adds r4, r2, 0
	lsls r0, 24
	lsrs r0, 24
	lsls r3, 16
	lsrs r3, 16
	lsls r4, 24
	lsrs r4, 24
	ldr r2, =gUnknown_0851021C
	ldr r5, =gUnknown_03005D90
	ldr r1, [r5]
	ldrb r1, [r1, 0x14]
	lsrs r1, 3
	lsls r1, 3
	adds r1, r2
	ldr r1, [r1]
	movs r2, 0x90
	lsls r2, 1
	bl LoadBgTiles
	ldr r0, [r5]
	ldrb r0, [r0, 0x14]
	lsrs r0, 3
	bl sub_8098758
	ldr r0, [r0, 0x4]
	adds r1, r4, 0
	movs r2, 0x20
	bl gpu_pal_apply
	pop {r4,r5}
	pop {r0}
	bx r0
	.pool
	thumb_func_end sub_8098C6C

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