diff options
| author | octorock <79596758+octorock@users.noreply.github.com> | 2022-02-16 17:41:35 +0100 |
|---|---|---|
| committer | octorock <79596758+octorock@users.noreply.github.com> | 2022-02-18 20:48:58 +0100 |
| commit | 0aebbae239abcfcd2dce4423a6caa1a706a04f41 (patch) | |
| tree | e2dba3de9ef8510fa747858e7a61e1a188d327fd /src | |
| parent | a448d222983a89d0a75ac15993db5e01fb5f5359 (diff) | |
Decompile BossDoor
Diffstat (limited to 'src')
| -rw-r--r-- | src/code_08078778.c | 4 | ||||
| -rw-r--r-- | src/enemy/octorokBoss.c | 3 | ||||
| -rw-r--r-- | src/npc/beedle.c | 3 | ||||
| -rw-r--r-- | src/npc/cat.c | 1 | ||||
| -rw-r--r-- | src/npc/drLeft.c | 3 | ||||
| -rw-r--r-- | src/npc/gregal.c | 3 | ||||
| -rw-r--r-- | src/npc/mayorHagen.c | 2 | ||||
| -rw-r--r-- | src/npc/npc4E.c | 4 | ||||
| -rw-r--r-- | src/npc/rem.c | 1 | ||||
| -rw-r--r-- | src/npc/smallTownMinish.c | 2 | ||||
| -rw-r--r-- | src/npc/smith.c | 3 | ||||
| -rw-r--r-- | src/npc/stockwell.c | 2 | ||||
| -rw-r--r-- | src/npc/townMinish.c | 1 | ||||
| -rw-r--r-- | src/npc/townsperson.c | 1 | ||||
| -rw-r--r-- | src/object/bossDoor.c | 225 | ||||
| -rw-r--r-- | src/object/houseDoorExterior.c | 2 | ||||
| -rw-r--r-- | src/object/lavaPlatform.c | 2 | ||||
| -rw-r--r-- | src/object/lockedDoor.c | 2 | ||||
| -rw-r--r-- | src/object/object3E.c | 2 | ||||
| -rw-r--r-- | src/object/object6A.c | 5 | ||||
| -rw-r--r-- | src/object/windcrest.c | 3 |
21 files changed, 237 insertions, 37 deletions
diff --git a/src/code_08078778.c b/src/code_08078778.c index 643cd7bc..4f0f85db 100644 --- a/src/code_08078778.c +++ b/src/code_08078778.c @@ -65,13 +65,13 @@ s32 sub_08078828(Entity* ent) { return iVar1; } -void sub_08078850(u32 arg0, u32 arg1, u32 arg2, u32 arg3) { +void sub_08078850(Entity* arg0, u32 arg1, u32 arg2, void* arg3) { s32 iVar1; iVar1 = sub_08078904(); if (iVar1 >= 0) { gUnk_03003DF0[iVar1].unk[8] = arg1; gUnk_03003DF0[iVar1].unk[10] = arg2; - *(&gUnk_03003DF0[iVar1].unk4 + 1) = arg3; + *(&gUnk_03003DF0[iVar1].unk4 + 1) = (u32)arg3; } } diff --git a/src/enemy/octorokBoss.c b/src/enemy/octorokBoss.c index 4ae0be4e..cd45f7cf 100644 --- a/src/enemy/octorokBoss.c +++ b/src/enemy/octorokBoss.c @@ -11,9 +11,6 @@ #include "projectile.h" #include "game.h" -extern u32 GetRandomByWeight(const u8*); -extern void sub_080792BC(s32, u32, u32); - enum OctorokRotation { ROTATION_CW, ROTATION_CCW, NO_ROTATION = 0xff }; typedef struct HelperStruct { diff --git a/src/npc/beedle.c b/src/npc/beedle.c index 9a9717ab..41c81f2f 100644 --- a/src/npc/beedle.c +++ b/src/npc/beedle.c @@ -5,14 +5,13 @@ #include "script.h" #include "npc.h" #include "game.h" +#include "functions.h" typedef struct { u32 unk_00; s8 unk_04; } gUnk_0810C89C_struct; -extern void sub_08078850(Entity*, u32, s8, gUnk_0810C89C_struct*); - extern u8 gUnk_0810C88C[]; extern Hitbox gUnk_0810C894; extern gUnk_0810C89C_struct gUnk_0810C89C[]; diff --git a/src/npc/cat.c b/src/npc/cat.c index a5cba705..9de7337d 100644 --- a/src/npc/cat.c +++ b/src/npc/cat.c @@ -34,7 +34,6 @@ extern void sub_08067DCC(Entity*, u32); extern u8 gUnk_0811110C[2]; extern u32 gUnk_0811110F; -extern void sub_08078850(Entity*, u32, u8, u32*); extern u16 gUnk_08111104[]; diff --git a/src/npc/drLeft.c b/src/npc/drLeft.c index 65eabde0..0cd15668 100644 --- a/src/npc/drLeft.c +++ b/src/npc/drLeft.c @@ -1,6 +1,5 @@ #include "npc.h" - -extern void sub_08078850(Entity*, u32, u8, u32*); +#include "functions.h" extern u32 gUnk_081133B4; void sub_0806BFD8(Entity* this); diff --git a/src/npc/gregal.c b/src/npc/gregal.c index 34f5dbd6..d503f209 100644 --- a/src/npc/gregal.c +++ b/src/npc/gregal.c @@ -5,7 +5,6 @@ extern void (*gUnk_08113D8C[])(Entity*); -extern void sub_08078850(Entity*, u32, u8, u32*); extern u32 gUnk_08113D84[]; void Gregal(Entity* this) { @@ -32,7 +31,7 @@ void sub_0806CAF4(Entity* this) { } sub_0807DD64(this); sub_08078778(this); - sub_08078850(this, 1, gUnk_08113D84[1], gUnk_08113D84); + sub_08078850(this, 1, (u8)gUnk_08113D84[1], gUnk_08113D84); } ExecuteScriptForEntity(this, NULL); HandleEntity0x82Actions(this); diff --git a/src/npc/mayorHagen.c b/src/npc/mayorHagen.c index 673b2b81..0fad2970 100644 --- a/src/npc/mayorHagen.c +++ b/src/npc/mayorHagen.c @@ -3,8 +3,8 @@ #include "player.h" #include "flags.h" #include "npc.h" +#include "functions.h" -extern void sub_08078850(Entity*, u32, u32, u32*); extern u32 gUnk_08113F44; extern Dialog gUnk_08113F48[]; diff --git a/src/npc/npc4E.c b/src/npc/npc4E.c index b842076f..8e60e1db 100644 --- a/src/npc/npc4E.c +++ b/src/npc/npc4E.c @@ -14,8 +14,6 @@ typedef struct { s8 unk_04; } gUnk_0810C89C_struct; -extern void sub_08078850(Entity*, u32, u8 /* TODO this is a s8 in beedle.c*/, gUnk_0810C89C_struct*); - extern void script_Object3ELeftStoneOpening; // Cutscene data type? extern void script_Object3ERightStoneOpening; // Cutscene data type? @@ -46,7 +44,7 @@ void sub_0806DA04(Entity* this, ScriptExecutionContext* context) { // TODO gUnk_0811415C should be a gUnk_0810C89C_struct[], but then a lot of bytes everywhere are wrong? gUnk_0810C89C_struct* a = (gUnk_0810C89C_struct*)&( (gUnk_0810C89C_struct*)gUnk_0811415C)[context->intVariable]; // cast necessary to no longer make it a const* ? - sub_08078850(this, 1, a->unk_04, a); + sub_08078850(this, 1, (u8)a->unk_04, a); } void sub_0806DA1C(Entity* this, ScriptExecutionContext* context) { diff --git a/src/npc/rem.c b/src/npc/rem.c index 392c8198..8c321d01 100644 --- a/src/npc/rem.c +++ b/src/npc/rem.c @@ -8,7 +8,6 @@ extern void (*gUnk_08112278[])(Entity*); extern void script_Rem; -extern void sub_08078850(Entity*, u32, u32, u32*); extern u32 gUnk_0811229C; extern void sub_0807F950(Entity* this, ScriptExecutionContext* context); diff --git a/src/npc/smallTownMinish.c b/src/npc/smallTownMinish.c index d4e7d1ea..b9526d34 100644 --- a/src/npc/smallTownMinish.c +++ b/src/npc/smallTownMinish.c @@ -4,9 +4,9 @@ #include "script.h" #include "save.h" #include "npc.h" +#include "functions.h" extern Hitbox gUnk_081142FC; -extern void sub_08078850(Entity*, u32, u32, u32*); extern u32 gUnk_08114304; extern Dialog gUnk_08114308[]; diff --git a/src/npc/smith.c b/src/npc/smith.c index 9667b16c..1b922edc 100644 --- a/src/npc/smith.c +++ b/src/npc/smith.c @@ -1,6 +1,5 @@ #include "npc.h" - -extern void sub_08078850(Entity*, u32, u32, u32*); +#include "functions.h" extern void (*const gUnk_08110360[])(Entity*); extern void (*const gUnk_0811036C[])(Entity*); diff --git a/src/npc/stockwell.c b/src/npc/stockwell.c index dced086b..2b02257b 100644 --- a/src/npc/stockwell.c +++ b/src/npc/stockwell.c @@ -14,8 +14,6 @@ extern u16 script_StockwellBuy[]; extern u16 script_StockwellDogFood[]; extern u8 gUnk_0810FDB8[]; -extern void sub_08078850(Entity*, u32, u8, u32*); -extern void InitScriptExecutionContext(ScriptExecutionContext* context, u16* script); extern u32 gUnk_0810FDA0; extern u16 script_Stockwell; diff --git a/src/npc/townMinish.c b/src/npc/townMinish.c index 5b30edc6..fecc3747 100644 --- a/src/npc/townMinish.c +++ b/src/npc/townMinish.c @@ -8,7 +8,6 @@ extern void sub_0806ACC4(Entity*); extern void sub_0806AEA8(Entity*); extern void sub_0806AEE4(Entity*); extern void sub_0806AFE8(Entity*, ScriptExecutionContext*); -extern void sub_08078850(Entity*, u32, u32, u32*); extern u8 gUnk_081125F4[12]; extern SpriteLoadData gUnk_08112674[]; diff --git a/src/npc/townsperson.c b/src/npc/townsperson.c index f888ea21..3de73499 100644 --- a/src/npc/townsperson.c +++ b/src/npc/townsperson.c @@ -13,7 +13,6 @@ extern void (*const gUnk_0810B77C[])(Entity*); extern void sub_08061CB4(Entity*, u32); extern void sub_08061D64(Entity*); extern void sub_08062048(Entity*); -extern void sub_08078850(Entity*, u32, u8, u32*); extern SpriteLoadData* gUnk_0810B6EC[]; extern u8 gUnk_0810B78C[]; diff --git a/src/object/bossDoor.c b/src/object/bossDoor.c new file mode 100644 index 00000000..aebe6edc --- /dev/null +++ b/src/object/bossDoor.c @@ -0,0 +1,225 @@ +/** + * @file bossDoor.c + * @ingroup Objects + * + * @brief Boss Door object + */ + +#define NENT_DEPRECATED +#include "global.h" +#include "object.h" +#include "functions.h" + +typedef struct { + /*0x00*/ Entity base; + /*0x68*/ u8 unk_68[8]; + /*0x70*/ u16 unk_70; + /*0x72*/ u16 unk_72; + /*0x74*/ u16 unk_74; + /*0x76*/ u16 unk_76; + /*0x78*/ u16 unk_78; + /*0x7a*/ u16 unk_7a; + /*0x7c*/ u16 unk_7c; + /*0x7e*/ u8 unk_7e[6]; + /*0x84*/ u16 unk_84; + /*0x86*/ u16 unk_86; +} BossDoorEntity; + +extern Hitbox gHitbox_3; +extern bool32 gUnk_02036BB8; +extern const u8 gUnk_0811F740[]; + +void sub_0808C500(BossDoorEntity*); +void sub_0808C4BC(BossDoorEntity*); +void sub_0808C5D0(BossDoorEntity*); +void BossDoor_Init(BossDoorEntity*); +void BossDoor_Action1(BossDoorEntity*); +void BossDoor_Action2(BossDoorEntity*); +void BossDoor_Action3(BossDoorEntity*); +void BossDoor_Action4(BossDoorEntity*); +void BossDoor_Action5(BossDoorEntity*); +void BossDoor_Action6(BossDoorEntity*); + +void BossDoor(BossDoorEntity* this) { + static void (*const BossDoor_Actions[])(BossDoorEntity*) = { + BossDoor_Init, BossDoor_Action1, BossDoor_Action2, BossDoor_Action3, + BossDoor_Action4, BossDoor_Action5, BossDoor_Action6, + }; + BossDoor_Actions[super->action](this); +} + +void BossDoor_Init(BossDoorEntity* this) { + if ((this->unk_84 != 0xffff) && CheckFlags(this->unk_84)) { + DeleteThisEntity(); + } + if ((this->unk_86 != BEGIN) && CheckFlags(this->unk_86)) { + DeleteThisEntity(); + } + super->type2 = super->type >> 2; + super->speed = 0x300; + this->unk_70 = super->x.HALF.HI; + this->unk_72 = super->y.HALF.HI; + super->hitbox = (Hitbox*)&gHitbox_3; + super->spritePriority.b0 = 5; + this->unk_76 = super->type & 3; + this->unk_74 = COORD_TO_TILE(super); + InitializeAnimation(super, super->type & 0x1f); + switch (super->type2) { + case 0: + super->action = 1; + super->spriteSettings.draw = 1; + sub_0808C500(this); + sub_08078800(super); + sub_08078850(super, 0, gUnk_0811F740[this->unk_76], 0); + break; + case 1: + super->action = 4; + super->spriteSettings.draw = 0; + break; + case 2: + super->action = 1; + super->spriteSettings.draw = 1; + sub_0808C500(this); + break; + } +} + +void BossDoor_Action1(BossDoorEntity* this) { + if (super->interactType != 0) { + super->action = 2; + sub_080788E0(super); + SetFlag(this->unk_86); + } +} + +void BossDoor_Action2(BossDoorEntity* this) { + if ((super->frame & 0x80) == 0) { + if ((gRoomTransition.frameCount & 3) == 0) { + SoundReq(SFX_185); + } + GetNextFrame(super); + } else { + sub_0808C4BC(this); + } +} + +void BossDoor_Action3(BossDoorEntity* this) { + LinearMoveUpdate(super); + if (--super->actionDelay == 0) { + if (super->type < 4) { + sub_08078AC0(0x40, 0, 1); + gPlayerEntity.direction = super->type << 3; + } + DeleteThisEntity(); + } +} + +void BossDoor_Action4(BossDoorEntity* this) { + static const s8 gUnk_081214F4[] = { 0, -36, 36, 0, 0, 36, -36, 0 }; + const s8* ptr; + + if (sub_08083734(super, this->unk_76)) { + super->action = 5; + super->actionDelay = 0xc; + super->spriteSettings.draw = 1; + super->direction = *(u8*)&this->unk_76 << 3 ^ 0x10; + ptr = &gUnk_081214F4[this->unk_76 * 2]; + super->x.HALF.HI += ptr[0]; + super->y.HALF.HI += ptr[1]; + sub_0808C500(this); + } +} + +void BossDoor_Action5(BossDoorEntity* this) { + static const s8 gUnk_081214FC[] = { 12, 12, -12, 12, -12, 12, -12, -12, 12, -12, -12, -12, 12, 12, 12, -12 }; + Entity* effect; + const s8* ptr; + + LinearMoveUpdate(super); + if (--super->actionDelay == 0) { + super->action = 6; + super->z.HALF.HI = 0; + super->x.HALF.HI = this->unk_70; + super->y.HALF.HI = this->unk_72; + ptr = &gUnk_081214FC[this->unk_76 * 4]; + effect = CreateFx(super, FX_DASH, 0x40); + if (effect != NULL) { + effect->x.HALF.HI += ptr[0]; + effect->y.HALF.HI += ptr[1]; + } + effect = CreateFx(super, FX_DASH, 0x40); + if (effect != NULL) { + effect->x.HALF.HI += ptr[2]; + effect->y.HALF.HI += ptr[3]; + } + EnqueueSFX(SFX_10B); + } +} + +void BossDoor_Action6(BossDoorEntity* this) { + if (CheckFlags(this->unk_86)) { + super->action = 2; + } +} + +void sub_0808C4BC(BossDoorEntity* this) { + static const s8 gUnk_0812150C[] = { 0, -2, 2, 0, 0, 2, -2, 0 }; + const s8* ptr; + super->action = 3; + super->actionDelay = 0xc; + super->direction = this->unk_76 * 8; + ptr = &gUnk_0812150C[this->unk_76 * 2]; + super->x.HALF.HI += ptr[0]; + super->y.HALF.HI += ptr[1]; + sub_0808C5D0(this); + SoundReq(SFX_10B); +} + +void sub_0808C500(BossDoorEntity* this) { + if ((this->unk_76 == 0) || (this->unk_76 == 2)) { + this->unk_78 = GetTileIndex(this->unk_74 - 1, super->collisionLayer); + this->unk_7a = GetTileIndex(this->unk_74, super->collisionLayer); + this->unk_7c = GetTileIndex(this->unk_74 + 1, super->collisionLayer); + SetTile(0x4022, this->unk_74 - 1, super->collisionLayer); + SetTile(0x4022, this->unk_74, super->collisionLayer); + SetTile(0x4022, this->unk_74 + 1, super->collisionLayer); + } else { + this->unk_78 = GetTileIndex(this->unk_74 - 0x40, super->collisionLayer); + this->unk_7a = GetTileIndex(this->unk_74, super->collisionLayer); + this->unk_7c = GetTileIndex(this->unk_74 + 0x40, super->collisionLayer); + SetTile(0x4022, this->unk_74 - 0x40, super->collisionLayer); + SetTile(0x4022, this->unk_74, super->collisionLayer); + SetTile(0x4022, this->unk_74 + 0x40, super->collisionLayer); + } +} + +void sub_0808C5D0(BossDoorEntity* this) { + if ((this->unk_76 == 0) || (this->unk_76 == 2)) { + SetTile(this->unk_78, this->unk_74 - 1, super->collisionLayer); + SetTile(this->unk_7a, this->unk_74, super->collisionLayer); + SetTile(this->unk_7c, this->unk_74 + 1, super->collisionLayer); + } else { + SetTile(this->unk_78, this->unk_74 - 0x40, super->collisionLayer); + SetTile(this->unk_7a, this->unk_74, super->collisionLayer); + SetTile(this->unk_7c, this->unk_74 + 0x40, super->collisionLayer); + } +} + +void sub_0808C650(Entity* this, u32 param_2) { + Entity* obj = CreateObject(OBJECT_3A, 0, param_2); + if (obj != NULL) { + obj->parent = this; + gUnk_02036BB8 = FALSE; + } else { + gUnk_02036BB8 = TRUE; + } +} + +bool32 sub_0808C67C(void) { + return gUnk_02036BB8; +} + +void sub_0808C688(void) { + sub_0801E104(); + gUnk_02036BB8 = TRUE; +} diff --git a/src/object/houseDoorExterior.c b/src/object/houseDoorExterior.c index 62d0cb95..f7eb966c 100644 --- a/src/object/houseDoorExterior.c +++ b/src/object/houseDoorExterior.c @@ -28,8 +28,6 @@ static bool32 sub_080867CC(u32); void sub_0808681C(Entity*); static u8 sub_08086954(Entity*); -extern u32 CheckRegionOnScreen(u32, u32, u32, u32); - extern void (*const gUnk_081206B4[])(Entity*); extern Hitbox gUnk_081206AC; // TODO: should be const diff --git a/src/object/lavaPlatform.c b/src/object/lavaPlatform.c index 9fc23de9..dbe5856e 100644 --- a/src/object/lavaPlatform.c +++ b/src/object/lavaPlatform.c @@ -14,7 +14,7 @@ typedef struct { /*0x00*/ Entity base; /*0x68*/ u8 unk_68[8]; /*0x70*/ u16 timer; - /*0x72*/ u16 wobbleTime; /**< Time the player can stand on the platform. */ + /*0x72*/ u16 wobbleTime; /**< Time the player can stand on the platform. */ /*0x74*/ u16 respawnTime; /**< Time until the platform respawns after it has sunk. */ /*0x76*/ u16 unk_76; /*0x78*/ Entity* unk_78; // Typed same as second argument of sub_080A2CC0 diff --git a/src/object/lockedDoor.c b/src/object/lockedDoor.c index 74cb0e55..918ba9cf 100644 --- a/src/object/lockedDoor.c +++ b/src/object/lockedDoor.c @@ -37,8 +37,6 @@ void LockedDoor(Entity* this) { extern Hitbox gHitbox_2; -extern void sub_08078850(Entity*, u32, u32, u32); - typedef struct PACKED { s8 x; s8 y; diff --git a/src/object/object3E.c b/src/object/object3E.c index 8e083d1e..672c428e 100644 --- a/src/object/object3E.c +++ b/src/object/object3E.c @@ -29,7 +29,7 @@ void Object3E_Type8_Action2(Object3EEntity*); void Object3E(Object3EEntity* this) { static void (*const Object3E_Types[])(Object3EEntity*) = { - Object3E_Type0, Object3E_Type1, Object3E_Type1, Object3E_Type3, Object3E_Type4, + Object3E_Type0, Object3E_Type1, Object3E_Type1, Object3E_Type3, Object3E_Type4, Object3E_Type5, Object3E_Type6, Object3E_Type7, Object3E_Type8, Object3E_Type1, }; Object3E_Types[super->type](this); diff --git a/src/object/object6A.c b/src/object/object6A.c index 0d2fb68e..ad910be4 100644 --- a/src/object/object6A.c +++ b/src/object/object6A.c @@ -103,11 +103,6 @@ Object6ATypeAction sub_080961F4; Object6ATypeAction sub_08096284; Object6ATypeAction sub_08096290; -extern void sub_08080CB4(Entity*); -extern u32 sub_080002B8(Entity*); -extern u32 CheckOnScreen(Entity*); -extern void sub_08078850(Entity*, u32, u32, u8*); - void sub_08095754(Object6AEntity*); void sub_080957B4(Object6AEntity*); void sub_08095954(Object6AEntity*); diff --git a/src/object/windcrest.c b/src/object/windcrest.c index 15828253..97d88300 100644 --- a/src/object/windcrest.c +++ b/src/object/windcrest.c @@ -4,8 +4,7 @@ #include "save.h" #include "script.h" #include "effects.h" - -extern void sub_08078850(Entity*, u32, u32, u8*); +#include "functions.h" extern u8 gUnk_08125010; |
