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
|
#include "global.h"
#include "heap.h"
#include "string16.h"
#include "player_data.h"
#include "msgdata.h"
#include "pokemon.h"
#include "pokemon_storage_system.h"
#include "unk_02015CC0.h"
#include "unk_020286F8.h"
#include "filesystem.h"
#include "unk_0201B8B8.h"
#include "trainer_data.h"
#include "script_buffers.h"
#include "unk_02024E64.h"
#include "text.h"
#include "msgdata/msg.naix"
#include "graphic/font.naix"
#pragma thumb on
extern u32 GetCityNamesMsgdataIdByCountry(u32);
extern void GetECWordIntoStringByIndex(u32 a0, struct String * a1);
extern void StringCat_HandleTrainerName(struct String * dest, const struct String * src);
extern void StrAddChar(struct String * str, u16 val);
extern void * GfGfxLoader_GetCharData(NarcId, s32, s32, struct UnkStruct_0200B870_sub **, u32);
extern void * GfGfxLoader_LoadFromNarc(NarcId narcId, s32 memberNo, BOOL isCompressed, u32 heap_id, BOOL allocAtEnd);
const u16 UNK_020ECE6C[][2] = {
{ 0x0140, 0x0008 },
{ 0x0160, 0x0010 },
{ 0x01A0, 0x0010 },
{ 0x01E0, 0x0010 },
{ 0x0220, 0x0010 },
{ 0x0260, 0x0010 },
{ 0x02A0, 0x0010 },
};
const u16 UNK_020ECE64[] = {
NARC_msg_narc_0382_bin,
NARC_msg_narc_0384_bin,
NARC_msg_narc_0383_bin,
0
};
struct ScrStrBufs * ScrStrBufs_new(u32 heap_id)
{
return ScrStrBufs_new_custom(8, 32, heap_id);
}
struct ScrStrBufs * ScrStrBufs_new_custom(u32 nstr, u32 strlen, u32 heap_id)
{
GF_ASSERT(nstr != 0);
GF_ASSERT(strlen != 0);
struct ScrStrBufs * r4 = AllocFromHeapAtEnd(heap_id, sizeof(struct ScrStrBufs));
if (r4 != NULL)
{
r4->count = nstr;
r4->heap_id = heap_id;
r4->tmpbuf = String_ctor(strlen, heap_id);
if (r4->tmpbuf != NULL)
{
r4->array = AllocFromHeapAtEnd(heap_id, nstr * sizeof(struct UnkStruct_0200AA80_sub));
if (r4->array != NULL)
{
int i;
for (i = 0; i < nstr; i++)
{
ScrStrBufs_InitSub(&r4->array[i]);
r4->array[i].msg = String_ctor(strlen, heap_id);
if (r4->array[i].msg == NULL)
break;
}
if (i == nstr)
return r4;
}
}
}
return NULL;
}
void ScrStrBufs_delete(struct ScrStrBufs * ptr)
{
GF_ASSERT(ptr->count != 0);
if (ptr->array != NULL)
{
int i;
for (i = 0; i < ptr->count; i++)
{
if (ptr->array[i].msg == NULL)
break;
String_dtor(ptr->array[i].msg);
}
FreeToHeap(ptr->array);
}
if (ptr->tmpbuf != NULL)
String_dtor(ptr->tmpbuf);
ptr->count = 0;
FreeToHeap(ptr);
}
void ScrStrBufs_InitSub(struct UnkStruct_0200AA80_sub * sub)
{
#pragma unused(sub)
}
void SetStringAsPlaceholder(struct ScrStrBufs * mgr, u32 idx, struct String * str, struct UnkStruct_0200AA80_sub_sub * a3)
{
GF_ASSERT(idx < mgr->count);
if (idx < mgr->count)
{
if (a3 != NULL)
{
mgr->array[idx].attrs = *a3;
}
StringCopy(mgr->array[idx].msg, str);
}
}
void BufferString(struct ScrStrBufs * mgr, u32 idx, struct String * str, u32 a3, u32 a4, u32 a5)
{
#pragma unused(a3,a4,a5)
SetStringAsPlaceholder(mgr, idx, str, NULL);
}
void BufferPlayersName(struct ScrStrBufs * mgr, u32 idx, struct PlayerData * data)
{
u16 * name = PlayerProfile_GetNamePtr(data);
CopyU16ArrayToString(mgr->tmpbuf, name);
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
}
void BufferRivalsName(struct ScrStrBufs * mgr, u32 idx, struct SaveBlock2 * sav2)
{
u16 * name = GetRivalNamePtr(FUN_02024EC0(sav2));
CopyU16ArrayToString(mgr->tmpbuf, name);
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
}
void BufferFriendsName(struct ScrStrBufs * mgr, u32 idx, struct SaveBlock2 * sav2)
{
struct PlayerData * data = Sav2_PlayerData_GetProfileAddr(sav2);
struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0497_bin, mgr->heap_id);
if (PlayerProfile_GetTrainerGender(data) == 0)
{
ReadMsgDataIntoString(msgData, 1, mgr->tmpbuf);
}
else
{
ReadMsgDataIntoString(msgData, 0, mgr->tmpbuf);
}
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
DestroyMsgData(msgData);
}
void BufferBoxMonSpeciesName(struct ScrStrBufs * mgr, u32 idx, struct BoxPokemon * mon)
{
struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0362_bin, mgr->heap_id);
ReadMsgDataIntoString(msgData, GetBoxMonData(mon, MON_DATA_SPECIES, NULL), mgr->tmpbuf);
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
DestroyMsgData(msgData);
}
void BufferBoxMonSpeciesNameWithArticle(struct ScrStrBufs * mgr, u32 idx, struct BoxPokemon * mon)
{
BufferSpeciesNameWithArticle(mgr, idx, GetBoxMonData(mon, MON_DATA_SPECIES, NULL));
}
void BufferSpeciesNameWithArticle(struct ScrStrBufs * mgr, u32 idx, u32 species)
{
struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0363_bin, mgr->heap_id);
ReadMsgDataIntoString(msgData, species, mgr->tmpbuf);
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
DestroyMsgData(msgData);
}
void BufferBoxMonNickname(struct ScrStrBufs * mgr, u32 idx, struct BoxPokemon * mon)
{
GetBoxMonData(mon, MON_DATA_NICKNAME_3, mgr->tmpbuf);
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
}
void BufferBoxMonOTName(struct ScrStrBufs * mgr, u32 idx, struct BoxPokemon * mon)
{
GetBoxMonData(mon, MON_DATA_OT_NAME_2, mgr->tmpbuf);
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
}
void BufferIntegerAsString(struct ScrStrBufs * mgr, u32 idx, int num, u32 ndigits, int strConvMode, BOOL whichCharset)
{
String16_FormatInteger(mgr->tmpbuf, num, ndigits, strConvMode, whichCharset);
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
}
void BufferMoveName(struct ScrStrBufs * mgr, u32 idx, u32 move)
{
struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0588_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, move, mgr->tmpbuf);
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
DestroyMsgData(msgData);
}
}
void BufferRibbonNameOrDesc(struct ScrStrBufs * mgr, u32 idx, u32 ribbon)
{
struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0484_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, ribbon, mgr->tmpbuf);
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
DestroyMsgData(msgData);
}
}
void BufferAbilityName(struct ScrStrBufs * mgr, u32 idx, u32 ability)
{
struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0552_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, ability, mgr->tmpbuf);
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
DestroyMsgData(msgData);
}
}
void BufferNatureName(struct ScrStrBufs * mgr, u32 idx, u32 nature)
{
struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0190_bin, mgr->heap_id);
ReadMsgDataIntoString(msgData, nature, mgr->tmpbuf);
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
DestroyMsgData(msgData);
}
void BufferItemName(struct ScrStrBufs * mgr, u32 idx, u32 item)
{
struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0344_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, item, mgr->tmpbuf);
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
DestroyMsgData(msgData);
}
}
void BufferItemNameWithIndefArticle(struct ScrStrBufs * mgr, u32 idx, u32 item)
{
struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0346_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, item, mgr->tmpbuf);
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
DestroyMsgData(msgData);
}
}
void BufferItemNamePlural(struct ScrStrBufs * mgr, u32 idx, u32 item)
{
struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0347_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, item, mgr->tmpbuf);
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
DestroyMsgData(msgData);
}
}
void BufferPocketName(struct ScrStrBufs * mgr, u32 idx, u32 pocket)
{
struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0349_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, pocket, mgr->tmpbuf);
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
DestroyMsgData(msgData);
}
}
void BufferTypeName(struct ScrStrBufs * mgr, u32 idx, u32 type)
{
struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0565_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, type, mgr->tmpbuf);
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
DestroyMsgData(msgData);
}
}
void BufferStatName(struct ScrStrBufs * mgr, u32 idx, u32 stat)
{
struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0495_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, stat, mgr->tmpbuf);
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
DestroyMsgData(msgData);
}
}
void BufferStatusName(struct ScrStrBufs * mgr, u32 idx, u32 status)
{
struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0205_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, status, mgr->tmpbuf);
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
DestroyMsgData(msgData);
}
}
void BufferFlavorDislikeText(struct ScrStrBufs * mgr, u32 idx, u32 flavor)
{
struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0548_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, flavor, mgr->tmpbuf);
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
DestroyMsgData(msgData);
}
}
void BufferLandmarkName(struct ScrStrBufs * mgr, u32 idx, u32 landmark)
{
struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0382_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, landmark, mgr->tmpbuf);
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
DestroyMsgData(msgData);
}
}
void BufferPoketchAppName(struct ScrStrBufs * mgr, u32 idx, u32 app)
{
struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0406_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, app, mgr->tmpbuf);
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
DestroyMsgData(msgData);
}
}
void BufferTrainerClassName(struct ScrStrBufs * mgr, u32 idx, u32 trclass)
{
struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0560_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, trclass, mgr->tmpbuf);
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
DestroyMsgData(msgData);
}
}
void BufferTrainerClassNameWithArticle(struct ScrStrBufs * mgr, u32 idx, u32 trclass)
{
struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0561_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, trclass, mgr->tmpbuf);
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
DestroyMsgData(msgData);
}
}
void BufferTrainerClassNameFromDataStruct(struct ScrStrBufs * mgr, u32 idx, struct TrainerDataLoaded * tr)
{
struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0560_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, tr->data.trainerClass, mgr->tmpbuf);
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
DestroyMsgData(msgData);
}
}
void BufferTrainerName(struct ScrStrBufs * mgr, u32 idx, u32 msgno)
{
struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0559_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, msgno, mgr->tmpbuf);
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
DestroyMsgData(msgData);
}
}
void BufferTrainerNameFromDataStruct(struct ScrStrBufs * mgr, u32 idx, struct TrainerDataLoaded * trdata)
{
CopyU16ArrayToString(mgr->tmpbuf, trdata->name);
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
}
void BufferUndergroundItemName(struct ScrStrBufs * mgr, u32 idx, u32 item)
{
struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0569_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, item, mgr->tmpbuf);
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
DestroyMsgData(msgData);
}
}
void BufferUndergroundItemNameWithArticle(struct ScrStrBufs * mgr, u32 idx, u32 item)
{
struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0570_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, item, mgr->tmpbuf);
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
DestroyMsgData(msgData);
}
}
void BufferUndergroundTrapName(struct ScrStrBufs * mgr, u32 idx, u32 trap)
{
struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0571_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, trap, mgr->tmpbuf);
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
DestroyMsgData(msgData);
}
}
void BufferUndergroundTrapNameWithArticle(struct ScrStrBufs * mgr, u32 idx, u32 trap)
{
struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0572_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, trap, mgr->tmpbuf);
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
DestroyMsgData(msgData);
}
}
void BufferContestJudgeName(struct ScrStrBufs * mgr, u32 idx, u32 judge)
{
struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0194_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, judge, mgr->tmpbuf);
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
DestroyMsgData(msgData);
}
}
void BufferContestMessage(struct ScrStrBufs * mgr, u32 idx, u32 msg)
{
struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0191_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, msg, mgr->tmpbuf);
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
DestroyMsgData(msgData);
}
}
void BufferContestMessage2(struct ScrStrBufs * mgr, u32 idx, u32 msg)
{
struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0191_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, msg, mgr->tmpbuf);
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
DestroyMsgData(msgData);
}
}
void BufferInterviewQuestion(struct ScrStrBufs * mgr, u32 idx, u32 question)
{
struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0574_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, question, mgr->tmpbuf);
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
DestroyMsgData(msgData);
}
}
void BufferInterviewAnswer(struct ScrStrBufs * mgr, u32 idx, u32 answer)
{
struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0573_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, answer, mgr->tmpbuf);
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
DestroyMsgData(msgData);
}
}
void BufferDecorationName(struct ScrStrBufs * mgr, u32 idx, u32 decor)
{
struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0567_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, decor, mgr->tmpbuf);
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
DestroyMsgData(msgData);
}
}
void BufferDecorationNameWithArticle(struct ScrStrBufs * mgr, u32 idx, u32 decor)
{
struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0568_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, decor, mgr->tmpbuf);
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
DestroyMsgData(msgData);
}
}
void BufferGenderSymbol(struct ScrStrBufs * mgr, u32 idx, u32 gender)
{
struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0199_bin, mgr->heap_id);
switch (gender)
{
case 0:
ReadMsgDataIntoString(msgData, 68, mgr->tmpbuf);
break;
case 1:
ReadMsgDataIntoString(msgData, 69, mgr->tmpbuf);
break;
default:
StringSetEmpty(mgr->tmpbuf);
break;
}
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
DestroyMsgData(msgData);
}
void BufferBoxName(struct ScrStrBufs * mgr, u32 idx, struct PCStorage * pc, int boxno)
{
PCStorage_GetBoxName(pc, boxno, mgr->tmpbuf);
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
}
void BufferGymName(struct ScrStrBufs * mgr, u32 idx, u32 gym)
{
struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0331_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, gym, mgr->tmpbuf);
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
DestroyMsgData(msgData);
}
}
void BufferTimeOfDayName(struct ScrStrBufs * mgr, u32 idx, u32 time)
{
struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0550_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, time, mgr->tmpbuf);
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
DestroyMsgData(msgData);
}
}
void BufferCountryName(struct ScrStrBufs * mgr, u32 idx, u32 country)
{
struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0612_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, country, mgr->tmpbuf);
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
DestroyMsgData(msgData);
}
}
void BufferCityName(struct ScrStrBufs * mgr, u32 idx, u32 a2, u32 a3)
{
u32 r2 = GetCityNamesMsgdataIdByCountry(a2);
if (r2 != 0 && a3 != 0)
{
struct MsgData *msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, (int)r2, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, a3, mgr->tmpbuf);
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
DestroyMsgData(msgData);
}
}
}
void FUN_0200B518(struct ScrStrBufs * mgr, u32 idx, u32 a2)
{
GetECWordIntoStringByIndex(a2, mgr->tmpbuf);
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
}
void BufferSealName(struct ScrStrBufs * mgr, u32 idx, u32 seal)
{
struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0010_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, seal, mgr->tmpbuf);
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
DestroyMsgData(msgData);
}
}
void BufferSealNamePlural(struct ScrStrBufs * mgr, u32 idx, u32 seal)
{
struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0011_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, seal, mgr->tmpbuf);
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
DestroyMsgData(msgData);
}
}
void BufferLocationName(struct ScrStrBufs * mgr, u32 idx, u16 a2)
{
u32 r6 = (u32)FUN_02015CC0(a2);
u32 r4 = (u32)FUN_02015CE0(a2);
struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, UNK_020ECE64[r6], mgr->heap_id);
if (msgData != NULL)
{
if (r4 < MsgDataGetCount(msgData))
{
ReadMsgDataIntoString(msgData, r4, mgr->tmpbuf);
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
DestroyMsgData(msgData);
return;
}
// Location is invalid.
// Fallback: Mystery Zone
DestroyMsgData(msgData);
msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0382_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, 0, mgr->tmpbuf);
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
DestroyMsgData(msgData);
}
}
}
void BufferPoffinName(struct ScrStrBufs * mgr, u32 idx, u32 poffin)
{
struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0414_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, poffin, mgr->tmpbuf);
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
DestroyMsgData(msgData);
}
}
void BufferFashionName(struct ScrStrBufs * mgr, u32 idx, u32 fashion)
{
struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0338_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, fashion, mgr->tmpbuf);
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
DestroyMsgData(msgData);
}
}
void BufferFashionNameWithArticle(struct ScrStrBufs * mgr, u32 idx, u32 fashion)
{
struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0339_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, fashion, mgr->tmpbuf);
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
DestroyMsgData(msgData);
}
}
void BufferContestBackgroundName(struct ScrStrBufs * mgr, u32 idx, u32 bg)
{
struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0340_bin, mgr->heap_id);
if (msgData != NULL)
{
ReadMsgDataIntoString(msgData, bg, mgr->tmpbuf);
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
DestroyMsgData(msgData);
}
}
void BufferEasyChatWord(struct ScrStrBufs * mgr, struct SaveBlock2 * sav2, u32 r5, u32 idx, u32 sp28)
{
void * r6 = FUN_0202881C(sav2);
u8 sp10 = FUN_020287F8(r6, r5);
u8 r7 = FUN_02028804(r6, r5);
struct String * r4 = String_ctor(64, 4);
CopyU16ArrayToString(r4, FUN_020287A8(r6, r5, sp28));
BufferString(mgr, idx, r4, sp10, 1, r7);
String_dtor(r4);
}
void BufferMonthNameAbbr(struct ScrStrBufs * mgr, u32 idx, u32 month)
{
struct MsgData * msgData = NewMsgDataFromNarc(1, NARC_MSGDATA_MSG, NARC_msg_narc_0364_bin, mgr->heap_id);
if (msgData != NULL)
{
if (month < 1 || month > 12)
month = 1;
ReadMsgDataIntoString(msgData, month - 1, mgr->tmpbuf);
SetStringAsPlaceholder(mgr, idx, mgr->tmpbuf, NULL);
DestroyMsgData(msgData);
}
}
void ScrStrBufs_UpperFirstChar(struct ScrStrBufs * mgr, u32 idx)
{
StrUpperFirstChar(mgr->array[idx].msg);
}
void StringExpandPlaceholders(struct ScrStrBufs * mgr, struct String * dest, struct String * src)
{
const u16 * cstr = String_c_str(src);
StringSetEmpty(dest);
while (*cstr != EOS)
{
if (*cstr == 0xFFFE)
{
if (MsgArray_ControlCodeIsStrVar(cstr))
{
u32 idx = MsgArray_ControlCodeGetField(cstr, 0);
GF_ASSERT(idx < mgr->count);
StringCat_HandleTrainerName(dest, mgr->array[idx].msg);
cstr = MsgArray_SkipControlCode(cstr);
}
else
{
const u16 * before = cstr;
cstr = MsgArray_SkipControlCode(cstr);
while (before < cstr)
StrAddChar(dest, *before++);
}
}
else
StrAddChar(dest, *cstr++);
}
}
void ScrStrBufs_ResetBuffers(struct ScrStrBufs * mgr)
{
for (int i = 0; i < mgr->count; i++)
StringSetEmpty(mgr->array[i].msg);
}
struct UnkStruct_0200B870 * MessagePrinter_new(u32 color1, u32 color2, u32 color3, u32 heap_id)
{
struct UnkStruct_0200B870 * sp8 = AllocFromHeap(heap_id, sizeof(struct UnkStruct_0200B870));
if (sp8 != NULL)
{
sp8->unk_0 = GfGfxLoader_GetCharData(NARC_GRAPHIC_FONT, NARC_font_narc_0004_NCGR_lz, 1, &sp8->unk_4, heap_id);
int i;
u8 * ptr = sp8->unk_4->unk_14;
for (i = 0; i < sp8->unk_4->unk_10; i++)
{
switch (ptr[i])
{
case 0x00:
ptr[i] = (u8)((color3 << 4) | color3);
break;
case 0x01:
ptr[i] = (u8)((color3 << 4) | color1);
break;
case 0x02:
ptr[i] = (u8)((color3 << 4) | color2);
break;
case 0x10:
ptr[i] = (u8)((color1 << 4) | color3);
break;
case 0x11:
ptr[i] = (u8)((color1 << 4) | color1);
break;
case 0x12:
ptr[i] = (u8)((color1 << 4) | color2);
break;
case 0x20:
ptr[i] = (u8)((color2 << 4) | color3);
break;
case 0x21:
ptr[i] = (u8)((color2 << 4) | color1);
break;
case 0x22:
ptr[i] = (u8)((color2 << 4) | color2);
break;
}
}
sp8->unk_28 = color3;
}
return sp8;
}
void MessagePrinter_delete(struct UnkStruct_0200B870 * a0)
{
if (a0 != NULL)
{
if (a0->unk_0 != NULL)
FreeToHeap(a0->unk_0);
FreeToHeap(a0);
}
}
void FUN_0200B9A8(struct UnkStruct_0200B870 * a0, int a1, struct Window *a2, int a3, int a4)
{
BlitBitmapRectToWindow(a2, a0->unk_4->unk_14 + UNK_020ECE6C[a1][0], 0, 0, UNK_020ECE6C[a1][1], 8, (u16)a3, (u16)a4, UNK_020ECE6C[a1][1], 8);
}
void FUN_0200B9EC(struct UnkStruct_0200B870 * string, u32 value, u32 n, enum PrintingMode mode, struct Window *window, int x, int y)
{
ConvertUIntToDecimalString(string->data, value, mode, n);
for (int i = 0; string->data[i] != EOS; i++)
{
if (string->data[i] >= CHAR_0 && string->data[i] <= CHAR_9)
{
BlitBitmapRectToWindow(window, string->unk_4->unk_14 + (string->data[i] - CHAR_0) * 32, 0, 0, 8, 8, (u16)x, (u16)y, 8, 8);
}
else
{
FillWindowPixelRect(window, (u8)string->unk_28, (u16)x, (u16)y, 8, 8);
}
x += 8;
}
}
|