Manager Struct Split to not include structure of manager-specific data
Changed some function signatures to work with managers
This commit is contained in:
Ibot02 2020-08-21 02:53:52 +02:00
parent 6e53face64
commit f7b1a516dd
13 changed files with 147 additions and 100 deletions

View File

@ -4,6 +4,7 @@
#include "global.h"
#include "entity.h"
#include "manager.h"
#include "position.h"
#include "player.h"
#include "structures.h"
@ -61,7 +62,7 @@ extern void sub_0805EC60();
extern void sub_080873D0();
extern u8 sub_080045D4(s16, s16, u16, u16);
extern void sub_0806F69C(Entity*);
extern void sub_0805E3A0(Entity*, u32);
extern void sub_0805E3A0(void*, u32);
extern void sub_0806D0B0(Entity*);
extern void sub_0807DD64(Entity*);
extern void sub_0807DDAC(Entity*, u32);
@ -196,8 +197,8 @@ extern u32 sub_0807953C(void);
extern void ResetPlayer(void);
extern void sub_080A29BC(Entity*);
extern void sub_080AE068(Entity*);
extern Entity* GetEmptyManager(void);
extern void AppendEntityToList(Entity*, u32);
extern Manager* GetEmptyManager(void);
extern void AppendEntityToList(void*, u32);
extern u32 sub_0800445C(Entity*);
extern void sub_0807A108(void);
extern void sub_0801766C(Entity*);
@ -217,7 +218,6 @@ extern void sub_0807D20C(u32, char*, u32);
extern u32 sub_0807CF88(u32, u8*);
extern u32 sub_0807D008(u32, void*);
extern void sub_0807D184(u32, char*);
extern void sub_0805E3A0(Entity*, u32);
extern u32 sub_0806F520();
extern void sub_0806F4E8();
extern u32 sub_0806F3E4(Entity*);
@ -255,4 +255,4 @@ extern u32 sub_080044EC(Entity*, u32);
extern u32 sub_080002B8(Entity*);
extern u32 sub_08049F84(Entity*, u32);
extern void sub_0802F45C(Entity*);
#endif
#endif

View File

@ -2,6 +2,7 @@
#define MANAGER_H
#include "global.h"
#include "entity.h"
union SplitSHWord {
s16 SHWORD;
@ -10,33 +11,38 @@ union SplitSHWord {
} PACKED HALF;
} PACKED;
typedef struct {
u8 unk_00[0x0a];
u8 unk_0a;
u8 unk_0b;
u8 unk_0c;
u8 unk_0d;
u8 unk_0e;
u8 unk_0f[0x11];
u16 unk_20;
u16 unk_22;
u16 unk_24;
u16 unk_26;
u8 unk_28[0x0D];
u8 unk_35;
u16 unk_36;
union SplitSHWord unk_38;
union SplitSHWord unk_3a;
u16 unk_3c;
u16 unk_3e;
typedef struct Manager {
/*0x00*/ struct Manager* previous;
/*0x00*/ struct Manager* next;
/*0x08*/ u8 type;
/*0x09*/ u8 subtype;
/*0x0a*/ u8 unk_0a;
/*0x0b*/ u8 unk_0b;
/*0x0c*/ u8 action;
/*0x0d*/ u8 unk_0d;
/*0x0e*/ u8 unk_0e;
/*0x0f*/ u8 unk_0f[0x5];
/*0x14*/ struct Manager * parent;
/*0x18*/ u8 unk_18[0x8];
// union SplitHWord unk_20;
// u16 unk_22;
// u16 unk_24;
// u16 unk_26;
// u8 unk_28[0x0D];
// u8 unk_35;
// u16 unk_36;
// union SplitSHWord unk_38;
// union SplitSHWord unk_3a;
// u16 unk_3c;
// u16 unk_3e;
} Manager;
typedef struct {
u16 field_0x00;
u16 field_0x02;
u8 field_0x04;
u8 field_0x05;
u8 field_0x06;
u16 posX;
u16 posY;
u8 width;
u8 height;
u8 unk_06;
union {
u8 all;
struct {
@ -45,8 +51,55 @@ typedef struct {
u8 unk2 : 1;
u8 unk3 : 3;
} PACKED b;
} PACKED field_0x07;
} UnkManagerHelperStruct;
} PACKED unk_07;
} Manager6WarpData;
typedef struct {
Manager manager;
Manager6WarpData* warpList;
} Manager6;
typedef struct {
Manager manager;
u16 unk_20;
u16 unk_22;
u16 unk_24;
u16 unk_26;
u8 unk_28[0x0D];
u8 unk_35;
u16 unk_36;
u8 unk_38;
u8 unk_39;
u8 unk_3a;
u8 unk_3b;
u16 unk_3c;
u16 unk_3e;
} ManagerA;
typedef struct {
Manager manager;
u8 unk_20;
u8 unk_21[0x14];
u8 unk_35;
u8 unk_36[0x4];
u16 unk_3a;
u16 unk_3c;
u16 unk_3e;
} ManagerB;
typedef struct {
Manager manager;
Entity* enemies[8];
} ManagerBHelper;
typedef struct {
Manager manager;
u8 unk_20[0x18];
s16 unk_38;
s16 unk_3a;
u16 unk_3c;
u16 unk_3e;
} ManagerE;
typedef struct {
u16 unk_00;

View File

@ -17,7 +17,6 @@ Entity* sub_08077C94(ItemBehavior*, u32);
void* sub_08077C54(UnkItemStruct* unk);
Entity* CreatePlayerBomb(ItemBehavior*, u32);
extern Entity* sub_0805E744();
extern void AppendEntityToList(Entity*, u32);
extern struct_0811BE48 gUnk_0811BE48[];
@ -137,4 +136,4 @@ Entity * sub_08077CF8(u32 subtype, u32 form, u32 parameter, u32 unk)
NAKED
void sub_08077D38(ItemBehavior *beh, u32 arg1) {
asm(".include \"asm/non_matching/sub_08077D38.inc\"");
}
}

