summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authornotyouraveragehooman <65437533+notyouraveragehooman@users.noreply.github.com>2020-08-03 12:20:27 -0700
committerGitHub <noreply@github.com>2020-08-03 12:20:27 -0700
commite2bbe039ded00520c4267552697bb7f643ca3482 (patch)
treea95daff18d41883c4168a5eb4ab1d47605d28e5b /src
parentcbf02a618eb14e99aee4f97b4aa186b01c0034e2 (diff)
parent2325ed7144dde82026d261e470ff16794e375b27 (diff)
Merge pull request #35 from notyouraveragehooman/master
librari.c OK, goronmerchant.c, object2a.c OK
Diffstat (limited to 'src')
-rw-r--r--src/enemy/rupeeLike.c2
-rw-r--r--src/npc/goronMerchant.c143
-rw-r--r--src/npc/librari.c107
-rw-r--r--src/npc/percy.c36
-rw-r--r--src/object/minecart.c225
-rw-r--r--src/object/object2A.c40
6 files changed, 552 insertions, 1 deletions
diff --git a/src/enemy/rupeeLike.c b/src/enemy/rupeeLike.c
index 5b6bd3e5..009b8789 100644
--- a/src/enemy/rupeeLike.c
+++ b/src/enemy/rupeeLike.c
@@ -161,7 +161,7 @@ void sub_0802953C(Entity* this) {
if (((this->field_0xf > 0x2d) || (gUnk_02002A40.stats.rupees == 0)) && (this->actionDelay == 0)) {
sub_080296D8(this);
} else {
- sub_08077B2C();
+ ResetLink();
gLinkState.field_0x1a[0] |= 0x80;
PositionRelative(this, &gLinkEntity, 0, 0x10000);
pbVar3 = GetSpriteSubEntryOffsetDataPointer((u16)this->spriteIndex, this->frameIndex);
diff --git a/src/npc/goronMerchant.c b/src/npc/goronMerchant.c
new file mode 100644
index 00000000..8cda93ec
--- /dev/null
+++ b/src/npc/goronMerchant.c
@@ -0,0 +1,143 @@
+#include "global.h"
+#include "entity.h"
+#include "functions.h"
+#include "structures.h"
+#include "textbox.h"
+#include "room.h"
+#include "flags.h"
+
+extern u32 sub_080696BC(Entity*);
+
+extern void (*const gUnk_08111B88[])(Entity*);
+extern void (*const gUnk_08111B98[])(Entity*);
+
+extern u16 gUnk_08111BA0[];
+
+
+void GoronMerchant(Entity *this)
+{
+ if ((this->flags & 2) != 0) {
+ gUnk_08111B98[this->action](this);
+ }
+ else {
+ gUnk_08111B88[this->action](this);
+ sub_0806ED78(this);
+ }
+}
+
+void sub_08069584(Entity *this)
+{
+ if (gUnk_030010A0.field_0x24[8] != 0) {
+ this->action = 3;
+ }
+ else {
+ this->action = 1;
+ }
+ InitAnimationForceUpdate(this, 2);
+}
+
+void sub_080695AC(Entity *this)
+{
+ s32 iVar2;
+
+ if (++this->field_0xf > 0x10) {
+ this->field_0xf = 0;
+ iVar2 = sub_0806ED9C(this, 0x28, 0x28);
+ if (iVar2 > -1) {
+ this->animationState = iVar2;
+ }
+ }
+ if (this->animIndex != this->animationState) {
+ InitAnimationForceUpdate(this, this->animationState);
+ }
+}
+
+void sub_080695E8(Entity *this)
+{
+ UpdateAnimationSingleFrame(this);
+ if ((gTextBox.doTextBox & 0x7f) == 0) {
+ this->action = 1;
+ this->interactType = gTextBox.doTextBox & 0x7f;
+ sub_0805E584(this);
+ InitAnimationForceUpdate(this, this->animationState);
+ }
+}
+
+void sub_0806961C(Entity *this)
+{
+ if (gUnk_030010A0.field_0x24[8] == 2) {
+ UpdateAnimationSingleFrame(this);
+ }
+ sub_0806FD3C(this);
+}
+
+void sub_0806963C(Entity *this)
+{
+ this->action = 1;
+ this->spriteSettings.b.draw = TRUE;
+ sub_0807DD50(this);
+}
+
+void sub_08069654(Entity* this) {
+ sub_0807DD94(this, 0);
+}
+
+void sub_08069660(Entity *this)
+{
+ u32 uVar1;
+
+ TextboxNoOverlap(0x2c1c, this);
+ gTextBox.field_0x10 = (u16)sub_080696BC(this);
+}
+
+void sub_08069684(void)
+{
+ Entity *mgr;
+
+ if (sub_0805EB00(9, 0x31, 8) == NULL) {
+ mgr = sub_0805E8D4();
+ if (mgr != NULL) {
+ mgr->entityType.type = 9;
+ mgr->entityType.subtype = 0x31;
+ sub_0805EA2C(mgr, 8);
+ }
+ }
+}
+
+void sub_080696B0(void)
+{
+ gRoomVars.itemForSaleIndex = 0;
+}
+
+u32 sub_080696BC(Entity* this)
+{
+ u32 uVar1;
+ u32 temp;
+ u32 iVar3;
+ s32 temp2;
+
+ temp2 = gRoomVars.field_0x7;
+ if (temp2 > 0x70) {
+ iVar3 = 1;
+ }
+ else {
+ iVar3 = 0;
+ }
+ if (temp2 > 0x72) {
+ iVar3 = 2;
+ }
+
+ temp = CheckGlobalFlag(0x3e);
+ uVar1 = (-temp | temp) >> 0x1f;
+
+ if (CheckGlobalFlag(0x3f)) {
+ uVar1 = 2;
+ }
+ if (CheckGlobalFlag(0x40)) {
+ uVar1 = 3;
+ }
+ if (CheckGlobalFlag(0x41)) {
+ uVar1 = 4;
+ }
+ return gUnk_08111BA0[uVar1 * 3 + iVar3];
+} \ No newline at end of file
diff --git a/src/npc/librari.c b/src/npc/librari.c
new file mode 100644
index 00000000..77b48bb6
--- /dev/null
+++ b/src/npc/librari.c
@@ -0,0 +1,107 @@
+#include "global.h"
+#include "entity.h"
+#include "npc.h"
+#include "flags.h"
+#include "textbox.h"
+#include "functions.h"
+
+extern u16 gUnk_08112D48[];
+
+void Librari(Entity* this) {
+ switch (this->action) {
+ case 0:
+ this->action = 1;
+ this->spriteSettings.b.draw = TRUE;
+ this->animationState = this->actionDelay;
+ this->field_0x68 = sub_0801E99C(this);
+ sub_08078784(this, this->field_0x68);
+ sub_0805E3A0(this, 2);
+ 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);
+ UpdateAnimationSingleFrame(this);
+ }
+ break;
+ case 2:
+ if (UpdateFuseInteraction(this)) {
+ this->action = 1;
+ }
+ }
+}
+
+void sub_0806B260(Entity* this, u32 arg1) {
+ u32 index;
+
+ *(u32*)(arg1 + 0x14) = 0;
+ // flippers
+ if (!GetInventoryValue(0x46)) {
+ if (CheckGlobalFlag(0x29)) {
+ index = 2;
+ *(u32*)(arg1 + 0x14) = 1;
+ } else if (!CheckLocalFlag(0x7a)) {
+ index = 0;
+ SetLocalFlag(0x7a);
+ } else {
+ index = 1;
+ }
+ } else {
+ index = 3;
+ }
+ TextboxNoOverlap(gUnk_08112D48[index], this);
+}
+
+extern u16 gUnk_08112D50[];
+
+void sub_0806b2b4(Entity* this) {
+ u32 index;
+
+ if (CheckLocalFlag(0xb3)) {
+ if (!CheckRoomFlag(0)) {
+ index = 1;
+ SetRoomFlag(0);
+ } else if (!CheckRoomFlag(1)) {
+ index = 2;
+ SetRoomFlag(1);
+ } else if (!CheckRoomFlag(2)) {
+ index = 3;
+ SetRoomFlag(2);
+ } else {
+ index = 4;
+ ClearRoomFlag(0);
+ ClearRoomFlag(1);
+ ClearRoomFlag(2);
+ }
+ } else {
+ index = 0;
+ }
+ TextboxNoOverlap(gUnk_08112D50[index], this);
+}
+
+void Librari_Fusion(Entity *this)
+{
+ if (this->action == 0) {
+ this->action++;
+ this->spriteSettings.b.draw = TRUE;
+ InitAnimationForceUpdate(this, 9);
+ }
+ else {
+ UpdateAnimationSingleFrame(this);
+ }
+}
+
+void Percy_Head(Entity *this) // ???
+{
+ SetExtraSpriteFrame(this, 0, (this->frameSpriteSettings & 0x3f) + 0x13);
+ SetExtraSpriteFrame(this, 1, (this->frames.all & 0x7f) + 0xb);
+ SetExtraSpriteFrame(this, 2, this->frameIndex);
+ SetSpriteSubEntryOffsetData1(this, 2, 1);
+ SetSpriteSubEntryOffsetData2(this, 2, 0);
+ sub_0807000C(this);
+} \ No newline at end of file
diff --git a/src/npc/percy.c b/src/npc/percy.c
new file mode 100644
index 00000000..759b94d3
--- /dev/null
+++ b/src/npc/percy.c
@@ -0,0 +1,36 @@
+#include "global.h"
+#include "entity.h"
+#include "npc.h"
+#include "textbox.h"
+#include "functions.h"
+
+extern void sub_0806B41C(Entity*);
+void sub_0806B3CC(Entity*);
+
+extern SpriteLoadData gUnk_08112E1C;
+
+void Percy(Entity* this) {
+ if ((this->flags & 2) != 0) {
+ sub_0806B41C(this);
+ } else {
+ sub_0806B3CC(this);
+ }
+}
+
+void sub_0806B3CC(Entity *this)
+{
+ if (this->action == 0) {
+ if (!LoadExtraSpriteData(this, &gUnk_08112E1C)) {
+ return;
+ }
+ this->action = 1;
+ InitializeAnimation(this, 0);
+ sub_08078778(this);
+ }
+ GetNextFrame(this);
+ if (this->interactType != 0) {
+ this->interactType = 0;
+ TextboxNoOverlapFollow(0);
+ }
+ sub_0806ED78(this);
+}
diff --git a/src/object/minecart.c b/src/object/minecart.c
new file mode 100644
index 00000000..eff15d3a
--- /dev/null
+++ b/src/object/minecart.c
@@ -0,0 +1,225 @@
+#include "global.h"
+#include "entity.h"
+#include "functions.h"
+#include "room.h"
+
+typedef struct {
+ u16 field_0x0;
+ u16 field_0x2;
+ u8 field_0x4;
+ u8 field_0x5;
+ u8 field_0x6;
+ u8 field_0x7;
+} struct_030010EC;
+
+extern void (*const gUnk_081223A8[])(Entity*);
+
+extern struct_030010EC gUnk_030010EC[];
+extern BoundingBox gUnk_080FD310;
+
+void Minecart(Entity* this) {
+ gUnk_081223A8[this->action](this);
+ this->bitfield = 0;
+}
+
+void sub_080916EC(Entity* this) {
+ struct_030010EC* unk = &gUnk_030010EC[this->actionDelay];
+
+ *(struct_030010EC**)&this->cutsceneBeh.HWORD = unk;
+ if ((gRoomControls.roomID != unk->field_0x4) || (gLinkState.flags.all & 0x1000) != 0) {
+ DeleteThisEntity();
+ }
+ this->x.HALF.HI = gRoomControls.roomOriginX + ((unk->field_0x0 & 0x3f) << 4) + 8;
+ this->y.HALF.HI = gRoomControls.roomOriginY + ((unk->field_0x0 & 0xfc << 4) >> 2) + 8;
+ this->animationState = unk->field_0x5;
+ this->entityType.parameter = unk->field_0x6;
+ this->action = 1;
+ this->boundingBox = &gUnk_080FD310;
+ this->flags |= 0x80;
+ this->damageType = 1;
+ this->field_0x3c = 0x47;
+ this->field_0x40 = 0x44;
+ this->flags2 = 0x80;
+ this->direction = this->animationState << 3;
+ this->nonPlanarMovement = 0x700;
+ this->spritePriority.b1 = 3;
+ InitAnimationForceUpdate(this, this->entityType.parameter + 4 + this->animationState);
+ SetTile(0x4022, COORD_TO_TILE(this), this->collisionLayer);
+}
+
+void sub_080917DC(Entity* this) {
+
+ if ((this->bitfield & 0x7f) == 0x1d) {
+ this->field_0x20 = 0x2a000;
+ this->action = 7;
+ InitAnimationForceUpdate(this, this->entityType.parameter + 4 + this->animationState);
+ PlaySFX(0x13b);
+ } else {
+ if (sub_0800445C(this) != 0) {
+ if (((gLinkState.flags.all & 0x40080) == 0) && (gLinkState.field_0x1c == 0) &&
+ (gLinkState.heldObject == 0) && (gLinkState.jumpStatus == 0)) {
+ this->actionDelay++;
+ } else {
+ this->actionDelay = 0;
+ }
+ } else {
+ this->actionDelay = 0;
+ }
+ if ((this->entityType).parameter == 0) {
+ if (8 < this->actionDelay) {
+ this->action = this->action + 1;
+ gLinkState.jumpStatus = 0x81;
+ gLinkState.flags.all |= 0x4000000;
+ gLinkEntity.field_0x20 = 0x20000;
+ gLinkEntity.nonPlanarMovement = 0x100;
+ gLinkEntity.flags &= 0x7f;
+ ResetLink();
+ sub_0807A108();
+ PlaySFX(0x7c);
+ }
+ } else {
+ this->actionDelay = 0;
+ }
+ }
+}
+
+void sub_080918A4(Entity *this)
+{
+ if (sub_080041A0(this, &gLinkEntity, 2, 2) != 0) {
+ gLinkEntity.x.HALF.HI = this->x.HALF.HI;
+ gLinkEntity.y.HALF.HI = this->y.HALF.HI;
+ if (gLinkEntity.height.HALF.HI > -0x10) {
+ if ((s32)gLinkEntity.field_0x20 > -1) {
+ return;
+ }
+ gLinkEntity.animationState = this->animationState << 1;
+ gLinkState.flags.all = (gLinkState.flags.all ^ 0x4000000) | 0x1000;
+ this->action++;
+ this->field_0xf = 1;
+ this->flags |= 0x20;
+ this->damageType = 0x97;
+ this->field_0x3c = (gLinkEntity.field_0x3c + 1) | 0x20;
+ this->flags2 = gLinkEntity.flags2;
+ this->field_0x40 = 0x18;
+ this->field_0x44 = 8;
+ sub_0801766C(this);
+ sub_0807BA8C(COORD_TO_TILE(this), this->collisionLayer);
+ PlaySFX(0x137);
+ }
+ }
+ else {
+ gLinkEntity.direction = GetFacingDirection(&gLinkEntity, this);
+ }
+ if (gLinkEntity.field_0x20 < 0) {
+ gLinkEntity.spritePriority.b0 = this->spritePriority.b0 - 1;
+ }
+}
+
+#if 0
+
+typedef struct {
+ u8 field_0x0;
+ u8 field_0x1;
+} struct_081223C8;
+
+extern struct_081223C8 gUnk_081223C8[];
+
+extern u32 gUnk_081223D8[];
+
+void sub_080919AC(Entity *this)
+{
+ u32 iVar2;
+ u32 uVar3;
+ u32 uVar4;
+ struct_081223C8* temp;
+
+ gRoomControls.unk5 = 7;
+ if ((gLinkState.flags.all & 0x1000) == 0) {
+ this->action = 1;
+ }
+ else {
+ if ((gLinkEntity.frames.all & 0xf) == 0) {
+ this->flags = this->flags & 0x7f;
+ CopyPosition(this,&gLinkEntity);
+ if ((gLinkEntity.frames.all & 0xf0) == 0x10) {
+ this->spriteOffsetY = 1;
+ }
+ else {
+ this->spriteOffsetY = 0;
+ }
+ }
+ else {
+ this->flags = this->flags | 0x80;
+ gLinkEntity.nonPlanarMovement = 0;
+ sub_0806F69C(this);
+ CopyPosition(this,&gLinkEntity);
+ gLinkEntity.spritePriority.b0 = this->spritePriority.b0 - 1;
+ if (!sub_08091DDC(this)) {
+ if ((gUnk_030010A0.field_0x0 & 0xf) == 0) {
+ PlaySFX(0x138);
+ }
+
+ if (--this->field_0xf == 0xff) {
+ PlaySFX(0x7b);
+ this->field_0xf = 0x3c;
+ }
+ uVar3 = sub_03005800(this, gUnk_081223C8[this->animationState].field_0x0, gUnk_081223C8[this->animationState].field_0x1);
+ iVar2 = sub_08007DD6(uVar3, gUnk_081223D8[this->animationState]);
+ if (iVar2 == 0) {
+ this->direction = this->direction ^ 0x10;
+ this->animationState = this->animationState ^ 2;
+ }
+ else {
+ switch(uVar3) {
+ case 100:
+ this->flags = this->flags & 0xdf;
+ this->damageType = 1;
+ this->field_0x3c = 0x47;
+ this->field_0x40 = 0x44;
+ this->flags2 = 0x80;
+ this->action = 6;
+ sub_08017744(this);
+ gLinkState.jumpStatus = 0x41;
+ gLinkState.flags.all = (gLinkState.flags.all ^ 0x1000) | 0x4000000;
+ gLinkEntity.field_0x20 = 0x20000;
+ gLinkEntity.nonPlanarMovement = 0x200;
+ gLinkEntity.animationState = this->animationState << 1;
+ gLinkEntity.direction = this->direction;
+ gLinkEntity.flags |= 0x80;
+ sub_08004168(this);
+ InitAnimationForceUpdate(this, this->animationState + 0xc);
+ PlaySFX(0x78);
+ PlaySFX(0x139);
+ return;
+ case 0x67:
+ case 0x68:
+ case 0x69:
+ case 0x6a:
+ case 0x6c:
+ case 0x6d:
+ case 0x6e:
+ case 0x6f:
+ if (uVar3 == sub_080002B8()) {
+ sub_08091C0C(this);
+ gLinkEntity.animationState *= 2;
+ return;
+ }
+ }
+ }
+ gLinkEntity.animationState *= 2;
+ if (this->animIndex == this->animationState) {
+ UpdateAnimationSingleFrame(this);
+ }
+ else {
+ InitAnimationForceUpdate(this, this->animationState);
+ }
+ }
+ }
+ }
+}
+#else
+NAKED
+void sub_080919AC(Entity *this) {
+ asm(".include \"asm/non_matching/minecart/sub_080919AC.inc\"");
+}
+#endif \ No newline at end of file
diff --git a/src/object/object2A.c b/src/object/object2A.c
new file mode 100644
index 00000000..d8f30b54
--- /dev/null
+++ b/src/object/object2A.c
@@ -0,0 +1,40 @@
+#include "global.h"
+#include "entity.h"
+#include "functions.h"
+#include "flags.h"
+
+extern void (*const gUnk_08120DD0[])(Entity*);
+
+void Object2A(Entity* this) {
+ gUnk_08120DD0[this->action](this);
+}
+
+void sub_08089B18(Entity *this)
+{
+ this->action = 1;
+ this->spriteSettings.b.draw = TRUE;
+ if (this->entityType.parameter != 0) {
+ this->actionDelay = this->entityType.parameter;
+ }
+ InitializeAnimation(this, 0);
+ switch (this->entityType.form) {
+ case 1:
+ this->y.HALF.HI -= 8;
+ this->actionDelay = 0x28;
+ break;
+ case 2:
+ this->actionDelay = 0xf;
+ sub_08004168(this);
+ break;
+ case 3:
+ CopyPosition(this->parent, this);
+ break;
+ case 4:
+ if (!CheckFlags(this->field_0x86)) {
+ this->spriteSettings.b.draw = FALSE;
+ this->previousActionFlag = 1;
+ return;
+ }
+ }
+ sub_08004488(0x124);
+} \ No newline at end of file