-
Notifications
You must be signed in to change notification settings - Fork 2.7k
/
decoration.c
2780 lines (2553 loc) · 76 KB
/
decoration.c
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
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "global.h"
#include "decompress.h"
#include "malloc.h"
#include "text.h"
#include "string_util.h"
#include "international_string_util.h"
#include "script.h"
#include "task.h"
#include "main.h"
#include "palette.h"
#include "songs.h"
#include "overworld.h"
#include "fieldmap.h"
#include "metatile_behavior.h"
#include "field_weather.h"
#include "field_player_avatar.h"
#include "field_camera.h"
#include "field_screen.h"
#include "field_map_obj.h"
#include "list_menu.h"
#include "menu_helpers.h"
#include "new_menu_helpers.h"
#include "menu_indicators.h"
#include "sound.h"
#include "event_scripts.h"
#include "event_data.h"
#include "region_map.h"
#include "player_pc.h"
#include "strings.h"
#include "tv.h"
#include "secret_base.h"
#include "tilesets.h"
#include "item_icon.h"
#include "trader.h"
#include "map_object_constants.h"
#include "decoration_inventory.h"
#include "decoration.h"
#include "graphics.h"
// Static type declarations
#define OVERWORLD_PLACE_DECOR_SELECTOR_PAL_TAG 0xbe5
#define OVERWORLD_PLACE_DECOR_PLAYER_PAL_TAG 0x008
struct DecorPCBuffer {
struct ListMenuItem items[41];
u8 names[41][24];
u8 unk_520;
u8 unk_521;
u8 unk_522;
};
struct PlaceDecorationGraphicsDataBuffer {
/*0x000; 0x0203a190*/ const struct Decoration *decoration;
/*0x004; 0x0203a194*/ u16 tiles[0x40];
/*0x084; 0x0203a214*/ u8 image[0x800];
/*0x884; 0x0203aa14*/ u16 palette[16];
};
struct DecorRearrangementDataBuffer {
u8 idx;
u8 width;
u8 height;
u16 flagId;
};
// Static RAM declarations
EWRAM_DATA u8 *gCurDecorInventoryItems = NULL;
EWRAM_DATA static u8 sSecretBasePCMenuCursorPos = 0;
EWRAM_DATA static u8 sCurDecorCatCount = 0;
EWRAM_DATA static u8 sSecretBaseItemsIndicesBuffer[16] = {};
EWRAM_DATA static u8 sPlayerRoomItemsIndicesBuffer[12] = {};
EWRAM_DATA static u16 sSecretBasePCSelectDecorLineNo = 0;
EWRAM_DATA static u16 sSecretBasePCSelectDecorPageNo = 0;
EWRAM_DATA u8 gCurDecorationIndex = 0;
EWRAM_DATA static u8 sCurDecorationCategory = DECORCAT_DESK;
EWRAM_DATA static u32 filler_0203a174[2] = {};
EWRAM_DATA struct DecorPCPointers gUnknown_0203A17C = {};
EWRAM_DATA static u8 sDecorMenuWindowIndices[4] = {};
EWRAM_DATA struct DecorPCBuffer *sDecorPCBuffer = NULL;
EWRAM_DATA struct PlaceDecorationGraphicsDataBuffer sPlaceDecorationGraphicsDataBuffer = {};
EWRAM_DATA static u16 sCurDecorMapX = 0;
EWRAM_DATA static u16 sCurDecorMapY = 0;
EWRAM_DATA static u8 sDecor_CameraSpriteObjectIdx1 = 0;
EWRAM_DATA static u8 sDecor_CameraSpriteObjectIdx2 = 0;
EWRAM_DATA static u8 sDecorationLastDirectionMoved = 0;
EWRAM_DATA static struct OamData sDecorSelectorOam = {};
EWRAM_DATA static struct DecorRearrangementDataBuffer sDecorRearrangementDataBuffer[16] = {};
EWRAM_DATA static u8 sCurDecorSelectedInRearrangement = 0;
// Static ROM declarations
void sub_8126B80(u8 taskId);
void sub_8126C08(void);
void SecretBasePC_Decorate(u8 taskId);
void SecretBasePC_PutAway(u8 taskId);
void SecretBasePC_Toss(u8 taskId);
void sub_8126DA4(u8 taskId);
void SecretBasePC_Cancel(u8 taskId);
void SecretBasePC_PrepMenuForSelectingStoredDecors(u8 taskId);
void sub_8126DFC(u8 taskId);
void sub_8126E8C(u8 taskId);
void sub_8126F68(u8 winid, u8 decorCat, u8 x, u8 y, bool8 flag, u8 speed);
void sub_8127058(u8 *str, bool8 flag);
void sub_8127088(u8 taskId);
void sub_81270E8(u8 taskId);
void sub_8127180(u8 taskId);
void sub_812719C(u8 taskId);
void sub_81271CC(u8 taskId);
void sub_8127268(u8 taskId);
void sub_8127454(u8 *dest, u16 decorId);
void sub_8127480(u32 a0, bool8 flag, struct ListMenu *menu);
void sub_81274A0(u8 a0, s32 a1, u8 a2);
void sub_8127620(u8 taskId);
void sub_812764C(u8 taskId);
void sub_8127744(u32 a0);
void sub_81277A8(void);
bool8 sub_81277BC(u8 idx);
bool8 sub_81277E8(u8 idx);
void IdentifyOwnedDecorationsCurrentlyInUse(u8 taskId);
void sub_812759C(u8 taskId);
void sub_8127718(u8 decorCat);
void sub_8127A30(u8 taskId);
void sub_8127A8C(u8 taskId);
void sub_8127F68(u8 taskId);
void sub_8128060(u8 taskId);
void ConfigureCameraObjectForPlacingDecoration(struct PlaceDecorationGraphicsDataBuffer *data, u8 decor);
void SetUpPlacingDecorationPlayerAvatar(u8 taskId, struct PlaceDecorationGraphicsDataBuffer *data);
void sub_812826C(u8 taskId);
void sub_81283BC(u8 taskId);
void sub_8128414(u8 taskId);
void sub_8128950(u8 taskId);
void sub_81289D0(u8 taskId);
void sub_81289F0(u8 taskId);
void sub_8128AAC(u8 taskId);
void sub_8128B80(u8 taskId);
void sub_8128BA0(u8 taskId);
void sub_8128BBC(u8 taskId);
void c1_overworld_prev_quest(u8 taskId);
void sub_8128CD4(void);
void sub_8128DE0(void);
void sub_8128FD8(u8 taskId);
void sub_8129020(u8 taskId);
void sub_81292D0(struct Sprite *sprite);
void sub_81292E8(struct Sprite *sprite);
u8 gpu_pal_decompress_alloc_tag_and_upload(struct PlaceDecorationGraphicsDataBuffer *data, u8 decor);
const u8 *GetDecorationIconPicOrPalette(u16 decor, u8 mode);
bool8 sub_81299AC(u8 taskId);
void sub_8129ABC(u8 taskId);
void sub_8129B34(u8 taskId);
void sub_8129BCC(u8 taskId);
void sub_8129BF8(u8 taskId);
void sub_8129C74(u8 taskId);
void sub_8129D64(u8 taskId);
void sub_812A0E8(u8 taskId);
void sub_812A1A0(u8 taskId);
void sub_812A1C0(u8 taskId);
void sub_812A1F0(u8 taskId);
void sub_812A210(u8 taskId);
void sub_812A22C(u8 taskId);
void sub_812A25C(u8 taskId);
void sub_812A334(void);
void sub_812A36C(struct Sprite *sprite);
void sub_812A39C(void);
void sub_812A3C8(void);
void sub_812A3D4(u8 taskId);
void sub_812A458(u8 taskId);
void sub_812A478(u8 taskId);
// .rodata
#include "data/decoration/tiles.h"
#include "data/decoration/description.h"
#include "data/decoration/header.h"
const u8 *const sDecorCatNames[] = {
gText_Desk,
gText_Chair,
gText_Plant,
gText_Ornament,
gText_Mat,
gText_Poster,
gText_Doll,
gText_Cushion
};
const struct MenuAction sSecretBasePCMenuActions[] = {
{
gText_Decorate, {.void_u8=SecretBasePC_Decorate}
}, {
gText_PutAway, {.void_u8=SecretBasePC_PutAway}
}, {
gText_Toss2, {.void_u8=SecretBasePC_Toss}
}, {
gText_Cancel, {.void_u8=SecretBasePC_Cancel}
}
};
const u8 *const sSecretBasePCMenuItemDescriptions[] = {
gText_PutOutSelectedDecorItem,
gText_StoreChosenDecorInPC,
gText_ThrowAwayUnwantedDecors,
gText_GoBackPrevMenu
};
void (*const SecretBasePC_SelectedDecorActions[][2])(u8 taskId) = {
{
sub_8127F68, sub_8127A8C
}, {
sub_812A3D4, sub_8127A8C
}, {
sub_8133DA0, sub_8127A8C
}
};
const struct WindowTemplate gUnknown_085A6B90[4] = {
{ 0, 1, 1, 18, 8, 15, 0x0001 },
{ 0, 1, 1, 13, 18, 13, 0x0091 },
{ 0, 17, 1, 12, 2, 15, 0x017b },
{ 0, 16, 13, 13, 6, 15, 0x0193 }
};
const u16 gUnknown_085A6BB0[] = INCBIN_U16("graphics/decorations/unk_85a6bb0.gbapal");
const struct ListMenuTemplate gUnknown_085A6BD0 = {
NULL,
sub_8127480,
sub_81274A0,
0, 0,
0, 0, 8, 0,
9, 2, 1, 3, FALSE, 0, FALSE, 7
};
#include "data/decoration/icon.h"
#include "data/decoration/tilemaps.h"
const struct {
u8 shape;
u8 size;
u8 x;
u8 y;
} gUnknown_085A7250[] = {
{0, 1, 0x78, 0x4e},
{1, 2, 0x80, 0x4e},
{1, 3, 0x90, 0x56},
{1, 3, 0x90, 0x46},
{0, 2, 0x80, 0x46},
{2, 2, 0x78, 0x46},
{2, 3, 0x80, 0x56},
{2, 3, 0x80, 0x36},
{0, 3, 0x90, 0x46},
{1, 3, 0x90, 0x46}
};
const union AnimCmd gUnknown_085A7278[] = {
ANIMCMD_FRAME(0, 0, FALSE, FALSE),
ANIMCMD_END
};
const union AnimCmd *const sDecorSelectorAnims[] = {
gUnknown_085A7278
};
const struct SpriteFrameImage sDecorSelectorSpriteFrameImages = {
(const u8 *)&sPlaceDecorationGraphicsDataBuffer.image, 0x800
};
const struct SpriteTemplate sDecorSelectorSpriteTemplate = {
0xffff,
OVERWORLD_PLACE_DECOR_SELECTOR_PAL_TAG,
&sDecorSelectorOam,
sDecorSelectorAnims,
&sDecorSelectorSpriteFrameImages,
gDummySpriteAffineAnimTable,
SpriteCallbackDummy
};
const struct SpriteTemplate sDecorWhilePlacingSpriteTemplate = {
0x0000,
0x0000,
&sDecorSelectorOam,
sDecorSelectorAnims,
NULL,
gDummySpriteAffineAnimTable,
SpriteCallbackDummy
};
const struct SpritePalette gUnknown_085A72BC = {
(const u16 *)&sPlaceDecorationGraphicsDataBuffer.palette, OVERWORLD_PLACE_DECOR_SELECTOR_PAL_TAG
};
const struct YesNoFuncTable gUnknown_085A72C4 = {
sub_81289F0,
sub_8128FD8
};
const struct YesNoFuncTable gUnknown_085A72CC = {
sub_8128BA0,
sub_8128FD8
};
const struct YesNoFuncTable gUnknown_085A72D4[] = {
{
sub_81283BC,
sub_8128414
}, {
sub_8129BCC,
sub_8129BF8
}
};
const u8 gUnknown_085A72E4[] = {
0x04, 0x04, 0x04, 0x04, 0x00, 0x03, 0x03, 0x00
};
const u8 gUnknown_085A72EC[] = {
0x04, 0x04, 0x04, 0x04, 0x00, 0x04, 0x03, 0x00
};
const u16 gUnknown_085A72F4[] = {
0x04, 0x08, 0x10, 0x20, 0x10, 0x08, 0x10, 0x20, 0x40, 0x20
};
const u16 Unknown_085A7308[] = INCBIN_U16("graphics/decorations/unk_85a7308.gbapal");
const u16 Unknown_085A7328[] = INCBIN_U16("graphics/decorations/unk_85a7328.gbapal");
const struct YesNoFuncTable gUnknown_085A7348 = {
sub_812A1C0,
sub_8129B34
};
const struct YesNoFuncTable gUnknown_085A7350 = {
sub_812A210,
sub_8129B34
};
const u8 Unknown_085A7358[] = INCBIN_U8("graphics/misc/decoration_unk_85a7358.4bpp");
const struct SpritePalette gUnknown_085A73D8 = {
Unknown_085A7308, OVERWORLD_PLACE_DECOR_PLAYER_PAL_TAG
};
const struct SpritePalette gUnknown_085A73E0 = {
Unknown_085A7328, OVERWORLD_PLACE_DECOR_PLAYER_PAL_TAG
};
const struct OamData Unknown_085A73E8 = {
.size = 1, .priority = 1
};
const union AnimCmd Unknown_085A73F0[] = {
ANIMCMD_FRAME(0, 0, 0),
ANIMCMD_END
};
const union AnimCmd *const Unknown_085A73F8[] = {
Unknown_085A73F0
};
const struct SpriteFrameImage Unknown_085A73FC = {
Unknown_085A7358, 0x80
};
const struct SpriteTemplate gUnknown_085A7404 = {
0xFFFF,
OVERWORLD_PLACE_DECOR_PLAYER_PAL_TAG,
&Unknown_085A73E8,
Unknown_085A73F8,
&Unknown_085A73FC,
gDummySpriteAffineAnimTable,
sub_812A36C
};
const struct YesNoFuncTable gUnknown_085A741C = {
sub_812A478,
sub_8127A30
};
// .text
void sub_8126968(void)
{
if (sCurDecorationCategory < 8)
{
gCurDecorInventoryItems = gDecorationInventories[sCurDecorationCategory].items;
}
if (gUnknown_0203A17C.isPlayerRoom == FALSE)
{
gUnknown_0203A17C.items = gSaveBlock1Ptr->secretBases[0].decorations;
gUnknown_0203A17C.pos = gSaveBlock1Ptr->secretBases[0].decorationPos;
}
if (gUnknown_0203A17C.isPlayerRoom == TRUE)
{
gUnknown_0203A17C.items = gSaveBlock1Ptr->playerRoomDecor;
gUnknown_0203A17C.pos = gSaveBlock1Ptr->playerRoomDecorPos;
}
}
u8 sub_81269D4(u8 idx)
{
u8 *winidx;
struct WindowTemplate template;
winidx = &sDecorMenuWindowIndices[idx];
if (idx == 0)
{
template = gUnknown_085A6B90[0];
template.width = GetMaxWidthInMenuTable(sSecretBasePCMenuActions, 4);
if (template.width > 18)
{
template.width = 18;
}
*winidx = AddWindow(&template);
}
else
{
*winidx = AddWindow(&gUnknown_085A6B90[idx]);
}
SetWindowBorderStyle(*winidx, 0, 0x214, 0xe);
schedule_bg_copy_tilemap_to_vram(0);
return *winidx;
}
void sub_8126A58(u8 idx)
{
sub_8198070(sDecorMenuWindowIndices[idx], FALSE);
ClearWindowTilemap(sDecorMenuWindowIndices[idx]);
RemoveWindow(sDecorMenuWindowIndices[idx]);
schedule_bg_copy_tilemap_to_vram(0);
}
void sub_8126A88(void)
{
u8 idx;
idx = sub_81269D4(0);
PrintMenuTable(idx, 4, sSecretBasePCMenuActions);
InitMenuInUpperLeftCornerPlaySoundWhenAPressed(idx, 4, sSecretBasePCMenuCursorPos);
}
void sub_8126ABC(void)
{
sSecretBasePCMenuCursorPos = 0;
ScriptContext2_Enable();
sub_8126A88();
sub_8126C08();
}
void sub_8126AD8(u8 taskId)
{
sub_8126ABC();
gUnknown_0203A17C.items = gSaveBlock1Ptr->secretBases[0].decorations;
gUnknown_0203A17C.pos = gSaveBlock1Ptr->secretBases[0].decorationPos;
gUnknown_0203A17C.size = sizeof(gSaveBlock1Ptr->secretBases[0].decorations);
gUnknown_0203A17C.isPlayerRoom = FALSE;
gTasks[taskId].func = sub_8126B80;
}
void sub_8126B2C(u8 taskId)
{
sub_8126ABC();
gUnknown_0203A17C.items = gSaveBlock1Ptr->playerRoomDecor;
gUnknown_0203A17C.pos = gSaveBlock1Ptr->playerRoomDecorPos;
gUnknown_0203A17C.size = sizeof(gSaveBlock1Ptr->playerRoomDecor);
gUnknown_0203A17C.isPlayerRoom = TRUE;
gTasks[taskId].func = sub_8126B80;
}
void sub_8126B80(u8 taskId)
{
u8 menuPos;
if (!gPaletteFade.active)
{
menuPos = GetMenuCursorPos();
switch (ProcessMenuInput())
{
default:
PlaySE(SE_SELECT);
sSecretBasePCMenuActions[sSecretBasePCMenuCursorPos].func.void_u8(taskId);
break;
case -2:
sSecretBasePCMenuCursorPos = GetMenuCursorPos();
if ((s8)menuPos != sSecretBasePCMenuCursorPos)
{
sub_8126C08();
}
break;
case -1:
PlaySE(SE_SELECT);
SecretBasePC_Cancel(taskId);
break;
}
}
}
void sub_8126C08(void)
{
FillWindowPixelBuffer(0, 0x11);
AddTextPrinterParametrized(0, 1, sSecretBasePCMenuItemDescriptions[sSecretBasePCMenuCursorPos], 0, 0, 2, 1, 3);
}
void SecretBasePC_Decorate(u8 taskId)
{
if (CountDecorations() == 0)
{
StringExpandPlaceholders(gStringVar4, gText_NoDecorations);
DisplayItemMessageOnField(taskId, gStringVar4, sub_8126DA4);
}
else
{
gTasks[taskId].data[11] = 0;
sCurDecorationCategory = DECORCAT_DESK;
SecretBasePC_PrepMenuForSelectingStoredDecors(taskId);
}
}
void SecretBasePC_PutAway(u8 taskId)
{
if (!sub_81299AC(taskId))
{
StringExpandPlaceholders(gStringVar4, gText_NoDecorationsInUse);
DisplayItemMessageOnField(taskId, gStringVar4, sub_8126DA4);
}
else
{
sub_8126A58(0);
sub_8197434(0, 0);
fade_screen(1, 0);
gTasks[taskId].data[2] = 0;
gTasks[taskId].func = sub_8129ABC;
}
}
void SecretBasePC_Toss(u8 taskId)
{
if (CountDecorations() == 0)
{
StringExpandPlaceholders(gStringVar4, gText_NoDecorations);
DisplayItemMessageOnField(taskId, gStringVar4, sub_8126DA4);
}
else
{
gTasks[taskId].data[11] = 1;
sCurDecorationCategory = DECORCAT_DESK;
SecretBasePC_PrepMenuForSelectingStoredDecors(taskId);
}
}
void SecretBasePC_Cancel(u8 taskId)
{
sub_8126A58(0);
if (!gUnknown_0203A17C.isPlayerRoom)
{
ScriptContext1_SetupScript(gUnknown_0823B4E8);
DestroyTask(taskId);
}
else
{
sub_816B060(taskId);
}
}
void sub_8126DA4(u8 taskId)
{
sub_8126C08();
gTasks[taskId].func = sub_8126B80;
}
void SecretBasePC_PrepMenuForSelectingStoredDecors(u8 taskId)
{
LoadPalette(gUnknown_085A6BB0, 0xd0, 0x20);
sub_8197434(0, 0);
sub_8126A58(0);
sub_8126DFC(taskId);
}
void sub_8126DFC(u8 taskId)
{
u8 winIdx;
winIdx = sub_81269D4(1);
sub_8126E8C(taskId);
InitMenuInUpperLeftCornerPlaySoundWhenAPressed(winIdx, 9, sCurDecorationCategory);
gTasks[taskId].func = sub_8127088;
}
void sub_8126E44(u8 taskId)
{
FillWindowPixelBuffer(sDecorMenuWindowIndices[1], 0x11);
sub_8126E8C(taskId);
InitMenuInUpperLeftCornerPlaySoundWhenAPressed(sDecorMenuWindowIndices[1], 9, sCurDecorationCategory);
gTasks[taskId].func = sub_8127088;
}
void sub_8126E8C(u8 taskId)
{
s16 *data;
u8 r5;
bool8 r8;
u8 i;
bool8 fl;
data = gTasks[taskId].data;
r5 = sDecorMenuWindowIndices[1];
fl = gUnknown_0203A17C.isPlayerRoom;
r8 = FALSE;
if (fl == TRUE && data[11] == 0)
{
r8 = TRUE;
}
for (i = 0; i < 8; i ++)
{
if (r8 == TRUE && i != DECORCAT_DOLL && i != DECORCAT_CUSHION)
{
sub_8126F68(r5, i, 8, i << 4, TRUE, 0xFF);
}
else
{
sub_8126F68(r5, i, 8, i << 4, FALSE, 0xFF);
}
}
PrintTextOnWindow(r5, 1, gTasks[taskId].data[11] == 2 ? gText_Exit : gText_Cancel, 8, (i << 4) + 1, 0, 0);
schedule_bg_copy_tilemap_to_vram(0);
}
void sub_8126F68(u8 winid, u8 decorCat, u8 x, u8 y, bool8 flag, u8 speed)
{
u8 width;
u8 *strbuf;
width = x == 8 ? 0x68 : 0x60;
y ++;
sub_8127058(gStringVar4, flag);
strbuf = StringLength(gStringVar4) + gStringVar4;
StringCopy(strbuf, sDecorCatNames[decorCat]);
PrintTextOnWindow(winid, 1, gStringVar4, x, y, speed, NULL);
strbuf = ConvertIntToDecimalStringN(strbuf, CountDecorationCategoryN(decorCat), STR_CONV_MODE_RIGHT_ALIGN, 2);
*strbuf++ = CHAR_SLASH;
ConvertIntToDecimalStringN(strbuf, gDecorationInventories[decorCat].size, STR_CONV_MODE_RIGHT_ALIGN, 2);
x = GetStringRightAlignXOffset(1, gStringVar4, width);
PrintTextOnWindow(winid, 1, gStringVar4, x, y, speed, NULL);
}
void sub_8127058(u8 *str, bool8 flag)
{
StringCopy(str, gText_Color161Shadow161);
if (flag == TRUE)
{
str[2] = 0x04; // RED
str[5] = 0x05; // LIGHT_RED
}
else
{
str[2] = 0x02; // DARK_GREY
str[5] = 0x03; // LIGHT_GREY
}
}
void sub_8127088(u8 taskId)
{
s8 input;
if (!gPaletteFade.active)
{
input = ProcessMenuInput();
switch (input)
{
case -1:
case 8:
PlaySE(SE_SELECT);
sub_812719C(taskId);
break;
case -2:
break;
default:
PlaySE(SE_SELECT);
sCurDecorationCategory = input;
sub_81270E8(taskId);
break;
}
}
}
void sub_81270E8(u8 taskId)
{
sCurDecorCatCount = CountDecorationCategoryN(sCurDecorationCategory);
if (sCurDecorCatCount != 0)
{
CondenseDecorationCategoryN(sCurDecorationCategory);
gCurDecorInventoryItems = gDecorationInventories[sCurDecorationCategory].items;
IdentifyOwnedDecorationsCurrentlyInUse(taskId);
sSecretBasePCSelectDecorPageNo = 0;
sSecretBasePCSelectDecorLineNo = 0;
gTasks[taskId].func = sub_8127620;
}
else
{
sub_8126A58(1);
StringExpandPlaceholders(gStringVar4, gText_NoDecorations);
DisplayItemMessageOnField(taskId, gStringVar4, sub_8127180);
}
}
void sub_8127180(u8 taskId)
{
sub_8197434(0, 0);
sub_8126DFC(taskId);
}
void sub_812719C(u8 taskId)
{
if (gTasks[taskId].data[11] != 2)
{
sub_81271CC(taskId);
}
else
{
sub_8127268(taskId);
}
}
void sub_81271CC(u8 taskId)
{
sub_8126A58(1);
sub_8126A88();
sub_81973C4(0, 0);
sub_8126C08();
gTasks[taskId].func = sub_8126B80;
}
void sub_8127208(u8 taskId)
{
LoadPalette(gUnknown_085A6BB0, 0xd0, 0x20);
sub_8197434(0, 0);
gTasks[taskId].data[11] = 2;
sCurDecorationCategory = DECORCAT_DESK;
sub_8126DFC(taskId);
}
void sub_8127250(u8 *dest, u8 decorCat)
{
StringCopy(dest, sDecorCatNames[decorCat]);
}
void sub_8127268(u8 taskId)
{
sub_8126A58(1);
sub_8133E1C(taskId);
}
void sub_8127284(void)
{
sDecorPCBuffer->unk_520 = sCurDecorCatCount + 1;
if (sDecorPCBuffer->unk_520 > 8)
{
sDecorPCBuffer->unk_521 = 8;
}
else
{
sDecorPCBuffer->unk_521 = sDecorPCBuffer->unk_520;
}
}
void sub_81272C8(void)
{
sub_812225C(&sSecretBasePCSelectDecorPageNo, &sSecretBasePCSelectDecorLineNo, sDecorPCBuffer->unk_521, sDecorPCBuffer->unk_520);
}
void sub_81272F8(void)
{
sub_8122298(&sSecretBasePCSelectDecorPageNo, &sSecretBasePCSelectDecorLineNo, sDecorPCBuffer->unk_521, sDecorPCBuffer->unk_520, 8);
}
void sub_8127330(u8 taskId)
{
s16 *data;
u16 i;
data = gTasks[taskId].data;
if ((sCurDecorationCategory < DECORCAT_DOLL || sCurDecorationCategory > DECORCAT_CUSHION) && gUnknown_0203A17C.isPlayerRoom == TRUE && data[11] == 0)
{
sub_8127058(gStringVar1, TRUE);
}
else
{
sub_8127058(gStringVar1, FALSE);
}
for (i = 0; i < sDecorPCBuffer->unk_520 - 1; i ++)
{
sub_8127454(sDecorPCBuffer->names[i], gCurDecorInventoryItems[i]);
sDecorPCBuffer->items[i].unk_00 = sDecorPCBuffer->names[i];
sDecorPCBuffer->items[i].unk_04 = i;
}
StringCopy(sDecorPCBuffer->names[i], gText_Cancel);
sDecorPCBuffer->items[i].unk_00 = sDecorPCBuffer->names[i];
sDecorPCBuffer->items[i].unk_04 = -2;
gUnknown_03006310 = gUnknown_085A6BD0;
gUnknown_03006310.unk_10 = sDecorMenuWindowIndices[1];
gUnknown_03006310.totalItems = sDecorPCBuffer->unk_520;
gUnknown_03006310.items = sDecorPCBuffer->items;
gUnknown_03006310.maxShowed = sDecorPCBuffer->unk_521;
}
void sub_8127454(u8 *dest, u16 decorId)
{
StringCopy(dest, gStringVar1);
StringAppend(dest, gDecorations[decorId].name);
}
void sub_8127480(u32 a0, bool8 flag, struct ListMenu *menu)
{
if (flag != TRUE)
{
PlaySE(SE_SELECT);
}
sub_8127744(a0);
}
void sub_81274A0(u8 a0, s32 a1, u8 a2)
{
if (a1 != -2)
{
if (sub_81277BC(a1 + 1) == TRUE)
{
blit_move_info_icon(a0, 0x18, 0x5c, a2 + 2);
}
else if (sub_81277E8(a1 + 1) == TRUE)
{
blit_move_info_icon(a0, 0x19, 0x5c, a2 + 2);
}
}
}
void sub_8127500(void)
{
if (sDecorPCBuffer->unk_522 == 0xFF)
{
sDecorPCBuffer->unk_522 = AddScrollIndicatorArrowPairParametrized(0x02, 0x3c, 0x0c, 0x94, sDecorPCBuffer->unk_520 - sDecorPCBuffer->unk_521, 0x6e, 0x6e, &sSecretBasePCSelectDecorPageNo);
}
}
void sub_8127554(void)
{
if (sDecorPCBuffer->unk_522 != 0xFF)
{
RemoveScrollIndicatorArrowPair(sDecorPCBuffer->unk_522);
sDecorPCBuffer->unk_522 = 0xFF;
}
}
void sub_8127580(u8 taskId)
{
sub_81269D4(1);
sub_812759C(taskId);
}
void sub_812759C(u8 taskId)
{
s16 *data;
data = gTasks[taskId].data;
sub_81269D4(3);
sub_8127718(sCurDecorationCategory);
sDecorPCBuffer = calloc(1, sizeof(struct DecorPCBuffer));
sDecorPCBuffer->unk_522 = 0xFF;
sub_8127284();
sub_81272C8();
sub_81272F8();
sub_8127330(taskId);
data[13] = ListMenuInit(&gUnknown_03006310, sSecretBasePCSelectDecorPageNo, sSecretBasePCSelectDecorLineNo);
sub_8127500();
}
void sub_8127620(u8 taskId)
{
sub_812759C(taskId);
gTasks[taskId].func = sub_812764C;
}
void sub_812764C(u8 taskId)
{
s16 *data;
s32 input;
data = gTasks[taskId].data;
if (!gPaletteFade.active)
{
input = ListMenuHandleInput(data[13]);
get_coro_args_x18_x1A(data[13], &sSecretBasePCSelectDecorPageNo, &sSecretBasePCSelectDecorLineNo);
switch (input)
{
case -1:
break;
case -2:
PlaySE(SE_SELECT);
SecretBasePC_SelectedDecorActions[data[11]][1](taskId);
break;
default:
PlaySE(SE_SELECT);
gCurDecorationIndex = input;
sub_8127554();
sub_81AE6C8(data[13], &sSecretBasePCSelectDecorPageNo, &sSecretBasePCSelectDecorLineNo);
sub_8126A58(1);
sub_81277A8();
free(sDecorPCBuffer);
SecretBasePC_SelectedDecorActions[data[11]][0](taskId);
break;
}
}
}
void sub_8127718(u8 decorCat)
{
sub_8126F68(sub_81269D4(2), decorCat, 0, 0, 0, 0);
}
void sub_8127744(u32 a0)
{
u8 winidx;
const u8 *txt;
winidx = sDecorMenuWindowIndices[3];
FillWindowPixelBuffer(winidx, 0x11);
if (a0 >= sCurDecorCatCount)
{
txt = gText_GoBackPrevMenu;
}
else
{
txt = gDecorations[gCurDecorInventoryItems[a0]].description;
}
PrintTextOnWindow(winidx, 1, txt, 0, 1, 0, 0);
}
void sub_81277A8(void)
{
sub_8126A58(3);
sub_8126A58(2);
}
bool8 sub_81277BC(u8 idx)
{
u8 i;
for (i = 0; i < 16; i ++)
{
if (sSecretBaseItemsIndicesBuffer[i] == idx)
{
return TRUE;
}
}
return FALSE;
}
bool8 sub_81277E8(u8 idx)
{
u8 i;
for (i = 0; i < 12; i ++)
{
if (sPlayerRoomItemsIndicesBuffer[i] == idx)
{
return TRUE;
}
}
return FALSE;
}
void IdentifyOwnedDecorationsCurrentlyInUseInternal(u8 taskId)
{
u16 i;
u16 j;
u16 k;
u16 cnt;
cnt = 0;
memset(sSecretBaseItemsIndicesBuffer, 0, 16);
memset(sPlayerRoomItemsIndicesBuffer, 0, 12);
for (i = 0; i < 16; i ++)
{
if (gSaveBlock1Ptr->secretBases[0].decorations[i] != DECOR_NONE)
{
for (j = 0; j < gDecorationInventories[sCurDecorationCategory].size; j ++)
{
if (gCurDecorInventoryItems[j] == gSaveBlock1Ptr->secretBases[0].decorations[i])
{
for (k = 0; k < cnt && sSecretBaseItemsIndicesBuffer[k] != j + 1; k ++);
if (k == cnt)
{
sSecretBaseItemsIndicesBuffer[cnt] = j + 1;
cnt ++;
break;
}
}
}
}
}