diff options
| author | Macrepeh <63179588+Macrepeh@users.noreply.github.com> | 2020-07-14 17:28:41 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-07-14 17:28:41 -0400 |
| commit | 9ee00ce656cf97507a51313e997064b15600aaa1 (patch) | |
| tree | 809e6905cd950005c659561fcc693cadc23b24d6 /src | |
| parent | d649701eb8cf9b2261871fe0864f57db820850d4 (diff) | |
| parent | ed5c6d08dd012b1f5cd7c441b8b52169bb3ba6df (diff) | |
Merge pull request #2 from zeldaret/master
mnerge
Diffstat (limited to 'src')
| -rw-r--r-- | src/area.c (renamed from src/bitGetters.c) | 0 | ||||
| -rw-r--r-- | src/code_08018C58.c | 29 | ||||
| -rw-r--r-- | src/code_080A29BC.c | 69 | ||||
| -rw-r--r-- | src/createEnemy.c | 4 | ||||
| -rw-r--r-- | src/createEntity.c | 1 | ||||
| -rw-r--r-- | src/enemy/bladeTrap.c (renamed from src/bladeTrap.c) | 15 | ||||
| -rw-r--r-- | src/enemy/bombPeahat.c (renamed from src/bombPeahat.c) | 1 | ||||
| -rw-r--r-- | src/enemy/bowMoblin.c (renamed from src/bowMoblin.c) | 0 | ||||
| -rw-r--r-- | src/enemy/hangingSeed.c (renamed from src/hangingSeed.c) | 7 | ||||
| -rw-r--r-- | src/enemy/keese.c (renamed from src/keese.c) | 29 | ||||
| -rw-r--r-- | src/enemy/lakitu.c | 429 | ||||
| -rw-r--r-- | src/enemy/lakituCloud.c | 150 | ||||
| -rw-r--r-- | src/enemy/miniFireballGuy.c | 61 | ||||
| -rw-r--r-- | src/enemy/octorok.c (renamed from src/octorok.c) | 2 | ||||
| -rw-r--r-- | src/enemy/slime.c (renamed from src/slime.c) | 5 | ||||
| -rw-r--r-- | src/enemy/smallPesto.c (renamed from src/smallPesto.c) | 1 | ||||
| -rw-r--r-- | src/item.c | 12 | ||||
| -rw-r--r-- | src/item11.c | 99 | ||||
| -rw-r--r-- | src/loadRoom.c | 10 | ||||
| -rw-r--r-- | src/mainLoop.c | 40 | ||||
| -rw-r--r-- | src/manager/manager1.c | 64 | ||||
| -rw-r--r-- | src/manager/manager2.c | 18 | ||||
| -rw-r--r-- | src/manager/manager27.c (renamed from src/manager27.c) | 0 | ||||
| -rw-r--r-- | src/manager/manager2E.c (renamed from src/manager2E.c) | 0 | ||||
| -rw-r--r-- | src/npc/bigGoron.c (renamed from src/bigGoron.c) | 2 | ||||
| -rw-r--r-- | src/npc/bladeBrothers.c (renamed from src/bladeBrothers.c) | 11 | ||||
| -rw-r--r-- | src/npc/carpenter.c | 74 | ||||
| -rw-r--r-- | src/npc/cat.c (renamed from src/cat.c) | 0 | ||||
| -rw-r--r-- | src/npc/clothesRack.c (renamed from src/clothesRack.c) | 0 | ||||
| -rw-r--r-- | src/npc/cow.c (renamed from src/cow.c) | 4 | ||||
| -rw-r--r-- | src/npc/dampe.c | 116 | ||||
| -rw-r--r-- | src/npc/emma.c (renamed from src/emma.c) | 0 | ||||
| -rw-r--r-- | src/npc/epona.c (renamed from src/epona.c) | 6 | ||||
| -rw-r--r-- | src/npc/festari.c | 91 | ||||
| -rw-r--r-- | src/npc/forestMinish.c | 304 | ||||
| -rw-r--r-- | src/npc/gentari.c | 53 | ||||
| -rw-r--r-- | src/npc/goron.c (renamed from src/goron.c) | 2 | ||||
| -rw-r--r-- | src/npc/guard.c | 196 | ||||
| -rw-r--r-- | src/npc/mailbox.c (renamed from src/mailbox.c) | 9 | ||||
| -rw-r--r-- | src/npc/malon.c (renamed from src/malon.c) | 8 | ||||
| -rw-r--r-- | src/npc/milkCart.c (renamed from src/milkCart.c) | 7 | ||||
| -rw-r--r-- | src/npc/mutoh.c | 99 | ||||
| -rw-r--r-- | src/npc/npc9.c | 53 | ||||
| -rw-r--r-- | src/npc/postman.c | 227 | ||||
| -rw-r--r-- | src/npc/rem.c (renamed from src/rem.c) | 1 | ||||
| -rw-r--r-- | src/npc/simon.c (renamed from src/simon.c) | 1 | ||||
| -rw-r--r-- | src/npc/smith.c | 225 | ||||
| -rw-r--r-- | src/npc/stamp.c (renamed from src/stamp.c) | 26 | ||||
| -rw-r--r-- | src/npc/syrup.c (renamed from src/syrup.c) | 4 | ||||
| -rw-r--r-- | src/npc/talon.c (renamed from src/talon.c) | 10 | ||||
| -rw-r--r-- | src/npc/teachers.c | 113 | ||||
| -rw-r--r-- | src/npc/townMinish.c (renamed from src/townMinish.c) | 2 | ||||
| -rw-r--r-- | src/npc/townsperson.c | 324 | ||||
| -rw-r--r-- | src/npc/wheaton.c | 26 | ||||
| -rw-r--r-- | src/npc/windTribespeople.c (renamed from src/windTribespeople.c) | 22 | ||||
| -rw-r--r-- | src/npc/zelda.c (renamed from src/zelda.c) | 19 | ||||
| -rw-r--r-- | src/object/archway.c (renamed from src/archway.c) | 6 | ||||
| -rw-r--r-- | src/object/bell.c (renamed from src/bell.c) | 10 | ||||
| -rw-r--r-- | src/object/chestSpawner.c (renamed from src/chestSpawner.c) | 8 | ||||
| -rw-r--r-- | src/object/cloud.c (renamed from src/cloud.c) | 7 | ||||
| -rw-r--r-- | src/object/fan.c | 86 | ||||
| -rw-r--r-- | src/object/giantLeaf.c (renamed from src/giantLeaf.c) | 6 | ||||
| -rw-r--r-- | src/object/greatFairy.c (renamed from src/greatFairy.c) | 46 | ||||
| -rw-r--r-- | src/object/heartContainer.c (renamed from src/heartContainer.c) | 8 | ||||
| -rw-r--r-- | src/object/lightableSwitch.c | 145 | ||||
| -rw-r--r-- | src/object/mask.c (renamed from src/mask.c) | 12 | ||||
| -rw-r--r-- | src/object/metalDoor.c | 115 | ||||
| -rw-r--r-- | src/object/mineralWaterSource.c (renamed from src/mineralWaterSource.c) | 0 | ||||
| -rw-r--r-- | src/object/minishSizedEntrance.c | 27 | ||||
| -rw-r--r-- | src/object/object1A.c (renamed from src/object1A.c) | 3 | ||||
| -rw-r--r-- | src/object/object1C.c (renamed from src/object1C.c) | 0 | ||||
| -rw-r--r-- | src/object/object1D.c (renamed from src/object1D.c) | 0 | ||||
| -rw-r--r-- | src/object/object49.c | 155 | ||||
| -rw-r--r-- | src/object/object86.c | 81 | ||||
| -rw-r--r-- | src/object/object9E.c | 45 | ||||
| -rw-r--r-- | src/object/objectA8.c (renamed from src/objectA8.c) | 0 | ||||
| -rw-r--r-- | src/object/railtrack.c | 148 | ||||
| -rw-r--r-- | src/object/smoke.c | 60 | ||||
| -rw-r--r-- | src/object/swordsmanNewsletter.c | 31 | ||||
| -rw-r--r-- | src/object/thoughtBubble.c (renamed from src/thoughtBubble.c) | 4 | ||||
| -rw-r--r-- | src/object/treeHidingPortal.c | 88 | ||||
| -rw-r--r-- | src/object/well.c (renamed from src/well.c) | 3 | ||||
| -rw-r--r-- | src/object/windTribeFlag.c (renamed from src/windTribeFlag.c) | 6 | ||||
| -rw-r--r-- | src/object/windcrest.c (renamed from src/windcrest.c) | 0 | ||||
| -rw-r--r-- | src/ocarina.c | 4 | ||||
| -rw-r--r-- | src/position.c | 6 | ||||
| -rw-r--r-- | src/sub_0804AFF4.c | 10 | ||||
| -rw-r--r-- | src/textbox.c | 2 |
88 files changed, 3964 insertions, 239 deletions
diff --git a/src/bitGetters.c b/src/area.c index 4616248c..4616248c 100644 --- a/src/bitGetters.c +++ b/src/area.c diff --git a/src/code_08018C58.c b/src/code_08018C58.c new file mode 100644 index 00000000..23dd9fc6 --- /dev/null +++ b/src/code_08018C58.c @@ -0,0 +1,29 @@ +#include "global.h" +#include "entity.h" + +extern u32 SetTileType(u32 tileID, u32 tilePos, u32 layerID); + +void CreateMinishEntrance(u32 tilePos) +{ + u32 x, y; + u32 tileID = 0x185; + + for (y = 0; y <= 3; y++) { + for (x = 0; x <= 4; x++) { + SetTileType(tileID++, tilePos + x, 1); + } + tilePos += 0x40; + } +} + +void sub_08018C58(u32 tilePos) +{ + u32 i = 0; + + for (;i < 6;) { + SetTileType(0x260 + i, tilePos, 1); + SetTileType(0x261 + i, tilePos + 1, 1); + i += 2; + tilePos += 0x40; + } +}
\ No newline at end of file diff --git a/src/code_080A29BC.c b/src/code_080A29BC.c new file mode 100644 index 00000000..7fa80ee2 --- /dev/null +++ b/src/code_080A29BC.c @@ -0,0 +1,69 @@ +#include "global.h" +#include "entity.h" +#include "room.h" + +void sub_080A29BC(Entity *parent) +{ + CreateFx(parent, 2, 0); +} + +void sub_080A29C8(s32 xOff, s32 yOff, u32 layer) +{ + Entity *pEVar1; + + pEVar1 = CreateObject(0xf, 2, 0); + if (pEVar1 != NULL) { + pEVar1->x.HALF.HI = gRoomControls.roomOriginX + xOff; + pEVar1->y.HALF.HI = gRoomControls.roomOriginY + yOff; + pEVar1->collisionLayer = layer; + } +} + +void sub_080A29FC(Entity *parent) +{ + CreateFx(parent, 0x11, 0); +} + +void sub_080A2A08(Entity *parent) +{ + CreateFx(parent, 0x6, 0); +} + +void sub_080A2A14(Entity *parent) +{ + CreateFx(parent, 0xb, 0); +} + +Entity * sub_080A2A20(Entity *parent, u32 form, u32 parameter) +{ + Entity *pEVar1; + + pEVar1 = CreateObjectWithParent(parent, 0, form, parameter); + if (pEVar1 != NULL) { + pEVar1->actionDelay = 5; + } + return pEVar1; +} + +Entity * sub_080A2A3C(Entity *parent, u32 form, u32 subtype, u32 param_4) +{ + Entity *ent; + + ent = CreateObjectWithParent(parent, 0, form, subtype); + if (ent != NULL) { + ent->actionDelay = 5; + ent->field_0x86 = param_4; + } + return ent; +} + +Entity * sub_080A2A64(Entity *parent) +{ + Entity *pEVar1; + + pEVar1 = CreateFx(parent, 0x20, 0); + if (pEVar1 != NULL) { + pEVar1->spritePriority.b0 = 7; + } + return pEVar1; +}
\ No newline at end of file diff --git a/src/createEnemy.c b/src/createEnemy.c index 7dc492ff..6090da14 100644 --- a/src/createEnemy.c +++ b/src/createEnemy.c @@ -4,14 +4,14 @@ extern Entity* GetEmptyEntity(); extern void sub_0805EA2C(Entity*, u8); -Entity* CreateEnemy(u32 subtype, u32 param1) { +Entity* CreateEnemy(u32 subtype, u32 form) { Entity* enemy; enemy = GetEmptyEntity(); if (enemy != NULL) { (enemy->entityType).type = 3; (enemy->entityType).subtype = subtype; - (enemy->entityType).form = param1; + (enemy->entityType).form = form; sub_0805EA2C(enemy, 4); } return enemy; diff --git a/src/createEntity.c b/src/createEntity.c index 1119b4b7..9d597c4c 100644 --- a/src/createEntity.c +++ b/src/createEntity.c @@ -29,7 +29,6 @@ // sub_0804AEB0(entity,param_1); // if ((param_1->field_0x1 & 240) != 16) { // (entity->entityType).parameter = *(u8 *)¶m_1->entityparameter; -// /* i suspect this is where the entity's behavior is defined. Not sure. */ // entity->actionDelay = (u8)((u32)param_1->entityparameter >> 8); // if ((type != 9) && (sub_0804AF0C(entity,param_1), entity->field_0x4 != NULL)) { // if ((param_1->entityType & 16) == 0) { diff --git a/src/bladeTrap.c b/src/enemy/bladeTrap.c index 58cff0c1..3c37d08a 100644 --- a/src/bladeTrap.c +++ b/src/enemy/bladeTrap.c @@ -4,7 +4,7 @@ extern void sub_080A2CC0(); extern void sub_0806F69C(); extern void sub_08004488(); -extern Entity* sub_0804B128(); +extern Entity* GetCurrentRoomProperty(); void BladeTrap(Entity* ent) { u16 uVar1; @@ -12,18 +12,21 @@ void BladeTrap(Entity* ent) { u16* puVar3; if (ent->action == 0) { ent->action = 1; - pEVar2 = sub_0804B128((u8)(ent->entityType).form); + pEVar2 = GetCurrentRoomProperty((u8)(ent->entityType).form); ent->attachedEntity = pEVar2; - sub_080A2CC0((EntityData*)ent, &ent->attachedEntity, &ent->heldObjectPtr); + sub_080A2CC0((EntityData*)ent, &ent->attachedEntity, &ent->field_0x74); } if ((ent->direction & 0x80) == 0) { sub_0806F69C(ent); } - puVar3 = (u16*)&(ent->heldObjectPtr); + + + + puVar3 = &(ent->field_0x74); uVar1 = *puVar3; *puVar3 = uVar1 - 1; - if ((u16)(*puVar3) == 0) { - if ((ent->direction & 0x80) == 0) { + if ((*puVar3) == 0) { + if ((u16)(ent->direction & 0x80) == 0) { sub_08004488(0x74); } sub_080A2CC0((EntityData*)ent, &ent->attachedEntity, puVar3); diff --git a/src/bombPeahat.c b/src/enemy/bombPeahat.c index b5dda939..3921737a 100644 --- a/src/bombPeahat.c +++ b/src/enemy/bombPeahat.c @@ -7,7 +7,6 @@ extern s32 sub_080012DC(Entity*); extern u32 GetNextFunction(Entity*); extern void sub_0802AD54(Entity*); extern void sub_0802B048(Entity*); -extern void InitializeAnimation(Entity*, u32); extern void sub_0806F4E8(Entity*); extern void sub_0806F3E4(Entity*); diff --git a/src/bowMoblin.c b/src/enemy/bowMoblin.c index 6c7620d6..6c7620d6 100644 --- a/src/bowMoblin.c +++ b/src/enemy/bowMoblin.c diff --git a/src/hangingSeed.c b/src/enemy/hangingSeed.c index 35653f43..7f0ba1dc 100644 --- a/src/hangingSeed.c +++ b/src/enemy/hangingSeed.c @@ -2,7 +2,6 @@ #include "entity.h" extern void EnemyFunctionHandler(Entity*, void (*const funcs[])(Entity*)); -extern void CreateFx(Entity*, u32, u32); extern void DeleteThisEntity(); extern void (*const gUnk_080CB570[])(Entity*); @@ -31,10 +30,10 @@ void nullsub_7(Entity* this){} void sub_08021720(Entity *this) { this->action = 1; - this->spriteSettings.b.ss0 = 1; + this->spriteSettings.b.draw = 1; this->frameIndex = (this->entityType).form; - this->spriteOrder.b3 = 1; - this->ticks.b0 = 3; + this->spriteRendering.b3 = 1; + this->spritePriority.b0 = 3; } void nullsub_08(Entity* this){}
\ No newline at end of file diff --git a/src/keese.c b/src/enemy/keese.c index b9914c2f..0cbc9acd 100644 --- a/src/keese.c +++ b/src/enemy/keese.c @@ -4,19 +4,16 @@ #include "link.h" extern void sub_0804AA30(Entity*, void *); -extern u32 sub_0806F520(void); +extern u32 sub_0806F520(Entity*); extern void sub_0806F4E8(Entity*); -extern u32 sub_0806F3E4(void); +extern u32 sub_0806F3E4(Entity*); extern void sub_0804A7D4(Entity*); extern void sub_0804A720(Entity*); extern u32 Random(); -extern void UpdateSpriteOrderAndFlip(Entity*); extern void sub_08021EF0(Entity*); -extern void GetNextFrame(Entity*); extern void sub_080AEFB4(Entity*); extern void sub_08021F24(Entity*); extern u32 sub_0806FCB8(Entity*, s32, s32, u32); -extern void InitializeAnimation(Entity*, u32); extern void (*gUnk_080CB69C[])(Entity*); extern void (*gUnk_080CB6B4[])(Entity*); @@ -45,7 +42,7 @@ void sub_08021d98(Entity *this) void sub_08021DA8(Entity *this) { - if (sub_0806F520()) { + if (sub_0806F520(this)) { gUnk_080CB6C4[this->previousActionFlag](this); } } @@ -62,7 +59,7 @@ void sub_08021DD4(Entity *this) void sub_08021DDC(Entity *this) { - if (sub_0806F3E4()) { + if (sub_0806F3E4(this)) { sub_0804A7D4(this); } } @@ -72,24 +69,24 @@ void sub_08021DF0(Entity *this) sub_0804A720(this); if ((this->entityType).form != 0) { - this->ticks.b1 = 1; + this->spritePriority.b1 = 1; this->height.HALF.HI = -0x10; } this->direction = Random() & 0x1f; this->filler[0] = 1; - this->ticks.b0 = 3; + this->spritePriority.b0 = 3; this->collisionLayer = 3; - UpdateSpriteOrderAndFlip(this); + UpdateSpriteForCollisionLayer(this); sub_08021EF0(this); } void sub_08021E4C(Entity *this) { - if (this->field_0x78 != 0) { - this->field_0x78--; + if (this->field_0x78.HWORD != 0) { + this->field_0x78.HWORD--; } - if (this->itemCooldown != 0) { - (this->itemCooldown)--; + if (this->field_0x7a != 0) { + (this->field_0x7a)--; } GetNextFrame(this); if ((this->frames.b.f3) != 0) { @@ -128,7 +125,7 @@ void sub_08021EF0(Entity *this) u32 uVar1; this->action = 1; - this->field_0x78 = gUnk_080CB6D6[Random() & 0xf]; - this->itemCooldown = 0x3c; + this->field_0x78.HWORD = gUnk_080CB6D6[Random() & 0xf]; + this->field_0x7a = 0x3c; InitializeAnimation(this, 0); } diff --git a/src/enemy/lakitu.c b/src/enemy/lakitu.c new file mode 100644 index 00000000..9189c525 --- /dev/null +++ b/src/enemy/lakitu.c @@ -0,0 +1,429 @@ +#include "global.h" +#include "entity.h" +#include "trig.h" +#include "random.h" +#include "link.h" + +// Lakitu +extern void EnemyFunctionHandler(Entity *, void (*const funcs[])(Entity*)); +extern void SetChildOffset(Entity *, u32, u32, u32); + +// sub_0803C758 +extern void sub_0803CAD0(Entity *); + +// sub_0803C784 +extern void sub_0803CBAC(Entity *); // Also used in sub_0803C86C +extern Entity *CreateFx(Entity*, u32, u32); +extern void sub_0804A9FC(Entity *, u32); +extern void sub_0804AA30(Entity *, void (*const funcs[])(Entity *)); + +// sub_0803C820 +extern u32 sub_0806F520(Entity *); + +// sub_0803C850 +extern void sub_0806F4E8(Entity *); + +// sub_0803C87C +extern Entity *sub_0804A98C(Entity *, u32, u32); +extern void sub_0804A720(Entity *); + +// sub_0803C8BC and sub_0803C918 +extern void sub_0803CA84(Entity *, u32); +extern bool32 sub_0803CA4C(Entity *); + +// Many functions +extern void UpdateAnimationSingleFrame(Entity *); +extern void InitAnimationForceUpdate(Entity *, u32); + +// sub_0803C918 +extern u32 sub_0803CB04(Entity *); + +// sub_0803C97C +extern void sub_0803CB64(Entity *); + +// sub_0803C9D4 and sub_0803CB04 +extern void sub_0803CB34(Entity *); + +// sub_0803CA0C +extern u32 sub_08003FC4(Entity *, u32); +extern void sub_0803CC08(Entity *this); + +// sub_0803CA4C +extern u32 sub_0806FCB8(Entity *, u32, u32, u32); +extern u32 sub_080041A0(Entity *, Entity *, u32, u32); + +// sub_0803CA84 +extern u32 GetFacingDirection(Entity *, Entity *); + +// sub_0803CAD0 +extern u8 sub_080045D4(s16, s16, u16, u16); +extern void sub_080AEFE0(Entity *); + +// sub_0803CB64 +extern void PositionRelative(Entity *, Entity *, u32, u32); +extern void sub_08004488(u32); + +typedef struct { + s8 x; + s8 y; +} PACKED OffsetCoords; + +// sub_0803CC08 +extern void DeleteEntity(Entity *); + +// Variables +extern void (*const gUnk_080D0110[])(Entity *); +extern void (*const gUnk_080D0128[])(Entity *); +extern void (*const gUnk_080D0148[])(Entity *); +extern const OffsetCoords gUnk_080D0154[]; + +void Lakitu(Entity *this) { + EnemyFunctionHandler(this, gUnk_080D0110); + + SetChildOffset(this, 0, 1, -16); +} + +void sub_0803C758(Entity *this) { + if (this->action != 0 && this->action != 7) { + sub_0803CAD0(this); + } + + gUnk_080D0128[this->action](this); +} + +void sub_0803C784(Entity *this) { + if ((this->bitfield & 0x7f) == 0x1d) { + this->field_0x20 = 0x20000; + + sub_0803CBAC(this); + } + else { + if (this->damageType == 0x43) { + Entity *sound = CreateFx(this, 2, 0); + + if (sound != 0) { + u32 angle = (this->field_0x3e ^ 0x10) << 3; + s32 sine; + + sine = gSineTable[angle]; + if (sine < 0) { + sine += 0x1f; + } + + sound->x.HALF.HI += sine >> 5; + + sine = gSineTable[angle + 0x40]; + if (sine < 0) { + sine += 0x1f; + } + + sound->y.HALF.HI -= sine >> 5; + } + } + } + + if (this->field_0x43) { + sub_0804A9FC(this, 0x1c); + } + + sub_0804AA30(this, gUnk_080D0110); +} + +void sub_0803C820(Entity *this) { + if (sub_0806F520(this)) { + gUnk_080D0148[this->previousActionFlag](this); + } +} + +void sub_0803C844(Entity *this) { + this->previousActionFlag = 1; + this->field_0x1d = 0x3c; +} + +void sub_0803C850(Entity *this) { + Entity *cloud = this->attachedEntity; + if (cloud != 0) { + cloud->spriteOffsetX = this->spriteOffsetX; + } + + sub_0806F4E8(this); +} + +void sub_0803C86C(Entity *this) { + sub_0803CBAC(this); + this->attachedEntity = 0; +} + +void sub_0803C87C(Entity *this) { + Entity *cloud = sub_0804A98C(this, 17, 0); + if (cloud == 0) { + return; + } + + cloud->parent = this; + this->attachedEntity = cloud; + + sub_0804A720(this); + + this->action = 1; + + this->height.HALF.HI = -2; + + this->spriteOffsetY = 0xff; + + this->field_0x74 = this->x.HALF.HI; + this->field_0x76 = this->y.HALF.HI; +} + +void sub_0803C8BC(Entity *this) { + sub_0803CA84(this, 0); + + if (sub_0803CA4C(this)) { + this->action = 2; + this->spriteSettings.b.draw = 1; + } +} + +void sub_0803C8E4(Entity *this) { + UpdateAnimationSingleFrame(this); + + if (this->frames.b.f3) { + this->action = 3; + this->actionDelay = 0x3c; + + this->damageType = 0x42; + + InitAnimationForceUpdate(this, this->animationState + 4); + } +} + +void sub_0803C918(Entity *this) { + if (sub_0803CB04(this) != 0) { + return; + } + + if (sub_0803CA4C(this) == 0) { + this->action = 4; + + this->damageType = 0x43; + InitAnimationForceUpdate(this, this->animationState + 0xc); + } + else { + sub_0803CA84(this, 4); + } +} + +void sub_0803C950(Entity *this) { + UpdateAnimationSingleFrame(this); + + if (this->frames.b.f3 != 0) { + this->action = 1; + this->spriteSettings.b.draw = 0; + + InitAnimationForceUpdate(this, this->animationState); + } +} + +void sub_0803C97C(Entity *this) { + UpdateAnimationSingleFrame(this); + + if (this->frames.b.f3 == 0) { + return; + } + + sub_0803CB64(this); + this->action = 6; + this->damageType = 0x42; + + + if ((Random() & 1) && this->field_0x78.HALF.HI == 0) { + this->actionDelay = 0xf; + this->field_0x78.HALF.HI = 1; + } + else { + this->actionDelay = 0x1e; + this->field_0x78.HALF.HI = 0; + + InitAnimationForceUpdate(this->attachedEntity, this->animationState); + } +} + +void sub_0803C9D4(Entity *this) { + this->actionDelay--; + + if (this->actionDelay != 0) { + return; + } + + if (this->field_0x78.HALF.HI == 1) { + sub_0803CB34(this); + } + else { + this->action = 3; + this->actionDelay = 0xb4; + + InitAnimationForceUpdate(this, this->animationState + 4); + } +} + +void sub_0803CA0C(Entity *this) { + if (sub_08003FC4(this, 0x1800) == 0 && this->animIndex <= 19) { + InitAnimationForceUpdate(this, this->animationState + 20); + + this->spritePriority.b1 = 0; + } + + UpdateAnimationSingleFrame(this); + sub_0803CC08(this); +} + +bool32 sub_0803CA4C(Entity *this) { + if (sub_0806FCB8(this, gLinkEntity.x.HALF.HI, gLinkEntity.y.HALF.HI, 0x28) == 0) { + if (sub_080041A0(this, &gLinkEntity, 0x70, 0x50)) { + return 1; + } + } + + return 0; +} + +void sub_0803CA84(Entity *this, u32 unkParameter) { + u32 altAnimState = GetFacingDirection(this, &gLinkEntity); + + if (((altAnimState - 3) & 7) > 2 || ((this->animationState - (altAnimState >> 3)) & 3) > 1) { + u32 intermediate = (altAnimState + 4) & 0x18; + altAnimState = intermediate >> 3; + + if (altAnimState != this->animationState) { + this->animationState = altAnimState; + + InitAnimationForceUpdate(this, altAnimState + unkParameter); + InitAnimationForceUpdate(this->attachedEntity, altAnimState); + } + } +} + +void sub_0803CAD0(Entity *this) { + if (sub_0806FCB8(this, this->field_0x74, this->field_0x76, 1) == 0) { + this->direction = sub_080045D4(this->x.HALF.HI, this->y.HALF.HI, this->field_0x74, this->field_0x76); + + sub_080AEFE0(this); + } +} + +bool32 sub_0803CB04(Entity *this) { + bool32 returnValue; + u8 delay; + + delay = --this->actionDelay; + if (delay != 0) { + returnValue = 0; + } + else { + sub_0803CB34(this); + this->field_0x78.HALF.HI = delay; + + InitAnimationForceUpdate(this->attachedEntity, this->animationState + 4); + returnValue = 1; + } + + return returnValue; +} + +void sub_0803CB34(Entity *this) { + this->action = 5; + this->damageType = 0xa6; + + this->field_0x78.HALF.LO = GetFacingDirection(this, &gLinkEntity); + + InitAnimationForceUpdate(this, this->animationState + 8); +} + +void sub_0803CB64(Entity *this) { + Entity *cloud; + const OffsetCoords *offset; + + cloud = sub_0804A98C(this, 18, 0); + + if (cloud == 0) { + return; + } + + offset = &gUnk_080D0154[this->animationState]; + + cloud->direction = this->field_0x78.HALF.LO; + + PositionRelative(this, cloud, offset->x << 16, offset->y << 16); + + sub_08004488(0x193); +} + +void sub_0803CBAC(Entity *this) { + Entity *cloud; + + cloud = this->attachedEntity; + if (cloud != 0) { + cloud->flags |= 0x80; + cloud->damageType = 0x43; + } + + this->action = 7; + this->spriteSettings.b.draw = 1; + + this->spritePriority.b1 = 1; + + this->flags2 &= 0x7b; + + this->damageType = 0x42; + + InitAnimationForceUpdate(this, this->animationState + 16); +} + +void sub_0803CC08(Entity *this) { + Entity *cloud; + Entity *sound; + + cloud = this->attachedEntity; + if (cloud == 0) { + return; + } + + if ((u32)(cloud->height.HALF.HI - this->height.HALF.HI) > 2) { + return; + } + + if (this->field_0x20 >= 0) { + return; + } + + if (!sub_0806FCB8(this, cloud->x.HALF.HI, cloud->y.HALF.HI, 6)) { + return; + } + + sound = CreateFx(this, 2, 0); + if (sound != 0) { + sound->x.HALF.HI += 6; + sound->y.HALF.HI += 6; + } + + sound = CreateFx(this, 2, 0); + if (sound != 0) { + sound->x.HALF.HI -= 6; + sound->y.HALF.HI += 6; + } + + sound = CreateFx(this, 2, 0); + if (sound != 0) { + sound->x.HALF.HI += 6; + sound->y.HALF.HI -= 6; + } + + sound = CreateFx(this, 2, 0); + if (sound != 0) { + sound->x.HALF.HI -= 6; + sound->y.HALF.HI -= 6; + } + + this->attachedEntity = 0; + DeleteEntity(cloud); +}
\ No newline at end of file diff --git a/src/enemy/lakituCloud.c b/src/enemy/lakituCloud.c new file mode 100644 index 00000000..0dca3465 --- /dev/null +++ b/src/enemy/lakituCloud.c @@ -0,0 +1,150 @@ +#include "global.h" +#include "entity.h" +#include "link.h" + +extern u32 GetNextFunction(Entity *); + +extern void (* const gUnk_080D0418[])(Entity *); +extern void (* const gUnk_080D0430[])(Entity *); +extern void (* const gUnk_080D043C[])(Entity *); + +extern bool32 sub_0806F3E4(Entity *); +extern bool32 sub_0806F520(Entity *); + +extern void sub_0800449C(Entity *, u32); +extern void sub_0803CE14(Entity *); +extern void sub_0803CE3C(Entity *); +extern Entity *GetCurrentRoomProperty(u8); +extern void sub_0806F4E8(Entity *); +extern void sub_0806F69C(Entity *); +extern void sub_08079D84(void); +extern void sub_080A2CC0(Entity *, Entity **, u16 *); + +void LakituCloud(Entity *this) { + gUnk_080D0418[GetNextFunction(this)](this); +} + +void sub_0803CCD4(Entity *this) { + gUnk_080D0430[this->action](this); +} + +void sub_0803CCEC(Entity *this) { + this->field_0x42 = 0; + sub_0803CCD4(this); +} + +void sub_0803CCFC(Entity *this) { + if (sub_0806F520(this) == 0) { + if (this->previousActionFlag == 2) { + sub_0803CE3C(this); + } + } + else { + gUnk_080D043C[this->previousActionFlag](this); + } +} + +void sub_0803CD2C(Entity *this) { + this->previousActionFlag = 1; + this->field_0x1d = 0x3c; +} + +void sub_0803CD38(Entity *this) { + sub_0806F4E8(this); +} + +void sub_0803CD40(Entity *this) { + if (!sub_0806F3E4(this)) { + return; + } + + ModHealth(-2); + + sub_0800449C(&gLinkEntity, 122); + sub_08079D84(); + + sub_0803CE3C(this); +} + +void sub_0803CD6C(Entity *this) { + Entity *lakitu; + + this->action = 1; + this->height.HALF.HI = -2; + + // Set parent to lakitu + lakitu = GetCurrentRoomProperty(this->entityType.form); + this->attachedEntity = lakitu; + this->parent = lakitu; + + this->field_0x78.HWORD = this->x.HALF.HI; + this->field_0x7a = this->y.HALF.HI; + + InitAnimationForceUpdate(this, 4); + + sub_0803CE14(this); +} + +void sub_0803CDA8(Entity *this) { + UpdateAnimationSingleFrame(this); + + if ((this->direction & 0x80) == 0) { + sub_0806F69C(this); + } + + if (--this->field_0x74 << 0x10 == 0) { + sub_0803CE14(this); + } +} + +void sub_0803CDD8(Entity *this) { + u8 one; + u8 draw; + + draw = this->spriteSettings.b.draw; + one = 1; + this->spriteSettings.b.draw = draw ^ one; + + this->actionDelay--; + + if (this->actionDelay == 0) { + this->action = 1; + + this->flags |= 0x80; + + this->spriteSettings.b.draw = one; + } +} + +void sub_0803CE14(Entity *this) { + u8 direction; + + sub_080A2CC0(this, &this->attachedEntity, &this->field_0x74); + + direction = this->direction; + if (direction & 0x80) { + return; + } + + direction = direction / 8 + 4; + + InitAnimationForceUpdate(this, direction); +} + +void sub_0803CE3C(Entity *this) { + CreateFx(this, 2, 0); + + this->action = 2; + this->actionDelay = 60; + + this->flags &= 0x7f; + + this->field_0x3a &= 0xfb; + + this->x.HALF.HI = this->field_0x78.HWORD; + this->y.HALF.HI = this->field_0x7a; + + this->attachedEntity = this->parent; + + sub_0803CE14(this); +} diff --git a/src/enemy/miniFireballGuy.c b/src/enemy/miniFireballGuy.c new file mode 100644 index 00000000..d7bdc540 --- /dev/null +++ b/src/enemy/miniFireballGuy.c @@ -0,0 +1,61 @@ +#include "global.h" +#include "entity.h" + +extern void EnemyFunctionHandler(Entity*, void (*const func[])(Entity*)); +extern void sub_0804AA30(Entity*, void (*const func[][])(Entity*)); +extern void sub_0804A7D4(Entity*); +extern void sub_0804A720(Entity*); +extern void sub_08045678(Entity*); +extern void sub_080AEFE0(void); +extern u32 sub_08003FC4(Entity*, u32); +extern void sub_08045678(Entity*); + +extern void (*const gUnk_080D1868[])(Entity*); +extern void (*const gUnk_080D1880[])(Entity*); + +void MiniFireballGuy(Entity *this) +{ + EnemyFunctionHandler(this, gUnk_080D1868); +} + +void sub_080455BC(Entity *this) +{ + gUnk_080D1880[this->action](this); +} + +void sub_080455D4(Entity *this) +{ + sub_0804AA30(this, &gUnk_080D1868); +} + +void sub_080455E4(Entity *this) +{ + if ((this != this->parent) && (this->parent != NULL)) { + this->field_0x6c = this->field_0x6c & 0x7f; + this->parent->attachedEntity = this->attachedEntity; + this->attachedEntity->parent = this->parent; + } + sub_0804A7D4(this); +} + +void nullsub_23(Entity* this) {} + +void sub_08045618(Entity *this) +{ + this->action = 1; + this->spriteSettings.b.draw = 1; + this->nonPlanarMovement = 0x80; + this->field_0x3c = this->field_0x3c | 0x10; + sub_0804A720(this); + InitializeAnimation(this, 1); + sub_08045678(this); +} + +void sub_08045654(Entity *this) +{ + sub_080AEFE0(); + GetNextFrame(this); + if (sub_08003FC4(this, 0x1800) == 0) { + sub_08045678(this); + } +}
\ No newline at end of file diff --git a/src/octorok.c b/src/enemy/octorok.c index 5c66b098..ff699ec0 100644 --- a/src/octorok.c +++ b/src/enemy/octorok.c @@ -9,14 +9,12 @@ extern void sub_0804A7D4(); extern void CreateDeathFx(); extern void sub_0801ECFC(); extern u32 sub_0806F520(); -extern void InitializeAnimation(); extern void sub_0806F4E8(); extern void sub_0806F3E4(); extern void InitializeAnimationAnimation(); extern void sub_0804A720(); extern u32 Random(); extern void sub_0801ED14(); -extern void GetNextFrame(); extern void(*gOctorok[2]); extern void (*gOctorokIdle[4])(Entity*); diff --git a/src/slime.c b/src/enemy/slime.c index 3738038f..42a5d952 100644 --- a/src/slime.c +++ b/src/enemy/slime.c @@ -12,15 +12,12 @@ extern void SetChildOffset(Entity*, u32, u32, u32); extern void sub_0804AA30(Entity*, void*); extern void sub_0804A9FC(Entity*, u32); extern void sub_0804A720(Entity*); -extern void InitializeAnimation(Entity*, u32); extern void sub_08044FF8(Entity*); extern u32 Random(void); -extern void GetNextFrame(Entity*); extern u32 sub_0806FA04(u32, u32); extern u32 sub_08049FA0(Entity*); extern u32 sub_08049EE4(Entity*); extern u32 sub_080AEF88(void); -extern Entity* CreateEnemy(u32, u32); extern void (*gUnk_080D16BC[])(Entity*); extern void (*gUnk_080D16A4[])(Entity*); @@ -56,7 +53,7 @@ void nullsub_171() { void sub_08044FC8(Entity* this) { this->action = 1; - this->spriteSettings.b.ss0 = 1; + this->spriteSettings.b.draw = 1; this->nonPlanarMovement = 128; sub_0804A720(this); InitializeAnimation(this, 0); diff --git a/src/smallPesto.c b/src/enemy/smallPesto.c index 5069510c..c29fe80c 100644 --- a/src/smallPesto.c +++ b/src/enemy/smallPesto.c @@ -2,7 +2,6 @@ #include "entity.h" extern u32 GetNextFunction(Entity*); -extern u32 GetNextFrame(Entity*); extern u32 sub_0806F520(Entity*); extern void sub_0806F4E8(Entity*); extern u32 sub_0806F3E4(); @@ -2,8 +2,10 @@ #include "entity.h" #include "item.h" + +// TODO - How does this relate to PlayerItemFunctions? Is this just a lookup table? void (*const gItemFunctions[])(ItemBehavior*, u32) = { - CellOverwriteSet, + DebugItem, Sword, Sword, Sword, @@ -25,11 +27,11 @@ void (*const gItemFunctions[])(ItemBehavior*, u32) = { MoleMitts, RocsCape, sub_08076800, - CellOverwriteSet, + DebugItem, Ocarina, - CellOverwriteSet, - CellOverwriteSet, - CellOverwriteSet, + DebugItem, + DebugItem, + DebugItem, TryPickupObject, JarEmpty, JarEmpty, diff --git a/src/item11.c b/src/item11.c new file mode 100644 index 00000000..0af53106 --- /dev/null +++ b/src/item11.c @@ -0,0 +1,99 @@ +#include "global.h" +#include "entity.h" +#include "link.h" + +extern void DeleteThisEntity(); +extern void sub_08078CD0(Entity*); +extern void sub_08018FA0(Entity*); +extern void sub_0801766C(Entity*); +extern void sub_08018F6C(Entity*); + +extern void (*const gUnk_080B3DD0[])(Entity*); + +extern BoundingBox gUnk_080B3E18; +extern u8 gUnk_080B3DE0[]; +extern BoundingBox* gUnk_080B3DE8[]; + +void Item11(Entity *this) +{ + if (this->currentHealth) { + this->hurtBlinkTime = 0; + gUnk_080B3DD0[this->action](this); + } + else { + DeleteThisEntity(); + } +} + +void sub_08018CBC(Entity *this) +{ + u32 PVar1; + u8 uVar2; + Entity *pEVar3; + + *(u32 *)&this->cutsceneBeh = this->x.WORD = gLinkEntity.x.WORD; + *(u32 *)&this->field_0x80 = this->y.WORD = gLinkEntity.y.WORD; + uVar2 = this->animationState = gLinkEntity.animationState & 0xe; + this->direction = (u8)(uVar2 << 2); + this->nonPlanarMovement = 0x400; + this->damageType = 0x96; + this->field_0x3c = (gLinkEntity.field_0x3c + 1) | 0x80; + this->flags2 = gLinkEntity.flags2; + pEVar3 = this->attachedEntity; + if (pEVar3 != NULL) { + this->action = 1; + this->flags = this->flags & 0x7f; + this->actionDelay = 0x56; + this->field_0x40 = 0x1c; + this->field_0x44 = 6; + this->boundingBox = &gUnk_080B3E18; + this->attachedEntity->spriteOffsetX = 0; + this->attachedEntity->spriteSettings.b.draw = 0; + } + else { + if (gLinkState.field_0x1c == 0) { + DeleteThisEntity(); + } + this->action = 2; + this->spriteSettings.b.draw = 1; + this->spriteTileSize = 0xa6; + this->palette = 0x33; + this->spriteVramOffset = 0; + (this->entityType).form = gLinkState.filler9[0] - 1; + this->actionDelay = gUnk_080B3DE0[(this->entityType).form * 2]; + this->field_0x44 = gUnk_080B3DE0[(this->entityType).form * 2 + 1]; + this->field_0x40 = 0x1b; + this->boundingBox = gUnk_080B3DE8[(this->entityType).form]; + (u32 *)gLinkEntity.field_0x70.WORD = this; + sub_08078CD0(&gLinkEntity); + (u32 *)gLinkEntity.field_0x70.WORD = pEVar3; + InitializeAnimation(this, (this->entityType).form + 10); + sub_08018FA0(this); + } + sub_0801766C(this); +} + +void sub_08018DE8(Entity *this) +{ + u8 bVar1; + + bVar1 = this->attachedEntity->field_0x3a & 4; + if (bVar1 == 0) { + gLinkState.field_0x1c = bVar1; + DeleteThisEntity(); + } + switch (gLinkState.field_0x1c) { + case 0: + sub_08018F6C(this); + break; + case 5: + this->attachedEntity->previousActionFlag = 4; + this->flags = this->flags | 0x80; + this->action = 2; + this->spritePriority.b0 = 2; + this->attachedEntity->spriteSettings.b.draw = 1; + sub_08018FA0(this); + break; + } + sub_08078CD0(&gLinkEntity); +}
\ No newline at end of file diff --git a/src/loadRoom.c b/src/loadRoom.c index 7acf18d1..c429264b 100644 --- a/src/loadRoom.c +++ b/src/loadRoom.c @@ -3,7 +3,7 @@ void LoadRoomEntityList(); s32 CheckGlobalFlag(u32 flag); -extern s32* sub_0804B128(u8 unk); +extern s32* GetCurrentRoomProperty(u8 unk); extern void sub_0804B058(s32* unk); extern void sub_0804B1AC(); extern void sub_0801AC98(); @@ -15,13 +15,13 @@ void LoadRoom(void) s32 iVar1; s32* dat; - sub_0804B128(1); + GetCurrentRoomProperty(1); LoadRoomEntityList(); - sub_0804B128(0); + GetCurrentRoomProperty(0); LoadRoomEntityList(); - if (CheckGlobalFlag(21)) sub_0804B058(sub_0804B128(2)); - sub_0804B128(3); + if (CheckGlobalFlag(21)) sub_0804B058(GetCurrentRoomProperty(2)); + GetCurrentRoomProperty(3); sub_0804B1AC(); sub_0801AC98(); } diff --git a/src/mainLoop.c b/src/mainLoop.c index a9bf0d32..dcc0ebbf 100644 --- a/src/mainLoop.c +++ b/src/mainLoop.c @@ -1,7 +1,7 @@ #include "global.h" #include "main.h" -#ifdef NON_MATCHING +#if 0 typedef struct { u8 interruptFlag; @@ -52,6 +52,7 @@ void MainLoop(void) { bool32 codeInputted; u8 cVar1; u32 uVar2; + MainStruct *s; sub_08055F70(); sub_080A3204(); @@ -66,45 +67,42 @@ void MainLoop(void) { sub_08056418(); sub_080ADD30(); gRand = 0x1234567; - sub_0801D630(&gUnk_03001000, 16); + s = &gUnk_03001000; + sub_0801D630(s, 16); sub_08056010(0); - do { + while (1) { ReadKeyInput(); codeInputted = sub_08055FF4(); if (codeInputted) { sub_080560A8(); } - if ((gUnk_03001000.field_0x1 == 0) || (gUnk_03001000.field_0x1 != 1)) { - if (gUnk_03001000.field_0x8 != '\0') { - while (codeInputted) { + if ((s->field_0x1 != 0) || (s->field_0x1 == 1)) { + sub_08056260(); + } else if (s->field_0x8 != 0) { + while (--s->field_0x8) { VBlankInterruptWait(); - cVar1 = gUnk_03001000.field_0x8 + -1; - codeInputted = gUnk_03001000.field_0x8 != '\x01'; - gUnk_03001000.field_0x8 = cVar1; } } - if (gUnk_03001000.countdown != '\0') { - gUnk_03001000.countdown = gUnk_03001000.countdown + -1; - uVar2 = gUnk_03001000.field_0xa; - while (0 < uVar2) { + if (s->countdown != 0) { + s->countdown--; + uVar2 = s->field_0xa; + while (uVar2 > 0) { VBlankIntrWait(); - uVar2 = uVar2 - 1; + uVar2--; } } - gUnk_03001000.ticks = gUnk_03001000.ticks + 1; - gUnk_08100CBC[gUnk_03001000.loadType](); + s->ticks++; + gUnk_08100CBC[s->loadType](); sub_08056458(); sub_08050154(); sub_080A3480(); - } else { - sub_08056260(); } sub_08016E78(); - } while (TRUE); } -#else + +#endif + NAKED void MainLoop(void) { asm(".include \"asm/non_matching/mainLoop.inc\""); } -#endif diff --git a/src/manager/manager1.c b/src/manager/manager1.c new file mode 100644 index 00000000..ba556db0 --- /dev/null +++ b/src/manager/manager1.c @@ -0,0 +1,64 @@ +#include "global.h" +#include "entity.h" +#include "screen.h" + +extern void sub_0801D7EC(u32); +extern void sub_08056250(void); +extern void sub_080570B8(Entity*); +void sub_080570F8(void); +extern void sub_08052D74(void*, void*, void*); + +extern void (*const gUnk_08107C5C[])(Entity*); +extern void (*const gUnk_08107C48[])(Entity*); + +extern u8 gUnk_08107C40[]; + +void Manager1(Entity *this) +{ + u8 bVar1; + u8 *pbVar2; + + gUnk_08107C5C[this->action](this); + gUnk_08107C48[((u8*)&this->field_0x20)[1]](this); + bVar1 = gUnk_08107C40[((u8*)&this->field_0x20)[1]]; + if ((bVar1 != 0) && (*(u8 *)&this->field_0x20 != bVar1)) { + ((u8*)&this->field_0x20)[0] = bVar1; + sub_0801D7EC(bVar1); + } +} + +void sub_080570B8(Entity *this) +{ + u8 *pbVar1; + + sub_0801D7EC(((u8 *)&this->field_0x20)[0]); + this->height.WORD = 0; + pbVar1 = ((u8 *)&this->field_0x20 + 1); + if (*pbVar1 == 3) { + gScreen.affine.bg3xOffset = 1; + } + else { + gUnk_08107C48[*pbVar1](this); + } +} + +void sub_080570F8(void) +{ + gScreen.lcd.lcdControl2 &= 0xf7ff; + gScreen.controls.windowOutsideControl = 0; + sub_08056250(); +} + +void sub_08057118(Entity *this) +{ + this->actionDelay = 0; + *(u8 *)&this->field_0x20 = 0; + ((u8 *)&this->field_0x20)[1] = 0; + ((u8 *)&this->field_0x20)[2] = 0; + this->action = 1; + gScreen.affine.unk2 = 0x1e04; + *(u16 *)&gScreen.lcd.lcdControl2 |= 0x800; + gScreen.controls.windowOutsideControl = 0x3648; + gScreen.controls.mosaicSize = 0x1000; + sub_08052D74(this, sub_080570B8, sub_080570F8); +}
\ No newline at end of file diff --git a/src/manager/manager2.c b/src/manager/manager2.c new file mode 100644 index 00000000..707c13d1 --- /dev/null +++ b/src/manager/manager2.c @@ -0,0 +1,18 @@ +#include "global.h" +#include "entity.h" +#include "screen.h" + +extern void sub_080576A0(); +extern void sub_08052D74(); +extern void sub_0805754C(Entity*); + +void Manager2(Entity *this) +{ + if (this->action == 0) { + this->action = 1; + gScreen.affine.bg3xOffset = 0; + gScreen.bg2.bg0xOffset = 0; + sub_08052D74(this, sub_080576A0, 0); + } + sub_0805754C(this); +}
\ No newline at end of file diff --git a/src/manager27.c b/src/manager/manager27.c index db5bd8b6..db5bd8b6 100644 --- a/src/manager27.c +++ b/src/manager/manager27.c diff --git a/src/manager2E.c b/src/manager/manager2E.c index 3e528098..3e528098 100644 --- a/src/manager2E.c +++ b/src/manager/manager2E.c diff --git a/src/bigGoron.c b/src/npc/bigGoron.c index 28405514..0d6b9f3f 100644 --- a/src/bigGoron.c +++ b/src/npc/bigGoron.c @@ -1,10 +1,10 @@ #include "global.h" #include "entity.h" +#include "link.h" extern void (*gUnk_081140D4[])(Entity*); extern u16 gUnk_081140CC[]; -extern Entity gLinkEntity; extern u32 gUnk_030010A0; extern void sub_0805E3A0(Entity*, u32); extern void sub_0806D0B0(Entity*); diff --git a/src/bladeBrothers.c b/src/npc/bladeBrothers.c index 69a981f0..68630e8e 100644 --- a/src/bladeBrothers.c +++ b/src/npc/bladeBrothers.c @@ -22,7 +22,6 @@ extern void (*gUnk_081115D0[])(Entity*); extern struct_030010A0 gUnk_030010A0; extern u16 gUnk_081115DC[]; -extern Entity gLinkEntity; extern u8 gUnk_08111618[]; extern u32* gUnk_081115EC[]; extern struct_02002A40 gUnk_02002A40; @@ -123,7 +122,7 @@ void sub_08068ADC(Entity* this) { void sub_08068AFC(Entity* this) { this->action = 1; - this->spriteSettings.b.ss0 = 1; + this->spriteSettings.b.draw = 1; *(u8*)&this->field_0x68 = sub_0801E99C(this); sub_08078784(this, *(u8*)&this->field_0x68); sub_0807DD50(this); @@ -135,7 +134,7 @@ void FUN_08068b2c(Entity* this) { if (this->interactType == '\x02') { this->action = 2; this->interactType = '\0'; - uVar1 = sub_0806F5A4(sub_080045C4(this, &gLinkEntity)); + uVar1 = sub_0806F5A4(GetFacingDirection(this, &gLinkEntity)); InitAnimationForceUpdate(this, uVar1); sub_0806F118(this); } else { @@ -177,7 +176,7 @@ void sub_08068BEC(Entity* this, u32 unused) { target = CreateFx(this, 0x44, 0); if (target) { - target->ticks.b0 = 1; + target->spritePriority.b0 = 1; PositionRelative(this, target, 0, -0x100000); PlaySFX(0xfa); } @@ -401,8 +400,8 @@ void BladeBrothers_Fusion(Entity* this) { if (this->action == 0) { this->action += 1; - this->spriteSettings.b.ss0 = 0; - this->spriteSettings.b.ss0 = 1; + this->spriteSettings.b.draw = 0; + this->spriteSettings.b.draw = 1; InitAnimationForceUpdate(this, 4); } else { UpdateAnimationSingleFrame(this); diff --git a/src/npc/carpenter.c b/src/npc/carpenter.c new file mode 100644 index 00000000..b0608f6d --- /dev/null +++ b/src/npc/carpenter.c @@ -0,0 +1,74 @@ +#include "global.h" +#include "entity.h" +#include "sprite.h" +#include "link.h" + +extern void DeleteThisEntity(); +extern u32 LoadExtraSpriteData(Entity*, SpriteLoadData*); +extern SpriteLoadData gUnk_08110CA8[]; +extern void sub_0805E3A0(Entity*, u32); +extern void sub_0807DD64(Entity*); +extern u32 GetFacingDirection(Entity*, Entity*); +extern void sub_0806F118(Entity*); +extern void sub_0807DDAC(Entity*, u32); +extern void sub_0807DDE4(Entity*); +extern u32 UpdateFuseInteraction(Entity*); +extern void SetSpriteSubEntryOffsetData2(Entity*, u32, u32); +extern void sub_0807000C(Entity*); +extern u32 sub_0806F5A4(); + +void Carpenter(Entity* this) { + if (*(u32*)&this->cutsceneBeh == 0) { + DeleteThisEntity(); + } + switch (this->action) { + case 0: + if (!LoadExtraSpriteData(this, gUnk_08110CA8 + this->entityType.form * 4)) + break; + this->action = 1; + this->field_0x69 = 0; + sub_0805E3A0(this, 2); + sub_0807DD64(this); + + case 1: + if (this->interactType == 2) { + this->action = 2; + this->interactType = 0; + this->field_0x69 = this->animIndex; + InitializeAnimation(this, sub_0806F5A4(GetFacingDirection(this, &gLinkEntity)) + 4 + (this->entityType.form * 8)); + sub_0806F118(this); + } else { + sub_0807DDAC(this, 0); + sub_0807DDE4(this); + GetNextFrame(this); + } + break; + case 2: + if (!UpdateFuseInteraction(this)) + break; + this->action = 1; + InitializeAnimation(this, this->field_0x69); + break; + } +} + +void Carpenter_Head(Entity* this) { + if ((this->entityType).form < 2) { + SetExtraSpriteFrame(this, 0, this->frames.all & 0xffffff7f); + SetExtraSpriteFrame(this, 1, this->frameIndex); + SetExtraSpriteFrame(this, 2, this->frameSpriteSettings & 0x3f); + SetSpriteSubEntryOffsetData1(this, 1, 0); + SetSpriteSubEntryOffsetData2(this, 1, 2); + sub_0807000C(this); + } else { + SetExtraSpriteFrame(this, 0, this->frames.all & 0xffffff7f); + SetExtraSpriteFrame(this, 1, this->frameIndex); + SetSpriteSubEntryOffsetData1(this, 1, 0); + sub_0807000C(this); + } +} + +void sub_080672b0(Entity *this, u32 param_2) +{ + InitializeAnimation(this,*(u32 *)(param_2 + 4) + (this->animationState >> 1) + this->entityType.form * 8); +}
\ No newline at end of file diff --git a/src/cat.c b/src/npc/cat.c index 1ec7df88..1ec7df88 100644 --- a/src/cat.c +++ b/src/npc/cat.c diff --git a/src/clothesRack.c b/src/npc/clothesRack.c index 9dd18b37..9dd18b37 100644 --- a/src/clothesRack.c +++ b/src/npc/clothesRack.c diff --git a/src/cow.c b/src/npc/cow.c index 9a1ebba3..633334b1 100644 --- a/src/cow.c +++ b/src/npc/cow.c @@ -4,7 +4,6 @@ extern void sub_0806ED78(Entity*); extern void sub_0806920C(Entity*); -extern void UpdateAnimationSingleFrame(Entity*); extern u32 sub_0805ACC0(Entity*); extern u32 sub_0801E99C(Entity*); extern void sub_0806924C(Entity*); @@ -17,7 +16,6 @@ extern void sub_080791D0(); extern void (*gUnk_08111914[])(Entity*); extern void (*gUnk_08111928[])(Entity*); extern u32 gUnk_08111938[]; -extern void InitAnimationForceUpdate(); extern void PlaySFX(u32); extern u32 Random(); extern u32 UpdateFuseInteraction(Entity*); @@ -231,7 +229,7 @@ void sub_0806924C(Entity* ent) { void Cow_Fusion(Entity* ent) { if (ent->action == 0) { ent->action++; - ent->spriteSettings.b.ss0 = 1; + ent->spriteSettings.b.draw = 1; InitAnimationForceUpdate(ent, 15); } else { UpdateAnimationSingleFrame(ent); diff --git a/src/npc/dampe.c b/src/npc/dampe.c new file mode 100644 index 00000000..b7947c32 --- /dev/null +++ b/src/npc/dampe.c @@ -0,0 +1,116 @@ +#include "global.h" +#include "entity.h" +#include "link.h" +#include "room.h" +#include "flags.h" +#include "sprite.h" +#include "textbox.h" +#include "npc.h" + +extern void sub_0805E3A0(Entity*, u32); +extern void sub_0807DD50(Entity*); +extern u32 sub_0806F5A4(u32); +extern void sub_0806F118(Entity*); +extern void sub_0807DD94(Entity*, u32); +extern u32 sub_0801E99C(void); +extern void sub_08078784(Entity*, u32); + +extern u16 gUnk_08113344[]; +extern u16 gUnk_0811334A[]; + +typedef struct { + u8 filler[18]; + u32 unk; +} struct_0806BE84; + +void Dampe(Entity* this) { + + switch (this->action) { + case 0: + this->action = 1; + this->spriteSettings.b.draw = 1; + sub_0805E3A0(this, 2); + sub_0807DD50(this); + return; + case 1: + if (this->interactType == 2) { + this->action = 2; + this->interactType = 0; + InitAnimationForceUpdate(this, sub_0806F5A4(GetFacingDirection(this, &gLinkEntity)) + 4); + sub_0806F118(this); + } else { + sub_0807DD94(this, 0); + } + return; + case 2: + UpdateAnimationSingleFrame(this); + if (UpdateFuseInteraction(this)) { + this->action = 1; + } + default: + } +} + +void sub_0806BE3C(Entity* this) { + this->field_0x68 = sub_0801E99C(); + sub_08078784(this, this->field_0x68); +} + +void Dampe_Fusion(Entity* this) { + if (this->action == 0) { + this->action++; + this->spriteSettings.b.draw = 1; + InitAnimationForceUpdate(this, 2); + } else { + UpdateAnimationSingleFrame(this); + } +} + +void sub_0806BE84(Entity* this, struct_0806BE84* r1) { + u32 msgIndex; + + r1->unk = 0; + msgIndex = 1; + if (!CheckLocalFlag(0x69)) { + msgIndex = 0; + SetLocalFlag(0x69); + r1->unk = 1; + } + // Graveyard key + if (GetInventoryValue(0x3C) >= 2) { + msgIndex = 2; + } + TextboxNoOverlap(gUnk_08113344[msgIndex], this); +} + +void sub_0806BEC8(Entity* this, struct_0806BE84* r1) { + u32 hasGraveyardKey; + u32 msgIndex; + + msgIndex = 0; + r1->unk = 0; + hasGraveyardKey = GetInventoryValue(0x3C); + if (hasGraveyardKey == 1) { + msgIndex = 1; + r1->unk = 1; + } else if (hasGraveyardKey >= 2) { + msgIndex = 2; + } + + TextboxNoOverlap(gUnk_0811334A[msgIndex], this); +} + +void sub_0806BEFC() { + SetTileType(0x17E, 0x58E, 1); + SetTileType(0x17F, 0x58F, 1); + SetTileType(0x180, 0x5CE, 1); + SetTileType(0x181, 0x5CF, 1); +} + +void sub_0806BF44(Entity* this, struct_0806BE84* r1) { + r1->unk = 0; + if (((this->x.HALF.HI - gRoomControls.roomScrollX) + 0x10U < 0x110) && + ((this->y.HALF.HI - gRoomControls.roomScrollY) + 0x18U < 0xD0)) { + r1->unk = 1; + } +} diff --git a/src/emma.c b/src/npc/emma.c index c43b961c..c43b961c 100644 --- a/src/emma.c +++ b/src/npc/emma.c diff --git a/src/epona.c b/src/npc/epona.c index 0d294408..617867b6 100644 --- a/src/epona.c +++ b/src/npc/epona.c @@ -18,7 +18,7 @@ void Epona(Entity* this) { void sub_080659B8(Entity* this) { this->action = 1; - this->spriteSettings.b.ss0 = 1; + this->spriteSettings.b.draw = 1; this->animationState = 6; this->field_0x69 = -1; this->field_0x68 = sub_0801E99C(this); @@ -78,7 +78,7 @@ void sub_08065AA4(Entity* this) { sub_0805E3A0(this, 2); sub_08065A50(this); } - InitAnimationForceUpdate(this, sub_0806F5A4(sub_080045C4(this, &gLinkEntity))); + InitAnimationForceUpdate(this, sub_0806F5A4(GetFacingDirection(this, &gLinkEntity))); } else { sub_08065A50(this); sub_080791D0(); @@ -91,7 +91,7 @@ void sub_08065AA4(Entity* this) { void Epona_Fusion(Entity* this) { if (this->action == 0) { this->action += 1; - this->spriteSettings.b.ss0 = 1; + this->spriteSettings.b.draw = 1; InitAnimationForceUpdate(this, 7); } else { UpdateAnimationSingleFrame(this); diff --git a/src/npc/festari.c b/src/npc/festari.c new file mode 100644 index 00000000..ff64ccd6 --- /dev/null +++ b/src/npc/festari.c @@ -0,0 +1,91 @@ +#include "global.h" +#include "entity.h" +#include "npc.h" +#include "link.h" + +extern void sub_0805E3A0(Entity*, u32); +extern u32 sub_0801E99C(Entity*); +extern void sub_08078784(Entity*, u32); +extern void sub_0807DD50(Entity*); +extern void sub_0806F118(Entity*); +extern void ExecuteScriptCommandSet(Entity*, void *); +extern void sub_0805FF2C(Entity*, void*); +extern void sub_0806ED78(Entity*); + +extern void (*const gUnk_08109BBC[])(Entity*); + + +void Festari(Entity *this) +{ + gUnk_08109BBC[this->action](this); +} + +void sub_0805FE10(Entity *this) +{ + this->action = 1; + this->spriteSettings.b.draw = TRUE; + sub_0805E3A0(this, 2); + this->field_0x68 = sub_0801E99C(this); + sub_08078784(this, this->field_0x68); + sub_0807DD50(this); +} + +#if NON_MATCHING +void sub_0805FE48(Entity *this) +{ + u8 bVar1; + u16 uVar2; + u32 uVar3; + u32 uVar4; + + if (this->interactType == 2) { + this->action = 2; + this->interactType = 0; + InitAnimationForceUpdate(this, sub_0806F5A4(GetFacingDirection(this, &gLinkEntity))); + sub_0806F118(this); + } + else { + ExecuteScriptCommandSet(this, *(void **)&this->cutsceneBeh); + sub_0805FF2C(this, *(void **)&this->cutsceneBeh); + if (this->field_0x80 < 8) { + if ((this->field_0x82 & 1) != 0) { + uVar4 = (uVar4 & 0xfc) + (this->field_0xf >> 1); + } + else { + uVar4 = (uVar4 & 0xfc) + (this->animationState >> 1); + this->field_0xf = this->animationState; + } + } + if (uVar4 != this->animIndex) { + InitAnimationForceUpdate(this, uVar4); + } + UpdateAnimationSingleFrame(this); + + if (this->frames.b.f3) + { + switch (this->animIndex) { + case 8: + case 10: + case 11: + case 12: + this->field_0x80 = 0; + } + } + if ((this->field_0x82 & (~this->field_0x82 + 1)) == 2) { + sub_0806ED78(this); + } + } +} +#else +NAKED +void sub_0805FE48(Entity *this) { + asm(".include \"asm/non_matching/festari/sub_0805FE48.inc\""); +} +#endif + +void sub_0805FF18(Entity *this) +{ + if (UpdateFuseInteraction(this)) { + this->action = 1; + } +}
\ No newline at end of file diff --git a/src/npc/forestMinish.c b/src/npc/forestMinish.c new file mode 100644 index 00000000..29a4ea6a --- /dev/null +++ b/src/npc/forestMinish.c @@ -0,0 +1,304 @@ +#include "global.h" +#include "entity.h" +#include "npc.h" +#include "flags.h" +#include "textbox.h" +#include "link.h" + +extern void sub_0805E3A0(Entity*, u32); +extern void StartCutscene(Entity*, void*); +extern void sub_0807DD50(Entity*); +extern void sub_0806F118(Entity*); +extern void sub_0807DDAC(Entity*, u32); +extern void sub_0807DDE4(Entity*); +extern void sub_080600F0(Entity*); +extern u32 sub_0801E99C(Entity*); +extern void sub_08078784(Entity*, u32); +extern void sub_0807000C(Entity*); +extern void sub_080042BA(Entity*, u32); +extern void sub_08060158(Entity*); +extern u32 CheckKinstoneFused(u32); +extern Entity* sub_0805EB00(u32, u32, u32); +extern void sub_080A29BC(Entity* parent); +extern void DeleteEntity(Entity*); +extern u32 Random(void); +extern void ModBombs(s32); + +extern SpriteLoadData gUnk_0810A348; +extern void* gUnk_08109D18[]; +extern u8 gUnk_08109C98[]; +extern u16 gUnk_0810A354[]; +extern u32 gUnk_08109DC8[]; +extern u16 gUnk_0810A35A[]; +extern u16 gUnk_0810A362[]; + +void ForestMinish(Entity* this) { + switch (this->action) { + case 0: + if (LoadExtraSpriteData(this, &gUnk_0810A348)) { + this->action = 1; + this->spriteSettings.b.draw = TRUE; + this->field_0x69 = this->animationState = this->actionDelay << 1; + this->actionDelay = 0; + sub_0805E3A0(this, 2); + StartCutscene(this, gUnk_08109D18[this->entityType.parameter]); + sub_0807DD50(this); + } + break; + case 1: + if (this->interactType == 2) { + this->action = 2; + this->interactType = 0; + sub_0806F118(this); + } else { + sub_0807DDAC(this, 0); + sub_0807DDE4(this); + if (this->frameDuration != 0xf0) { + sub_080600F0(this); + } + } + break; + case 2: + if (UpdateFuseInteraction(this)) { + this->action = 1; + } + } +} + +void sub_08060090(Entity* this) { + this->field_0x68 = sub_0801E99C(this); + sub_08078784(this, this->field_0x68); +} + +void ForestMinish_Head(Entity* this) { + u32 pbVar1; + + pbVar1 = this->frames.all; + if (this->frames.all != 0xff) { + pbVar1 &= -0x81; + } + if ((this->frameSpriteSettings & 1) == 0) { + pbVar1 = 0xff; + } + SetExtraSpriteFrame(this, 0, pbVar1); + SetExtraSpriteFrame(this, 1, this->frameIndex); + SetSpriteSubEntryOffsetData1(this, 1, 0); + sub_0807000C(this); +} + +void sub_080600F0(Entity* this) { + u32 uVar1; + u32 uVar2; + + uVar2 = this->field_0x80; + if (this->field_0x80 < 8) { + if ((this->field_0x82 & 1) != 0) { + uVar2 = (uVar2 & 0xfc) + (this->field_0xf >> 1); + } else { + uVar2 = (uVar2 & 0xfc) + (this->animationState >> 1); + this->field_0xf = this->animationState; + } + } + if (uVar2 != this->animIndex) { + InitAnimationForceUpdate(this, uVar2); + } + if ((this->field_0x82 & 4) != 0) { + uVar1 = 2; + } else { + uVar1 = 1; + } + sub_080042BA(this, uVar1); +} + +void sub_0806014C(Entity* this) { + this->actionDelay = 0; + sub_08060158(this); +} + +#if 0 +void sub_08060158(Entity *this) +{ + u8 bVar1; + u8 bVar2; + s32 iVar4; + u32 temp; + if (this->actionDelay != 0) { + this->actionDelay--; + } + else { + this->actionDelay = 2; + iVar4 = sub_0806EDD8(this, 0x20, 0x20); + if (iVar4 < 0) { + this->animationState = this->field_0x69; + iVar4 = this->field_0x69 << 2; + } + temp = (this->animationState >> 1) * 0x20 + (iVar4 >> 1) * 2; + bVar1 = gUnk_08109C98[temp]; + bVar2 = gUnk_08109C98[temp + 1]; + if ((bVar2 & 0x80) != 0) { + this->animationState = sub_0806F5B0(iVar4); + } + this->frames.all = bVar1; + this->frameIndex = bVar2 & 0x7f; + this->frameSpriteSettings = 1; + this->animIndex = 0; + this->frameDuration = 0xf0; + } +} +#endif +NAKED +void sub_08060158(Entity* this) { + asm(".include \"asm/non_matching/forestMinish/sub_08060158.inc\""); +} + +void sub_080601D4(Entity* this) { + u32 temp; + u32 uVar2; + + if (CheckGlobalFlag(4) == 0) { + uVar2 = 2; + } else { + temp = CheckKinstoneFused(0x17); + uVar2 = (-temp | temp) >> 0x1f; + } + TextboxNoOverlap(gUnk_0810A354[uVar2], this); +} + +void sub_08060208(Entity *this) +{ + ShowNPCDialogue(this, &gUnk_08109DC8[this->entityType.parameter * 0x8]); +} + +void sub_0806021C(Entity *this) +{ + u32 uVar1; + u32 uVar2; + + //jabber nut + uVar1 = GetInventoryValue(0x5B); + uVar2 = (-uVar1 | uVar1) >> 0x1f; + + //earth element + if (GetInventoryValue(0x40)) { + uVar2 = 2; + } + + //mole mitts + if (GetInventoryValue(0x13)) { + uVar2 = 3; + } + ShowNPCDialogue(this, gUnk_08109DC8 + this->entityType.parameter * 0x8 + uVar2 * 2); +} + +void sub_0806025C(Entity *this) +{ + ShowNPCDialogue(this, &gUnk_08109DC8[this->entityType.parameter * 0x8]); +} + +void sub_08060270(Entity *this) +{ + u32 index; + + //flippers + if (GetInventoryValue(0x46) == 0) { + index = 1; + if (CheckGlobalFlag(0x29) == 0) { + index = 0; + SetGlobalFlag(0x29); + } + } + else { + index = 3; + if (CheckLocalFlag(0x76) == 0) { + index = 2; + SetLocalFlag(0x76); + } + } + TextboxNoOverlap(gUnk_0810A35A[index], this); +} + +void sub_080602BC(Entity *this) +{ + u32 index; + + //spin attack + if (GetInventoryValue(0x48) != 0) { + index = (Random() & 1) + 2; + } + else { + if (gUnk_02002A40.stats.bombCount < gBombBagSizes[gUnk_02002A40.stats.bombBagType]) { + index = 1; + } + else { + index = 0; + } + } + TextboxNoOverlap(gUnk_0810A362[index], this); +} + +void sub_0806030C(Entity* this, u32 *arg1) +{ + ModBombs(*(arg1 + 1)); +} + +void sub_08060318(void) +{ + Entity *ent; + int i; + + for (i = 2; i >= 0; i--) { + ent = sub_0805EB00(8, 2, 2); + if (ent != NULL) { + sub_080A29BC(ent); + DeleteEntity(ent); + } + } +} + +void sub_08060340(void) +{ + gUnk_02002A40.unk3 = gUnk_02002A40.unk2; +} + +u32 sub_08060354(void) +{ + u32 iVar1; + s32 iVar2; + + iVar2 = gUnk_02002A40.unk2 - gUnk_02002A40.unk3; + if (CheckGlobalFlag(0x3b) == 0) { + if (4 < iVar2) { + return 0x8444; + } + } + else { + if (CheckGlobalFlag(0x3c) == 0) { + if (iVar2 > 9) { + return 0x8444; + } + } + else { + if (CheckGlobalFlag(0x3d) == 0) { + if (iVar2 > 14) { + return 0x8444; + } + } + } + } + return 0; +} + +void ForestMinish_Fusion(Entity *this) +{ + if (this->action == 0) { + if (LoadExtraSpriteData(this, &gUnk_0810A348)) { + this->action++; + this->spriteSettings.b.draw = TRUE; + sub_0805E3A0(this, 2); + InitializeAnimation(this, 6); + } + } + else { + GetNextFrame(this); + } +}
\ No newline at end of file diff --git a/src/npc/gentari.c b/src/npc/gentari.c new file mode 100644 index 00000000..f41a7438 --- /dev/null +++ b/src/npc/gentari.c @@ -0,0 +1,53 @@ +#include "global.h" +#include "entity.h" +#include "npc.h" +#include "link.h" + +extern void sub_0805E3A0(Entity*, u32); +extern u32 sub_0801E99C(Entity*); +extern void sub_08078784(Entity*, u32); +extern void sub_0807DD50(Entity*); +extern u32 sub_0806F5A4(u32); +extern void sub_0806F118(Entity*); +extern void sub_0807DD94(Entity*, u32); + +void Gentari(Entity *this) +{ + switch (this->action) { + case 0: + this->action = 1; + this->spriteSettings.b.draw = TRUE; + sub_0805E3A0(this, 2); + this->field_0x68 = sub_0801E99C(this); + sub_08078784(this, this->field_0x68); + sub_0807DD50(this); + break; + case 1: + if (this->interactType == 2) { + this->action = 2; + this->interactType = 0; + InitAnimationForceUpdate(this, sub_0806F5A4(GetFacingDirection(this, &gLinkEntity))); + sub_0806F118(this); + } else { + sub_0807DD94(this, 0); + } + break; + case 2: + if (UpdateFuseInteraction(this)) { + this->action = 1; + } + } +} + +void Gentari_Fusion(Entity *this) +{ + if (this->action == 0) { + this->action++; + this->spriteSettings.b.draw = TRUE; + sub_0805E3A0(this, 2); + InitAnimationForceUpdate(this, 10); + } + else { + UpdateAnimationSingleFrame(this); + } +}
\ No newline at end of file diff --git a/src/goron.c b/src/npc/goron.c index 42124144..b65e97ea 100644 --- a/src/goron.c +++ b/src/npc/goron.c @@ -127,7 +127,7 @@ void sub_080694EC(Entity* this) { void Goron_Fusion(Entity* this) { if (this->action == 0) { this->action++; - this->spriteSettings.b.ss0 = 1; + this->spriteSettings.b.draw = 1; InitAnimationForceUpdate(this, 2); } else { UpdateAnimationSingleFrame(this); diff --git a/src/npc/guard.c b/src/npc/guard.c new file mode 100644 index 00000000..765a89dd --- /dev/null +++ b/src/npc/guard.c @@ -0,0 +1,196 @@ +#include "global.h" +#include "entity.h" +#include "link.h" +#include "flags.h" +#include "textbox.h" +#include "room.h" + +typedef struct { + u32 unk; + u32 entityCount; +} struct_03003DB8; + +typedef struct { + u8 filler[8]; + u8 unk; +} struct_030010A0; + +typedef struct { + u32 unk; + u32 unk2; +} struct_08064050; + +extern void sub_08063D24(Entity*); +extern void sub_0806ED78(Entity*); +extern u32 GetFacingDirection(Entity*, Entity*); +extern u32 sub_0806F5A4(u32); +extern void sub_0806EE20(Entity*); +extern void sub_08064428(Entity*); +extern u32 sub_0805ACC0(Entity*); +extern void sub_0807DDAC(Entity*, u32); +extern void sub_0807DDE4(Entity*); +extern void sub_0807000C(Entity*); + +extern void (*const gUnk_0810F544[])(Entity*); +extern void (*const gUnk_0810F550[])(Entity*); + +// entity count +extern u8 gUnk_03003DBC; +extern SpriteLoadData gUnk_0810F524[]; +extern void* gUnk_0810F6BC[]; +extern struct_030010A0 gUnk_030010A0; + +void Guard(Entity *this) +{ + if ((this->flags & 2) != 0) { + gUnk_0810F544[this->action](this); + } + else { + sub_08063D24(this); + } +} + +void sub_08063D24(Entity *this) +{ + gUnk_0810F550[this->action](this); + sub_0806ED78(this); +} + +NAKED +void sub_08063D44(Entity* this) { + asm(".include \"asm/non_matching/guard/sub_08063D44.inc\""); +} + +void sub_08063DC8(Entity *this) +{ + if ((this->entityType).form == 0xff) { + this->action = 2; + this->actionDelay = 0x1e; + this->animationState = sub_0806F5A4(GetFacingDirection(this,&gLinkEntity)); + InitAnimationForceUpdate(this, this->animationState + 4); + } + else { + sub_0806EE20(this); + if (this->field_0x3e != this->animationState) { + this->animationState = this->field_0x3e; + InitializeAnimation(this, this->animationState + 4); + } + else { + GetNextFrame(this); + } + if (this->interactType != 0) { + this->action = 3; + this->interactType = 0; + InitializeAnimation(this, sub_0806F5A4(GetFacingDirection(this,&gLinkEntity))); + sub_08064428(this); + } + } +} + +void sub_08063E54(Entity *this) +{ + if (--this->actionDelay == 0) { + SetRoomFlag(0xf); + } +} + +void sub_08063E6C(Entity *this) +{ + if ((gTextBox.doTextBox & 0x7f) == 0) { + this->action = 1; + InitializeAnimation(this, this->animationState + 4); + } +} + +NAKED +void sub_08063E90(Entity* this) { + asm(".include \"asm/non_matching/guard/sub_08063E90.inc\""); +} + +void sub_08063F20(Entity *this) +{ + sub_0807DDAC(this, 0); + sub_0807DDE4(this); + GetNextFrame(this); + if (this->interactType != 0) { + this->action++; + this->interactType = 0; + InitializeAnimation(this, sub_0806F5A4(GetFacingDirection(this, &gLinkEntity)) + *(s8 *)&this->field_0x70); + sub_08064428(this); + } +} + +void sub_08063F78(Entity *this) +{ + if ((gTextBox.doTextBox & 0x7f) == 0) { + this->action = this->action - 1; + InitializeAnimation(this,(this->animationState >> 1) + 4 + *(s8 *)&this->field_0x70); + } +} + +void Guard_Head(Entity *this) +{ + u8 bVar1; + u32 uVar2; + u32 pbVar3; + u32 uVar4; + u32 pbVar5; + + uVar2 = this->frames.all & 0x3f; + pbVar5 = (this->frameIndex & 0x3f); + uVar4 = this->frameSpriteSettings & 0x3f; + if ((this->entityType).subtype == 0x15) { + if ((this->frameIndex & 0x40) != 0) { + pbVar5 = pbVar5 + 0x21; + pbVar3 = 0xffffffff; + uVar4 = 0; + } + else { + pbVar3 = (uVar2 + 0x19); + if ((this->frameSpriteSettings & 0x3f) != 0) { + uVar4 += 0x1f; + } + } + } + else { + pbVar3 = (uVar2 + 0x46); + pbVar5 = pbVar5 + 0x2d; + if ((this->frameSpriteSettings & 0x3f) != 0) { + uVar4 += 0x4c; + } + } + uVar4--; + SetExtraSpriteFrame(this, 0, pbVar3); + SetExtraSpriteFrame(this, 1, pbVar5); + SetExtraSpriteFrame(this, 2, uVar4); + SetSpriteSubEntryOffsetData1(this, 1, 0); + SetSpriteSubEntryOffsetData2(this, 1, 2); + sub_0807000C(this); +} + +void sub_08064030(Entity *arg0,Entity *arg1) +{ + *(u32*)&arg1->animationState = (-gRoomVars.greatFairyState | gRoomVars.greatFairyState) >> 0x1f; +} + +void sub_08064044(void) +{ + gUnk_030010A0.unk = 1; +} + +void sub_08064050(Entity *arg0, struct_08064050 *arg1) +{ + u32 unk; + + arg1->unk2 = 0; + switch (arg0->entityType.parameter) { + case 0x11: + arg1->unk2 = 1; + break; + case 0x12: + arg1->unk2 = 2; + break; + case 0x13: + arg1->unk2 = 3; + } +}
\ No newline at end of file diff --git a/src/mailbox.c b/src/npc/mailbox.c index c744cc4e..1aca5a34 100644 --- a/src/mailbox.c +++ b/src/npc/mailbox.c @@ -1,12 +1,9 @@ #include "global.h" #include "entity.h" +#include "textbox.h" extern void sub_0806ED78(Entity*); -extern void InitAnimationForceUpdate(); extern void sub_08063280(); -extern void TextboxNoOverlapFollow(u32); -extern void UpdateAnimationSingleFrame(); -extern void CreateFx(); extern void (*gMailboxBehaviors[4])(Entity*); @@ -34,7 +31,7 @@ void sub_08063220(Entity* this) { } if (this->animIndex != bVar1) { - InitAnimationForceUpdate(this); + InitAnimationForceUpdate(this, bVar1); } else { sub_08063280(this, bVar1); } @@ -57,7 +54,7 @@ void sub_08063280(Entity* this, u32 unused) { u8 var; // r2@1 e = this; - UpdateAnimationSingleFrame(); + UpdateAnimationSingleFrame(e); var = e->frames.all & 0x7F; e->frames.all ^= var; if (var == 2) CreateFx(e, 49, 0); diff --git a/src/malon.c b/src/npc/malon.c index 3f9c4517..de484cc4 100644 --- a/src/malon.c +++ b/src/npc/malon.c @@ -20,7 +20,7 @@ void Malon(Entity* this) { void sub_08065864(Entity* this) { this->action = 1; - this->spriteSettings.b.ss0 = 1; + this->spriteSettings.b.draw = 1; InitAnimationForceUpdate(this, 0xC); } @@ -30,7 +30,7 @@ void sub_08065880(Entity* this) { void sub_08065888(Entity* this) { this->action = 1; - this->spriteSettings.b.ss0 = 1; + this->spriteSettings.b.draw = 1; this->animationState = 4; this->field_0x68 = sub_0801E99C(this); sub_08078784(this, this->field_0x68); @@ -41,7 +41,7 @@ void sub_080658BC(Entity* this) { if (this->interactType == 2) { this->action = 2; this->interactType = 0; - InitAnimationForceUpdate(this, sub_0806F5A4(sub_080045C4(this, &gLinkEntity))); + InitAnimationForceUpdate(this, sub_0806F5A4(GetFacingDirection(this, &gLinkEntity))); sub_0806F118(this); } else { sub_0807DD94(this, 0); @@ -72,7 +72,7 @@ void sub_08065914(Entity* this) { void Malon_Fusion(Entity* this) { if (this->action == 0) { this->action++; - this->spriteSettings.b.ss0 = 1; + this->spriteSettings.b.draw = 1; InitAnimationForceUpdate(this, 0xC); } else { UpdateAnimationSingleFrame(this); diff --git a/src/milkCart.c b/src/npc/milkCart.c index 2c1bc52f..b423dca7 100644 --- a/src/milkCart.c +++ b/src/npc/milkCart.c @@ -1,10 +1,7 @@ #include "global.h" #include "entity.h" -extern void _call_via_r1(Entity*, u32); extern void sub_0806ED78(); -extern void InitAnimationForceUpdate(); -extern void UpdateAnimationSingleFrame(); extern void (*gMilkCartBehaviors[2])(Entity*); @@ -15,8 +12,8 @@ void MilkCart(Entity* ent) { void sub_08065B6C(Entity* ent) { ent->action++; - ent->spriteSettings.b.ss0 = 1; - (ent->y).HALF.LO += -0x8000; + ent->spriteSettings.b.draw = 1; + ent->y.HALF.LO += -0x8000; ent->animationState = 6; InitAnimationForceUpdate(ent, 3); } diff --git a/src/npc/mutoh.c b/src/npc/mutoh.c new file mode 100644 index 00000000..b50ff552 --- /dev/null +++ b/src/npc/mutoh.c @@ -0,0 +1,99 @@ +#include "global.h" +#include "entity.h" +#include "link.h" +#include "flags.h" +#include "textbox.h" +#include "npc.h" + +extern void sub_0805E3A0(Entity*, u32); +extern void sub_0807DD50(Entity*); +extern u32 GetFacingDirection(Entity*, Entity*); +extern u32 sub_0806F5A4(u32); +extern void sub_0806F118(Entity*); +extern void sub_0807DD94(Entity*, u32); +extern u32 UpdateFuseInteraction(Entity*); +extern void sub_0807000C(Entity*); +extern u32 sub_0801E99C(Entity*); +extern void sub_08078784(Entity*, u32); + +extern SpriteLoadData gUnk_08110C00; +extern u16 gUnk_08110C0C[]; +extern u32 gUnk_08110C10[]; + +void Mutoh(Entity* this) +{ + if (*(u32*)&this->cutsceneBeh == 0) { + DeleteThisEntity(); + } + + switch (this->action) { + case 0: + if (LoadExtraSpriteData(this, &gUnk_08110C00)) { + this->action = 1; + this->spriteSettings.b.draw = TRUE; + sub_0805E3A0(this, 2); + sub_0807DD50(this); + } + break; + case 1: + if (this->interactType == 2) { + this->action = 2; + this->interactType = 0; + InitAnimationForceUpdate(this, sub_0806F5A4(GetFacingDirection(this, &gLinkEntity)) + 4); + sub_0806F118(this); + } else { + sub_0807DD94(this, 0); + } + break; + case 2: + if (UpdateFuseInteraction(this)) { + this->action = 1; + } + } +} + +void Mutoh_Head(Entity *this) +{ + SetExtraSpriteFrame(this, 0, (this->frames.all & -0x81)); + SetExtraSpriteFrame(this, 1, this->frameIndex); + SetSpriteSubEntryOffsetData1(this,1,0); + sub_0807000C(this); +} + +void sub_080670B4(Entity *this) +{ + u32 uVar1; + u32 uVar2; + + uVar2 = 0; + if (GetInventoryValue(0x11) == 0) { + uVar1 = CheckGlobalFlag(0x15); + uVar2 = (-uVar1 | uVar1) >> 0x1f; + } + TextboxNoOverlap(gUnk_08110C0C[uVar2],this); +} + +void sub_080670E4(Entity *this) +{ + ShowNPCDialogue(this, &gUnk_08110C10[gUnk_02002A40.unk * 2]); +} + +void sub_08067100(Entity *this) +{ + this->field_0x68 = sub_0801E99C(this); + sub_08078784(this, this->field_0x68); +} + +void Mutoh_Fusion(Entity *this) +{ + if (this->action == 0) { + if (LoadExtraSpriteData(this, &gUnk_08110C00) != 0) { + this->action++; + this->spriteSettings.b.draw = TRUE; + InitializeAnimation(this, 2); + } + } + else { + GetNextFrame(this); + } +}
\ No newline at end of file diff --git a/src/npc/npc9.c b/src/npc/npc9.c new file mode 100644 index 00000000..3954ed8f --- /dev/null +++ b/src/npc/npc9.c @@ -0,0 +1,53 @@ +#include "global.h" +#include "entity.h" +#include "textbox.h" + +extern void sub_08078778(Entity*); +extern void sub_0805E47C(Entity*); +extern void sub_0806ED78(Entity*); +extern void sub_0805E584(Entity*); + +extern void (*const gUnk_0810C290[])(Entity*); + +void NPC9(Entity *this) +{ + gUnk_0810C290[this->action](this); +} + +void sub_08062AF0(Entity *this) +{ + this->action = 1; + this->spriteSettings.b.draw = TRUE; + InitializeAnimation(this, 0); + sub_08078778(this); +} + +void sub_08062B14(Entity *this) +{ + GetNextFrame(this); + if (this->interactType != 0) { + this->interactType = 0; + this->action++; + InitializeAnimation(this, 1); + sub_0805E47C(this); + } + sub_0806ED78(this); +} + +void sub_08062B48(Entity *this) +{ + GetNextFrame(this); + if ((this->frames.b.f3) != 0) { + TextboxNoOverlapFollow(0xa01); + this->action++; + } +} + +void sub_08062B70(Entity *this) +{ + if ((gTextBox.doTextBox & 0x7f) == 0) { + InitializeAnimation(this, 2); + this->action = 1; + sub_0805E584(this); + } +}
\ No newline at end of file diff --git a/src/npc/postman.c b/src/npc/postman.c new file mode 100644 index 00000000..b3a51dba --- /dev/null +++ b/src/npc/postman.c @@ -0,0 +1,227 @@ +#include "global.h" +#include "entity.h" +#include "npc.h" +#include "textbox.h" +#include "link.h" + +typedef struct { + u8 filler[7]; + u8 unk; +} struct_02033280; + +extern void sub_08060528(Entity*); +extern void* GetCurrentRoomProperty(u32); +extern void sub_0806EE04(Entity*, void*, u32); +extern void sub_080604DC(Entity*); +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*); +extern u32 sub_0806F5A4(u32); +extern u32 GetFacingDirection(Entity*, Entity*); +extern void sub_080606D8(Entity*); +extern void sub_0807DD94(Entity*, u32); +extern void sub_080788E0(Entity*); +extern void sub_08004488(u32); +extern void sub_08003FC4(Entity*, u32); +extern void sub_080606C0(Entity*); +extern void sub_0800451C(Entity*); +extern void sub_08078784(Entity*, u32); +extern void sub_0807DEDC(Entity*, u32, u32, u32); + +extern void (*const gUnk_0810AA24[])(Entity*); +extern u32 gUnk_0810AA30[]; +extern u32** gUnk_0810A66C; +extern u32 gUnk_0810A918[]; +extern struct_02033280 gUnk_02033280; + +void Postman(Entity* this) { + if ((this->flags & 2) != 0) { + sub_08060528(this); + } else { + gUnk_0810AA24[this->action](this); + } +} + +void sub_08060428(Entity* this) { + u8 bVar1; + void* data; + + this->actionDelay = 0x5a; + this->nonPlanarMovement = 0x180; + if (this->entityType.parameter != 0) { + data = GetCurrentRoomProperty(this->entityType.parameter); + } else { + data = NULL; + } + sub_0806EE04(this, data, 0); + this->action = 1; + InitAnimationForceUpdate(this, 4); +} + +void sub_0806045C(Entity* this) { + u8 bVar1; + u32 uVar2; + u32 bVar3; + s32 temp; + + UpdateAnimationSingleFrame(this); + sub_080604DC(this); + switch (this->interactType) { + case 1: + case 2: + this->action = 2; + TextboxNoOverlapFollow(0); + break; + default: + bVar1 = this->field_0x3e; + if (bVar1 != this->animationState) { + this->animationState = bVar1; + InitAnimationForceUpdate(this, 4 + bVar1); + } + temp = sub_0806ED9C(this, 0x18, 0x18); + if ((temp > -1) && (temp == this->animationState)) { + bVar3 = 1; + } else { + bVar3 = 0; + } + if (!bVar3) { + sub_0806EE20(this); + } + } + sub_0806ED78(this); +} + +void sub_080604C8(Entity* this) { + UpdateAnimationSingleFrame(this); + sub_080604DC(this); + this->action = 1; +} + +void sub_080604DC(Entity* this) { + u8 bVar1; + int iVar2; + Entity* ent; + + if (((u32)(this->spriteSettings.raw << 0x1e) >> 0x1e == 1) && sub_080040A8(this)) { + if ((this->frames.all & 1) != 0) { + this->frames.all &= 0xfe; + ent = CreateFx(this, 0x11, 0x40); + if (ent != NULL) { + ent->y.HALF.HI++; + sub_0805E3A0(ent, 3); + } + } + } +} + +void sub_08060528(Entity *this) +{ + switch (this->action) { + case 0: + this->action = 1; + this->spriteSettings.b.draw = TRUE; + this->field_0x68 = 0; + this->field_0x69 = 0; + this->field_0x6a.HWORD = 0; + this->field_0x6d = 0; + this->field_0x6c = sub_0801E99C(this); + sub_0807DD50(this); + break; + case 1: + if (this->interactType == 2) { + this->action = 3; + this->interactType = 0; + sub_0806F118(this); + InitAnimationForceUpdate(this, sub_0806F5A4(GetFacingDirection(this, &gLinkEntity))); + } + else { + if (this->interactType != 0) { + this->action = 2; + this->interactType = 0; + sub_080606D8(this); + InitAnimationForceUpdate(this, sub_0806F5A4(GetFacingDirection(this, &gLinkEntity))); + } + else { + sub_0807DD94(this, 0); + } + } + break; + case 2: + UpdateAnimationSingleFrame(this); + if ((gTextBox.doTextBox & 0x7f) != 0) { + break; + } + this->action = 1; + break; + case 3: + UpdateAnimationSingleFrame(this); + if (!UpdateFuseInteraction(this)) { + break; + } + this->action = 1; + } + sub_080604DC(this); + if (0 < (s16)this->field_0x6a.HWORD) { + if ((s16)this->field_0x6a.HWORD > 0x12b) { + this->field_0x6a.HWORD = 0; + this->field_0x20 = 0x20000; + this->field_0x6d = 1; + sub_080788E0(this); + sub_08004488(0x7c); + } + else { + this->field_0x6a.HWORD -= 1; + } + } + sub_08003FC4(this, 0x1800); + if (((this->field_0x6d != 0) && (this->field_0x20 == 0)) && this->height.WORD == 0) { + this->field_0x6d = 0; + sub_080606C0(this); + } + if ((-1 < this->height.WORD) && + ((gLinkEntity.collisionLayer == 0 || (this->collisionLayer == gLinkEntity.collisionLayer)))) { + sub_0806ED78(this); + } + sub_0800451C(this); +} + +void sub_080606C0(Entity *this) +{ + this->field_0x6c = sub_0801E99C(this); + sub_08078784(this, this->field_0x6c); +} + +void sub_080606D8(Entity* this) +{ + s32 iVar1; + + iVar1 = gUnk_02002A40.unk - 2; + if (iVar1 < 0) { + iVar1 = 0; + } + ShowNPCDialogue(this, &gUnk_0810AA30[iVar1 * 2]); +} + +#if 0 +void sub_08060700(Entity *arg0, u32 arg1) +{ + sub_0807DEDC(arg0,arg1, + gUnk_0810A918[gUnk_0810A66C[arg0->field_0x69][arg0->field_0x68] * 4 + gRoomControls.roomOriginX], + gUnk_0810A918[gUnk_0810A66C[arg0->field_0x69][arg0->field_0x68] * 4 + gRoomControls.roomOriginY + 2]); + gUnk_02033280.unk |= 1; +} +#endif +NAKED void sub_08060700(Entity *arg0, u32 arg1) { + asm(".include \"asm/non_matching/postman/sub_08060700.inc\""); +} + +void sub_0806075C(Entity *this) +{ + this->field_0x68 = 0xb; + this->field_0x69 = 0xff; +}
\ No newline at end of file diff --git a/src/rem.c b/src/npc/rem.c index 8e3fe38f..2edd917e 100644 --- a/src/rem.c +++ b/src/npc/rem.c @@ -4,7 +4,6 @@ extern void sub_0807DDAC(Entity*, u32); extern void sub_0807DDE4(Entity*); -extern void UpdateAnimationSingleFrame(Entity*); extern void sub_0806ED78(Entity*); extern void PlaySFX(u32); extern void sub_0805E3A0(Entity*, u32); diff --git a/src/simon.c b/src/npc/simon.c index 45046de5..4e01af67 100644 --- a/src/simon.c +++ b/src/npc/simon.c @@ -16,7 +16,6 @@ typedef struct { extern void DoExitTransition(void *); extern void SetTileType(u32, u32, u32); -extern void CreateObjectWithParent(Entity*, u32, u32, u32); extern void DoExitTransition(void *); extern void DoFade(u32, u32); diff --git a/src/npc/smith.c b/src/npc/smith.c new file mode 100644 index 00000000..061d3c40 --- /dev/null +++ b/src/npc/smith.c @@ -0,0 +1,225 @@ +#include "global.h" +#include "entity.h" +#include "textbox.h" + +typedef struct { + u8 filler[8]; + u8 unk; +} struct_02002A40; + +extern u32 GetFacingDirection(Entity*, Entity*); +extern u32 sub_0806F5A4(u32); +extern void sub_0806F118(Entity*); +extern void sub_0806ED78(Entity*); +extern Entity* CreateFx(Entity*, u32, u32); +extern void PlaySFX(u32); +extern u32 Random(void); +extern void sub_0807000C(Entity*); +extern u32 sub_0801E99C(Entity*); +extern u32 sub_0806ED9C(Entity*, u32, u32); +extern u32 sub_0806F078(Entity*, u32); +extern void sub_0807DD50(Entity*); +extern void sub_0807DD94(Entity*, u32); +extern void sub_0807DDAC(Entity*, u32); +extern void sub_0807DDE4(Entity*); +extern u32 UpdateFuseInteraction(Entity*); +extern u32 GetAnimationState(Entity*); +extern void ShowNPCDialogue(Entity*, u32*); +extern void sub_08078850(u32, u32, u32, u32*); +extern void sub_08078784(Entity*, u32); + +extern void (*const gUnk_08110360[])(Entity*); +extern void (*const gUnk_0811036C[])(Entity*); + +extern u16 gUnk_08110380[]; +extern SpriteLoadData gUnk_08110354; +extern struct_02002A40 gUnk_02002A40; +extern u32 gUnk_08110390[]; +extern u16 gUnk_081103D0[]; +extern u32 gUnk_081103E0; + +#if NON_MATCHING //reg-alloc +void Smith(Entity *this) +{ + u32 iVar2; + u32 iVar4; + + if ((this->flags & 2) != 0) { + if (this->interactType == 2) { + this->action = 4; + this->interactType = 0; + iVar4 = (this->animIndex == 0xc) ? 8 : 0; + iVar2 = sub_0806F5A4(GetFacingDirection(this, &gLinkEntity)); + InitAnimationForceUpdate(this, iVar2 + iVar4); + sub_0806F118(this); + } + gUnk_0811036C[this->action](this); + } + else { + gUnk_08110360[this->action](this); + sub_0806ED78(this); + } + if (this->animIndex == 0xc) { + this->spritePriority.b1 = 0; + } + else { + this->spritePriority.b1 = 1; + } + if ((this->frames.all & 1) != 0) { + this->frames.all &= 0xfe; + CreateFx(this, 0x3d, 0x20); + PlaySFX(gUnk_08110380[(Random() & 7)]); + } +} +#else +NAKED +void Smith(Entity *this) { + asm(".include \"asm/non_matching/smith/smith.inc\""); +} +#endif + +void Smith_Head(Entity *this) +{ + u8 bVar1; + + bVar1 = this->frames.all; + SetExtraSpriteFrame(this, 0, this->frameIndex); + if ((bVar1 & 0x40) != 0) { + SetExtraSpriteFrame(this, 1, 0x16); + } + else { + SetExtraSpriteFrame(this, 1, 0xff); + } + SetSpriteSubEntryOffsetData1(this,0,1); + sub_0807000C(this); +} + +void sub_080660EC(Entity *this) +{ + if (LoadExtraSpriteData(this, &gUnk_08110354) != 0) { + this->action = 1; + this->field_0x68 = sub_0801E99C(this); + InitAnimationForceUpdate(this, 2); + } +} + +void sub_08066118(Entity *this) +{ + s32 uVar1; + u32 iVar2; + + uVar1 = sub_0806ED9C(this, 0x28, 0x28); + if (uVar1 < 0) { + uVar1 = 2; + } + else { + if (this->field_0xf == 0) { + this->field_0xf = 0x10; + } + else { + --this->field_0xf; + uVar1 = this->animIndex; + } + } + if (sub_0806F078(this, uVar1) == 0) { + UpdateAnimationSingleFrame(this); + } + if (this->interactType != 0) { + this->action = 2; + TextboxNoOverlapFollow(0); + } +} + +void sub_08066170(Entity *this) +{ + this->action = 1; +} + +void sub_08066178(Entity *this) +{ + if (LoadExtraSpriteData(this, &gUnk_08110354) != 0) { + this->action = 1; + this->spriteSettings.b.draw = 1; + this->field_0x68 = sub_0801E99C(this); + sub_0807DD50(this); + } +} + +void sub_080661B0(Entity *this) +{ + sub_0807DD94(this, 0); +} + +void sub_080661BC(Entity *this) +{ + u32 sVar1; + + if (this->animIndex == 0xc) { + UpdateAnimationSingleFrame(this); + if ((this->frames.b.f3) != 0) { + this->field_0x80 = GetAnimationState(this) + 8; + InitAnimationForceUpdate(this, this->field_0x80); + } + } + else { + sub_0807DD94(this,0); + } +} + +void sub_08066200(Entity *this) +{ + sub_0807DDAC(this, 0); + sub_0807DDE4(this); + UpdateAnimationSingleFrame(this); +} + +void sub_08066218(Entity *this) +{ + if (UpdateFuseInteraction(this) != 0) { + this->action = 1; + } +} + +void sub_0806622C(Entity *this) +{ + u32 iVar1; + + if (gUnk_02002A40.unk - 2 < 0) { + iVar1 = 0; + } + else { + iVar1 = gUnk_02002A40.unk - 2; + } + ShowNPCDialogue(this, &gUnk_08110390[iVar1 * 2]); +} + +void nullsub_501(Entity* this) {} + +void sub_08066258(void) +{ + PlaySFX(gUnk_081103D0[Random() & 7]); +} + +void sub_08066274(u32 arg0) +{ + sub_08078850(arg0, 1, 0, &gUnk_081103E0); +} + +void sub_08066288(Entity *arg0) +{ + sub_08078784(arg0, arg0->field_0x68); +} + +void Smith_Fusion(Entity *this) +{ + if (this->action == 0) { + if (LoadExtraSpriteData(this, &gUnk_08110354) != 0) { + this->action++; + this->spriteSettings.b.draw = 1; + InitAnimationForceUpdate(this, 6); + } + } + else { + UpdateAnimationSingleFrame(this); + } +}
\ No newline at end of file diff --git a/src/stamp.c b/src/npc/stamp.c index 656fb838..db1d7310 100644 --- a/src/stamp.c +++ b/src/npc/stamp.c @@ -2,15 +2,11 @@ #include "entity.h" #include "textbox.h" -extern void InitializeAnimation(Entity*, u32); extern void sub_08078778(Entity*); extern void sub_0805E47C(Entity*); -extern void GetNextFrame(Entity*); extern void sub_0806ED78(Entity*); -extern void TextboxNoOverlapFollow(u32); extern void sub_0805E584(); extern void sub_0807DD64(); -extern void CreateFx(); extern void sub_08062CA4(); extern void sub_0807DDAC(); extern void sub_0807DDE4(); @@ -20,29 +16,9 @@ extern void ShowNPCDialogue(); extern void (*gStampBehaviors1[4])(Entity*); extern void (*gStampBehaviors2[2])(Entity*); -extern TextBox gTextBox; extern u32 gUnk_0810C2E4; -extern void InitializeAnimation(Entity*, u32); -extern void sub_08078778(Entity*); -extern void sub_0805E47C(Entity*); -extern void GetNextFrame(Entity*); -extern void sub_0806ED78(Entity*); -extern void TextboxNoOverlapFollow(u32); -extern void sub_0805E584(); -extern void sub_0807DD64(); -extern void CreateFx(); -extern void sub_08062CA4(); -extern void sub_0807DDAC(); -extern void sub_0807DDE4(); -extern u32 CheckKinstoneFused(); -extern void ShowNPCDialogue(); -extern void (*gStampBehaviors1[4])(Entity*); -extern void (*gStampBehaviors2[2])(Entity*); - -extern TextBox gTextBox; -extern u32 gUnk_0810C2E4; void Stamp(Entity* ent) { if ((ent->flags & 2) != 0) { @@ -54,7 +30,7 @@ void Stamp(Entity* ent) { void sub_08062BD4(Entity* ent) { ent->action = 1; - ent->spriteSettings.b.ss0 = 1; + ent->spriteSettings.b.draw = 1; InitializeAnimation(ent, 0); sub_08078778(ent); } diff --git a/src/syrup.c b/src/npc/syrup.c index 4f0badb4..341c60c8 100644 --- a/src/syrup.c +++ b/src/npc/syrup.c @@ -4,10 +4,8 @@ extern void sub_0807DD50(Entity*); -extern Entity* LoadExtraSpriteData(Entity*, SpriteLoadData*); extern void sub_0806ED78(Entity*); extern void sub_0805E3A0(Entity*, u32); -extern void InitializeAnimation(Entity*, u32); extern void (*gUnk_081121D4[])(Entity*); @@ -26,7 +24,7 @@ void Syrup(Entity *this) void sub_0806A1F8(Entity *this) { - Entity *iVar1; + u32 iVar1; SpriteLoadData *paVar2; (this->entityType).form == 0 ? (paVar2 = &gUnk_081121B4) : (paVar2 = &gUnk_081121C4); diff --git a/src/talon.c b/src/npc/talon.c index 49b7de77..01449c06 100644 --- a/src/talon.c +++ b/src/npc/talon.c @@ -4,11 +4,9 @@ #include "functions.h" #include "link.h" -extern Entity gLinkEntity; - extern void (*gUnk_0810FEC4[])(Entity* this); extern void (*gUnk_0810FEBC[])(Entity* this); -extern u32 gUnk_0810FEB0; +extern SpriteLoadData gUnk_0810FEB0; extern u8 gUnk_0800B41C; extern u8 gUnk_0810FED8[]; @@ -65,7 +63,7 @@ void sub_0806559C(Entity* this) { void sub_08065608(Entity* this) { if (LoadExtraSpriteData(this, &gUnk_0810FEB0) != 0) { this->action = 1; - this->spriteSettings.b.ss0 = 1; + this->spriteSettings.b.draw = 1; this->field_0x68 = sub_0801E99C(this); sub_08078784(this, this->field_0x68); sub_0807DD50(this); @@ -128,7 +126,7 @@ void sub_080656D4(Entity* this) { void sub_0806574C(Entity* this) { u32 j; - j = (this->animIndex & ~3) + sub_0806F5A4(sub_080045C4(this, &gLinkEntity)); + j = (this->animIndex & ~3) + sub_0806F5A4(GetFacingDirection(this, &gLinkEntity)); if (this->animIndex != j) { InitAnimationForceUpdate(this, j); } @@ -154,7 +152,7 @@ void Talon_Fusion(Entity* this) { if (this->action == 0) { if (LoadExtraSpriteData(this, &gUnk_0810FEB0) != 0) { this->action++; - this->spriteSettings.b.ss0 = 1; + this->spriteSettings.b.draw = 1; InitializeAnimation(this, 6); } } else { diff --git a/src/npc/teachers.c b/src/npc/teachers.c new file mode 100644 index 00000000..a82bdadd --- /dev/null +++ b/src/npc/teachers.c @@ -0,0 +1,113 @@ +#include "global.h" +#include "entity.h" +#include "link.h" + +typedef struct { + u8 filler[8]; + u8 unk; +} struct_02002A40; + +extern SpriteLoadData gUnk_08113910[]; +extern void sub_0805E3A0(Entity*, u32); +extern void sub_0807DD50(Entity*); +extern u32 GetFacingDirection(Entity*, Entity*); +extern u32 sub_0806F5A4(u32); +extern void sub_0806F118(Entity*); +extern void sub_0807DD94(Entity*, u32); +extern u32 sub_0801E99C(); +extern void sub_08078784(Entity*, u32); +extern u32 UpdateFuseInteraction(Entity*); +extern void sub_0807000C(Entity*); +extern void ShowNPCDialogue(Entity*, u16*); + +extern struct_02002A40 gUnk_02002A40; +extern u16 gUnk_08113930[]; + +void Teachers(Entity* this) { + switch (this->action) { + case 0: + if (LoadExtraSpriteData(this, &gUnk_08113910[this->entityType.form * 4])) { + this->action = 1; + this->spriteSettings.b.draw = TRUE; + this->animationState = this->actionDelay; + this->field_0x69 = 0; + sub_0805E3A0(this, 2); + sub_0807DD50(this); + } + break; + case 1: + if (this->interactType == 2) { + this->action = 2; + this->interactType = 0; + this->field_0x69 = this->animIndex; + InitializeAnimation(this, + (this->animIndex & -4) + sub_0806F5A4(GetFacingDirection(this, &gLinkEntity))); + sub_0806F118(this); + } else { + sub_0807DD94(this, 0); + } + break; + case 2: + if (UpdateFuseInteraction(this)) { + this->action = 1; + InitializeAnimation(this, this->field_0x69); + } + } +} + +void sub_0806C674(Entity *this) +{ + this->field_0x68 = sub_0801E99C(); + sub_08078784(this, this->field_0x68); +} + +void Teachers_Head(Entity *this) +{ + u8 bVar1; + u8 bVar2; + u32 uVar3; + + + uVar3 = this->frames.all & -0x81; + bVar1 = this->frameIndex; + bVar2 = this->frameSpriteSettings & 0x3f; + if ((this->entityType).form == 0) { + SetExtraSpriteFrame(this,0, (uVar3 + 3)); + SetExtraSpriteFrame(this,1, bVar1); + SetSpriteSubEntryOffsetData1(this, 1, 0); + sub_0807000C(this); + } + else { + SetExtraSpriteFrame(this, 0, (uVar3 + 6)); + SetExtraSpriteFrame(this, 1, ((bVar2) + 3)); + SetExtraSpriteFrame(this, 2, bVar1); + SetSpriteSubEntryOffsetData1(this, 2, 1); + SetSpriteSubEntryOffsetData2(this, 2, 0); + sub_0807000C(this); + } +} + +void sub_0806C70C(Entity *this) +{ + int offset; + + offset = gUnk_02002A40.unk - 2; + if (offset < 0) { + offset = 0; + } + ShowNPCDialogue(this, gUnk_08113930 + this->entityType.form * 0x20 + offset * 4); +} + +void Teachers_Fusion(Entity *this) +{ + if (this->action == 0) { + if (LoadExtraSpriteData(this, &gUnk_08113910[this->entityType.form * 4])) { + this->action++; + this->spriteSettings.b.draw = TRUE; + InitializeAnimation(this, 2); + } + } + else { + GetNextFrame(this); + } +}
\ No newline at end of file diff --git a/src/townMinish.c b/src/npc/townMinish.c index 73d19682..c47a2a3f 100644 --- a/src/townMinish.c +++ b/src/npc/townMinish.c @@ -52,7 +52,7 @@ void sub_0806ABFC(Entity *this) Entity *link = &gLinkEntity; if (sub_080041A0(this, link, 0x18, 0x18)) { - unk = sub_080045C4(this, link) & (u8)0x1e; + unk = GetFacingDirection(this, link) & (u8)0x1e; } else { unk = this->animationState << 2; diff --git a/src/npc/townsperson.c b/src/npc/townsperson.c new file mode 100644 index 00000000..7c4bf877 --- /dev/null +++ b/src/npc/townsperson.c @@ -0,0 +1,324 @@ +#include "global.h" +#include "entity.h" +#include "npc.h" +#include "link.h" +#include "textbox.h" +#include "flags.h" + +typedef struct { + u8 frame1; + u8 frame2; + u8 unk2; + u8 unk3; +} struct_0810B680; + +typedef struct { + u32 unk; + u32 unk2; +} struct_08061FB8; + +extern void (*const gUnk_0810B774[])(Entity*); +extern void (*const gUnk_0810B77C[])(Entity*); +extern void sub_08061CB4(Entity*, u32); +extern u32 sub_0806ED9C(Entity*, u32, u32); +extern void sub_0806ED78(Entity*); +extern u32 sub_0805ACC0(Entity*); +extern u32 sub_0801E99C(Entity*); +extern void sub_0807DD64(Entity*); +extern void sub_08061D64(Entity*); +extern void sub_0806F118(Entity*); +extern u32 sub_0806F5A4(u32); +extern u32 GetFacingDirection(Entity*, Entity*); +extern void sub_0807DDAC(Entity*, u32); +extern void sub_0807DDE4(Entity*); +extern void sub_08062048(Entity*); +extern void sub_08078784(Entity*, u32); +extern void sub_08078778(Entity*); +extern u32 sub_0806F5B0(u32); +extern void sub_080AEF88(Entity*); +extern u32 Random(void); +extern void ResolveEntityOnTop(Entity*, Entity*); +extern void sub_08078850(Entity*, u32, u8, u32*); + +extern SpriteLoadData* gUnk_0810B6EC[]; +extern u8 gUnk_0810B78C[]; +extern struct_0810B680 gUnk_0810B680[]; +extern u16 gUnk_0810B74A[]; +extern u8 gUnk_02033280[]; +extern u8 gUnk_0810B748[]; +extern u32 gUnk_0810B740[]; +extern u16 gUnk_0810B790[]; +extern u16 gUnk_0810B7BA[]; +extern u32 gUnk_0810B7C0[]; + +void Townsperson(Entity* this) { + if ((this->flags & 2) != 0) { + gUnk_0810B77C[this->action](this); + } else { + gUnk_0810B774[this->action](this); + } +} + +void sub_08061BC8(Entity* this) { + if (LoadExtraSpriteData(this, gUnk_0810B6EC[this->entityType.form])) { + this->animationState = 2; + this->field_0xf = this->entityType.form + 1; + this->action++; + sub_08061CB4(this, 2); + } +} + +void sub_08061C00(Entity* this) { + s32 uVar1; + + uVar1 = sub_0806ED9C(this, 0x20, 0x20); + if (uVar1 < 0) { + uVar1 = this->animationState + 4; + } else { + if (this->field_0xf == 0) { + this->field_0xf = 0x10; + } else { + this->field_0xf--; + uVar1 = this->animIndex & 3; + } + } + sub_08061CB4(this, uVar1); + sub_0806ED78(this); + if (this->interactType != 0) { + this->interactType = 0; + TextboxNoOverlapFollow(this->entityType.parameter + 0xa01); + } +} + +#if NON_MATCHING +void Townsperson_Head(Entity* this) { + SetExtraSpriteFrame(this, 0, + *(gUnk_0810B78C + (this->animIndex & 3)) + gUnk_0810B680[this->entityType.form].frame1); + SetExtraSpriteFrame(this, 1, this->frameIndex + gUnk_0810B680[this->entityType.form].frame2); + SetSpriteSubEntryOffsetData1(this, 1, 0); + sub_0807000C(this); +} +#else +NAKED +void Townsperson_Head(Entity* this) { + asm(".include \"asm/non_matching/townsperson/sub_08061C60.inc\""); +} +#endif + +void sub_08061CB4(Entity* this, u32 arg1) { + if (this->animIndex != arg1) { + InitializeAnimation(this, arg1); + } else { + GetNextFrame(this); + } + if (this->frameDuration == 0xff) { + this->frameDuration = gUnk_0810B680[this->entityType.form].unk2; + } +} + +void sub_08061CEC(Entity* this) { + u32 uVar2; + + if (LoadExtraSpriteData(this, gUnk_0810B6EC[this->entityType.form])) { + this->action = 1; + this->spriteSettings.b.draw = TRUE; + this->animationState = this->actionDelay; + this->field_0x69 = 0xff; + uVar2 = sub_0805ACC0(this); + if (uVar2 == 0) { + this->field_0x6a.HWORD = this->x.HALF.HI; + uVar2 = (u16)this->y.HALF.HI; + } else { + this->field_0x6a.HWORD = (uVar2 >> 0x10); + } + *(u16*)&this->field_0x6c = uVar2; + this->field_0x68 = sub_0801E99C(this); + sub_0807DD64(this); + sub_08061D64(this); + } +} + +void sub_08061D64(Entity* this) { + if (this->interactType == 2) { + this->action = 3; + this->interactType = 0; + sub_0806F118(this); + this->field_0x69 = this->animIndex; + InitializeAnimation(this, (this->animIndex & -4) + sub_0806F5A4(GetFacingDirection(this, &gLinkEntity))); + } else { + sub_0807DDAC(this, 0); + sub_0807DDE4(this); + if (this->frameDuration == 0xff) { + this->frameDuration = gUnk_0810B680[this->entityType.form].unk2; + } + GetNextFrame(this); + if (this->interactType != 0) { + this->action = 2; + this->interactType = 0; + sub_08062048(this); + this->field_0x69 = this->animIndex; + InitializeAnimation(this, (this->animIndex & -4) + sub_0806F5A4(GetFacingDirection(this, &gLinkEntity))); + } + } +} + +void sub_08061E24(Entity* this) { + GetNextFrame(this); + if ((gTextBox.doTextBox & 0x7f) == 0) { + this->action = 1; + InitializeAnimation(this, this->field_0x69); + } +} + +void sub_08061E50(Entity* this) { + + if (UpdateFuseInteraction(this) != 0) { + this->action = 1; + InitializeAnimation(this, this->field_0x69); + } +} + +void sub_08061E70(Entity* this) { + if ((this->entityType).subtype == 6) { + sub_08078784(this, this->field_0x68); + } else { + sub_08078778(this); + } +} + +void sub_08061E90(Entity* this, Entity* arg1) { + u32 animIndex; + s32 iVar4; + + if (arg1->spriteSettings.raw == 0) { + arg1->spriteSettings.raw++; + arg1->spriteTileSize = (Random() & 0x3f) + 0x20; + animIndex = Random() & 0x18; + switch (this->direction) { + case 0x0: + if (animIndex == 0x10) { + animIndex = 0x8; + } + break; + case 0x8: + if (animIndex == 0x18) { + animIndex = 0x10; + } + break; + case 0x10: + if (animIndex == 0x0) { + animIndex = 0x18; + } + break; + case 0x18: + if (animIndex == 0x8) { + animIndex = 0; + } + } + this->direction = (u8)animIndex; + this->animationState = sub_0806F5B0(animIndex); + this->nonPlanarMovement = gUnk_0810B74A[this->entityType.form]; + } + animIndex = (this->animationState >> 1) + 4; + if (animIndex != this->animIndex) { + InitializeAnimation(this, animIndex); + } + sub_080AEF88(this); + iVar4 = this->x.HALF.HI - *(s16*)&this->field_0x6a.HWORD; + if (0x10 < iVar4) { + this->x.HALF.HI = this->field_0x6a.HWORD + 0x10; + arg1->spriteTileSize = 1; + } + if (iVar4 < -0x10) { + this->x.HALF.HI = *(s16*)&this->field_0x6a.HWORD - 0x10; + arg1->spriteTileSize = 1; + } + + iVar4 = this->y.HALF.HI - *(s16*)&this->field_0x6c; + if (0x10 < iVar4) { + this->y.HALF.HI = *(s16*)&this->field_0x6c + 0x10; + arg1->spriteTileSize = 1; + } + if (iVar4 < -0x10) { + this->y.HALF.HI = *(s16*)&this->field_0x6c - 0x10; + arg1->spriteTileSize = 1; + } + if (--arg1->spriteTileSize != 0) { + gUnk_02033280[6] = 0; + } +} + +void sub_08061F94(Entity* this) { + Entity* ent; + + ent = CreateFx(this, 0x35, 0); + if (ent != NULL) { + ResolveEntityOnTop(this, ent); + } +} + +void sub_08061FB0(Entity* this) { + this->boundingBox = NULL; +} + +void sub_08061FB8(Entity* this, struct_08061FB8* arg1) { + u8* temp = gUnk_0810B748; + + sub_08078850(this, 1, temp[arg1->unk2], &gUnk_0810B740[arg1->unk2]); +} + +void sub_08061FD8(Entity* this) { + InitializeAnimation(this, this->animationState >> 1); +} + +void sub_08061FE4(Entity* this) { + InitializeAnimation(this, (this->animationState >> 1) + 4); +} + +void sub_08061FF4(Entity* this) { + TextboxNoOverlap(gUnk_0810B790[this->entityType.form], this); +} + +void sub_0806200C(Entity* this) { + u32 index; + + index = 0; + if ((CheckGlobalFlag(0x29) != 0) && (CheckLocalFlag(0x6b))) { + + // hyrule bestiary + if (GetInventoryValue(0x39) == 2) { + index = 2; + } else { + index = 1; + } + } + TextboxNoOverlap(gUnk_0810B7BA[index], this); +} + +void sub_08062048(Entity *this) +{ + int iVar1; + + if ((this->entityType).subtype == 6) { + iVar1 = gUnk_02002A40.unk - 2; + if (iVar1 < 0) { + iVar1 = 0; + } + ShowNPCDialogue(this, gUnk_0810B7C0 + this->entityType.form * 0x10 + iVar1 * 2); + } + else { + TextboxNoOverlap(0, this); + } +} + +void Townsperson_Fusion(Entity *this) +{ + if (this->action == 0) { + if (LoadExtraSpriteData(this, gUnk_0810B6EC[this->entityType.form]) == 0) { + return; + } + this->action++; + this->spriteSettings.b.draw = TRUE; + } + sub_08061CB4(this, 6); +}
\ No newline at end of file diff --git a/src/npc/wheaton.c b/src/npc/wheaton.c new file mode 100644 index 00000000..06285482 --- /dev/null +++ b/src/npc/wheaton.c @@ -0,0 +1,26 @@ +#include "global.h" +#include "entity.h" + +extern void sub_0805E3A0(Entity *, u32); +extern void ResolveEntityOnTop(Entity *, Entity *); +extern BoundingBox gUnk_0810C3C0; +extern void sub_0807DD64(Entity *); +extern void sub_0807DD94(Entity *, u32); + +void Wheaton(Entity *this) { + if (this->action == 0) { + this->action++; + + sub_0805E3A0(this, 2); + + ResolveEntityOnTop(this, this); + + this->boundingBox = &gUnk_0810C3C0; + + this->spriteOffsetY = 0xfe; + + sub_0807DD64(this); + } + + sub_0807DD94(this, 0); +}
\ No newline at end of file diff --git a/src/windTribespeople.c b/src/npc/windTribespeople.c index 9f176c47..d01f22d4 100644 --- a/src/windTribespeople.c +++ b/src/npc/windTribespeople.c @@ -2,11 +2,7 @@ #include "entity.h" #include "npc.h" #include "textbox.h" - -typedef struct { - u8 filler[8]; - u8 unk; -} struct_02002A40; +#include "flags.h" extern u32 LoadExtraSpriteData(Entity*, SpriteLoadData*); extern void sub_0807DD50(Entity*); @@ -14,27 +10,19 @@ extern void sub_0806C7D4(Entity*); extern void sub_0806F118(Entity*); extern void sub_0807DD94(Entity*, u32); extern void sub_0807DD80(Entity*, u32*); -extern u32 CheckGlobalFlag(u32); -extern u32 CheckLocalFlag(u32); -extern u32 CheckRoomFlag(u32); extern u32 sub_0801E99C(); -extern void InitializeAnimation(Entity*, u32); -extern u32 UpdateFuseInteraction(); extern void sub_08078784(Entity*, u32); extern void SetExtraSpriteFrame(Entity*, u32, u32); extern void SetSpriteSubEntryOffsetData2(Entity*, u32, u32); extern void SetSpriteSubEntryOffsetData1(Entity*, u32, u32); extern void sub_0807000C(Entity*); -extern void ShowNPCDialogue(Entity*, u16*); -extern void TextboxNoOverlap(u32, Entity*); extern void (*const gUnk_08113A7C[])(Entity*); extern void (*const gUnk_08113A8C[])(Entity*, Entity*); extern SpriteLoadData gUnk_08113A1C[]; extern u32 gUnk_08014A80; -extern u16 gUnk_08113ABC[]; -extern struct_02002A40 gUnk_02002A40; +extern u32 gUnk_08113ABC[]; extern u16 gUnk_08113B0C[]; void WindTribespeople(Entity* this) { @@ -47,7 +35,7 @@ void sub_0806C798(Entity* this) { iVar1 = LoadExtraSpriteData(this, gUnk_08113A1C + (this->entityType.form * 4)); if (iVar1 != 0) { this->action = 1; - this->spriteSettings.b.ss0 = 1; + this->spriteSettings.b.draw = 1; this->animationState = this->actionDelay; sub_0807DD50(this); sub_0806C7D4(this); @@ -80,7 +68,7 @@ void sub_0806C834(Entity* this) { } void sub_0806C85C(Entity* this) { - if (UpdateFuseInteraction() != 0) { + if (UpdateFuseInteraction(this) != 0) { this->action = 1; } } @@ -134,7 +122,7 @@ void sub_0806C90C(Entity *param_1,Entity *param_2) void sub_0806C928(Entity *this) { - ShowNPCDialogue(this, gUnk_08113ABC + (gUnk_02002A40.unk * 4)); + ShowNPCDialogue(this, &gUnk_08113ABC[gUnk_02002A40.unk * 2]); } void sub_0806C944(Entity *this) diff --git a/src/zelda.c b/src/npc/zelda.c index 830bbf3e..2ba8bf28 100644 --- a/src/zelda.c +++ b/src/npc/zelda.c @@ -1,6 +1,7 @@ #include "global.h" #include "entity.h" #include "room.h" +#include "flags.h" extern void sub_0805EA78(Entity*, u32); extern void sub_0805E3A0(Entity*, u32); @@ -10,14 +11,10 @@ extern Entity* sub_0805EB9C(u32, u32); void CopyPosition(Entity*, Entity*); void sub_08068680(Entity*, Entity*); void sub_08068694(Entity*, Entity*); -extern void SetGlobalFlag(u32); -extern Entity* CreateNPC(u32 subtype, u32 form, u32 parameter); -u32 sub_0806EDC4(Entity* ent); +u32 GetAnimationState(Entity* ent); void DeleteThisEntity(void); extern Entity* GetEntityByType(u32, u32); extern void sub_080686C4(Entity*, Entity*); -extern void InitAnimationForceUpdate(Entity*, u32); -extern void UpdateAnimationSingleFrame(Entity*); extern void sub_0806F62C(Entity*, u32, u32); extern u32 sub_08003FC4(Entity*, u32); extern void PlaySFX(u32); @@ -37,7 +34,7 @@ void Zelda(Entity* ent) { void sub_08066CCC(Entity* ent) { ent->action = 1; - ent->spriteSettings.b.ss0 = 1; + ent->spriteSettings.b.draw = 1; sub_0805EA78(ent, 7); sub_0805E3A0(ent, 2); sub_0807DD50(ent); @@ -57,7 +54,7 @@ void sub_08066D14(Entity* ent, u32* param_2) { parent = ent->parent; if (parent != NULL) { ent->animationState = parent->animationState; - ent->spriteSettings.b.ss0 = 1; + ent->spriteSettings.b.draw = 1; CopyPosition(parent, ent); sub_08068680(ent, ent->parent); param_2[5] = 1; @@ -72,9 +69,9 @@ void sub_08066D4C(Entity* ent, u32* param_2) { parent = ent->parent; if (ent->parent != NULL) { CopyPosition(ent, parent); - ent->parent->spriteSettings.b.ss0 = 1; + ent->parent->spriteSettings.b.draw = 1; ent->parent->animationState = ent->animationState; - ent->spriteSettings.b.ss0 = 0; + ent->spriteSettings.b.draw = 0; ent->field_0x17 &= 0xFE; sub_08068694(ent, ent->parent); param_2[5] = 1; @@ -92,9 +89,9 @@ void sub_08066D94(Entity* ent) { if (npc != NULL) { npc->animationState = gLinkEntity.animationState; npc->flags |= 0x20; - npc->animationState = sub_0806EDC4(ent); + npc->animationState = GetAnimationState(ent); roomID = gRoomControls.roomID; - *(u16*)&npc->heldObjectPtr = roomID; + npc->field_0x74 = roomID; CopyPosition(ent, npc); } DeleteThisEntity(); diff --git a/src/archway.c b/src/object/archway.c index 4596b42c..ff6c7b14 100644 --- a/src/archway.c +++ b/src/object/archway.c @@ -1,7 +1,7 @@ #include "global.h" #include "entity.h" +#include "sprite.h" -extern void UpdateSpriteOrderAndFlip(); extern u32 CheckIsDungeon(); void Archway(Entity *this) @@ -18,10 +18,10 @@ void Archway(Entity *this) this->spriteSettings.raw = v1 | 1; this->frameIndex = this->entityType.parameter; this->collisionLayer = 2; - UpdateSpriteOrderAndFlip(this); + UpdateSpriteForCollisionLayer(this); v3 = CheckIsDungeon(); if (v3 != 0) { - this->ticks.b0 = (this->ticks.b0 & 0xf8) | 1; + this->spritePriority.b0 = (this->spritePriority.b0 & 0xf8) | 1; } } }
\ No newline at end of file diff --git a/src/bell.c b/src/object/bell.c index 5b21eaee..072b0798 100644 --- a/src/bell.c +++ b/src/object/bell.c @@ -1,22 +1,18 @@ #include "entity.h" #include "global.h" -extern void UpdateAnimationSingleFrame(); extern void (*gUnk_08123384[])(Entity*); -extern void UpdateSpriteOrderAndFlip(Entity*); -extern void InitAnimationForceUpdate(); - void Bell(Entity* ent) { gUnk_08123384[ent->action](ent); } void sub_08097D90(Entity* ent) { ent->action = 1; - ent->spriteSettings.b.ss0 = 1; + ent->spriteSettings.b.draw = 1; ent->collisionLayer = 1; - ent->ticks.b0 = 0; - UpdateSpriteOrderAndFlip(ent); + ent->spritePriority.b0 = 0; + UpdateSpriteForCollisionLayer(ent); InitAnimationForceUpdate(ent, 0); } diff --git a/src/chestSpawner.c b/src/object/chestSpawner.c index ac50a692..8af7769d 100644 --- a/src/chestSpawner.c +++ b/src/object/chestSpawner.c @@ -1,11 +1,9 @@ #include "global.h" #include "entity.h" +#include "flags.h" extern void sub_080842D8(Entity*); extern void sub_08078828(Entity*); -extern u32 CheckLocalFlag(u32); -extern void InitializeAnimation(Entity*, u32); -extern u32 CheckFlags(u32); extern void sub_08083E20(Entity*); extern void (*const gUnk_0811F7E8[])(Entity*); @@ -30,8 +28,8 @@ void sub_08083E08(Entity *this) void sub_08083E20(Entity *this) { this->action = 3; - this->spriteSettings.b.ss0 = 1; - this->spriteOrder.b1 = 0; + this->spriteSettings.b.draw = 1; + this->spriteRendering.alphaBlend = 0; sub_080842D8(this); sub_08078828(this); } diff --git a/src/cloud.c b/src/object/cloud.c index 297fbbc5..734559c4 100644 --- a/src/cloud.c +++ b/src/object/cloud.c @@ -2,18 +2,17 @@ #include "entity.h" #include "room.h" #include "link.h" +#include "flags.h" extern void sub_0809F7BC(Entity*); extern void PlaySFX(u32); extern void sub_0809F814(u32); extern void sub_0809F7F4(Entity*); -extern void SetGlobalFlag(u32); extern void LoadRoomEntityList(); extern void DeleteThisEntity(); extern u32 CheckRoomFlag(u32); extern void sub_08078A90(u32); extern void sub_08078B48(void); -extern u32 SetLocalFlag(u32); extern u32 Random(void); extern void sub_0806F69C(Entity*); extern void (*gUnk_08124798[])(Entity*); @@ -47,7 +46,7 @@ void sub_0809F4DC(Entity* this) { void sub_0809F514(Entity* this) { this->action = 1; this->actionDelay = 120; - this->spriteSettings.b.ss0 = 0; + this->spriteSettings.b.draw = 0; *(u8*)&this->field_0x68 = 12; gRoomControls.cameraTarget = this; gUnk_02034490 = 255; @@ -81,7 +80,7 @@ void sub_0809F5B0(Entity* this) { void sub_0809F5DC(Entity* this) { this->action = 1; - this->spriteSettings.b.ss0 = 0; + this->spriteSettings.b.draw = 0; *(u8*)&this->field_0x68 = 12; } diff --git a/src/object/fan.c b/src/object/fan.c new file mode 100644 index 00000000..481e3887 --- /dev/null +++ b/src/object/fan.c @@ -0,0 +1,86 @@ +#include "global.h" +#include "entity.h" +#include "flags.h" + +extern void sub_0809EE34(Entity*); +extern void sub_0809EFB0(Entity*); +extern void sub_0809EE08(Entity*); +extern void sub_0809F08C(void); +extern void sub_0809EE44(Entity*); +extern void sub_0809EE24(Entity*); + +extern void (*const gUnk_081243D4[])(Entity*); + +void Fan(Entity *this) +{ + gUnk_081243D4[this->action](this); +} + +void sub_0809ED30(Entity *this) +{ + this->direction = (this->entityType.form ^ 2) << 3; + sub_0809EE34(this); + sub_0809EFB0(this); + InitializeAnimation(this, this->entityType.form); +} + +void sub_0809ED54(Entity *this) +{ + u16 uVar1; + u32 iVar2; + + if (((this->cutsceneBeh.HWORD == 0) || CheckFlags(this->cutsceneBeh.HWORD)) && + ((this->entityType.parameter != 1 || + (--this->field_0x74 == 0)))) { + sub_0809EE08(this); + } +} + +void sub_0809ED88(Entity *this) +{ + sub_0809F08C(); + sub_0809EE44(this); + if (this->field_0x86 != 0) { + if (this->cutsceneBeh.HWORD == this->field_0x86) { + if (CheckFlags(this->cutsceneBeh.HWORD)) { + return; + } + } + else if (!CheckFlags(this->cutsceneBeh.HWORD)) { + return; + } + sub_0809EE24(this); + } + else if (((this->entityType).parameter == 1) && + (--this->field_0x74 == 0)) { + sub_0809EE24(this); + } +} + +void sub_0809EDE4(Entity *this) +{ + sub_0809F08C(); + sub_0809EE44(this); + if (this->frames.b.f3) { + sub_0809EE34(this); + } +} + +void sub_0809EE08(Entity *this) +{ + this->action = 2; + this->field_0x74 = *((u8 *)&this->field_0x7c + 3) << 2; + InitializeAnimation(this, this->entityType.form); +} + +void sub_0809EE24(Entity *this) +{ + this->action = 3; + InitializeAnimation(this, this->entityType.form + 4); +} + +void sub_0809EE34(Entity *this) +{ + this->action = 1; + this->field_0x74 = this->actionDelay << 2; +}
\ No newline at end of file diff --git a/src/giantLeaf.c b/src/object/giantLeaf.c index d34c1605..9003f28b 100644 --- a/src/giantLeaf.c +++ b/src/object/giantLeaf.c @@ -12,9 +12,9 @@ extern s16 gUnk_0812176A[]; void GiantLeaf(Entity* ent) { if (ent->action == 0) { ent->action = 1; - ent->spriteSettings.b.ss0 = 1; - ent->spriteOrder.b3 = 3; - ent->ticks.b0 = 7; + ent->spriteSettings.b.draw = 1; + ent->spriteRendering.b3 = 3; + ent->spritePriority.b0 = 7; ent->frameIndex = ent->entityType.form; sub_0808D618(ent); } diff --git a/src/greatFairy.c b/src/object/greatFairy.c index 02b5268b..2f3276b9 100644 --- a/src/greatFairy.c +++ b/src/object/greatFairy.c @@ -160,9 +160,9 @@ void GreatFairy_WingsCallBehavior(Entity* this) { void GreatFairy_WingsInit(Entity* this) { GreatFairy_InitializeAnimation(this); - this->ticks.b0 = 5; - this->spriteSettings.b.ss0 = 1; - this->spriteOrder.b1 = 1; + this->spritePriority.b0 = 5; + this->spriteSettings.b.draw = 1; + this->spriteRendering.alphaBlend = 1; gScreen.controls.windowOutsideControl = 3904; gScreen.controls.mosaicSize = 2057; this->nonPlanarMovement = 1024; @@ -192,8 +192,8 @@ void GreatFairy_WakeCallBehavior(Entity* this) { void GreatFairy_WakeInit(Entity* this) { GreatFairy_InitializeAnimation(this); - this->spriteSettings.b.ss0 = 1; - this->ticks.b0 = 6; + this->spriteSettings.b.draw = 1; + this->spritePriority.b0 = 6; } void GreatFairy_WakeUpdate(Entity* this) { @@ -213,7 +213,7 @@ void GreatFairy_MiniInit(Entity* this) { CopyPosition(this, aff); aff->parent = this; GreatFairy_InitializeAnimation(this); - this->spriteSettings.b.ss0 = 1; + this->spriteSettings.b.draw = 1; this->field_0xf = 0; } } @@ -252,8 +252,8 @@ void GreatFairy_MiniAffineCallBehavior(Entity* this) { void GreatFairy_MiniAffineInit(Entity* this) { GreatFairy_InitializeAnimation(this); - this->ticks.b0 = 6; - this->spriteSettings.b.ss0 = 1; + this->spritePriority.b0 = 6; + this->spriteSettings.b.draw = 1; } // Getting ready for affine transformation @@ -266,7 +266,7 @@ void GreatFairy_MiniAffineInit2(Entity* this) { this->action = 2; this->actionDelay = 90; this->nonPlanarMovement = 4096; - this->spriteOrder.b0 = 3; + this->spriteRendering.b0 = 3; sub_0805EC9C(this, 256, 256, 0); } } @@ -293,9 +293,9 @@ void GreatFairy_DropletCallBehavior(Entity* this) { void GreatFairy_DropletInit(Entity* this) { GreatFairy_InitializeAnimation(this); - this->spriteSettings.b.ss0 = 1; + this->spriteSettings.b.draw = 1; this->height.HALF.HI = 0; - this->ticks.b0 = 5; + this->spritePriority.b0 = 5; PlaySFX(320); } @@ -313,8 +313,8 @@ void GreatFairy_RippleCallBehavior(Entity* this) { void GreatFairy_RippleInit(Entity* this) { GreatFairy_InitializeAnimation(this); - this->spriteSettings.b.ss0 = 1; - this->ticks.b0 = 6; + this->spriteSettings.b.draw = 1; + this->spritePriority.b0 = 6; } void GreatFairy_RippleUpdate(Entity* this) { @@ -333,8 +333,8 @@ void GreatFairy_BigRippleCallBehavior(Entity* this) { void GreatFairy_BigRippleInit(Entity* this) { GreatFairy_InitializeAnimation(this); this->actionDelay = 120; - this->spriteSettings.b.ss0 = 1; - this->ticks.b0 = 5; + this->spriteSettings.b.draw = 1; + this->spritePriority.b0 = 5; PlaySFX(249); } @@ -361,8 +361,8 @@ void GreatFairy_EnergyCallBehavior(Entity* this) { void GreatFairy_EnergyInit(Entity* this) { GreatFairy_InitializeAnimation(this); - this->spriteSettings.b.ss0 = 1; - this->ticks.b0 = 5; + this->spriteSettings.b.draw = 1; + this->spritePriority.b0 = 5; } void GreatFairy_EnergyUpdate(Entity* this) { @@ -387,10 +387,10 @@ void sub_08087150(Entity* this) { u32 var2; GreatFairy_InitializeAnimation(this); - this->spriteSettings.b.ss0 = 1; + this->spriteSettings.b.draw = 1; this->spriteOrientation &= 63; - this->spriteOrder.b0 = 0; - this->ticks.b0 = 3; + this->spriteRendering.b0 = 0; + this->spritePriority.b0 = 3; this->nonPlanarMovement = 128; this->direction = 16; var = gUnk_0812079C[0]; @@ -472,9 +472,9 @@ void sub_08087294(Entity* this) { #ifdef NON_MATCHING void sub_080872AC(Entity* this) { - this->spriteSettings.b.ss0 = 1; - this->spriteOrientation.b2 = 1; - this->spriteOrder.b0 = 0; + this->spriteSettings.b.draw = 1; + this->spriteOrientation.flipY = 1; + this->spriteRendering.b0 = 0; this->field_0x68 = (u16)(this->x).HALF.HI; this->field_0x6a = (u16)(this->y).HALF.HI; this->direction = (u8)Random() & 0x1F; diff --git a/src/heartContainer.c b/src/object/heartContainer.c index 643b87dd..10714a8e 100644 --- a/src/heartContainer.c +++ b/src/object/heartContainer.c @@ -1,7 +1,7 @@ #include "global.h" #include "entity.h" +#include "flags.h" -extern u32 CheckFlags(u32); extern void DeleteThisEntity(); extern void sub_0808E714(Entity*); @@ -20,7 +20,7 @@ void sub_0808E6A0(Entity* this) { } this->action = 1; this->entityType.form = 0x62; - this->spriteSettings.b.ss0 = 0; + this->spriteSettings.b.draw = 0; this->boundingBox = &gUnk_08121C58; this->collisionLayer = 3; this->scriptedScene = 3; @@ -29,8 +29,8 @@ void sub_0808E6A0(Entity* this) { void sub_0808E6E4(Entity* this) { if (CheckFlags(this->field_0x86)) { this->action = 2; - this->spriteSettings.b.ss0 = 1; - this->spriteOrder.b0 = 3; + this->spriteSettings.b.draw = 1; + this->spriteRendering.b0 = 3; sub_0808E714(this); } } diff --git a/src/object/lightableSwitch.c b/src/object/lightableSwitch.c new file mode 100644 index 00000000..2368da04 --- /dev/null +++ b/src/object/lightableSwitch.c @@ -0,0 +1,145 @@ +#include "global.h" +#include "entity.h" +#include "room.h" +#include "flags.h" +#include "functions.h" + +extern void sub_0809EB30(Entity*); +extern void sub_0809EAD8(Entity*); +extern void sub_0809EABC(Entity*); +extern void sub_08004488(u32); +extern void sub_080A2CC0(Entity*, Entity**, u16*); +extern Entity* GetCurrentRoomProperty(u32); +extern void SetTile(u32, u32, u32); +extern void sub_0806F69C(Entity*); + +extern void (*const gUnk_081243B4[])(Entity*); +extern void (*const gUnk_081243BC[])(Entity*); +extern void (*const gUnk_081243C4[])(Entity*); + +extern BoundingBox gUnk_080FD150; + +void LightableSwitch(Entity* this) { + gUnk_081243B4[this->entityType.form](this); + sub_0809EB30(this); +} + +void sub_0809EA1C(Entity* this) { + gUnk_081243BC[this->action](this); +} + +void sub_0809EA34(Entity* this) { + this->action = 1; + this->flags = this->flags | 0x80; + this->frameIndex = 0; + this->field_0x3c = 7; + this->field_0x40 = 0x48; + this->damageType = 0x28; + this->flags2 = 10; + this->boundingBox = &gUnk_080FD150; + sub_0809EAD8(this); + UpdateSpriteForCollisionLayer(this); + sub_0809EABC(this); +} + +void sub_0809EA80(Entity* this) { + + if ((this->bitfield & 0x80) != 0) { + if (CheckFlags(this->field_0x86) != 0) { + ClearFlag(this->field_0x86); + } else { + SetFlag(this->field_0x86); + } + sub_08004488(0x110); + } + sub_0809EABC(this); +} + +void sub_0809EABC(Entity* this) { + bool32 anySet; + u32 f; + + f = CheckFlags(this->field_0x86); + anySet = (-f | f) >> 0x1F; + if (this->frameIndex != anySet) { + this->frameIndex = anySet; + } +} + +void sub_0809EAD8(Entity* this) { + u8 bVar1; + Entity* pEVar2; + + if (this->entityType.parameter != 0) { + + this->attachedEntity = GetCurrentRoomProperty(this->entityType.parameter); + sub_080A2CC0(this, &this->attachedEntity, &this->field_0x74); + + } else { + SetTile(0x4050, COORD_TO_TILE(this), this->collisionLayer); + } +} + +void sub_0809EB30(Entity* this) { + u16 uVar1; + u16* puVar2; + + if (this->entityType.parameter != 0) { + if ((this->direction & 0x80) == 0) { + sub_0806F69C(this); + } + puVar2 = &this->field_0x74; + if (!--*puVar2) { + sub_080A2CC0(this, &this->attachedEntity, puVar2); + } + } +} + +void sub_0809EB68(Entity* this) { + gUnk_081243C4[this->action](this); +} + +void sub_0809EB80(Entity* this) { + + this->action = 1; + this->flags = this->flags | 0x80; + this->frameIndex = 3; + this->field_0x3c = 7; + this->field_0x40 = 0x48; + this->damageType = 0x28; + this->flags2 = 10; + this->boundingBox = &gUnk_080FD150; + sub_0809EAD8(this); + UpdateSpriteForCollisionLayer(this); + if (CheckFlags(this->cutsceneBeh.HWORD) != 0) { + this->action = 3; + this->frameIndex = 2; + } +} + +void sub_0809EBD8(Entity* this) { + if ((this->bitfield & 0x80) != 0) { + this->action = 2; + this->actionDelay = 0x10; + this->frameIndex = 2; + SetFlag(this->field_0x86); + sub_08004488(0x110); + } +} + +void sub_0809EC08(Entity* this) { + + if (CheckFlags(this->cutsceneBeh.HWORD) != 0) { + this->action = 3; + + } else { + if (--this->actionDelay == 0) { + this->action = 1; + this->frameIndex = 3; + ClearFlag(this->field_0x86); + sub_08004488(0x110); + } + } +} + +void nullsub_126(Entity* this) { }
\ No newline at end of file diff --git a/src/mask.c b/src/object/mask.c index d33f3481..6dd866c9 100644 --- a/src/mask.c +++ b/src/object/mask.c @@ -16,8 +16,6 @@ extern void ClearFlag(u16); extern void SetTile(u32, u16, u32); -extern void CreateFx(Entity *, u16, u16); - extern void sub_08000148(u16, u16, u32); extern s16 sub_080001DA(u16, u32); extern u16 sub_080002E0(u16, u32); @@ -60,7 +58,7 @@ void sub_080929A4(Entity *this) { this->action = 1; this->field_0x20 = 0x18000; - this->field_0x78 = ((Random() & 7) << 10) | 0x2000; + this->field_0x78.HWORD = ((Random() & 7) << 10) | 0x2000; this->field_0xf = this->actionDelay >> 1; this->actionDelay = 0; @@ -70,7 +68,7 @@ void sub_080929A4(Entity *this) { this->field_0x7c.HALF.HI = COORD_TO_TILE(this); this->field_0x7c.HALF.LO = sub_080001DA(this->field_0x7c.HALF.HI, 1); - this->itemCooldown = sub_080002E0(this->field_0x7c.HALF.HI, 1); + this->field_0x7a = sub_080002E0(this->field_0x7c.HALF.HI, 1); SetTile(0x4022, this->field_0x7c.HALF.HI, 1); } @@ -98,14 +96,14 @@ void sub_08092A94(Entity *this) { // Presumably, make the mask fall SetTile((u16)this->field_0x7c.HALF.LO, this->field_0x7c.HALF.HI, 1); - sub_08000148(this->itemCooldown, this->field_0x7c.HALF.HI, 1); + sub_08000148(this->field_0x7a, this->field_0x7c.HALF.HI, 1); this->action = 2; this->height.HALF.HI -= 0x20; this->y.HALF.HI += 0x20; - this->spriteOrder.b3 = 2; + this->spriteRendering.b3 = 2; } // Probably falling down @@ -129,7 +127,7 @@ void sub_08092B0C(Entity *this) { sub_0805457C(this, 3); } else { - sub_080044EC(this, this->field_0x78); + sub_080044EC(this, this->field_0x78.HWORD); if (this->height.HALF.HI == 0) { this->actionDelay++; diff --git a/src/object/metalDoor.c b/src/object/metalDoor.c new file mode 100644 index 00000000..1f18a272 --- /dev/null +++ b/src/object/metalDoor.c @@ -0,0 +1,115 @@ +#include "global.h" +#include "entity.h" +#include "room.h" +#include "flags.h" + +extern u32 sub_08083734(Entity*, u32); +extern void sub_080A080C(Entity*); +extern void sub_0806F69C(Entity*); +extern void sub_08004488(u32); +extern void sub_080A0870(Entity*); +extern void PlaySFX(u32); +extern u32 sub_080001DA(u32, u32); +extern void SetTile(u32, u32, u32); + +extern void (*const gUnk_0812493C[])(Entity*); + +extern BoundingBox gUnk_080FD180; + +void MetalDoor(Entity* this) { + gUnk_0812493C[this->action](this); +} + +void sub_080A0684(Entity *this) +{ + if ((this->cutsceneBeh.HWORD != 0xffff) && CheckFlags(this->cutsceneBeh.HWORD)) { + DeleteThisEntity(); + } + this->action = 1; + this->nonPlanarMovement = 0x300; + this->spriteSettings.b.draw = 0; + this->frameIndex = 0; + this->spriteSettings.b.flipY = 1; + this->boundingBox = &gUnk_080FD180; + this->spritePriority.b0 = 5; + this->field_0x70.HALF.LO = this->x.HALF.HI; + this->field_0x70.HALF.HI = this->y.HALF.HI; + this->field_0x74 = COORD_TO_TILE(this); +} + +void sub_080A0718(Entity *this) +{ + if (sub_08083734(this, 2) != 0) { + this->action = 2; + this->actionDelay = 0xc; + this->spriteSettings.b.draw = TRUE; + this->direction = 0; + this->y.HALF.HI += 0x24; + sub_080A080C(this); + } +} + +void sub_080A074C(Entity *this) +{ + u8 bVar1; + Entity *ent; + + sub_0806F69C(this); + + if (--this->actionDelay == 0) { + this->action = 3; + this->height.HALF.HI = 0; + this->x.HALF.HI = this->field_0x70.HALF.LO; + this->y.HALF.HI = this->field_0x70.HALF.HI; + ent = CreateFx(this, 0x11, 0x40); + if (ent != NULL) { + ent->x.HALF.HI += 0xc; + ent->y.HALF.HI -= 0xc; + } + ent = CreateFx(this, 0x11, 0x40); + if (ent != NULL) { + ent->x.HALF.HI -= 0xc; + ent->y.HALF.HI -= 0xc; + } + sub_08004488(0x10b); + } +} + +void sub_080A07BC(Entity *this) +{ + if (CheckFlags(this->field_0x86)) { + this->action = 4; + this->actionDelay = 0xc; + this->direction = 0x10; + this->y.HALF.HI += 2; + sub_080A0870(this); + PlaySFX(0x10b); + } +} + +void sub_080A07F0(Entity *this) +{ + + sub_0806F69C(this); + + if (--this->actionDelay == 0) { + DeleteThisEntity(); + } +} + +void sub_080A080C(Entity *this) +{ + this->field_0x76 = sub_080001DA(this->field_0x74 - 1, this->collisionLayer); + this->field_0x78.HWORD = sub_080001DA(this->field_0x74, this->collisionLayer); + this->field_0x7a = sub_080001DA(this->field_0x74 + 1, this->collisionLayer); + SetTile(0x4022, this->field_0x74 - 1, this->collisionLayer); + SetTile(0x4022, this->field_0x74, this->collisionLayer); + SetTile(0x4022, this->field_0x74 + 1, this->collisionLayer); +} + +void sub_080A0870(Entity *this) +{ + SetTile(this->field_0x76, this->field_0x74 - 1, this->collisionLayer); + SetTile(this->field_0x78.HWORD, this->field_0x74, this->collisionLayer); + SetTile(this->field_0x7a, this->field_0x74 + 1, this->collisionLayer); +}
\ No newline at end of file diff --git a/src/mineralWaterSource.c b/src/object/mineralWaterSource.c index c874530b..c874530b 100644 --- a/src/mineralWaterSource.c +++ b/src/object/mineralWaterSource.c diff --git a/src/object/minishSizedEntrance.c b/src/object/minishSizedEntrance.c new file mode 100644 index 00000000..ca261d35 --- /dev/null +++ b/src/object/minishSizedEntrance.c @@ -0,0 +1,27 @@ +#include "global.h" +#include "entity.h" + +extern u32 Random(); +extern bool32 CheckIsDungeon(); +extern void sub_080AE068(Entity*); +extern void LoadFixedGFX(Entity*, u32); + +extern void (*const gUnk_08122254[])(Entity*); + +void MinishSizedEntrance(Entity* this) +{ + gUnk_08122254[this->action](this); +} + +void sub_08090EC0(Entity *this) +{ + this->action = 1; + this->spriteRendering.b3 = 3; + this->spritePriority.b0 = 7; + this->frameIndex = (this->entityType).parameter; + if (CheckIsDungeon()) { + this->frameIndex += 4; + sub_080AE068(this); + LoadFixedGFX(this, 0x184); + } +} diff --git a/src/object1A.c b/src/object/object1A.c index 2cb9d9ff..f7d9e469 100644 --- a/src/object1A.c +++ b/src/object/object1A.c @@ -1,7 +1,6 @@ #include "global.h" #include "entity.h" -extern Entity* CreateObject(); extern void CopyPosition(); extern void sub_08086A6C(); extern s32 sub_080044EC(); @@ -22,7 +21,7 @@ void sub_080869DC(Entity* ent) { Entity* itemEntity; ent->action = 1; - ent->spriteSettings.b.ss0 = 0; + ent->spriteSettings.b.draw = 0; ent->boundingBox = &gUnk_080FD1A8; ent->field_0x3c |= 16; itemEntity = CreateObject(0, ent->entityType.form, 0); diff --git a/src/object1C.c b/src/object/object1C.c index 16c20816..16c20816 100644 --- a/src/object1C.c +++ b/src/object/object1C.c diff --git a/src/object1D.c b/src/object/object1D.c index 1912facb..1912facb 100644 --- a/src/object1D.c +++ b/src/object/object1D.c diff --git a/src/object/object49.c b/src/object/object49.c new file mode 100644 index 00000000..d9551953 --- /dev/null +++ b/src/object/object49.c @@ -0,0 +1,155 @@ +#include "global.h" +#include "entity.h" + +extern u32 Random(void); +extern void sub_0808F2B0(Entity*); +extern u32 sub_08003FC4(Entity*, u32); +void sub_0808F14C(Entity*); +extern void PlaySFX(u32); +extern void sub_0806FCF4(Entity*, u32, u32, u32); +extern void sub_0808F244(Entity*); +extern void sub_0805EC9C(Entity*, u32, u32, u32); + +extern void (*const gUnk_08121E5C[])(Entity*); +extern void (*const gUnk_08121E88[])(Entity*); +extern void (*const gUnk_08121E98[])(Entity*); + + +void Object49(Entity* this) { + gUnk_08121E5C[this->entityType.form](this); +} + +void sub_0808F0B8(Entity* this) { + gUnk_08121E88[this->action](this); +} + +void sub_0808F0D0(Entity* this) { + u32 offsetX; + u32 offsetY; + Entity* ent; + u32 uVar3; + + ent = CreateObjectWithParent(this, 0x49, 2, 0); + this->attachedEntity = ent; + if (ent == NULL) { + DeleteThisEntity(); + } + this->action = 1; + this->height.HALF.HI = -0xc0; + offsetX = Random() % 64; + if ((Random() & 1) != 0) { + offsetX = -offsetX; + } + this->x.HALF.HI = this->parent->x.HALF.HI + offsetX; + offsetY = Random() % 32; + if ((Random() & 1) != 0) { + offsetY = -offsetY; + } + this->y.HALF.HI = this->parent->y.HALF.HI + offsetY; + *(u32*)&this->field_0x74 = 0x240; + *(u32*)&this->field_0x78 = 0x140; + InitializeAnimation(this, 3); + sub_0808F14C(this); +} + +void sub_0808F14C(Entity* this) { + sub_0808F2B0(this); + if (sub_08003FC4(this, 0x2000) == 0) { + this->action++; + PlaySFX(0x84); + } +} + +void sub_0808F170(Entity *this) +{ + *(u32 *)&this->field_0x74 -= 0x20; + *(u32 *)&this->field_0x78 += 0x20; + sub_0806FCF4(this, *(u32 *)&this->field_0x78, 8, 2); + if (*(u32 *)&this->field_0x78 > 0x1ff) { + this->action++; + } + sub_0808F2B0(this); +} + +void sub_0808F1A4(Entity *this) +{ + *(u32 *)&this->field_0x78 += 0x10; + *(u32 *)&this->field_0x74 += 0x10; + sub_0806FCF4(this, *(u32 *)&this->field_0x78, 8, 2); + if (*(u32 *)&this->field_0x78 > 0x3ff) { + this->attachedEntity->action = 0xff; + DeleteThisEntity(); + } + else { + sub_0808F2B0(this); + } +} + +void sub_0808F1E0(Entity *this) +{ + gUnk_08121E98[this->action](this); +} + +void sub_0808F1F8(Entity *this) +{ + u8 bVar1; + + this->spriteRendering.b0 = 3; + this->action++; + this->spriteRendering.b3 = this->parent->spriteRendering.b3; + this->spriteOrientation.flipY = this->parent->spriteOrientation.flipY; + this->spritePriority.b0 = 7; + InitializeAnimation(this, 1); + sub_0808F244(this); +} + +void sub_0808F244(Entity *this) +{ + + this->spriteSettings.b.draw = this->parent->spriteSettings.b.draw; + this->y.HALF.HI = this->parent->y.HALF.HI + 3; + this->x.HALF.HI = (*(s8*)&this->attachedEntity->spriteOffsetX + this->attachedEntity->x.HALF.HI); + this->height.WORD = 0; + *(u32 *)&this->field_0x74 = 0x80 - this->parent->height.HALF.HI; + *(u32 *)&this->field_0x78 = 0x100 - this->parent->height.HALF.HI; + *(u32 *)&this->field_0x70.WORD = *((u8 *)&this->parent->field_0x7c + 3); + sub_0808F2B0(this); + if ((this->parent->field_0x6d & 2) != 0) { + DeleteThisEntity(); + } +} + +void sub_0808F2B0(Entity *this) +{ + sub_0805EC9C(this, *(u32 *)&this->field_0x74, *(u32 *)&this->field_0x78, this->field_0x70.WORD); +} + +void sub_0808F2C0(Entity *this) +{ + if (this->action == 0) { + this->action++; + this->spriteRendering.b3 = this->parent->spriteRendering.b3; + this->spriteOrientation.flipY = this->parent->spriteOrientation.flipY; + this->spriteSettings.b.draw = 1; + this->spritePriority.b0 = 7; + this->height.WORD = 0; + + this->y.HALF.HI = this->parent->y.HALF.HI + 3; + this->x.HALF.HI = this->parent->x.HALF.HI; + InitializeAnimation(this,3); + } + if (this->parent->height.HALF.HI == 0) { + *(u32 *)&this->field_0x74 = *(u32 *)&this->parent->field_0x74; + *(u32 *)&this->field_0x78 = *(u32 *)&this->parent->field_0x78; + } + else { + *(u32 *)&this->field_0x74 = 0x200 - this->parent->height.HALF.HI; + *(u32 *)&this->field_0x78 = this->parent->height.HALF.HI * -2 + 0x300; + } + *(u32 *)&this->field_0x70 = 0; + sub_0808F2B0(this); + sub_0806FCF4(this,*(u32 *)&this->field_0x78,8,2); + if (this->action == 0xff) { + DeleteThisEntity(); + } +}
\ No newline at end of file diff --git a/src/object/object86.c b/src/object/object86.c new file mode 100644 index 00000000..979ab47a --- /dev/null +++ b/src/object/object86.c @@ -0,0 +1,81 @@ +#include "global.h" +#include "entity.h" +#include "link.h" +#include "flags.h" + +extern u32 sub_080041A0(Entity*, Entity*, u32, u32); +void sub_08099ECC(Entity*); +extern void sub_0805E4E0(Entity*, u32); +extern void sub_0805B390(u32); +extern void CopyPosition(Entity*, Entity*); + +extern void (*const gUnk_081237F8[])(Entity*); + +void Object86(Entity* this) { + gUnk_081237F8[this->action](this); +} + +void sub_08099DD0(Entity* this) { + this->collisionLayer = 1; + this->spriteRendering.b3 = 3; + this->spritePriority.b0 = 7; + this->previousActionFlag = 0; + if (GetInventoryValue(0x46)) { + this->action = 4; + this->frameIndex = 0; + } else { + this->action = 1; + InitializeAnimation(this, 0); + } +} + +void sub_08099E10(Entity* this) { + if (CheckLocalFlag(0x74)) { + GetNextFrame(this); + if ((this->frames.all == 1) && (this->previousActionFlag == 0)) { + this->frames.all = 0; + sub_08099ECC(this); + } + if (this->frames.b.f3) { + this->action = 2; + InitializeAnimation(this, 1); + } + } +} + +void sub_08099E58(Entity *this) +{ + GetNextFrame(this); + if (this->frames.b.f3) { + this->frames.b.f3 = 0; + this->actionDelay++; + if (this->actionDelay == 3) { + this->action = 3; + this->frameIndex = 4; + } + } +} + +void sub_08099E8C(Entity *this) +{ + if (sub_080041A0(this, &gLinkEntity, 0xc, 0xc)) { + if (this->previousActionFlag == 0) { + sub_08099ECC(this); + sub_0805E4E0(this, 0x1e); + } + if (CheckLocalFlag(0x75)) { + sub_0805B390(0x7); + } + } +} + +void nullsub_534(Entity* this) {} + +void sub_08099ECC(Entity *this) +{ + this->previousActionFlag = 1; + CopyPosition(this, &gLinkEntity); + gLinkState.linkAction = 3; + gLinkState.filler12[4] = 0; + gLinkState.flags.all |= 0x8000; +} diff --git a/src/object/object9E.c b/src/object/object9E.c new file mode 100644 index 00000000..4c770e82 --- /dev/null +++ b/src/object/object9E.c @@ -0,0 +1,45 @@ +#include "global.h" +#include "entity.h" +#include "room.h" + +extern BoundingBox gUnk_080FD168; + +extern void SetTile(u32, u32, u32); +extern void CopyPosition(Entity*, Entity*); + +void Object9E(Entity *this) +{ + Entity *ent; + u32 tilePos; + u8 *layer; + + if (this->action == 0) { + this->action = 1; + this->spritePriority.b0 = 6; + if ((this->entityType).form == 0) { + this->flags = this->flags | 0x80; + this->frameIndex = 1; + layer = &this->collisionLayer; + *layer = 1; + this->field_0x3c = 7; + this->field_0x40 = 0x48; + this->damageType = 0x7a; + this->flags2 = 1; + this->boundingBox = &gUnk_080FD168; + tilePos = COORD_TO_TILE(this); + SetTile(0x4066, tilePos - 1, *layer); + SetTile(0x4065, tilePos, *layer); + UpdateSpriteForCollisionLayer(this); + ent = CreateObject(0x9e,1,0); + if (ent != NULL) { + this->attachedEntity = ent; + CopyPosition(this, ent); + } + } + else { + this->frameIndex = 0; + this->collisionLayer = 2; + UpdateSpriteForCollisionLayer(this); + } + } +}
\ No newline at end of file diff --git a/src/objectA8.c b/src/object/objectA8.c index b68a141a..b68a141a 100644 --- a/src/objectA8.c +++ b/src/object/objectA8.c diff --git a/src/object/railtrack.c b/src/object/railtrack.c new file mode 100644 index 00000000..95c418f4 --- /dev/null +++ b/src/object/railtrack.c @@ -0,0 +1,148 @@ +#include "global.h" +#include "entity.h" +#include "room.h" +#include "flags.h" + +extern u32* GetLayerByIndex(u32); +extern void sub_08085394(Entity*); +extern void sub_0808543C(Entity*); +extern void sub_08004488(u32); +extern u32 sub_080854A8(Entity*); +extern void SetTile(u32, u32, u32); + +extern void (*const gUnk_081205D0[])(Entity*); + +extern u16 gUnk_081205E0[]; +extern s8 gUnk_080B4488[]; + +void Railtrack(Entity* this) { + gUnk_081205D0[this->action](this); +} + +void sub_080851AC(Entity* this) { + u32 uVar1; + + this->action = 1; + this->spriteSettings.b.draw = 1; + this->spritePriority.b0 = 7; + if ((this->entityType.parameter & 1) != 0) { + this->field_0x7c.HALF.LO = -1; + } else { + this->field_0x7c.HALF.LO = 1; + } + this->animationState = this->entityType.parameter & 2; + if ((this->entityType).form == 3) { + uVar1 = CheckFlags(this->field_0x86); + this->field_0x7a = uVar1; + if ((u16)(uVar1 & -1) != 0) { + this->animationState = (this->animationState + 2) & 3; + this->action = 3; + } + } + InitializeAnimation(this, this->animationState); + this->field_0x70.WORD = (u32)GetLayerByIndex(this->collisionLayer) + 4 + (COORD_TO_TILE(this) * 2); + sub_08085394(this); +} + +void sub_08085264(Entity* this) { + if (CheckFlags(this->field_0x86)) { + this->action = 2; + this->field_0xf = 8; + if (this->entityType.form == 1) { + ClearFlag(this->field_0x86); + } + this->animationState = (this->animationState + *(u8*)&this->field_0x7c) & 3; + InitializeAnimation(this, this->animationState); + sub_0808543C(this); + sub_08004488(0x151); + } +} + +void sub_080852B4(Entity* this) { + if (--this->field_0xf == 0) { + this->action = 3; + this->field_0xf = this->actionDelay; + this->field_0x7a = CheckFlags(this->field_0x86); + this->animationState = (this->animationState + *(u8*)&this->field_0x7c) & 3; + InitializeAnimation(this, this->animationState); + sub_08085394(this); + sub_08004488(0x151); + } +} + +void sub_08085308(Entity* this) { + if (sub_080854A8(this) == 0) { + switch (this->entityType.form) { + case 0: + case 1: + break; + case 2: + if (CheckFlags(this->field_0x86) == 0) { + this->action = 1; + return; + } + break; + case 3: + if (CheckFlags(this->field_0x86) == *(u16*)&this->field_0x7a) { + this->field_0xf = 0xff; + } else { + this->field_0xf = 1; + } + } + + if (--this->field_0xf == 0) { + this->action = 2; + this->field_0xf = 8; + this->animationState = (this->animationState + *(u8*)&this->field_0x7c) & 3; + InitializeAnimation(this, this->animationState); + sub_0808543C(this); + sub_08004488(0x151); + } + } +} + +#if 0 +void sub_08085394(Entity *this) +{ + u32 uVar1; + u16 *layerData; + u32 iVar3; + u32 uVar4; + u8 *pbVar5; + + uVar1 = gUnk_081205E0[this->animationState / 2]; + iVar3 = this->animationState / 2; + layerData = *(u16 **)&this->field_0x70; + uVar4 = COORD_TO_TILE(this); + this->field_0x74 = layerData[gUnk_080B4488[iVar3]]; + pbVar5 = &this->collisionLayer; + SetTile(uVar1, uVar4 - iVar3, *pbVar5); + this->field_0x76 = layerData[0]; + SetTile(uVar1,uVar4, *pbVar5); + *(u16 *)&this->field_0x78 = layerData[iVar3]; + SetTile(uVar1,uVar4 + iVar3, *pbVar5); +} +#endif + +NAKED +void sub_08085394(Entity* this) { + asm(".include \"asm/non_matching/railtrack/sub_08085394.inc\""); +} + +void sub_0808543C(Entity *this) +{ + s8 *cVar1; + u32 uVar2; + s8 temp; + + temp = gUnk_080B4488[(this->animationState >> 1) << 1]; + uVar2 = COORD_TO_TILE(this); + SetTile(this->field_0x74, uVar2 - temp, this->collisionLayer); + SetTile(this->field_0x76, uVar2, this->collisionLayer); + SetTile(this->field_0x78.HWORD, uVar2 + temp, this->collisionLayer); +} + +NAKED +u32 sub_080854A8(Entity *this) { + asm(".include \"asm/non_matching/railtrack/sub_080854A8.inc\""); +}
\ No newline at end of file diff --git a/src/object/smoke.c b/src/object/smoke.c new file mode 100644 index 00000000..b4c83115 --- /dev/null +++ b/src/object/smoke.c @@ -0,0 +1,60 @@ +#include "global.h" +#include "entity.h" + +extern u32 Random(void); +extern void CopyPosition(Entity*, Entity*); +extern void sub_0806F69C(Entity*); +extern void DeleteEntity(Entity*); + +extern void (*const gUnk_08121060[])(Entity*); +extern void (*const gUnk_08121070[])(Entity*); + +extern s8 gUnk_08121068[]; + +void Smoke(Entity* this) { + gUnk_08121060[this->entityType.form](this); +} + +void sub_0808A40C(Entity *this) +{ + Entity *ent; + + if (this->action == 0) { + this->action = 1; + this->actionDelay = 0x28; + } + if (--this->actionDelay == 0) { + this->actionDelay = 0x40 - (Random() & 0x1f); + ent = CreateObject(0x2d, 1, 0); + if (ent != NULL) { + CopyPosition(this,ent); + ent->x.HALF.HI += gUnk_08121068[(Random() & 7)]; + } + } +} + +void sub_0808A46C(Entity *this) +{ + gUnk_08121070[this->action](this); +} + +void sub_0808A484(Entity *this) +{ + this->action = 1; + this->spriteSettings.b.draw = TRUE; + this->nonPlanarMovement = 0x40; + this->direction = 6; + this->spriteRendering.b3 = 1; + this->spritePriority.b0 = 0; + this->spriteOrientation.flipY = 1; + InitializeAnimation(this, 0x28); +} + +void sub_0808A4D0(Entity *this) +{ + GetNextFrame(this); + sub_0806F69C(this); + if (this->frames.b.f3) { + DeleteEntity(this); + } +}
\ No newline at end of file diff --git a/src/object/swordsmanNewsletter.c b/src/object/swordsmanNewsletter.c new file mode 100644 index 00000000..414ac180 --- /dev/null +++ b/src/object/swordsmanNewsletter.c @@ -0,0 +1,31 @@ +#include "global.h" +#include "entity.h" +#include "textbox.h" + +extern void sub_080787B4(Entity*); + +extern void (*const gUnk_081228B0[])(Entity*); + +extern BoundingBox gUnk_081228A8; +extern u16 gUnk_081228B8[]; + +void SwordsmanNewsletter(Entity* this) { + gUnk_081228B0[this->action](this); +} + +void sub_080933D8(Entity *this) +{ + this->action = 1; + this->frameIndex = this->entityType.form; + UpdateSpriteForCollisionLayer(this); + this->boundingBox = &gUnk_081228A8; + sub_080787B4(this); +} + +void sub_080933FC(Entity *this) +{ + if (this->interactType != 0) { + this->interactType = 0; + TextboxNoOverlap(gUnk_081228B8[this->entityType.form], this); + } +}
\ No newline at end of file diff --git a/src/thoughtBubble.c b/src/object/thoughtBubble.c index eebbba1b..73316eca 100644 --- a/src/thoughtBubble.c +++ b/src/object/thoughtBubble.c @@ -18,11 +18,11 @@ void ThoughtBubble(Entity* this) void ThoughtBubble_Init(Entity *this) { this->action = 1; - this->spriteSettings.b.ss0 = 1; + this->spriteSettings.b.draw = 1; if (this->actionDelay == 0) { this->actionDelay = 0x2d; } - this->spriteOrientation.b2 = 1; + this->spriteOrientation.flipY = 1; InitializeAnimation(this, this->entityType.parameter); PlaySFX(ThoughtBubble_SFX[this->entityType.parameter]); } diff --git a/src/object/treeHidingPortal.c b/src/object/treeHidingPortal.c new file mode 100644 index 00000000..8ea54861 --- /dev/null +++ b/src/object/treeHidingPortal.c @@ -0,0 +1,88 @@ +#include "global.h" +#include "entity.h" +#include "flags.h" +#include "link.h" +#include "room.h" + +extern void sub_0809E96C(Entity*); +extern u32 sub_0800419C(Entity*, Entity*, u32, u32); +extern void sub_080A2B80(Entity*); +extern u32 sub_0809E9A0(void); +extern void sub_08078A90(u32); +extern void sub_0809E918(Entity*); +extern void PlaySFX(u32); +extern void CreateMinishEntrance(u32 tile); + +extern void (*const gUnk_08124354[])(Entity*); + +extern u32 gUnk_030010A0; +extern s16 gUnk_08124364[]; + +void TreeHidingPortal(Entity* this) { + gUnk_08124354[this->action](this); +} + +void sub_0809E83C(Entity* this) { + if (CheckFlags(this->field_0x86)) { + sub_0809E96C(this); + DeleteThisEntity(); + } + this->action = 1; + this->collisionLayer = 2; + UpdateSpriteForCollisionLayer(this); +} + +void sub_0809E86C(Entity* this) { + + if (sub_0800419C(this, &gLinkEntity, 0x30, 0x30)) { + if (CheckGlobalFlag(0x14)) { + if (((gUnk_030010A0 & 3) == 0)) { + sub_080A2B80(this); + } + } + } + if (sub_0809E9A0() == 0x54) { + this->action = 2; + this->actionDelay = 0xf; + sub_08078A90(1); + } +} + +void sub_0809E8BC(Entity* this) { + if (--this->actionDelay == 0) { + this->action = 3; + this->actionDelay = 0x3c; + this->spriteSettings.b.draw = 0; + sub_0809E96C(this); + sub_0809E918(this); + } +} + +void sub_0809E8EC(Entity* this) { + if (--this->actionDelay == 0) { + SetFlag(this->field_0x86); + sub_08078A90(0); + PlaySFX(0x73); + DeleteThisEntity(); + } +} + +void sub_0809E918(Entity* this) { + Entity* fx; + s16* i = gUnk_08124364; + while (*i != -1000) { + fx = CreateFx(this, 3, 0); + if (fx != NULL) { + fx->x.HALF.HI += i[0]; + fx->y.HALF.HI += i[1]; + fx->collisionLayer = 2; + UpdateSpriteForCollisionLayer(fx); + } + i += sizeof(s16); + } +} + +void sub_0809E96C(Entity *this) +{ + CreateMinishEntrance(COORD_TO_TILE_OFFSET(this, 0x20, 0x8)); +}
\ No newline at end of file diff --git a/src/well.c b/src/object/well.c index fa387763..9efcd750 100644 --- a/src/well.c +++ b/src/object/well.c @@ -1,14 +1,13 @@ #include "global.h" #include "entity.h" #include "room.h" +#include "link.h" void SetTile(u32 tileIndex, s32 tilePosition, s32 layerIndex); s32 GetTileType(s32 tilePosition, s32 layerIndex); void sub_08078B48(); void DeleteThisEntity(); -extern Entity gLinkEntity; -extern RoomControls gRoomControls; extern void (*gUnk_08124C08[])(Entity*); void Well(Entity* ent) { diff --git a/src/windTribeFlag.c b/src/object/windTribeFlag.c index b17e9e9e..f9c82da8 100644 --- a/src/windTribeFlag.c +++ b/src/object/windTribeFlag.c @@ -8,12 +8,12 @@ void WindTribeFlag(Entity *this) this->action++; this->collisionLayer = 2; if ((this->entityType).form == 0) { - this->spriteSettings.b.ss6 = 0; + this->spriteSettings.b.flipX = 0; } else { - this->spriteSettings.b.ss6 = 1; + this->spriteSettings.b.flipX = 1; } - UpdateSpriteOrderAndFlip(this); + UpdateSpriteForCollisionLayer(this); InitializeAnimation(this,0); } else { diff --git a/src/windcrest.c b/src/object/windcrest.c index 231eb425..231eb425 100644 --- a/src/windcrest.c +++ b/src/object/windcrest.c diff --git a/src/ocarina.c b/src/ocarina.c index 88fab47b..b4eddddc 100644 --- a/src/ocarina.c +++ b/src/ocarina.c @@ -24,7 +24,7 @@ void Ocarina(ItemBehavior* pItemBeh, u32 inputFlags) // u32 *ocarinaStates = &gOcarinaStates; //_call_via_r2(pItemBeh, inputFlags,(ocarinaStates)[pItemBeh->stateID]); gOcarinaStates[pItemBeh->stateID](pItemBeh, inputFlags); - gLinkEntity.itemCooldown = gLinkEntity.itemCooldown + 1; + gLinkEntity.field_0x7a = gLinkEntity.field_0x7a + 1; } void OcarinaUse(ItemBehavior* itemBeh, s32 inputFlags) { @@ -40,7 +40,7 @@ void OcarinaUse(ItemBehavior* itemBeh, s32 inputFlags) { gLinkEntity.spriteSettings.raw &= var; gLinkEntity.flags &= 127; - gLinkEntity.itemCooldown = 2; + gLinkEntity.field_0x7a = 2; gLinkState.flags.all |= 0x10000000; gLinkState.filler8[0] = 255; gUnk_02034490 = 1; diff --git a/src/position.c b/src/position.c index 1c96046f..50aa4c6f 100644 --- a/src/position.c +++ b/src/position.c @@ -28,7 +28,7 @@ void PositionRelative(Entity* source, Entity* target, s32 offsetX, s32 offsetY) target->height = source->height; // ldr target->collisionLayer = source->collisionLayer; - UpdateSpriteOrderAndFlip(target); + UpdateSpriteForCollisionLayer(target); } void CopyPositionAndSpriteOffset(Entity *param_1,Entity *param_2) @@ -47,10 +47,10 @@ void sub_0806FA90(Entity *param_1,Entity *param_2, s32 offsetX, s32 offsetY) void ResolveEntityOnTop(Entity *param_1,Entity *param_2) { - param_2->ticks.b0 = gUnk_08114F78[param_1->ticks.b0]; + param_2->spritePriority.b0 = gUnk_08114F78[param_1->spritePriority.b0]; } void sub_0806FAD8(Entity *param_1,Entity *param_2) { - param_2->ticks.b0 = gUnk_08114F80[param_1->ticks.b0]; + param_2->spritePriority.b0 = gUnk_08114F80[param_1->spritePriority.b0]; } diff --git a/src/sub_0804AFF4.c b/src/sub_0804AFF4.c index a1a4731d..a7108fd6 100644 --- a/src/sub_0804AFF4.c +++ b/src/sub_0804AFF4.c @@ -1,7 +1,7 @@ #include "global.h" extern void sub_080186EC(); -extern u32* sub_0804B128(u8); +extern u32* GetCurrentRoomProperty(u8); extern u32 _call_via_r0(u32*); extern void sub_0804B16C(); @@ -9,11 +9,11 @@ void sub_0804AFF4(void) { u32* func; sub_080186EC(); - func = sub_0804B128(5); + func = GetCurrentRoomProperty(5); if (func != NULL) { _call_via_r0(func); } - func = sub_0804B128(7); + func = GetCurrentRoomProperty(7); if (func != NULL) { _call_via_r0(func); } @@ -27,13 +27,13 @@ sub_0804AFF4: @ 0x0804AFF4 push {lr} bl sub_080186EC movs r0, #5 - bl sub_0804B128 + bl GetCurrentRoomProperty cmp r0, #0 beq _0804B008 bl _call_via_r0 _0804B008: movs r0, #7 - bl sub_0804B128 + bl GetCurrentRoomProperty cmp r0, #0 beq _0804B016 bl _call_via_r0 diff --git a/src/textbox.c b/src/textbox.c index 1ec017d8..b8b82940 100644 --- a/src/textbox.c +++ b/src/textbox.c @@ -7,8 +7,6 @@ void sub_0801D630(); void ShowTextbox(); void TextboxAtPosition(); -extern TextBox gTextBox; -extern RoomControls gRoomControls; extern u32 gUnk_02022780; extern u32 gUnk_02036A40; extern u32 gUnk_02036A38; |
