Merge pull request #413 from DizzyEggg/naming_screen

This commit is contained in:
Seth Barberee 2025-06-04 07:51:58 -07:00 committed by GitHub
commit 8c960ff1b9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
29 changed files with 1010 additions and 1016 deletions

View File

@ -1,7 +0,0 @@
#ifndef GUARD_CODE_8012A18_1_H
#define GUARD_CODE_8012A18_1_H
s32 sub_8015FEC(u8 *buffer, s32 size);
s32 sub_8016028(void);
#endif // GUARD_CODE_8012A18_1_H

View File

@ -6,9 +6,9 @@
u32 sub_8012A64(MenuInputStructSub *r0, s32 r1);
s32 GetKeyPress(MenuInputStruct *r0);
s32 sub_8012AE8(void);
s32 GetMenuInput(void);
void sub_8012BC4(u32 x, u32 y, s32 n, s32 len, u32 color, u32 windowId);
void sub_8012C60(u32 x, u32 y, u32 param_3, u32 color, u32 param_5);
void DrawCharOnWindowWidth12(u32 x, u32 y, u32 param_3, u32 color, u32 param_5);
void sub_8012CAC(WindowTemplate *param_1, const MenuItem *param_2);
void sub_8012D08(WindowTemplate *param_1, s32 param_2);
void sub_8012D34(WindowTemplate *param_1, s32 param_2);

10
include/naming_screen.h Normal file
View File

@ -0,0 +1,10 @@
#ifndef GUARD_NAMING_SCREEN_H
#define GUARD_NAMING_SCREEN_H
u32 NamingScreen_Init(u32 type, u8 *defaultText);
u32 NamingScreen_HandleInput(void);
void NamingScreen_Free(void);
s32 GetStrWidth(u8 *buffer, s32 size);
s32 GetMaxPokeNameWidth(void);
#endif

View File

@ -12,7 +12,6 @@
void sub_80140DC(void);
void sub_8014114(void);
s32 sub_80144A4(s32 *);
u32 sub_80151C0(u32, u8 *);
u32 sub_80154F0(void);
void sub_80155F0(void);

View File

