Unsplit managerF to avoid conflicts with the pr of Ibot02

This commit is contained in:
octorock 2021-09-26 14:57:42 +02:00
parent 9283aa5afe
commit c603199e0a
17 changed files with 475 additions and 55 deletions

View File

@ -1,36 +0,0 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.section .rodata
.align 2
gUnk_08108314:: @ 08108314
.4byte sub_08058EE4
.4byte sub_08058FB0
.4byte sub_08058FB0
.4byte sub_08059094
.4byte sub_080590E0
.4byte sub_08059124
.4byte sub_080591CC
.4byte sub_08059220
.4byte sub_08059290
.4byte sub_080592A4
.4byte sub_08059368
.4byte sub_0805938C
.4byte sub_08059424
.4byte sub_0805947C
.ifndef EU
.4byte sub_080594DC
.ifndef JP
.4byte sub_08059548
.endif
.endif
gUnk_08108354:: @ 08108354
.incbin "baserom.gba", 0x108354, 0x000002C
gUnk_08108380:: @ 08108380
.4byte script_0800E600
.4byte script_0800E62C
.4byte script_0800E658
.4byte script_0800E684

View File

@ -9,7 +9,9 @@ typedef struct {
u8 unk;
u8 regret;
u16 localFlagOffset;
u8 filler[10];
u8 filler[4];
u16 unk_0a;
u8 filler3[4];
u16 field_0x10;
u16 curPortalX;
u16 curPortalY;
@ -20,7 +22,8 @@ typedef struct {
bool8 playShrinkSeq;
u8 unk1A;
u8 filler2[13];
u8 filler4[0x835];
u8 field_0x28;
u8 filler4[0x834];
u32 musicIndex;
u32 pMusicIndex;
u8 filler5[0x20];

View File

@ -281,4 +281,12 @@ extern bool32 sub_08077EFC(ItemBehavior*);
extern void sub_08078E84(Entity*, Entity*);
extern void sub_080042D0(Entity*, u32, u16);
extern u32 sub_080002A8(u32, u32, u32);
extern void CreateDustAt(u32, u32, u32);
extern void sub_080806BC(u32, u32, u32, u32);
extern void sub_080186C0(u32);
extern void sub_0801855C(void);
#endif

View File

@ -103,6 +103,15 @@ typedef struct {
u16 unk_3e;
} ManagerE;
typedef struct {
Manager manager;
u8 unk_20[0x18];
s16 unk_38;
s16 unk_3a;
u16 unk_3c;
u16 unk_3e;
} ManagerF;
typedef struct Manager11 {
Manager manager;
u8 unk_20[0x1C];
@ -154,7 +163,7 @@ extern void ManagerB_Main();
extern void ManagerC_Main();
extern void ManagerD_Main();
extern void ManagerE_Main();
extern void ManagerF_Main();
extern void sub_08058ECC(ManagerF*);
extern void Manager10_Main();
extern void Manager11_Main(Manager11*);
extern void Manager12_Main();

View File

@ -23,7 +23,8 @@ typedef struct {
/*0x0C*/ s16 roomScrollY;
/*0x0E*/ u8 unk5;
/*0x0F*/ u8 unk6;
/*0x10*/ u8 filler[4];
/*0x10*/ u8 unk_10;
/*0x11*/ u8 filler[3];
/*0x14*/ u8 screenShakeMagnitude;
/*0x15*/ u8 unk7;
/*0x16*/ u16 screenShakeTime;
@ -37,7 +38,10 @@ typedef struct {
} RoomControls;
typedef struct {
u8 filler[4];
u8 field_0x0;
u8 filler_0x1;
u8 field_0x2;
u8 field_0x3;
u8 field_0x4;
u8 filler1[1];
u8 itemForSaleIndex;

View File

@ -1203,7 +1203,7 @@ SECTIONS {
src/manager/managerB.o(.rodata);
src/manager/managerC.o(.rodata);
data/const/manager/managerD.o(.rodata);
data/const/manager/managerF.o(.rodata);
src/manager/managerF.o(.rodata);
data/const/manager/manager10.o(.rodata);
data/const/manager/manager12.o(.rodata);
data/const/manager/manager13.o(.rodata);

View File

@ -171,11 +171,11 @@ NONMATCH("asm/non_matching/sub_08054524.inc", void sub_08054524(void)) {
END_NONMATCH
void sub_08054564(void) {
gRoomVars.filler[2] = 1;
gRoomVars.field_0x2 = 1;
}
void sub_08054570(void) {
gRoomVars.filler[2] = 0;
gRoomVars.field_0x2 = 0;
}
#ifdef EU

View File

@ -42,7 +42,7 @@ void sub_08080930(void)
gRoomControls.unk3 = 5;
gRoomControls.unk4 = 0;
gRoomControls.unk2 = 2;
gRoomControls.filler[0] = 0;
gRoomControls.unk_10 = 0;
sub_0805E5A8();
}

View File

@ -6,7 +6,6 @@
extern u32 sub_080002E0(u32, u32);
extern u32 sub_080002C8(u16, u8);
extern u16 sub_080002A8(u32, u32, u32);
extern u16 sub_080002D4(u32, u32, u32);
extern void sub_0804AA1C(Entity*);
extern Entity* sub_08049DF4(u32);

View File

@ -4,7 +4,7 @@
void (*const gManagerFunctions[])() = {
NULL, Manager1_Main, Manager2_Main, Manager3_Main, Manager4_Main, Manager5_Main, Manager6_Main,
Manager7_Main, Manager8_Main, Manager9_Main, ManagerA_Main, ManagerB_Main, ManagerC_Main, ManagerD_Main,
ManagerE_Main, ManagerF_Main, Manager10_Main, Manager11_Main, Manager12_Main, Manager13_Main, Manager14_Main,
ManagerE_Main, sub_08058ECC, Manager10_Main, Manager11_Main, Manager12_Main, Manager13_Main, Manager14_Main,
Manager15_Main, Manager16_Main, Manager17_Main, Manager18_Main, Manager19_Main, Manager1A_Main, Manager1B_Main,
Manager1C_Main, Manager1D_Main, Manager1E_Main, Manager1F_Main, Manager20_Main, Manager21_Main, Manager22_Main,
Manager23_Main, Manager24_Main, Manager25_Main, Manager26_Main, Manager27_Main, Manager28_Main, Manager29_Main,

View File

@ -25,8 +25,6 @@ void sub_0805BEC4(Manager23*);
void sub_0805BE70(Manager23*, u32);
extern void CreateDustAt(s32, s32, u32);
void Manager23_Main(Manager* this) {
gUnk_08108CCC[this->unk_0a](this);
}

View File

@ -43,7 +43,6 @@ void sub_080583EC(ManagerA* this) {
}
extern void sub_0805E544(void);
extern void sub_080186C0(u16);
u32 sub_0805848C(ManagerA*);
void sub_080585DC(ManagerA*);
@ -150,7 +149,7 @@ void sub_08058514(ManagerA* this) {
extern void sub_0801855C(void);
void sub_080585B0(ManagerA* this) {
if (gArea.filler4[0] != 0xFF) {
if (gArea.field_0x28 != 0xFF) {
DeleteThisEntity();
}
if (CheckFlags(this->unk_3c)) {

436
src/manager/managerF.c Normal file
View File

@ -0,0 +1,436 @@
#include "global.h"
#include "manager.h"
#include "flags.h"
#include "audio.h"
#include "room.h"
#include "player.h"
#include "functions.h"
#include "area.h"
#include "textbox.h"
#include "script.h"
#include "utils.h"
void sub_08058ECC(ManagerF*);
void sub_08058EE4(ManagerF*);
void sub_08058FB0(ManagerF*);
void sub_08059094(ManagerF*);
void sub_080590E0(ManagerF*);
void sub_08059124(ManagerF*);
void sub_080591CC(ManagerF*);
void sub_08059220(ManagerF*);
void sub_08059290(ManagerF*);
void sub_080592A4(ManagerF*);
void sub_08059368(ManagerF*);
void sub_0805938C(ManagerF*);
void sub_08059424(ManagerF*);
void sub_0805947C(ManagerF*);
#ifndef EU
void sub_080594DC(ManagerF*);
#endif
#if defined(USA) || defined(DEMO)
void sub_08059548(ManagerF*);
#endif
// clang-format off
void (*const gUnk_08108314[])(ManagerF*) = {
sub_08058EE4,
sub_08058FB0,
sub_08058FB0, // dup
sub_08059094,
sub_080590E0,
sub_08059124,
sub_080591CC,
sub_08059220,
sub_08059290,
sub_080592A4,
sub_08059368,
sub_0805938C,
sub_08059424,
sub_0805947C,
#ifndef EU
sub_080594DC,
#endif
#if defined(USA) || defined(DEMO)
sub_08059548,
#endif
};
// clang-format on
typedef struct {
u16 x;
u16 y;
u16 width;
u16 height;
u16 unk_08;
} PACKED __attribute__((aligned(2))) ManagerF_HelperStruct;
const ManagerF_HelperStruct gUnk_08108354[] = {
{ 0xF0, 0xB0, 0xF0, 0xB0, 0x100 },
{ 0x188, 0x190, 0x28, 0x30, 0x100 },
{ 0xF0, 0x340, 0xF0, 0xB0, 0x80 },
{ 0x180, 0x278, 0x60, 0x38, 0x80 },
};
const u32 gUnk_08108354_terminator = 0xFFFF; // terminator for the previous array
extern u16 script_0800E600[];
extern u16 script_0800E62C[];
extern u16 script_0800E658[];
extern u16 script_0800E684[];
u16* const gUnk_08108380[] = {
script_0800E600,
script_0800E62C,
script_0800E658,
script_0800E684,
};
void sub_08058F44(u32, u32, u32);
void sub_08058F84(u32, u32);
void sub_08059064(ManagerF*);
void sub_080592EC(ManagerF*);
void sub_0805930C(ManagerF*);
u32 sub_080593CC(ManagerF*);
void sub_0805E4E0(ManagerF*, u32);
// to be moved to headers
extern EntityData gUnk_080F4B88[];
void sub_08058ECC(ManagerF* this) {
gUnk_08108314[this->manager.unk_0a](this);
}
void sub_08058EE4(ManagerF* this) {
if (!this->manager.action)
this->manager.action = 1;
if (!CheckRoomFlag(this->manager.unk_0b))
return;
sub_08058F44(0x128, 0x68, this->manager.unk_0b + 1);
sub_08058F44(0x158, 0x68, this->manager.unk_0b + 2);
sub_08058F44(0x128, 0x98, this->manager.unk_0b + 3);
sub_08058F44(0x158, 0x98, this->manager.unk_0b + 4);
SoundReq(0x124);
DeleteThisEntity();
}
void sub_08058F44(u32 unk0, u32 unk1, u32 unk2) {
if (CheckRoomFlag(unk2))
return;
if (sub_080002A8(unk0, unk1, 1) != 0x61)
return;
SetTileType(0x26, ((unk0 >> 4) & 0x3F) | (((unk1 >> 4) & 0x3F) << 6), 1);
sub_08058F84(unk0, unk1);
}
void sub_08058F84(u32 unk0, u32 unk1) {
Entity* tmp;
tmp = CreateObject(0x21, 0, 0);
if (!tmp)
return;
tmp->x.HALF.HI = gRoomControls.roomOriginX + unk0;
tmp->y.HALF.HI = gRoomControls.roomOriginY + unk1;
}
void sub_08058FB0(ManagerF* this) {
switch (this->manager.action) {
case 0:
this->manager.action = 1;
if (this->manager.unk_0a == 1) {
this->manager.unk_0d = 7;
this->manager.unk_0f = 6;
} else {
this->manager.unk_0d = 8;
this->manager.unk_0f = 2;
}
if (CheckFlags(this->unk_3e)) {
DeleteManager(&this->manager);
}
break;
case 1:
if (CheckFlags(this->unk_3e)) {
this->manager.action = 2;
this->manager.unk_0e = 120;
sub_0805E4E0(this, 0xF0);
sub_08059064(this);
}
break;
case 2:
if (this->manager.unk_0e == 90) {
sub_08078A90(2);
sub_08077B20();
}
if (this->manager.unk_0e == 60) {
gPlayerEntity.animationState = this->manager.unk_0f;
}
if (!--this->manager.unk_0e) {
this->manager.action = 3;
MenuFadeIn(5, this->manager.unk_0d);
}
break;
default:
SetFlag(this->unk_3e);
sub_08078A90(1);
DeleteThisEntity();
}
}
void sub_08059064(ManagerF* this) {
Entity* tmp;
tmp = CreateObject(0, 0x53, 0);
if (!tmp)
return;
tmp->actionDelay = 2;
tmp->x.HALF.HI = this->unk_38 + gRoomControls.roomOriginX;
tmp->y.HALF.HI = this->unk_3a + gRoomControls.roomOriginY;
}
void sub_08059094(ManagerF* this) {
u32 tmp = 0;
if (!this->manager.action) {
this->manager.action = 1;
if (CheckLocalFlag(0x60)) {
tmp = 1;
} else {
SetLocalFlag(0x5F);
}
} else {
if (CheckLocalFlag(0x60)) {
ClearLocalFlag(0x5F);
tmp = 1;
}
}
if (tmp) {
LoadRoomEntityList(gUnk_080F4B88);
DeleteManager(&this->manager);
}
}
void sub_080590E0(ManagerF* this) {
if (!this->manager.action) {
this->manager.action = 1;
sub_0805E3A0(this, 6);
}
if (CheckLocalFlag(0x6c)) {
if (CheckLocalFlag(0x4b)) {
SetLocalFlag(0x4a);
} else {
ClearLocalFlag(0x4a);
}
} else {
ClearLocalFlag(0x4a);
}
}
void sub_08059124(ManagerF* this) {
switch (this->manager.action) {
default:
if (!--this->manager.unk_0e) {
CreateDustAt(this->unk_38, this->unk_3a, this->manager.unk_0b);
sub_0807BA8C(((this->unk_38 >> 4) & 0x3f) | ((this->unk_3a >> 4) & 0x3f) << 6, this->manager.unk_0b);
SoundReq(0xcd);
DeleteThisEntity();
}
break;
case 0:
if (CheckFlags(this->unk_3e)) {
DeleteThisEntity();
}
this->manager.action = 1;
SetTileType(0x365, ((this->unk_38 >> 4) & 0x3f) | ((this->unk_3a >> 4) & 0x3f) << 6, this->manager.unk_0b);
break;
case 1:
if (CheckFlags(this->unk_3e)) {
sub_0805E4E0(this, 0x4b);
this->manager.unk_0e = 0x2d;
this->manager.action++;
}
}
}
void sub_080591CC(ManagerF* this) {
if (!this->manager.action) {
this->manager.action = 1;
this->manager.unk_0b = CheckFlags(this->unk_3e);
if (this->manager.unk_0b) {
gRoomVars.field_0xc = this->unk_3a;
} else {
gRoomVars.field_0xc = this->unk_38;
}
} else {
u32 tmp = CheckFlags(this->unk_3e);
if (this->manager.unk_0b != tmp) {
this->manager.unk_0b = tmp;
if (tmp) {
gRoomVars.field_0xc = this->unk_3a;
} else {
gRoomVars.field_0xc = this->unk_38;
}
}
}
}
void sub_08059220(ManagerF* this) {
const ManagerF_HelperStruct* data;
gRoomVars.field_0xc = 0;
for (data = gUnk_08108354; data->x != 0xFFFF; data++) {
if (CheckPlayerInRegion(data->x, data->y, data->width, data->height)) {
gRoomVars.field_0xc = data->unk_08;
}
}
if (!this->manager.action) {
this->manager.action = 1;
gArea.unk_0a = gRoomVars.field_0xc;
}
}
void sub_08059278() {
ManagerF* tmp;
tmp = (ManagerF*)FindEntityByID(0x9, 0xF, 0x6);
if (tmp) {
sub_08058ECC(tmp);
}
}
void sub_08059290(ManagerF* this) {
this->manager.action = 1;
gRoomControls.cameraTarget = &gPlayerEntity;
}
void sub_080592A4(ManagerF* this) {
if (!this->manager.action) {
this->manager.action = 1;
if (CheckFlags(this->unk_3e)) {
sub_080592EC(this);
DeleteThisEntity();
}
} else {
if (CheckFlags(this->unk_3e)) {
sub_080592EC(this);
sub_0805930C(this);
#ifndef EU
SoundReq(0x16E);
#endif
DeleteThisEntity();
}
}
}
void sub_080592EC(ManagerF* this) {
SetDirtTile(((this->unk_38 >> 4) & 0x3F) | (((this->unk_3a >> 4) & 0x3F) << 6));
}
void sub_0805930C(ManagerF* this) {
Entity* tmp;
#ifdef EU
tmp = CreateObject(0xF, 0x43, 0x0);
#else
tmp = CreateObject(0xF, 0x43, 0x40);
#endif
if (!tmp)
return;
tmp->x.HALF.HI = this->unk_38 + gRoomControls.roomOriginX;
tmp->y.HALF.HI = this->unk_3a + gRoomControls.roomOriginY;
tmp->collisionLayer = 1;
}
void SetDirtTile(u32 tile) {
SetTileType(0x1d, tile, 1);
SetTileType(0, tile, 2);
SetTileType(0, tile - 0x40, 2);
}
void sub_08059368(ManagerF* this) {
this->manager.action = 1;
if (this->unk_3c == gCurrentTextBox._28) {
SetFlag(this->unk_3e);
DeleteThisEntity();
}
}
void sub_0805938C(ManagerF* this) {
if (sub_080593CC(this)) {
if (++this->manager.unk_0e >= 8) {
sub_080806BC(this->unk_38 - gRoomControls.roomOriginX, this->unk_3a - gRoomControls.roomOriginY, 0xFF, 0xA);
}
} else {
this->manager.unk_0e = 0;
}
}
u32 sub_080593CC(ManagerF* this) {
if (!(gPlayerState.flags.all & 0x80) && gPlayerState.swimState != 0 && gPlayerEntity.animationState == 0 &&
(gPlayerState.field_0x90.HALF.LO & 0xF00) == 0x400) {
return sub_0806FCB8(&gPlayerEntity, this->unk_38, this->unk_3a + 0xC, 6);
}
return 0;
}
void sub_08059424(ManagerF* this) {
Entity* tmp;
if (CheckFlags(this->unk_3e)) {
DeleteThisEntity();
}
if (!CheckFlags(this->unk_3c))
return;
tmp = CreateObject(0xF, 0x35, 0);
if (!tmp)
return;
tmp->collisionLayer = 2;
tmp->x.HALF.HI = this->unk_38 + gRoomControls.roomOriginX;
tmp->y.HALF.HI = this->unk_3a + gRoomControls.roomOriginY;
EnqueueSFX(0x1B0);
DeleteThisEntity();
}
void sub_0805947C(ManagerF* this) {
if (!CheckFlags(this->unk_3e)) {
sub_08078A90(3);
if (gRoomControls.unk2)
return;
if (gRoomVars.field_0x0) {
StartPlayerScript(gUnk_08108380[gRoomControls.unk_10]);
} else {
StartPlayerScript(gUnk_08108380[gPlayerEntity.animationState >> 1]);
}
}
DeleteThisEntity();
}
#ifndef EU
void sub_080594DC(ManagerF* this) {
switch (this->manager.action) {
case 0:
this->manager.action = 1;
// fall through
case 1:
if (!GetInventoryValue(6))
return;
if (CheckLocalFlagByOffset(0x8c0, 0x85))
return;
this->manager.action = 2;
sub_080186C0(0xB0F);
break;
case 2:
default:
if (gArea.field_0x28 != 0xFF) {
DeleteThisEntity();
}
if (CheckLocalFlagByOffset(0x8c0, 0x85)) {
sub_0801855C();
DeleteThisEntity();
}
}
}
#endif
#if defined(USA) || defined(DEMO)
void sub_08059548(ManagerF* this) {
sub_0805E3A0(this, 6);
if (gPlayerEntity.action == 0x16) {
DeleteThisEntity();
}
gInput.heldKeys |= 0x4;
}
#endif

View File

@ -117,7 +117,7 @@ void sub_08060A00(Entity* this) {
this->action = 1;
this->spriteSettings.b.draw = 1;
this->speed = 0x120;
tmp = gRoomControls.filler[0];
tmp = gRoomControls.unk_10;
this->animationState = tmp * 2;
InitAnimationForceUpdate(this, tmp << 0x19 >> 0x19); // TODO some conversion between u8 and u32?
this->frameDuration = (Random() & 0x7f) + 0x80;

View File

@ -308,7 +308,7 @@ void sub_0806AA18(Entity* this) {
ASM_FUNC("asm/non_matching/rem/sub_0806AA50.inc", void sub_0806AA50(Entity* this, ScriptExecutionContext* context))
void sub_0806AB74(Entity* this) {
gRoomVars.filler[3] = 1;
gRoomVars.field_0x3 = 1;
if ((s32)(this->y.HALF.HI - (u32)gRoomControls.roomOriginY) < 0xa8) {
this->y.HALF.HI = gRoomControls.roomOriginY + 0xa8;
}

View File

@ -1375,7 +1375,7 @@ void sub_080724DC(Entity* this) {
} else {
this->spriteSettings.b.draw = 3;
this->subAction = 1;
if (gRoomVars.filler[0] == 0) {
if (gRoomVars.field_0x0 == 0) {
if (gPlayerState.flags.all & 0x80) {
gPlayerState.field_0x8 = 0xc18;
} else {

View File

@ -521,7 +521,7 @@ void sub_0804BA0C(void) {
if (gSave.unk8 < 8) {
LoadRoomEntityList(&gUnk_080D7038);
}
if (gRoomVars.filler[0] == 0) {
if (gRoomVars.field_0x0 == 0) {
sub_08052CA4(2, 0, 0x2c8, 0xa8);
}
}