diff options
| author | notyouraveragehooman <65437533+notyouraveragehooman@users.noreply.github.com> | 2020-06-13 14:51:06 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-13 14:51:06 -0700 |
| commit | f4d8c90e9d06c6969a67bf97dadfceb2ce65fa68 (patch) | |
| tree | ed52c8201df2bcede89fbf32c2369b26d10433e6 /src | |
| parent | a3be2626358e15dc89a31027113e8995fbf7eade (diff) | |
| parent | 23dfe5affad47ee0ca27c1210e37fb8fe0cfc748 (diff) | |
Merge pull request #6 from gamestabled/zelda
zelda OK
Diffstat (limited to 'src')
| -rw-r--r-- | src/zelda.c | 237 |
1 files changed, 237 insertions, 0 deletions
diff --git a/src/zelda.c b/src/zelda.c new file mode 100644 index 00000000..4400351d --- /dev/null +++ b/src/zelda.c @@ -0,0 +1,237 @@ +#include "global.h" +#include "entity.h" +#include "room.h" + +extern void sub_0805EA78(Entity*, u32); +extern void sub_0805E3A0(Entity*, u32); +extern void sub_0807DD50(Entity*); +extern void sub_0807DD94(Entity*, u32); +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 parameter1,u32 parameter2); +u32 sub_0806EDC4(Entity* ent); +void DeleteThisEntity(void); +extern Entity* GetEntityByType(u32, u32); +extern void sub_080686C4(Entity*, Entity*); +extern void LoadAnimation(Entity*, u32); +extern void sub_080042B8(Entity*); +extern void sub_0806F62C(Entity*, u32, u32); +extern u32 sub_08003FC4(Entity*, u32); +extern void PlaySFX(u32); +extern void SetTileType(u32, u32, u32); +extern void sub_0807BA8C(u16, u32); + +extern Entity gLinkEntity; +extern RoomControls gRoomControls; + +extern void (*gUnk_08110BD8[])(Entity* ent); +extern u8 gUnk_02033280[]; +extern u16 gUnk_08110BE0[]; + + +void sub_08066CB4(Entity* ent) +{ + gUnk_08110BD8[ent->action](ent); +} + +void sub_08066CCC(Entity *ent) +{ + ent->action = 1; + ent->spriteSettings.b.ss0 = 1; + sub_0805EA78(ent, 7); + sub_0805E3A0(ent, 2); + sub_0807DD50(ent); +} + +void sub_08066CF8(Entity* ent) +{ + sub_0807DD94(ent, 0); +} + +void sub_08066D04(Entity* ent) +{ + ent->parent = sub_0805EB9C(7, 0x2E); +} + +void sub_08066D14(Entity* ent, u32* param_2) +{ + Entity* parent; + + parent = ent->parent; + if (parent != NULL) + { + ent->animationState = parent->animationState; + ent->spriteSettings.b.ss0 = 1; + CopyPosition(parent, ent); + sub_08068680(ent, ent->parent); + param_2[5] = 1; + } + else + { + param_2[5] = 0; + } +} + +void sub_08066D4C(Entity* ent, u32* param_2) +{ + Entity* parent; + + parent = ent->parent; + if (ent->parent != NULL) + { + CopyPosition(ent, parent); + ent->parent->spriteSettings.b.ss0 = 1; + ent->parent->animationState = ent->animationState; + ent->spriteSettings.b.ss0 = 0; + ent->field_0x17 &= 0xFE; + sub_08068694(ent, ent->parent); + param_2[5] = 1; + } + else + { + param_2[5] = 0; + } +} + +void sub_08066D94(Entity* ent) +{ + u32 roomID; + Entity* npc; + + SetGlobalFlag(0x1C); + npc = CreateNPC(0x2E, 0, 0); + if (npc != NULL) + { + npc->animationState = gLinkEntity.animationState; + npc->flags |= 0x20; + npc->animationState = sub_0806EDC4(ent); + roomID = gRoomControls.roomID; + *(u16*)&npc->heldObjectPtr = roomID; + CopyPosition(ent, npc); + } + DeleteThisEntity(); +} + +void sub_08066DE4(Entity* ent) +{ + Entity* pEVar1; + + pEVar1 = sub_0805EB9C(7, 0x2E); + if (pEVar1 != NULL) + { + CopyPosition(ent, pEVar1); + sub_080686C4(ent, pEVar1); + } +} + +void sub_08066E08(Entity* ent) +{ + LoadAnimation(ent, 0x50); + ent->field_0x80 = ent->field_0x58; +} + +void sub_08066E20(Entity* ent) +{ + LoadAnimation(ent, 0x44); + ent->field_0x80 = ent->field_0x58; +} + +void sub_08066E38(Entity* ent) +{ + LoadAnimation(ent, 0x48); + ent->field_0x80 = ent->field_0x58; +} + +void sub_08066E50(Entity* ent) +{ + LoadAnimation(ent, 0x4C); + ent->field_0x80 = ent->field_0x58; +} + +void sub_08066E68(Entity* ent) +{ + LoadAnimation(ent, 0x54); + ent->field_0x80 = ent->field_0x58; +} + +void sub_08066E80(Entity* ent, u8* param_2) +{ + switch(param_2[0x18]) + { + case 0: + param_2[0x18]++; + LoadAnimation(ent, 0x16); + break; + case 1: + sub_080042B8(ent); + if (ent->frames.all & 1) + { + param_2[0x18]++; + ent->field_0x20 = 0x20000; + ent->frames.all &= 0xFE; + PlaySFX(0x7C); + } + break; + case 2: + sub_0806F62C(ent, 0x100, 0x80); + sub_08003FC4(ent, 0x2000); + if (!(ent->frames.all & 1)) + { + sub_080042B8(ent); + } + if (ent->field_0x20 < 0) + { + param_2[0x18]++; + } + break; + case 3: + sub_0806F62C(ent, 0x100, 0x80); + sub_080042B8(ent); + if (sub_08003FC4(ent, 0x2000) == 0) + { + param_2[0x18]++; + LoadAnimation(ent, 0x1E); + } + break; + case 4: + sub_080042B8(ent); + if (ent->frames.b.f3) + { + gUnk_02033280[7] |= 1; + return; + } + } + ent->field_0x80 = ent->field_0x58; + gUnk_02033280[6] = 0; +} + +void sub_08066F94(void) +{ + u16 uVar1; + u16* puVar2; + + puVar2 = gUnk_08110BE0; + while (*puVar2 != 0) + { + uVar1 = *puVar2; + puVar2++; + SetTileType(16498, uVar1, 1); + } +} + +void sub_08066FB8(void) +{ + u16 uVar1; + u16* puVar2; + + puVar2 = gUnk_08110BE0; + while (*puVar2 != 0) + { + uVar1 = *puVar2; + puVar2++; + sub_0807BA8C(uVar1, 1); + } +} |