View File

@ -7,7 +7,7 @@
extern void (*gUnk_08107C70[])(Manager*);
void sub_08057854(Manager* this) {
gUnk_08107C70[this->unk_0c](this);
gUnk_08107C70[this->action](this);
}
extern void sub_080805F8(void);
@ -47,7 +47,7 @@ void sub_0805786C(Manager* this) {
tmp++;
}
}
this->unk_0c = 1;
this->action = 1;
}
extern u32 sub_0805795C(Manager*, DiggingCaveEntrance*);

View File

@ -8,25 +8,25 @@ extern u32 CheckPlayerInRegion(u16, u16, u8, u8);
extern void DoExitTransition(void*);
extern void DeleteManager(Entity*);
void sub_08057CB4(Entity * this) {
void sub_08057CB4(Manager6 * this) {
u32 tmp;
UnkManagerHelperStruct* i;
if (this->action == 0){
this->action = 1;
this->field_0x20 = (s32) GetCurrentRoomProperty(this->entityType.form);
if (this->field_0x20 == 0) {
DeleteManager(this);
Manager6WarpData* i;
if (this->manager.action == 0){
this->manager.action = 1;
this->warpList = GetCurrentRoomProperty(this->manager.unk_0a);
if (!this->warpList) {
DeleteManager((Entity*) this);
return;
}
}
if (this->actionDelay == 0 || gPlayerState.field_0x10[2] == 0x1e) {
for (i = ((UnkManagerHelperStruct*) this->field_0x20);i->field_0x00 != 0xFFFF; i++) {
tmp = (i->field_0x07.all & 0x3);
if (this->manager.unk_0e == 0 || gPlayerState.field_0x10[2] == 0x1e) {
for (i = this->warpList; i->posX != 0xFFFF; i++) {
tmp = (i->unk_07.all & 0x3);
if (((tmp & (gPlayerEntity.collisionLayer)) != 0) &&
(((gPlayerState.flags.all & 0x80) != 0) || ((i->field_0x07.b.unk2) != 0)) &&
(CheckPlayerInRegion(i->field_0x00,i->field_0x02,i->field_0x04,i->field_0x05) != 0) &&
(((gPlayerState.flags.all & 0x80) != 0) || ((i->unk_07.b.unk2) != 0)) &&
(CheckPlayerInRegion(i->posX,i->posY,i->width,i->height) != 0) &&
(gPlayerEntity.height.HALF.HI == 0)) {
DoExitTransition(GetCurrentRoomProperty(i->field_0x06));
DoExitTransition(GetCurrentRoomProperty(i->unk_06));
}
}
}

View File

@ -9,36 +9,36 @@
extern void (*gUnk_081081F4[])(Manager*);
void sub_08058380(Manager* this) {
gUnk_081081F4[this->unk_0c](this);
gUnk_081081F4[this->action](this);
}
extern void sub_0805E3A0(Manager*, u32);
void sub_08058398(Manager* this) {
void sub_08058398(ManagerA* this) {
if (CheckFlags(this->unk_3c) != 0) {
DeleteThisEntity();
}
this->unk_24 = this->unk_3a.HALF.LO<<3;
this->unk_26 = this->unk_3a.HALF.HI<<3;
this->unk_20 = this->unk_24 + (this->unk_38.HALF.LO<<4);
this->unk_22 = this->unk_26 + (this->unk_38.HALF.HI<<4);
sub_0805E3A0(this, 0x06);
this->unk_24 = this->unk_3a<<3;
this->unk_26 = this->unk_3b<<3;
this->unk_20 = this->unk_24 + (this->unk_38<<4);
this->unk_22 = this->unk_26 + (this->unk_39<<4);
sub_0805E3A0(&this->manager, 0x06);
if (this->unk_3e == 0) {
this->unk_0c = 2;
this->manager.action = 2;
} else {
this->unk_0c = 1;
this->manager.action = 1;
}
}
void sub_08058408(Manager*);
void sub_08058408(ManagerA*);
void sub_080583EC(Manager* this) {
void sub_080583EC(ManagerA* this) {
if (CheckFlags(this->unk_3e) != 0) {
this->unk_0c = 2;
this->manager.action = 2;
sub_08058408(this);
}
}
@ -50,15 +50,15 @@ extern void sub_08078AA8(u32, u32);
extern void sub_080186C0(u16);
extern void sub_08078B48(void);
u32 sub_0805848C(Manager*);
void sub_080585DC(Manager*);
u32 sub_0805848C(ManagerA*);
void sub_080585DC(ManagerA*);
void sub_08058408(Manager* this){
void sub_08058408(ManagerA* this){
u32 tmp2;
tmp2 = (gPlayerState.flags.all & 0x08);
if (tmp2 != 0) return;
if (!CheckPlayerInRegion(this->unk_20, this->unk_22, this->unk_24, this->unk_26)) return;
switch (this->unk_0a) {
switch (this->manager.unk_0a) {
case 1:
return;
case 2:
@ -71,20 +71,20 @@ void sub_08058408(Manager* this){
sub_08078A90(3);
sub_08078B48();
sub_0805E544();
this->unk_0c = 3;
this->unk_0d = 0;
this->unk_0e = 0x1e;
this->manager.action = 3;
this->manager.unk_0d = 0;
this->manager.unk_0e = 0x1e;
return;
case 3:
this->unk_0c = 4;
this->unk_0d = tmp2;
this->manager.action = 4;
this->manager.unk_0d = tmp2;
sub_080186C0(this->unk_36);
return;
}
}
u32 sub_0805848C(Manager* this) {
u32 sub_0805848C(ManagerA* this) {
switch (gPlayerState.field_0xa8[0]-5) {
case 0:
case 2:
@ -119,8 +119,8 @@ u32 sub_0805848C(Manager* this) {
extern void UnfreezeTime(void);
void sub_08058514(Manager* this) {
switch (this->unk_0d) {
void sub_08058514(ManagerA* this) {
switch (this->manager.unk_0d) {
case 1:
if ((gPlayerState.flags.all & 0x1235) != 0)
return;
@ -128,13 +128,13 @@ void sub_08058514(Manager* this) {
return;
gPlayerState.jumpStatus = 0;
sub_08078AA8(this->unk_36, this->unk_35);
this->unk_0d++;
this->unk_0e = 0x1E;
this->manager.unk_0d++;
this->manager.unk_0e = 0x1E;
return;
case 0:
case 2:
if (((--this->unk_0e)<<0x18) == 0) {
this->unk_0d++;
if (((--this->manager.unk_0e)<<0x18) == 0) {
this->manager.unk_0d++;
}
return;
case 3:
@ -152,7 +152,7 @@ void sub_08058514(Manager* this) {
extern void sub_0801855C(void);
void sub_080585B0(Manager* this) {
void sub_080585B0(ManagerA* this) {
if (gArea.filler4[0] != 0xFF) {
DeleteThisEntity();
}
@ -161,7 +161,7 @@ void sub_080585B0(Manager* this) {
DeleteThisEntity();
}
}
void sub_080585DC(Manager* this) {
void sub_080585DC(ManagerA* this) {
if (CheckFlags(this->unk_3c)) {
DeleteThisEntity();
}

View File

@ -12,28 +12,28 @@ extern void sub_08078A90(u32);
extern void sub_08078B48(void);
extern void PlaySFX(u32);
void sub_08058E60(Manager* this) {
if (!this->unk_0c) {
this->unk_0c = 1;
void sub_08058E60(ManagerE* this) {
if (!this->manager.action) {
this->manager.action = 1;
if (CheckFlags(this->unk_3e)) {
DeleteManager(this);
DeleteManager(&this->manager);
return;
}
}
if (!CheckFlags(this->unk_3e))
return;
if (this->unk_0b != 0) {
this->unk_0b = 0;
if (this->manager.unk_0b != 0) {
this->manager.unk_0b = 0;
sub_08078A90(0xff);
sub_08078B48();
}
if (this->unk_3a.SHWORD == 0){
if (this->unk_38.SHWORD != 0) {
PlaySFX(this->unk_38.SHWORD);
if (this->unk_3a == 0){
if (this->unk_38 != 0) {
PlaySFX(this->unk_38);
}
LoadRoomEntityList(GetCurrentRoomProperty(this->unk_0a));
LoadRoomEntityList(GetCurrentRoomProperty(this->manager.unk_0a));
DeleteThisEntity();
} else {
this->unk_3a.SHWORD -= 1;
this->unk_3a -= 1;
}
}

View File

@ -4,7 +4,6 @@
#include "npc.h"
#include "player.h"
extern void sub_0805E3A0(Entity*, u32);
extern u32 sub_0801E99C(Entity*);
extern void sub_08078784(Entity*, u32);
extern void sub_0807DD50(Entity*);
@ -84,4 +83,4 @@ void sub_0805FF18(Entity *this)
if (UpdateFuseInteraction(this)) {
this->action = 1;
}
}
}

View File

@ -92,13 +92,13 @@ void sub_08069660(Entity *this)
void sub_08069684(void)
{
Entity *mgr;
Manager *mgr;
if (FindEntityInListBySubtype(9, 0x31, 8) == NULL) {
mgr = GetEmptyManager();
if (mgr != NULL) {
mgr->entityType.type = 9;
mgr->entityType.subtype = 0x31;
mgr->type = 9;
mgr->subtype = 0x31;
AppendEntityToList(mgr, 8);
}
}
@ -140,4 +140,4 @@ u32 sub_080696BC(Entity* this)
uVar1 = 4;
}
return gUnk_08111BA0[uVar1 * 3 + iVar3];
}
}

View File

@ -8,7 +8,6 @@ extern void sub_0806ED78(Entity*);
extern void sub_08068780(Entity*);
extern void sub_08078778(Entity*);
extern u32 Random(void);
extern void sub_0805E3A0(Entity*, u32);
extern void sub_0807DD50(Entity*);
extern void sub_0806F118(Entity*);
extern void sub_0807DDAC(Entity*, u32);
@ -170,4 +169,4 @@ void Melari_Fusion(Entity* this) {
}
void nullsub_502(Entity* this) {
}
}

View File

@ -20,7 +20,6 @@ extern s32 sub_0806ED9C(Entity*, u32, u32);
extern void sub_0806EE20(Entity*);
extern void sub_0806ED78(Entity*);
extern u32 sub_080040A8(Entity*);
extern void sub_0805E3A0(Entity*, u32);
extern u32 sub_0801E99C(Entity*);
extern void sub_0807DD50(Entity*);
extern void sub_0806F118(Entity*);

View File

@ -6,7 +6,6 @@ extern void sub_0807DDAC(Entity*, u32);
extern void sub_0807DDE4(Entity*);
extern void sub_0806ED78(Entity*);
extern void PlaySFX(u32);
extern void sub_0805E3A0(Entity*, u32);
extern void sub_0806A8C8(Entity*);
extern void sub_0807DD94(Entity*, u32);

View File

@ -5,7 +5,6 @@
#include "flags.h"
extern void PrependEntityToList(Entity*, u32);
extern void sub_0805E3A0(Entity*, u32);
extern void sub_0807DD50(Entity*);
extern void sub_0807DD94(Entity*, u32);
extern Entity* FindEntityBySubtype(u32, u32);