summaryrefslogtreecommitdiff
path: root/src/manager
diff options
context:
space:
mode:
authoroctorock <79596758+octorock@users.noreply.github.com>2021-09-26 14:57:42 +0200
committeroctorock <79596758+octorock@users.noreply.github.com>2021-09-26 22:09:22 +0200
commitc603199e0aedc258a3b6310457fa7f2dd045663f (patch)
tree3a2bca05d7662046935db590c080dae2682650dd /src/manager
parent9283aa5afecdcb4632d95b40f1c0f0a2bbb35b57 (diff)
Unsplit managerF to avoid conflicts with the pr of Ibot02
Diffstat (limited to 'src/manager')
-rw-r--r--src/manager/manager23.c2
-rw-r--r--src/manager/managerA.c3
-rw-r--r--src/manager/managerF.c436
3 files changed, 437 insertions, 4 deletions
diff --git a/src/manager/manager23.c b/src/manager/manager23.c
index 949ccf3f..1d895f30 100644
--- a/src/manager/manager23.c
+++ b/src/manager/manager23.c
@@ -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);
}
diff --git a/src/manager/managerA.c b/src/manager/managerA.c
index ec6bfd05..3f1b841e 100644
--- a/src/manager/managerA.c
+++ b/src/manager/managerA.c
@@ -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)) {
diff --git a/src/manager/managerF.c b/src/manager/managerF.c
new file mode 100644
index 00000000..a4f5c78f
--- /dev/null
+++ b/src/manager/managerF.c
@@ -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