diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/code_08077DF4.c | 4 | ||||
| -rw-r--r-- | src/npc/cow.c | 10 | ||||
| -rw-r--r-- | src/npc/epona.c | 4 | ||||
| -rw-r--r-- | src/npc/festari.c | 1 | ||||
| -rw-r--r-- | src/npc/forestMinish.c | 208 | ||||
| -rw-r--r-- | src/npc/goron.c | 11 | ||||
| -rw-r--r-- | src/npc/mayorHagen.c | 87 | ||||
| -rw-r--r-- | src/npc/melari.c | 1 | ||||
| -rw-r--r-- | src/npc/mutoh.c | 81 | ||||
| -rw-r--r-- | src/npc/postman.c | 13 | ||||
| -rw-r--r-- | src/npc/rem.c | 1 | ||||
| -rw-r--r-- | src/npc/smith.c | 283 | ||||
| -rw-r--r-- | src/npc/stamp.c | 9 | ||||
| -rw-r--r-- | src/npc/teachers.c | 97 | ||||
| -rw-r--r-- | src/npc/townMinish.c | 351 | ||||
| -rw-r--r-- | src/npc/townsperson.c | 47 | ||||
| -rw-r--r-- | src/npc/windTribespeople.c | 113 |
17 files changed, 742 insertions, 579 deletions
diff --git a/src/code_08077DF4.c b/src/code_08077DF4.c index 1f6d9246..69dd5820 100644 --- a/src/code_08077DF4.c +++ b/src/code_08077DF4.c @@ -29,9 +29,9 @@ void UpdateItemAnim(Entity *ent) sub_08077E54(ent); } -void sub_08077E3C(Entity *ent) +void sub_08077E3C(Entity *ent, u32 idx) { - sub_080042BA(&gPlayerEntity); + sub_080042BA(&gPlayerEntity, idx); sub_08077E54(ent); } diff --git a/src/npc/cow.c b/src/npc/cow.c index 9c62c898..54500e02 100644 --- a/src/npc/cow.c +++ b/src/npc/cow.c @@ -1,21 +1,19 @@ #include "global.h" #include "entity.h" #include "player.h" +#include "functions.h" -extern void sub_0806ED78(Entity*); extern void sub_0806920C(Entity*); extern u32 sub_0805ACC0(Entity*); extern u32 sub_0801E99C(Entity*); extern void sub_0806924C(Entity*); -extern void sub_080AEF88(Entity*); -extern void ShowNPCDialogue(Entity*, u32*); extern void sub_08078778(Entity*); extern void sub_080787A8(Entity*, u32); extern void sub_0806F118(Entity*); extern void sub_080791D0(); extern void (*gUnk_08111914[])(Entity*); extern void (*gUnk_08111928[])(Entity*); -extern u32 gUnk_08111938[]; +extern Dialog gUnk_08111938[]; extern void PlaySFX(u32); extern u32 Random(); extern u32 UpdateFuseInteraction(Entity*); @@ -184,9 +182,7 @@ void sub_080691E0(Entity* ent) { // Show dialogue void Cow_ShowDialogue(Entity* ent) { - u32 var0 = ent->entityType.form; - u32* var1 = gUnk_08111938 + (var0 * 2); - ShowNPCDialogue(ent, var1); + ShowNPCDialogue(ent, &gUnk_08111938[ent->entityType.form]); } void sub_0806920C(Entity* ent) { diff --git a/src/npc/epona.c b/src/npc/epona.c index 89c18204..69368bc3 100644 --- a/src/npc/epona.c +++ b/src/npc/epona.c @@ -8,7 +8,7 @@ void sub_08065A64(Entity* this); void sub_08065AA4(Entity*); extern void (*gUnk_0811006C[])(Entity*); -extern u32 gUnk_08110080[]; +extern Dialog gUnk_08110080[]; void Epona(Entity* this) { gUnk_0811006C[this->action](this); @@ -50,7 +50,7 @@ void sub_08065A34(Entity* this) { } void sub_08065A50(Entity* this) { - ShowNPCDialogue(this, &gUnk_08110080[this->entityType.form * 2]); + ShowNPCDialogue(this, &gUnk_08110080[this->entityType.form]); } void sub_08065A64(Entity* this) { diff --git a/src/npc/festari.c b/src/npc/festari.c index 3a86130c..dccde267 100644 --- a/src/npc/festari.c +++ b/src/npc/festari.c @@ -10,7 +10,6 @@ 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*); diff --git a/src/npc/forestMinish.c b/src/npc/forestMinish.c index 7c2d214d..5dc80dce 100644 --- a/src/npc/forestMinish.c +++ b/src/npc/forestMinish.c @@ -5,9 +5,8 @@ #include "textbox.h" #include "player.h" #include "structures.h" +#include "functions.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); @@ -16,7 +15,6 @@ 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* FindEntityInListBySubtype(u32, u32, u32); @@ -26,10 +24,10 @@ extern u32 Random(void); extern void ModBombs(s32); extern SpriteLoadData gUnk_0810A348; -extern void* gUnk_08109D18[]; +extern u8* gUnk_08109D18[]; extern u8 gUnk_08109C98[]; extern u16 gUnk_0810A354[]; -extern u32 gUnk_08109DC8[]; +extern Dialog gUnk_08109DC8[]; extern u16 gUnk_0810A35A[]; extern u16 gUnk_0810A362[]; @@ -165,141 +163,125 @@ void sub_080601D4(Entity* this) { TextboxNoOverlap(gUnk_0810A354[uVar2], this); } -void sub_08060208(Entity *this) -{ - ShowNPCDialogue(this, &gUnk_08109DC8[this->entityType.parameter * 0x8]); +void sub_08060208(Entity* this) { + ShowNPCDialogue(this, &gUnk_08109DC8[this->entityType.parameter * 0x4]); } -void sub_0806021C(Entity *this) -{ - u32 uVar1; - u32 uVar2; +void sub_0806021C(Entity* this) { + u32 uVar1; + u32 uVar2; - //jabber nut - uVar1 = GetInventoryValue(0x5B); - uVar2 = (-uVar1 | uVar1) >> 0x1f; + // jabber nut + uVar1 = GetInventoryValue(0x5B); + uVar2 = (-uVar1 | uVar1) >> 0x1f; - //earth element - if (GetInventoryValue(0x40)) { - uVar2 = 2; - } + // earth element + if (GetInventoryValue(0x40)) { + uVar2 = 2; + } - //mole mitts - if (GetInventoryValue(0x13)) { - uVar2 = 3; - } - ShowNPCDialogue(this, gUnk_08109DC8 + this->entityType.parameter * 0x8 + uVar2 * 2); + // mole mitts + if (GetInventoryValue(0x13)) { + uVar2 = 3; + } + ShowNPCDialogue(this, gUnk_08109DC8 + this->entityType.parameter * 0x4 + uVar2); } -void sub_0806025C(Entity *this) -{ - ShowNPCDialogue(this, &gUnk_08109DC8[this->entityType.parameter * 0x8]); +void sub_0806025C(Entity* this) { + ShowNPCDialogue(this, &gUnk_08109DC8[this->entityType.parameter * 0x4]); } -void sub_08060270(Entity *this) -{ - u32 index; +void sub_08060270(Entity* this) { + u32 index; - //flippers - if (GetInventoryValue(0x46) == 0) { - index = 1; - if (CheckGlobalFlag(MIZUKAKI_START) == 0) { - index = 0; - SetGlobalFlag(MIZUKAKI_START); - } - } - else { - index = 3; - if (CheckLocalFlag(0x76) == 0) { - index = 2; - SetLocalFlag(0x76); + // flippers + if (GetInventoryValue(0x46) == 0) { + index = 1; + if (CheckGlobalFlag(MIZUKAKI_START) == 0) { + index = 0; + SetGlobalFlag(MIZUKAKI_START); + } + } else { + index = 3; + if (CheckLocalFlag(0x76) == 0) { + index = 2; + SetLocalFlag(0x76); + } } - } - TextboxNoOverlap(gUnk_0810A35A[index], this); + TextboxNoOverlap(gUnk_0810A35A[index], this); } -void sub_080602BC(Entity *this) -{ - u32 index; - - //spin attack +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; + 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); + TextboxNoOverlap(gUnk_0810A362[index], this); } -void sub_0806030C(Entity* this, u32 *arg1) -{ +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 = FindEntityInListBySubtype(8, 2, 2); - if (ent != NULL) { - sub_080A29BC(ent); - DeleteEntity(ent); +void sub_08060318(void) { + Entity* ent; + int i; + + for (i = 2; i >= 0; i--) { + ent = FindEntityInListBySubtype(8, 2, 2); + if (ent != NULL) { + sub_080A29BC(ent); + DeleteEntity(ent); + } } - } } -void sub_08060340(void) -{ - gUnk_02002A40.unk490 = gUnk_02002A40.unk50; +void sub_08060340(void) { + gUnk_02002A40.unk490 = gUnk_02002A40.unk50; } -u32 sub_08060354(void) -{ - u32 iVar1; - s32 iVar2; - - iVar2 = gUnk_02002A40.unk50 - gUnk_02002A40.unk490; - if (CheckGlobalFlag(DRUG_1) == 0) { - if (4 < iVar2) { - return 0x8444; - } - } - else { - if (CheckGlobalFlag(DRUG_2) == 0) { - if (iVar2 > 9) { - return 0x8444; - } - } - else { - if (CheckGlobalFlag(DRUG_3) == 0) { - if (iVar2 > 14) { - return 0x8444; - } - } +u32 sub_08060354(void) { + u32 iVar1; + s32 iVar2; + + iVar2 = gUnk_02002A40.unk50 - gUnk_02002A40.unk490; + if (CheckGlobalFlag(DRUG_1) == 0) { + if (4 < iVar2) { + return 0x8444; + } + } else { + if (CheckGlobalFlag(DRUG_2) == 0) { + if (iVar2 > 9) { + return 0x8444; + } + } else { + if (CheckGlobalFlag(DRUG_3) == 0) { + if (iVar2 > 14) { + return 0x8444; + } + } + } } - } - return 0; + 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); +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); } - } - else { - GetNextFrame(this); - } }
\ No newline at end of file diff --git a/src/npc/goron.c b/src/npc/goron.c index 0fa725e4..08ddcc5a 100644 --- a/src/npc/goron.c +++ b/src/npc/goron.c @@ -3,9 +3,10 @@ #include "functions.h" #include "textbox.h" +extern u8 gUnk_02033280[]; extern void (*gUnk_08111A80[])(Entity*); extern void (*gUnk_08111A8C[])(Entity*); -extern u8 gUnk_02033280[]; +extern Dialog gUnk_08111A94[]; void Goron(Entity* this) { if (this->flags & 2) { @@ -72,7 +73,7 @@ void sub_080693D0(Entity* this) { } if (this->frames.all == 2) { this->frames.all = 0; - sub_08069428(this, 0x80<<12, createFx65); + sub_08069428(this, 0x80 << 12, createFx65); } } } @@ -110,16 +111,16 @@ void sub_080694B0(Entity* this) { } } -extern u64 gUnk_08111A94[]; //array of unknown 64 bit structure type void sub_080694D8(Entity* this) { - ShowNPCDialogue(this, (u32*)&gUnk_08111A94[this->entityType.form]); + ShowNPCDialogue(this, &gUnk_08111A94[this->entityType.form]); } void sub_080694EC(Entity* this) { u32 anim; this->animationState = 4; anim = 2; - if (!CheckKinstoneFused(47)) anim = 8; + if (!CheckKinstoneFused(47)) + anim = 8; InitAnimationForceUpdate(this, anim); this->field_0x80.HWORD = anim; } diff --git a/src/npc/mayorHagen.c b/src/npc/mayorHagen.c index 222ec32c..63bc5e7a 100644 --- a/src/npc/mayorHagen.c +++ b/src/npc/mayorHagen.c @@ -7,33 +7,30 @@ #include "textbox.h" #include "npc.h" #include "structures.h" +#include "functions.h" extern void sub_0807DD50(Entity*); extern u32 sub_0806F5A4(u32); extern void sub_0806F118(Entity*); -extern u32 sub_0801E99C(); -extern void sub_08078784(Entity*,u32); -extern void sub_0807DDAC(Entity*,u32); -extern void sub_0805E3A0(Entity*,u32); +extern void sub_08078784(Entity*, u32); +extern void sub_0807DDAC(Entity*, u32); extern void sub_0807DDE4(Entity*); extern void sub_08078850(); extern u32 gUnk_08113F44; -extern u32 gUnk_08113F48; +extern Dialog gUnk_08113F48[]; extern u32 GetInventoryValue(u32); extern u32 CheckLocalFlag(u32); extern void SetLocalFlag(); -extern void ShowNPCDialogue(); -void MayorHagen(Entity *this) -{ +void MayorHagen(Entity* this) { u32 v; switch (this->action) { case 0: - this->action = 1; - this->field_0x68.HALF.HI = 0; - this->field_0x68.HALF.LO = sub_0801E99C(this); - sub_0805E3A0(this, 2); - sub_0807DD50(this); + this->action = 1; + this->field_0x68.HALF.HI = 0; + this->field_0x68.HALF.LO = sub_0801E99C(this); + sub_0805E3A0(this, 2); + sub_0807DD50(this); break; case 1: v = this->interactType; @@ -41,11 +38,11 @@ void MayorHagen(Entity *this) this->action = v; this->interactType = 0; this->field_0x68.HALF.HI = this->animIndex; - InitAnimationForceUpdate(this,4 + sub_0806F5A4(GetFacingDirection(this, &gPlayerEntity))); + InitAnimationForceUpdate(this, 4 + sub_0806F5A4(GetFacingDirection(this, &gPlayerEntity))); sub_0806F118(this); break; } - sub_0807DDAC(this,0); + sub_0807DDAC(this, 0); sub_0807DDE4(this); UpdateAnimationSingleFrame(this); break; @@ -57,49 +54,43 @@ void MayorHagen(Entity *this) } } -void sub_0806CE5C(Entity *this) -{ - sub_08078784(this,sub_0801E99C()); - sub_08078850(this,1,0,&gUnk_08113F44); +void sub_0806CE5C(Entity* this) { + sub_08078784(this, sub_0801E99C(this)); + sub_08078850(this, 1, 0, &gUnk_08113F44); } -void sub_0806CE80(Entity *this) -{ +void sub_0806CE80(Entity* this) { u32 v; u32 v2; v = gUnk_02002A40.unk8; - if (v == 5) { - //flippers - if (GetInventoryValue(0x46) == 0) { - if (CheckLocalFlag(0x70) != 0) { - v2 = CheckLocalFlag(0x71); - if (v2 == 0) { - v = 0xb; - SetLocalFlag(0x71); - } - else { - v = 0xc; - } - } - else { + if (v == 5) { + // flippers + if (GetInventoryValue(0x46) == 0) { + if (CheckLocalFlag(0x70) != 0) { + v2 = CheckLocalFlag(0x71); + if (v2 == 0) { + v = 0xb; + SetLocalFlag(0x71); + } else { + v = 0xc; + } + } else { v = 0xa; } - } - else { - v2 = CheckLocalFlag(0x89); - if (v2 == 0) { - v = 0xd; - SetLocalFlag(0x89); - } - else { - v = 0xe; - } + } else { + v2 = CheckLocalFlag(0x89); + if (v2 == 0) { + v = 0xd; + SetLocalFlag(0x89); + } else { + v = 0xe; + } + } } - } - ShowNPCDialogue(this,&gUnk_08113F48 + 2*v); + ShowNPCDialogue(this, &gUnk_08113F48[v]); } -void MayorHagen_Fusion(Entity *this) { +void MayorHagen_Fusion(Entity* this) { if (this->action == 0) { this->action++; this->spriteSettings.b.draw = 1; diff --git a/src/npc/melari.c b/src/npc/melari.c index a50d4aad..87afe16c 100644 --- a/src/npc/melari.c +++ b/src/npc/melari.c @@ -4,7 +4,6 @@ #include "textbox.h" #include "functions.h" -extern void sub_0806ED78(Entity*); extern void sub_08068780(Entity*); extern void sub_08078778(Entity*); extern u32 Random(void); diff --git a/src/npc/mutoh.c b/src/npc/mutoh.c index b0e95a36..c0f5fda0 100644 --- a/src/npc/mutoh.c +++ b/src/npc/mutoh.c @@ -5,8 +5,8 @@ #include "textbox.h" #include "npc.h" #include "structures.h" +#include "functions.h" -extern void sub_0805E3A0(Entity*, u32); extern void sub_0807DD50(Entity*); extern u32 GetFacingDirection(Entity*, Entity*); extern u32 sub_0806F5A4(u32); @@ -19,10 +19,9 @@ extern void sub_08078784(Entity*, u32); extern SpriteLoadData gUnk_08110C00; extern u16 gUnk_08110C0C[]; -extern u32 gUnk_08110C10[]; +extern Dialog gUnk_08110C10[]; -void Mutoh(Entity* this) -{ +void Mutoh(Entity* this) { if (*(u32*)&this->cutsceneBeh == 0) { DeleteThisEntity(); } @@ -30,11 +29,11 @@ void Mutoh(Entity* this) 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); - } + this->action = 1; + this->spriteSettings.b.draw = TRUE; + sub_0805E3A0(this, 2); + sub_0807DD50(this); + } break; case 1: if (this->interactType == 2) { @@ -53,48 +52,42 @@ void Mutoh(Entity* this) } } -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 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(TABIDACHI); - uVar2 = (-uVar1 | uVar1) >> 0x1f; - } - TextboxNoOverlap(gUnk_08110C0C[uVar2],this); +void sub_080670B4(Entity* this) { + u32 uVar1; + u32 uVar2; + + uVar2 = 0; + if (GetInventoryValue(0x11) == 0) { + uVar1 = CheckGlobalFlag(TABIDACHI); + uVar2 = (-uVar1 | uVar1) >> 0x1f; + } + TextboxNoOverlap(gUnk_08110C0C[uVar2], this); } -void sub_080670E4(Entity *this) -{ - ShowNPCDialogue(this, &gUnk_08110C10[gUnk_02002A40.unk8 * 2]); +void sub_080670E4(Entity* this) { + ShowNPCDialogue(this, &gUnk_08110C10[gUnk_02002A40.unk8]); } -void sub_08067100(Entity *this) -{ - this->field_0x68.HALF.LO = sub_0801E99C(this); - sub_08078784(this, this->field_0x68.HALF.LO); +void sub_08067100(Entity* this) { + this->field_0x68.HALF.LO = sub_0801E99C(this); + sub_08078784(this, this->field_0x68.HALF.LO); } -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); +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); } - } - else { - GetNextFrame(this); - } }
\ No newline at end of file diff --git a/src/npc/postman.c b/src/npc/postman.c index f3d9bd96..f7b6395d 100644 --- a/src/npc/postman.c +++ b/src/npc/postman.c @@ -18,7 +18,6 @@ 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 u32 sub_0801E99C(Entity*); extern void sub_0807DD50(Entity*); @@ -43,7 +42,7 @@ extern Coords16 gUnk_0810A66C[]; extern s8* gUnk_0810A918[]; extern void (*const gUnk_0810AA24[])(Entity*); -extern u32 gUnk_0810AA30[]; +extern Dialog gUnk_0810AA30[]; extern struct_02033280 gUnk_02033280; void Postman(Entity* this) { @@ -205,13 +204,13 @@ void sub_080606C0(Entity *this) void sub_080606D8(Entity* this) { - s32 iVar1; + s32 index; - iVar1 = gUnk_02002A40.unk8 - 2; - if (iVar1 < 0) { - iVar1 = 0; + index = gUnk_02002A40.unk8 - 2; + if (index < 0) { + index = 0; } - ShowNPCDialogue(this, &gUnk_0810AA30[iVar1 * 2]); + ShowNPCDialogue(this, &gUnk_0810AA30[index]); } void sub_08060700(Entity *entity, u32 arg1) diff --git a/src/npc/rem.c b/src/npc/rem.c index b183f687..6d17b95d 100644 --- a/src/npc/rem.c +++ b/src/npc/rem.c @@ -4,7 +4,6 @@ extern void sub_0807DDAC(Entity*, u32); extern void sub_0807DDE4(Entity*); -extern void sub_0806ED78(Entity*); extern void PlaySFX(u32); extern void sub_0806A8C8(Entity*); extern void sub_0807DD94(Entity*, u32); diff --git a/src/npc/smith.c b/src/npc/smith.c index dc222709..171ccad2 100644 --- a/src/npc/smith.c +++ b/src/npc/smith.c @@ -1,30 +1,22 @@ #include "global.h" #include "entity.h" #include "textbox.h" - -typedef struct { - u8 filler[8]; - u8 unk; -} SaveFile; +#include "functions.h" 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); @@ -33,193 +25,170 @@ extern void (*const gUnk_0811036C[])(Entity*); extern u16 gUnk_08110380[]; extern SpriteLoadData gUnk_08110354; -extern SaveFile gUnk_02002A40; -extern u32 gUnk_08110390[]; +extern Dialog 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, &gPlayerEntity)); - InitAnimationForceUpdate(this, iVar2 + iVar4); - sub_0806F118(this); +#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, &gPlayerEntity)); + 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)]); } - 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) { +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) -{ +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.HALF.LO = 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; + this->action = 1; + this->field_0x68.HALF.LO = 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; + } } - else { - --this->field_0xf; - uVar1 = this->animIndex; + if (sub_0806F078(this, uVar1) == 0) { + UpdateAnimationSingleFrame(this); + } + if (this->interactType != 0) { + this->action = 2; + TextboxNoOverlapFollow(0); } - } - if (sub_0806F078(this, uVar1) == 0) { - UpdateAnimationSingleFrame(this); - } - if (this->interactType != 0) { - this->action = 2; - TextboxNoOverlapFollow(0); - } } -void sub_08066170(Entity *this) -{ +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.HALF.LO = sub_0801E99C(this); - sub_0807DD50(this); - } +void sub_08066178(Entity* this) { + if (LoadExtraSpriteData(this, &gUnk_08110354) != 0) { + this->action = 1; + this->spriteSettings.b.draw = 1; + this->field_0x68.HALF.LO = sub_0801E99C(this); + sub_0807DD50(this); + } } -void sub_080661B0(Entity *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.HWORD = GetAnimationState(this) + 8; - InitAnimationForceUpdate(this, this->field_0x80.HWORD); +void sub_080661BC(Entity* this) { + u32 sVar1; + + if (this->animIndex == 0xc) { + UpdateAnimationSingleFrame(this); + if ((this->frames.b.f3) != 0) { + this->field_0x80.HWORD = GetAnimationState(this) + 8; + InitAnimationForceUpdate(this, this->field_0x80.HWORD); + } + } else { + sub_0807DD94(this, 0); } - } - else { - sub_0807DD94(this,0); - } } -void sub_08066200(Entity *this) -{ - sub_0807DDAC(this, 0); - sub_0807DDE4(this); - UpdateAnimationSingleFrame(this); +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_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 sub_0806622C(Entity* this) { + u32 index; + + if (gUnk_02002A40.unk8 - 2 < 0) { + index = 0; + } else { + index = gUnk_02002A40.unk8 - 2; + } + ShowNPCDialogue(this, &gUnk_08110390[index]); } -void nullsub_501(Entity* this) {} +void nullsub_501(Entity* this) { +} -void sub_08066258(void) -{ - PlaySFX(gUnk_081103D0[Random() & 7]); +void sub_08066258(void) { + PlaySFX(gUnk_081103D0[Random() & 7]); } -void sub_08066274(u32 arg0) -{ - sub_08078850(arg0, 1, 0, &gUnk_081103E0); +void sub_08066274(u32 arg0) { + sub_08078850(arg0, 1, 0, &gUnk_081103E0); } -void sub_08066288(Entity *arg0) -{ - sub_08078784(arg0, arg0->field_0x68.HALF.LO); +void sub_08066288(Entity* arg0) { + sub_08078784(arg0, arg0->field_0x68.HALF.LO); } -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); +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); } - } - else { - UpdateAnimationSingleFrame(this); - } }
\ No newline at end of file diff --git a/src/npc/stamp.c b/src/npc/stamp.c index db1d7310..f77b1fdd 100644 --- a/src/npc/stamp.c +++ b/src/npc/stamp.c @@ -1,24 +1,21 @@ #include "global.h" #include "entity.h" #include "textbox.h" +#include "functions.h" extern void sub_08078778(Entity*); extern void sub_0805E47C(Entity*); -extern void sub_0806ED78(Entity*); extern void sub_0805E584(); extern void sub_0807DD64(); 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 u32 gUnk_0810C2E4; - - +extern Dialog gUnk_0810C2E4[2]; void Stamp(Entity* ent) { if ((ent->flags & 2) != 0) { @@ -80,7 +77,7 @@ void sub_08062CBC(Entity* ent) { u32 uVar1; uVar1 = CheckKinstoneFused(44); - ShowNPCDialogue(ent, &gUnk_0810C2E4 + ((-uVar1 | uVar1) >> 31) * 2); + ShowNPCDialogue(ent, &gUnk_0810C2E4[(-uVar1 | uVar1) >> 31]); } void sub_08062CE0(Entity* ent) { diff --git a/src/npc/teachers.c b/src/npc/teachers.c index 53d4a11a..09bab83d 100644 --- a/src/npc/teachers.c +++ b/src/npc/teachers.c @@ -1,27 +1,19 @@ #include "global.h" #include "entity.h" #include "player.h" - -typedef struct { - u8 filler[8]; - u8 unk; -} SaveFile; +#include "functions.h" 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 SaveFile gUnk_02002A40; -extern u16 gUnk_08113930[]; +extern Dialog gUnk_08113930[]; void Teachers(Entity* this) { switch (this->action) { @@ -55,59 +47,52 @@ void Teachers(Entity* this) { } } -void sub_0806C674(Entity *this) -{ - this->field_0x68.HALF.LO = sub_0801E99C(); +void sub_0806C674(Entity* this) { + this->field_0x68.HALF.LO = sub_0801E99C(this); sub_08078784(this, this->field_0x68.HALF.LO); } -void Teachers_Head(Entity *this) -{ - u8 bVar1; - u8 bVar2; - u32 uVar3; - +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); - } + 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 sub_0806C70C(Entity* this) { + int offset; + + offset = gUnk_02002A40.unk8 - 2; + if (offset < 0) + offset = 0; + + ShowNPCDialogue(this, gUnk_08113930 + this->entityType.form * 8 + offset); } -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); +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); } - } - else { - GetNextFrame(this); - } }
\ No newline at end of file diff --git a/src/npc/townMinish.c b/src/npc/townMinish.c index 80d207ef..0ef4098e 100644 --- a/src/npc/townMinish.c +++ b/src/npc/townMinish.c @@ -1,35 +1,49 @@ #include "global.h" #include "entity.h" #include "npc.h" +#include "functions.h" +#include "textbox.h" +#include "flags.h" -extern void InitializeAnimation(Entity *, u32); +extern void InitializeAnimation(Entity*, u32); +extern u32 LoadExtraSpriteData(Entity*, SpriteLoadData*); -extern void sub_0806ED78(Entity *); +extern u32 sub_080002C0(); +extern void sub_0806ACC4(Entity*); +extern void sub_0806AEA8(); +extern void sub_0806AEE4(Entity*); +extern void sub_0806AFE8(Entity*, s32*); +extern s32 sub_0806EDD8(Entity*, u32, u32); +extern u32 sub_0806F5B0(u32); +extern void sub_0806F62C(Entity*, s32, s32); +extern void sub_08078784(Entity*, u32); +extern void sub_08078850(Entity*, u32, u32, u32*); -extern void (*gUnk_081126E8[])(); -extern void sub_0806ACC4(Entity *); - -extern u32 LoadExtraSpriteData(Entity *, SpriteLoadData *); +extern u8 gUnk_081125F4[12]; extern SpriteLoadData gUnk_08112674[]; +extern u32 gUnk_081126D4[4]; +extern u8 gUnk_081126E4[4]; +extern void (*gUnk_081126E8[])(); +extern Dialog gUnk_081126F0[0x10]; +extern void (*gUnk_08112BF0[])(Entity*, s32*); +extern u16 gUnk_08112C40[5]; +extern u16 gUnk_08112C4A[3]; +extern u16 gUnk_08112C50[6]; +extern u16 gUnk_08112C5C[2]; +extern u16 gUnk_08112C60[4]; -void TownMinish(Entity *this) -{ +void TownMinish(Entity* this) { if ((this->flags & 2) == 0) { - (*gUnk_081126E8[this->action])(this); + gUnk_081126E8[this->action](this); sub_0806ED78(this); - } - else { + } else { sub_0806ACC4(this); } } -void sub_0806ABFC(Entity *this) -{ - u8 animationState; - - SpriteLoadData* SpriteLoadData = &gUnk_08112674[this->entityType.form << 2]; - if (!LoadExtraSpriteData(this, SpriteLoadData)) - { +void sub_0806ABFC(Entity* this) { + SpriteLoadData* SpriteLoadData = &gUnk_08112674[this->entityType.form * 4]; + if (!LoadExtraSpriteData(this, SpriteLoadData)) { return; } @@ -38,47 +52,298 @@ void sub_0806ABFC(Entity *this) this->field_0x6a.HALF.LO = this->actionDelay; this->animationState = this->field_0x6a.HALF.LO << 1; - animationState = this->animationState; - this->field_0x68.HALF.HI = animationState << 2; + this->field_0x68.HALF.HI = this->animationState * 4; this->actionDelay = 0; } -// Not matching yet, not 100% sure it's functionally identical -/*void sub_0806AC3C(Entity *this) { - if (this->field_0x58 <= 3) { +void sub_0806AC3C(Entity* this) { + if (this->animIndex <= 3) { s32 unk; - u8 field_0x68; - - Entity *link = &gPlayerEntity; + Entity* link = &gPlayerEntity; if (sub_080041A0(this, link, 0x18, 0x18)) { - unk = GetFacingDirection(this, link) & (u8)0x1e; + unk = GetFacingDirection(this, link) & 0x1e; + } else { + unk = this->animationState * 4; } - else { - unk = this->animationState << 2; - } - - field_0x68.HALF.HI = this->field_0x68.HALF.HI; - if (unk != field_0x68.HALF.HI) { + if (unk != this->field_0x68.HALF.HI) { s32 temp; - if (((unk - field_0x68.HALF.HI) & 0x1f) <= 0xf) { - field_0x68.HALF.HI--; - } - else { - field_0x68.HALF.HI++; + if (((unk - this->field_0x68.HALF.HI) & 0x1f) <= 0xf) { + this->field_0x68.HALF.HI--; + } else { + this->field_0x68.HALF.HI++; } - temp = field_0x68.HALF.HI; - this->field_0x68.HALF.HI = temp & 0x1f; + this->field_0x68.HALF.HI &= 0x1f; } if (!(this->field_0x68.HALF.HI & 7)) { this->animationState = sub_0806F5B0(this->field_0x68.HALF.HI); - UpdateSprite(this, (this->animationState >> 1) ^ 2); + InitializeAnimation(this, (this->animationState / 2) ^ 2); } } - sub_080042B8(this); -}*/ + UpdateAnimationSingleFrame(this); +} + +void sub_0806ACC4(Entity* this) { + u8 delay; + switch (this->action) { + case 0: + if (LoadExtraSpriteData(this, &gUnk_08112674[this->entityType.form * 4]) == 0) + return; + + this->action = 1; + delay = this->actionDelay; + this->field_0x6a.HALF.LO = delay; + this->animationState = delay * 2; + this->actionDelay = 0; + + this->field_0x68.HALF.LO = sub_0801E99C(this); + sub_0807DD50(this); + InitializeAnimation(this, (this->animationState / 2) + 8); + break; + case 1: + if (this->interactType == 2) { + this->action = 3; + this->interactType = 0; + sub_0806F118(this); + } else { + sub_0807DDAC(this, 0); + sub_0806AEA8(this); + if (this->entityType.parameter == 10 && this->interactType) { + this->action = 2; + this->interactType = 0; + InitializeAnimation(this, sub_0806F5A4(GetFacingDirection(this, &gPlayerEntity)) + 8); + sub_0806AFE8(this, *(s32**)&this->cutsceneBeh); + } + if (this->entityType.form == 1) { + u8 idx = gPlayerEntity.animationState >> 1; + sub_08078850(this, 1, gUnk_081126E4[idx], &gUnk_081126D4[idx]); + } + } + break; + case 2: + if (gTextBox.doTextBox & 0x7f) + break; + + this->action = 1; + InitializeAnimation(this, this->animationState / 2 + 4); + break; + case 3: + if (UpdateFuseInteraction(this)) + this->action = 1; + break; + } + + if (this->frameDuration != 0xff) { + GetNextFrame(this); + } +} + +void sub_0806ADFC(Entity* this) { + sub_08078784(this, this->field_0x68.HALF.LO); +} + +void TownMinish_Head(Entity* this) { + u32 frames; + + if ((this->flags & 2) == 0) { + frames = this->field_0x68.HALF.HI / 2; + if ((this->frameSpriteSettings & 1)) { + SetExtraSpriteFrame(this, 0, frames + 0x1c); + } else { + SetExtraSpriteFrame(this, 0, 0xff); + } + SetExtraSpriteFrame(this, 1, this->frameIndex); + SetSpriteSubEntryOffsetData1(this, 1, 0); + sub_0807000C(this); + } else { + frames = this->frames.all; + if (frames != 0xff) { + frames &= ~0x80; + } + if ((this->frameSpriteSettings & 1) == 0) { + frames = 0xff; + } + SetExtraSpriteFrame(this, 0, frames); + SetExtraSpriteFrame(this, 1, this->frameIndex); + SetSpriteSubEntryOffsetData1(this, 1, 0); + sub_0807000C(this); + } +} + +void sub_0806AEA8(Entity* this) { + int old = this->field_0x82.HWORD; + this->field_0x82.HWORD &= ~0x20; + if (old & 0x20) { + sub_08003FC4(this, 0x4000); + } + sub_0807DDE4(this); + this->field_0x82.HWORD = old; +} + +void sub_0806AED8(Entity* this) { + this->actionDelay = 0; + sub_0806AEE4(this); +} + +void sub_0806AEE4(Entity* this) { + int index; + u8* idx3; + u8 tmp1, tmp2; + + if (this->actionDelay) { + this->actionDelay--; + } else { + this->actionDelay = 2; + index = sub_0806EDD8(this, 0x20, 0x20); + if (index < 0) { + int state = this->field_0x6a.HALF.LO; + this->animationState = state * 2; + index = state * 8; + } + + idx3 = gUnk_081125F4 + (this->animationState / 2) * 0x20 + (index >> 1) * 2; + tmp1 = idx3[0]; + tmp2 = idx3[1]; + + if (tmp2 & 0x80) { + this->animationState = sub_0806F5B0(index); + } + tmp2 &= 0x7f; + this->frames.all = tmp1; + this->frameIndex = tmp2; + this->frameSpriteSettings = 1; + this->animIndex = 0; + this->frameDuration = 0xff; + } +} + +void sub_0806AF60(Entity* this, int* idx) { + InitializeAnimation(this, idx[1] + (this->animationState / 2)); +} + +void sub_0806AF70(Entity* this, u32 arg1) { + this->field_0x20 = 0x24000; +} + +void sub_0806AF78(Entity* this, u32 arg1) { + sub_08003FC4(this, 0x1800); + if (0 <= this->height.WORD && this->field_0x20 < 1) { + this->height.WORD = 0; + sub_0806AF70(this, arg1); + } +} + +void sub_0806AFA0(Entity* this) { + if (sub_0806ED78(this)) { + sub_0806F62C(this, -this->nonPlanarMovement, this->direction); + } +} + +void sub_0806AFBC(Entity* this) { + int idx = gUnk_02002A40.unk8 - 2; + if (idx < 0) + idx = 0; + + ShowNPCDialogue(this, gUnk_081126F0 + this->entityType.parameter * 8 + idx); +} + +void sub_0806AFE8(Entity* this, s32* unk) { + unk[5] = 0; + gUnk_08112BF0[this->entityType.parameter](this, unk); +} + +void sub_0806B004(Entity* this, int* unk) { + int idx = 0; + + if (CheckGlobalFlag(0x29)) { + if (CheckLocalFlag(0x73)) { + if (GetInventoryValue(0x46) == 0) { + idx = 3; + if (CheckLocalFlag(0x78) == 0) { + idx = 2; + unk[5] = 1; + SetLocalFlag(0x78); + } + } else { + idx = 4; + } + } else { + idx = 1; + SetLocalFlag(0x6a); + } + } + TextboxNoOverlap(gUnk_08112C40[idx], this); +} + +void sub_0806B064(Entity* this) { + int idx = 0; + + if (CheckGlobalFlag(0x29)) { + idx = 1; + if (CheckLocalFlag(0x73)) { + idx = 2; + } + } + TextboxNoOverlap(gUnk_08112C4A[idx], this); +} + +void sub_0806B098(Entity* this) { + u32 f; + int idx = 2; + + if (GetInventoryValue(0x46) == 0) { + idx = 1; + if (CheckGlobalFlag(0x29)) { + f = CheckGlobalFlag(0x2a); + idx = (-f | f) >> 0x1f; + } + } + TextboxNoOverlap(gUnk_08112C50[(this->entityType.parameter - 7) * 3 + idx], this); +} + +void sub_0806B0E0(Entity* this) { + int idx = 0; + + if (sub_080002C0(0x38, 0xb8, 1) == 0x57 && sub_080002C0(0x48, 0xb8, 1) == 0x57 && + sub_080002C0(0x38, 200, 1) == 0x57 && sub_080002C0(0x48, 200, 1) == 0x57) { + idx = 1; + } + + TextboxNoOverlap(gUnk_08112C5C[idx], this); +} + +void sub_0806B134(Entity* this) { + int idx; + + if (GetInventoryValue(0x45)) { + idx = 2; + if (CheckLocalFlag(0x7b) == 0) { + idx = 1; + SetLocalFlag(0x7b); + } + } else { + idx = 0; + SetGlobalFlag(0x4a); + } + if (5 < gUnk_02002A40.unk8) { + idx = 3; + } + TextboxNoOverlap(gUnk_08112C60[idx], this); +} + +void TownMinish_Fusion(Entity* this) { + if (this->action == 0) { + if (LoadExtraSpriteData(this, &gUnk_08112674[this->entityType.form * 4])) { + this->action++; + this->spriteSettings.b.draw = 1; + InitializeAnimation(this, 6); + } + } else { + GetNextFrame(this); + } +} diff --git a/src/npc/townsperson.c b/src/npc/townsperson.c index 7fe6e64a..436dc186 100644 --- a/src/npc/townsperson.c +++ b/src/npc/townsperson.c @@ -5,6 +5,7 @@ #include "textbox.h" #include "flags.h" #include "structures.h" +#include "functions.h" typedef struct { u8 frame1; @@ -21,8 +22,6 @@ typedef struct { 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*); @@ -36,7 +35,6 @@ 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*); @@ -50,7 +48,7 @@ extern u8 gUnk_0810B748[]; extern u32 gUnk_0810B740[]; extern u16 gUnk_0810B790[]; extern u16 gUnk_0810B7BA[]; -extern u32 gUnk_0810B7C0[]; +extern Dialog gUnk_0810B7C0[]; void Townsperson(Entity* this) { if ((this->flags & 2) != 0) { @@ -296,30 +294,27 @@ void sub_0806200C(Entity* this) { TextboxNoOverlap(gUnk_0810B7BA[index], this); } -void sub_08062048(Entity *this) -{ - int iVar1; - - if ((this->entityType).subtype == 6) { - iVar1 = gUnk_02002A40.unk8 - 2; - if (iVar1 < 0) { - iVar1 = 0; +void sub_08062048(Entity* this) { + int iVar1; + + if ((this->entityType).subtype == 6) { + iVar1 = gUnk_02002A40.unk8 - 2; + if (iVar1 < 0) { + iVar1 = 0; + } + ShowNPCDialogue(this, gUnk_0810B7C0 + this->entityType.form * 0x8 + iVar1); + } else { + TextboxNoOverlap(0, this); } - 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; +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; } - this->action++; - this->spriteSettings.b.draw = TRUE; - } - sub_08061CB4(this, 6); + sub_08061CB4(this, 6); }
\ No newline at end of file diff --git a/src/npc/windTribespeople.c b/src/npc/windTribespeople.c index 620483b3..4f8b4d97 100644 --- a/src/npc/windTribespeople.c +++ b/src/npc/windTribespeople.c @@ -4,6 +4,7 @@ #include "textbox.h" #include "flags.h" #include "structures.h" +#include "functions.h" extern u32 LoadExtraSpriteData(Entity*, SpriteLoadData*); extern void sub_0807DD50(Entity*); @@ -23,7 +24,7 @@ extern void (*const gUnk_08113A8C[])(Entity*, Entity*); extern SpriteLoadData gUnk_08113A1C[]; extern u32 gUnk_08014A80; -extern u32 gUnk_08113ABC[]; +extern Dialog gUnk_08113ABC[]; extern u16 gUnk_08113B0C[]; void WindTribespeople(Entity* this) { @@ -74,73 +75,65 @@ void sub_0806C85C(Entity* this) { } } -void sub_0806C870(Entity *this) -{ - u8 bVar1; - - bVar1 = sub_0801E99C(); - this->field_0x68.HALF.LO = bVar1; - sub_08078784(this, this->field_0x68.HALF.LO); +void sub_0806C870(Entity* this) { + u8 bVar1; + + bVar1 = sub_0801E99C(this); + this->field_0x68.HALF.LO = bVar1; + sub_08078784(this, this->field_0x68.HALF.LO); } -void WindTribespeople_Head(Entity *this) -{ - u32 uVar1; - u32 uVar2; - u8 pbVar3; - - pbVar3 = (this->frames.all & 0x3F); - if (this->entityType.form == 4) { - SetExtraSpriteFrame(this, 0, 9); - SetExtraSpriteFrame(this, 1, pbVar3); - SetExtraSpriteFrame(this, 2, this->frameIndex); - SetSpriteSubEntryOffsetData2(this, 2, 0); - SetSpriteSubEntryOffsetData1(this, 2, 1); - sub_0807000C(this); - } - else { - if (this->frames.b.f2 != 0) { - uVar2 = 1; - uVar1 = 0; - } - else { - uVar2 = 0; - uVar1 = 1; +void WindTribespeople_Head(Entity* this) { + u32 uVar1; + u32 uVar2; + u8 pbVar3; + + pbVar3 = (this->frames.all & 0x3F); + if (this->entityType.form == 4) { + SetExtraSpriteFrame(this, 0, 9); + SetExtraSpriteFrame(this, 1, pbVar3); + SetExtraSpriteFrame(this, 2, this->frameIndex); + SetSpriteSubEntryOffsetData2(this, 2, 0); + SetSpriteSubEntryOffsetData1(this, 2, 1); + sub_0807000C(this); + } else { + if (this->frames.b.f2 != 0) { + uVar2 = 1; + uVar1 = 0; + } else { + uVar2 = 0; + uVar1 = 1; + } + SetExtraSpriteFrame(this, uVar2, pbVar3); + SetExtraSpriteFrame(this, uVar1, this->frameIndex); + SetSpriteSubEntryOffsetData1(this, uVar1, uVar2); + sub_0807000C(this); } - SetExtraSpriteFrame(this, uVar2, pbVar3); - SetExtraSpriteFrame(this, uVar1, this->frameIndex); - SetSpriteSubEntryOffsetData1(this, uVar1, uVar2); - sub_0807000C(this); - } } -//body and head entities? -void sub_0806C90C(Entity *param_1,Entity *param_2) -{ - *(u32 *)¶m_2->animationState = 0; - gUnk_08113A8C[param_1->entityType.parameter](param_1, param_2); +// body and head entities? +void sub_0806C90C(Entity* param_1, Entity* param_2) { + *(u32*)¶m_2->animationState = 0; + gUnk_08113A8C[param_1->entityType.parameter](param_1, param_2); } -void sub_0806C928(Entity *this) -{ - ShowNPCDialogue(this, &gUnk_08113ABC[gUnk_02002A40.unk8 * 2]); +void sub_0806C928(Entity* this) { + ShowNPCDialogue(this, &gUnk_08113ABC[gUnk_02002A40.unk8]); } -void sub_0806C944(Entity *this) -{ - int iVar1; - int iVar2; - - iVar1 = CheckGlobalFlag(WARP_EVENT_END); - if (iVar1 == 0) { - iVar2 = 0; - } - else { - iVar1 = CheckLocalFlag(0x63); - iVar2 = 2; - if (iVar1 != 0) { - iVar2 = 1; +void sub_0806C944(Entity* this) { + int iVar1; + int iVar2; + + iVar1 = CheckGlobalFlag(WARP_EVENT_END); + if (iVar1 == 0) { + iVar2 = 0; + } else { + iVar1 = CheckLocalFlag(0x63); + iVar2 = 2; + if (iVar1 != 0) { + iVar2 = 1; + } } - } - TextboxNoOverlap(gUnk_08113B0C[iVar2], this); + TextboxNoOverlap(gUnk_08113B0C[iVar2], this); }
\ No newline at end of file |
