From ea6b79a53622da3409fd0adf65fd20e0de38d5aa Mon Sep 17 00:00:00 2001 From: Retnuhytnuob Date: Sun, 14 Sep 2025 02:20:47 -0500 Subject: [PATCH] flipper state naming --- include/global.h | 14 +++-- src/board_process4.c | 120 ++++++++++++++++++++-------------------- src/board_process6.c | 34 ++++++------ src/pinball_game_main.c | 2 +- 4 files changed, 86 insertions(+), 84 deletions(-) diff --git a/include/global.h b/include/global.h index 11bf368..9a7bd25 100644 --- a/include/global.h +++ b/include/global.h @@ -99,16 +99,18 @@ struct BallState /*0x3C*/ struct Vector32 prevPositionQ8; }; -struct UnkPinballGame13BC +// Position rises in steps of 2 from 0 to 10. +// Releasing the button continues rising till it reaches 10, and stalls for 3 frames before falling +struct FlipperState { - /*0x00*/ s8 unk0; - /*0x01*/ s8 unk1; + /*0x00*/ s8 position; + /*0x01*/ s8 prevPosition; /*0x02*/ s8 unk2; /*0x03*/ s8 unk3; /*0x04*/ s8 unk4; /*0x05*/ s8 unk5; - /*0x06*/ s8 unk6; - /*0x07*/ u8 unk7; + /*0x06*/ s8 active; + /*0x07*/ u8 stallTicks; /*0x08*/ s8 unk8; /*0x09*/ u8 filler9[0x3]; }; @@ -857,7 +859,7 @@ struct PinballGame /*0x132C*/struct BallState *ball; /*0x1330*/struct BallState *unk1330; /*0x1334*/struct BallState unk1334[2]; - /*0x13BC*/struct UnkPinballGame13BC unk13BC[2]; + /*0x13BC*/struct FlipperState flipper[2]; /*0x13D4*/u16 unk13D4[10]; /*0x13E8*/struct Vector16 unk13E8[10]; } /* size=0x1410 */; diff --git a/src/board_process4.c b/src/board_process4.c index e8e1439..7c548f0 100644 --- a/src/board_process4.c +++ b/src/board_process4.c @@ -17,7 +17,7 @@ void sub_1931C(struct Vector16 arg0) struct Unk086ACE8C *line; struct Vector16 point1, point2; - line = &gUnknown_086ACE8C[gCurrentPinballGame->unk13BC[0].unk0]; + line = &gUnknown_086ACE8C[gCurrentPinballGame->flipper[0].position]; point1.x = line->unk0 + 0x53; point1.y = line->unk2 + gUnknown_02031520.unk14.unk1C; @@ -27,11 +27,11 @@ void sub_1931C(struct Vector16 arg0) check = (point2.y - point1.y) * (arg0.x - point1.x) * 30 / (point2.x - point1.x) + (point1.y - arg0.y) * 30; if (check >= 0) - gCurrentPinballGame->unk13BC[0].unk8 = 1; + gCurrentPinballGame->flipper[0].unk8 = 1; else - gCurrentPinballGame->unk13BC[0].unk8 = -1; + gCurrentPinballGame->flipper[0].unk8 = -1; - line = &gUnknown_086ACE8C[gCurrentPinballGame->unk13BC[1].unk0]; + line = &gUnknown_086ACE8C[gCurrentPinballGame->flipper[1].position]; point1.x = 0x9C - line->unk0; point1.y = line->unk2 + gUnknown_02031520.unk14.unk1C; @@ -42,9 +42,9 @@ void sub_1931C(struct Vector16 arg0) check = (point2.y - point1.y) * (arg0.x - point1.x) * 30 / (point2.x - point1.x) + (point1.y - arg0.y) * 30; if (check >= 0) - gCurrentPinballGame->unk13BC[1].unk8 = 1; + gCurrentPinballGame->flipper[1].unk8 = 1; else - gCurrentPinballGame->unk13BC[1].unk8 = -1; + gCurrentPinballGame->flipper[1].unk8 = -1; } void MainBoardProcess_4B_19490(void) @@ -58,10 +58,10 @@ void MainBoardProcess_4B_19490(void) { struct SpriteGroup *spriteGroup; - if (gCurrentPinballGame->unk13BC[i].unk0 > 10) - gCurrentPinballGame->unk13BC[i].unk0 = 10; - else if (gCurrentPinballGame->unk13BC[i].unk0 < 0) - gCurrentPinballGame->unk13BC[i].unk0 = 0; + if (gCurrentPinballGame->flipper[i].position > 10) + gCurrentPinballGame->flipper[i].position = 10; + else if (gCurrentPinballGame->flipper[i].position < 0) + gCurrentPinballGame->flipper[i].position = 0; spriteGroup = &gMain.spriteGroups[10 + i]; if (spriteGroup->available) @@ -69,7 +69,7 @@ void MainBoardProcess_4B_19490(void) s8 unk0; struct OamDataSimple *oamData; - unk0 = gCurrentPinballGame->unk13BC[i].unk0 / 2; + unk0 = gCurrentPinballGame->flipper[i].position / 2; spriteGroup->baseX = gUnknown_086ACEF4[i] - gCurrentPinballGame->unk58; spriteGroup->baseY = gUnknown_02031520.unk14.unk1C - gCurrentPinballGame->unk5A; @@ -91,34 +91,34 @@ void sub_195C4(void) for (i = 0; i < 2; i++) { s16 dir; - struct UnkPinballGame13BC *unk13BC; - unk13BC = &gCurrentPinballGame->unk13BC[i]; + struct FlipperState *flipper; + flipper = &gCurrentPinballGame->flipper[i]; - unk13BC->unk1 = unk13BC->unk0; - unk13BC->unk2 = 0; + flipper->prevPosition = flipper->position; + flipper->unk2 = 0; if (gCurrentPinballGame->heldButtonActions[i]) { - if (unk13BC->unk6 == 0 && gCurrentPinballGame->unk25 == 0) + if (flipper->active == 0 && gCurrentPinballGame->unk25 == 0) m4aSongNumStart(SE_UNKNOWN_0x72); - unk13BC->unk6 = 1; - unk13BC->unk7 = 0; + flipper->active = 1; + flipper->stallTicks = 0; } else { - if (unk13BC->unk0 == 10) + if (flipper->position == 10) { - if (unk13BC->unk7 > 2) - unk13BC->unk6 = gCurrentPinballGame->heldButtonActions[i]; - unk13BC->unk7++; + if (flipper->stallTicks > 2) + flipper->active = gCurrentPinballGame->heldButtonActions[i]; + flipper->stallTicks++; } } dir = 0; - if (unk13BC->unk6 != 0) + if (flipper->active != 0) { - if (unk13BC->unk0 != 10) + if (flipper->position != 10) { dir = 1; } @@ -129,14 +129,14 @@ void sub_195C4(void) gCurrentPinballGame->unk5C = 0; sub_11B0(7); } - unk13BC->unk2 = unk13BC->unk0 / 2 + 1; - unk13BC->unk0 += 4; + flipper->unk2 = flipper->position / 2 + 1; + flipper->position += 4; } else { - if (unk13BC->unk0 != 0) + if (flipper->position != 0) { - unk13BC->unk2 = unk13BC->unk0 / 2 + 6; + flipper->unk2 = flipper->position / 2 + 6; dir = -1; } else if (gCurrentPinballGame->unk5C != 0) @@ -146,12 +146,12 @@ void sub_195C4(void) gCurrentPinballGame->unk5C = 0; sub_11B0(7); } - unk13BC->unk0 -= 2; + flipper->position -= 2; } - unk13BC->unk3 = unk13BC->unk3 * dir; - if (unk13BC->unk3 <= 0) - unk13BC->unk4 = 0; - unk13BC->unk3 = dir; + flipper->unk3 = flipper->unk3 * dir; + if (flipper->unk3 <= 0) + flipper->unk4 = 0; + flipper->unk3 = dir; } } @@ -169,10 +169,10 @@ void BonusBoardProcess_4B_19734(void) { struct SpriteGroup *spriteGroup; - if (gCurrentPinballGame->unk13BC[i].unk0 > 10) - gCurrentPinballGame->unk13BC[i].unk0 = 10; - else if (gCurrentPinballGame->unk13BC[i].unk0 < 0) - gCurrentPinballGame->unk13BC[i].unk0 = 0; + if (gCurrentPinballGame->flipper[i].position > 10) + gCurrentPinballGame->flipper[i].position = 10; + else if (gCurrentPinballGame->flipper[i].position < 0) + gCurrentPinballGame->flipper[i].position = 0; spriteGroup = &gMain.spriteGroups[3 + i]; if (spriteGroup->available) @@ -180,7 +180,7 @@ void BonusBoardProcess_4B_19734(void) s8 unk0; struct OamDataSimple *oamData; - unk0 = gCurrentPinballGame->unk13BC[i].unk0 / 2; + unk0 = gCurrentPinballGame->flipper[i].position / 2; spriteGroup->baseX = gUnknown_086ACEF4[i] - gCurrentPinballGame->unk58; spriteGroup->baseY = gUnknown_02031520.unk14.unk1C - gCurrentPinballGame->unk5A; @@ -206,35 +206,35 @@ void sub_19894(void) for (i = 0; i < 2; i++) { s16 dir; - struct UnkPinballGame13BC *unk13BC; - unk13BC = &gCurrentPinballGame->unk13BC[i]; + struct FlipperState *flipper; + flipper = &gCurrentPinballGame->flipper[i]; - unk13BC->unk1 = unk13BC->unk0; - unk13BC->unk2 = 0; + flipper->prevPosition = flipper->position; + flipper->unk2 = 0; if (gCurrentPinballGame->heldButtonActions[i] && gMain.unkF == 0) { - if (unk13BC->unk6 == 0 && gCurrentPinballGame->unk25 == 0 && gCurrentPinballGame->unk1A == 0) + if (flipper->active == 0 && gCurrentPinballGame->unk25 == 0 && gCurrentPinballGame->unk1A == 0) { m4aSongNumStart(SE_UNKNOWN_0x72); } - unk13BC->unk6 = 1; - unk13BC->unk7 = 0; + flipper->active = 1; + flipper->stallTicks = 0; } else { - if (unk13BC->unk0 == 10) + if (flipper->position == 10) { - if (unk13BC->unk7 > 2) - unk13BC->unk6 = 0; - unk13BC->unk7++; + if (flipper->stallTicks > 2) + flipper->active = 0; + flipper->stallTicks++; } } dir = 0; - if (unk13BC->unk6 != 0) + if (flipper->active != 0) { - if (unk13BC->unk0 != 10) + if (flipper->position != 10) { dir = 1; } @@ -245,14 +245,14 @@ void sub_19894(void) gCurrentPinballGame->unk5C = 0; sub_11B0(7); } - unk13BC->unk2 = unk13BC->unk0 / 2 + 1; - unk13BC->unk0 += 4; + flipper->unk2 = flipper->position / 2 + 1; + flipper->position += 4; } else { - if (unk13BC->unk0 != 0) + if (flipper->position != 0) { - unk13BC->unk2 = unk13BC->unk0 / 2 + 6; + flipper->unk2 = flipper->position / 2 + 6; dir = -1; } else if (gCurrentPinballGame->unk5C != 0) @@ -262,11 +262,11 @@ void sub_19894(void) gCurrentPinballGame->unk5C = 0; sub_11B0(7); } - unk13BC->unk0 -= 2; + flipper->position -= 2; } - unk13BC->unk3 = unk13BC->unk3 * dir; - if (unk13BC->unk3 <= 0) - unk13BC->unk4 = 0; - unk13BC->unk3 = dir; + flipper->unk3 = flipper->unk3 * dir; + if (flipper->unk3 <= 0) + flipper->unk4 = 0; + flipper->unk3 = dir; } } diff --git a/src/board_process6.c b/src/board_process6.c index 2628462..611e88b 100644 --- a/src/board_process6.c +++ b/src/board_process6.c @@ -78,10 +78,10 @@ void AllBoardProcess_6B_1333C() sub_13934(&var0, &var1, r7); var0.x -= (gUnknown_02031520.unk14.unk22 * 2); var0.y -= (gUnknown_02031520.unk14.unk20 * 2); - if (gCurrentPinballGame->unk13BC[0].unk4 == 0) + if (gCurrentPinballGame->flipper[0].unk4 == 0) { sub_13D24(r7, &gCurrentPinballGame->ball->velocity, &var2); - gCurrentPinballGame->unk13BC[0].unk4 = 1; + gCurrentPinballGame->flipper[0].unk4 = 1; } else { @@ -110,10 +110,10 @@ void AllBoardProcess_6B_1333C() sub_13934(&var0, &var1, r7); var0.x -= (gUnknown_02031520.unk14.unk24 * 2); var0.y -= (gUnknown_02031520.unk14.unk20 * 2); - if (gCurrentPinballGame->unk13BC[1].unk4 == 0) + if (gCurrentPinballGame->flipper[1].unk4 == 0) { sub_13D24(r7, &gCurrentPinballGame->ball->velocity, &var2); - gCurrentPinballGame->unk13BC[1].unk4 = 1; + gCurrentPinballGame->flipper[1].unk4 = 1; } else { @@ -276,14 +276,14 @@ void sub_13B28(struct Vector16* arg0, struct Vector16* arg1, s16 arg2) for (;;) { - sp12 = gCurrentPinballGame->unk13BC[arg2].unk0 - gCurrentPinballGame->unk13BC[arg2].unk1; + sp12 = gCurrentPinballGame->flipper[arg2].position - gCurrentPinballGame->flipper[arg2].prevPosition; - if ((sp12 *= gCurrentPinballGame->unk13BC[arg2].unk8) > 0) + if ((sp12 *= gCurrentPinballGame->flipper[arg2].unk8) > 0) { - if (gCurrentPinballGame->unk13BC[arg2].unk2 < 7) - r4 = gUnknown_086ACD84[gCurrentPinballGame->unk13BC[arg2].unk5 - 1][0] + 0x4000; + if (gCurrentPinballGame->flipper[arg2].unk2 < 7) + r4 = gUnknown_086ACD84[gCurrentPinballGame->flipper[arg2].unk5 - 1][0] + 0x4000; else - r4 = gUnknown_086ACD84[gCurrentPinballGame->unk13BC[arg2].unk5 + 1][1] + -0x4000; // This changes compilation, apparently + r4 = gUnknown_086ACD84[gCurrentPinballGame->flipper[arg2].unk5 + 1][1] + -0x4000; // This changes compilation, apparently } else { @@ -896,7 +896,7 @@ void sub_1493C(void) } u16 sub_14AF4(struct Vector16 r0, s16 r1, u16 *r2, s16 r3) { - struct UnkPinballGame13BC* unk13BC; + struct FlipperState* flipper; u16 res; int new_var; unsigned short ix; @@ -904,13 +904,13 @@ u16 sub_14AF4(struct Vector16 r0, s16 r1, u16 *r2, s16 r3) { res = 0; ix = (r0.y * 96) + r0.x; - unk13BC = &gCurrentPinballGame->unk13BC[r3]; + flipper = &gCurrentPinballGame->flipper[r3]; - unk13BC->unk5 = gUnknown_086ACDB8[r1 + (unk13BC->unk2 * 5)]; + flipper->unk5 = gUnknown_086ACDB8[r1 + (flipper->unk2 * 5)]; - if (0xF & (&gUnknown_02031520.unk68[unk13BC->unk5 * 0x2400])[ix]) + if (0xF & (&gUnknown_02031520.unk68[flipper->unk5 * 0x2400])[ix]) { - *r2 = 0xFFF0 & (&gUnknown_02031520.unk68[unk13BC->unk5 * 0x2400])[ix]; + *r2 = 0xFFF0 & (&gUnknown_02031520.unk68[flipper->unk5 * 0x2400])[ix]; if (r3 == 1) { new_var = 0x8000; @@ -926,9 +926,9 @@ void sub_14B84(s32 arg0, s16 arg1, struct Vector16* arg2, u16 arg3) { u16 angle; - angle = gCurrentPinballGame->unk13BC[arg1].unk5; + angle = gCurrentPinballGame->flipper[arg1].unk5; - if (gCurrentPinballGame->unk13BC[arg1].unk8 > 0) + if (gCurrentPinballGame->flipper[arg1].unk8 > 0) { if (gCurrentPinballGame->unk5C == 0) { @@ -937,7 +937,7 @@ void sub_14B84(s32 arg0, s16 arg1, struct Vector16* arg2, u16 arg3) s16 temp_r2; s16 temp_r5; - temp_r2 = gCurrentPinballGame->unk13BC[arg1].unk5; + temp_r2 = gCurrentPinballGame->flipper[arg1].unk5; temp_r5 = (temp_r2 - 2) * 25; arg0 -= temp_r5; diff --git a/src/pinball_game_main.c b/src/pinball_game_main.c index 22877bb..0b6259f 100644 --- a/src/pinball_game_main.c +++ b/src/pinball_game_main.c @@ -1364,7 +1364,7 @@ void sub_4C290(void) for (i = 0; i <= 1; i++) { - var0 = gCurrentPinballGame->unk13BC[i].unk0 / 2; + var0 = gCurrentPinballGame->flipper[i].position / 2; DmaCopy16(3, gUnknown_083FE44C[var0], ((i * 0x200) + 0x06010000), 0x200); }