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
|
#include "global.h"
#include "input.h"
#include "main_menu.h"
#include "play_time.h"
#include "file_system.h"
#include "memory.h"
#include "menu.h"
#include "text.h"
#include "pokemon.h"
#include "save.h"
#include "code_800D090.h"
extern const struct FileArchive gTitleMenuFileArchive;
struct unkStruct_203B484
{
u8 fill0[0xC];
/* 0xC */ s16 speciesIndex;
u8 fillE[0x50 - 0xE];
/* 0x50 */ u8 helperName[10];
};
struct LoadScreen
{
// size: 0x27c
u32 currMenu;
u32 unk4;
u8 fill8[0x54 - 8];
u32 unk54;
u8 fill58[0xA4 - 0x58];
u32 unkA4;
u8 fillA8[0x144 - 0xA8];
struct UnkTextStruct2 unk144[4];
/* 0x1A4 */ u8 formattedTeamName[0x24];
/* 0x1C8 */ u8 formattedPlayerName[0x24];
/* 0x1EC */ u8 formattedLocation[0x24];
/* 0x210 */ u8 formattedPlayTime[0x24];
/* 0x234 */ u8 formattedAdventures[0x24];
/* 0x258 */ u8 formattedHelperInfo[0x24];
};
EWRAM_DATA struct LoadScreen *gLoadScreen;
EWRAM_DATA struct MenuItem gUnknown_203B378[2];
EWRAM_DATA u32 gUnknown_203B388[12];
EWRAM_DATA u32 gUnknown_203B3B8[12];
extern struct unkStruct_203B484 *gUnknown_203B484;
u8 IsQuickSave(void);
void DrawLoadScreenText(void);
void sub_80397B4(void);
extern void sub_8035CF4(u32 *, u32, u32);
extern void SetMenuItems(u32 *, struct UnkTextStruct2 *, u32, const struct UnkTextStruct2 *, const struct MenuItem *, u32, u32, u32);
extern u8 sub_8012FD8(u32 *);
extern void sub_8013114(u32 *, u32 *);
extern void sub_8095240(u32);
extern void sub_80920D8(u8 *);
extern struct PokemonStruct *GetPlayerPokemonStruct(void);
extern u8 sub_80023E4(u32);
extern u8 *sub_8098FB4();
extern u8 *GetDungeonLocationInfo(void);
extern u32 GetNumAdventures(void);
extern void xxx_call_draw_string(u32 x, u32 y, const u8 *, u32, u32);
extern void PrintDungeonLocationtoBuffer(u8 *, u8 *);
extern void sub_80922B4(u8 *, const u8 *, u32);
extern s32 sub_8095324(u32);
extern u32 sub_8001658(u32, u32);
extern void sub_80073E0(u32);
extern void sub_8008C54(u32);
extern void sub_80073B8(u32);
extern void sub_808D930(u8 *, s16);
extern void xxx_format_string(u8 *, u8 *, u8 *, u32);
extern void SetBGPaletteBufferColorArray(s32, s32);
extern void sub_8007E20(s32, s32, s32, u32, u32, s32, u32);
const struct UnkTextStruct2 gUnknown_80E75F8 = {
0x00, 0x00, 0x00, 0x00,
0x03, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
NULL
};
const struct UnkTextStruct2 gUnknown_80E7610 = {
0x00, 0x00, 0x00, 0x00,
0x03, 0x00, 0x00, 0x00,
0x02, 0x00, 0x02, 0x00,
0x1A, 0x0B,
0x0B, 0x00,
NULL
};
const u8 gUnkData_80E7628[] = {0x20, 0x00, 0x00, 0x00};
const struct UnkTextStruct2 gUnknown_80E762C = {
0x00, 0x00, 0x00, 0x00,
0x03, 0x00, 0x00, 0x00,
0x02, 0x00, 0x0F, 0x00,
0x13, 0x03,
0x03, 0x00,
NULL
};
const struct MenuItem gResumeQuicksaveMenuItems[3] =
{
{"Resuming from quicksave.", 5},
{"Is that OK?", 5},
{NULL, 3},
};
const struct MenuItem gResumeAdventureMenuItems[3] =
{
{"Resuming saved adventure.", 5},
{"Is that OK?", 5},
{NULL, 3},
};
const struct MenuItem gQuitWaitingRescueMenuItems[3] =
{
{"Quit awaiting rescue?", 5},
{"Is that OK?", 5},
{NULL, 3},
};
const struct MenuItem gDeleteSavePromptMenuItems[3] =
{
{"Your saved data will be", 5},
{"deleted. Is that OK?", 5},
{NULL, 3},
};
const struct MenuItem gDeleteSaveConfirmMenuItems[3] =
{
{"Are you sure you want to", 5},
{"delete all of your saved data?", 5},
{NULL, 3},
};
const struct UnkTextStruct2 gUnknown_80E7784 =
{
0x00, 0x00, 0x00, 0x00,
0x03, 0x00, 0x00, 0x00,
0x17, 0x00, 0x0F, 0x00,
0x05, 0x03,
0x03, 0x00,
NULL
};
const struct MenuItem gLoadScreenYesNoMenu[3] =
{
{"Yes", 1},
{"No", 2},
{NULL, 3},
};
ALIGNED(4) const char gTeamHeadingText[] = "Team:";
ALIGNED(4) const char gNameHeadingText[] = "Name:";
ALIGNED(4) const char gLocationHeadingText[] = "Location:";
ALIGNED(4) const char gPlayTimeHeadingText[] = "Play time:";
ALIGNED(4) const char gAdventuresHeadingText[] = "Adventures:";
ALIGNED(4) const char gHelperHeadingText[] = "Helper:";
ALIGNED(4) const char gNoTeamNamePlaceholder[] = _("????");
ALIGNED(4) const char gUnknown_80E7804[] = "%s ";
ALIGNED(4) const char gNoNamePlaceholder[] = "???";
ALIGNED(4) const char gQuicksaveDataDeletedText[] = "Quicksave data deleted.";
ALIGNED(4) const char gLocationUnknownText[] = "Location unknown.";
ALIGNED(4) const char gPlayTimePlaceholder[] = "%d:%02d:%02d ";
ALIGNED(4) const char gNumAdventurePlaceholder[] = "%d";
ALIGNED(4) const char gHelperInfoPlaceholder[] = "%s (%s)";
ALIGNED(4) const char gNoHelperText[] = "-----";
ALIGNED(4) const char gClmkpatFileName[] = "clmkpat"; // clmkpat
ALIGNED(4) const char load_screen_fill[] = "pksdir0";
void CreateLoadScreen(u32 currMenu)
{
int iVar8;
if (gLoadScreen == NULL) {
gLoadScreen = MemoryAlloc(sizeof(struct LoadScreen),8);
MemoryFill8((u8 *)gLoadScreen,0,sizeof(struct LoadScreen));
}
gLoadScreen->currMenu = currMenu;
for(iVar8 = 0; iVar8 < 4; iVar8++){
gLoadScreen->unk144[iVar8] = gUnknown_80E75F8;
}
ResetUnusedInputStruct();
sub_800641C(gLoadScreen->unk144,1,1);
SetMenuItems(&gLoadScreen->unk4,gLoadScreen->unk144,0,&gUnknown_80E7610,gUnknown_203B378,0,6,0);
switch(gLoadScreen->currMenu){
case MENU_CONTINUE:
if (IsQuickSave())
SetMenuItems(&gLoadScreen->unk4,gLoadScreen->unk144,1,&gUnknown_80E762C,gResumeQuicksaveMenuItems,0,6,0);
else
SetMenuItems(&gLoadScreen->unk4,gLoadScreen->unk144,1,&gUnknown_80E762C,gResumeAdventureMenuItems,0,6,0);
break;
case MENU_AWAITING_RESCUE:
SetMenuItems(&gLoadScreen->unk4,gLoadScreen->unk144,1,&gUnknown_80E762C,gQuitWaitingRescueMenuItems,0,6,0);
break;
case MENU_DELETE_SAVE_PROMPT:
SetMenuItems(&gLoadScreen->unk4,gLoadScreen->unk144,1,&gUnknown_80E762C,gDeleteSavePromptMenuItems,0,6,0);
break;
case MENU_DELETE_SAVE_CONFIRM:
SetMenuItems(&gLoadScreen->unk4,gLoadScreen->unk144,1,&gUnknown_80E762C, gDeleteSaveConfirmMenuItems,0,6,0);
break;
}
SetMenuItems(&gLoadScreen->unk4,gLoadScreen->unk144,2,&gUnknown_80E7784,gLoadScreenYesNoMenu,1,2,0);
sub_8035CF4(&gLoadScreen->unk4,0,0);
sub_8035CF4(&gLoadScreen->unk4,1,0);
sub_8035CF4(&gLoadScreen->unk4,2,1);
DrawLoadScreenText();
}
void CleanLoadScreen(void)
{
ResetUnusedInputStruct();
sub_800641C(NULL, 1, 1);
if(gLoadScreen != NULL)
{
MemoryFree(gLoadScreen);
gLoadScreen = NULL;
}
}
u32 UpdateLoadScreenMenu(void)
{
u32 nextMenu;
u32 menuAction;
nextMenu = MENU_NO_SCREEN_CHANGE;
menuAction = 4;
sub_8012FD8(&gLoadScreen->unk54);
if (sub_8012FD8(&gLoadScreen->unkA4) == '\0') {
sub_8013114(&gLoadScreen->unkA4,&menuAction);
}
switch(menuAction)
{
case 3:
case 2:
nextMenu = MENU_MAIN_SCREEN;
break;
case 1:
switch(gLoadScreen->currMenu)
{
case MENU_CONTINUE:
nextMenu = 2; // MENU_???
break;
case MENU_AWAITING_RESCUE:
sub_8095240(0);
nextMenu = 4; // MENU_???
break;
case MENU_DELETE_SAVE_PROMPT:
nextMenu = MENU_DELETE_SAVE_CONFIRM;
break;
case MENU_DELETE_SAVE_CONFIRM:
sub_80122A8();
nextMenu = MENU_DELETE_SAVE;
break;
}
break;
case 5:
default:
break;
}
return nextMenu;
}
static inline u8 *DrawLoadScreenTextSub(u8 *teamNameBuffer) {
strcpy(teamNameBuffer,gNoTeamNamePlaceholder);
return teamNameBuffer;
}
void DrawLoadScreenText(void)
{
int iVar2;
u32 numAdventures;
u8 auStack356 [100];
u8 teamNameBuffer [40];
u8 playerName [80];
u8 nameHelper [80];
u8 speciesHelper [20];
u32 hours;
u32 minutes;
u32 seconds;
struct PokemonStruct *playerInfo;
struct unkStruct_203B484 *temp2;
u8 *r2;
iVar2 = sub_8011FA8();
sub_8008C54(0);
sub_80073B8(0);
xxx_call_draw_string(8,0, gTeamHeadingText,0,0); // Team:
xxx_call_draw_string(8,12,gNameHeadingText,0,0); // Name:
xxx_call_draw_string(8,24,gLocationHeadingText,0,0); // Location:
xxx_call_draw_string(8,36,gPlayTimeHeadingText,0,0); // Play time:
xxx_call_draw_string(8,48,gAdventuresHeadingText,0,0); // Adventures:
xxx_call_draw_string(8,60,gHelperHeadingText,0,0); // Helper:
// Draw Team Name
if (sub_80023E4(0) != '\0') {
sub_80920D8(teamNameBuffer);
r2 = teamNameBuffer;
}
else {
// NOTE: static inline was needed here to match -jiang
r2 = DrawLoadScreenTextSub(teamNameBuffer);
}
sprintf_2(gLoadScreen->formattedTeamName,gUnknown_80E7804,r2);
xxx_call_draw_string(64,0,gLoadScreen->formattedTeamName,0,0);
// Draw Player Name
playerInfo = GetPlayerPokemonStruct();
if (playerInfo == NULL)
sub_80922B4(playerName, gNoNamePlaceholder, POKEMON_NAME_LENGTH);
else
sub_80922B4(playerName, playerInfo->name, POKEMON_NAME_LENGTH);
sprintf_2(gLoadScreen->formattedPlayerName,gUnknown_80E7804,playerName);
xxx_call_draw_string(64,12,gLoadScreen->formattedPlayerName,0,0);
// Draw Location Info
if ((sub_8095324(1) != 0) || (sub_8095324(7) != 0)) {
if (iVar2 == 0xf1207)
PrintDungeonLocationtoBuffer(gLoadScreen->formattedLocation,GetDungeonLocationInfo());
else
sprintf_2(gLoadScreen->formattedLocation,gQuicksaveDataDeletedText); // Quicksave data deleted
}
else {
switch(sub_8011C1C())
{
case 1:
switch(sub_8001658(0,24))
{
default:
sprintf_2(auStack356,gUnknown_80E7804,sub_8098FB4());
xxx_format_string(auStack356,gLoadScreen->formattedLocation,gLoadScreen->formattedPlayTime,0);
break;
case 0x7:
case 0xB:
sprintf_2(gLoadScreen->formattedLocation,gQuicksaveDataDeletedText); // Quicksave data deleted
break;
}
break;
case 2:
if (iVar2 == 0xf1207)
PrintDungeonLocationtoBuffer(gLoadScreen->formattedLocation,GetDungeonLocationInfo());
else
sprintf_2(gLoadScreen->formattedLocation,gQuicksaveDataDeletedText); // Quicksave data deleted
break;
default:
sprintf_2(gLoadScreen->formattedLocation,gLocationUnknownText); // Location unknown
break;
}
}
xxx_call_draw_string(64,24,gLoadScreen->formattedLocation,0,0);
// Draw Play Time
DeconstructPlayTime(gPlayTimeRef,&hours,&minutes,&seconds);
sprintf_2(gLoadScreen->formattedPlayTime,gPlayTimePlaceholder,hours,minutes,seconds);
xxx_call_draw_string(64,36,gLoadScreen->formattedPlayTime,0,0);
// Draw Adventures Info
numAdventures = GetNumAdventures();
sprintf_2(gLoadScreen->formattedAdventures,gNumAdventurePlaceholder,numAdventures); // %d
xxx_call_draw_string(64,48,gLoadScreen->formattedAdventures,0,0);
// Draw Helper Info
if (iVar2 == 0xf1207){
// NOTE: very hacky match here but needed var here to match
temp2 = gUnknown_203B484;
if(temp2->speciesIndex != SPECIES_NONE) {
sub_808D930(speciesHelper,temp2->speciesIndex);
sub_80922B4(nameHelper,temp2->helperName,POKEMON_NAME_LENGTH);
sprintf_2(gLoadScreen->formattedHelperInfo,gHelperInfoPlaceholder,nameHelper,speciesHelper); // %s (%s)
}
else
goto print_helper_placeholder;
}
else {
print_helper_placeholder:
sprintf_2(gLoadScreen->formattedHelperInfo,gNoHelperText); // -----
}
xxx_call_draw_string(64,60,gLoadScreen->formattedHelperInfo,0,0);
sub_80397B4(); // Draw event icons??
sub_80073E0(0);
}
// Think structure of clmkFile is like Team Rank Badges except each pic has a diff pallete
// TODO clean up but it matches so yea
void sub_80397B4(void)
{
struct OpenedFile *clmkFile;
int iVar3;
int iVar4;
s32 other_arg;
clmkFile = OpenFileAndGetFileDataPtr(gClmkpatFileName,&gTitleMenuFileArchive); // clmkpat
for(iVar3 = 0; iVar3 < 64; iVar3++)
{
SetBGPaletteBufferColorArray(iVar3 + 176,*(int *)((clmkFile->data) + 4) + iVar3 * 4);
}
iVar4 = 8;
other_arg = 0x49;
// Draw the 12 legendary icons
for(iVar3 = 0; iVar3 < 12; iVar3++)
{
if (sub_80023E4(gUnknown_203B3B8[iVar3]) != 0) {
sub_8007E20(0,iVar4,other_arg,0x10,0x10,*(int *)(clmkFile->data) + iVar3 * 0x80,
gUnknown_203B388[iVar3]);
iVar4 += 16;
}
}
CloseFile(clmkFile);
}
bool8 IsQuickSave(void)
{
int iVar1;
bool8 isQuicksave;
iVar1 = sub_8011FA8();
isQuicksave = FALSE;
if (sub_8095324(1) != 0 || sub_8095324(7) != 0)
{
if (iVar1 == 0xf1207)
isQuicksave = TRUE;
}
else if (sub_8011C1C() == 2 && iVar1 == 0xf1207)
isQuicksave = TRUE;
return isQuicksave;
}
|