diff --git a/asm/rom_4CEA8.s b/asm/rom_4CEA8.s index 30c7947..4f9ec6b 100644 --- a/asm/rom_4CEA8.s +++ b/asm/rom_4CEA8.s @@ -2518,182 +2518,3 @@ _0804E2E6: bx r0 .align 2, 0 _0804E2F4: .4byte 0x00000123 - - thumb_func_start sub_4E2F8 -sub_4E2F8: @ 0x0804E2F8 - push {r4, r5, r6, r7, lr} - ldr r0, _0804E3E4 @ =gCurrentPinballGame - ldr r2, [r0] - movs r1, #0x13 - ldrsb r1, [r2, r1] - adds r5, r0, #0 - cmp r1, #0 - beq _0804E328 - ldrb r0, [r2, #5] - cmp r0, #0 - beq _0804E328 - adds r0, r2, #0 - adds r0, #0x20 - ldrb r0, [r0] - cmp r0, #0 - beq _0804E328 - adds r0, r2, #0 - adds r0, #0x21 - movs r1, #1 - strb r1, [r0] - ldr r0, [r5] - ldr r2, _0804E3E8 @ =0x00000163 - adds r0, r0, r2 - strb r1, [r0] -_0804E328: - adds r4, r5, #0 - ldr r1, [r4] - adds r0, r1, #0 - adds r0, #0x21 - ldrb r0, [r0] - cmp r0, #0 - beq _0804E372 - ldrb r0, [r1, #0xa] - cmp r0, #0 - beq _0804E372 - ldr r0, _0804E3E8 @ =0x00000163 - adds r1, r1, r0 - movs r6, #0 - movs r0, #3 - strb r0, [r1] - ldr r0, [r4] - adds r0, #0x20 - ldrb r0, [r0] - cmp r0, #0 - beq _0804E36C - movs r0, #7 - bl sub_11B0 - ldr r0, [r4] - ldr r1, _0804E3EC @ =0x0000132C - adds r0, r0, r1 - ldr r2, [r0] - ldr r1, _0804E3F0 @ =0x0000FDB2 - strh r1, [r2, #0x32] - ldr r0, [r0] - strh r6, [r0, #0x30] - movs r0, SE_UNKNOWN_0xCD - bl m4aSongNumStart -_0804E36C: - ldr r0, [r5] - adds r0, #0x21 - strb r6, [r0] -_0804E372: - ldr r7, _0804E3E4 @ =gCurrentPinballGame - ldr r6, [r7] - ldr r2, _0804E3EC @ =0x0000132C - adds r3, r6, r2 - ldr r0, _0804E3F4 @ =0x00001334 - adds r4, r6, r0 - str r4, [r3] - ldr r0, _0804E3F8 @ =gUnknown_02031520 - movs r2, #0x12 - ldrsh r1, [r4, r2] - ldrh r5, [r0, #0x2a] - movs r2, #0x2a - ldrsh r0, [r0, r2] - cmp r1, r0 - blt _0804E452 - movs r2, #0 - strh r5, [r4, #0x12] - ldr r1, [r3] - movs r4, #0x10 - ldrsh r0, [r1, r4] - lsls r0, r0, #1 - strh r0, [r1, #0x28] - ldr r1, [r3] - movs r4, #0x12 - ldrsh r0, [r1, r4] - lsls r0, r0, #1 - strh r0, [r1, #0x2a] - ldr r1, [r3] - movs r4, #0x10 - ldrsh r0, [r1, r4] - lsls r0, r0, #8 - str r0, [r1, #0x34] - ldr r1, [r3] - movs r4, #0x12 - ldrsh r0, [r1, r4] - lsls r0, r0, #8 - str r0, [r1, #0x38] - ldr r0, [r3] - strh r2, [r0, #0x30] - ldr r0, [r3] - strh r2, [r0, #0x32] - ldr r4, _0804E3FC @ =gMain - ldrh r0, [r4, #0x14] - cmp r0, #0 - bne _0804E452 - ldr r1, _0804E400 @ =0x00000724 - adds r0, r6, r1 - ldrh r0, [r0] - cmp r0, #0 - beq _0804E404 - movs r0, #4 - strh r0, [r4, #0x14] - movs r0, #8 - strb r0, [r4, #0x11] - movs r0, #0xcc - strh r0, [r4, #0x12] - b _0804E452 - .align 2, 0 -_0804E3E4: .4byte gCurrentPinballGame -_0804E3E8: .4byte 0x00000163 -_0804E3EC: .4byte 0x0000132C -_0804E3F0: .4byte 0x0000FDB2 -_0804E3F4: .4byte 0x00001334 -_0804E3F8: .4byte gUnknown_02031520 -_0804E3FC: .4byte gMain -_0804E400: .4byte 0x00000724 -_0804E404: - movs r0, #0x50 - strh r0, [r4, #0x14] - movs r0, #0x10 - strb r0, [r4, #0x11] - movs r0, #0xc8 - strh r0, [r4, #0x12] - bl m4aMPlayAllStop - movs r0, MUS_END_OF_BALL - bl m4aSongNumStart - bl sub_4E598 - ldr r2, [r7] - movs r3, #0xf1 - lsls r3, r3, #1 - adds r0, r2, r3 - movs r1, #0 - ldrsb r1, [r0, r1] - cmp r1, #2 - bne _0804E452 - movs r0, #9 - ldrsb r0, [r4, r0] - cmp r0, #0 - bne _0804E452 - movs r4, #0xdf - lsls r4, r4, #1 - adds r0, r2, r4 - strb r1, [r0] - ldr r1, [r7] - movs r0, #0xe0 - lsls r0, r0, #1 - adds r2, r1, r0 - movs r0, #0xc8 - lsls r0, r0, #2 - strh r0, [r2] - adds r1, r1, r3 - movs r0, #0 - strb r0, [r1] -_0804E452: - ldr r0, _0804E464 @ =gCurrentPinballGame - ldr r0, [r0] - adds r0, #0x20 - movs r1, #0 - strb r1, [r0] - pop {r4, r5, r6, r7} - pop {r0} - bx r0 - .align 2, 0 -_0804E464: .4byte gCurrentPinballGame diff --git a/expected_objs/sub_4E2F8.o b/expected_objs/sub_4E2F8.o deleted file mode 100644 index 3276cff..0000000 Binary files a/expected_objs/sub_4E2F8.o and /dev/null differ diff --git a/include/global.h b/include/global.h index 7369f9d..e67dc59 100644 --- a/include/global.h +++ b/include/global.h @@ -131,7 +131,8 @@ struct PinballGame /*0x01D*/ u8 unk1D; /*0x01E*/ u8 unk1E; /*0x01F*/ u8 unk1F; - /*0x020*/ u8 filler20[0x2]; + /*0x020*/ u8 unk20; + /*0x021*/ u8 unk21; /*0x022*/ s8 unk22; /*0x023*/ u8 unk23; // Holds the value of some enum state /*0x024*/ s8 unk24; @@ -214,7 +215,9 @@ struct PinballGame /*0x12D*/ u8 filler12D; /*0x12E*/ s16 totalWeight; // Added weight of all possible mons in area /*0x130*/ s16 speciesWeights[25]; // Weight of each species - /*0x162*/ u8 filler162[0x4]; + /*0x162*/ u8 filler162[0x1]; + /*0x163*/ u8 unk163; + /*0x164*/ u8 filler164[0x2]; /*0x166*/ u16 unk166; /*0x168*/ u8 filler168[0x4]; /*0x16C*/ u8 unk16C; @@ -243,7 +246,8 @@ struct PinballGame /*0x1B6*/ u8 filler1B6[0x4]; /*0x1BA*/ u16 unk1BA; /*0x1BC*/ u16 unk1BC; - /*0x1BE*/ u8 filler1BE[0x2]; + /*0x1BE*/ u8 unk1BE; + /*0x1BF*/ u8 filler1BF[0x1]; /*0x1C0*/ u16 unk1C0; /*0x1C2*/ s8 unk1C2; /*0x1C3*/ u8 filler1C3[0x1]; diff --git a/src/rom_4E598.c b/src/rom_4E598.c index ee49c9f..baa1fd0 100644 --- a/src/rom_4E598.c +++ b/src/rom_4E598.c @@ -1,5 +1,72 @@ #include "global.h" +#include "m4a.h" #include "main.h" +#include "constants/bg_music.h" + +void sub_4E2F8(void) +{ + struct BallState *unk1334; + + if (gCurrentPinballGame->unk13 && gCurrentPinballGame->newButtonActions[1] && gCurrentPinballGame->unk20) + { + gCurrentPinballGame->unk21 = 1; + gCurrentPinballGame->unk163 = 1; + } + + if (gCurrentPinballGame->unk21 && gCurrentPinballGame->releasedButtonActions[1]) + { + gCurrentPinballGame->unk163 = 3; + if (gCurrentPinballGame->unk20) + { + sub_11B0(7); + gCurrentPinballGame->ball->velocity.y = -590; + gCurrentPinballGame->ball->velocity.x = 0; + m4aSongNumStart(SE_UNKNOWN_0xCD); + } + + gCurrentPinballGame->unk21 = 0; + } + + gCurrentPinballGame->ball = &gCurrentPinballGame->unk1334[0]; + unk1334 = &gCurrentPinballGame->unk1334[0]; + + if (unk1334->positionQ0.y >= gUnknown_02031520.unk14.unk2A) + { + unk1334->positionQ0.y = gUnknown_02031520.unk14.unk2A; + gCurrentPinballGame->ball->positionQ1.x = gCurrentPinballGame->ball->positionQ0.x * 2; + gCurrentPinballGame->ball->positionQ1.y = gCurrentPinballGame->ball->positionQ0.y * 2; + gCurrentPinballGame->ball->positionQ8.x = gCurrentPinballGame->ball->positionQ0.x << 8; + gCurrentPinballGame->ball->positionQ8.y = gCurrentPinballGame->ball->positionQ0.y << 8; + gCurrentPinballGame->ball->velocity.x = 0; + gCurrentPinballGame->ball->velocity.y = 0; + if (gMain.unk14 == 0) + { + if (gCurrentPinballGame->unk724) + { + gMain.unk14 = 4; + gMain.unk11 = 8; + gMain.unk12 = 204; + } + else + { + gMain.unk14 = 80; + gMain.unk11 = 16; + gMain.unk12 = 200; + m4aMPlayAllStop(); + m4aSongNumStart(MUS_END_OF_BALL); + sub_4E598(); + if (gCurrentPinballGame->outLanePikaPosition == 2 && gMain.eReaderBonuses[EREADER_DX_MODE_CARD] == 0) + { + gCurrentPinballGame->unk1BE = 2; + gCurrentPinballGame->unk1C0 = 800; + gCurrentPinballGame->outLanePikaPosition = 0; + } + } + } + } + + gCurrentPinballGame->unk20 = 0; +} void sub_4E468(void) {