sub_4B408

This commit is contained in:
Marcus Huderle 2025-02-17 09:44:40 -06:00
parent 69fd8d61f2
commit 92cd662876
5 changed files with 89 additions and 284 deletions

View File

@ -6,279 +6,6 @@
.text
thumb_func_start sub_4B408
sub_4B408: @ 0x0804B408
push {r4, r5, r6, r7, lr}
mov r7, r8
push {r7}
lsls r0, r0, #0x10
lsrs r4, r0, #0x10
ldr r2, _0804B430 @ =gMPlayInfo_BGM
ldr r0, [r2, #4]
cmp r0, #0
blt _0804B43C
ldr r0, _0804B434 @ =gCurrentPinballGame
ldr r0, [r0]
ldr r1, _0804B438 @ =0x00000F4C
adds r0, r0, r1
ldr r1, [r2]
str r1, [r0]
adds r0, r2, #0
bl m4aMPlayStop
b _0804B448
.align 2, 0
_0804B430: .4byte gMPlayInfo_BGM
_0804B434: .4byte gCurrentPinballGame
_0804B438: .4byte 0x00000F4C
_0804B43C:
ldr r0, _0804B5EC @ =gCurrentPinballGame
ldr r0, [r0]
ldr r2, _0804B5F0 @ =0x00000F4C
adds r0, r0, r2
movs r1, #0
str r1, [r0]
_0804B448:
movs r3, #0
ldr r6, _0804B5EC @ =gCurrentPinballGame
ldr r0, _0804B5F4 @ =gMain
mov ip, r0
lsls r4, r4, #0x10
mov r8, r4
mov r5, ip
adds r7, r6, #0
_0804B458:
ldr r4, [r7]
lsls r1, r3, #0x10
asrs r1, r1, #0x10
lsls r2, r1, #1
ldrb r3, [r5, #6]
movs r0, #0xc8
muls r0, r3, r0
adds r2, r2, r0
ldr r3, _0804B5F8 @ =0x00000F68
adds r4, r4, r3
adds r4, r4, r2
movs r0, #0xb8
muls r0, r1, r0
adds r0, r0, r5
movs r2, #0xbe
lsls r2, r2, #2
adds r0, r0, r2
ldrh r0, [r0]
strh r0, [r4]
adds r1, #1
lsls r1, r1, #0x10
lsrs r3, r1, #0x10
asrs r1, r1, #0x10
cmp r1, #0x63
ble _0804B458
ldr r2, _0804B5FC @ =0x040000D4
ldr r0, _0804B600 @ =0x05000200
str r0, [r2]
mov r3, ip
ldrb r1, [r3, #6]
lsls r1, r1, #9
ldr r0, _0804B604 @ =0x0000074C
adds r1, r1, r0
ldr r0, [r6]
adds r0, r0, r1
str r0, [r2, #4]
ldr r3, _0804B608 @ =0x80000100
str r3, [r2, #8]
ldr r0, [r2, #8]
movs r0, #0xa0
lsls r0, r0, #0x13
str r0, [r2]
mov r0, ip
ldrb r1, [r0, #6]
lsls r1, r1, #9
ldr r0, _0804B60C @ =0x00000B4C
adds r1, r1, r0
ldr r0, [r6]
adds r0, r0, r1
str r0, [r2, #4]
str r3, [r2, #8]
ldr r0, [r2, #8]
mov r1, r8
cmp r1, #0
bne _0804B4C8
b _0804B5E0
_0804B4C8:
ldr r1, [r6]
ldr r3, _0804B610 @ =0x00000F58
adds r2, r1, r3
movs r0, #0xba
lsls r0, r0, #2
add r0, ip
ldr r0, [r0]
str r0, [r2]
ldr r0, _0804B614 @ =0x00000F5C
adds r2, r1, r0
movs r0, #0xbb
lsls r0, r0, #2
add r0, ip
ldr r0, [r0]
str r0, [r2]
adds r3, #8
adds r2, r1, r3
movs r0, #0xbc
lsls r0, r0, #2
add r0, ip
ldr r0, [r0]
str r0, [r2]
ldr r0, _0804B618 @ =0x00000F64
adds r2, r1, r0
movs r0, #0xbd
lsls r0, r0, #2
add r0, ip
ldr r0, [r0]
str r0, [r2]
mov r2, ip
ldrb r0, [r2, #4]
ldr r3, _0804B61C @ =0x000010FD
adds r1, r1, r3
strb r0, [r1]
ldr r0, [r6]
ldrb r1, [r2, #5]
ldr r2, _0804B620 @ =0x000010FE
adds r0, r0, r2
strb r1, [r0]
ldr r0, [r6]
mov r3, ip
ldrb r1, [r3, #6]
adds r2, #1
adds r0, r0, r2
strb r1, [r0]
ldr r0, [r6]
ldrb r1, [r3, #0xf]
ldr r3, _0804B624 @ =0x00001101
adds r0, r0, r3
strb r1, [r0]
ldr r0, [r6]
mov r2, ip
ldrb r1, [r2, #0x10]
adds r3, #1
adds r0, r0, r3
strb r1, [r0]
ldr r0, [r6]
ldrb r1, [r2, #0x11]
ldr r2, _0804B628 @ =0x00001103
adds r0, r0, r2
strb r1, [r0]
ldr r1, [r6]
mov r3, ip
ldrh r2, [r3, #0x12]
movs r3, #0x99
lsls r3, r3, #5
adds r0, r1, r3
strh r2, [r0]
mov r0, ip
ldrh r2, [r0, #0x14]
adds r3, #2
adds r0, r1, r3
strh r2, [r0]
mov r0, ip
ldrh r2, [r0, #0x28]
adds r3, #2
adds r0, r1, r3
strh r2, [r0]
mov r0, ip
ldrh r2, [r0, #0x2a]
adds r3, #2
adds r0, r1, r3
strh r2, [r0]
ldr r2, _0804B62C @ =0x00001106
adds r0, r1, r2
ldrh r2, [r0]
ldr r3, _0804B630 @ =0x00001110
adds r0, r1, r3
ldrh r3, [r0]
strh r2, [r0]
ldr r2, _0804B634 @ =0x00001108
adds r0, r1, r2
ldrh r2, [r0]
ldr r3, _0804B638 @ =0x00001112
adds r0, r1, r3
ldrh r3, [r0]
strh r2, [r0]
ldr r2, _0804B63C @ =0x0000110A
adds r0, r1, r2
ldrh r2, [r0]
ldr r3, _0804B640 @ =0x00001114
adds r0, r1, r3
ldrh r3, [r0]
strh r2, [r0]
ldr r2, _0804B644 @ =0x0000110C
adds r0, r1, r2
ldrh r2, [r0]
ldr r3, _0804B648 @ =0x00001116
adds r0, r1, r3
strh r2, [r0]
ldr r2, _0804B64C @ =0x0000110E
adds r0, r1, r2
ldrh r2, [r0]
adds r3, #2
adds r0, r1, r3
strh r2, [r0]
movs r0, #0xa1
lsls r0, r0, #1
add r0, ip
ldrb r0, [r0]
adds r1, #0x31
strb r0, [r1]
movs r3, #0
ldr r5, _0804B650 @ =0x000010F8
mov r4, ip
adds r4, #7
_0804B5C4:
ldr r2, [r6]
lsls r0, r3, #0x10
asrs r0, r0, #0x10
adds r2, r2, r5
adds r2, r2, r0
adds r1, r0, r4
ldrb r1, [r1]
strb r1, [r2]
adds r0, #1
lsls r0, r0, #0x10
lsrs r3, r0, #0x10
asrs r0, r0, #0x10
cmp r0, #4
ble _0804B5C4
_0804B5E0:
pop {r3}
mov r8, r3
pop {r4, r5, r6, r7}
pop {r0}
bx r0
.align 2, 0
_0804B5EC: .4byte gCurrentPinballGame
_0804B5F0: .4byte 0x00000F4C
_0804B5F4: .4byte gMain
_0804B5F8: .4byte 0x00000F68
_0804B5FC: .4byte 0x040000D4
_0804B600: .4byte 0x05000200
_0804B604: .4byte 0x0000074C
_0804B608: .4byte 0x80000100
_0804B60C: .4byte 0x00000B4C
_0804B610: .4byte 0x00000F58
_0804B614: .4byte 0x00000F5C
_0804B618: .4byte 0x00000F64
_0804B61C: .4byte 0x000010FD
_0804B620: .4byte 0x000010FE
_0804B624: .4byte 0x00001101
_0804B628: .4byte 0x00001103
_0804B62C: .4byte 0x00001106
_0804B630: .4byte 0x00001110
_0804B634: .4byte 0x00001108
_0804B638: .4byte 0x00001112
_0804B63C: .4byte 0x0000110A
_0804B640: .4byte 0x00001114
_0804B644: .4byte 0x0000110C
_0804B648: .4byte 0x00001116
_0804B64C: .4byte 0x0000110E
_0804B650: .4byte 0x000010F8
thumb_func_start sub_4B654
sub_4B654: @ 0x0804B654
push {lr}

Binary file not shown.

View File

@ -8,6 +8,7 @@
#include "functions.h"
#include "variables.h"
#include "constants/global.h"
#include "constants/ereader.h"
// Prevent cross-jump optimization.
#define BLOCK_CROSS_JUMP asm("");
@ -67,6 +68,12 @@
#define JOY_NEW(button) TEST_BUTTON(gMain.newKeys, button)
#define JOY_HELD(button) TEST_BUTTON(gMain.heldKeys, button)
struct BgOffsets
{
u16 xOffset;
u16 yOffset;
};
struct UnkPinballGame1334
{
/*0x00*/ u8 unk0;
@ -202,13 +209,42 @@ struct PinballGame
/*0x731*/ u8 filler731[0xB];
/*0x73C*/ u8 unk73C; // TODO: unknown type
/*0x73D*/ s8 catchModeArrows; // Affects which encounter table is used per area
/*0x73E*/ u8 filler73E[0x80E];
/*0x73E*/ u8 filler73E[0xE];
/*0x74C*/ volatile u8 unk74C[2][OBJ_PLTT_SIZE];
/*0xB4C*/ volatile u8 unkB4C[2][BG_PLTT_SIZE];
/*0xF4C*/ struct SongHeader *unkF4C;
/*0xF50*/ u8 fillerF50[0x1B0];
/*0xF50*/ u8 fillerF50[0x8];
/*0xF58*/ struct BgOffsets unkF58;
/*0xF5C*/ struct BgOffsets unkF5C;
/*0xF60*/ struct BgOffsets unkF60;
/*0xF64*/ struct BgOffsets unkF64;
/*0xF68*/ u16 unkF68[2][100];
/*0x10F8*/u8 unk10F8[NUM_EREADER_CARDS];
/*0x10FD*/u8 unk10FD;
/*0x10FE*/u8 unk10FE;
/*0x10FF*/u8 unk10FF;
/*0x1100*/u8 unk1100;
/*0x1101*/u8 filler1101[0x19];
/*0x1101*/u8 unk1101;
/*0x1102*/u8 unk1102;
/*0x1103*/u8 unk1103;
/*0x1104*/u8 filler1104[0x2];
/*0x1106*/u16 unk1106;
/*0x1108*/u16 unk1108;
/*0x110A*/u16 unk110A;
/*0x110C*/u16 unk110C;
/*0x110E*/u16 unk110E;
/*0x1110*/volatile u16 unk1110;
/*0x1112*/volatile u16 unk1112;
/*0x1114*/volatile u16 unk1114;
/*0x1116*/u16 unk1116;
/*0x1118*/u16 unk1118;
/*0x111A*/u8 unk111A[OBJ_PLTT_SIZE];
/*0x131A*/u8 filler131A[0x12];
/*0x131A*/u8 filler131A[0x6];
/*0x1320*/s16 unk1320;
/*0x1322*/s16 unk1322;
/*0x1324*/s16 unk1324;
/*0x1326*/s16 unk1326;
/*0x1328*/u8 filler1328[0x4];
/*0x132C*/struct UnkPinballGame1334 *unk132c;
/*0x1330*/struct UnkPinballGame1334 *unk1330;
/*0x1334*/struct UnkPinballGame1334 unk1334[2];

View File

@ -47,12 +47,6 @@ struct MainUnk44
u8 filler38[0x40];
}; /* size=0x78 */
struct BgOffsets
{
u16 xOffset;
u16 yOffset;
};
struct Main
{
/*0x00*/ u8 filler0[0x2];

View File

@ -33,7 +33,7 @@ void sub_4A518(void);
void sub_4A90C(void);
void sub_4B280(void);
void sub_4B334(void);
void sub_4B408(u16);
void sub_4B408(s16);
void sub_4B654(void);
void sub_4B678(u16);
@ -905,3 +905,51 @@ void sub_4B334(void)
if (gCurrentPinballGame->unk4[1])
gMain.newKeys = A_BUTTON;
}
void sub_4B408(s16 arg0)
{
s16 i;
u16 *var0;
if (gMPlayInfo_BGM.status >= 0)
{
gCurrentPinballGame->unkF4C = gMPlayInfo_BGM.songHeader;
m4aMPlayStop(&gMPlayInfo_BGM);
}
else
{
gCurrentPinballGame->unkF4C = NULL;
}
for (i = 0; i < 100; i++)
gCurrentPinballGame->unkF68[gMain.unk6][i] = gMain.spriteGroups[i].available;
DmaCopy16(3, (void *)OBJ_PLTT, gCurrentPinballGame->unk74C[gMain.unk6], OBJ_PLTT_SIZE);
DmaCopy16(3, (void *)BG_PLTT, gCurrentPinballGame->unkB4C[gMain.unk6], BG_PLTT_SIZE);
if (!arg0)
return;
gCurrentPinballGame->unkF58 = gMain.bgOffsets[0];
gCurrentPinballGame->unkF5C = gMain.bgOffsets[1];
gCurrentPinballGame->unkF60 = gMain.bgOffsets[2];
gCurrentPinballGame->unkF64 = gMain.bgOffsets[3];
gCurrentPinballGame->unk10FD = gMain.selectedField;
gCurrentPinballGame->unk10FE = gMain.unk5;
gCurrentPinballGame->unk10FF = gMain.unk6;
gCurrentPinballGame->unk1101 = gMain.unkF;
gCurrentPinballGame->unk1102 = gMain.unk10;
gCurrentPinballGame->unk1103 = gMain.unk11;
gCurrentPinballGame->unk1320 = gMain.unk12;
gCurrentPinballGame->unk1322 = gMain.unk14;
gCurrentPinballGame->unk1324 = gMain.unk28;
gCurrentPinballGame->unk1326 = gMain.unk2A;
gCurrentPinballGame->unk1110 = gCurrentPinballGame->unk1106;
gCurrentPinballGame->unk1112 = gCurrentPinballGame->unk1108;
gCurrentPinballGame->unk1114 = gCurrentPinballGame->unk110A;
gCurrentPinballGame->unk1116 = gCurrentPinballGame->unk110C;
gCurrentPinballGame->unk1118 = gCurrentPinballGame->unk110E;
gCurrentPinballGame->unk31 = gMain_saveData.ballSpeed;
for (i = 0; i < NUM_EREADER_CARDS; i++)
gCurrentPinballGame->unk10F8[i] = gMain.eReaderBonus[i];
}