Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Label input processing and other small stuff #131

Merged
merged 5 commits into from
Jan 28, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 21 additions & 14 deletions include/core_sys.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
#include "struct_decls/struct_0201CD88_decl.h"
#include "overlay023/funcptr_ov23_022537D4.h"

typedef enum ButtonMode {
BUTTON_MODE_NORMAL = 0,
BUTTON_MODE_START_IS_X = 1,
BUTTON_MODE_SWAP_XY = 2,
BUTTON_MODE_L_IS_A = 3,
} ButtonMode;
meithecatte marked this conversation as resolved.
Show resolved Hide resolved

typedef struct CoreSys {
UnkFuncPtr_02017798 unk_00;
void * unk_04;
Expand All @@ -19,20 +26,20 @@ typedef struct CoreSys {
u32 * unk_28;
u32 unk_2C;
u32 unk_30;
int unk_34;
int unk_38;
int unk_3C;
int unk_40;
int unk_44;
int padInput;
int unk_4C;
int unk_50;
int unk_54;
int unk_58;
u16 unk_5C;
u16 unk_5E;
u16 touchInput;
u16 unk_62;
ButtonMode buttonMode;
meithecatte marked this conversation as resolved.
Show resolved Hide resolved
u32 heldKeysRaw;
u32 pressedKeysRaw;
u32 pressedKeysRepeatableRaw;
u32 heldKeys;
u32 pressedKeys;
u32 pressedKeysRepeatable;
int autorepeatTimer;
int autorepeatRate;
int autorepeatDelay;
u16 touchX;
u16 touchY;
u16 touchPressed;
u16 touchHeld;
u8 unk_64;
u8 unk_65;
u8 unk_66;
Expand Down
2 changes: 1 addition & 1 deletion include/party.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "struct_decls/struct_021C0794_decl.h"

int Party_SaveSize(void);
Party * sub_02079FF4(u32 param0);
Party * Party_New(u32 param0);
void Party_Init(Party * param0);
void Party_InitWithCapacity(Party * party, int capacity);
BOOL Party_AddPokemon(Party * party, Pokemon * pokemon);
Expand Down
10 changes: 5 additions & 5 deletions include/unk_02017728.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ void sub_020177A4(void);
BOOL sub_020177BC(UnkFuncPtr_02017798 param0, void * param1);
void sub_0201789C(void);
void sub_020179E4(void);
void * sub_02017A40(int param0, const char * param1);
void sub_02017A94(const char * param0, void ** param1);
void * ReadFileToHeap(int heapID, const char * filename);
void ReadFileToBuffer(const char * filename, void ** buf);
void sub_02017ACC(void);
void sub_02017AF4(void);
void InitKeypadAndTouchpad(void);
void sub_02017B70(int param0);
void sub_02017B7C(u8 param0);
void sub_02017B8C(u8 param0);
void sub_02017B9C(void);
void sub_02017DD4(int param0, int param1);
void ReadKeypadAndTouchpad(void);
void SetAutorepeat(int rate, int delay);
void sub_02017DE0(u8 param0);
void sub_02017DF0(u8 param0);
void sub_02017E00(int param0);
Expand Down
2 changes: 1 addition & 1 deletion replace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ if [ "$1" = "" -o "$2" = "" ]; then
exit 0
fi

sed -i 's/\<'"$1"'\>/'"$2"'/' $(git grep -Ilwr "$1")
sed -i 's/\<'"$1"'\>/'"$2"'/g' $(git grep -Ilwr "$1")
2 changes: 1 addition & 1 deletion src/error_message_reset.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ void ErrorMessageReset_PrintErrorAndReset (void)
GX_SetVisiblePlane(0);
GXS_SetVisiblePlane(0);

sub_02017DD4(4, 8);
SetAutorepeat(4, 8);
gCoreSys.unk_65 = 0;
GXLayers_SwapDisplay();

Expand Down
10 changes: 5 additions & 5 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void NitroMain (void)
{
sub_0201789C();
sub_020179E4();
sub_02017AF4();
InitKeypadAndTouchpad();

sub_02017B70(0);
PM_GetBackLight(&Unk_02101D20, NULL);
Expand Down Expand Up @@ -120,9 +120,9 @@ void NitroMain (void)
while (TRUE) {
sub_02000F30();
sub_0200106C();
sub_02017B9C();
ReadKeypadAndTouchpad();

if ((gCoreSys.unk_38 & (PAD_BUTTON_START | PAD_BUTTON_SELECT | PAD_BUTTON_L | PAD_BUTTON_R)) == (PAD_BUTTON_START | PAD_BUTTON_SELECT | PAD_BUTTON_L | PAD_BUTTON_R)) {
if ((gCoreSys.heldKeysRaw & (PAD_BUTTON_START | PAD_BUTTON_SELECT | PAD_BUTTON_L | PAD_BUTTON_R)) == (PAD_BUTTON_START | PAD_BUTTON_SELECT | PAD_BUTTON_L | PAD_BUTTON_R)) {
meithecatte marked this conversation as resolved.
Show resolved Hide resolved
if (gCoreSys.unk_68 == 0) {
sub_02000F60(0);
}
Expand Down Expand Up @@ -295,10 +295,10 @@ static void sub_02000F94 (int param0, int param1)

while (TRUE) {
sub_0200106C();
sub_02017B9C();
ReadKeypadAndTouchpad();

if (v0 >= 30) {
if (gCoreSys.padInput & PAD_BUTTON_A) {
if (gCoreSys.pressedKeys & PAD_BUTTON_A) {
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/overlay005/ov5_021D0D80.c
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ static void ov5_021D134C (UnkStruct_0203CDB0 * param0, u8 param1)
ov5_021D15F4(param0);
}

if (gCoreSys.padInput & PAD_BUTTON_X) {
if (gCoreSys.pressedKeys & PAD_BUTTON_X) {
(void)0;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/overlay005/ov5_021D2F14.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void ov5_021D2F14 (UnkStruct_ov5_021D30A8 * param0, const UnkStruct_ov7_0224F2EC

for (v4 = 0; v4 < param0->unk_1C4; v4++) {
v0 = sub_02009F38(v1, v4);
v2 = sub_02017A40(param3, param1->val1[v4]);
v2 = ReadFileToHeap(param3, param1->val1[v4]);

sub_02009F40(v2, v0, param3);
Heap_FreeToHeap(v2);
Expand Down Expand Up @@ -78,7 +78,7 @@ void ov5_021D2F14 (UnkStruct_ov5_021D30A8 * param0, const UnkStruct_ov7_0224F2EC
sub_0200A41C(param0->unk_1AC[0]);
sub_0200A684(param0->unk_1AC[1]);

v2 = sub_02017A40(param3, param1->val2.unk_18);
v2 = ReadFileToHeap(param3, param1->val2.unk_18);
param0->unk_190 = sub_02009508(v2, param3, param0->unk_194[0], param0->unk_194[1], param0->unk_194[2], param0->unk_194[3], param0->unk_194[4], param0->unk_194[5]);

Heap_FreeToHeap(v2);
Expand Down
2 changes: 1 addition & 1 deletion src/overlay005/ov5_021DC018.c
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ static void ov5_021DC95C (SysTask * param0, void * param1)
Sound_PlayEffect(1500);
}

if ((gCoreSys.unk_4C & PAD_KEY_UP) || (gCoreSys.unk_4C & PAD_KEY_DOWN) || (gCoreSys.unk_4C & PAD_KEY_LEFT) || (gCoreSys.unk_4C & PAD_KEY_RIGHT)) {
if ((gCoreSys.pressedKeysRepeatable & PAD_KEY_UP) || (gCoreSys.pressedKeysRepeatable & PAD_KEY_DOWN) || (gCoreSys.pressedKeysRepeatable & PAD_KEY_LEFT) || (gCoreSys.pressedKeysRepeatable & PAD_KEY_RIGHT)) {
ov5_021DCAF4(v2);
}

Expand Down
2 changes: 1 addition & 1 deletion src/overlay005/ov5_021DFB54.c
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ static BOOL ov5_021E0560 (UnkStruct_020508D4 * param0)
case 2:
{
int v2 = sub_0205EA78(v0->unk_0C);
u32 v3, v4 = gCoreSys.padInput, v5 = gCoreSys.unk_44;
u32 v3, v4 = gCoreSys.pressedKeys, v5 = gCoreSys.heldKeys;
int v6 = sub_02061308(v0->unk_0C, v4, v5);

if ((v6 == -1) || (v6 == v2)) {
Expand Down
4 changes: 2 additions & 2 deletions src/overlay005/ov5_021F08CC.c
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ static void * ov5_021F0D1C (u32 param0)

static int ov5_021F0D40 (void)
{
if ((gCoreSys.padInput & PAD_BUTTON_A)) {
if ((gCoreSys.pressedKeys & PAD_BUTTON_A)) {
return 1;
}

Expand All @@ -498,7 +498,7 @@ static int ov5_021F0D40 (void)

static int ov5_021F0D54 (void)
{
if ((gCoreSys.padInput & (PAD_BUTTON_A | PAD_BUTTON_B))) {
if ((gCoreSys.pressedKeys & (PAD_BUTTON_A | PAD_BUTTON_B))) {
return 1;
}

Expand Down
8 changes: 4 additions & 4 deletions src/overlay006/ov6_0223E140.c
Original file line number Diff line number Diff line change
Expand Up @@ -2194,25 +2194,25 @@ static BOOL ov6_02240364 (UnkStruct_ov6_022401B8 * param0, int param1, int param
BOOL v1[2] = {0, 0};
UnkStruct_ov6_02240260 * v2 = &param0->unk_34;

if (gCoreSys.padInput & PAD_KEY_UP) {
if (gCoreSys.pressedKeys & PAD_KEY_UP) {
v2->unk_00++;
v2->unk_00 %= 32;
}

if (gCoreSys.padInput & PAD_KEY_DOWN) {
if (gCoreSys.pressedKeys & PAD_KEY_DOWN) {
if (v2->unk_00) {
v2->unk_00--;
} else {
v2->unk_00 = 31;
}
}

if (gCoreSys.padInput & PAD_KEY_RIGHT) {
if (gCoreSys.pressedKeys & PAD_KEY_RIGHT) {
v2->unk_04++;
v2->unk_04 %= 32;
}

if (gCoreSys.padInput & PAD_KEY_LEFT) {
if (gCoreSys.pressedKeys & PAD_KEY_LEFT) {
if (v2->unk_04) {
v2->unk_04--;
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/overlay006/ov6_02247A0C.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ static BOOL ov6_02247A34 (UnkStruct_020508D4 * param0)
v1->unk_04++;
break;
case 1:
if (gCoreSys.padInput & (PAD_BUTTON_A | PAD_BUTTON_B)) {
if (gCoreSys.pressedKeys & (PAD_BUTTON_A | PAD_BUTTON_B)) {
ov6_02247CC8(v1->unk_00);
v1->unk_04++;
}
Expand Down
12 changes: 6 additions & 6 deletions src/overlay007/ov7_02249960.c
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ static void ov7_0224A34C (SysTask * param0, void * param1)

if (ov7_0224A244(param0, param1)) {
(void)0;
} else if (( PAD_BUTTON_B )&gCoreSys.padInput) {
} else if (( PAD_BUTTON_B )&gCoreSys.pressedKeys) {
ov7_02249960(3, 0);
ov7_0224A530(ov7_0224A394);
}
Expand Down Expand Up @@ -1119,7 +1119,7 @@ static void ov7_0224AB64 (SysTask * param0, void * param1)
UnkStruct_ov7_02249C2C * v0 = (UnkStruct_ov7_02249C2C *)param1;

if (sub_0205DA04(Unk_ov7_0224F5A0->unk_94)) {
if (gCoreSys.padInput & (PAD_BUTTON_A | PAD_BUTTON_B)) {
if (gCoreSys.pressedKeys & (PAD_BUTTON_A | PAD_BUTTON_B)) {
ov7_0224AFD8(param0, v0);
ov7_0224A528();
Unk_ov7_0224F5A0->unk_88 = 4;
Expand All @@ -1135,7 +1135,7 @@ static void ov7_0224ABA4 (SysTask * param0, void * param1)
ov7_0224A64C(v0);

if (sub_0205DA04(Unk_ov7_0224F5A0->unk_94)) {
if (gCoreSys.padInput & (PAD_BUTTON_A | PAD_BUTTON_B)) {
if (gCoreSys.pressedKeys & (PAD_BUTTON_A | PAD_BUTTON_B)) {
ov7_0224A5D0();
ov7_0224A530(ov7_0224ABE0);
}
Expand Down Expand Up @@ -1307,7 +1307,7 @@ static void ov7_0224AD68 (SysTask * param0, void * param1)
static void ov7_0224ADD8 (SysTask * param0, void * param1)
{
if (sub_0205DA04(Unk_ov7_0224F5A0->unk_94)) {
if (gCoreSys.padInput & (PAD_BUTTON_A | PAD_BUTTON_B)) {
if (gCoreSys.pressedKeys & (PAD_BUTTON_A | PAD_BUTTON_B)) {
Unk_ov7_0224F5A0->unk_88 = 1;
SysTask_Done(param0);
}
Expand Down Expand Up @@ -1587,7 +1587,7 @@ static void ov7_0224B2A0 (SysTask * param0, void * param1)
UnkStruct_ov7_02249C2C * v0 = (UnkStruct_ov7_02249C2C *)param1;

if (sub_0205DA04(Unk_ov7_0224F5A0->unk_94)) {
if (gCoreSys.padInput & (PAD_BUTTON_A | PAD_BUTTON_B)) {
if (gCoreSys.pressedKeys & (PAD_BUTTON_A | PAD_BUTTON_B)) {
SysTask_Done(param0);
ov7_0224A528();
Unk_ov7_0224F5A0->unk_88 = 1;
Expand Down Expand Up @@ -1637,7 +1637,7 @@ static void ov7_0224B370 (SysTask * param0, void * param1)
UnkStruct_ov7_02249C2C * v0 = (UnkStruct_ov7_02249C2C *)param1;

if (sub_0205DA04(Unk_ov7_0224F5A0->unk_94)) {
if (gCoreSys.padInput & (PAD_BUTTON_A | PAD_BUTTON_B)) {
if (gCoreSys.pressedKeys & (PAD_BUTTON_A | PAD_BUTTON_B)) {
ov7_02249E0C(v0);
SysTask_Done(param0);
}
Expand Down
4 changes: 2 additions & 2 deletions src/overlay007/ov7_0224B4E8.c
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ static BOOL ov7_0224BC74 (UnkStruct_020508D4 * param0)
break;
case 6:
if (sub_0205DA04(v1->unk_74)) {
if (gCoreSys.padInput & (PAD_BUTTON_A | PAD_BUTTON_B)) {
if (gCoreSys.pressedKeys & (PAD_BUTTON_A | PAD_BUTTON_B)) {
v1->unk_7C = 0;
}
}
Expand All @@ -524,7 +524,7 @@ static BOOL ov7_0224BC74 (UnkStruct_020508D4 * param0)
v1->unk_7C++;
break;
case 8:
if (gCoreSys.padInput & (PAD_BUTTON_A | PAD_BUTTON_B)) {
if (gCoreSys.pressedKeys & (PAD_BUTTON_A | PAD_BUTTON_B)) {
ov7_0224BBA0(v1);
ov7_0224B4E8(v1, 106);
ov7_0224B5A8(v1);
Expand Down
2 changes: 1 addition & 1 deletion src/overlay007/ov7_0224BE9C.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ BOOL ov7_0224BF2C (UnkStruct_ov7_0224BEFC * param0)
break;
case 11:
if (ov7_0224C4B8(&param0->unk_1B8)) {
if (gCoreSys.padInput & (PAD_BUTTON_A | PAD_BUTTON_B)) {
if (gCoreSys.pressedKeys & (PAD_BUTTON_A | PAD_BUTTON_B)) {
param0->unk_00 = param0->unk_04;
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/overlay007/ov7_0224CD28.c
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ static u8 ov7_0224D250 (UnkStruct_0203CDB0 * param0, UnkStruct_ov7_0224D008 * pa
return 0;
}

if (gCoreSys.padInput & (PAD_BUTTON_A | PAD_BUTTON_B)) {
if (gCoreSys.pressedKeys & (PAD_BUTTON_A | PAD_BUTTON_B)) {
void * v0;

sub_0200E084(&param1->unk_08[1], 0);
Expand Down Expand Up @@ -971,7 +971,7 @@ static u8 ov7_0224DFB0 (UnkStruct_ov7_0224D008 * param0)
return 6;
}

if (gCoreSys.padInput & PAD_BUTTON_A) {
if (gCoreSys.pressedKeys & PAD_BUTTON_A) {
sub_02021CAC(param0->unk_25C[0], 0);
sub_02021CAC(param0->unk_25C[1], 0);
Window_Clear(&param0->unk_08[4], 1);
Expand All @@ -982,7 +982,7 @@ static u8 ov7_0224DFB0 (UnkStruct_ov7_0224D008 * param0)
return ov7_0224E098(param0);
}

if (gCoreSys.padInput & PAD_BUTTON_B) {
if (gCoreSys.pressedKeys & PAD_BUTTON_B) {
Window_Clear(&param0->unk_08[4], 1);
Window_Clear(&param0->unk_08[3], 1);
sub_0200E084(&param0->unk_08[5], 0);
Expand Down Expand Up @@ -1224,7 +1224,7 @@ static u8 ov7_0224E6B8 (UnkStruct_ov7_0224D008 * param0)
return 10;
}

if (gCoreSys.padInput & (PAD_BUTTON_A | PAD_BUTTON_B)) {
if (gCoreSys.pressedKeys & (PAD_BUTTON_A | PAD_BUTTON_B)) {
if (param0->unk_28C == 1) {
sub_0206B3B4(param0->unk_288);
}
Expand Down Expand Up @@ -1267,7 +1267,7 @@ static u8 ov7_0224E7C8 (UnkStruct_ov7_0224D008 * param0)
return 11;
}

if (gCoreSys.padInput & (PAD_BUTTON_A | PAD_BUTTON_B)) {
if (gCoreSys.pressedKeys & (PAD_BUTTON_A | PAD_BUTTON_B)) {
sub_0200E084(&param0->unk_08[5], 0);
ov7_0224EB38(param0, 0);
sub_02021CAC(param0->unk_25C[0], param0->unk_26C[0]);
Expand Down
2 changes: 1 addition & 1 deletion src/overlay008/ov8_02249960.c
Original file line number Diff line number Diff line change
Expand Up @@ -2953,7 +2953,7 @@ static BOOL ov8_0224B3D4 (UnkStruct_020508D4 * param0)

v2->unk_00++;
case 12:
if (gCoreSys.padInput & (PAD_BUTTON_A | PAD_BUTTON_B)) {
if (gCoreSys.pressedKeys & (PAD_BUTTON_A | PAD_BUTTON_B)) {
int v9 = sub_0205EABC(v1->unk_3C);
int v10 = sub_0205EAC8(v1->unk_3C);

Expand Down
2 changes: 1 addition & 1 deletion src/overlay010/ov10_0221F800.c
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ static void ov10_0221F930 (UnkStruct_ov10_0221FB28 * param0)
break;
case 2:
if (param0->unk_BBC == 1) {
if (gCoreSys.padInput & PAD_BUTTON_A) {
if (gCoreSys.pressedKeys & PAD_BUTTON_A) {
param0->unk_BB0 = 3;
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/overlay012/ov12_0221FC20.c
Original file line number Diff line number Diff line change
Expand Up @@ -1047,9 +1047,9 @@ static void ov12_0222048C (UnkStruct_ov12_0221FCDC * param0)
{
param0->unk_89 = 1;

if (gCoreSys.unk_44 & PAD_BUTTON_L) {
if (gCoreSys.unk_44 & PAD_BUTTON_R) {
if (gCoreSys.padInput & PAD_BUTTON_X) {
if (gCoreSys.heldKeys & PAD_BUTTON_L) {
if (gCoreSys.heldKeys & PAD_BUTTON_R) {
if (gCoreSys.pressedKeys & PAD_BUTTON_X) {
param0->unk_18 += 1;
param0->unk_89 = 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/overlay013/ov13_0221FC20.c
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ static u8 ov13_02220848 (UnkStruct_ov13_022213F0 * param0)

static u8 ov13_02220864 (UnkStruct_ov13_022213F0 * param0)
{
if ((gCoreSys.padInput & (PAD_BUTTON_A | PAD_BUTTON_B)) || (TouchScreen_Tapped() == 1)) {
if ((gCoreSys.pressedKeys & (PAD_BUTTON_A | PAD_BUTTON_B)) || (TouchScreen_Tapped() == 1)) {
return param0->unk_2075;
}

Expand Down
Loading
Loading