diff --git a/include/script.h b/include/script.h index 9abc5291..416485b5 100644 --- a/include/script.h +++ b/include/script.h @@ -3,14 +3,24 @@ #include "global.h" +typedef struct +{ + u16 command; + u16 metadata; +} ScriptCommand; + + typedef struct { - u16* unk_00; + union { + u16* raw; + ScriptCommand* commands; // list of commands to execute + } unk_00; u32 unk_04; u32 unk_08; u8 unk_0C[0x4]; // unused u16 unk_10; u16 unk_12; - u32 unk_14; + u32 compareResult; // result of a compare script command u8 unk_18; u8 unk_19; u8 unk_1A; diff --git a/include/structures.h b/include/structures.h index 59811d6f..f6108ad6 100644 --- a/include/structures.h +++ b/include/structures.h @@ -119,11 +119,15 @@ typedef struct { extern struct_02024490 gUnk_02024490; + +// Some kind of ScriptInterpreter state? typedef struct { u32 unk_00; - u16 unk_04; + u16 operationId; u8 unk_06; - u8 unk_07; + // bit 0 is reset before each script execution + // execution is continued if bit 0 or bit 1 are true, so bit 1 can be set to execute until someone unsets bit 1 + u8 continueScriptExecutionFlags; u8 unk_08; } struct_02033280; diff --git a/src/npc/ezloCap.c b/src/npc/ezloCap.c index 13ecd8f9..201c0e4e 100644 --- a/src/npc/ezloCap.c +++ b/src/npc/ezloCap.c @@ -172,7 +172,7 @@ void sub_0806DAAC(Entity* this, u32* param_2) { u32 uVar1; uVar1 = CheckKinstoneFused(sub_0806DA3C(this)); param_2[5] = uVar1; - gUnk_02033280.unk_07 |= 1; + gUnk_02033280.continueScriptExecutionFlags |= 1; } // maybe actually execute the kinstone fusion? diff --git a/src/npc/goron.c b/src/npc/goron.c index 0203969c..2bd99575 100644 --- a/src/npc/goron.c +++ b/src/npc/goron.c @@ -97,9 +97,10 @@ u32 sub_08069480(Entity* this) { return (sub_0801E99C(this) << 24) >> 24; } +// TODO param_1 possibly ScriptExecutionContext? void sub_0806948C(Entity* this, u32* param_1) { param_1[5] = CheckKinstoneFused((sub_08069480(this) << 24) >> 24); - gUnk_02033280.unk_07 |= 1; + gUnk_02033280.continueScriptExecutionFlags |= 1; } void sub_080694B0(Entity* this) { diff --git a/src/npc/postman.c b/src/npc/postman.c index 532f129f..7306b69b 100644 --- a/src/npc/postman.c +++ b/src/npc/postman.c @@ -201,13 +201,13 @@ void sub_080606D8(Entity* this) { ShowNPCDialogue(this, &gUnk_0810AA30[index]); } -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]]; +void sub_08060700(Entity* this, ScriptExecutionContext* context) { + s8* var0 = gUnk_0810A918[(s8)this->field_0x68.HALF.LO]; + Coords16* coords = &gUnk_0810A66C[var0[(s8)this->field_0x68.HALF.HI]]; u32 x = coords->x + gRoomControls.roomOriginX; u32 y = coords->y + gRoomControls.roomOriginY; - sub_0807DEDC(entity, context, x, y); - gUnk_02033280.unk_07 |= 1; + sub_0807DEDC(this, context, x, y); + gUnk_02033280.continueScriptExecutionFlags |= 1; } void sub_0806075C(Entity* this) { diff --git a/src/npc/zelda.c b/src/npc/zelda.c index 90a40fc0..0b1e44f9 100644 --- a/src/npc/zelda.c +++ b/src/npc/zelda.c @@ -128,6 +128,7 @@ void sub_08066E68(Entity* ent) { ent->field_0x80.HWORD = ent->animIndex; } +// TODO param_2 possibly ScriptExecutionContext? void sub_08066E80(Entity* ent, u8* param_2) { switch (param_2[0x18]) { case 0: @@ -164,7 +165,7 @@ void sub_08066E80(Entity* ent, u8* param_2) { case 4: UpdateAnimationSingleFrame(ent); if (ent->frames.b.f3) { - gUnk_02033280.unk_07 |= 1; + gUnk_02033280.continueScriptExecutionFlags |= 1; return; } } diff --git a/src/script.c b/src/script.c index 494e0ae5..495a01d5 100644 --- a/src/script.c +++ b/src/script.c @@ -154,30 +154,147 @@ 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, sub_0807E014, sub_0807E024, sub_0807E050, sub_0807E064, sub_0807E078, sub_0807E0A0, - sub_0807E0B8, sub_0807E0CC, sub_0807E0E0, sub_0807E10C, sub_0807E124, sub_0807E148, sub_0807E158, sub_0807E188, - sub_0807E1D8, - sub_0807E4AC, // defined out of order - sub_0807E200, sub_0807E220, sub_0807E240, sub_0807E260, sub_0807E280, sub_0807E2A8, sub_0807E2E4, sub_0807E30C, - sub_0807E390, sub_0807E3BC, sub_0807E3E8, sub_0807E40C, sub_0807E42C, sub_0807E48C, sub_0807E4CC, sub_0807E4EC, - sub_0807E514, sub_0807E538, sub_0807E564, sub_0807E584, sub_0807E5A0, sub_0807E5CC, sub_0807E5F8, sub_0807E610, - sub_0807E628, sub_0807E634, sub_0807E644, sub_0807E650, sub_0807E65C, sub_0807E668, sub_0807E674, sub_0807E680, - sub_0807E690, sub_0807E6AC, sub_0807E6DC, sub_0807E700, sub_0807E72C, sub_0807E75C, sub_0807E778, sub_0807E788, - sub_0807E79C, nullsub_508, sub_0807E7B0, sub_0807E7C4, sub_0807E7D8, sub_0807E7EC, sub_0807E800, sub_0807E80C, - sub_0807E858, sub_0807E864, sub_0807E878, sub_0807E888, sub_0807E898, sub_0807E8C4, sub_0807E8D4, sub_0807E8E4, - sub_0807E8E4, // duplicate - sub_0807E8E4, // duplicate - sub_0807E8E4, // duplicate - sub_0807E908, sub_0807E914, sub_0807E924, sub_0807E930, sub_0807E944, sub_0807E974, sub_0807E9D4, sub_0807E9DC, - sub_0807E9E4, sub_0807E9F0, sub_0807EA4C, sub_0807EA88, sub_0807EA94, sub_0807EAB4, sub_0807EAC0, sub_0807EAD0, - sub_0807EAF0, sub_0807EB18, sub_0807EB28, sub_0807EB38, sub_0807EB44, sub_0807EB4C, sub_0807EB74, sub_0807EB8C, - sub_0807EBA8, sub_0807EBB0, sub_0807EBC0, sub_0807EBC8, sub_0807EBD8, sub_0807EBF4, sub_0807EC08, nullsub_509, - sub_0807EC1C, sub_0807EC64, sub_0807EC94, sub_0807ECC4, sub_0807ECF4, sub_0807ED24, sub_0807EDD4, sub_0807EE04, - sub_0807EE30, sub_0807EEB4, sub_0807EEF4, sub_0807EF3C, sub_0807EF80, sub_0807EF90, sub_0807EFA0, sub_0807EFAC, - sub_0807EFD4, sub_0807EFE4, sub_0807EFF4, sub_0807F004, sub_0807F010, sub_0807F034, sub_0807F050, sub_0807F060, - sub_0807F078, sub_0807F088, sub_0807F098, sub_0807F0A4, sub_0807F0B4, sub_0807F0C8 +// size: 139 +void (*const scriptOperations[])() = { + nullsub_507, // 0 + sub_0807E004, // 1 + sub_0807E014, // 2 + sub_0807E024, // 3 + sub_0807E050, // 4 + sub_0807E064, // 5 + sub_0807E078, // 6 + sub_0807E0A0, // 7 + sub_0807E0B8, // 8 + sub_0807E0CC, // 9 + sub_0807E0E0, // 10 + sub_0807E10C, // 11 + sub_0807E124, // 12 + sub_0807E148, // 13 + sub_0807E158, // 14 + sub_0807E188, // 15 + sub_0807E1D8, // 16 + sub_0807E4AC, // defined out of order 17 + sub_0807E200, // 18 + sub_0807E220, // 19 + sub_0807E240, // 20 + sub_0807E260, // 21 + sub_0807E280, // 22 + sub_0807E2A8, // 23 + sub_0807E2E4, // 24 + sub_0807E30C, // 25 + sub_0807E390, // 26 + sub_0807E3BC, // 27 + sub_0807E3E8, // 28 + sub_0807E40C, // 29 + sub_0807E42C, // 30 + sub_0807E48C, // 31 + sub_0807E4CC, // 32 + sub_0807E4EC, // 33 + sub_0807E514, // 34 + sub_0807E538, // 35 + sub_0807E564, // 36 + sub_0807E584, // 37 + sub_0807E5A0, // 38 + sub_0807E5CC, // 39 + sub_0807E5F8, // 40 + sub_0807E610, // 41 + sub_0807E628, // 42 + sub_0807E634, // 43 + sub_0807E644, // 44 + sub_0807E650, // 45 + sub_0807E65C, // 46 + sub_0807E668, // 47 + sub_0807E674, // 48 + sub_0807E680, // 49 + sub_0807E690, // 50 + sub_0807E6AC, // 51 + sub_0807E6DC, // 52 + sub_0807E700, // 53 + sub_0807E72C, // 54 + sub_0807E75C, // 55 + sub_0807E778, // 56 + sub_0807E788, // 57 + sub_0807E79C, // 58 + nullsub_508, // 59 + sub_0807E7B0, // 60 + sub_0807E7C4, // 61 + sub_0807E7D8, // 62 + sub_0807E7EC, // 63 + sub_0807E800, // 64 + sub_0807E80C, // 65 + sub_0807E858, // 66 + sub_0807E864, // 67 + sub_0807E878, // 68 + sub_0807E888, // 69 + sub_0807E898, // 70 + sub_0807E8C4, // 71 + sub_0807E8D4, // 72 + sub_0807E8E4, // 73 + sub_0807E8E4, // 74// duplicate + sub_0807E8E4, // 75// duplicate + sub_0807E8E4, // 76// duplicate + sub_0807E908, // 77 + sub_0807E914, // 78 + sub_0807E924, // 79 + sub_0807E930, // 80 + sub_0807E944, // 81 + sub_0807E974, // 82 + sub_0807E9D4, // 83 + sub_0807E9DC, // 84 + sub_0807E9E4, // 85 + sub_0807E9F0, // 86 + sub_0807EA4C, // 87 + sub_0807EA88, // 88 + sub_0807EA94, // 89 + sub_0807EAB4, // 90 + sub_0807EAC0, // 91 + sub_0807EAD0, // 92 + sub_0807EAF0, // 93 + sub_0807EB18, // 94 + sub_0807EB28, // 95 + sub_0807EB38, // 96 + sub_0807EB44, // 97 + sub_0807EB4C, // 98 + sub_0807EB74, // 99 + sub_0807EB8C, // 100 + sub_0807EBA8, // 101 + sub_0807EBB0, // 102 + sub_0807EBC0, // 103 + sub_0807EBC8, // 104 + sub_0807EBD8, // 105 + sub_0807EBF4, // 106 + sub_0807EC08, // 107 + nullsub_509, // 108 + sub_0807EC1C, // 109 + sub_0807EC64, // 110 + sub_0807EC94, // 111 + sub_0807ECC4, // 112 + sub_0807ECF4, // 113 + sub_0807ED24, // 114 + sub_0807EDD4, // 115 + sub_0807EE04, // 116 + sub_0807EE30, // 117 + sub_0807EEB4, // 118 + sub_0807EEF4, // 119 + sub_0807EF3C, // 120 + sub_0807EF80, // 121 + sub_0807EF90, // 122 + sub_0807EFA0, // 123 + sub_0807EFAC, // 124 + sub_0807EFD4, // 125 + sub_0807EFE4, // 126 + sub_0807EFF4, // 127 + sub_0807F004, // 128 + sub_0807F010, // 129 + sub_0807F034, // 130 + sub_0807F050, // 131 + sub_0807F060, // 132 + sub_0807F078, // 133 + sub_0807F088, // 134 + sub_0807F098, // 135 + sub_0807F0A4, // 136 + sub_0807F0B4, // 137 + sub_0807F0C8 // 138 }; extern const u16 gUnk_08016984; @@ -198,7 +315,7 @@ ScriptExecutionContext* CreateScriptExecutionContext(void) { context = gScriptExecutionContextArray; do { - if (context->unk_00 == 0) { + if (context->unk_00.raw == 0) { return context; } context++; @@ -210,20 +327,21 @@ void DestroyScriptExecutionContext(ScriptExecutionContext* context) { MemClear32(context, sizeof(ScriptExecutionContext)); } -ScriptExecutionContext* StartCutscene(Entity* entity, u16* unk_2) { +ScriptExecutionContext* StartCutscene(Entity* entity, u16* scriptCode) { ScriptExecutionContext* context; context = CreateScriptExecutionContext(); if (context) { - sub_0807DAF0(entity, context, unk_2); + sub_0807DAF0(entity, context, scriptCode); } return context; } -void sub_0807DAF0(Entity* entity, ScriptExecutionContext* context, u16* unk1) { +// start script on entity +void sub_0807DAF0(Entity* entity, ScriptExecutionContext* context, u16* scriptCode) { entity->flags = entity->flags | 2; *(ScriptExecutionContext**)&entity->cutsceneBeh = context; - sub_0807DB88(context, unk1); + sub_0807DB88(context, scriptCode); } void UnloadCutsceneData(Entity* entity) { @@ -238,7 +356,7 @@ void StartPlayerScript(u16* unk1) { Entity* player; MemClear32(&gPlayerScriptExecutionContext, sizeof(gPlayerScriptExecutionContext)); - gPlayerScriptExecutionContext.unk_00 = unk1; + gPlayerScriptExecutionContext.unk_00.raw = unk1; player = &gPlayerEntity; *(ScriptExecutionContext**)&player->cutsceneBeh = &gPlayerScriptExecutionContext; gPlayerState.playerAction = 0x1c; @@ -254,14 +372,15 @@ ScriptExecutionContext* sub_0807DB68(Entity* entity, u16* unk1) { if (context) { entity->flags |= 2; *(ScriptExecutionContext**)&entity->field_0x3c = context; - context->unk_00 = unk1; + context->unk_00.raw = unk1; } return context; } -void sub_0807DB88(ScriptExecutionContext* context, u16* unk1) { +// reset ScriptExecutionContext and set new commands? +void sub_0807DB88(ScriptExecutionContext* context, u16* scriptCode) { MemClear32(context, sizeof(ScriptExecutionContext)); - context->unk_00 = unk1; + context->unk_00.raw = scriptCode; } void sub_0807DB98(Entity* entity, ScriptExecutionContext* context) { @@ -350,8 +469,9 @@ void sub_0807DD64(Entity* entity) { entity->field_0x82.HWORD = 0; } -void sub_0807DD80(Entity* entity, u16* unk1) { - sub_0807DB88(*(ScriptExecutionContext**)&entity->cutsceneBeh, unk1); +// Special script start for windTribespeople? +void sub_0807DD80(Entity* entity, u16* scriptCode) { + sub_0807DB88(*(ScriptExecutionContext**)&entity->cutsceneBeh, scriptCode); sub_0807DD64(entity); } @@ -361,16 +481,17 @@ void sub_0807DD94(Entity* entity, void (*function)(Entity*, ScriptExecutionConte sub_0807DE80(entity); } +// executeScript commandset, then call the function (or sub_0807DB98 if NULL), then delete if no next entity void sub_0807DDAC(Entity* entity, void (*function)(Entity*, ScriptExecutionContext*)) { - ScriptExecutionContext** piVar1; + ScriptExecutionContext** context; - piVar1 = (ScriptExecutionContext**)&entity->cutsceneBeh; - if (*piVar1) { - ExecuteScriptCommandSet(entity, *piVar1); + context = (ScriptExecutionContext**)&entity->cutsceneBeh; + if (*context) { + ExecuteScriptCommandSet(entity, *context); if (function) { - function(entity, *piVar1); + function(entity, *context); } else { - sub_0807DB98(entity, *piVar1); + sub_0807DB98(entity, *context); } if (!entity->next) { DeleteThisEntity(); @@ -452,7 +573,7 @@ void sub_0807DEDC(Entity* entity, ScriptExecutionContext* context, u32 arg2, u32 context->unk_19 = 8; context->unk_08 |= 2; - context->unk_14 = 0; + context->compareResult = 0; context->unk_1C.HALF.HI = arg2; context->unk_20.HALF.HI = arg3; t0 = context->unk_1C.HALF.HI - entity->x.HALF.HI; @@ -482,123 +603,140 @@ void sub_0807DF50(void) { } void ExecuteScriptCommandSet(Entity* unk1, ScriptExecutionContext* unk2) { - if (!unk2->unk_00) + if (!unk2->unk_00.raw) return; if (unk2->unk_10) { unk2->unk_10--; } else { struct_02033280* tmp2 = &gUnk_02033280; - tmp2->unk_07 = 0; + // unk_07 bit 1 is being reset in each iteration + // but bit 2 is also tested, so it can be set to continue execution until you reset it + + tmp2->continueScriptExecutionFlags = 0; do { - u32 cmd = GetNextScriptCommandHalfword(unk2->unk_00); + u32 cmd = GetNextScriptCommandHalfword(unk2->unk_00.raw); u16* tmp; if (cmd == 0xFFFF) return; + // after cutting of 10 bits, this is the amount to advance the unk_00 pointer of ScriptExecutionContext unk2 tmp2->unk_06 = cmd >> 0xA; - tmp2->unk_04 = cmd & 0x3FF; - tmp = unk2->unk_00; - tmp2->unk_07 &= ~1; - gUnk_0811E524[tmp2->unk_04](unk1, unk2); - unk2->unk_00 += tmp2->unk_06; - if (tmp != unk2->unk_00) { + // lower 10 bits are the operationId (index to scriptOperations pointer array) + tmp2->operationId = cmd & 0x3FF; + tmp = unk2->unk_00.raw; + tmp2->continueScriptExecutionFlags &= ~1; + scriptOperations[tmp2->operationId](unk1, unk2); + unk2->unk_00.raw += tmp2->unk_06; + if (tmp != unk2->unk_00.raw) { // unk_00 was changed by tmp->unk_06 or the executed function -> set a flag + // to execute the next instruction or something? unk2->unk_18 = 0; } - } while (tmp2->unk_07 & 3); + } while (tmp2->continueScriptExecutionFlags & 3); } } void nullsub_507(Entity* unk1, ScriptExecutionContext* unk2) { } +// Start executing scripts void sub_0807E004(Entity* unk1, ScriptExecutionContext* unk2) { - gUnk_02033280.unk_07 |= 2; + gUnk_02033280.continueScriptExecutionFlags |= 2; } +// Stop executing scripts void sub_0807E014(Entity* unk1, ScriptExecutionContext* unk2) { - gUnk_02033280.unk_07 &= ~2; + gUnk_02033280.continueScriptExecutionFlags &= ~2; } void sub_0807E024(Entity* unk1, ScriptExecutionContext* unk2) { s16 tmp; - unk2->unk_00++; - tmp = GetNextScriptCommandHalfword(unk2->unk_00); - unk2->unk_00 += (tmp / 2); + // get metadata -> tmp + unk2->unk_00.raw++; + tmp = GetNextScriptCommandHalfword(unk2->unk_00.raw); + unk2->unk_00.raw += (tmp / 2); gUnk_02033280.unk_06 = 0; } +// if void sub_0807E050(Entity* unk1, ScriptExecutionContext* unk2) { - if (unk2->unk_14) { + if (unk2->compareResult) { sub_0807E024(unk1, unk2); } } +// if not void sub_0807E064(Entity* unk1, ScriptExecutionContext* unk2) { - if (!unk2->unk_14) { + if (!unk2->compareResult) { sub_0807E024(unk1, unk2); } } void sub_0807E078(Entity* unk1, ScriptExecutionContext* unk2) { if (gUnk_02033280.unk_06 > unk2->unk_04) { - unk2->unk_00 += unk2->unk_04; + unk2->unk_00.raw += unk2->unk_04; sub_0807E024(unk1, unk2); } } void sub_0807E0A0(Entity* unk1, ScriptExecutionContext* unk2) { - unk2->unk_00 = (u16*)GetNextScriptCommandWordAfterCommandMetadata(unk2->unk_00); + unk2->unk_00.raw = (u16*)GetNextScriptCommandWordAfterCommandMetadata(unk2->unk_00.raw); gUnk_02033280.unk_06 = 0; } +// if void sub_0807E0B8(Entity* unk1, ScriptExecutionContext* unk2) { - if (unk2->unk_14) { + if (unk2->compareResult) { sub_0807E0A0(unk1, unk2); } } +// if not void sub_0807E0CC(Entity* unk1, ScriptExecutionContext* unk2) { - if (!unk2->unk_14) { + if (!unk2->compareResult) { sub_0807E0A0(unk1, unk2); } } void sub_0807E0E0(Entity* unk1, ScriptExecutionContext* unk2) { if (gUnk_02033280.unk_06 > (unk2->unk_04 << 1) + 1) { - unk2->unk_00 += unk2->unk_04 << 1; + unk2->unk_00.raw += unk2->unk_04 << 1; sub_0807E0A0(unk1, unk2); } } +// Execute function via pointer void sub_0807E10C(Entity* unk1, ScriptExecutionContext* unk2) { - ((void (*)(Entity*, ScriptExecutionContext*))GetNextScriptCommandWordAfterCommandMetadata(unk2->unk_00))(unk1, - unk2); + ((void (*)(Entity*, ScriptExecutionContext*))GetNextScriptCommandWordAfterCommandMetadata(unk2->unk_00.raw))(unk1, + unk2); } +// Execute function via pointer but set context->unk_04 to some meta/cmd before? void sub_0807E124(Entity* unk1, ScriptExecutionContext* unk2) { void (*tmp)(Entity*, ScriptExecutionContext*) = - (void (*)(Entity*, ScriptExecutionContext*))GetNextScriptCommandWordAfterCommandMetadata(unk2->unk_00); - unk2->unk_04 = GetNextScriptCommandWord(unk2->unk_00 + 3); + (void (*)(Entity*, ScriptExecutionContext*))GetNextScriptCommandWordAfterCommandMetadata(unk2->unk_00.raw); + unk2->unk_04 = GetNextScriptCommandWord(unk2->unk_00.raw + 3); tmp(unk1, unk2); } void sub_0807E148(Entity* unk1, ScriptExecutionContext* unk2) { - LoadRoomEntityList(GetNextScriptCommandWordAfterCommandMetadata(unk2->unk_00)); + LoadRoomEntityList(GetNextScriptCommandWordAfterCommandMetadata(unk2->unk_00.raw)); } +// compare ??? void sub_0807E158(Entity* unk1, ScriptExecutionContext* unk2) { - u32 tmp = GetNextScriptCommandWordAfterCommandMetadata(unk2->unk_00); + u32 tmp = GetNextScriptCommandWordAfterCommandMetadata(unk2->unk_00.raw); u32 tmp2 = 0; u32 tmp3 = gUnk_02033280.unk_00; if ((tmp3 & tmp) == tmp) tmp2 = 1; - unk2->unk_14 = tmp2; + unk2->compareResult = tmp2; gUnk_02033280.unk_00 = tmp3 & ~tmp; - gUnk_02033280.unk_07 |= 1; + gUnk_02033280.continueScriptExecutionFlags |= 1; } +// different compare functions (dungeon map, dungeon compass, dungeon big key, dungeon small keys, inventory value) void sub_0807E188(Entity* unk1, ScriptExecutionContext* unk2) { u32 tmp; - u32 tmp2 = GetNextScriptCommandHalfwordAfterCommandMetadata(unk2->unk_00); + u32 tmp2 = GetNextScriptCommandHalfwordAfterCommandMetadata(unk2->unk_00.raw); switch (tmp2) { case 0x53: tmp = sub_08052734(); @@ -615,66 +753,75 @@ void sub_0807E188(Entity* unk1, ScriptExecutionContext* unk2) { default: tmp = GetInventoryValue(tmp2); } - unk2->unk_14 = tmp; - gUnk_02033280.unk_07 |= 1; + unk2->compareResult = tmp; + gUnk_02033280.continueScriptExecutionFlags |= 1; } +// compare GetInventoryValue(meta) == 2 void sub_0807E1D8(Entity* unk1, ScriptExecutionContext* unk2) { - unk2->unk_14 = GetInventoryValue(unk2->unk_00[1]) == 2; - gUnk_02033280.unk_07 |= 1; + unk2->compareResult = GetInventoryValue(unk2->unk_00.raw[1]) == 2; + gUnk_02033280.continueScriptExecutionFlags |= 1; } +// compare CheckLocalFlag void sub_0807E200(Entity* unk1, ScriptExecutionContext* unk2) { - unk2->unk_14 = CheckLocalFlag(unk2->unk_00[1]); - gUnk_02033280.unk_07 |= 1; + unk2->compareResult = CheckLocalFlag(unk2->unk_00.raw[1]); + gUnk_02033280.continueScriptExecutionFlags |= 1; } +// compare CheckLocalFlagByOffset(metadata1, metadata2) void sub_0807E220(Entity* unk1, ScriptExecutionContext* unk2) { - unk2->unk_14 = CheckLocalFlagByOffset(unk2->unk_00[1], unk2->unk_00[2]); - gUnk_02033280.unk_07 |= 1; + unk2->compareResult = CheckLocalFlagByOffset(unk2->unk_00.raw[1], unk2->unk_00.raw[2]); + gUnk_02033280.continueScriptExecutionFlags |= 1; } +// compare CheckGlobalFlag void sub_0807E240(Entity* unk1, ScriptExecutionContext* unk2) { - unk2->unk_14 = CheckGlobalFlag(GetNextScriptCommandHalfwordAfterCommandMetadata(unk2->unk_00)); - gUnk_02033280.unk_07 |= 1; + unk2->compareResult = CheckGlobalFlag(GetNextScriptCommandHalfwordAfterCommandMetadata(unk2->unk_00.raw)); + gUnk_02033280.continueScriptExecutionFlags |= 1; } +// compare CheckRoomFlag void sub_0807E260(Entity* unk1, ScriptExecutionContext* unk2) { - unk2->unk_14 = CheckRoomFlag(unk2->unk_00[1]); - gUnk_02033280.unk_07 |= 1; + unk2->compareResult = CheckRoomFlag(unk2->unk_00.raw[1]); + gUnk_02033280.continueScriptExecutionFlags |= 1; } +// compare checkPlayerInRegion (square?) void sub_0807E280(Entity* unk1, ScriptExecutionContext* unk2) { u32 x, y, width, height; - width = unk2->unk_00[3]; + width = unk2->unk_00.raw[3]; height = width >> 8; width &= 0xFF; - x = unk2->unk_00[1]; - y = unk2->unk_00[2]; - unk2->unk_14 = CheckPlayerInRegion(x, y, width, height); - gUnk_02033280.unk_07 |= 1; + x = unk2->unk_00.raw[1]; + y = unk2->unk_00.raw[2]; + unk2->compareResult = CheckPlayerInRegion(x, y, width, height); + gUnk_02033280.continueScriptExecutionFlags |= 1; } +// compare CheckPlayerInRegion (room?) void sub_0807E2A8(Entity* unk1, ScriptExecutionContext* unk2) { u32 x, y, width, height; - width = unk2->unk_00[1] & 0xFF; - height = unk2->unk_00[1] >> 8; + width = unk2->unk_00.raw[1] & 0xFF; + height = unk2->unk_00.raw[1] >> 8; x = unk1->x.HALF.HI - gRoomControls.roomOriginX; y = unk1->y.HALF.HI - gRoomControls.roomOriginY; - unk2->unk_14 = CheckPlayerInRegion(x, y, width, height); - gUnk_02033280.unk_07 |= 1; + unk2->compareResult = CheckPlayerInRegion(x, y, width, height); + gUnk_02033280.continueScriptExecutionFlags |= 1; } +// compare and reset Entity->interactType void sub_0807E2E4(Entity* unk1, ScriptExecutionContext* unk2) { if (unk1->interactType) { unk1->interactType = 0; - unk2->unk_14 = 1; + unk2->compareResult = 1; } else { - unk2->unk_14 = 0; + unk2->compareResult = 0; } - gUnk_02033280.unk_07 |= 1; + gUnk_02033280.continueScriptExecutionFlags |= 1; } +// compare and reset interactType while setting animationState ?? void sub_0807E30C(Entity* unk1, ScriptExecutionContext* unk2) { if ((unk2->unk_1A & 0xF) == 0 && (gPlayerState.flags.all & 0x80) == 0 && sub_080041A0(unk1, &gPlayerEntity, 0x28, 0x28)) { @@ -683,160 +830,175 @@ void sub_0807E30C(Entity* unk1, ScriptExecutionContext* unk2) { unk2->unk_1A++; if (unk1->interactType) { unk1->interactType = 0; - unk2->unk_14 = 1; + unk2->compareResult = 1; unk1->animationState = sub_0806F5B0(GetFacingDirection(unk1, &gPlayerEntity)); } else { - unk2->unk_14 = 0; + unk2->compareResult = 0; } - gUnk_02033280.unk_07 |= 1; + gUnk_02033280.continueScriptExecutionFlags |= 1; } +// compare enough rupees void sub_0807E390(Entity* unk1, ScriptExecutionContext* unk2) { - unk2->unk_14 = (unk2->unk_00[1] <= gSave.stats.rupees); - gUnk_02033280.unk_07 |= 1; + unk2->compareResult = (unk2->unk_00.raw[1] <= gSave.stats.rupees); + gUnk_02033280.continueScriptExecutionFlags |= 1; } +// compare enough ??? void sub_0807E3BC(Entity* unk1, ScriptExecutionContext* unk2) { - unk2->unk_14 = (unk2->unk_00[1] <= gSave.stats.field_0x1a); - gUnk_02033280.unk_07 |= 1; + unk2->compareResult = (unk2->unk_00.raw[1] <= gSave.stats.field_0x1a); + gUnk_02033280.continueScriptExecutionFlags |= 1; } +// compare ??? void sub_0807E3E8(Entity* unk1, ScriptExecutionContext* unk2) { - unk2->unk_14 = !gUnk_02000040.unk_01; - gUnk_02033280.unk_07 |= 1; + unk2->compareResult = !gUnk_02000040.unk_01; + gUnk_02033280.continueScriptExecutionFlags |= 1; } +// compare CheckKinstoneFused void sub_0807E40C(Entity* unk1, ScriptExecutionContext* unk2) { - unk2->unk_14 = CheckKinstoneFused(unk2->unk_00[1]); - gUnk_02033280.unk_07 |= 1; + unk2->compareResult = CheckKinstoneFused(unk2->unk_00.raw[1]); + gUnk_02033280.continueScriptExecutionFlags |= 1; } +// compare enough rupees and remove rupees ?? void sub_0807E42C(Entity* unk1, ScriptExecutionContext* unk2) { u32 tmp, tmp2; s32 tmp3; - tmp = unk2->unk_00[1]; - tmp2 = unk2->unk_00[2]; + tmp = unk2->unk_00.raw[1]; + tmp2 = unk2->unk_00.raw[2]; if (!tmp) { tmp = gRoomVars.itemForSaleIndex; tmp2 = gRoomVars.field_0x7; } tmp3 = sub_08053FE0(tmp); - unk2->unk_14 = (tmp3 <= gSave.stats.rupees); - if (unk2->unk_14) { + unk2->compareResult = (tmp3 <= gSave.stats.rupees); + if (unk2->compareResult) { ModRupees(-tmp3); sub_080A7C18(tmp, tmp2, 0); gRoomVars.itemForSaleIndex = 0; gRoomVars.field_0x7 = 0; } - gUnk_02033280.unk_07 |= 1; + gUnk_02033280.continueScriptExecutionFlags |= 1; } +// compare ?? void sub_0807E48C(Entity* unk1, ScriptExecutionContext* unk2) { - unk2->unk_14 = sub_080544DC(unk2->unk_00[1]); - gUnk_02033280.unk_07 |= 1; + unk2->compareResult = sub_080544DC(unk2->unk_00.raw[1]); + gUnk_02033280.continueScriptExecutionFlags |= 1; } +// compare itemForSaleIndex?? void sub_0807E4AC(Entity* unk1, ScriptExecutionContext* unk2) { - unk2->unk_14 = !!gRoomVars.itemForSaleIndex; - gUnk_02033280.unk_07 |= 1; + unk2->compareResult = !!gRoomVars.itemForSaleIndex; + gUnk_02033280.continueScriptExecutionFlags |= 1; } +// compare ?? void sub_0807E4CC(Entity* unk1, ScriptExecutionContext* unk2) { - unk2->unk_14 = !!(unk2->unk_04 & unk2->unk_00[1]); - gUnk_02033280.unk_07 |= 1; + unk2->compareResult = !!(unk2->unk_04 & unk2->unk_00.raw[1]); + gUnk_02033280.continueScriptExecutionFlags |= 1; } +// compare meta & unk_04 ?? void sub_0807E4EC(Entity* unk1, ScriptExecutionContext* unk2) { - u32 tmp = unk2->unk_00[1]; - unk2->unk_14 = tmp == (tmp & unk2->unk_04); - gUnk_02033280.unk_07 |= 1; + u32 tmp = unk2->unk_00.raw[1]; + unk2->compareResult = tmp == (tmp & unk2->unk_04); + gUnk_02033280.continueScriptExecutionFlags |= 1; } +// compare meta == unk_04 ?? void sub_0807E514(Entity* unk1, ScriptExecutionContext* unk2) { - u32 tmp = unk2->unk_00[1]; - unk2->unk_14 = tmp == unk2->unk_04; - gUnk_02033280.unk_07 |= 1; + u32 tmp = unk2->unk_00.raw[1]; + unk2->compareResult = tmp == unk2->unk_04; + gUnk_02033280.continueScriptExecutionFlags |= 1; } +// compare player state flags ??? void sub_0807E538(Entity* unk1, ScriptExecutionContext* unk2) { - unk2->unk_14 = !!(GetNextScriptCommandWordAfterCommandMetadata(unk2->unk_00) & gPlayerState.flags.all); - gUnk_02033280.unk_07 |= 1; + unk2->compareResult = !!(GetNextScriptCommandWordAfterCommandMetadata(unk2->unk_00.raw) & gPlayerState.flags.all); + gUnk_02033280.continueScriptExecutionFlags |= 1; } +// compare player state flags ??? void sub_0807E564(Entity* unk1, ScriptExecutionContext* unk2) { - unk2->unk_14 = (gPlayerState.flags.all >> 7) & 1; - gUnk_02033280.unk_07 |= 1; + unk2->compareResult = (gPlayerState.flags.all >> 7) & 1; + gUnk_02033280.continueScriptExecutionFlags |= 1; } +// compare entity height != 0 void sub_0807E584(Entity* unk1, ScriptExecutionContext* unk2) { - unk2->unk_14 = unk1->height.WORD != 0; - gUnk_02033280.unk_07 |= 1; + unk2->compareResult = unk1->height.WORD != 0; + gUnk_02033280.continueScriptExecutionFlags |= 1; } +// compare meta == player.action void sub_0807E5A0(Entity* unk1, ScriptExecutionContext* unk2) { - unk2->unk_14 = unk2->unk_00[1] == gPlayerEntity.action; - gUnk_02033280.unk_07 |= 1; + unk2->compareResult = unk2->unk_00.raw[1] == gPlayerEntity.action; + gUnk_02033280.continueScriptExecutionFlags |= 1; } +// compare meta == player.animationState void sub_0807E5CC(Entity* unk1, ScriptExecutionContext* unk2) { - unk2->unk_14 = unk2->unk_00[1] == gPlayerEntity.animationState; - gUnk_02033280.unk_07 |= 1; + unk2->compareResult = unk2->unk_00.raw[1] == gPlayerEntity.animationState; + gUnk_02033280.continueScriptExecutionFlags |= 1; } void sub_0807E5F8(Entity* unk1, ScriptExecutionContext* unk2) { - gUnk_02033280.unk_00 |= GetNextScriptCommandWordAfterCommandMetadata(unk2->unk_00); + gUnk_02033280.unk_00 |= GetNextScriptCommandWordAfterCommandMetadata(unk2->unk_00.raw); } void sub_0807E610(Entity* unk1, ScriptExecutionContext* unk2) { - gUnk_02033280.unk_00 &= ~GetNextScriptCommandWordAfterCommandMetadata(unk2->unk_00); + gUnk_02033280.unk_00 &= ~GetNextScriptCommandWordAfterCommandMetadata(unk2->unk_00.raw); } void sub_0807E628(Entity* unk1, ScriptExecutionContext* unk2) { - SetLocalFlag(unk2->unk_00[1]); + SetLocalFlag(unk2->unk_00.raw[1]); } void sub_0807E634(Entity* unk1, ScriptExecutionContext* unk2) { - SetLocalFlagByOffset(unk2->unk_00[1], unk2->unk_00[2]); + SetLocalFlagByOffset(unk2->unk_00.raw[1], unk2->unk_00.raw[2]); } void sub_0807E644(Entity* unk1, ScriptExecutionContext* unk2) { - ClearLocalFlag(unk2->unk_00[1]); + ClearLocalFlag(unk2->unk_00.raw[1]); } void sub_0807E650(Entity* unk1, ScriptExecutionContext* unk2) { - SetGlobalFlag(unk2->unk_00[1]); + SetGlobalFlag(unk2->unk_00.raw[1]); } void sub_0807E65C(Entity* unk1, ScriptExecutionContext* unk2) { - ClearGlobalFlag(unk2->unk_00[1]); + ClearGlobalFlag(unk2->unk_00.raw[1]); } void sub_0807E668(Entity* unk1, ScriptExecutionContext* unk2) { - SetRoomFlag(unk2->unk_00[1]); + SetRoomFlag(unk2->unk_00.raw[1]); } void sub_0807E674(Entity* unk1, ScriptExecutionContext* unk2) { - ClearRoomFlag(unk2->unk_00[1]); + ClearRoomFlag(unk2->unk_00.raw[1]); } void sub_0807E680(Entity* unk1, ScriptExecutionContext* unk2) { - unk2->unk_10 = GetNextScriptCommandHalfwordAfterCommandMetadata(unk2->unk_00); + unk2->unk_10 = GetNextScriptCommandHalfwordAfterCommandMetadata(unk2->unk_00.raw); } void sub_0807E690(Entity* unk1, ScriptExecutionContext* unk2) { - u32 tmp = GetNextScriptCommandWordAfterCommandMetadata(unk2->unk_00); + u32 tmp = GetNextScriptCommandWordAfterCommandMetadata(unk2->unk_00.raw); if ((gUnk_02033280.unk_00 & tmp) != tmp) { gUnk_02033280.unk_06 = 0; } } void sub_0807E6AC(Entity* unk1, ScriptExecutionContext* unk2) { - u32 tmp = GetNextScriptCommandWordAfterCommandMetadata(unk2->unk_00); + u32 tmp = GetNextScriptCommandWordAfterCommandMetadata(unk2->unk_00.raw); if ((gUnk_02033280.unk_00 & tmp) != tmp) { gUnk_02033280.unk_06 = 0; } else { gUnk_02033280.unk_00 &= ~tmp; - gUnk_02033280.unk_07 |= 1; + gUnk_02033280.continueScriptExecutionFlags |= 1; } } @@ -850,7 +1012,7 @@ void sub_0807E6DC(Entity* unk1, ScriptExecutionContext* unk2) { void sub_0807E700(Entity* unk1, ScriptExecutionContext* unk2) { if (gPlayerEntity.action != 0x17) { - gUnk_02033280.unk_07 |= 1; + gUnk_02033280.continueScriptExecutionFlags |= 1; } else { gUnk_02033280.unk_06 = 0; } @@ -860,7 +1022,7 @@ void sub_0807E72C(Entity* unk1, ScriptExecutionContext* unk2) { if (gRoomControls.unk6 & 4) { gUnk_02033280.unk_06 = 0; } else { - gUnk_02033280.unk_07 |= 1; + gUnk_02033280.continueScriptExecutionFlags |= 1; } } @@ -871,11 +1033,11 @@ void sub_0807E75C(Entity* unk1, ScriptExecutionContext* unk2) { } void sub_0807E778(Entity* unk1, ScriptExecutionContext* unk2) { - gUnk_02033280.unk_08 = unk2->unk_00[1]; + gUnk_02033280.unk_08 = unk2->unk_00.raw[1]; } void sub_0807E788(Entity* unk1, ScriptExecutionContext* unk2) { - gFadeControl.field_0x4 = GetNextScriptCommandWordAfterCommandMetadata(unk2->unk_00); + gFadeControl.field_0x4 = GetNextScriptCommandWordAfterCommandMetadata(unk2->unk_00.raw); } void sub_0807E79C(Entity* unk1, ScriptExecutionContext* unk2) { @@ -923,7 +1085,7 @@ void sub_0807E818(u32 unk1) { } void sub_0807E858(Entity* unk1, ScriptExecutionContext* unk2) { - sub_08050038(unk2->unk_00[1]); + sub_08050038(unk2->unk_00.raw[1]); } void sub_0807E864(Entity* unk1, ScriptExecutionContext* unk2) { @@ -940,7 +1102,7 @@ void sub_0807E888(Entity* unk1, ScriptExecutionContext* unk2) { } void sub_0807E898(Entity* unk1, ScriptExecutionContext* unk2) { - u32 tmp = GetNextScriptCommandWordAfterCommandMetadata(unk2->unk_00); + u32 tmp = GetNextScriptCommandWordAfterCommandMetadata(unk2->unk_00.raw); gPlayerState.playerAction = tmp; gPlayerState.field_0x38 = tmp >> 8; gPlayerState.field_0x39 = tmp >> 0x10; @@ -948,26 +1110,26 @@ void sub_0807E898(Entity* unk1, ScriptExecutionContext* unk2) { } void sub_0807E8C4(Entity* unk1, ScriptExecutionContext* unk2) { - StartPlayerScript((u16*)GetNextScriptCommandWordAfterCommandMetadata(unk2->unk_00)); + StartPlayerScript((u16*)GetNextScriptCommandWordAfterCommandMetadata(unk2->unk_00.raw)); } void sub_0807E8D4(Entity* unk1, ScriptExecutionContext* unk2) { - gPlayerState.field_0x8 = unk2->unk_00[1]; + gPlayerState.field_0x8 = unk2->unk_00.raw[1]; } void sub_0807E8E4(Entity* unk1, ScriptExecutionContext* unk2) { u32 tmp = (gUnk_08016984 & 0x3FF); u32 tmp2; - gPlayerEntity.animationState = tmp2 = (unk2->unk_00[0] - tmp) << 1; + gPlayerEntity.animationState = tmp2 = (unk2->unk_00.raw[0] - tmp) << 1; } void sub_0807E908(Entity* unk1, ScriptExecutionContext* unk2) { - unk1->action = unk2->unk_00[1]; + unk1->action = unk2->unk_00.raw[1]; unk1->previousActionFlag = 0; } void sub_0807E914(Entity* unk1, ScriptExecutionContext* unk2) { - unk2->unk_04 = GetNextScriptCommandWordAfterCommandMetadata(unk2->unk_00); + unk2->unk_04 = GetNextScriptCommandWordAfterCommandMetadata(unk2->unk_00.raw); } void sub_0807E924(Entity* unk1, ScriptExecutionContext* unk2) { @@ -976,14 +1138,14 @@ void sub_0807E924(Entity* unk1, ScriptExecutionContext* unk2) { } void sub_0807E930(Entity* unk1, ScriptExecutionContext* unk2) { - unk1->field_0x80.HWORD = unk2->unk_00[1]; - InitAnimationForceUpdate(unk1, unk2->unk_00[1]); + unk1->field_0x80.HWORD = unk2->unk_00.raw[1]; + InitAnimationForceUpdate(unk1, unk2->unk_00.raw[1]); } void sub_0807E944(Entity* unk1, ScriptExecutionContext* unk2) { if (unk1->interactType) { unk1->interactType = 0; - gUnk_02033280.unk_07 |= 1; + gUnk_02033280.continueScriptExecutionFlags |= 1; } else { gUnk_02033280.unk_06 = 0; } @@ -1000,7 +1162,7 @@ void sub_0807E974(Entity* unk1, ScriptExecutionContext* unk2) { break; unk1->interactType = 0; unk2->unk_18++; - TextboxNoOverlapFollow(unk2->unk_00[1]); + TextboxNoOverlapFollow(unk2->unk_00.raw[1]); break; case 1: if (gTextBox.doTextBox & 0x7F) @@ -1021,9 +1183,10 @@ void sub_0807E9DC(Entity* unk1, ScriptExecutionContext* unk2) { } void sub_0807E9E4(Entity* unk1, ScriptExecutionContext* unk2) { - sub_08078784(unk1, unk2->unk_00[1]); + sub_08078784(unk1, unk2->unk_00.raw[1]); } +// compare and do stuff? void sub_0807E9F0(Entity* unk1, ScriptExecutionContext* unk2) { u32 tmp; sub_0801E00C(); @@ -1032,10 +1195,10 @@ void sub_0807E9F0(Entity* unk1, ScriptExecutionContext* unk2) { case 2: gPlayerState.field_0x8b = 3; gUnk_02034490[0] = tmp; - unk2->unk_14 = tmp; + unk2->compareResult = tmp; break; case 1: - unk2->unk_14 = 0; + unk2->compareResult = 0; break; default: goto lbl; @@ -1053,14 +1216,14 @@ void sub_0807EA4C(Entity* unk1, ScriptExecutionContext* unk2) { if (unk1->interactType == 2) { sub_0801DFB4(unk1, 0, 0, 0); unk1->interactType = 0; - gUnk_02033280.unk_07 |= 1; + gUnk_02033280.continueScriptExecutionFlags |= 1; } else { gUnk_02033280.unk_06 = 0; } } void sub_0807EA88(Entity* unk1, ScriptExecutionContext* unk2) { - sub_08078790(unk1, unk2->unk_00[1]); + sub_08078790(unk1, unk2->unk_00.raw[1]); } void sub_0807EA94(Entity* unk1, ScriptExecutionContext* unk2) { @@ -1070,22 +1233,22 @@ void sub_0807EA94(Entity* unk1, ScriptExecutionContext* unk2) { } void sub_0807EAB4(Entity* unk1, ScriptExecutionContext* unk2) { - TextboxNoOverlapFollow(unk2->unk_00[1]); + TextboxNoOverlapFollow(unk2->unk_00.raw[1]); } void sub_0807EAC0(Entity* unk1, ScriptExecutionContext* unk2) { - TextboxNoOverlap(unk2->unk_00[1], unk1); + TextboxNoOverlap(unk2->unk_00.raw[1], unk1); } void sub_0807EAD0(Entity* unk1, ScriptExecutionContext* unk2) { - TextboxNoOverlapFollow(unk2->unk_00[1]); + TextboxNoOverlapFollow(unk2->unk_00.raw[1]); gTextBox.textWindowPosX = 1; - gTextBox.textWindowPosY = unk2->unk_00[2]; + gTextBox.textWindowPosY = unk2->unk_00.raw[2]; } void sub_0807EAF0(Entity* unk1, ScriptExecutionContext* unk2) { if (gUnk_02033280.unk_06 > unk2->unk_04) { - u16* tmp = unk2->unk_00 + unk2->unk_04; + u16* tmp = unk2->unk_00.raw + unk2->unk_04; TextboxNoOverlapFollow(tmp[1]); } else { TextboxNoOverlapFollow(0); @@ -1097,7 +1260,7 @@ void sub_0807EB18(Entity* unk1, ScriptExecutionContext* unk2) { } void sub_0807EB28(Entity* unk1, ScriptExecutionContext* unk2) { - sub_08078AA8(unk2->unk_00[1], 0); + sub_08078AA8(unk2->unk_00.raw[1], 0); } void sub_0807EB38(Entity* unk1, ScriptExecutionContext* unk2) { @@ -1105,12 +1268,12 @@ void sub_0807EB38(Entity* unk1, ScriptExecutionContext* unk2) { } void sub_0807EB44(Entity* unk1, ScriptExecutionContext* unk2) { - unk1->animationState = unk2->unk_00[1]; + unk1->animationState = unk2->unk_00.raw[1]; } void sub_0807EB4C(Entity* unk1, ScriptExecutionContext* unk2) { - unk1->animationState = sub_0806F5B0( - sub_080045B4(unk1, unk2->unk_00[1] + gRoomControls.roomOriginX, unk2->unk_00[2] + gRoomControls.roomOriginY)); + unk1->animationState = sub_0806F5B0(sub_080045B4(unk1, unk2->unk_00.raw[1] + gRoomControls.roomOriginX, + unk2->unk_00.raw[2] + gRoomControls.roomOriginY)); } void sub_0807EB74(Entity* unk1, ScriptExecutionContext* unk2) { @@ -1122,30 +1285,30 @@ void sub_0807EB8C(Entity* unk1, ScriptExecutionContext* unk2) { } void sub_0807EBA8(Entity* unk1, ScriptExecutionContext* unk2) { - unk1->direction = unk2->unk_00[1]; + unk1->direction = unk2->unk_00.raw[1]; } void sub_0807EBB0(Entity* unk1, ScriptExecutionContext* unk2) { - unk1->direction = unk2->unk_00[1]; + unk1->direction = unk2->unk_00.raw[1]; unk1->animationState = unk1->direction / 4; } void sub_0807EBC0(Entity* unk1, ScriptExecutionContext* unk2) { - unk1->nonPlanarMovement = unk2->unk_00[1]; + unk1->nonPlanarMovement = unk2->unk_00.raw[1]; } void sub_0807EBC8(Entity* unk1, ScriptExecutionContext* unk2) { - unk1->field_0x20 = GetNextScriptCommandWordAfterCommandMetadata(unk2->unk_00); + unk1->field_0x20 = GetNextScriptCommandWordAfterCommandMetadata(unk2->unk_00.raw); } void sub_0807EBD8(Entity* unk1, ScriptExecutionContext* unk2) { - unk1->x.HALF.HI = gRoomControls.roomOriginX + unk2->unk_00[1]; - unk1->y.HALF.HI = gRoomControls.roomOriginY + unk2->unk_00[2]; + unk1->x.HALF.HI = gRoomControls.roomOriginX + unk2->unk_00.raw[1]; + unk1->y.HALF.HI = gRoomControls.roomOriginY + unk2->unk_00.raw[2]; } void sub_0807EBF4(Entity* unk1, ScriptExecutionContext* unk2) { - unk1->x.HALF.HI += unk2->unk_00[1]; - unk1->y.HALF.HI += unk2->unk_00[2]; + unk1->x.HALF.HI += unk2->unk_00.raw[1]; + unk1->y.HALF.HI += unk2->unk_00.raw[2]; } void sub_0807EC08(Entity* unk1, ScriptExecutionContext* unk2) { @@ -1158,7 +1321,7 @@ void nullsub_509(Entity* unk1, ScriptExecutionContext* unk2) { void sub_0807EC1C(Entity* unk1, ScriptExecutionContext* unk2) { if (!unk2->unk_18) { unk2->unk_18 = 1; - unk2->unk_12 = unk2->unk_00[1]; + unk2->unk_12 = unk2->unk_00.raw[1]; unk2->unk_08 |= 2; } sub_0807EC44(unk1, unk2); @@ -1174,7 +1337,7 @@ void sub_0807EC44(Entity* unk1, ScriptExecutionContext* unk2) { void sub_0807EC64(Entity* unk1, ScriptExecutionContext* unk2) { if (!unk2->unk_18) { unk2->unk_18 = 1; - unk2->unk_12 = unk2->unk_00[1]; + unk2->unk_12 = unk2->unk_00.raw[1]; unk1->animationState = 0; unk1->direction = 0; unk2->unk_08 |= 2; @@ -1185,7 +1348,7 @@ void sub_0807EC64(Entity* unk1, ScriptExecutionContext* unk2) { void sub_0807EC94(Entity* unk1, ScriptExecutionContext* unk2) { if (!unk2->unk_18) { unk2->unk_18 = 1; - unk2->unk_12 = unk2->unk_00[1]; + unk2->unk_12 = unk2->unk_00.raw[1]; unk1->animationState = 2; unk1->direction = 8; unk2->unk_08 |= 2; @@ -1196,7 +1359,7 @@ void sub_0807EC94(Entity* unk1, ScriptExecutionContext* unk2) { void sub_0807ECC4(Entity* unk1, ScriptExecutionContext* unk2) { if (!unk2->unk_18) { unk2->unk_18 = 1; - unk2->unk_12 = unk2->unk_00[1]; + unk2->unk_12 = unk2->unk_00.raw[1]; unk1->animationState = 4; unk1->direction = 0x10; unk2->unk_08 |= 2; @@ -1207,7 +1370,7 @@ void sub_0807ECC4(Entity* unk1, ScriptExecutionContext* unk2) { void sub_0807ECF4(Entity* unk1, ScriptExecutionContext* unk2) { if (!unk2->unk_18) { unk2->unk_18 = 1; - unk2->unk_12 = unk2->unk_00[1]; + unk2->unk_12 = unk2->unk_00.raw[1]; unk1->animationState = 6; unk1->direction = 0x18; unk2->unk_08 |= 2; @@ -1219,20 +1382,20 @@ void sub_0807ED24(Entity* unk1, ScriptExecutionContext* unk2) { if (!unk2->unk_18) { s32 tmp, tmp2, tmp3; unk2->unk_18 = 1; - unk2->unk_12 = unk2->unk_00[3]; - tmp = unk2->unk_00[1]; + unk2->unk_12 = unk2->unk_00.raw[3]; + tmp = unk2->unk_00.raw[1]; tmp2 = unk1->x.HALF.HI - gRoomControls.roomOriginX; unk2->unk_1C.WORD = ((tmp - tmp2) << 0x10) / unk2->unk_12; - tmp = unk2->unk_00[2]; + tmp = unk2->unk_00.raw[2]; tmp3 = unk1->y.HALF.HI - gRoomControls.roomOriginY; unk2->unk_20.WORD = ((tmp - tmp3) << 0x10) / unk2->unk_12; - unk1->animationState = sub_0806F5B0(sub_080045B4(unk1, unk2->unk_00[1] + gRoomControls.roomOriginX, - unk2->unk_00[2] + gRoomControls.roomOriginY)); + unk1->animationState = sub_0806F5B0(sub_080045B4(unk1, unk2->unk_00.raw[1] + gRoomControls.roomOriginX, + unk2->unk_00.raw[2] + gRoomControls.roomOriginY)); unk2->unk_08 |= 2; } else { if (!--unk2->unk_12) { - unk1->x.HALF.HI = unk2->unk_00[1] + gRoomControls.roomOriginX; - unk1->y.HALF.HI = unk2->unk_00[2] + gRoomControls.roomOriginY; + unk1->x.HALF.HI = unk2->unk_00.raw[1] + gRoomControls.roomOriginX; + unk1->y.HALF.HI = unk2->unk_00.raw[2] + gRoomControls.roomOriginY; return; } unk1->x.WORD += unk2->unk_1C.WORD; @@ -1241,22 +1404,25 @@ void sub_0807ED24(Entity* unk1, ScriptExecutionContext* unk2) { gUnk_02033280.unk_06 = 0; } +// something else and an if not void sub_0807EDD4(Entity* unk1, ScriptExecutionContext* unk2) { if (!unk2->unk_18) { unk2->unk_18 = 1; sub_0807EE04(unk1, unk2); } sub_0807EE30(unk1, unk2); - if (!unk2->unk_14) { + if (!unk2->compareResult) { gUnk_02033280.unk_06 = 0; } } void sub_0807EE04(Entity* unk1, ScriptExecutionContext* unk2) { - sub_0807DEDC(unk1, unk2, unk2->unk_00[1] + gRoomControls.roomOriginX, unk2->unk_00[2] + gRoomControls.roomOriginY); - gUnk_02033280.unk_07 |= 1; + sub_0807DEDC(unk1, unk2, unk2->unk_00.raw[1] + gRoomControls.roomOriginX, + unk2->unk_00.raw[2] + gRoomControls.roomOriginY); + gUnk_02033280.continueScriptExecutionFlags |= 1; } +// something else and a compare void sub_0807EE30(Entity* unk1, ScriptExecutionContext* unk2) { s32 tmp, tmp2; if (!--unk2->unk_19) { @@ -1271,30 +1437,33 @@ void sub_0807EE30(Entity* unk1, ScriptExecutionContext* unk2) { if (tmp <= 0 && tmp2 <= 0) { unk1->x.HALF.HI = unk2->unk_1C.HALF.HI; unk1->y.HALF.HI = unk2->unk_20.HALF.HI; - unk2->unk_14 = 1; + unk2->compareResult = 1; } else { - unk2->unk_14 = 0; + unk2->compareResult = 0; } } +// another if not and ??? void sub_0807EEB4(Entity* unk1, ScriptExecutionContext* unk2) { - if (!unk2->unk_18) { + if (!unk2->unk_18) { // TODO unk_18 another compare flag? unk2->unk_18 = 1; sub_0807DEDC(unk1, unk2, gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI); } sub_0807EE30(unk1, unk2); - if (!unk2->unk_14) { - gUnk_02033280.unk_06 = 0; + if (!unk2->compareResult) { + gUnk_02033280.unk_06 = 0; // TODO research unk_06 } } +// another if not ??? void sub_0807EEF4(Entity* unk1, ScriptExecutionContext* unk2) { if (!unk2->unk_18) { unk2->unk_18 = 1; - sub_0807DEDC(unk1, unk2, unk1->x.HALF.HI + ((s16)unk2->unk_00[1]), unk1->y.HALF.HI + ((s16)unk2->unk_00[2])); + sub_0807DEDC(unk1, unk2, unk1->x.HALF.HI + ((s16)unk2->unk_00.raw[1]), + unk1->y.HALF.HI + ((s16)unk2->unk_00.raw[2])); } sub_0807EE30(unk1, unk2); - if (!unk2->unk_14) { + if (!unk2->compareResult) { gUnk_02033280.unk_06 = 0; } } @@ -1302,8 +1471,8 @@ void sub_0807EEF4(Entity* unk1, ScriptExecutionContext* unk2) { void sub_0807EF3C(Entity* unk1, ScriptExecutionContext* unk2) { if (!unk2->unk_18) { unk2->unk_18 = 1; - unk1->field_0x20 = ((s16)unk2->unk_00[1]) << 8; - unk2->unk_1C.HALF.LO = unk2->unk_00[2] << 8; + unk1->field_0x20 = ((s16)unk2->unk_00.raw[1]) << 8; + unk2->unk_1C.HALF.LO = unk2->unk_00.raw[2] << 8; sub_08003FC4(unk1, (u16)unk2->unk_1C.HALF.LO); } else { if (!sub_08003FC4(unk1, (u16)unk2->unk_1C.HALF.LO)) @@ -1313,27 +1482,27 @@ void sub_0807EF3C(Entity* unk1, ScriptExecutionContext* unk2) { } void sub_0807EF80(Entity* unk1, ScriptExecutionContext* unk2) { - unk2->unk_08 |= 1 << unk2->unk_00[1]; + unk2->unk_08 |= 1 << unk2->unk_00.raw[1]; } void sub_0807EF90(Entity* unk1, ScriptExecutionContext* unk2) { - unk2->unk_08 |= 1 << unk2->unk_00[1]; + unk2->unk_08 |= 1 << unk2->unk_00.raw[1]; } void sub_0807EFA0(Entity* unk1, ScriptExecutionContext* unk2) { - SoundReq(unk2->unk_00[1]); + SoundReq(unk2->unk_00.raw[1]); } void sub_0807EFAC(Entity* unk1, ScriptExecutionContext* unk2) { - if (unk2->unk_00[1] >= 100) { + if (unk2->unk_00.raw[1] >= 100) { SoundReq(gArea.musicIndex); } else { - SoundReq(unk2->unk_00[1]); + SoundReq(unk2->unk_00.raw[1]); } } void sub_0807EFD4(Entity* unk1, ScriptExecutionContext* unk2) { - SoundReq(GetNextScriptCommandWordAfterCommandMetadata(unk2->unk_00)); + SoundReq(GetNextScriptCommandWordAfterCommandMetadata(unk2->unk_00.raw)); } void sub_0807EFE4(Entity* unk1, ScriptExecutionContext* unk2) { @@ -1341,11 +1510,11 @@ void sub_0807EFE4(Entity* unk1, ScriptExecutionContext* unk2) { } void sub_0807EFF4(Entity* unk1, ScriptExecutionContext* unk2) { - ModRupees((s16)unk2->unk_00[1]); + ModRupees((s16)unk2->unk_00.raw[1]); } void sub_0807F004(Entity* unk1, ScriptExecutionContext* unk2) { - ModHealth(unk2->unk_00[1]); + ModHealth(unk2->unk_00.commands[0].metadata); } void sub_0807F010(Entity* unk1, ScriptExecutionContext* unk2) { @@ -1355,27 +1524,28 @@ void sub_0807F010(Entity* unk1, ScriptExecutionContext* unk2) { void sub_0807F034(Entity* unk1, ScriptExecutionContext* unk2) { u32 tmp = 0; - if (unk2->unk_00[1] == 0x3F) { + if (unk2->unk_00.raw[1] == 0x3F) { tmp = unk2->unk_04; } - sub_080A7C18(unk2->unk_00[1], tmp, 0); + sub_080A7C18(unk2->unk_00.raw[1], tmp, 0); } void sub_0807F050(Entity* unk1, ScriptExecutionContext* unk2) { - sub_080A7C18(0x5C, unk2->unk_00[1], 0); + sub_080A7C18(0x5C, unk2->unk_00.raw[1], 0); } +// get inventory value and compare ?? void sub_0807F060(Entity* unk1, ScriptExecutionContext* unk2) { - unk2->unk_04 = GetInventoryValue(unk2->unk_00[1]); - unk2->unk_14 = unk2->unk_04 != 0; + unk2->unk_04 = GetInventoryValue(unk2->unk_00.raw[1]); + unk2->compareResult = unk2->unk_04 != 0; } void sub_0807F078(Entity* unk1, ScriptExecutionContext* unk2) { - sub_0807CAA0(unk2->unk_00[1], unk2->unk_00[2]); + sub_0807CAA0(unk2->unk_00.raw[1], unk2->unk_00.raw[2]); } void sub_0807F088(Entity* unk1, ScriptExecutionContext* unk2) { - sub_080A7C18(unk2->unk_00[1], 0, 3); + sub_080A7C18(unk2->unk_00.raw[1], 0, 3); } void sub_0807F098(Entity* unk1, ScriptExecutionContext* unk2) { @@ -1387,9 +1557,9 @@ void sub_0807F0A4(Entity* unk1, ScriptExecutionContext* unk2) { } void sub_0807F0B4(Entity* unk1, ScriptExecutionContext* unk2) { - gRoomControls.unk5 = unk2->unk_00[1] & 7; + gRoomControls.unk5 = unk2->unk_00.raw[1] & 7; } void sub_0807F0C8(Entity* unk1, ScriptExecutionContext* unk2) { - sub_08080964(unk2->unk_00[1], unk2->unk_00[2]); + sub_08080964(unk2->unk_00.raw[1], unk2->unk_00.raw[2]); }