@ -8,7 +8,7 @@ typedef struct unkChar
{
const u16 *unk0;
u16 unk4;
s16 unk6;
s16 width;
u8 unk8;
u8 fill9;
u8 unkA;

View File

@ -16,9 +16,9 @@ void sub_8007B7C(u32 a0, s32 x, s32 y, s32 a3, u32 color);
void sub_8007E20(u32 a0, u32 a1, u32 a2, u32 a3, u32 a4, u32 *a5, u32 a6);
void sub_80087EC(s32 a0, s32 a1, s32 a2, s32 a3, s32 a4);
void sub_80089AC(const WindowTemplate *r4, DungeonPos *r5_Str);
u32 xxx_call_draw_char(s32 x, s32 y, u32 chr, u32 color, u32 windowId);
u32 DrawCharOnWindow(s32 x, s32 y, u32 chr, u32 color, u32 windowId);
bool8 xxx_call_update_bg_vram(void);
u32 xxx_draw_char(Window *windows, s32 x, s32 y, u32 chr, u32 color, u32 windowId);
u32 DrawCharOnWindowInternal(Window *windows, s32 x, s32 y, u32 chr, u32 color, u32 windowId);
const u8 *xxx_get_next_char_from_string(const u8 *a1, u32 *dstChr);
#endif // GUARD_TEXT_2_H

View File

@ -103,7 +103,7 @@ SECTIONS {
src/menu_input.o(.text);
src/string_format.o(.text);
src/code_8015080.o(.text);
src/code_8012A18_1.o(.text);
src/naming_screen.o(.text);
src/code_801602C.o(.text);
src/felicity_bank.o(.text);
src/kangaskhan_storage1.o(.text);
@ -455,6 +455,7 @@ SECTIONS {
src/string_format.o(.rodata);
src/common_strings.o(.rodata);
src/code_8015080.o(.rodata);
src/naming_screen.o(.rodata);
src/code_801602C.o(.rodata);
src/felicity_bank.o(.rodata);
src/kangaskhan_storage1.o(.rodata);

View File

@ -1,100 +0,0 @@
#include "global.h"
#include "structs/sprite_oam.h"
#include "code_8012A18_1.h"
#include "text_2.h"
#include "text_util.h"
struct unkStruct_203B1FC
{
// size: 0x198
u32 unk0;
u8 unk4;
SpriteOAM unk6;
SpriteOAM unkE;
u8 unk16;
u8 unk17;
u8 unk18;
u8 unk1B;
u8 unk1C;
s16 unk1E[1];
u8 fill20[0x8A - 0x20];
s16 unk8A[2];
u8 fill8E[0xF8 - 0x8E];
u8 *unkF8;
u8 unkFC[54];
};
EWRAM_INIT struct unkStruct_203B1FC *gUnknown_203B1FC = NULL;
s32 sub_8015F44(void)
{
s32 index;
s32 counter;
index = 0;
if (index < gUnknown_203B1FC->unk1B && gUnknown_203B1FC->unkF8[0] != 0) {
index = 1;
counter = 1;
while (TRUE) {
if (counter >= gUnknown_203B1FC->unk1B)
return index;
if (gUnknown_203B1FC->unkF8[counter] == 0)
return index;
index = counter + 1;
counter = index;
}
}
return index;
}
void sub_8015F84(void)
{
u32 uVar2;
const unkChar *puVar3;
s32 index;
s32 total;
total = 0;
for(index = 0; index < gUnknown_203B1FC->unk1B; index++)
{
gUnknown_203B1FC->unk1E[index] = total;
if (gUnknown_203B1FC->unkF8[index] == 0) {
gUnknown_203B1FC->unk8A[index] = 8;
return;
}
uVar2 = ReturnIntFromChar2(gUnknown_203B1FC->unkF8[index]);
puVar3 = GetCharacter(uVar2);
gUnknown_203B1FC->unk8A[index] = puVar3->unk6;
total += puVar3->unk6;
}
}
// TODO: Above code is in code_80130A8.s
s32 sub_8015FEC(u8 *buffer, s32 size)
{
const unkChar *iVar2;
s32 currLength;
s32 length;
u8 *bufferPtr;
length = 0;
currLength = 0;
if (currLength < size && *buffer != '\0') {
bufferPtr = buffer; // Had to have another variable to match..
do {
iVar2 = GetCharacter(ReturnIntFromChar2(*bufferPtr));
length += iVar2->unk6;
bufferPtr++;
currLength++;
} while (currLength < size && *bufferPtr != '\0');
}
return length;
}
s32 sub_8016028(void)
{
return 60;
}

View File

@ -11,6 +11,8 @@
#include "text_1.h"
#include "text_2.h"
#include "text_3.h"
#include "text_util.h"
#include "constants/input.h"
struct unkStruct_203B1F8
{
@ -23,14 +25,7 @@ struct unkStruct_203B1F8
EWRAM_INIT struct unkStruct_203B1F8 *gUnknown_203B1F8 = {NULL};
const WindowTemplate gUnknown_80DAF70 = {
0x00,
0x03,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
NULL
};
static const WindowTemplate sWindowTemplateDummy = WIN_TEMPLATE_DUMMY;
const WindowTemplate gUnknown_80DAF88 = {
0x00,
@ -50,244 +45,6 @@ const WindowTemplate gUnknown_80DAFA0 = {
NULL
};
struct Struct80DB0F8
{
u8 unk0;
u8 unk1;
u8 unk2;
u8 unk3;
u8 x;
u8 y;
u8 unk6;
s32 unk8;
};
UNUSED static const char sPksDir[] = "pksdir0";
static const DungeonPos gUnknown_80DAFC0[] =
{
{3, 0xD},
{0xF, 0xD},
{0x1B, 0xD},
{0x27, 0xD},
{0x33, 0xD},
{0x40, 0xF},
{0x4C, 0xF},
{0x58, 0xF},
{0x64, 0xF},
{0x70, 0xF},
{0x7C, 0xF},
{0x88, 0xF},
{0x94, 0xF},
{0xA1, 0xD},
{0xAD, 0xD},
{0xB9, 0xD},
{0xC5, 0xD},
{0xD1, 0xD},
{3, 0x1A},
{0xF, 0x1A},
{0x1B, 0x1A},
{0x27, 0x1A},
{0x33, 0x1A},
{0x40, 0x1C},
{0x4C, 0x1C},
{0x58, 0x1C},
{0x64, 0x1C},
{0x70, 0x1C},
{0x7C, 0x1C},
{0x88, 0x1C},
{0x94, 0x1C},
{0xA1, 0x1A},
{0xAD, 0x1A},
{0xB9, 0x1A},
{0xC5, 0x1A},
{0xD1, 0x1A},
{3, 0x28},
{0xF, 0x28},
{0x1B, 0x28},
{0x27, 0x28},
{0x33, 0x28},
{0x40, 0x2A},
{0x4C, 0x2A},
{0x58, 0x2A},
{0x64, 0x2A},
{0x70, 0x2A},
{0x7C, 0x2A},
{0x88, 0x2A},
{0x94, 0x2A},
{0xA1, 0x28},
{0xAD, 0x28},
{0xB9, 0x28},
{0xC5, 0x28},
{0xD1, 0x28},
};
static const DungeonPos gUnknown_80DB098[] =
{
{0x20, 0x12},
{0x2E, 0x12},
{0x3C, 0x12},
{0x4A, 0x12},
{0x58, 0x14},
{0x66, 0x14},
{0x74, 0x14},
{0x82, 0x14},
{0x90, 0x12},
{0x9E, 0x12},
{0xAC, 0x12},
{0xBA, 0x12},
{0x20, 0x24},
{0x2E, 0x24},
{0x3C, 0x24},
{0x4A, 0x24},
{0x58, 0x26},
{0x66, 0x26},
{0x74, 0x26},
{0x82, 0x26},
{0x90, 0x24},
{0x9E, 0x24},
{0xAC, 0x24},
{0xBA, 0x24},
};
// It was programmed as a 2d array, however it's effectively a 1d array(since there's only one entry for [0][x]). Could be different in Blue?
static const struct Struct80DB0F8 gUnknown_80DB0F8[][85] =
{
[0] = {
{0, 0, 0, 0, 8, 3, 0, 264},
{0, 0, 0, 0, 8, 14, 0, 264},
{0, 0, 0, 0, 8, 25, 0, 264},
{5, 4, 81, 9, 8, 36, 3, 263},
{3, 5, 82, 10, 8, 47, 3, 261},
{4, 3, 83, 11, 8, 58, 3, 262},
{11, 7, 78, 12, 36, 3, 0, 97},
{6, 8, 79, 13, 36, 14, 0, 110},
{7, 9, 80, 14, 36, 25, 0, 65},
{8, 10, 3, 15, 36, 36, 0, 78},
{9, 11, 4, 16, 36, 47, 0, 233},
{10, 6, 5, 17, 36, 58, 0, 43},
{17, 13, 6, 18, 50, 3, 0, 98},
{12, 14, 7, 19, 50, 14, 0, 111},
{13, 15, 8, 20, 50, 25, 0, 66},
{14, 16, 9, 21, 50, 36, 0, 79},
{15, 17, 10, 22, 50, 47, 0, 49},
{16, 12, 11, 23, 50, 58, 0, 45},
{23, 19, 12, 24, 64, 3, 0, 99},
{18, 20, 13, 25, 64, 14, 0, 112},
{19, 21, 14, 26, 64, 25, 0, 67},
{20, 22, 15, 27, 64, 36, 0, 80},
{21, 23, 16, 28, 64, 47, 0, 50},
{22, 18, 17, 29, 64, 58, 0, 44},
{29, 25, 18, 30, 78, 3, 0, 100},
{24, 26, 19, 31, 78, 14, 0, 113},
{25, 27, 20, 32, 78, 25, 0, 68},
{26, 28, 21, 33, 78, 36, 0, 81},
{27, 29, 22, 34, 78, 47, 0, 51},
{28, 24, 23, 35, 78, 58, 0, 46},
{35, 31, 24, 36, 92, 3, 0, 101},
{30, 32, 25, 37, 92, 14, 0, 114},
{31, 33, 26, 38, 92, 25, 0, 69},
{32, 34, 27, 39, 92, 36, 0, 82},
{33, 35, 28, 40, 92, 47, 0, 52},
{34, 30, 29, 41, 92, 58, 0, 33},
{41, 37, 30, 42, 106, 3, 0, 102},
{36, 38, 31, 43, 106, 14, 0, 115},
{37, 39, 32, 44, 106, 25, 0, 70},
{38, 40, 33, 45, 106, 36, 0, 83},
{39, 41, 34, 46, 106, 47, 0, 53},
{40, 36, 35, 47, 106, 58, 0, 63},
{47, 43, 36, 48, 120, 3, 0, 103},
{42, 44, 37, 49, 120, 14, 0, 116},
{43, 45, 38, 50, 120, 25, 0, 71},
{44, 46, 39, 51, 120, 36, 0, 84},
{45, 47, 40, 52, 120, 47, 0, 54},
{46, 42, 41, 53, 120, 58, 0, 145},
{53, 49, 42, 54, 134, 3, 0, 104},
{48, 50, 43, 55, 134, 14, 0, 117},
{49, 51, 44, 56, 134, 25, 0, 72},
{50, 52, 45, 57, 134, 36, 0, 85},
{51, 53, 46, 58, 134, 47, 0, 55},
{52, 48, 47, 59, 134, 58, 0, 146},
{59, 55, 48, 60, 148, 3, 0, 105},
{54, 56, 49, 61, 148, 14, 0, 118},
{55, 57, 50, 62, 148, 25, 0, 73},
{56, 58, 51, 63, 148, 36, 0, 86},
{57, 59, 52, 64, 148, 47, 0, 56},
{58, 54, 53, 65, 148, 58, 0, 147},
{65, 61, 54, 66, 162, 3, 0, 106},
{60, 62, 55, 67, 162, 14, 0, 119},
{61, 63, 56, 68, 162, 25, 0, 74},
{62, 64, 57, 69, 162, 36, 0, 87},
{63, 65, 58, 70, 162, 47, 0, 57},
{64, 60, 59, 71, 162, 58, 0, 148},
{71, 67, 60, 72, 176, 3, 0, 107},
{66, 68, 61, 73, 176, 14, 0, 120},
{67, 69, 62, 74, 176, 25, 0, 75},
{68, 70, 63, 75, 176, 36, 0, 88},
{69, 71, 64, 76, 176, 47, 0, 48},
{70, 66, 65, 77, 176, 58, 0, 189},
{77, 73, 66, 78, 190, 3, 0, 108},
{72, 74, 67, 79, 190, 14, 0, 121},
{73, 75, 68, 80, 190, 25, 0, 76},
{74, 76, 69, 81, 190, 36, 0, 89},
{75, 77, 70, 82, 190, 47, 0, 58},
{76, 72, 71, 83, 190, 58, 0, 190},
{83, 79, 72, 6, 204, 3, 0, 109},
{78, 80, 73, 7, 204, 14, 0, 122},
{79, 81, 74, 8, 204, 25, 0, 77},
{80, 82, 75, 3, 204, 36, 0, 90},
{81, 83, 76, 4, 204, 47, 0, 133},
{82, 78, 77, 5, 204, 58, 0, 32},
{0, 0, 0, 0, 8, 3, 2, 265},
}
};
static const u8 *const gUnknown_80DB4F4[] =
{
_(""),
_(""),
_("かな"),
_("カナ"),
_(""),
_("DEL"),
_("END"),
};
static const WindowTemplate gUnknown_80DB538 = {
0x00,
0x03,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
NULL
};
static const WindowTemplate gUnknown_80DB550 = {
0x00,
0x01,
0x01, 0x0A,
0x1C, 0x09,
0x09, 0x00,
NULL
};
static const WindowTemplate gUnknown_80DB568 = {
0x00,
0x01,
0x04, 0x03,
0x16, 0x05,
0x05, 0x00,
NULL
};
static const WindowTemplate gUnknown_80DB580 = {
0x00,
0x01,
0x01, 0x02,
0x1C, 0x07,
0x07, 0x00,
NULL
};
bool8 sub_8015080(u8 *buffer, const MenuItem *menuItems)
{
s32 index;
@ -295,9 +52,9 @@ bool8 sub_8015080(u8 *buffer, const MenuItem *menuItems)
gUnknown_203B1F8 = MemoryAlloc(sizeof(struct unkStruct_203B1F8), 8);
gUnknown_203B1F8->menuAction = 0;
for(index = 0; index < 4; index++)
for(index = 0; index < MAX_WINDOWS; index++)
{
gUnknown_203B1F8->windows.id[index] = gUnknown_80DAF70;
gUnknown_203B1F8->windows.id[index] = sWindowTemplateDummy;
}
gUnknown_203B1F8->windows.id[0] = gUnknown_80DAF88;
@ -336,559 +93,3 @@ void sub_80151A4(void)
gUnknown_203B1F8 = NULL;
}
}
struct unkStruct_203B1FC
{
// size: 0x198
u32 unk0;
u8 unk4;
// Note: These had to be declared like these, because SpriteOAM is aligned by 4 and these aren't. Makes you think if SpriteOAM is actually a struct, and not just an array of 4 u16s.
u16 sprite1Attribs[4];
u16 sprite2Attribs[4];
u8 unk16;
u8 unk17;
u8 unk18;
u8 unk19;
u8 unk1A;
u8 unk1B;
u8 unk1C;
u16 unk1E[54];
s16 unk8A[54];
u8 *unkF8;
u8 unkFC[56];
u8 *unk134;
WindowTemplates windows;
};
extern struct unkStruct_203B1FC *gUnknown_203B1FC;
s32 sub_8015F44(void);
void sub_8015A08(u32);
void sub_8015C1C(void);
void sub_8015F84();
void sub_80157D8(void);
void sub_80158BC(void);
void sub_8015E10(u8 *a0, s32 a1, s32 _a2);
void sub_8015EB4(u8 *a0, s32 a1, s32 _a2);
s32 sub_8016028(void);
s32 sub_8015FEC(u8 *buffer, s32 size);
u32 sub_801560C(void);
bool8 sub_8015748(void);
u32 sub_80151C0(u32 r0, u8 *buffer)
{
SpriteOAM *sprite;
s32 index;
s32 i;
gUnknown_203B1FC = MemoryAlloc(sizeof(*gUnknown_203B1FC), 8);
gUnknown_203B1FC->unk0 = r0;
gUnknown_203B1FC->unk19 = 0;
gUnknown_203B1FC->unk18 = 0;
gUnknown_203B1FC->unk4 = 0;
switch(gUnknown_203B1FC->unk0) {
case 4:
gUnknown_203B1FC->unk1A = 9;
gUnknown_203B1FC->unk4 = 1;
gUnknown_203B1FC->unk1B = 0x36;
break;
case 5:
gUnknown_203B1FC->unk1A = 9;
gUnknown_203B1FC->unk4 = 1;
gUnknown_203B1FC->unk1B = 0x18;
break;
case 0:
case 1:
case 3:
default:
gUnknown_203B1FC->unk1A = 6;
gUnknown_203B1FC->unk1B = 0xA;
break;
}
gUnknown_203B1FC->unk134 = buffer;
gUnknown_203B1FC->unkF8 = gUnknown_203B1FC->unkFC;
for (i = 0; i < 0x36; i++) {
gUnknown_203B1FC->unkF8[i] = 0;
}
MemoryCopy8(gUnknown_203B1FC->unkF8, gUnknown_203B1FC->unk134, gUnknown_203B1FC->unk1B);
for (i = 0; i < gUnknown_203B1FC->unk1B; i++) {
if (gUnknown_203B1FC->unkF8[i] == 0) {
break;
}
}
for (; i < gUnknown_203B1FC->unk1B; i++) {
gUnknown_203B1FC->unkF8[i] = 0;
}
gUnknown_203B1FC->unk1C = sub_8015F44();
if (gUnknown_203B1FC->unk1C == gUnknown_203B1FC->unk1B) {
gUnknown_203B1FC->unk1C--;
}
SpriteSetAffine1((SpriteOAM *) &gUnknown_203B1FC->sprite1Attribs, 0);
SpriteSetAffine2((SpriteOAM *) &gUnknown_203B1FC->sprite1Attribs, 0);
SpriteSetObjMode((SpriteOAM *) &gUnknown_203B1FC->sprite1Attribs, 0);
SpriteSetMosaic((SpriteOAM *) &gUnknown_203B1FC->sprite1Attribs, 0);
SpriteSetBpp((SpriteOAM *) &gUnknown_203B1FC->sprite1Attribs, 0);
SpriteSetPriority((SpriteOAM *) &gUnknown_203B1FC->sprite1Attribs, 0);
SpriteSetPalNum((SpriteOAM *) &gUnknown_203B1FC->sprite1Attribs, 15);
SpriteSetX((SpriteOAM *) &gUnknown_203B1FC->sprite1Attribs, DISPLAY_WIDTH);
SpriteSetY((SpriteOAM *) &gUnknown_203B1FC->sprite1Attribs, DISPLAY_WIDTH);
if (gUnknown_203B1FC->unk4 != 0) {
SpriteSetMatrixNum((SpriteOAM *) &gUnknown_203B1FC->sprite1Attribs, 0);
SpriteSetTileNum((SpriteOAM *) &gUnknown_203B1FC->sprite1Attribs, 0x3F6);
SpriteSetSize((SpriteOAM *) &gUnknown_203B1FC->sprite1Attribs, 0);
SpriteSetShape((SpriteOAM *) &gUnknown_203B1FC->sprite1Attribs, 1);
}
else {
SpriteSetMatrixNum((SpriteOAM *) &gUnknown_203B1FC->sprite1Attribs, 16);
SpriteSetTileNum((SpriteOAM *) &gUnknown_203B1FC->sprite1Attribs, 0x3F0);
SpriteSetSize((SpriteOAM *) &gUnknown_203B1FC->sprite1Attribs, 0);
SpriteSetShape((SpriteOAM *) &gUnknown_203B1FC->sprite1Attribs, 1);
}
gUnknown_203B1FC->unk16 = 4;
sprite = (SpriteOAM *) &gUnknown_203B1FC->sprite2Attribs;
SpriteSetAffine1(sprite, 0);
SpriteSetAffine2(sprite, 0);
SpriteSetObjMode(sprite, 0);
SpriteSetMosaic(sprite, 0);
SpriteSetBpp(sprite, 0);
SpriteSetShape(sprite, 0);
SpriteSetTileNum(sprite, 0x3F4);
SpriteSetPriority(sprite, 0);
SpriteSetPalNum(sprite, 15);
SpriteSetMatrixNum(sprite, 0);
SpriteSetSize(sprite, 0);
SpriteSetX(sprite, DISPLAY_WIDTH);
SpriteSetY(sprite, DISPLAY_WIDTH);
gUnknown_203B1FC->unk17 = 0;
for (index = 0; index < 4; index++) {
gUnknown_203B1FC->windows.id[index] = gUnknown_80DB538;
}
if(gUnknown_203B1FC->unk4 != 0) {
gUnknown_203B1FC->windows.id[1] = gUnknown_80DB580;
}
else {
gUnknown_203B1FC->windows.id[1] = gUnknown_80DB568;
}
gUnknown_203B1FC->windows.id[0] = gUnknown_80DB550;
ResetUnusedInputStruct();
ShowWindows(&gUnknown_203B1FC->windows, 1, 1);
sub_8015A08(1);
sub_8015C1C();
sub_8015F84();
return 1;
}
u32 sub_80154F0(void)
{
gUnknown_203B1FC->unk16++;
sub_80157D8();
if (gUnknown_203B1FC->unk16 & 8) {
AddSprite((SpriteOAM *) &gUnknown_203B1FC->sprite1Attribs, 0x100, NULL, NULL);
}
gUnknown_203B1FC->unk17++;
sub_80158BC();
if (gUnknown_203B1FC->unk17 & 8) {
AddSprite((SpriteOAM *) &gUnknown_203B1FC->sprite2Attribs, 0x100, NULL, NULL);
}
switch (sub_8012AE8()) {
case 5:
if (gUnknown_203B1FC->unk1C == 0) {
PlayMenuSoundEffect(2);
}
else {
gUnknown_203B1FC->unk1C--;
PlayMenuSoundEffect(3);
}
break;
case 6:
if (gUnknown_203B1FC->unk1C != gUnknown_203B1FC->unk1B - 1 && gUnknown_203B1FC->unk1C < sub_8015F44()) {
gUnknown_203B1FC->unk1C++;
PlayMenuSoundEffect(3);
}
else {
PlayMenuSoundEffect(2);
}
break;
case 1:
return sub_801560C();
case 2:
if (sub_8015748()) {
return 2;
}
break;
case 4:
PlayMenuSoundEffect(3);
gUnknown_203B1FC->unk1A = 5;
break;
}
return 0;
}
void sub_80155F0(void)
{
if (gUnknown_203B1FC != NULL) {
MemoryFree(gUnknown_203B1FC);
gUnknown_203B1FC = NULL;
}
}
u32 sub_801560C(void)
{
s32 var = gUnknown_80DB0F8[gUnknown_203B1FC->unk19][gUnknown_203B1FC->unk1A].unk8;
switch (var) {
case 0x107:
gUnknown_203B1FC->unk18 = (gUnknown_203B1FC->unk18 == 0);
PlayMenuSoundEffect(4);
sub_8015A08(0);
break;
case 0x105:
if (sub_8015748()) {
return 2;
}
break;
case 0x106:
if (sub_8015F44() == 0 || (gUnknown_203B1FC->unk4 != 0 && sub_8015F44() != gUnknown_203B1FC->unk1B)) {
PlayMenuSoundEffect(2);
}
else {
PlayMenuSoundEffect(0);
MemoryCopy8(gUnknown_203B1FC->unk134, gUnknown_203B1FC->unkF8, gUnknown_203B1FC->unk1B);
return 3;
}
break;
default:
if (gUnknown_203B1FC->unk4 != 0 && sub_803D0F0(var) == 0xFF) {
PlayMenuSoundEffect(2);
}
else {
if (gUnknown_203B1FC->unk18 == 1) {
s32 i;
for (i = gUnknown_203B1FC->unk1B - 2; i >= gUnknown_203B1FC->unk1C; i--) {
u8 *ptr = &gUnknown_203B1FC->unkF8[i];
ptr[1] = ptr[0];
}
}
gUnknown_203B1FC->unkF8[gUnknown_203B1FC->unk1C] = var;
if (gUnknown_203B1FC->unk1C < gUnknown_203B1FC->unk1B - 1) {
gUnknown_203B1FC->unk1C++;
}
else {
gUnknown_203B1FC->unk1A = 5;
}
PlayMenuSoundEffect(0);
sub_8015C1C();
sub_8015F84();
}
break;
}
return 0;
}
bool8 sub_8015748(void)
{
u32 val = gUnknown_203B1FC->unkF8[gUnknown_203B1FC->unk1C];
if (val == 0) {
if (gUnknown_203B1FC->unk1C == 0) {
PlayMenuSoundEffect(2);
return TRUE;
}
else {
gUnknown_203B1FC->unk1C--;
gUnknown_203B1FC->unkF8[gUnknown_203B1FC->unk1C] = val;
PlayMenuSoundEffect(1);
sub_8015C1C();
sub_8015F84();
}
}
else {
s32 i, n;
n = sub_8015F44() - 1;
for (i = gUnknown_203B1FC->unk1C; i < n; i++) {
u8 *ptr = &gUnknown_203B1FC->unkF8[i];
ptr[0] = ptr[1];
}
gUnknown_203B1FC->unkF8[n] = 0;
PlayMenuSoundEffect(1);
sub_8015C1C();
sub_8015F84();
}
return FALSE;
}
void sub_80157D8(void)
{
Window *window = &gWindows[1];
// Note: for cases 4 and 5, the code is identical except for different position structs.
if (gUnknown_203B1FC->unk0 == 4) {
s32 x, y;
x = gUnknown_80DAFC0[gUnknown_203B1FC->unk1C].x + (window->x * 8);
SpriteSetX((SpriteOAM *) &gUnknown_203B1FC->sprite1Attribs, x);
y = gUnknown_80DAFC0[gUnknown_203B1FC->unk1C].y + (window->y * 8) + 5;
SpriteSetY((SpriteOAM *) &gUnknown_203B1FC->sprite1Attribs, y);
}
else if (gUnknown_203B1FC->unk0 == 5) {
s32 x, y;
x = gUnknown_80DB098[gUnknown_203B1FC->unk1C].x + (window->x * 8);
SpriteSetX((SpriteOAM *) &gUnknown_203B1FC->sprite1Attribs, x);
y = gUnknown_80DB098[gUnknown_203B1FC->unk1C].y + (window->y * 8) + 5;
SpriteSetY((SpriteOAM *) &gUnknown_203B1FC->sprite1Attribs, y);
}
else {
s32 x, y;
x = gUnknown_203B1FC->unk1E[gUnknown_203B1FC->unk1C] + (gUnknown_203B1FC->unk8A[gUnknown_203B1FC->unk1C] / 2) + 30 + (window->x * 8);
SpriteSetX((SpriteOAM *) &gUnknown_203B1FC->sprite1Attribs, (u16) x);
y = (window->y * 8) + 34;
SpriteSetY((SpriteOAM *) &gUnknown_203B1FC->sprite1Attribs, y);
}
}
void sub_80158BC(void)
{
s32 x, y;
Window *window = &gWindows[0];
u32 var;
switch (sub_8012AE8()) {
case 7:
var = gUnknown_80DB0F8[gUnknown_203B1FC->unk19][gUnknown_203B1FC->unk1A].unk0;
break;
case 8:
var = gUnknown_80DB0F8[gUnknown_203B1FC->unk19][gUnknown_203B1FC->unk1A].unk1;
break;
case 9:
var = gUnknown_80DB0F8[gUnknown_203B1FC->unk19][gUnknown_203B1FC->unk1A].unk2;
break;
case 10:
var = gUnknown_80DB0F8[gUnknown_203B1FC->unk19][gUnknown_203B1FC->unk1A].unk3;
break;
default:
var = gUnknown_203B1FC->unk1A;
break;
}
if (var != gUnknown_203B1FC->unk1A) {
gUnknown_203B1FC->unk1A = var;
PlayMenuSoundEffect(3);
gUnknown_203B1FC->unk17 = 8;
}
x = gUnknown_80DB0F8[gUnknown_203B1FC->unk19][gUnknown_203B1FC->unk1A].x + (window->x * 8) - 5;
y = gUnknown_80DB0F8[gUnknown_203B1FC->unk19][gUnknown_203B1FC->unk1A].y + (window->y * 8) + 1;
SpriteSetX((SpriteOAM *) &gUnknown_203B1FC->sprite2Attribs, x);
SpriteSetY((SpriteOAM *) &gUnknown_203B1FC->sprite2Attribs, y);
}
void sub_8015A08(u32 unused)
{
s32 r4;
s32 i;
u8 text1[16];
u8 text2[16];
CallPrepareTextbox_8008C54(0);
sub_80073B8(0);
for (i = 0; (r4 = gUnknown_80DB0F8[gUnknown_203B1FC->unk19][i].unk8) != 0x109; i++) {
s32 r5;
switch (gUnknown_80DB0F8[gUnknown_203B1FC->unk19][i].unk6) {
case 1:
r5 = 5;
break;
case 2:
r5 = 2;
break;
case 3:
r5 = 7;
break;
default:
r5 = 7;
if (gUnknown_203B1FC->unk4 != 0) {
if (r4 <= 0xFF) {
if (sub_803D0F0(r4) == 0xFF) {
r5 = 2;
}
}
else if (r4 < 0x102) {
r5 = 2;
}
}
break;
}
if (r4 != 0x108) {
if (r4 == 0x107) {
if (gUnknown_203B1FC->unk18 == 0) {
PrintStringOnWindow(gUnknown_80DB0F8[gUnknown_203B1FC->unk19][i].x + 3, gUnknown_80DB0F8[gUnknown_203B1FC->unk19][i].y, _("{COLOR GREEN}OVR{RESET}"), 0, '\0');
}
else {
PrintStringOnWindow(gUnknown_80DB0F8[gUnknown_203B1FC->unk19][i].x + 3, gUnknown_80DB0F8[gUnknown_203B1FC->unk19][i].y, _("{COLOR YELLOW}INS{RESET}"), 0, '\0');
}
}
else if (r4 == 0x20) {
sprintfStatic(text1, _("{COLOR}%c{0x81}{0x59}"), r5);
PrintStringOnWindow(gUnknown_80DB0F8[gUnknown_203B1FC->unk19][i].x + 1, gUnknown_80DB0F8[gUnknown_203B1FC->unk19][i].y, text1, 0, '\0');
}
else if (r4 > 0xFF) {
sprintfStatic(text2, _("{COLOR}%c%s"), r5, gUnknown_80DB4F4[r4 & 0xFF]);
PrintStringOnWindow(gUnknown_80DB0F8[gUnknown_203B1FC->unk19][i].x + 3, gUnknown_80DB0F8[gUnknown_203B1FC->unk19][i].y, text2, 0, '\0');
}
else {
sub_8012C60(gUnknown_80DB0F8[gUnknown_203B1FC->unk19][i].x, gUnknown_80DB0F8[gUnknown_203B1FC->unk19][i].y, (u8) r4, r5, 0);
}
}
}
AddUnderScoreHighlight(0, 0, 0, 0xE0, 0xE);
AddUnderScoreHighlight(0, 0, 0x47, 0xE0, 0xE);
sub_8007A78(0, 0, 0, 0x48, 0xE);
sub_8007A78(0, 0xDF, 0, 0x48, 0xE);
sub_80073E0(0);
}
void sub_8015C1C(void)
{
u8 text[80];
CallPrepareTextbox_8008C54(1);
sub_80073B8(1);
if (gUnknown_203B1FC->unk4 != 0) {
AddUnderScoreHighlight(1, 0, 0, 0xE0, 0xE);
AddUnderScoreHighlight(1, 0, 0x37, 0xE0, 0xE);
sub_8007A78(1, 0, 0, 0x38, 0xE);
sub_8007A78(1, 0xDF, 0, 0x38, 0xE);
}
else {
AddUnderScoreHighlight(1, 0, 0, 0xB0, 0xE);
AddUnderScoreHighlight(1, 0, 0x27, 0xB0, 0xE);
sub_8007A78(1, 0, 0, 0x28, 0xE);
sub_8007A78(1, 0xAF, 0, 0x28, 0xE);
}
switch (gUnknown_203B1FC->unk0) {
case 0:
PrintStringOnWindow(8, 5, _("What is your name?"), 1, '\0');
break;
case 2:
PrintStringOnWindow(8, 5, _("What is this Pokémon's nickname?"), 1, '\0');
break;
case 3:
PrintStringOnWindow(8, 5, _("What is your partner's nickname?"), 1, '\0');
break;
case 1:
PrintStringOnWindow(8, 5, _("What is your team's name?"), 1, '\0');
break;
case 4:
PrintStringOnWindow(54, 2, _("Please enter the password."), 1, '\0');
break;
case 5:
PrintStringOnWindow(48, 4, _("Please enter the password."), 1, '\0');
break;
}
switch (gUnknown_203B1FC->unk0) {
case 4:
sub_8015E10(gUnknown_203B1FC->unkF8, 1, 0);
break;
case 5:
sub_8015EB4(gUnknown_203B1FC->unkF8, 1, 0);
break;
case 0:
case 1:
case 2:
case 3:
AddDoubleUnderScoreHighlight(1, 38, 33, sub_8016028(), 4);
if (sub_8015FEC(gUnknown_203B1FC->unkF8, gUnknown_203B1FC->unk1B) > sub_8016028()) {
sprintfStatic(text, _("{COLOR RED}%s{RESET}"), gUnknown_203B1FC->unkF8);
}
else if (sub_8015F44() == gUnknown_203B1FC->unk1B) {
sprintfStatic(text, _("{COLOR CYAN}%s{RESET}"), gUnknown_203B1FC->unkF8);
}
else {
sprintfStatic(text, _("%s"), gUnknown_203B1FC->unkF8);
}
PrintStringOnWindow(38, 22, text, 1, '\0');
break;
}
sub_80073E0(1);
}
void sub_8015E10(u8 *a0, s32 a1, s32 _a2)
{
s32 i;
s32 a2 = (s16) _a2;
for (i = 0; i < ARRAY_COUNT_INT(gUnknown_80DAFC0); i++) {
AddDoubleUnderScoreHighlight(a1, gUnknown_80DAFC0[i].x, gUnknown_80DAFC0[i].y + 11 + a2, 11, 5);
}
for (i = 0; i < ARRAY_COUNT_INT(gUnknown_80DAFC0) && a0[i] != 0; i++) {
s32 arg3;
if (i <= 4) arg3 = 7;
else if (i <= 12) arg3 = 6;
else if (i <= 17) arg3 = 7;
else if (i <= 22) arg3 = 7;
else if (i <= 30) arg3 = 6;
else if (i <= 35) arg3 = 7;
else if (i <= 40) arg3 = 7;
else if (i <= 48) arg3 = 6;
else arg3 = 7;
sub_8012C60(gUnknown_80DAFC0[i].x, gUnknown_80DAFC0[i].y + a2, a0[i], arg3, a1);
}
}
void sub_8015EB4(u8 *a0, s32 a1, s32 _a2)
{
s32 i;
s32 a2 = (s16) _a2;
for (i = 0; i < ARRAY_COUNT_INT(gUnknown_80DB098); i++) {
AddDoubleUnderScoreHighlight(a1, gUnknown_80DB098[i].x, gUnknown_80DB098[i].y + 11 + a2, 12, 5);
}
for (i = 0; i < ARRAY_COUNT_INT(gUnknown_80DB098) && a0[i] != 0; i++) {
s32 arg3;
if (i <= 3) arg3 = 7;
else if (i <= 7) arg3 = 6;
else if (i <= 15) arg3 = 7;
else if (i <= 19) arg3 = 6;
else arg3 = 7;
sub_8012C60(gUnknown_80DB098[i].x, gUnknown_80DB098[i].y + a2, a0[i], arg3, a1);
}
}

View File

@ -1,6 +1,5 @@
#include "global.h"
#include "globaldata.h"
#include "code_8012A18_1.h"
#include "code_801602C.h"
#include "common_strings.h"
#include "input.h"
@ -8,6 +7,7 @@
#include "string_format.h"
#include "text_util.h"
#include "text_1.h"
#include "naming_screen.h"
EWRAM_INIT static struct unkStruct_203B200 *sUnknown_203B200 = {NULL};
@ -98,7 +98,7 @@ static void sub_8016110(void)
{
switch (sUnknown_203B200->state) {
case CONFIRM_NAME_MENU_INIT:
sub_80151C0(sUnknown_203B200->unk4, sUnknown_203B200->pokeName);
NamingScreen_Init(sUnknown_203B200->unk4, sUnknown_203B200->pokeName);
break;
case CONFIRM_NAME_MENU_PROMPT:
BuildConfirmNameMenu();
@ -135,21 +135,17 @@ static void BuildConfirmNameMenu(void)
static void sub_80161F8(void)
{
s32 length;
s32 maxLength;
if (sub_80154F0() != 3)
if (NamingScreen_HandleInput() != 3)
return;
sub_80155F0();
NamingScreen_Free();
if (IsNameEmpty()) {
SetConfirmNameMenuState(CONFIRM_NAME_MENU_EMPTY);
}
else {
length = sub_8015FEC(sUnknown_203B200->pokeName, POKEMON_NAME_LENGTH);
maxLength = sub_8016028(); // returns 60
if (length > maxLength)
s32 width = GetStrWidth(sUnknown_203B200->pokeName, POKEMON_NAME_LENGTH);
s32 maxWidth = GetMaxPokeNameWidth(); // returns 60
if (width > maxWidth)
SetConfirmNameMenuState(CONFIRM_NAME_MENU_TOO_LONG);
else
SetConfirmNameMenuState(CONFIRM_NAME_MENU_PROMPT);

View File

@ -175,17 +175,17 @@ static void sub_80234BC(void)
iVar4 = GetDexInternalNo(species, 0);
cVar2 = (iVar4 % 10) + 48;
sub_8012C60(20, y, cVar2, color, gUnknown_3001B5C->s35C.s0.winId);
DrawCharOnWindowWidth12(20, y, cVar2, color, gUnknown_3001B5C->s35C.s0.winId);
if (9 < iVar4) {
iVar4 /= 10;
cVar2 = (iVar4 % 10) + 48;
sub_8012C60(13, y, cVar2, color, gUnknown_3001B5C->s35C.s0.winId);
DrawCharOnWindowWidth12(13, y, cVar2, color, gUnknown_3001B5C->s35C.s0.winId);
if (9 < iVar4) {
uVar3 = iVar4 / 10;
cVar2 = (uVar3 % 10) + 48;
sub_8012C60(6, y, cVar2, color, gUnknown_3001B5C->s35C.s0.winId);
DrawCharOnWindowWidth12(6, y, cVar2, color, gUnknown_3001B5C->s35C.s0.winId);
}
}

View File

@ -171,7 +171,7 @@ void DrawSOSPasswordScreen(void)
}
rowIndex = index % 0x12;
x = rowIndex * 0xb + 6;
sub_8012C60(x,y,buffer[index],color,gUnknown_203B334->unk10); // Draw character
DrawCharOnWindowWidth12(x,y,buffer[index],color,gUnknown_203B334->unk10); // Draw character
AddDoubleUnderScoreHighlight(gUnknown_203B334->unk10,x,y + 0xA,10,COLOR_CYAN); // Draw underscore beneath character
}
sub_80073E0(gUnknown_203B334->unk10);

View File

@ -31,6 +31,7 @@
#include "wigglytuff_shop1.h"
#include "wigglytuff_shop3.h"
#include "wonder_mail.h"
#include "naming_screen.h"
IWRAM_INIT struct unkStruct_3001B64 *gUnknown_3001B64 = { NULL };
@ -709,7 +710,7 @@ void MakuhitaDojo_Delete();
u32 HandleMakuhitaDojoState();
s16 sub_802FED0();
u8 sub_801FB50();
void sub_80155F0();
void NamingScreen_Free();
s32 sub_80160D8();
void ResetTextbox_809B294();
s32 sub_801A8AC();
@ -1385,13 +1386,13 @@ bool8 sub_809B648(void)
case 6:
if (gUnknown_3001B64->unk420 == 1) {
ResetTextbox_809B294();
sub_80151C0(4,gUnknown_3001B64->unk42C);
NamingScreen_Init(4,gUnknown_3001B64->unk42C);
}
else {
s32 var = sub_80154F0();
s32 var = NamingScreen_HandleInput();
if (var == 3)
{
sub_80155F0();
NamingScreen_Free();
gUnknown_3001B64->unk430 = 1;
return 0;
}
@ -1400,7 +1401,7 @@ bool8 sub_809B648(void)
if (gUnknown_3001B64->unk424 == 0) {
return 1;
}
sub_80155F0();
NamingScreen_Free();
gUnknown_3001B64->unk430 = 0;
return 0;
}

View File

@ -252,7 +252,7 @@ void xxx_draw_string_80524F0(void)
sp.unk0 += 6;
}
else {
sp.unk0 += xxx_call_draw_char(sp.unk0, sp.unk2, currChr, sp.unk10, 0);
sp.unk0 += DrawCharOnWindow(sp.unk0, sp.unk2, currChr, sp.unk10, 0);
}
}
sub_80073E0(0);

View File

@ -27,6 +27,7 @@
#include "text_util.h"
#include "wonder_mail_4.h"
#include "wonder_mail_5.h"
#include "naming_screen.h"
extern void SetFriendRescueMenuState(u32);
@ -688,7 +689,7 @@ void CleanFriendRescueMenu(void)
sub_803084C();
sub_8031E10();
FriendList_Free();
sub_80155F0();
NamingScreen_Free();
sub_801CBB8();
sub_802F2C0();
sub_8030DE4();
@ -1057,7 +1058,7 @@ void sub_8032828(void)
RestoreSavedWindows(&gUnknown_203B33C->unk3BC);
ResetUnusedInputStruct();
ShowWindows(NULL, TRUE, TRUE);
sub_80151C0(4, gUnknown_203B33C->passwordBuffer);
NamingScreen_Init(4, gUnknown_203B33C->passwordBuffer);
break;
case 0x5A:
CreateMenuDialogueBoxAndPortrait(&gUnknown_80E30A4[0], 0, 6, gUnknown_80E2458, NULL, 4, 0, NULL, 0x101);
@ -1133,7 +1134,7 @@ void sub_8032828(void)
RestoreSavedWindows(&gUnknown_203B33C->unk3BC);
ResetUnusedInputStruct();
ShowWindows(NULL, TRUE, TRUE);
sub_80151C0(4, gUnknown_203B33C->passwordBuffer);
NamingScreen_Init(4, gUnknown_203B33C->passwordBuffer);
break;
case 0x66:
CreateDialogueBoxAndPortrait(gUnknown_80E314C, 0, 0, 0x101);
@ -1659,7 +1660,7 @@ void sub_8033DBC(void)
unkStruct_203B480 mail;
unkStruct_203B480 *mail2;
return_var = sub_80154F0();
return_var = NamingScreen_HandleInput();
MemoryFill8(&mail, 0, sizeof(unkStruct_203B480));
switch(return_var)
{
@ -1717,10 +1718,10 @@ void sub_8033DBC(void)
default:
break;
}
sub_80155F0();
NamingScreen_Free();
break;
case 2:
sub_80155F0();
NamingScreen_Free();
ResetUnusedInputStruct();
ShowWindows(&gUnknown_203B33C->unk3BC, TRUE, TRUE);
SetFriendRescueMenuState(FRIEND_RESCUE_MENU_MAIN);
@ -2555,7 +2556,7 @@ void sub_8034D74(void)
unkStruct_203B480 mail;
unkStruct_203B480 *mail2;
return_var = sub_80154F0();
return_var = NamingScreen_HandleInput();
MemoryFill8(&mail, 0, sizeof(unkStruct_203B480));
switch(return_var)
{
@ -2585,10 +2586,10 @@ void sub_8034D74(void)
default:
break;
}
sub_80155F0();
NamingScreen_Free();
break;
case 2:
sub_80155F0();
NamingScreen_Free();
ResetUnusedInputStruct();
ShowWindows(&gUnknown_203B33C->unk3BC, TRUE, TRUE);
SetFriendRescueMenuState(FRIEND_RESCUE_MENU_MAIN);

View File

@ -71,7 +71,7 @@ static bool8 sub_8013DD0(unkStructFor8013AA0 *);
u32 sub_8012A64(MenuInputStructSub *r0, s32 r1)
{
if (r0 == NULL)
return sub_8012AE8();
return GetMenuInput();
if (r1 != -1)
nullsub_34(r0, r1);
@ -82,7 +82,7 @@ u32 sub_8012A64(MenuInputStructSub *r0, s32 r1)
}
if (r0->b_button == 0)
return sub_8012AE8();
return GetMenuInput();
r0->b_button = 0;
return INPUT_B_BUTTON;
@ -104,10 +104,10 @@ s32 GetKeyPress(MenuInputStruct *r0)
return INPUT_DPAD_RIGHT;
}
return sub_8012AE8();
return GetMenuInput();
}
s32 sub_8012AE8(void)
s32 GetMenuInput(void)
{
if (gRealInputs.held & R_BUTTON) {
if (gRealInputs.pressed & A_BUTTON)
@ -198,8 +198,8 @@ void sub_8012BC4(u32 x, u32 y, s32 n, s32 len, u32 color, u32 windowId)
piVar4++;
chr = ReturnIntFromChar2(iVar1 + 0x30);
iVar3 = GetCharacter(chr);
total_x += iVar3->unk6;
xxx_call_draw_char(x - total_x, y, chr, color, windowId);
total_x += iVar3->width;
DrawCharOnWindow(x - total_x, y, chr, color, windowId);
counter++;
if (counter >= len)
break;
@ -207,21 +207,18 @@ void sub_8012BC4(u32 x, u32 y, s32 n, s32 len, u32 color, u32 windowId)
}
}
void sub_8012C60(u32 x, u32 y, u32 a2, u32 color, u32 a4)
void DrawCharOnWindowWidth12(u32 x, u32 y, u32 chr, u32 color, u32 windowId)
{
u32 add_x;
const unkChar *iVar3;
u32 uVar2;
u32 chrId = ReturnIntFromChar2(chr);
const unkChar *chrInfo = GetCharacter(chrId);
uVar2 = ReturnIntFromChar2(a2);
iVar3 = GetCharacter(uVar2);
if (iVar3->unk6 < 12)
add_x = ((12 - iVar3->unk6) / 2);
if (chrInfo->width < 12)
add_x = ((12 - chrInfo->width) / 2);
else
add_x = 0;
xxx_call_draw_char(x + add_x, y, uVar2, color, a4);
DrawCharOnWindow(x + add_x, y, chrId, color, windowId);
}
void sub_8012CAC(WindowTemplate *a0, const MenuItem *a1)
@ -1054,7 +1051,7 @@ u32 sub_8013BBC(unkStructFor8013AA0 *a0)
if (sub_8013DD0(a0))
return 1;
switch (sub_8012AE8()) {
switch (GetMenuInput()) {
case INPUT_B_BUTTON:
PlayMenuSoundEffect(1);
return 2;
@ -1082,7 +1079,7 @@ void sub_8013C68(unkStructFor8013AA0 *a0)
else
ch = '0' + sp[i];
sub_8012C60(a0->unk1C - ((i + 1) * 12), a0->unk20, ch, 7, a0->unk14);
DrawCharOnWindowWidth12(a0->unk1C - ((i + 1) * 12), a0->unk20, ch, 7, a0->unk14);
}
for (i = 0; i < a0->unk10; i++)
@ -1098,7 +1095,7 @@ void sub_8013D10(unkStructFor8013AA0 *a0)
window = &gWindows[a0->unk14];
uVar4 = a0->unk24;
switch (sub_8012AE8()) {
switch (GetMenuInput()) {
case INPUT_DPAD_LEFT:
uVar4 = a0->unk24 < a0->unk25 - 1 ? a0->unk24 + 1 : 0;
break;
@ -1124,7 +1121,7 @@ static bool8 sub_8013DD0(unkStructFor8013AA0 *a0)
{
s32 iVar2;
switch (sub_8012AE8()) {
switch (GetMenuInput()) {
case INPUT_DPAD_UP:
if (a0->unk0 == a0->unkC) {
PlayMenuSoundEffect(2);

891
src/naming_screen.c Normal file
View File

@ -0,0 +1,891 @@
#include "global.h"
#include "globaldata.h"
#include "naming_screen.h"
#include "code_800D090.h"
#include "code_80118A4.h"
#include "code_803D0D8.h"
#include "input.h"
#include "memory.h"
#include "menu_input.h"
#include "sprite.h"
#include "string_format.h"
#include "text_1.h"
#include "text_2.h"
#include "text_3.h"
#include "text_util.h"
#include "constants/input.h"
#include "constants/colors.h"
#define MAX_TEXT_SIZE 54
enum
{
MODE_OVR,
MODE_INS,
};
struct NamingScreen
{
// size: 0x198
u32 type;
bool8 isPassword;
// Note: These had to be declared like these, because SpriteOAM is aligned by 4 and these aren't. Makes you think if SpriteOAM is actually a struct, and not just an array of 4 u16s.
u16 spriteLetterCursor[4];
u16 spriteInputCursor[4];
u8 letterCursorFrames;
u8 inputCursorFrames;
u8 insOvr;
u8 inputCursorArrId; // Always 0
u8 inputCursorPosition;
u8 maxLetters;
u8 letterCursorPos;
u16 letterTotalWidths[MAX_TEXT_SIZE];
s16 letterWidths[MAX_TEXT_SIZE];
u8 *textPtr; // Points to the field below. A bit over complicated in my opinion...
u8 text[MAX_TEXT_SIZE];
u8 *defaultText;
WindowTemplates windows;
};
static EWRAM_INIT struct NamingScreen *sNamingScreen = NULL;
static s32 GetEnteredNameLength(void);
static void UpdateInputWindow(bool8);
static void UpdateNameWindow(void);
static void UpdateLetterWidths(void);
static void SetLetterCursorSpritePosition(void);
static void HandleInputCursor(void);
static void UpdatePassword1Window(u8 *text, s32 windowId, s32 _yAdd);
static void UpdatePassword2Window(u8 *text, s32 windowId, s32 _yAdd);
static u32 HandleAPress(void);
static bool8 HandleBPress(void);
enum
{
NAMING_SELF,
NAMING_TEAM,
NAMING_POKEMON,
NAMING_PARTNER,
NAMING_PASSWORD1,
NAMING_PASSWORD2,
};
#define NAMING_WINDOW_INPUT 0
#define NAMING_WINDOW_NAME 1
struct LayoutInfo
{
u8 upPos;
u8 downPos;
u8 leftPos;
u8 rightPos;
u8 x;
u8 y;
u8 colorType;
s32 letter;
};
static const DungeonPos sPassword1CursorPositions[] =
{
{3, 0xD},
{0xF, 0xD},
{0x1B, 0xD},
{0x27, 0xD},
{0x33, 0xD},
{0x40, 0xF},
{0x4C, 0xF},
{0x58, 0xF},
{0x64, 0xF},
{0x70, 0xF},
{0x7C, 0xF},
{0x88, 0xF},
{0x94, 0xF},
{0xA1, 0xD},
{0xAD, 0xD},
{0xB9, 0xD},
{0xC5, 0xD},
{0xD1, 0xD},
{3, 0x1A},
{0xF, 0x1A},
{0x1B, 0x1A},
{0x27, 0x1A},
{0x33, 0x1A},
{0x40, 0x1C},
{0x4C, 0x1C},
{0x58, 0x1C},
{0x64, 0x1C},
{0x70, 0x1C},
{0x7C, 0x1C},
{0x88, 0x1C},
{0x94, 0x1C},
{0xA1, 0x1A},
{0xAD, 0x1A},
{0xB9, 0x1A},
{0xC5, 0x1A},
{0xD1, 0x1A},
{3, 0x28},
{0xF, 0x28},
{0x1B, 0x28},
{0x27, 0x28},
{0x33, 0x28},
{0x40, 0x2A},
{0x4C, 0x2A},
{0x58, 0x2A},
{0x64, 0x2A},
{0x70, 0x2A},
{0x7C, 0x2A},
{0x88, 0x2A},
{0x94, 0x2A},
{0xA1, 0x28},
{0xAD, 0x28},
{0xB9, 0x28},
{0xC5, 0x28},
{0xD1, 0x28},
};
static const DungeonPos sPassword2CursorPositions[] =
{
{0x20, 0x12},
{0x2E, 0x12},
{0x3C, 0x12},
{0x4A, 0x12},
{0x58, 0x14},
{0x66, 0x14},
{0x74, 0x14},
{0x82, 0x14},
{0x90, 0x12},
{0x9E, 0x12},
{0xAC, 0x12},
{0xBA, 0x12},
{0x20, 0x24},
{0x2E, 0x24},
{0x3C, 0x24},
{0x4A, 0x24},
{0x58, 0x26},
{0x66, 0x26},
{0x74, 0x26},
{0x82, 0x26},
{0x90, 0x24},
{0x9E, 0x24},
{0xAC, 0x24},
{0xBA, 0x24},
};
#define NAMING_LETTER_DEL 0x105
#define NAMING_LETTER_END 0x106
#define NAMING_LETTER_INS_OVR 0x107
#define NAMING_LETTER_BLANK 0x108
#define NAMING_LETTER_TERMINATOR 0x109
// It was programmed as a 2d array, however it's effectively a 1d array(since there's only one entry for [0][x]). Could be different in Blue?
static const struct LayoutInfo sLayoutInfo[][85] =
{
[0] = {
{0, 0, 0, 0, 8, 3, 0, NAMING_LETTER_BLANK},
{0, 0, 0, 0, 8, 14, 0, NAMING_LETTER_BLANK},
{0, 0, 0, 0, 8, 25, 0, NAMING_LETTER_BLANK},
{5, 4, 81, 9, 8, 36, 3, NAMING_LETTER_INS_OVR},
{3, 5, 82, 10, 8, 47, 3, NAMING_LETTER_DEL},
{4, 3, 83, 11, 8, 58, 3, NAMING_LETTER_END},
{11, 7, 78, 12, 36, 3, 0, 'a'},
{6, 8, 79, 13, 36, 14, 0, 'n'},
{7, 9, 80, 14, 36, 25, 0, 'A'},
{8, 10, 3, 15, 36, 36, 0, 'N'},
{9, 11, 4, 16, 36, 47, 0, 233},
{10, 6, 5, 17, 36, 58, 0, '+'},
{17, 13, 6, 18, 50, 3, 0, 'b'},
{12, 14, 7, 19, 50, 14, 0, 'o'},
{13, 15, 8, 20, 50, 25, 0, 'B'},
{14, 16, 9, 21, 50, 36, 0, 'O'},
{15, 17, 10, 22, 50, 47, 0, '1'},
{16, 12, 11, 23, 50, 58, 0, '-'},
{23, 19, 12, 24, 64, 3, 0, 'c'},
{18, 20, 13, 25, 64, 14, 0, 'p'},
{19, 21, 14, 26, 64, 25, 0, 'C'},
{20, 22, 15, 27, 64, 36, 0, 'P'},
{21, 23, 16, 28, 64, 47, 0, '2'},
{22, 18, 17, 29, 64, 58, 0, ','},
{29, 25, 18, 30, 78, 3, 0, 'd'},
{24, 26, 19, 31, 78, 14, 0, 'q'},
{25, 27, 20, 32, 78, 25, 0, 'D'},
{26, 28, 21, 33, 78, 36, 0, 'Q'},
{27, 29, 22, 34, 78, 47, 0, '3'},
{28, 24, 23, 35, 78, 58, 0, '.'},
{35, 31, 24, 36, 92, 3, 0, 'e'},
{30, 32, 25, 37, 92, 14, 0, 'r'},
{31, 33, 26, 38, 92, 25, 0, 'E'},
{32, 34, 27, 39, 92, 36, 0, 'R'},
{33, 35, 28, 40, 92, 47, 0, '4'},
{34, 30, 29, 41, 92, 58, 0, '!'},
{41, 37, 30, 42, 106, 3, 0, 'f'},
{36, 38, 31, 43, 106, 14, 0, 's'},
{37, 39, 32, 44, 106, 25, 0, 'F'},
{38, 40, 33, 45, 106, 36, 0, 'S'},
{39, 41, 34, 46, 106, 47, 0, '5'},
{40, 36, 35, 47, 106, 58, 0, '?'},
{47, 43, 36, 48, 120, 3, 0, 'g'},
{42, 44, 37, 49, 120, 14, 0, 't'},
{43, 45, 38, 50, 120, 25, 0, 'G'},
{44, 46, 39, 51, 120, 36, 0, 'T'},
{45, 47, 40, 52, 120, 47, 0, '6'},
{46, 42, 41, 53, 120, 58, 0, 145},
{53, 49, 42, 54, 134, 3, 0, 'h'},
{48, 50, 43, 55, 134, 14, 0, 'u'},
{49, 51, 44, 56, 134, 25, 0, 'H'},
{50, 52, 45, 57, 134, 36, 0, 'U'},
{51, 53, 46, 58, 134, 47, 0, '7'},
{52, 48, 47, 59, 134, 58, 0, 146},
{59, 55, 48, 60, 148, 3, 0, 'i'},
{54, 56, 49, 61, 148, 14, 0, 'v'},
{55, 57, 50, 62, 148, 25, 0, 'I'},
{56, 58, 51, 63, 148, 36, 0, 'V'},
{57, 59, 52, 64, 148, 47, 0, '8'},
{58, 54, 53, 65, 148, 58, 0, 147},
{65, 61, 54, 66, 162, 3, 0, 'j'},
{60, 62, 55, 67, 162, 14, 0, 'w'},
{61, 63, 56, 68, 162, 25, 0, 'J'},
{62, 64, 57, 69, 162, 36, 0, 'W'},
{63, 65, 58, 70, 162, 47, 0, '9'},
{64, 60, 59, 71, 162, 58, 0, 148},
{71, 67, 60, 72, 176, 3, 0, 'k'},
{66, 68, 61, 73, 176, 14, 0, 'x'},
{67, 69, 62, 74, 176, 25, 0, 'K'},
{68, 70, 63, 75, 176, 36, 0, 'X'},
{69, 71, 64, 76, 176, 47, 0, '0'},
{70, 66, 65, 77, 176, 58, 0, 189},
{77, 73, 66, 78, 190, 3, 0, 'l'},
{72, 74, 67, 79, 190, 14, 0, 'y'},
{73, 75, 68, 80, 190, 25, 0, 'L'},
{74, 76, 69, 81, 190, 36, 0, 'Y'},
{75, 77, 70, 82, 190, 47, 0, ':'},
{76, 72, 71, 83, 190, 58, 0, 190},
{83, 79, 72, 6, 204, 3, 0, 'm'},
{78, 80, 73, 7, 204, 14, 0, 'z'},
{79, 81, 74, 8, 204, 25, 0, 'M'},
{80, 82, 75, 3, 204, 36, 0, 'Z'},
{81, 83, 76, 4, 204, 47, 0, 133},
{82, 78, 77, 5, 204, 58, 0, ' '},
{0, 0, 0, 0, 8, 3, 2, NAMING_LETTER_TERMINATOR},
}
};
static const u8 *const sSpecialLetters[] =
{
_(""),
_(""),
_("かな"),
_("カナ"),
_(""),
_("DEL"),
_("END"),
};
static const WindowTemplate sWindowTemplateDummy = WIN_TEMPLATE_DUMMY;
static const WindowTemplate sInputWindowTemplate = {
.unk0 = 0,
.type = WINDOW_TYPE_WITHOUT_BORDER,
.pos = {1, 10},
.width = 28,
.height = 9,
.unk10 = 9,
.unk12 = 0,
.header = NULL,
};
static const WindowTemplate sNameWindowTemplate = {
.unk0 = 0,
.type = WINDOW_TYPE_WITHOUT_BORDER,
.pos = {4, 3},
.width = 22,
.height = 5,
.unk10 = 5,
.unk12 = 0,
.header = NULL,
};
static const WindowTemplate sPasswordNameWindowTemplate = {
.unk0 = 0,
.type = WINDOW_TYPE_WITHOUT_BORDER,
.pos = {1, 2},
.width = 28,
.height = 7,
.unk10 = 7,
.unk12 = 0,
.header = NULL,
};
u32 NamingScreen_Init(u32 type, u8 *defaultText)
{
SpriteOAM *sprite;
s32 index;
s32 i;
sNamingScreen = MemoryAlloc(sizeof(*sNamingScreen), 8);
sNamingScreen->type = type;
sNamingScreen->inputCursorArrId = 0;
sNamingScreen->insOvr = MODE_OVR;
sNamingScreen->isPassword = 0;
switch (sNamingScreen->type) {
case NAMING_PASSWORD1:
sNamingScreen->inputCursorPosition = 9;
sNamingScreen->isPassword = TRUE;
sNamingScreen->maxLetters = 0x36;
break;
case NAMING_PASSWORD2:
sNamingScreen->inputCursorPosition = 9;
sNamingScreen->isPassword = TRUE;
sNamingScreen->maxLetters = 0x18;
break;
case NAMING_TEAM:
sNamingScreen->inputCursorPosition = 6;
sNamingScreen->maxLetters = TEAM_NAME_LENGTH;
break;
case NAMING_SELF:
case NAMING_PARTNER:
case NAMING_POKEMON:
default:
sNamingScreen->inputCursorPosition = 6;
sNamingScreen->maxLetters = POKEMON_NAME_LENGTH;
break;
}
sNamingScreen->defaultText = defaultText;
sNamingScreen->textPtr = sNamingScreen->text;
for (i = 0; i < MAX_TEXT_SIZE; i++) {
sNamingScreen->textPtr[i] = '\0';
}
MemoryCopy8(sNamingScreen->textPtr, sNamingScreen->defaultText, sNamingScreen->maxLetters);
for (i = 0; i < sNamingScreen->maxLetters; i++) {
if (sNamingScreen->textPtr[i] == '\0') {
break;
}
}
for (; i < sNamingScreen->maxLetters; i++) {
sNamingScreen->textPtr[i] = '\0';
}
sNamingScreen->letterCursorPos = GetEnteredNameLength();
if (sNamingScreen->letterCursorPos == sNamingScreen->maxLetters) {
sNamingScreen->letterCursorPos--;
}
SpriteSetAffine1((SpriteOAM *) &sNamingScreen->spriteLetterCursor, 0);
SpriteSetAffine2((SpriteOAM *) &sNamingScreen->spriteLetterCursor, 0);
SpriteSetObjMode((SpriteOAM *) &sNamingScreen->spriteLetterCursor, 0);
SpriteSetMosaic((SpriteOAM *) &sNamingScreen->spriteLetterCursor, 0);
SpriteSetBpp((SpriteOAM *) &sNamingScreen->spriteLetterCursor, 0);
SpriteSetPriority((SpriteOAM *) &sNamingScreen->spriteLetterCursor, 0);
SpriteSetPalNum((SpriteOAM *) &sNamingScreen->spriteLetterCursor, 15);
SpriteSetX((SpriteOAM *) &sNamingScreen->spriteLetterCursor, DISPLAY_WIDTH);
SpriteSetY((SpriteOAM *) &sNamingScreen->spriteLetterCursor, DISPLAY_WIDTH);
if (sNamingScreen->isPassword) {
SpriteSetMatrixNum((SpriteOAM *) &sNamingScreen->spriteLetterCursor, 0);
SpriteSetTileNum((SpriteOAM *) &sNamingScreen->spriteLetterCursor, 0x3F6);
SpriteSetSize((SpriteOAM *) &sNamingScreen->spriteLetterCursor, 0);
SpriteSetShape((SpriteOAM *) &sNamingScreen->spriteLetterCursor, 1);
}
else {
SpriteSetMatrixNum((SpriteOAM *) &sNamingScreen->spriteLetterCursor, 16);
SpriteSetTileNum((SpriteOAM *) &sNamingScreen->spriteLetterCursor, 0x3F0);
SpriteSetSize((SpriteOAM *) &sNamingScreen->spriteLetterCursor, 0);
SpriteSetShape((SpriteOAM *) &sNamingScreen->spriteLetterCursor, 1);
}
sNamingScreen->letterCursorFrames = 4;
sprite = (SpriteOAM *) &sNamingScreen->spriteInputCursor;
SpriteSetAffine1(sprite, 0);
SpriteSetAffine2(sprite, 0);
SpriteSetObjMode(sprite, 0);
SpriteSetMosaic(sprite, 0);
SpriteSetBpp(sprite, 0);
SpriteSetShape(sprite, 0);
SpriteSetTileNum(sprite, 0x3F4);
SpriteSetPriority(sprite, 0);
SpriteSetPalNum(sprite, 15);
SpriteSetMatrixNum(sprite, 0);
SpriteSetSize(sprite, 0);
SpriteSetX(sprite, DISPLAY_WIDTH);
SpriteSetY(sprite, DISPLAY_WIDTH);
sNamingScreen->inputCursorFrames = 0;
for (index = 0; index < MAX_WINDOWS; index++) {
sNamingScreen->windows.id[index] = sWindowTemplateDummy;
}
if (sNamingScreen->isPassword) {
sNamingScreen->windows.id[NAMING_WINDOW_NAME] = sPasswordNameWindowTemplate;
}
else {
sNamingScreen->windows.id[NAMING_WINDOW_NAME] = sNameWindowTemplate;
}
sNamingScreen->windows.id[NAMING_WINDOW_INPUT] = sInputWindowTemplate;
ResetUnusedInputStruct();
ShowWindows(&sNamingScreen->windows, 1, 1);
UpdateInputWindow(TRUE);
UpdateNameWindow();
UpdateLetterWidths();
return 1;
}
u32 NamingScreen_HandleInput(void)
{
sNamingScreen->letterCursorFrames++;
SetLetterCursorSpritePosition();
if (sNamingScreen->letterCursorFrames & 8) {
AddSprite((SpriteOAM *) &sNamingScreen->spriteLetterCursor, 0x100, NULL, NULL);
}
sNamingScreen->inputCursorFrames++;
HandleInputCursor();
if (sNamingScreen->inputCursorFrames & 8) {
AddSprite((SpriteOAM *) &sNamingScreen->spriteInputCursor, 0x100, NULL, NULL);
}
switch (GetMenuInput()) {
case INPUT_L_BUTTON:
if (sNamingScreen->letterCursorPos == 0) {
PlayMenuSoundEffect(2);
}
else {
sNamingScreen->letterCursorPos--;
PlayMenuSoundEffect(3);
}
break;
case INPUT_R_BUTTON:
if (sNamingScreen->letterCursorPos != sNamingScreen->maxLetters - 1 && sNamingScreen->letterCursorPos < GetEnteredNameLength()) {
sNamingScreen->letterCursorPos++;
PlayMenuSoundEffect(3);
}
else {
PlayMenuSoundEffect(2);
}
break;
case INPUT_A_BUTTON:
return HandleAPress();
case INPUT_B_BUTTON:
if (HandleBPress()) {
return 2;
}
break;
case INPUT_START_BUTTON:
PlayMenuSoundEffect(3);
sNamingScreen->inputCursorPosition = 5;
break;
}
return 0;
}
void NamingScreen_Free(void)
{
if (sNamingScreen != NULL) {
MemoryFree(sNamingScreen);
sNamingScreen = NULL;
}
}
static u32 HandleAPress(void)
{
s32 letter = sLayoutInfo[sNamingScreen->inputCursorArrId][sNamingScreen->inputCursorPosition].letter;
switch (letter) {
case NAMING_LETTER_INS_OVR:
sNamingScreen->insOvr = (sNamingScreen->insOvr == 0); // Flip
PlayMenuSoundEffect(4);
UpdateInputWindow(FALSE);
break;
case NAMING_LETTER_DEL:
if (HandleBPress()) {
return 2;
}
break;
case NAMING_LETTER_END:
if (GetEnteredNameLength() == 0 || (sNamingScreen->isPassword && GetEnteredNameLength() != sNamingScreen->maxLetters)) {
PlayMenuSoundEffect(2);
}
else {
PlayMenuSoundEffect(0);
MemoryCopy8(sNamingScreen->defaultText, sNamingScreen->textPtr, sNamingScreen->maxLetters);
return 3;
}
break;
default:
if (sNamingScreen->isPassword && sub_803D0F0(letter) == 0xFF) {
PlayMenuSoundEffect(2);
}
else {
if (sNamingScreen->insOvr == MODE_INS) {
s32 i;
for (i = sNamingScreen->maxLetters - 2; i >= sNamingScreen->letterCursorPos; i--) {
u8 *ptr = &sNamingScreen->textPtr[i];
ptr[1] = ptr[0];
}
}
sNamingScreen->textPtr[sNamingScreen->letterCursorPos] = letter;
if (sNamingScreen->letterCursorPos < sNamingScreen->maxLetters - 1) {
sNamingScreen->letterCursorPos++;
}
else {
sNamingScreen->inputCursorPosition = 5;
}
PlayMenuSoundEffect(0);
UpdateNameWindow();
UpdateLetterWidths();
}
break;
}
return 0;
}
static bool8 HandleBPress(void)
{
if (sNamingScreen->textPtr[sNamingScreen->letterCursorPos] == '\0') {
if (sNamingScreen->letterCursorPos == 0) {
PlayMenuSoundEffect(2);
return TRUE;
}
else {
sNamingScreen->letterCursorPos--;
sNamingScreen->textPtr[sNamingScreen->letterCursorPos] = '\0';
PlayMenuSoundEffect(1);
UpdateNameWindow();
UpdateLetterWidths();
}
}
else {
s32 i, n;
n = GetEnteredNameLength() - 1;
for (i = sNamingScreen->letterCursorPos; i < n; i++) {
u8 *ptr = &sNamingScreen->textPtr[i];
ptr[0] = ptr[1];
}
sNamingScreen->textPtr[n] = 0;
PlayMenuSoundEffect(1);
UpdateNameWindow();
UpdateLetterWidths();
}
return FALSE;
}
static void SetLetterCursorSpritePosition(void)
{
Window *window = &gWindows[1];
// Note: for cases NAMING_PASSWORD1 and NAMING_PASSWORD2, the code is identical except for different position structs.
if (sNamingScreen->type == NAMING_PASSWORD1) {
s32 x, y;
x = sPassword1CursorPositions[sNamingScreen->letterCursorPos].x + (window->x * 8);
SpriteSetX((SpriteOAM *) &sNamingScreen->spriteLetterCursor, x);
y = sPassword1CursorPositions[sNamingScreen->letterCursorPos].y + (window->y * 8) + 5;
SpriteSetY((SpriteOAM *) &sNamingScreen->spriteLetterCursor, y);
}
else if (sNamingScreen->type == NAMING_PASSWORD2) {
s32 x, y;
x = sPassword2CursorPositions[sNamingScreen->letterCursorPos].x + (window->x * 8);
SpriteSetX((SpriteOAM *) &sNamingScreen->spriteLetterCursor, x);
y = sPassword2CursorPositions[sNamingScreen->letterCursorPos].y + (window->y * 8) + 5;
SpriteSetY((SpriteOAM *) &sNamingScreen->spriteLetterCursor, y);
}
else {
s32 x, y;
x = sNamingScreen->letterTotalWidths[sNamingScreen->letterCursorPos] + (sNamingScreen->letterWidths[sNamingScreen->letterCursorPos] / 2) + 30 + (window->x * 8);
SpriteSetX((SpriteOAM *) &sNamingScreen->spriteLetterCursor, (u16) x);
y = (window->y * 8) + 34;
SpriteSetY((SpriteOAM *) &sNamingScreen->spriteLetterCursor, y);
}
}
static void HandleInputCursor(void)
{
s32 x, y;
Window *window = &gWindows[0];
u32 newPosition;
switch (GetMenuInput()) {
case INPUT_DPAD_UP:
newPosition = sLayoutInfo[sNamingScreen->inputCursorArrId][sNamingScreen->inputCursorPosition].upPos;
break;
case INPUT_DPAD_DOWN:
newPosition = sLayoutInfo[sNamingScreen->inputCursorArrId][sNamingScreen->inputCursorPosition].downPos;
break;
case INPUT_DPAD_LEFT:
newPosition = sLayoutInfo[sNamingScreen->inputCursorArrId][sNamingScreen->inputCursorPosition].leftPos;
break;
case INPUT_DPAD_RIGHT:
newPosition = sLayoutInfo[sNamingScreen->inputCursorArrId][sNamingScreen->inputCursorPosition].rightPos;
break;
default:
newPosition = sNamingScreen->inputCursorPosition;
break;
}
if (newPosition != sNamingScreen->inputCursorPosition) {
sNamingScreen->inputCursorPosition = newPosition;
PlayMenuSoundEffect(3);
sNamingScreen->inputCursorFrames = 8;
}
x = sLayoutInfo[sNamingScreen->inputCursorArrId][sNamingScreen->inputCursorPosition].x + (window->x * 8) - 5;
y = sLayoutInfo[sNamingScreen->inputCursorArrId][sNamingScreen->inputCursorPosition].y + (window->y * 8) + 1;
SpriteSetX((SpriteOAM *) &sNamingScreen->spriteInputCursor, x);
SpriteSetY((SpriteOAM *) &sNamingScreen->spriteInputCursor, y);
}
static void UpdateInputWindow(bool8 unused)
{
s32 letter;
s32 i;
u8 text1[16];
u8 text2[16];
CallPrepareTextbox_8008C54(0);
sub_80073B8(0);
for (i = 0; (letter = sLayoutInfo[sNamingScreen->inputCursorArrId][i].letter) != NAMING_LETTER_TERMINATOR; i++) {
s32 color;
switch (sLayoutInfo[sNamingScreen->inputCursorArrId][i].colorType) {
case 1:
color = COLOR_CYAN;
break;
case 2:
color = COLOR_RED;
break;
case 3:
color = COLOR_WHITE_2;
break;
default:
color = COLOR_WHITE_2;
if (sNamingScreen->isPassword) {
if (letter <= 0xFF) {
if (sub_803D0F0(letter) == 0xFF) {
color = COLOR_RED;
}
}
else if (letter < 0x102) {
color = COLOR_RED;
}
}
break;
}
if (letter != NAMING_LETTER_BLANK) {
if (letter == NAMING_LETTER_INS_OVR) {
if (sNamingScreen->insOvr == MODE_OVR) {
PrintStringOnWindow(sLayoutInfo[sNamingScreen->inputCursorArrId][i].x + 3, sLayoutInfo[sNamingScreen->inputCursorArrId][i].y, _("{COLOR GREEN}OVR{RESET}"), NAMING_WINDOW_INPUT, '\0');
}
else {
PrintStringOnWindow(sLayoutInfo[sNamingScreen->inputCursorArrId][i].x + 3, sLayoutInfo[sNamingScreen->inputCursorArrId][i].y, _("{COLOR YELLOW}INS{RESET}"), NAMING_WINDOW_INPUT, '\0');
}
}
else if (letter == ' ') {
sprintfStatic(text1, _("{COLOR}%c{0x81}{0x59}"), color);
PrintStringOnWindow(sLayoutInfo[sNamingScreen->inputCursorArrId][i].x + 1, sLayoutInfo[sNamingScreen->inputCursorArrId][i].y, text1, NAMING_WINDOW_INPUT, '\0');
}
else if (letter > 0xFF) {
sprintfStatic(text2, _("{COLOR}%c%s"), color, sSpecialLetters[letter & 0xFF]);
PrintStringOnWindow(sLayoutInfo[sNamingScreen->inputCursorArrId][i].x + 3, sLayoutInfo[sNamingScreen->inputCursorArrId][i].y, text2, NAMING_WINDOW_INPUT, '\0');
}
else {
DrawCharOnWindowWidth12(sLayoutInfo[sNamingScreen->inputCursorArrId][i].x, sLayoutInfo[sNamingScreen->inputCursorArrId][i].y, (u8) letter, color, 0);
}
}
}
AddUnderScoreHighlight(NAMING_WINDOW_INPUT, 0, 0, 0xE0, 0xE);
AddUnderScoreHighlight(NAMING_WINDOW_INPUT, 0, 0x47, 0xE0, 0xE);
sub_8007A78(NAMING_WINDOW_INPUT, 0, 0, 0x48, 0xE);
sub_8007A78(NAMING_WINDOW_INPUT, 0xDF, 0, 0x48, 0xE);
sub_80073E0(NAMING_WINDOW_INPUT);
}
static void UpdateNameWindow(void)
{
u8 text[80];
CallPrepareTextbox_8008C54(1);
sub_80073B8(1);
if (sNamingScreen->isPassword) {
AddUnderScoreHighlight(NAMING_WINDOW_NAME, 0, 0, 0xE0, 0xE);
AddUnderScoreHighlight(NAMING_WINDOW_NAME, 0, 0x37, 0xE0, 0xE);
sub_8007A78(NAMING_WINDOW_NAME, 0, 0, 0x38, 0xE);
sub_8007A78(NAMING_WINDOW_NAME, 0xDF, 0, 0x38, 0xE);
}
else {
AddUnderScoreHighlight(NAMING_WINDOW_NAME, 0, 0, 0xB0, 0xE);
AddUnderScoreHighlight(NAMING_WINDOW_NAME, 0, 0x27, 0xB0, 0xE);
sub_8007A78(NAMING_WINDOW_NAME, 0, 0, 0x28, 0xE);
sub_8007A78(NAMING_WINDOW_NAME, 0xAF, 0, 0x28, 0xE);
}
switch (sNamingScreen->type) {
case NAMING_SELF:
PrintStringOnWindow(8, 5, _("What is your name?"), NAMING_WINDOW_NAME, '\0');
break;
case NAMING_POKEMON:
PrintStringOnWindow(8, 5, _("What is this Pokémon's nickname?"), NAMING_WINDOW_NAME, '\0');
break;
case NAMING_PARTNER:
PrintStringOnWindow(8, 5, _("What is your partner's nickname?"), NAMING_WINDOW_NAME, '\0');
break;
case NAMING_TEAM:
PrintStringOnWindow(8, 5, _("What is your team's name?"), NAMING_WINDOW_NAME, '\0');
break;
case NAMING_PASSWORD1:
PrintStringOnWindow(54, 2, _("Please enter the password."), NAMING_WINDOW_NAME, '\0');
break;
case NAMING_PASSWORD2:
PrintStringOnWindow(48, 4, _("Please enter the password."), NAMING_WINDOW_NAME, '\0');
break;
}
switch (sNamingScreen->type) {
case NAMING_PASSWORD1:
UpdatePassword1Window(sNamingScreen->textPtr, NAMING_WINDOW_NAME, 0);
break;
case NAMING_PASSWORD2:
UpdatePassword2Window(sNamingScreen->textPtr, NAMING_WINDOW_NAME, 0);
break;
case NAMING_SELF:
case NAMING_TEAM:
case NAMING_POKEMON:
case NAMING_PARTNER:
AddDoubleUnderScoreHighlight(NAMING_WINDOW_NAME, 38, 33, GetMaxPokeNameWidth(), 4);
if (GetStrWidth(sNamingScreen->textPtr, sNamingScreen->maxLetters) > GetMaxPokeNameWidth()) {
sprintfStatic(text, _("{COLOR RED}%s{RESET}"), sNamingScreen->textPtr);
}
else if (GetEnteredNameLength() == sNamingScreen->maxLetters) {
sprintfStatic(text, _("{COLOR CYAN}%s{RESET}"), sNamingScreen->textPtr);
}
else {
sprintfStatic(text, _("%s"), sNamingScreen->textPtr);
}
PrintStringOnWindow(38, 22, text, NAMING_WINDOW_NAME, '\0');
break;
}
sub_80073E0(NAMING_WINDOW_NAME);
}
static void UpdatePassword1Window(u8 *text, s32 windowId, s32 _yAdd)
{
s32 i;
s32 yAdd = (s16) _yAdd;
for (i = 0; i < ARRAY_COUNT_INT(sPassword1CursorPositions); i++) {
AddDoubleUnderScoreHighlight(windowId, sPassword1CursorPositions[i].x, sPassword1CursorPositions[i].y + 11 + yAdd, 11, 5);
}
for (i = 0; i < ARRAY_COUNT_INT(sPassword1CursorPositions) && text[i] != '\0'; i++) {
s32 color;
if (i <= 4) color = COLOR_WHITE_2;
else if (i <= 12) color = COLOR_YELLOW;
else if (i <= 17) color = COLOR_WHITE_2;
else if (i <= 22) color = COLOR_WHITE_2;
else if (i <= 30) color = COLOR_YELLOW;
else if (i <= 35) color = COLOR_WHITE_2;
else if (i <= 40) color = COLOR_WHITE_2;
else if (i <= 48) color = COLOR_YELLOW;
else color = 7;
DrawCharOnWindowWidth12(sPassword1CursorPositions[i].x, sPassword1CursorPositions[i].y + yAdd, text[i], color, windowId);
}
}
static void UpdatePassword2Window(u8 *text, s32 windowId, s32 _yAdd)
{
s32 i;
s32 yAdd = (s16) _yAdd;
for (i = 0; i < ARRAY_COUNT_INT(sPassword2CursorPositions); i++) {
AddDoubleUnderScoreHighlight(windowId, sPassword2CursorPositions[i].x, sPassword2CursorPositions[i].y + 11 + yAdd, 12, 5);
}
for (i = 0; i < ARRAY_COUNT_INT(sPassword2CursorPositions) && text[i] != '\0'; i++) {
s32 color;
if (i <= 3) color = COLOR_WHITE_2;
else if (i <= 7) color = COLOR_YELLOW;
else if (i <= 15) color = COLOR_WHITE_2;
else if (i <= 19) color = COLOR_YELLOW;
else color = COLOR_WHITE_2;
DrawCharOnWindowWidth12(sPassword2CursorPositions[i].x, sPassword2CursorPositions[i].y + yAdd, text[i], color, windowId);
}
}
static s32 GetEnteredNameLength(void)
{
s32 len = 0;
s32 i;
for (i = 0; i < sNamingScreen->maxLetters; i++) {
if (sNamingScreen->textPtr[i] != '\0') {
len = i + 1;
}
else {
break;
}
}
return len;
}
static void UpdateLetterWidths(void)
{
u32 chrId;
const unkChar *chrInfo;
s32 i;
s32 total = 0;
for (i = 0; i < sNamingScreen->maxLetters; i++) {
sNamingScreen->letterTotalWidths[i] = total;
if (sNamingScreen->textPtr[i] == '\0') {
sNamingScreen->letterWidths[i] = 8;
return;
}
chrId = ReturnIntFromChar2(sNamingScreen->textPtr[i]);
chrInfo = GetCharacter(chrId);
sNamingScreen->letterWidths[i] = chrInfo->width;
total += chrInfo->width;
}
}
s32 GetStrWidth(u8 *buffer, s32 size)
{
s32 i;
s32 width = 0;
for (i = 0; i < size && buffer[i] != '\0'; i++) {
width += GetCharacter(ReturnIntFromChar2(buffer[i]))->width;
}
return width;
}
s32 GetMaxPokeNameWidth(void)
{
return 60;
}

View File

@ -42,7 +42,7 @@ u32 sub_801E218(void)
flag = FALSE;
switch (sub_8012AE8()) {
switch (GetMenuInput()) {
case INPUT_B_BUTTON:
PlayMenuSoundEffect(1);
return 2;

View File

@ -9,6 +9,7 @@
#include "other_menus2.h"
#include "pokemon.h"
#include "save.h"
#include "menu_input.h"
#include "structs/str_dungeon.h"
typedef struct unkStruct_800D670
@ -41,7 +42,6 @@ extern u8 sub_800D600(void);
extern void sub_800D670(s32 idx, void *dst, s32 size);
extern void sub_800D68C(u32);
void sub_800D414(void);
s32 sub_8012AE8(void);
// Inline needed for 8-bit return cast
static inline bool8 IsNotChunsoft(unkStruct_800D670 *unk)
@ -118,7 +118,7 @@ s32 sub_8037B28(s32 mode)
while (TRUE) {
for (i = 0; i < 1; i++) {
sub_80373C4();
switch (sub_8012AE8()) {
switch (GetMenuInput()) {
case 2:
case 3:
sub_800D520();

View File

@ -2,7 +2,6 @@
#include "globaldata.h"
#include "constants/colors.h"
#include "code_800D090.h"
#include "code_8012A18_1.h"
#include "code_803C1D0.h"
#include "code_803D0D8.h"
#include "dungeon.h"
@ -17,6 +16,7 @@
#include "string_format.h"
#include "text_3.h"
#include "text_util.h"
#include "naming_screen.h"
#include "data/pokemon_mail.h"
@ -101,10 +101,10 @@ void CreateRescueTitle(unkStruct_802C39C *param_1)
if (param_1->mailTitleType == 7) {
if (param_1->playerName == NULL)
PrintStringOnWindow(178 - sub_8016028(), param_1->y, GetMonSpecies(param_1->clientSpecies), param_1->unk0[0], 0);
PrintStringOnWindow(178 - GetMaxPokeNameWidth(), param_1->y, GetMonSpecies(param_1->clientSpecies), param_1->unk0[0], 0);
else {
sub_80922B4(buf_2, param_1->playerName, POKEMON_NAME_LENGTH);
PrintStringOnWindow(178 - sub_8016028(), param_1->y, buf_2, param_1->unk0[0], 0);
PrintStringOnWindow(178 - GetMaxPokeNameWidth(), param_1->y, buf_2, param_1->unk0[0], 0);
}
}
else {
@ -379,7 +379,7 @@ void CreateRescueDescription(unkStruct_802C39C *param_1)
}
x = counter % 12;
sub_8012C60((x * 10) + 84, y, local_34[counter], color, param_1->unk0[0]);
DrawCharOnWindowWidth12((x * 10) + 84, y, local_34[counter], color, param_1->unk0[0]);
}
}
}

View File

@ -15,6 +15,7 @@
#include "sprite.h"
#include "string_format.h"
#include "text_1.h"
#include "naming_screen.h"
#define RESCUE_PASSWORD_SIZE 0x36
@ -292,7 +293,7 @@ void CreateRescuePasswordMenu(u32 currMenu)
case 0x1C:
case 0x1E:
case 0x20:
sub_80151C0(4, gRescuePasswordBuffer);
NamingScreen_Init(4, gRescuePasswordBuffer);
break;
case MENU_DISPLAY_RESCUE_PASSWORD:
temp = GetMailatIndex(0x1F);
@ -302,7 +303,7 @@ void CreateRescuePasswordMenu(u32 currMenu)
sub_8031D70(0x1F, 0);
break;
case MENU_RESCUE_PASSWORD_ENTRY:
sub_80151C0(4, gRescuePasswordBuffer);
NamingScreen_Init(4, gRescuePasswordBuffer);
break;
}
@ -316,7 +317,7 @@ void CleanRescuePasswordMenu(void)
ResetUnusedInputStruct();
ShowWindows(NULL, TRUE, TRUE);
if (gRescuePasswordMenu != NULL) {
sub_80155F0();
NamingScreen_Free();
sub_8031E10();
MemoryFree(gRescuePasswordMenu);
gRescuePasswordMenu = NULL;
@ -358,7 +359,7 @@ s32 UpdateRescuePasswordMenu(void)
case 1:
case 3:
case 5:
iVar7 = sub_80154F0();
iVar7 = NamingScreen_HandleInput();
MemoryFill8(&mail, 0, sizeof(unkStruct_203B480));
switch(iVar7)
{
@ -460,7 +461,7 @@ s32 UpdateRescuePasswordMenu(void)
nextMenu = UpdateRescuePasswordMenu_sub(MENU_WONDER_MAIL);
break;
case 7:
switch(sub_80154F0())
switch(NamingScreen_HandleInput())
{
case 3:
nextMenu = PASSWORD_ENTRY_NOT_WONDER_MAIL;
@ -496,7 +497,7 @@ s32 UpdateRescuePasswordMenu(void)
sub_8039174();
ResetUnusedInputStruct();
ShowWindows(NULL, TRUE, TRUE);
sub_80151C0(4,gRescuePasswordBuffer);
NamingScreen_Init(4,gRescuePasswordBuffer);
gRescuePasswordMenu->state = 8;
subtract = gRescuePasswordMenu->currMenu - 0x21;
nextMenu = MENU_FRIEND_RESCUE;
@ -524,7 +525,7 @@ s32 UpdateRescuePasswordMenu(void)
sub_8039174();
ResetUnusedInputStruct();
ShowWindows(NULL, TRUE, TRUE);
sub_80151C0(4,gRescuePasswordBuffer);
NamingScreen_Init(4,gRescuePasswordBuffer);
gRescuePasswordMenu->state = ConvertMenutoRescuePasswordState(gRescuePasswordMenu->currMenu);
subtract = gRescuePasswordMenu->currMenu - 0x21;
nextMenu = 0x2a;
@ -547,7 +548,7 @@ void DisplayRescuePasswordError(u32 passwordError)
RestoreSavedWindows(&gRescuePasswordMenu->unk1A8);
ResetUnusedInputStruct();
ShowWindows(NULL, TRUE, TRUE);
sub_80155F0();
NamingScreen_Free();
switch(passwordError) {
case PASSWORD_ENTRY_INCORRECT_PASSWORD:
SetMenuItems(gRescuePasswordMenu->unk8,&gRescuePasswordMenu->unk148,0,&gUnknown_80E71FC,gUnknown_80E7214,FALSE,13,FALSE);
@ -587,7 +588,7 @@ void DisplayPasswordAcceptScreen(void)
RestoreSavedWindows(&gRescuePasswordMenu->unk1A8);
ResetUnusedInputStruct();
ShowWindows(NULL, TRUE, TRUE);
sub_80155F0();
NamingScreen_Free();
SetMenuItems(gRescuePasswordMenu->unk8,&gRescuePasswordMenu->unk148,0,&gUnknown_80E7278,gUnknown_80E7290,FALSE,13,FALSE);
sub_8035CF4(gRescuePasswordMenu->unk8,0,TRUE);
}

View File

@ -46,7 +46,7 @@ void sub_8014114(void) {
void nullsub_201(void) {}
u32 sub_8014128(void) {
if(sub_8012AE8() == INPUT_B_BUTTON) return 0;
if(GetMenuInput() == INPUT_B_BUTTON) return 0;
else return 1;
}
@ -368,7 +368,7 @@ void DrawDialogueBoxString(void)
u32 chr;
str = xxx_get_next_char_from_string(str, &chr);
gUnknown_202E748.unk0 += xxx_call_draw_char(gUnknown_202E748.unk0, gUnknown_202E748.unk2, chr, gUnknown_202E748.unk10, 0);
gUnknown_202E748.unk0 += DrawCharOnWindow(gUnknown_202E748.unk0, gUnknown_202E748.unk2, chr, gUnknown_202E748.unk10, 0);
gUnknown_202E748.unk2C = gUnknown_202E78C;
}

View File

@ -95,7 +95,7 @@ const unkChar gUnknown_80B86A4 =
{
.unk0 = sUnknown_80B865C,
.unk4 = 0x81A1,
.unk6 = 7,
.width = 7,
.unk8 = 10,
.fill9 = 0,
.unkA = 0,

View File

@ -24,9 +24,9 @@ static bool8 xxx_update_bg_vram(Window *windows);
// TODO: Find these funcs in blue. DTCM funcs
// In NDS, this func is copied to 01FF9F34
u32 xxx_call_draw_char(s32 x, s32 y, u32 chr, u32 color, u32 windowId)
u32 DrawCharOnWindow(s32 x, s32 y, u32 chr, u32 color, u32 windowId)
{
return xxx_draw_char(gWindows, x, y, chr, color, windowId);
return DrawCharOnWindowInternal(gWindows, x, y, chr, color, windowId);
}
UNUSED static bool8 sub_8007464(void)
@ -35,7 +35,7 @@ UNUSED static bool8 sub_8007464(void)
}
// In NDS, this func is copied to 01FF994C
u32 xxx_draw_char(Window *windows, s32 x, s32 y, u32 chr, u32 color, u32 windowId)
u32 DrawCharOnWindowInternal(Window *windows, s32 x, s32 y, u32 chr, u32 color, u32 windowId)
{
u32 *r3;
const unkShiftData *shiftData;
@ -223,7 +223,7 @@ u32 xxx_draw_char(Window *windows, s32 x, s32 y, u32 chr, u32 color, u32 windowI
}
}
return sp0->unk6 + gCharacterSpacing;
return sp0->width + gCharacterSpacing;
}
// Copied to 01ff98f8 in NDS

View File

@ -6,7 +6,7 @@
static const u8 *HandleTextFormat(Window *windows, const u8 *str, UnkDrawStringStruct *sp);
static s32 InterpretColorChar(u8 a0);
static const u8 *sub_800915C(s16 *a0, const u8 *str);
static void xxx_draw_string(Window *strArr, s32 x, s32 y, const u8 *str, u32 windowId, u32 terminatingChr, s32 characterSpacing, s32 lineSpacing);
static void DrawStringInternal(Window *windows, s32 x, s32 y, const u8 *str, u32 windowId, u32 terminatingChr, s32 characterSpacing, s32 lineSpacing);
// arm9.bin::02003D4C
bool8 sub_8008D8C(s32 windowId)
@ -129,7 +129,7 @@ s32 sub_8008ED0(const u8 *str)
else {
const unkChar *ptr = GetCharacter(chr);
if (ptr != NULL) {
ret += ptr->unk6 + gCharacterSpacing;
ret += ptr->width + gCharacterSpacing;
}
}
}
@ -140,13 +140,13 @@ s32 sub_8008ED0(const u8 *str)
// arm9.bin::02003AE8
void PrintStringOnWindow2(s32 x, s32 y, const u8 *str, u32 windowId, u32 terminatingChr, s32 lineSpacing)
{
xxx_draw_string(gWindows, x, y, str, windowId, terminatingChr, 0, lineSpacing);
DrawStringInternal(gWindows, x, y, str, windowId, terminatingChr, 0, lineSpacing);
}
// arm9.bin::02003A9C
void PrintStringOnWindow(s32 x, s32 y, const u8 *str, u32 windowId, u32 terminatingChr)
{
xxx_draw_string(gWindows, x, y, str, windowId, terminatingChr, 0, 13);
DrawStringInternal(gWindows, x, y, str, windowId, terminatingChr, 0, 13);
}
// arm9.bin::02003A50
@ -159,7 +159,7 @@ UNUSED static void nullsub_170(s32 x, s32 y, const u8 *str, u32 windowId, u32 te
// Identical to PrintStringOnWindow
UNUSED static void UnusedPrintStringOnWindow(s32 x, u32 y, const u8 *str, u32 windowId, u32 terminatingChr)
{
xxx_draw_string(gWindows, x, y, str, windowId, terminatingChr, 0, 13);
DrawStringInternal(gWindows, x, y, str, windowId, terminatingChr, 0, 13);
}
UNUSED static void nullsub_171(void)
@ -168,7 +168,7 @@ UNUSED static void nullsub_171(void)
#endif
// arm9.bin::020038A4
static void xxx_draw_string(Window *strArr, s32 x, s32 y, const u8 *str, u32 windowId, u32 terminatingChr, s32 characterSpacing, s32 lineSpacing)
static void DrawStringInternal(Window *windows, s32 x, s32 y, const u8 *str, u32 windowId, u32 terminatingChr, s32 characterSpacing, s32 lineSpacing)
{
UnkDrawStringStruct sp;
u32 currChr;
@ -178,7 +178,7 @@ static void xxx_draw_string(Window *strArr, s32 x, s32 y, const u8 *str, u32 win
sp.unkC = x;
sp.unk10 = 7;
while (TRUE) {
str = HandleTextFormat(strArr, str, &sp);
str = HandleTextFormat(windows, str, &sp);
str = xxx_get_next_char_from_string(str, &currChr);
if (currChr == '\0' || currChr == terminatingChr)
break;
@ -204,15 +204,15 @@ static void xxx_draw_string(Window *strArr, s32 x, s32 y, const u8 *str, u32 win
sp.unk0 += 6;
}
else if (characterSpacing == 0) {
sp.unk0 += xxx_draw_char(strArr, sp.unk0, sp.unk2, currChr, sp.unk10, windowId);
sp.unk0 += DrawCharOnWindowInternal(windows, sp.unk0, sp.unk2, currChr, sp.unk10, windowId);
}
else {
const unkChar *chrPtr = GetCharacter(currChr);
if (chrPtr != NULL) {
s32 x = sp.unk0;
s32 x2 = gCharacterSpacing + 10;
x +=((x2 - chrPtr->unk6) / 2);
xxx_draw_char(strArr, x, sp.unk2, currChr, sp.unk10, windowId);
x +=((x2 - chrPtr->width) / 2);
DrawCharOnWindowInternal(windows, x, sp.unk2, currChr, sp.unk10, windowId);
sp.unk0 += characterSpacing;
}
}

View File

@ -24,6 +24,7 @@
#include "thank_you_wonder_mail.h"
#include "wonder_mail_4.h"
#include "wonder_mail_5.h"
#include "naming_screen.h"
static EWRAM_INIT WonderMailStruct_203B2C4 *sUnknown_203B2C4 = {NULL};
@ -414,7 +415,7 @@ void CleanThankYouMailPelipper(void)
FreeItemDescriptionWindow();
sub_803084C();
sub_801CBB8();
sub_80155F0();
NamingScreen_Free();
sub_8031E10();
sub_802F2C0();
}
@ -790,7 +791,7 @@ void HandleThankYouMailPasswordMenu(void)
u32 return_var;
unkStruct_203B480 mail1;
return_var = sub_80154F0();
return_var = NamingScreen_HandleInput();
MemoryFill8(&mail1, 0, sizeof(unkStruct_203B480));
switch(return_var)
{
@ -821,10 +822,10 @@ void HandleThankYouMailPasswordMenu(void)
case 7:
break;
}
sub_80155F0();
NamingScreen_Free();
break;
case 2:
sub_80155F0();
NamingScreen_Free();
ResetUnusedInputStruct();
ShowWindows(&sUnknown_203B2C4->unk3BC, TRUE, TRUE);
SetThankYouMailMenuState(ANYTHING_ELSE_THANK_YOU_MAIN_MENU);
@ -1333,7 +1334,7 @@ void UpdateThankYouMailText(void)
RestoreSavedWindows(&sUnknown_203B2C4->unk3BC);
ResetUnusedInputStruct();
ShowWindows(NULL, TRUE, TRUE);
sub_80151C0(4,sUnknown_203B2C4->passwordBuffer);
NamingScreen_Init(4,sUnknown_203B2C4->passwordBuffer);
break;
case 0x1a:
RestoreSavedWindows(&sUnknown_203B2C4->unk3BC);

View File

@ -22,6 +22,7 @@
#include "wonder_mail.h"
#include "wonder_mail_4.h"
#include "wonder_mail_5.h"
#include "naming_screen.h"
static EWRAM_INIT WonderMailStruct_203B2C0 *sUnknown_203B2C0 = {NULL};
@ -403,7 +404,7 @@ void sub_80282FC(void)
sub_8031E10();
FriendList_Free();
sub_803084C();
sub_80155F0();
NamingScreen_Free();
sub_80310B4();
sub_8030DE4();
sub_802453C();
@ -575,7 +576,7 @@ void sub_8028348(void)
RestoreSavedWindows(&sUnknown_203B2C0->unk3BC);
ResetUnusedInputStruct();
ShowWindows(NULL, TRUE, TRUE);
sub_80151C0(4, sUnknown_203B2C0->passwordBuffer);
NamingScreen_Init(4, sUnknown_203B2C0->passwordBuffer);
break;
case 8:
switch(sUnknown_203B2C0->unk538)
@ -1356,7 +1357,7 @@ void sub_80293F4(void)
u32 return_var;
unkStruct_203B480 mail;
return_var = sub_80154F0();
return_var = NamingScreen_HandleInput();
MemoryFill8(&mail, 0, sizeof(unkStruct_203B480));
switch(return_var)
{
@ -1387,10 +1388,10 @@ void sub_80293F4(void)
default:
break;
}
sub_80155F0();
NamingScreen_Free();
break;
case 2:
sub_80155F0();
NamingScreen_Free();
ResetUnusedInputStruct();
ShowWindows(&sUnknown_203B2C0->unk3BC, TRUE, TRUE);
SetFriendRescueCounterState(FRIEND_RESCUE_MAIN);

View File

@ -20,6 +20,7 @@
#include "wonder_mail_5.h"
#include "wonder_mail_802D098.h"
#include "wonder_mail_main_menu.h"
#include "naming_screen.h"
#define SELECT_WONDER_MAIL_MODE_MAIN_SCREEN 0
#define SEND_WONDER_MAIL_MAIN_SCREEN 1
@ -171,7 +172,7 @@ void CleanWonderMailMenu(void)
FreeItemDescriptionWindow(); // Frees 203B230
sub_803084C(); // Frees 203B320
sub_801CBB8(); // Frees 203B244
sub_80155F0(); // Frees 203B1FC
NamingScreen_Free(); // Frees 203B1FC
sub_8031E10(); // Frees 203B334
}
}
@ -325,11 +326,11 @@ void HandlePasswordEntryScreen(void)
{
s32 iVar2;
iVar2 = sub_80154F0();
iVar2 = NamingScreen_HandleInput();
MemoryFill8(gUnknown_203B3E8->UNK38.unk38_u8, 0, sizeof(gUnknown_203B3E8->UNK38));
switch(iVar2){
case 3:
sub_80155F0();
NamingScreen_Free();
ResetUnusedInputStruct();
ShowWindows(&gUnknown_203B3E8->unk1EC, TRUE, TRUE);
if ( !DecodeWonderMailPassword(gUnknown_203B3E8->PasswordEntryBuffer, &gUnknown_203B3E8->UNK38.decodedMail) || !IsValidWonderMail(&gUnknown_203B3E8->UNK38.decodedMail) )
@ -347,7 +348,7 @@ void HandlePasswordEntryScreen(void)
}
break;
case 2:
sub_80155F0();
NamingScreen_Free();
ResetUnusedInputStruct();
ShowWindows(&gUnknown_203B3E8->unk1EC, TRUE, TRUE);
SetWonderMailMainMenuState(EXIT_TO_MAIN_MENU);
@ -561,7 +562,7 @@ void WonderMailMainMenuCallback(void)
RestoreSavedWindows(&gUnknown_203B3E8->unk1EC);
ResetUnusedInputStruct();
ShowWindows(NULL, TRUE, TRUE);
sub_80151C0(5,gUnknown_203B3E8->PasswordEntryBuffer);
NamingScreen_Init(5,gUnknown_203B3E8->PasswordEntryBuffer);
break;
case PASSWORD_INVALID:
CreateMenuDialogueBoxAndPortrait(gUnknown_80E7CC4,0,6,gUnknown_80E78F8,0,4,0,0,0x101);

View File

@ -25,7 +25,7 @@
.include "src/quick_save_write.o"
.include "src/string_format.o"
.include "src/code_8015080.o"
.include "src/code_8012A18_1.o"
.include "src/naming_screen.o"
.include "src/code_801602C.o"
.include "src/felicity_bank.o"
.include "src/kangaskhan_storage1.o"