summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authornotyourav <65437533+notyourav@users.noreply.github.com>2021-02-19 01:58:05 -0800
committerGitHub <noreply@github.com>2021-02-19 01:58:05 -0800
commitab3e488126c735c3aefdedf15bcae3774202cc05 (patch)
treea6f776f144c60f78da4f720505c29d6a9334382b /src
parentba330e4875384f12e26b50c4bb9fe0d70e66f15d (diff)
parentfaa6fddc10b6021d31c1a0e793d0d4fa380f9f0d (diff)
Merge pull request #119 from Henny022p/master
Decompiled code_0807CC3C
Diffstat (limited to 'src')
-rw-r--r--src/code_0807CC3C.c19
-rw-r--r--src/manager/manager15.c4
-rw-r--r--src/manager/manager7.c6
-rw-r--r--src/npc/beedle.c3
-rw-r--r--src/npc/bigGoron.c4
-rw-r--r--src/npc/bladeBrothers.c3
-rw-r--r--src/npc/festari.c4
-rw-r--r--src/npc/forestMinish.c6
-rw-r--r--src/npc/goron.c3
-rw-r--r--src/npc/goronMerchant.c3
-rw-r--r--src/npc/librari.c3
-rw-r--r--src/npc/malon.c3
-rw-r--r--src/npc/mayorHagen.c4
-rw-r--r--src/npc/melari.c4
-rw-r--r--src/npc/mutoh.c4
-rw-r--r--src/npc/percy.c3
-rw-r--r--src/npc/postman.c9
-rw-r--r--src/npc/rem.c11
-rw-r--r--src/npc/simon.c3
-rw-r--r--src/npc/smith.c9
-rw-r--r--src/npc/stamp.c4
-rw-r--r--src/npc/talon.c7
-rw-r--r--src/npc/teachers.c4
-rw-r--r--src/npc/townMinish.c3
-rw-r--r--src/npc/townsperson.c4
-rw-r--r--src/npc/windTribespeople.c4
-rw-r--r--src/npc/zelda.c4
-rw-r--r--src/object/cloud.c4
-rw-r--r--src/object/houseDoorExterior.c7
-rw-r--r--src/object/windcrest.c4
-rw-r--r--src/save.c213
-rw-r--r--src/script.c (renamed from src/executeScriptCommandSet.c)311
32 files changed, 611 insertions, 66 deletions
diff --git a/src/code_0807CC3C.c b/src/code_0807CC3C.c
new file mode 100644
index 00000000..4df3598d
--- /dev/null
+++ b/src/code_0807CC3C.c
@@ -0,0 +1,19 @@
+#include "global.h"
+#include "structures.h"
+#include "functions.h"
+#include "script.h"
+#include "entity.h"
+#include "save.h"
+
+// these three functions use gRoomControls, maybe once that is understood better, these can be decompiled easier
+NONMATCH("asm/non_matching/code_0807CC3C/sub_0807D280.inc", void sub_0807D280(u32 unk_1, u32 unk_2)) {
+}
+END_NONMATCH
+
+NONMATCH("asm/non_matching/code_0807CC3C/sub_0807D46C.inc", void sub_0807D46C(u32 unk_1, u32 unk_2)) {
+}
+END_NONMATCH
+
+NONMATCH("asm/non_matching/code_0807CC3C/sub_0807D6D8.inc", void sub_0807D6D8(u32 unk_1, u32 unk_2)) {
+}
+END_NONMATCH
diff --git a/src/manager/manager15.c b/src/manager/manager15.c
index 23abd03e..44b38fb4 100644
--- a/src/manager/manager15.c
+++ b/src/manager/manager15.c
@@ -3,6 +3,7 @@
#include "screen.h"
#include "manager.h"
#include "functions.h"
+#include "structures.h"
typedef struct {
Manager manager;
@@ -293,7 +294,6 @@ void sub_0805A758(Manager15* this) {
}
}
-extern u8 gUnk_02034490;
extern void sub_0805E4E0(Manager*, u32);
extern void sub_08077B20(void);
@@ -308,7 +308,7 @@ void sub_0805A76C(Manager15* this) {
gPlayerEntity.animationState = 4;
sub_0805E4E0(&this->manager, 0x258);
sub_08078A90(0xFF);
- gUnk_02034490 = 1;
+ gUnk_02034490[0] = 1;
gRoomControls.cameraTarget = 0;
sub_08077B20();
}
diff --git a/src/manager/manager7.c b/src/manager/manager7.c
index 55e88f7d..6a0fe97d 100644
--- a/src/manager/manager7.c
+++ b/src/manager/manager7.c
@@ -1,6 +1,7 @@
#include "global.h"
#include "manager.h"
#include "functions.h"
+#include "structures.h"
#include "gba/gba.h"
typedef struct {
@@ -18,7 +19,6 @@ extern void sub_08052D74();
extern u32 sub_08056300(const u16*);
extern void sub_0805E3A0();
-extern u8 gUnk_02034490;
extern const u8 gGlobalGfxAndPalettes[];
const u16 gUnk_08108050[0x2A] = { 0, 0, 0x20, 0xE0, 0xE0, 1, 0, 0x1D0, 0x80, 0x60, 2,
@@ -63,7 +63,7 @@ void Manager7_Main(Manager7* this) {
tmp2 = &gUnk_081080A4[tmp << 4];
switch (this->manager.unk_0e) {
case 0:
- gUnk_02034490 = 1;
+ gUnk_02034490[0] = 1;
LoadAssetAsync(&gGlobalGfxAndPalettes[tmp2[0]], tmp2[1], 0x1000);
LoadPaletteGroup(gUnk_081081E4[tmp]);
this->manager.unk_0e++;
@@ -80,7 +80,7 @@ void Manager7_Main(Manager7* this) {
this->manager.unk_0e++;
break;
case 8:
- gUnk_02034490 = 0;
+ gUnk_02034490[0] = 0;
this->manager.unk_0e++;
break;
}
diff --git a/src/npc/beedle.c b/src/npc/beedle.c
index 6e6a525a..98297254 100644
--- a/src/npc/beedle.c
+++ b/src/npc/beedle.c
@@ -4,6 +4,7 @@
#include "textbox.h"
#include "player.h"
#include "room.h"
+#include "script.h"
typedef struct {
u32 unk_00;
@@ -108,7 +109,7 @@ void sub_08063410(Entity* this) {
if (this->entityType.form != 0) {
sub_0806346C(this);
}
- sub_0807DDAC(this, 0);
+ sub_0807DDAC(this, NULL);
sub_0807DDE4(this);
GetNextFrame(this);
}
diff --git a/src/npc/bigGoron.c b/src/npc/bigGoron.c
index bb28c9f0..4b45fe41 100644
--- a/src/npc/bigGoron.c
+++ b/src/npc/bigGoron.c
@@ -3,13 +3,13 @@
#include "player.h"
#include "structures.h"
#include "functions.h"
+#include "script.h"
extern void (*gUnk_081140D4[])(Entity*);
extern u16 gUnk_081140CC[];
extern void sub_0806D0B0(Entity*);
extern void sub_0807DD64(Entity*);
-extern void sub_0807DDAC(Entity*, u32);
extern void sub_0807DDE4(Entity*);
extern void PlaySFX(u32);
extern void sub_0806D02C(Entity*);
@@ -28,7 +28,7 @@ void sub_0806CF30(Entity* this) {
sub_0806D0B0(this);
sub_0807DD64(this);
} else {
- sub_0807DDAC(this, 0);
+ sub_0807DDAC(this, NULL);
sub_0807DDE4(this);
}
diff --git a/src/npc/bladeBrothers.c b/src/npc/bladeBrothers.c
index f19d4990..8211ed49 100644
--- a/src/npc/bladeBrothers.c
+++ b/src/npc/bladeBrothers.c
@@ -6,6 +6,7 @@
#include "room.h"
#include "textbox.h"
#include "save.h"
+#include "script.h"
extern void (*gUnk_081115C0[])(Entity*);
extern void (*gUnk_081115D0[])(Entity*);
@@ -126,7 +127,7 @@ void FUN_08068b2c(Entity* this) {
InitAnimationForceUpdate(this, uVar1);
sub_0806F118(this);
} else {
- sub_0807DD94(this, 0);
+ sub_0807DD94(this, NULL);
}
}
diff --git a/src/npc/festari.c b/src/npc/festari.c
index 67637ec3..fa1dac19 100644
--- a/src/npc/festari.c
+++ b/src/npc/festari.c
@@ -3,12 +3,12 @@
#include "functions.h"
#include "npc.h"
#include "player.h"
+#include "script.h"
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 (*const gUnk_08109BBC[])(Entity*);
@@ -38,7 +38,7 @@ void sub_0805FE48(Entity* this) {
InitAnimationForceUpdate(this, sub_0806F5A4(GetFacingDirection(this, &gPlayerEntity)));
sub_0806F118(this);
} else {
- ExecuteScriptCommandSet(this, *(void**)&this->cutsceneBeh);
+ ExecuteScriptCommandSet(this, *(ScriptExecutionContext **)&this->cutsceneBeh);
sub_0805FF2C(this, *(void**)&this->cutsceneBeh);
uVar4 = this->field_0x80.HWORD;
if (uVar4 < 8) {
diff --git a/src/npc/forestMinish.c b/src/npc/forestMinish.c
index f127acf4..66933ef3 100644
--- a/src/npc/forestMinish.c
+++ b/src/npc/forestMinish.c
@@ -7,10 +7,10 @@
#include "structures.h"
#include "functions.h"
#include "save.h"
+#include "script.h"
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 s32 sub_0806EDD8(Entity*, u32, u32);
@@ -41,7 +41,7 @@ void ForestMinish(Entity* this) {
this->field_0x68.HALF.HI = this->animationState = this->actionDelay << 1;
this->actionDelay = 0;
sub_0805E3A0(this, 2);
- StartCutscene(this, gUnk_08109D18[this->entityType.parameter]);
+ StartCutscene(this, (u16*)gUnk_08109D18[this->entityType.parameter]);
sub_0807DD50(this);
}
break;
@@ -51,7 +51,7 @@ void ForestMinish(Entity* this) {
this->interactType = 0;
sub_0806F118(this);
} else {
- sub_0807DDAC(this, 0);
+ sub_0807DDAC(this, NULL);
sub_0807DDE4(this);
if (this->frameDuration != 0xf0) {
sub_080600F0(this);
diff --git a/src/npc/goron.c b/src/npc/goron.c
index dcc0ac33..a7d4ee54 100644
--- a/src/npc/goron.c
+++ b/src/npc/goron.c
@@ -2,6 +2,7 @@
#include "entity.h"
#include "functions.h"
#include "textbox.h"
+#include "script.h"
extern void (*gUnk_08111A80[])(Entity*);
extern void (*gUnk_08111A8C[])(Entity*);
@@ -61,7 +62,7 @@ void sub_080693C4(Entity* this) {
void sub_08069428(Entity* this, s32 offsetX, bool32 createFx65);
void sub_080693D0(Entity* this) {
- sub_0807DD94(this, 0);
+ sub_0807DD94(this, NULL);
if (this->animIndex == 8) {
u32 var0 = this->field_0x82.HWORD & 0xF;
bool32 createFx65 = BOOLCAST(var0); // = !var0
diff --git a/src/npc/goronMerchant.c b/src/npc/goronMerchant.c
index 7cfdb685..9fd402c5 100644
--- a/src/npc/goronMerchant.c
+++ b/src/npc/goronMerchant.c
@@ -5,6 +5,7 @@
#include "textbox.h"
#include "room.h"
#include "flags.h"
+#include "script.h"
extern u32 sub_080696BC(Entity*);
@@ -70,7 +71,7 @@ void sub_0806963C(Entity* this) {
}
void sub_08069654(Entity* this) {
- sub_0807DD94(this, 0);
+ sub_0807DD94(this, NULL);
}
void sub_08069660(Entity* this) {
diff --git a/src/npc/librari.c b/src/npc/librari.c
index 27b20ad8..9db202b7 100644
--- a/src/npc/librari.c
+++ b/src/npc/librari.c
@@ -4,6 +4,7 @@
#include "flags.h"
#include "textbox.h"
#include "functions.h"
+#include "script.h"
extern u16 gUnk_08112D48[];
@@ -24,7 +25,7 @@ void Librari(Entity* this) {
this->interactType = 0;
sub_0806F118(this);
} else {
- sub_0807DDAC(this, 0);
+ sub_0807DDAC(this, NULL);
sub_0807DDE4(this);
UpdateAnimationSingleFrame(this);
}
diff --git a/src/npc/malon.c b/src/npc/malon.c
index 340e9cf7..ca6d6eab 100644
--- a/src/npc/malon.c
+++ b/src/npc/malon.c
@@ -1,6 +1,7 @@
#include "global.h"
#include "functions.h"
#include "entity.h"
+#include "script.h"
extern Entity gPlayerEntity;
@@ -44,7 +45,7 @@ void sub_080658BC(Entity* this) {
InitAnimationForceUpdate(this, sub_0806F5A4(GetFacingDirection(this, &gPlayerEntity)));
sub_0806F118(this);
} else {
- sub_0807DD94(this, 0);
+ sub_0807DD94(this, NULL);
}
}
diff --git a/src/npc/mayorHagen.c b/src/npc/mayorHagen.c
index ffa5b0c6..df7366dd 100644
--- a/src/npc/mayorHagen.c
+++ b/src/npc/mayorHagen.c
@@ -9,12 +9,12 @@
#include "structures.h"
#include "functions.h"
#include "save.h"
+#include "script.h"
extern void sub_0807DD50(Entity*);
extern u32 sub_0806F5A4(u32);
extern void sub_0806F118(Entity*);
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;
@@ -43,7 +43,7 @@ void MayorHagen(Entity* this) {
sub_0806F118(this);
break;
}
- sub_0807DDAC(this, 0);
+ sub_0807DDAC(this, NULL);
sub_0807DDE4(this);
UpdateAnimationSingleFrame(this);
break;
diff --git a/src/npc/melari.c b/src/npc/melari.c
index ed324001..b5101e02 100644
--- a/src/npc/melari.c
+++ b/src/npc/melari.c
@@ -3,12 +3,12 @@
#include "npc.h"
#include "textbox.h"
#include "functions.h"
+#include "script.h"
extern void sub_08068780(Entity*);
extern void sub_08078778(Entity*);
extern void sub_0807DD50(Entity*);
extern void sub_0806F118(Entity*);
-extern void sub_0807DDAC(Entity*, u32);
extern void sub_0807DDE4(Entity*);
extern u32 sub_080040A8(Entity*);
extern void EnqueueSFX(u32);
@@ -82,7 +82,7 @@ void sub_08068780(Entity* this) {
this->interactType = 0;
sub_0806F118(this);
} else {
- sub_0807DDAC(this, 0);
+ sub_0807DDAC(this, NULL);
sub_0807DDE4(this);
GetNextFrame(this);
}
diff --git a/src/npc/mutoh.c b/src/npc/mutoh.c
index c3084796..998a54a6 100644
--- a/src/npc/mutoh.c
+++ b/src/npc/mutoh.c
@@ -7,12 +7,12 @@
#include "structures.h"
#include "functions.h"
#include "save.h"
+#include "script.h"
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*);
@@ -43,7 +43,7 @@ void Mutoh(Entity* this) {
InitAnimationForceUpdate(this, sub_0806F5A4(GetFacingDirection(this, &gPlayerEntity)) + 4);
sub_0806F118(this);
} else {
- sub_0807DD94(this, 0);
+ sub_0807DD94(this, NULL);
}
break;
case 2:
diff --git a/src/npc/percy.c b/src/npc/percy.c
index 47a9fa43..484ee13b 100644
--- a/src/npc/percy.c
+++ b/src/npc/percy.c
@@ -4,6 +4,7 @@
#include "textbox.h"
#include "functions.h"
#include "flags.h"
+#include "script.h"
extern void sub_0806B41C(Entity*);
extern void sub_0806B3CC(Entity*);
@@ -77,7 +78,7 @@ void sub_0806B41C(Entity* this) {
sub_0801DFB4(this, tmp[0], tmp[1], tmp[2]);
gPlayerState.field_0x8b = 3;
} else {
- sub_0807DD94(this, 0);
+ sub_0807DD94(this, NULL);
}
break;
case 2:
diff --git a/src/npc/postman.c b/src/npc/postman.c
index 836bb5d5..266c3fb6 100644
--- a/src/npc/postman.c
+++ b/src/npc/postman.c
@@ -7,6 +7,7 @@
#include "room.h"
#include "structures.h"
#include "save.h"
+#include "script.h"
extern void sub_08060528(Entity*);
extern void* GetCurrentRoomProperty(u32);
@@ -21,13 +22,11 @@ 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 EnqueueSFX(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);
typedef struct {
s16 x;
@@ -145,7 +144,7 @@ void sub_08060528(Entity* this) {
sub_080606D8(this);
InitAnimationForceUpdate(this, sub_0806F5A4(GetFacingDirection(this, &gPlayerEntity)));
} else {
- sub_0807DD94(this, 0);
+ sub_0807DD94(this, NULL);
}
}
break;
@@ -202,12 +201,12 @@ void sub_080606D8(Entity* this) {
ShowNPCDialogue(this, &gUnk_0810AA30[index]);
}
-void sub_08060700(Entity* entity, u32 arg1) {
+void sub_08060700(Entity* entity, ScriptExecutionContext* context) {
s8* var0 = gUnk_0810A918[(s8)entity->field_0x68.HALF.LO];
Coords16* coords = &gUnk_0810A66C[var0[(s8)entity->field_0x68.HALF.HI]];
u32 x = coords->x + gRoomControls.roomOriginX;
u32 y = coords->y + gRoomControls.roomOriginY;
- sub_0807DEDC(entity, arg1, x, y);
+ sub_0807DEDC(entity, context, x, y);
gUnk_02033280.unk_07 |= 1;
}
diff --git a/src/npc/rem.c b/src/npc/rem.c
index 415f7ffa..f81929ad 100644
--- a/src/npc/rem.c
+++ b/src/npc/rem.c
@@ -1,12 +1,11 @@
#include "global.h"
#include "functions.h"
#include "entity.h"
+#include "script.h"
-extern void sub_0807DDAC(Entity*, u32);
extern void sub_0807DDE4(Entity*);
extern void PlaySFX(u32);
extern void sub_0806A8C8(Entity*);
-extern void sub_0807DD94(Entity*, u32);
extern void (*gUnk_08112260[])(Entity*);
extern void (*gUnk_08112278[])(Entity*);
@@ -21,7 +20,7 @@ void sub_0806a370(Entity* this) {
u8* pbVar1;
gUnk_08112278[this->action](this);
- sub_0807DDAC(this, 0);
+ sub_0807DDAC(this, NULL);
sub_0807DDE4(this);
UpdateAnimationSingleFrame(this);
sub_0806ED78(this);
@@ -39,13 +38,13 @@ void sub_0806a370(Entity* this) {
}
void sub_0806A3D8(Entity* this) {
- u32* uVar1;
+ ScriptExecutionContext* uVar1;
this->action = 1;
this->actionDelay = 0xb4;
sub_0805E3A0(this, 2);
sub_0806A8C8(this);
uVar1 = StartCutscene(this, &gUnk_08012F0C);
- *(u32*)&this->cutsceneBeh = (u32)uVar1;
- sub_0807DD94(this, 0);
+ *(ScriptExecutionContext**)&this->cutsceneBeh = uVar1;
+ sub_0807DD94(this, NULL);
}
diff --git a/src/npc/simon.c b/src/npc/simon.c
index 7c4b7f48..ecc57f36 100644
--- a/src/npc/simon.c
+++ b/src/npc/simon.c
@@ -3,6 +3,7 @@
#include "functions.h"
#include "room.h"
#include "flags.h"
+#include "script.h"
typedef struct {
u8 filler[4];
@@ -22,7 +23,7 @@ void Simon(Entity* this) {
this->action++;
sub_0807DD50(this);
} else {
- sub_0807DD94(this, 0);
+ sub_0807DD94(this, NULL);
}
}
diff --git a/src/npc/smith.c b/src/npc/smith.c
index 430b12af..d06cedfe 100644
--- a/src/npc/smith.c
+++ b/src/npc/smith.c
@@ -3,6 +3,7 @@
#include "textbox.h"
#include "functions.h"
#include "save.h"
+#include "script.h"
extern u32 GetFacingDirection(Entity*, Entity*);
extern u32 sub_0806F5A4(u32);
@@ -12,8 +13,6 @@ extern void PlaySFX(u32);
extern void sub_0807000C(Entity*);
extern u32 sub_0801E99C(Entity*);
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*);
@@ -118,7 +117,7 @@ void sub_08066178(Entity* this) {
}
void sub_080661B0(Entity* this) {
- sub_0807DD94(this, 0);
+ sub_0807DD94(this, NULL);
}
void sub_080661BC(Entity* this) {
@@ -131,12 +130,12 @@ void sub_080661BC(Entity* this) {
InitAnimationForceUpdate(this, this->field_0x80.HWORD);
}
} else {
- sub_0807DD94(this, 0);
+ sub_0807DD94(this, NULL);
}
}
void sub_08066200(Entity* this) {
- sub_0807DDAC(this, 0);
+ sub_0807DDAC(this, NULL);
sub_0807DDE4(this);
UpdateAnimationSingleFrame(this);
}
diff --git a/src/npc/stamp.c b/src/npc/stamp.c
index f77b1fdd..a30d31ad 100644
--- a/src/npc/stamp.c
+++ b/src/npc/stamp.c
@@ -2,13 +2,13 @@
#include "entity.h"
#include "textbox.h"
#include "functions.h"
+#include "script.h"
extern void sub_08078778(Entity*);
extern void sub_0805E47C(Entity*);
extern void sub_0805E584();
extern void sub_0807DD64();
extern void sub_08062CA4();
-extern void sub_0807DDAC();
extern void sub_0807DDE4();
extern u32 CheckKinstoneFused();
@@ -68,7 +68,7 @@ void sub_08062C7C(Entity* ent) {
}
void sub_08062CA4(Entity* ent) {
- sub_0807DDAC(ent, 0);
+ sub_0807DDAC(ent, NULL);
sub_0807DDE4(ent);
GetNextFrame(ent);
}
diff --git a/src/npc/talon.c b/src/npc/talon.c
index b4ddbe84..24380fc9 100644
--- a/src/npc/talon.c
+++ b/src/npc/talon.c
@@ -3,6 +3,7 @@
#include "textbox.h"
#include "functions.h"
#include "player.h"
+#include "script.h"
extern void (*gUnk_0810FEC4[])(Entity* this);
extern void (*gUnk_0810FEBC[])(Entity* this);
@@ -77,7 +78,7 @@ void sub_08065648(Entity* this) {
this->interactType = 0;
sub_0806F118(this);
} else {
- sub_0807DD94(this, 0);
+ sub_0807DD94(this, NULL);
}
}
@@ -106,7 +107,7 @@ void sub_080656D4(Entity* this) {
} else {
if (this->interactType != 0) {
if (GetInventoryValue(0x37) != 0) { // keyLonLon
- StartCutscene(this, &gUnk_0800B41C);
+ StartCutscene(this, (u16*)&gUnk_0800B41C);
goto label2;
} else {
this->field_0x68.HALF.HI = this->action;
@@ -118,7 +119,7 @@ void sub_080656D4(Entity* this) {
}
} else {
label2:
- sub_0807DD94(this, 0);
+ sub_0807DD94(this, NULL);
}
}
}
diff --git a/src/npc/teachers.c b/src/npc/teachers.c
index 2e0e99fd..9a9f0509 100644
--- a/src/npc/teachers.c
+++ b/src/npc/teachers.c
@@ -3,13 +3,13 @@
#include "player.h"
#include "functions.h"
#include "save.h"
+#include "script.h"
extern SpriteLoadData gUnk_08113910[];
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 void sub_08078784(Entity*, u32);
extern u32 UpdateFuseInteraction(Entity*);
extern void sub_0807000C(Entity*);
@@ -37,7 +37,7 @@ void Teachers(Entity* this) {
(this->animIndex & -4) + sub_0806F5A4(GetFacingDirection(this, &gPlayerEntity)));
sub_0806F118(this);
} else {
- sub_0807DD94(this, 0);
+ sub_0807DD94(this, NULL);
}
break;
case 2:
diff --git a/src/npc/townMinish.c b/src/npc/townMinish.c
index 3eab0a5a..9217fdd7 100644
--- a/src/npc/townMinish.c
+++ b/src/npc/townMinish.c
@@ -5,6 +5,7 @@
#include "textbox.h"
#include "flags.h"
#include "save.h"
+#include "script.h"
extern void InitializeAnimation(Entity*, u32);
extern u32 LoadExtraSpriteData(Entity*, SpriteLoadData*);
@@ -111,7 +112,7 @@ void sub_0806ACC4(Entity* this) {
this->interactType = 0;
sub_0806F118(this);
} else {
- sub_0807DDAC(this, 0);
+ sub_0807DDAC(this, NULL);
sub_0806AEA8(this);
if (this->entityType.parameter == 10 && this->interactType) {
this->action = 2;
diff --git a/src/npc/townsperson.c b/src/npc/townsperson.c
index 1c05c1a4..a5295f93 100644
--- a/src/npc/townsperson.c
+++ b/src/npc/townsperson.c
@@ -7,6 +7,7 @@
#include "structures.h"
#include "functions.h"
#include "save.h"
+#include "script.h"
typedef struct {
u8 frame1;
@@ -30,7 +31,6 @@ 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);
@@ -144,7 +144,7 @@ void sub_08061D64(Entity* this) {
this->field_0x68.HALF.HI = this->animIndex;
InitializeAnimation(this, (this->animIndex & -4) + sub_0806F5A4(GetFacingDirection(this, &gPlayerEntity)));
} else {
- sub_0807DDAC(this, 0);
+ sub_0807DDAC(this, NULL);
sub_0807DDE4(this);
if (this->frameDuration == 0xff) {
this->frameDuration = gUnk_0810B680[this->entityType.form].unk2;
diff --git a/src/npc/windTribespeople.c b/src/npc/windTribespeople.c
index bb09a0c8..05dca467 100644
--- a/src/npc/windTribespeople.c
+++ b/src/npc/windTribespeople.c
@@ -6,12 +6,12 @@
#include "structures.h"
#include "functions.h"
#include "save.h"
+#include "script.h"
extern u32 LoadExtraSpriteData(Entity*, SpriteLoadData*);
extern void sub_0807DD50(Entity*);
extern void sub_0806C7D4(Entity*);
extern void sub_0806F118(Entity*);
-extern void sub_0807DD94(Entity*, u32);
extern void sub_0807DD80(Entity*, u32*);
extern u32 sub_0801E99C();
extern void sub_08078784(Entity*, u32);
@@ -54,7 +54,7 @@ void sub_0806C7D4(Entity* this) {
this->interactType = '\0';
sub_0806F118(this);
} else {
- sub_0807DD94(this, 0);
+ sub_0807DD94(this, NULL);
if ((this->entityType.parameter == 3) && (!CheckGlobalFlag(WARP_EVENT_END)) && (CheckLocalFlag(0x63)) &&
(CheckRoomFlag(0))) {
(this->entityType).parameter = 7;
diff --git a/src/npc/zelda.c b/src/npc/zelda.c
index b7dec220..00c333e6 100644
--- a/src/npc/zelda.c
+++ b/src/npc/zelda.c
@@ -3,10 +3,10 @@
#include "functions.h"
#include "room.h"
#include "flags.h"
+#include "script.h"
extern void PrependEntityToList(Entity*, u32);
extern void sub_0807DD50(Entity*);
-extern void sub_0807DD94(Entity*, u32);
extern Entity* FindEntityBySubtype(u32, u32);
void CopyPosition(Entity*, Entity*);
void sub_08068680(Entity*, Entity*);
@@ -37,7 +37,7 @@ void sub_08066CCC(Entity* ent) {
}
void sub_08066CF8(Entity* ent) {
- sub_0807DD94(ent, 0);
+ sub_0807DD94(ent, NULL);
}
void sub_08066D04(Entity* ent) {
diff --git a/src/object/cloud.c b/src/object/cloud.c
index 8a133c2e..631e6605 100644
--- a/src/object/cloud.c
+++ b/src/object/cloud.c
@@ -4,6 +4,7 @@
#include "player.h"
#include "flags.h"
#include "functions.h"
+#include "structures.h"
extern void sub_0809F7BC(Entity*);
extern void PlaySFX(u32);
@@ -22,7 +23,6 @@ extern Entity* CreateObject(u32, u32, u32);
extern void PositionEntityOnTop(Entity*, Entity*);
extern void sub_0807BB68(u32*, u32, u32);
-extern u8 gUnk_02034490;
extern void* gUnk_080DD750;
extern Entity gPlayerEntity;
extern PlayerState gPlayerState;
@@ -48,7 +48,7 @@ void sub_0809F514(Entity* this) {
this->spriteSettings.b.draw = 0;
this->field_0x68.HALF.LO = 12;
gRoomControls.cameraTarget = this;
- gUnk_02034490 = 255;
+ gUnk_02034490[0] = 255;
sub_0809F7BC(this);
}
diff --git a/src/object/houseDoorExterior.c b/src/object/houseDoorExterior.c
index cdee3afe..ddf5b87e 100644
--- a/src/object/houseDoorExterior.c
+++ b/src/object/houseDoorExterior.c
@@ -3,6 +3,7 @@
#include "flags.h"
#include "functions.h"
#include "room.h"
+#include "script.h"
typedef struct {
/*0x00*/ u16 unk0;
@@ -64,7 +65,7 @@ void sub_080866D8(Entity* this) {
UpdateSpriteForCollisionLayer(entity);
*((u32*)(&this->field_0x68)) |= mask;
if (prop->unk8) {
- *((u32**)(&entity->cutsceneBeh)) = StartCutscene(entity, prop->unk8);
+ *((ScriptExecutionContext **)(&entity->cutsceneBeh)) = StartCutscene(entity, (u16*)prop->unk8);
}
}
}
@@ -116,7 +117,7 @@ static void sub_0808681C(Entity* this) {
}
if (this->flags & 0x2) {
- ExecuteScriptCommandSet(this, *(u32**)&this->cutsceneBeh);
+ ExecuteScriptCommandSet(this, *(ScriptExecutionContext **)&this->cutsceneBeh);
sub_080868EC(this, *(void**)&this->cutsceneBeh);
}
}
@@ -128,7 +129,7 @@ void sub_080868B0(Entity* this) {
this->boundingBox = &gUnk_081206AC;
this->actionDelay = 8;
}
- ExecuteScriptCommandSet(this, *(u32**)&this->cutsceneBeh);
+ ExecuteScriptCommandSet(this, *(ScriptExecutionContext **)&this->cutsceneBeh);
sub_080868EC(this, *(void**)&this->cutsceneBeh);
}
diff --git a/src/object/windcrest.c b/src/object/windcrest.c
index ff559344..a4c4049d 100644
--- a/src/object/windcrest.c
+++ b/src/object/windcrest.c
@@ -2,9 +2,9 @@
#include "entity.h"
#include "functions.h"
#include "save.h"
+#include "script.h"
extern void sub_0807DD64(Entity*);
-extern void sub_0807DDAC(Entity*, u32);
extern void sub_0807DDE4(Entity*);
extern void sub_08078850(Entity*, u32, u32, u8*);
extern void PlaySFX(u32);
@@ -18,7 +18,7 @@ void Windcrest(Entity* this) {
this->frameIndex = 0;
sub_0807DD64(this);
}
- sub_0807DDAC(this, 0);
+ sub_0807DDAC(this, NULL);
sub_0807DDE4(this);
}
diff --git a/src/save.c b/src/save.c
index 879e5d70..281e54c5 100644
--- a/src/save.c
+++ b/src/save.c
@@ -1,6 +1,13 @@
#include "save.h"
-extern u32 sub_0807D008(u32, SaveFile*);
+typedef struct Thing {
+ u16 unk_1;
+ u16 unk_2;
+ u32 unk_3;
+} Thing;
+
+extern u32 sub_080B180C(u32, const char*);
+extern u16 sub_080B18DC(u16, const char*);
const u16 gUnk_0811E454[] = { 0x0, 0x0, 0x100, 0x200, 0x300, 0x400, 0x500,
0x5C0, 0x680, 0x740, 0x800, 0x8C0, 0x9C0, 0xA80 };
@@ -12,6 +19,13 @@ static SaveResult HandleSaveInProgress(u32);
static SaveResult HandleSaveDone(u32);
static SaveResult (*const sSaveHandlers[])(u32) = { HandleSaveInit, HandleSaveInProgress, HandleSaveDone };
+u32 sub_0807D008(u32, SaveFile*);
+u32 sub_0807D0A0(u16*, u16*, u32);
+u32 sub_0807D0EC(u32, const char*);
+u32 sub_0807D128(const Thing*);
+u16 sub_0807D1A4(u16*, u32);
+u32 sub_0807D1D8(u32, const char*, u32);
+
static const char sSignatureLong[32] = "AGBZELDA:THE MINISH CAP:ZELDA 5";
// Save file is untouched
@@ -22,6 +36,7 @@ static const char sSaveDescDeleted[8] = "\xFF\xFF\xFF\xFF"
"DelF";
const char gUnk_0811E4B4[8] = "DAMEDAME";
+extern struct_0807D1C4 gUnk_0811E4BC[];
extern s16 gUnk_02021EE0[6];
@@ -155,3 +170,199 @@ void sub_0807CF68(u32 arg0) {
sub_0807D184(temp->field_0x4, str);
sub_0807D184(temp->field_0x2, str);
}
+
+u32 sub_0807CF88(u32 arg0, u8* arg1) {
+ Thing thing;
+
+ u32 retval;
+ struct_0807D1C4* ptr;
+ u32 e0, e1;
+ u16 l1prep;
+
+ ptr = sub_0807D1C4(arg0);
+
+ thing.unk_3 = 'MCZ3';
+ l1prep = sub_0807D1A4((u16*)&thing.unk_3, 4);
+ l1prep += sub_0807D1A4((u16*)arg1, ptr->field_0x0);
+ thing.unk_1 = l1prep;
+ thing.unk_2 = -(u32)l1prep;
+ e0 = sub_0807D20C(ptr->field_0x6, (const char*)arg1, ptr->field_0x0);
+ if (e0) {
+ e0 = sub_0807D184(ptr->field_0x2, (const char*)&thing.unk_1);
+ }
+ e1 = sub_0807D20C(ptr->field_0x8, (const char*)arg1, ptr->field_0x0);
+ if (e1) {
+ e1 = sub_0807D184(ptr->field_0x4, (const char*)&thing.unk_1);
+ }
+
+ retval = 0;
+ if (e0 || e1) {
+ retval = 1;
+ }
+ return retval;
+}
+
+NONMATCH("asm/non_matching/save/sub_0807D008.inc", u32 sub_0807D008(u32 param_1, SaveFile* saveFile)) {
+ u32 set_0;
+ char auStack32[8];
+
+ struct_0807D1C4* unk_s;
+ u32 t1;
+ u32 t2;
+ u32 ret;
+ u32 temp;
+
+ unk_s = sub_0807D1C4(param_1);
+ t1 = sub_0807D0EC(unk_s->field_0x2, auStack32);
+ if (t1 == 2) {
+ if ((sub_0807D1D8(unk_s->field_0x6, (char*)saveFile, unk_s->field_0x0) == 0) ||
+ (sub_0807D0A0((u16*)auStack32, (u16*)saveFile, (u32)unk_s->field_0x0) == 0)) {
+ t1 = 0;
+ } else {
+ return 1;
+ }
+ }
+ t2 = sub_0807D0EC(unk_s->field_0x4, auStack32);
+ if (t2 == 2) {
+ if ((sub_0807D1D8(unk_s->field_0x8, (char*)saveFile, unk_s->field_0x0) != 0) &&
+ (sub_0807D0A0((u16*)auStack32, (u16*)saveFile, (u32)unk_s->field_0x0) != 0)) {
+ return 1;
+ }
+ t2 = 0;
+ }
+ set_0 = 0;
+ CpuSet(&set_0, saveFile, unk_s->field_0x0 >> 2 | CPU_SET_SRC_FIXED | CPU_SET_32BIT);
+ temp = t1 | t2;
+ ret = 0;
+ if (temp == 0) {
+ ret = -1;
+ }
+ return ret;
+ }
+END_NONMATCH
+
+NONMATCH("asm/non_matching/save/sub_0807D0A0.inc", u32 sub_0807D0A0(u16* unk_1, u16* unk_2, u32 unk_3)) {
+ u32 r0;
+
+ u32* u32_1 = (u32*)unk_1;
+
+ u16 u0;
+ u32 u1;
+
+ u0 = sub_0807D1A4(unk_1 + 2, 4);
+ u0 = u0 + sub_0807D1A4(unk_2, unk_3);
+
+ u1 = unk_1[0];
+ if (u1 != u0) {
+ r0 = 0;
+ } else {
+ if (unk_1[1] == (-(u1 << 0x10) >> 0x10)) {
+ if (*(u32_1 + 1) != 'MCZ3') {
+ r0 = 0;
+ } else {
+ r0 = 1;
+ }
+ } else {
+ r0 = 0;
+ }
+ }
+ return r0;
+ }
+END_NONMATCH
+
+u32 sub_0807D0EC(u32 unk_1, const char* unk_2) {
+ u32 ret;
+
+ if (!sub_0807D1D8(unk_1, unk_2, 8)) {
+ ret = 0;
+ } else {
+ ret = sub_0807D128((Thing*)unk_2);
+ }
+ if (!ret && sub_0807D1D8(unk_1 + 8, unk_2, 8)) {
+ ret = sub_0807D128((Thing*)unk_2);
+ }
+ return ret;
+}
+
+u32 sub_0807D128(const Thing* thing) {
+ u32 ret;
+ switch (thing->unk_3) {
+ case 'MCZ3':
+ if (thing->unk_1 + thing->unk_2 == 0x10000) {
+ ret = 2;
+ } else {
+ ret = 0;
+ }
+ break;
+ case 'FleD':
+ case 'TINI':
+ ret = 0;
+ if ((thing->unk_1 & thing->unk_2) == 0xffff) {
+ ret = 1;
+ }
+ break;
+ default:
+ ret = 0;
+ break;
+ }
+ return ret;
+}
+
+u32 sub_0807D184(u32 param_1, const char* param_2) {
+ u32 uVar1;
+
+ uVar1 = sub_0807D20C(param_1, param_2, 8);
+ if (uVar1 == 0) {
+ uVar1 = sub_0807D20C(param_1 + 8, param_2, 8);
+ }
+ return uVar1;
+}
+
+u16 sub_0807D1A4(u16* unk_1, u32 unk_2) {
+ u32 uVar1;
+
+ uVar1 = 0;
+ while (unk_2 != 0) {
+ uVar1 = uVar1 + (*unk_1 ^ unk_2);
+ unk_1 = unk_1 + 1;
+ unk_2 = unk_2 - 2;
+ }
+ return uVar1;
+}
+
+struct_0807D1C4* sub_0807D1C4(u32 unk_1) {
+ return &gUnk_0811E4BC[unk_1];
+}
+
+// these three are basically the same and wrong by basically one instruction in the wrong place
+NONMATCH("asm/non_matching/save/sub_0807D1D8.inc", u32 sub_0807D1D8(u32 unk_1, const char* unk_2, u32 unk_3)) {
+ }
+END_NONMATCH
+
+NONMATCH("asm/non_matching/save/sub_0807D20C.inc", u32 sub_0807D20C(u32 unk_1, const char* unk_2, u32 unk_3)) {
+ unk_3 >>= 3;
+ unk_1 >>= 3;
+ while (unk_3-- > 0) {
+ if (sub_080B18DC(unk_1, unk_2)) {
+ sub_080B18DC(unk_1, gUnk_0811E4B4);
+ return 0;
+ }
+ unk_1++;
+ unk_2 += 8;
+ }
+ return 1;
+ }
+END_NONMATCH
+
+NONMATCH("asm/non_matching/save/sub_0807D24C.inc", u32 sub_0807D24C(u32 unk_1, const char* unk_2, u32 unk_3)) {
+ unk_3 >>= 3;
+ unk_1 >>= 3;
+ while (unk_3-- > 0) {
+ if (sub_080B180C(unk_1, unk_2))
+ return 0;
+ unk_1++;
+ unk_2 += 8;
+ }
+ return 1;
+ }
+END_NONMATCH
diff --git a/src/executeScriptCommandSet.c b/src/script.c
index de8ea781..2f38b5f3 100644
--- a/src/executeScriptCommandSet.c
+++ b/src/script.c
@@ -8,6 +8,10 @@
#include "functions.h"
#include "save.h"
+void sub_0807DAF0(Entity*, ScriptExecutionContext*, u16*);
+void sub_0807DB88(ScriptExecutionContext*, u16*);
+void sub_0807DE80(Entity*);
+void sub_0807DF38(void);
void nullsub_507 (Entity*, ScriptExecutionContext*);
void sub_0807E004(Entity*, ScriptExecutionContext*);
void sub_0807E014(Entity*, ScriptExecutionContext*);
@@ -147,6 +151,10 @@ void sub_0807F0A4(Entity*, ScriptExecutionContext*);
void sub_0807F0B4(Entity*, ScriptExecutionContext*);
void sub_0807F0C8(Entity*, ScriptExecutionContext*);
+extern void CreateSpeechBubbleExclamationMark(Entity*, u32, u32);
+extern void CreateSpeechBubbleQuestionMark(Entity*, u32, u32);
+extern void sub_0801C4A0(u32);
+
void (* const gUnk_0811E524[])() = {
nullsub_507,
sub_0807E004,
@@ -290,6 +298,305 @@ void (* const gUnk_0811E524[])() = {
};
extern const u16 gUnk_08016984;
+extern u8 gUnk_0811E514[];
+extern u8 gUnk_0811E510[];
+extern ScriptExecutionContext gPlayerScriptExecutionContext;
+extern ScriptExecutionContext gScriptExecutionContextArray[0x20];
+
+void sub_0807DA70(void) {
+ _DmaZero(&gUnk_02033280, sizeof(gUnk_02033280));
+ _DmaZero(&gScriptExecutionContextArray, sizeof(gScriptExecutionContextArray));
+ _DmaZero(&gPlayerScriptExecutionContext, sizeof(gPlayerScriptExecutionContext));
+ gUnk_02033280.unk_08 = 8;
+}
+
+ScriptExecutionContext* CreateScriptExecutionContext(void) {
+ ScriptExecutionContext* context;
+
+ context = gScriptExecutionContextArray;
+ do {
+ if (context->unk_00 == 0) {
+ return context;
+ }
+ context++;
+ } while (context < gScriptExecutionContextArray + ARRAY_COUNT(gScriptExecutionContextArray));
+ return NULL;
+}
+
+void DestroyScriptExecutionContext(ScriptExecutionContext* context) {
+ _DmaZero(context, sizeof(ScriptExecutionContext));
+}
+
+ScriptExecutionContext* StartCutscene(Entity* entity, u16* unk_2) {
+ ScriptExecutionContext* context;
+
+ context = CreateScriptExecutionContext();
+ if (context) {
+ sub_0807DAF0(entity, context, unk_2);
+ }
+ return context;
+}
+
+void sub_0807DAF0(Entity* entity, ScriptExecutionContext* context, u16* unk1) {
+ entity->flags = entity->flags | 2;
+ *(ScriptExecutionContext**)&entity->cutsceneBeh = context;
+ sub_0807DB88(context, unk1);
+}
+
+void UnloadCutsceneData(Entity* entity) {
+ if ((entity->flags & 2)) {
+ entity->flags = entity->flags & 0xfd;
+ DestroyScriptExecutionContext(*(ScriptExecutionContext**)&entity->cutsceneBeh);
+ *(ScriptExecutionContext**)&entity->cutsceneBeh = NULL;
+ }
+}
+
+void StartPlayerScript(u16* unk1) {
+ Entity* player;
+
+ _DmaZero(&gPlayerScriptExecutionContext, sizeof(gPlayerScriptExecutionContext));
+ gPlayerScriptExecutionContext.unk_00 = unk1;
+ player = &gPlayerEntity;
+ *(ScriptExecutionContext**)&player->cutsceneBeh = &gPlayerScriptExecutionContext;
+ gPlayerState.playerAction = 0x1c;
+ gPlayerState.field_0x3a = 0;
+ gPlayerState.field_0x39 = 0;
+ gPlayerState.field_0x38 = 0;
+}
+
+ScriptExecutionContext* sub_0807DB68(Entity* entity, u16* unk1) {
+ ScriptExecutionContext* context;
+
+ context = CreateScriptExecutionContext();
+ if (context) {
+ entity->flags |= 2;
+ *(ScriptExecutionContext**)&entity->field_0x3c = context;
+ context->unk_00 = unk1;
+ }
+ return context;
+}
+
+void sub_0807DB88(ScriptExecutionContext* context, u16* unk1) {
+ _DmaZero(context, sizeof(ScriptExecutionContext));
+ context->unk_00 = unk1;
+}
+
+void sub_0807DB98(Entity* entity, ScriptExecutionContext* context) {
+ u32 switchVar;
+
+ while (context->unk_08) {
+ switchVar = (~context->unk_08 + 1) & context->unk_08;
+ context->unk_08 ^= switchVar;
+ switch (switchVar) {
+ case 1:
+ entity->field_0x80.HWORD = 0;
+ break;
+ case 2:
+ entity->field_0x80.HWORD = 4;
+ break;
+ case 4:
+ break;
+ case 8:
+ entity->field_0x20 = 0x18000;
+ break;
+ case 0x10:
+ CreateSpeechBubbleExclamationMark(entity, 8, -0x18);
+ break;
+ case 0x20:
+ CreateSpeechBubbleQuestionMark(entity, 8, -0x18);
+ break;
+ case 0x40:
+ DestroyScriptExecutionContext(context);
+ DeleteThisEntity();
+ case 0x80:
+ entity->spriteSettings.b.draw = 1;
+ break;
+ case 0x100:
+ entity->spriteSettings.b.draw = 0;
+ break;
+ case 0x200:
+ entity->spriteOffsetY = 0;
+ entity->spriteOffsetX = 0;
+ entity->field_0x82.HWORD = 0;
+ break;
+ case 0x400:
+ entity->field_0x82.HWORD |= 2;
+ break;
+ case 0x800:
+ entity->field_0x82.HWORD &= 0xfffd;
+ break;
+ case 0x1000:
+ entity->field_0x82.HWORD &= 0xfffe;
+ break;
+ case 0x2000:
+ entity->field_0x82.HWORD |= 1;
+ break;
+ case 0x4000:
+ entity->field_0x82.HWORD |= 8;
+ break;
+ case 0x8000:
+ entity->field_0x82.HWORD ^= 4;
+ break;
+ case 0x10000:
+ entity->field_0x82.HWORD ^= 0x10;
+ break;
+ case 0x20000:
+ entity->spriteSettings.b.flipX ^= 1;
+ break;
+ case 0x40000:
+ entity->field_0x82.HWORD |= 0x20;
+ break;
+ case 0x80000:
+ entity->field_0x82.HWORD &= 0xffdf;
+ break;
+ default:
+ break;
+ }
+ }
+}
+
+void sub_0807DD50(Entity* entity) {
+ sub_0807DD64(entity);
+ sub_0807DD94(entity, 0);
+}
+
+void sub_0807DD64(Entity* entity) {
+ entity->field_0xf = entity->animationState;
+ entity->animIndex = 0xff;
+ entity->field_0x80.HWORD = 0;
+ entity->field_0x82.HWORD = 0;
+}
+
+void sub_0807DD80(Entity* entity, u16* unk1) {
+ sub_0807DB88(*(ScriptExecutionContext**)&entity->cutsceneBeh, unk1);
+ sub_0807DD64(entity);
+}
+
+void sub_0807DD94(Entity* entity, void (*function)(Entity*, ScriptExecutionContext*)) {
+ sub_0807DDAC(entity, function);
+ sub_0807DDE4(entity);
+ sub_0807DE80(entity);
+}
+
+void sub_0807DDAC(Entity* entity, void (*function)(Entity*, ScriptExecutionContext*)) {
+ ScriptExecutionContext** piVar1;
+
+ piVar1 = (ScriptExecutionContext**)&entity->cutsceneBeh;
+ if (*piVar1) {
+ ExecuteScriptCommandSet(entity, *piVar1);
+ if (function) {
+ function(entity, *piVar1);
+ } else {
+ sub_0807DB98(entity, *piVar1);
+ }
+ if (!entity->next) {
+ DeleteThisEntity();
+ }
+ }
+}
+
+void sub_0807DDE4(Entity* entity) {
+ u32 temp;
+ u32 switchVar;
+ u32 loopVar;
+
+ loopVar = entity->field_0x82.HWORD;
+ while (loopVar) {
+ switchVar = (~loopVar + 1) & loopVar;
+ loopVar = loopVar ^ switchVar;
+ switch (switchVar) {
+ case 2:
+ if (entity->entityType.type == 7) {
+ sub_0806ED78(entity);
+ } else {
+ sub_0800445C(entity);
+ }
+ break;
+ case 8:
+ if ((gScreenTransition.frameCount & 3) == 0) {
+ temp = (entity->field_0xf + 2U) & 7;
+ entity->animationState = temp;
+ entity->field_0xf = temp;
+ }
+ break;
+ case 0x10:
+ if ((gScreenTransition.frameCount & 1) == 0) {
+ entity->spriteOffsetX = gUnk_0811E510[Random() & 3];
+ }
+ break;
+ case 0x20:
+ sub_08003FC4(entity, 0x2000);
+ break;
+ }
+ }
+}
+
+void sub_0807DE80(Entity* entity) {
+ u32 local1;
+ u16 local2;
+
+ u32 temp;
+
+ local2 = entity->field_0x80.HWORD;
+ if (local2 < 8) {
+ if (entity->field_0x82.HWORD & 1) {
+ u32 t1, t2;
+ t1 = local2 & 0xfc;
+ t2 = entity->field_0xf >> 1;
+ local2 = t1 + t2;
+ } else {
+ u32 t1, t2;
+ t1 = local2 & 0xfc;
+ t2 = entity->animationState >> 1;
+ local2 = t1 + t2;
+ entity->field_0xf = entity->animationState;
+ }
+ }
+ if (local2 != entity->animIndex) {
+ InitAnimationForceUpdate(entity, local2);
+ }
+ temp = entity->field_0x82.HWORD & 4;
+ local1 = 1;
+ if (temp) {
+ local1 = 2;
+ }
+ sub_080042BA(entity, local1);
+}
+
+void sub_0807DEDC(Entity* entity, ScriptExecutionContext* context, u32 arg2, u32 arg3) {
+ int temp;
+ s32 t0, t1;
+
+ context->unk_19 = 8;
+ context->unk_08 |= 2;
+ context->unk_14 = 0;
+ context->unk_1C.HALF.HI = arg2;
+ context->unk_20.HALF.HI = arg3;
+ t0 = context->unk_1C.HALF.HI - entity->x.HALF.HI;
+ t1 = context->unk_20.HALF.HI - entity->y.HALF.HI;
+ temp = sub_080045DA(t0, t1);
+ entity->direction = temp;
+ entity->animationState = (entity->animationState & 0x80) | gUnk_0811E514[(u32)(temp << 0x18) >> 0x1c];
+}
+
+void sub_0807DF28(void) {
+ sub_0807DF38();
+ sub_08079184();
+ sub_08077B20();
+}
+
+void sub_0807DF38(void) {
+ gUnk_0200AF00.filler0[1] = 0xff;
+ gUnk_02034490[0] = 0xff;
+}
+
+void sub_0807DF50(void) {
+ gUnk_02034490[0] = 0;
+ gUnk_0200AF00.filler0[1] = 0;
+ sub_0801C4A0(0);
+ sub_080791D0();
+ sub_08079184();
+}
void ExecuteScriptCommandSet(Entity* unk1, ScriptExecutionContext* unk2) {
if (!unk2->unk_00) return;
@@ -752,7 +1059,7 @@ void sub_0807E898(Entity* unk1, ScriptExecutionContext* unk2) {
}
void sub_0807E8C4(Entity* unk1, ScriptExecutionContext* unk2) {
- StartPlayerScript(GetNextScriptCommandWordAfterCommandMetadata(unk2->unk_00));
+ StartPlayerScript((u16*)GetNextScriptCommandWordAfterCommandMetadata(unk2->unk_00));
}
void sub_0807E8D4(Entity* unk1, ScriptExecutionContext* unk2) {
@@ -832,7 +1139,7 @@ void sub_0807E9F0(Entity* unk1, ScriptExecutionContext* unk2) {
switch (gUnk_02022740[0]) {
case 2:
gPlayerState.field_0x8b = 3;
- gUnk_02034490 = tmp;
+ gUnk_02034490[0] = tmp;
unk2->unk_14 = tmp;
break;
case 1: