diff --git a/include/code_80A26CC.h b/include/code_80A26CC.h index 20f5372f4..6d59898f2 100644 --- a/include/code_80A26CC.h +++ b/include/code_80A26CC.h @@ -1,6 +1,8 @@ #ifndef GUARD_CODE_80A26CC_H #define GUARD_CODE_80A26CC_H +#include "structs/str_ground_script.h" + // size: 0x14 typedef struct DungeonInfo { @@ -17,9 +19,9 @@ typedef struct DungeonInfo /* 0x11 */ u8 unk11; } DungeonInfo; -void sub_80A2500(s32, s16 *); -void sub_80A252C(s32, s16 *); -void sub_80A2558(s32, s16 *); +void sub_80A2500(s32 param_1, ActionUnkIds *param_2); +void sub_80A252C(s32, ActionUnkIds *); +void sub_80A2558(s32, ActionUnkIds *); void sub_80A2584(s16, s16); void sub_80A2598(s16, s16); u32 sub_80A25AC(u16); diff --git a/include/ground_lives.h b/include/ground_lives.h index 4e6e5af66..4e15d8a23 100644 --- a/include/ground_lives.h +++ b/include/ground_lives.h @@ -2,6 +2,7 @@ #define GUARD_GROUND_LIVES_H #include "structs/str_position.h" +#include "structs/str_ground_script.h" struct Struct3001B84_sub120 { @@ -17,6 +18,7 @@ struct Struct3001B84_sub120 // ground_lives.s s32 sub_80A7AE8(s16); s32 sub_80A8FD8(s32 id_, PixelPos *pixelPos); +bool8 GroundLives_ExecuteScript(s32 id_, ActionUnkIds *a1, ScriptInfoSmall *scriptInfo); s16 GetFriendAreaDialogueId(s32 id_); #endif // GUARD_GROUND_LIVES_H diff --git a/include/ground_script.h b/include/ground_script.h index 82f647016..ae2aaaf6f 100644 --- a/include/ground_script.h +++ b/include/ground_script.h @@ -1,205 +1,8 @@ #ifndef GUARD_GROUND_SCRIPT_H #define GUARD_GROUND_SCRIPT_H -#include "structs/str_position.h" #include "number_util.h" - -// size: 0x10 -typedef struct ScriptCommand -{ - /* 0x0 */ u8 op; - /* 0x1 */ u8 argByte; - /* 0x2 */ s16 argShort; - /* 0x4 */ s32 arg1; - /* 0x8 */ s32 arg2; - /* 0xC */ const u8* argPtr; -} ScriptCommand; - -// size: 0xC -typedef struct ScriptInfoSmall -{ - /* 0x0 */ const ScriptCommand *ptr; - /* 0x4 */ s16 state; - /* 0x6 */ s16 group; - /* 0x8 */ s8 sector; -} ScriptInfoSmall; - -// size: 0xC -typedef struct ScriptInfo -{ - /* 0x0 */ const ScriptCommand *ptr; - /* 0x4 */ const ScriptCommand *ptr2; - /* 0x8 */ s16 group; - /* 0xA */ s8 sector; -} ScriptInfo; - -// size: 0x4 -typedef union ScriptUnion1632 { - s32 raw; - s16 arr[2]; -} ScriptUnion1632; - -// size: 0x60 -typedef struct ScriptData -{ - /* 0x00 */ s16 state; - /* 0x02 */ s16 savedState; - /* 0x04 */ ScriptInfo script; - /* 0x10 */ ScriptInfo savedScript; - /* 0x1C */ const ScriptCommand *curPtr; - /* 0x20 */ u8 curScriptOp; - /* 0x22 */ s16 unk22; - /* 0x24 */ u16 unk24; - /* 0x26 */ s8 unk26; - /* 0x28 */ s16 branchDiscriminant; - /* 0x2A */ s16 unk2A; - /* 0x2C */ s16 unk2C; - /* 0x30 */ s32 unk30; - /* 0x34 */ PixelPos pos1; - /* 0x3C */ PixelPos pos2; - /* 0x44 */ u8 unk44[4]; - /* 0x48 */ s32 unk48; - /* 0x4C */ u8 unk4C; - /* 0x4D */ u8 unk4D; - // ultimately accessed as ldrb, doesn't work as array of u32-sized structs, needs union - /* 0x50 */ union { - u8 buf[16]; - u32 val[4]; - } localVars; -} ScriptData; - -// size: 0x54 -typedef struct CallbackData -{ - /* 0x00 */ u16 maybeId; - // All callbacks take the parentObject as first parameter - /* 0x04 */ s16 (*getIndex)(void*); // id related - /* 0x08 */ void (*getSize)(void*, PixelPos *out); - /* 0x0C */ void (*getHitboxCenter)(void*, PixelPos *out); - /* 0x10 */ void (*getPosHeightAndUnk)(void*, u32 *height, u32 *unk); - /* 0x14 */ void (*getDirection)(void*, s8 *dir); - /* 0x18 */ void (*getFlags)(void*, u32 *flags); - /* 0x1C */ void (*setHitboxPos)(void*, PixelPos *posOrNull); - /* 0x20 */ void (*setPositionBounds)(void*, PixelPos *from, PixelPos *to); - /* 0x24 */ s32 (*moveReal)(void*, PixelPos*); - /* 0x28 */ void (*setPosHeight)(void*, u32 height); - /* 0x2C */ void (*setDirection)(void*, s32 dir); - /* 0x30 */ void (*setEventIndex)(void*, u16); - /* 0x34 */ void (*livesOnlyNullsub)(void*, u16); - /* 0x38 */ void (*func38)(void*, s32, s32); - /* 0x3C */ void (*setFlags)(void*, u32 bits); - /* 0x40 */ void (*clearFlags)(void*, u32 bits); - /* 0x44 */ void (*func44_livesOnlySpriteRelated)(void*, s32); - /* 0x48 */ s32 (*moveRelative)(void*, PixelPos*); - /* 0x4C */ bool8 (*func4C_spriteRelatedCheck)(void*); - /* 0x50 */ bool8 (*func50_spriteRelated)(void*); -} CallbackData; - -// size: 0xE4 -typedef struct Action -{ - /* 0x00 */ const struct CallbackData *callbacks; - /* 0x04 */ void *parentObject; // struct GroundObject * - /* 0x08 */ s16 unk8[2]; // id? - /* 0x0C */ ScriptUnion1632 unkC; - /* 0x10 */ s16 group; - /* 0x12 */ s8 sector; - /* 0x14 */ const ScriptCommand *predefinedScripts[4]; - /* 0x24 */ ScriptData scriptData; - /* 0x84 */ ScriptData scriptData2; -} Action; - -// Only used when accessing gGroundMapAction (3001B6C), basically everything else just uses Action -// probably worth moving to ground_map.h together with the main GroundMap struct -// oh well, TODO later I guess -typedef struct GroundMapAction -{ - // size: 0x110 - /* 0x00 */ Action action; - /* 0xE4 */ s16 groundMapId; - u16 fillE6; - u32 unkE8; - u32 unkEC; - s32 unkF0; - s32 unkF4; - PixelPos unkF8; - u32 unk100; - u32 unk104; - u32 unk108; - u32 unk10C; -} GroundMapAction; - -typedef struct ScriptRef -{ - s16 id; - s16 type; - u8 *name; - const ScriptCommand *script; -} ScriptRef; - -extern const ScriptRef gFunctionScriptTable[]; - -struct GroundLink { - CompactPos pos; - u8 width; - u8 height; - u8 ret; - u8 unk7; -}; -typedef struct GroundLivesData { - u8 kind; - u8 unk1; - u8 width; - u8 height; - CompactPos pos; - const ScriptCommand *scripts[4]; -} GroundLivesData; -typedef struct GroundObjectData { - u8 kind; - u8 unk1; - u8 width; - u8 height; - CompactPos pos; - const ScriptCommand *scripts[4]; -} GroundObjectData; -typedef struct GroundEffectData { - u8 kind; - u8 unk1; - u8 width; - u8 height; - CompactPos pos; - const ScriptCommand *script; -} GroundEffectData; -typedef struct GroundEventData { - u8 kind; - u8 unk1; - u8 width; - u8 height; - CompactPos pos; - const ScriptRef *script; -} GroundEventData; - -struct GroundScriptSector { - u32 nLives; - const GroundLivesData *lives; - u32 nObjects; - const GroundObjectData *objects; - u32 nEffects; - const GroundEffectData *effects; - u32 nEvents; - const GroundEventData *events; - u32 hasStation; - const ScriptRef * const *station; -}; -struct GroundScriptGroup { - u32 nSectors; - const struct GroundScriptSector *sectors; -}; -struct GroundScriptHeader { - u32 nGroups; - const struct GroundScriptGroup *groups; - const struct GroundLink *links; -}; +#include "structs/str_ground_script.h" // NOTE: F248 macros can match but has to be written this way to match in Blue static inline void SetUnkInGroundEvent(const CompactPos *posPtr, PixelPos *dst) @@ -229,7 +32,8 @@ void GetFunctionScript(Action *param_1, ScriptInfoSmall *script, s16 index); bool8 sub_809D684(Action *action, ScriptInfoSmall *scriptInfo); bool8 GroundScriptLockCond(Action *param_1, s16 index, s32 param_3); bool8 ActionResetScriptData(Action *param_1, const DebugLocation *unused); -bool8 GroundScript_ExecutePP(Action *, s32 *, ScriptInfoSmall *, const DebugLocation *unused); +bool8 GroundScript_ExecutePP(Action *action, ActionUnkIds *param_2, ScriptInfoSmall *param_3, const DebugLocation *unused); +bool8 ExecutePredefinedScript(Action *param_1, ActionUnkIds *param_2, s16 index, DebugLocation *debug); const ScriptCommand *FindLabel(Action *action, s32 r1); const ScriptCommand *ResolveJump(Action *action, s32 r1); void InitActionWithParams(Action *action, const CallbackData *callbacks, void *parent, s32 group, s32 sector); diff --git a/include/structs/str_ground_script.h b/include/structs/str_ground_script.h new file mode 100644 index 000000000..4296e0684 --- /dev/null +++ b/include/structs/str_ground_script.h @@ -0,0 +1,203 @@ +#ifndef GUARD_STR_GROUND_SCRIPT_H +#define GUARD_STR_GROUND_SCRIPT_H + +#include "structs/str_position.h" + +// size: 0x10 +typedef struct ScriptCommand +{ + /* 0x0 */ u8 op; + /* 0x1 */ u8 argByte; + /* 0x2 */ s16 argShort; + /* 0x4 */ s32 arg1; + /* 0x8 */ s32 arg2; + /* 0xC */ const u8* argPtr; +} ScriptCommand; + +// size: 0xC +typedef struct ScriptInfoSmall +{ + /* 0x0 */ const ScriptCommand *ptr; + /* 0x4 */ s16 state; + /* 0x6 */ s16 group; + /* 0x8 */ s8 sector; +} ScriptInfoSmall; + +// size: 0xC +typedef struct ScriptInfo +{ + /* 0x0 */ const ScriptCommand *ptr; + /* 0x4 */ const ScriptCommand *ptr2; + /* 0x8 */ s16 group; + /* 0xA */ s8 sector; +} ScriptInfo; + +// size: 0x4 +typedef struct ActionUnkIds { + s16 unk0; + s16 unk2; +} ActionUnkIds; + +// size: 0x60 +typedef struct ScriptData +{ + /* 0x00 */ s16 state; + /* 0x02 */ s16 savedState; + /* 0x04 */ ScriptInfo script; + /* 0x10 */ ScriptInfo savedScript; + /* 0x1C */ const ScriptCommand *curPtr; + /* 0x20 */ u8 curScriptOp; + /* 0x22 */ s16 unk22; + /* 0x24 */ u16 unk24; + /* 0x26 */ s8 unk26; + /* 0x28 */ s16 branchDiscriminant; + /* 0x2A */ s16 unk2A; + /* 0x2C */ s16 unk2C; + /* 0x30 */ s32 unk30; + /* 0x34 */ PixelPos pos1; + /* 0x3C */ PixelPos pos2; + /* 0x44 */ u8 unk44[4]; + /* 0x48 */ s32 unk48; + /* 0x4C */ u8 unk4C; + /* 0x4D */ u8 unk4D; + // ultimately accessed as ldrb, doesn't work as array of u32-sized structs, needs union + /* 0x50 */ union { + u8 buf[16]; + u32 val[4]; + } localVars; +} ScriptData; + +// size: 0x54 +typedef struct CallbackData +{ + /* 0x00 */ u16 maybeId; + // All callbacks take the parentObject as first parameter + /* 0x04 */ s16 (*getIndex)(void*); // id related + /* 0x08 */ void (*getSize)(void*, PixelPos *out); + /* 0x0C */ void (*getHitboxCenter)(void*, PixelPos *out); + /* 0x10 */ void (*getPosHeightAndUnk)(void*, u32 *height, u32 *unk); + /* 0x14 */ void (*getDirection)(void*, s8 *dir); + /* 0x18 */ void (*getFlags)(void*, u32 *flags); + /* 0x1C */ void (*setHitboxPos)(void*, PixelPos *posOrNull); + /* 0x20 */ void (*setPositionBounds)(void*, PixelPos *from, PixelPos *to); + /* 0x24 */ s32 (*moveReal)(void*, PixelPos*); + /* 0x28 */ void (*setPosHeight)(void*, u32 height); + /* 0x2C */ void (*setDirection)(void*, s32 dir); + /* 0x30 */ void (*setEventIndex)(void*, u16); + /* 0x34 */ void (*livesOnlyNullsub)(void*, u16); + /* 0x38 */ void (*func38)(void*, s32, s32); + /* 0x3C */ void (*setFlags)(void*, u32 bits); + /* 0x40 */ void (*clearFlags)(void*, u32 bits); + /* 0x44 */ void (*func44_livesOnlySpriteRelated)(void*, s32); + /* 0x48 */ s32 (*moveRelative)(void*, PixelPos*); + /* 0x4C */ bool8 (*func4C_spriteRelatedCheck)(void*); + /* 0x50 */ bool8 (*func50_spriteRelated)(void*); +} CallbackData; + +// size: 0xE4 +typedef struct Action +{ + /* 0x00 */ const struct CallbackData *callbacks; + /* 0x04 */ void *parentObject; // struct GroundObject * + /* 0x08 */ ActionUnkIds unk8; // id? + /* 0x0C */ ActionUnkIds unkC; + /* 0x10 */ s16 group; + /* 0x12 */ s8 sector; + /* 0x14 */ const ScriptCommand *predefinedScripts[4]; + /* 0x24 */ ScriptData scriptData; + /* 0x84 */ ScriptData scriptData2; +} Action; + +// Only used when accessing gGroundMapAction (3001B6C), basically everything else just uses Action +// probably worth moving to ground_map.h together with the main GroundMap struct +// oh well, TODO later I guess +typedef struct GroundMapAction +{ + // size: 0x110 + /* 0x00 */ Action action; + /* 0xE4 */ s16 groundMapId; + u16 fillE6; + u32 unkE8; + u32 unkEC; + s32 unkF0; + s32 unkF4; + PixelPos unkF8; + u32 unk100; + u32 unk104; + u32 unk108; + u32 unk10C; +} GroundMapAction; + +typedef struct ScriptRef +{ + s16 id; + s16 type; + u8 *name; + const ScriptCommand *script; +} ScriptRef; + +extern const ScriptRef gFunctionScriptTable[]; + +struct GroundLink { + CompactPos pos; + u8 width; + u8 height; + u8 ret; + u8 unk7; +}; +typedef struct GroundLivesData { + u8 kind; + u8 unk1; + u8 width; + u8 height; + CompactPos pos; + const ScriptCommand *scripts[4]; +} GroundLivesData; +typedef struct GroundObjectData { + u8 kind; + u8 unk1; + u8 width; + u8 height; + CompactPos pos; + const ScriptCommand *scripts[4]; +} GroundObjectData; +typedef struct GroundEffectData { + u8 kind; + u8 unk1; + u8 width; + u8 height; + CompactPos pos; + const ScriptCommand *script; +} GroundEffectData; +typedef struct GroundEventData { + u8 kind; + u8 unk1; + u8 width; + u8 height; + CompactPos pos; + const ScriptRef *script; +} GroundEventData; + +struct GroundScriptSector { + u32 nLives; + const GroundLivesData *lives; + u32 nObjects; + const GroundObjectData *objects; + u32 nEffects; + const GroundEffectData *effects; + u32 nEvents; + const GroundEventData *events; + u32 hasStation; + const ScriptRef * const *station; +}; +struct GroundScriptGroup { + u32 nSectors; + const struct GroundScriptSector *sectors; +}; +struct GroundScriptHeader { + u32 nGroups; + const struct GroundScriptGroup *groups; + const struct GroundLink *links; +}; + +#endif // GUARD_STR_GROUND_SCRIPT_H diff --git a/src/code_80A26CC.c b/src/code_80A26CC.c index 45ad7d7c4..2d543bdec 100644 --- a/src/code_80A26CC.c +++ b/src/code_80A26CC.c @@ -17,30 +17,30 @@ extern void sub_809AC18(s32, s32); s16 sub_80A8BBC(s16); -void sub_80A2500(s32 param_1, s16 *param_2) +void sub_80A2500(s32 param_1, ActionUnkIds *param_2) { s16 temp; - if (*param_2 == 1) { + if (param_2->unk0 == 1) { temp = param_1; - sub_809AB4C(temp, sub_80A8BBC(param_2[1])); + sub_809AB4C(temp, sub_80A8BBC(param_2->unk2)); } } -void sub_80A252C(s32 param_1, s16 *param_2) +void sub_80A252C(s32 param_1, ActionUnkIds *param_2) { s16 temp; - if (*param_2 == 1) { + if (param_2->unk0 == 1) { temp = param_1; - sub_809ABB4(temp, sub_80A8BBC(param_2[1])); + sub_809ABB4(temp, sub_80A8BBC(param_2->unk2)); } } -void sub_80A2558(s32 param_1, s16 *param_2) +void sub_80A2558(s32 param_1, ActionUnkIds *param_2) { s16 temp; - if (*param_2 == 1) { + if (param_2->unk0 == 1) { temp = param_1; - sub_809AC18(temp, sub_80A8BBC(param_2[1])); + sub_809AC18(temp, sub_80A8BBC(param_2->unk2)); } } diff --git a/src/ground_lives.c b/src/ground_lives.c index 98516ce5c..1d0e6561d 100644 --- a/src/ground_lives.c +++ b/src/ground_lives.c @@ -138,7 +138,6 @@ extern void sub_809CD68(struct Struct3001B84_sub120 *dst); extern bool8 GetCurrentDungeonBounds(PixelPos *a0, PixelPos *a1); extern void sub_80A7428(struct UnkGroundSpriteStruct *ptr, s32 a1_, s32 monsterId_, s32 a3); extern void SetPredefinedScript(Action *param_1, s16 index, const ScriptCommand *param_3); -extern bool8 ExecutePredefinedScript(Action *param_1, s32 *param_2, s16 index, const DebugLocation *debug); extern void sub_809D170(s32 r0, s32 r1); extern void sub_80A74E4(struct UnkGroundSpriteStruct *ptr); extern const struct GroundScriptHeader *GetGroundScript(s16 a0, const DebugLocation *); @@ -1065,7 +1064,7 @@ UNUSED static bool8 sub_80A88A0(s32 id_) return FALSE; } -bool8 GroundLives_ExecuteScript(s32 id_, s32 *a1, ScriptInfoSmall *scriptInfo) +bool8 GroundLives_ExecuteScript(s32 id_, ActionUnkIds *a1, ScriptInfoSmall *scriptInfo) { s32 id = (s16) id_; struct GroundLive *livesPtr = &gGroundLives->array[id]; @@ -1081,7 +1080,7 @@ bool8 GroundLives_ExecuteScript(s32 id_, s32 *a1, ScriptInfoSmall *scriptInfo) return FALSE; } -bool8 _ExecutePlayerScript(struct GroundLive *livesPtr, s32 *a1, ScriptInfoSmall *scriptInfo) +static bool8 _ExecutePlayerScript(struct GroundLive *livesPtr, ActionUnkIds *a1, ScriptInfoSmall *scriptInfo) { livesPtr->unk15E = 0x300; livesPtr->unk160 = 1; @@ -1098,7 +1097,7 @@ bool8 _ExecutePlayerScript(struct GroundLive *livesPtr, s32 *a1, ScriptInfoSmall return FALSE; } -UNUSED static bool8 sub_80A89AC(s32 id_, s32 *a1, ScriptInfoSmall *scriptInfo) +UNUSED static bool8 sub_80A89AC(s32 id_, ActionUnkIds *a1, ScriptInfoSmall *scriptInfo) { s32 id = (s16) id_; struct GroundLive *livesPtr = &gGroundLives->array[id]; @@ -1117,10 +1116,9 @@ bool8 GroundLives_ExecutePlayerScriptActionLives(s32 id1_, s32 id2_) struct GroundLive *livesPtr2 = &gGroundLives->array[id2]; if (livesPtr1->unk2 != -1 && livesPtr2->unk2 != -1 && GetPredefinedScript(&livesPtr2->action, &scriptInfo, 2)) { - s32 sp = 1; + ActionUnkIds sp = {1, id2}; - sp |= (id2 << 0x10); - ExecutePredefinedScript(&livesPtr2->action, (void *) &livesPtr1->action.unk8, 3, DEBUG_LOC_PTR("../ground/ground_lives.c", 1785, "GroundLives_ExecutePlayerScriptActionLives")); // TODO: fix unk8 field? + ExecutePredefinedScript(&livesPtr2->action, &livesPtr1->action.unk8, 3, DEBUG_LOC_PTR("../ground/ground_lives.c", 1785, "GroundLives_ExecutePlayerScriptActionLives")); return _ExecutePlayerScript(livesPtr1, &sp, &scriptInfo); } } @@ -1138,10 +1136,9 @@ bool8 sub_80A8A5C(s32 id1_, s32 id2_) struct GroundLive *livesPtr1 = &gGroundLives->array[id1]; if (sub_80AC274(id2, &scriptInfo1, 2)) { - s32 sp = 2; ScriptInfoSmall scriptInfo2; + ActionUnkIds sp = {2, id2}; - sp |= (id2 << 0x10); sub_80AC274(id2, &scriptInfo2, 3); GroundObject_ExecuteScript(id2, &livesPtr1->action.unk8, &scriptInfo2); return _ExecutePlayerScript(livesPtr1, &sp, &scriptInfo1); diff --git a/src/ground_script.c b/src/ground_script.c index ff6b441bb..c48a1d0cc 100644 --- a/src/ground_script.c +++ b/src/ground_script.c @@ -46,9 +46,8 @@ void GroundMap_Select(s16); void GroundMap_SelectDungeon(s32, DungeonLocation*, u32); void GroundMap_GetStationScript(ScriptInfoSmall *out, s16, s32, s32); -void GroundLives_ExecuteScript(s32, s16 *, ScriptInfoSmall *); -void GroundObject_ExecuteScript(s32, s16 *, ScriptInfoSmall *); -void GroundEffect_ExecuteScript(s32, s16 *, ScriptInfoSmall *); +void GroundObject_ExecuteScript(s32, ActionUnkIds *, ScriptInfoSmall *); +void GroundEffect_ExecuteScript(s32, ActionUnkIds *, ScriptInfoSmall *); void GroundLives_Select(s32, s32 group, s32 sector); void GroundObject_Select(s32, s32 group, s32 sector); void GroundEffect_Select(s32, s32 group, s32 sector); @@ -167,7 +166,6 @@ extern u8 gUnknown_811656C[]; extern DebugLocation gUnknown_81165C8; -extern void sub_809D520(void *); extern u8 GroundObjectsCancellAll(void); extern u8 GroundEffectsCancelAll(void); extern u8 GroundLivesCancelAll(void); @@ -247,25 +245,20 @@ EWRAM_DATA u16 gUnknown_2039DA8 = 0; EWRAM_INIT static int sNumChoices = 0; // -1 didn't match -void sub_809D520(void *a0) +void sub_809D520(ActionUnkIds *a0) { - u16 *ptr = a0; - u16 v = 0xFFFF; - *ptr = v; + a0->unk0 = -1; } -Action *sub_809D52C(void *a0) +Action *sub_809D52C(ActionUnkIds *a0) { - s16 *ptr = a0; - - switch (ptr[0]) - { - case 0: return 0; - case 1: return sub_80A882C(ptr[1]); - case 2: return sub_80AC240(ptr[1]); - case 3: return sub_80AD158(ptr[1]); + switch (a0->unk0) { + case 0: return 0; + case 1: return sub_80A882C(a0->unk2); + case 2: return sub_80AC240(a0->unk2); + case 3: return sub_80AD158(a0->unk2); } - return 0; + return NULL; } void InitScriptData(ScriptData *a0) @@ -321,12 +314,12 @@ void InitActionWithParams(Action *action, const CallbackData *callbacks, void *p action->parentObject = parent; action->group = group_s32; action->sector = sector_s32; - action->unk8[0] = callbacks->maybeId; + action->unk8.unk0 = callbacks->maybeId; if(callbacks->getIndex) - action->unk8[1] = callbacks->getIndex(parent); + action->unk8.unk2 = callbacks->getIndex(parent); else - action->unk8[1] = 0; + action->unk8.unk2 = 0; } void InitAction2(Action *action) @@ -427,7 +420,7 @@ bool8 ActionResetScriptDataForDeletion(Action *param_1, DebugLocation *unused) return TRUE; } -bool8 GroundScript_ExecutePP(Action *action, s32 *param_2, ScriptInfoSmall *param_3, const DebugLocation *unused) +bool8 GroundScript_ExecutePP(Action *action, ActionUnkIds *param_2, ScriptInfoSmall *param_3, const DebugLocation *unused) { if ((param_3 == NULL) || (param_3->ptr == NULL)) { return FALSE; @@ -468,7 +461,7 @@ bool8 GroundScript_ExecutePP(Action *action, s32 *param_2, ScriptInfoSmall *para } InitScriptData(&action->scriptData); if (param_2 != NULL) { - action->unkC.raw = param_2[0]; + action->unkC = *param_2; } else { sub_809D520(&action->unkC); @@ -488,7 +481,7 @@ bool8 GroundScript_ExecutePP(Action *action, s32 *param_2, ScriptInfoSmall *para return TRUE; } -bool8 ExecutePredefinedScript(Action *param_1, s32 *param_2, s16 index, DebugLocation *debug) +bool8 ExecutePredefinedScript(Action *param_1, ActionUnkIds *param_2, s16 index, DebugLocation *debug) { ScriptInfoSmall auStack28; @@ -1137,7 +1130,7 @@ s16 HandleAction(Action *action, DebugLocation *debug) action->scriptData.savedState = 3; sub_80999FC(cmd.argShort); GroundMap_ExecuteEvent(0x70, 0); - if (action->unk8[0] == 0) continue; + if (action->unk8.unk0 == 0) continue; action->scriptData.script.ptr = ResolveJump(action, 1); break; } @@ -1716,7 +1709,7 @@ s32 ExecuteScriptCommand(Action *action) if (gUnknown_2039A34 != map) { gUnknown_2039A34 = map; GroundCancelAllEntities(); - if (action->unk8[0] != 0) + if (action->unk8.unk0 != 0) return 4; // Fatal? } break; @@ -1744,26 +1737,26 @@ s32 ExecuteScriptCommand(Action *action) break; } case 0x20: { - switch (action->unkC.arr[0]) { + switch (action->unkC.unk0) { case 0: GroundMap_ExecuteEvent(curCmd.argShort, 0); break; case 1: { ScriptInfoSmall info1; GetFunctionScript(action, &info1, curCmd.argShort); - GroundLives_ExecuteScript(action->unkC.arr[1], action->unk8, &info1); + GroundLives_ExecuteScript(action->unkC.unk2, &action->unk8, &info1); break; } case 2: { ScriptInfoSmall info2; GetFunctionScript(action, &info2, curCmd.argShort); - GroundObject_ExecuteScript(action->unkC.arr[1], action->unk8, &info2); + GroundObject_ExecuteScript(action->unkC.unk2, &action->unk8, &info2); break; } case 3: { ScriptInfoSmall info3; GetFunctionScript(action, &info3, curCmd.argShort); - GroundEffect_ExecuteScript(action->unkC.arr[1], action->unk8, &info3); + GroundEffect_ExecuteScript(action->unkC.unk2, &action->unk8, &info3); break; } } @@ -1790,7 +1783,7 @@ s32 ExecuteScriptCommand(Action *action) sub_80A9090(ret, tmp); } } - GroundLives_ExecutePlayerScriptActionLives(action->unk8[1], ret); + GroundLives_ExecutePlayerScriptActionLives(action->unk8.unk2, ret); return 3; } break; @@ -1866,30 +1859,30 @@ s32 ExecuteScriptCommand(Action *action) break; } case 1: { - sub_80A2500(curCmd.argShort, action->unk8); + sub_80A2500(curCmd.argShort, &action->unk8); break; } case 2: { - sub_80A2500(curCmd.argShort, action->unkC.arr); + sub_80A2500(curCmd.argShort, &action->unkC); break; } case 3: { - struct {s16 unk0; s16 unk2;} unk; + ActionUnkIds unk; unk.unk2 = sub_80A7AE8((s16)curCmd.arg1); unk.unk0 = 1; - sub_80A2500(curCmd.argShort, (void*)&unk); + sub_80A2500(curCmd.argShort, &unk); break; } case 4: { - sub_80A252C(curCmd.argShort, action->unk8); + sub_80A252C(curCmd.argShort, &action->unk8); break; } case 5: { - sub_80A252C(curCmd.argShort, action->unkC.arr); + sub_80A252C(curCmd.argShort, &action->unkC); break; } case 6: { - struct {s16 unk0; s16 unk2;} unk; + ActionUnkIds unk; s16 res = sub_80A7AE8((s16)curCmd.arg1); unk.unk2 = res; if (unk.unk2 >= 0) { @@ -1901,11 +1894,11 @@ s32 ExecuteScriptCommand(Action *action) break; } case 7: { - sub_80A2558(curCmd.argShort, action->unk8); + sub_80A2558(curCmd.argShort, &action->unk8); break; } case 8: { - sub_80A2558(curCmd.argShort, action->unkC.arr); + sub_80A2558(curCmd.argShort, &action->unkC); break; } case 9: { @@ -2086,7 +2079,7 @@ s32 ExecuteScriptCommand(Action *action) PixelPos pos; s8 c; { - Action *tmp = (Action*)sub_809D52C(action->unkC.arr); + Action *tmp = sub_809D52C(&action->unkC); ptr = tmp; } if (ptr) { @@ -2485,7 +2478,7 @@ s32 ExecuteScriptCommand(Action *action) } case 0x98: { s32 id = action->callbacks->getIndex(action->parentObject); - switch(action->unk8[0]) { + switch(action->unk8.unk0) { case 1: sub_809D170(1, id); break; @@ -2501,7 +2494,7 @@ s32 ExecuteScriptCommand(Action *action) case 0x99: { s32 id = action->callbacks->getIndex(action->parentObject); PixelPos unk; - switch(action->unk8[0]) { + switch(action->unk8.unk0) { case 1: sub_80A8FD8(id, &unk); sub_809D158(0, &unk); @@ -2524,7 +2517,7 @@ s32 ExecuteScriptCommand(Action *action) case 0x9b: { s32 id = action->callbacks->getIndex(action->parentObject); if (id < 0) break; - switch(action->unk8[0]) { + switch(action->unk8.unk0) { case 1: sub_809D1A8(1, id, curCmd.argShort); return 2; @@ -2540,7 +2533,7 @@ s32 ExecuteScriptCommand(Action *action) case 0x9c: { s32 id = action->callbacks->getIndex(action->parentObject); PixelPos unk; - switch(action->unk8[0]) { + switch(action->unk8.unk0) { case 1: sub_80A8FD8(id, &unk); sub_809D190(0, &unk, curCmd.argShort); @@ -2563,7 +2556,7 @@ s32 ExecuteScriptCommand(Action *action) case 0x9e: { s32 id = action->callbacks->getIndex(action->parentObject); if (id < 0) break; - switch(action->unk8[0]) { + switch(action->unk8.unk0) { case 1: sub_809D1E4(1, id, curCmd.argShort); return 2; @@ -2579,7 +2572,7 @@ s32 ExecuteScriptCommand(Action *action) case 0x9f: { s32 id = action->callbacks->getIndex(action->parentObject); PixelPos unk; - switch(action->unk8[0]) { + switch(action->unk8.unk0) { case 1: sub_80A8FD8(id, &unk); sub_809D1CC(0, &unk, curCmd.argShort); @@ -2602,7 +2595,7 @@ s32 ExecuteScriptCommand(Action *action) case 0xa1: { s32 id = action->callbacks->getIndex(action->parentObject); if (id < 0) break; - switch(action->unk8[0]) { + switch(action->unk8.unk0) { case 1: sub_809D220(1, id, curCmd.argShort); return 2; @@ -2618,7 +2611,7 @@ s32 ExecuteScriptCommand(Action *action) case 0xa2: { s32 id = action->callbacks->getIndex(action->parentObject); PixelPos unk; - switch(action->unk8[0]) { + switch(action->unk8.unk0) { case 1: sub_80A8FD8(id, &unk); sub_809D208(0, &unk, curCmd.argShort); @@ -2774,8 +2767,8 @@ s32 ExecuteScriptCommand(Action *action) break; } case 0xbe: { - if (action->unk8[0] == 1) { - if ((s8)GroundLives_IsStarterMon(action->unk8[1])) { + if (action->unk8.unk0 == 1) { + if ((s8)GroundLives_IsStarterMon(action->unk8.unk2)) { scriptData->script.ptr = FindLabel(action, (u8)curCmd.argByte); } } @@ -3129,11 +3122,11 @@ s32 sub_80A14E8(Action *action, u8 idx, u32 r2, s32 r3) break; case 0xA: { - if ((action->unkC).arr[0] == 1) + if ((action->unkC).unk0 == 1) { u8 text[0x100]; DungeonLocation dungLocation; - s32 ret = sub_80A8C4C(action->unkC.arr[1], &dungLocation); + s32 ret = sub_80A8C4C(action->unkC.unk2, &dungLocation); if (ret != 0) { s32 dialogueId; @@ -3141,7 +3134,7 @@ s32 sub_80A14E8(Action *action, u8 idx, u32 r2, s32 r3) return 2; } - dialogueId = GetFriendAreaDialogueId(action->unkC.arr[1]); + dialogueId = GetFriendAreaDialogueId(action->unkC.unk2); InlineStrcpy(text, gFriendAreaDialogue[dialogueId]); if (ScriptPrintText(0, 1, text) != 0) return 1; @@ -3183,11 +3176,11 @@ s32 sub_80A14E8(Action *action, u8 idx, u32 r2, s32 r3) case 0xF: return sub_80964E4() == 0 ? 0 : 1; case 0x10: - if(action->unk8[0] == 1) - if(action->unk8[1] == 0) - if(action->unkC.arr[0] == 1) + if(action->unk8.unk0 == 1) + if(action->unk8.unk2 == 0) + if(action->unkC.unk0 == 1) { - if(sub_80A87E0(action->unk8[1], sub_80A8E9C(action->unkC.arr[1])) != 0) + if(sub_80A87E0(action->unk8.unk2, sub_80A8E9C(action->unkC.unk2)) != 0) return 1; } return 0; @@ -3212,8 +3205,8 @@ s32 sub_80A14E8(Action *action, u8 idx, u32 r2, s32 r3) } return 0; case 0x14: - if(action->unk8[0] == 1) { - if(GetCanMoveFlag(sub_80A8BFC(action->unk8[1]))) + if(action->unk8.unk0 == 1) { + if(GetCanMoveFlag(sub_80A8BFC(action->unk8.unk2))) return 1; } return 0;