diff --git a/include/functions.h b/include/functions.h index 501b45776f..622dfcffb6 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2007,7 +2007,7 @@ s32 func_80123810(GlobalContext* globalCtx); void func_80123AA4(Player* player, s32 arg1); // void func_80123BD4(void); // void func_80123C58(void); -void Player_SetEquipmentData(GlobalContext* globalCtx, Player* this); +void Player_SetEquipmentData(GlobalContext* globalCtx, Player* this); void func_80123D50(GlobalContext* globalCtx, Player* player, UNK_TYPE arg2, UNK_TYPE arg3); void func_80123DA4(Player* player); // void func_80123DC0(void); @@ -2299,26 +2299,7 @@ s32 Entrance_GetSceneNum(u16 entranceIndex); s32 Entrance_GetSceneNumAbsolute(u16 entranceIndex); s32 Entrance_GetSpawnNum(u16 entranceIndex); s32 Entrance_GetTransitionFlags(u16 entranceIndex); -// void func_801323D0(void); -// void func_80132428(void); -// void func_80132494(void); -// void func_801326B8(void); -// void func_801328F0(void); -// void func_80132920(void); -// void func_80132938(void); -// void func_80132954(void); -// void func_8013296C(void); -// void func_80132A18(void); -// void func_80132A3C(void); -// void func_80132A80(void); -// void func_80132AD8(void); -// void func_80132B24(void); -// void func_80132B84(void); -// void func_80132D70(void); -// void func_80132E9C(void); -// void func_80132FDC(void); -// void func_80133000(void); -UNK_TYPE func_80133038(GlobalContext* globalCtx, UNK_TYPE* arg1, struct_80133038_arg2* arg2); +s32 Schedule_RunScript(GlobalContext* globalCtx, u8* script, ScheduleResult* result); void SkelAnime_DrawLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor, s32 lod); void SkelAnime_DrawLod(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor, s32 lod); void SkelAnime_DrawFlexLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDrawFlex overrideLimbDraw, PostLimbDrawFlex postLimbDraw, Actor* actor, s32 lod, Mtx** mtx); @@ -2566,7 +2547,7 @@ s32 func_80142440(SkyboxContext* skyboxCtx, Vtx* vtx, s32 arg2, s32 arg3, s32 ar void func_80143148(SkyboxContext* skyboxCtx, s32 arg1); void func_801431E8(GameState* gameState, SkyboxContext* skyboxCtx, s16 skyType); void func_80143324(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skyType); -void func_801434E4(GameState* gameState, SkyboxContext* skyboxCtx, s16 skyType); +void func_801434E4(GameState* gameState, SkyboxContext* skyboxCtx, s16 skyType); Mtx* SkyboxDraw_UpdateMatrix(SkyboxContext* skyboxCtx, f32 x, f32 y, f32 z); void SkyboxDraw_SetColors(SkyboxContext* skyboxCtx, u8 primR, u8 primG, u8 primB, u8 envR, u8 envG, u8 envB); void SkyboxDraw_Draw(SkyboxContext* skyboxCtx, GraphicsContext* gfxCtx, s16 skyboxId, s16 blend, f32 x, f32 y, f32 z); diff --git a/include/z64.h b/include/z64.h index 1ef496df3f..e5533234aa 100644 --- a/include/z64.h +++ b/include/z64.h @@ -39,6 +39,7 @@ #include "z64player.h" #include "z64save.h" #include "z64scene.h" +#include "z64schedule.h" #include "z64skin.h" #include "z64subs.h" #include "z64transition.h" @@ -883,7 +884,7 @@ typedef struct { /* 0x12070 */ s32 unk12070; /* 0x12074 */ UNK_TYPE1 pad12074[0x4]; /* 0x12078 */ s32 bankRupeesSelected; - /* 0x1207C */ s32 bankRupees; + /* 0x1207C */ s32 bankRupees; /* 0x12080 */ MessageTableEntry* messageEntryTable; /* 0x12084 */ MessageTableEntry* messageEntryTableNes; /* 0x12088 */ UNK_TYPE4 unk12088; @@ -1223,7 +1224,7 @@ typedef struct { /* 0x12C */ UNK_TYPE1 pad_12C[0x4]; /* 0x130 */ OSThread thread; } AudioMgr; // size = 0x2E0 - + typedef struct { /* 0x00 */ MtxF displayMatrix; /* 0x40 */ Actor* actor; @@ -1397,12 +1398,6 @@ typedef struct { /* 0x24 */ s16 unk_24; } struct_800BD888_arg1; // size = 0x28 -typedef struct { - /* 0x0 */ u8 unk0; - /* 0x4 */ s32 unk4; - /* 0x8 */ s32 unk8; // game script pointer? -} struct_80133038_arg2; // size = 0xC - typedef struct { /* 0x00 */ u32 type; /* 0x04 */ u32 setScissor; diff --git a/include/z64schedule.h b/include/z64schedule.h new file mode 100644 index 0000000000..f5dfb2be87 --- /dev/null +++ b/include/z64schedule.h @@ -0,0 +1,248 @@ +#ifndef Z64SCHEDULE_H +#define Z64SCHEDULE_H + +#include "ultra64.h" + +/* + Schedule is a subsystem that acts as a way to make decisions based on the + time and scene (and a limited selection of items). It is utilized by writing + a script that is encoded into bytecode and ran, returning the result in a + struct. The returned result can be a value or a encoded time value. + + The scripts contain 2 kinds of instructions: + - Checks with branches (relative offsets, either 1-byte offsets (short, *_S), + or 2-byte offsets (long, *_L)) + - Returns + + Scripts are stored as u8[]. They are built using the macros are the bottom of + this file. The scheduledis.py script can be used to convert any scripts in + actor data into the macros. +*/ + +// Macro to convert the time format used in the save struct into the format used in Schedule +#define SCHEDULE_CONVERT_TIME(time) ((time) - 0x10000 / 360 * 90) +#define SCHEDULE_TIME_NOW SCHEDULE_CONVERT_TIME(gSaveContext.save.time) + +typedef enum { + /* 00 */ SCHEDULE_CMD_ID_CHECK_FLAG_S, // Checks if a weekEventReg flag is set and branches if so, short range branch + /* 01 */ SCHEDULE_CMD_ID_CHECK_FLAG_L, // Checks if a weekEventReg flag is set and branches if so, long range branch + /* 02 */ SCHEDULE_CMD_ID_CHECK_TIME_RANGE_S, // Checks if the current time is within the range of the two provided times and branches if so, short range branch + /* 03 */ SCHEDULE_CMD_ID_CHECK_TIME_RANGE_L, // Checks if the current time is within the range of the two provided times and branches if so, long range branch + /* 04 */ SCHEDULE_CMD_ID_RET_VAL_L, // Ends script and returns 2-byte value (Note: bugged as the return value size is only 1 byte in the struct) + /* 05 */ SCHEDULE_CMD_ID_RET_NONE, // Ends script without returning anything + /* 06 */ SCHEDULE_CMD_ID_RET_EMPTY, // Ends script and indicates return without changing existing value + /* 07 */ SCHEDULE_CMD_ID_NOP, // No-Op + /* 08 */ SCHEDULE_CMD_ID_CHECK_MISC_S, // Special check based on items or masks and branches if check passes, short range branch + /* 09 */ SCHEDULE_CMD_ID_RET_VAL_S, // Ends script and returns byte value + /* 10 */ SCHEDULE_CMD_ID_CHECK_NOT_IN_SCENE_S, // Checks if the current scene is not SceneNum and branches if so, short range branch + /* 11 */ SCHEDULE_CMD_ID_CHECK_NOT_IN_SCENE_L, // Checks if the current scene is not SceneNum and branches if so, long range branch + /* 12 */ SCHEDULE_CMD_ID_CHECK_NOT_IN_DAY_S, // Checks if the current day is not Day and branches if so, short range branch + /* 13 */ SCHEDULE_CMD_ID_CHECK_NOT_IN_DAY_L, // Checks if the current day is not Day and branches if so, long range branch + /* 14 */ SCHEDULE_CMD_ID_RET_TIME, // Returns 2 time values + /* 15 */ SCHEDULE_CMD_ID_CHECK_BEFORE_TIME_S, // Branches if the current time is less than the command time, short range branch + /* 16 */ SCHEDULE_CMD_ID_CHECK_BEFORE_TIME_L, // Branches if the current time is less than the command time, long range branch + /* 17 */ SCHEDULE_CMD_ID_BRANCH_S, // Always branch, short range branch + /* 18 */ SCHEDULE_CMD_ID_BRANCH_L, // Always branch, long range branch +} ScheduleCommandId; + +typedef enum { + /* 0 */ SCHEDULE_CHECK_MISC_ROOM_KEY, + /* 1 */ SCHEDULE_CHECK_MISC_LETTER_TO_KAFEI, + /* 2 */ SCHEDULE_CHECK_MISC_MASK_ROMANI, +} ScheduleCheckMisc; + +typedef struct { + /* 0x0 */ u8 result; + /* 0x4 */ s32 time0; + /* 0x8 */ s32 time1; + /* 0xC */ s32 hasResult; +} ScheduleResult; // size = 0x10 + +typedef struct { + /* 0x0 */ u8 cmd; +} ScheduleCmdBase; // size = 0x1 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 flagByte; + /* 0x2 */ u8 flagMask; + /* 0x3 */ s8 offset; +} ScheduleCmdCheckFlagS; // size = 0x4 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 flagByte; + /* 0x2 */ u8 flagMask; + /* 0x3 */ u8 offsetH; + /* 0x4 */ u8 offsetL; +} ScheduleCmdCheckFlagL; // size = 0x5 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 startHr; + /* 0x2 */ u8 startMin; + /* 0x3 */ u8 endHr; + /* 0x4 */ u8 endMin; + /* 0x5 */ s8 offset; +} ScheduleCmdCheckTimeRangeS; // size = 0x6 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 startHr; + /* 0x2 */ u8 startMin; + /* 0x3 */ u8 endHr; + /* 0x4 */ u8 endMin; + /* 0x5 */ u8 offsetH; + /* 0x6 */ u8 offsetL; +} ScheduleCmdCheckTimeRangeL; // size = 0x7 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 retH; + /* 0x2 */ u8 retL; +} ScheduleCmdReturnValueL; // size = 0x3 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 unk1; + /* 0x2 */ u8 unk2; + /* 0x3 */ u8 unk3; +} ScheduleCmdNop; // size = 0x4 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 which; + /* 0x2 */ s8 offset; +} ScheduleCmdCheckMiscS; // size = 0x3 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 result; +} ScheduleCmdReturnValueS; // size = 0x2 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 sceneH; + /* 0x2 */ u8 sceneL; + /* 0x3 */ s8 offset; +} ScheduleCmdCheckNotInSceneS; // size = 0x4 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 sceneH; + /* 0x2 */ u8 sceneL; + /* 0x3 */ u8 offsetH; + /* 0x4 */ u8 offsetL; +} ScheduleCmdCheckNotInSceneL; // size = 0x5 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 dayH; + /* 0x2 */ u8 dayL; + /* 0x3 */ s8 offset; +} ScheduleCmdCheckNotInDayS; // size = 0x4 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 dayH; + /* 0x2 */ u8 dayL; + /* 0x3 */ u8 offsetH; + /* 0x4 */ u8 offsetL; +} ScheduleCmdCheckNotInDayL; // size = 0x5 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 time0Hr; + /* 0x2 */ u8 time0Min; + /* 0x3 */ u8 time1Hr; + /* 0x4 */ u8 time1Min; + /* 0x5 */ u8 result; +} ScheduleCmdReturnTime; // size = 0x6 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 timeHr; + /* 0x2 */ u8 timeMin; + /* 0x3 */ s8 offset; +} ScheduleCmdCheckBeforeTimeS; // size = 0x4 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 timeHr; + /* 0x2 */ u8 timeMin; + /* 0x3 */ u8 offsetH; + /* 0x4 */ u8 offsetL; +} ScheduleCmdCheckBeforeTimeL; // size = 0x5 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ s8 offset; +} ScheduleCmdBranchS; // size = 0x2 + +typedef struct { + /* 0x0 */ ScheduleCmdBase base; + /* 0x1 */ u8 offsetH; + /* 0x2 */ u8 offsetL; +} ScheduleCmdBranchL; // size = 0x3 + +#define SCHEDULE_PACK_S16(val) \ + ((val) >> 8) & 0xFF, (val) & 0xFF + +#define SCHEDULE_CMD_CHECK_FLAG_S(index, mask, offset) \ + SCHEDULE_CMD_ID_CHECK_FLAG_S, (index), (mask), (offset) + +#define SCHEDULE_CMD_CHECK_FLAG_L(index, mask, offset) \ + SCHEDULE_CMD_ID_CHECK_FLAG_L, (index), (mask), SCHEDULE_PACK_S16(offset) + +#define SCHEDULE_CMD_CHECK_TIME_RANGE_S(startHr, startMin, endHr, endMin, offset) \ + SCHEDULE_CMD_ID_CHECK_TIME_RANGE_S, (startHr), (startMin), (endHr), (endMin), (offset) + +#define SCHEDULE_CMD_CHECK_TIME_RANGE_L(startHr, startMin, endHr, endMin, offset) \ + SCHEDULE_CMD_ID_CHECK_TIME_RANGE_L, (startHr), (startMin), (endHr), (endMin), SCHEDULE_PACK_S16(offset) + +#define SCHEDULE_CMD_RET_VAL_L(result) \ + SCHEDULE_CMD_ID_RET_VAL_L, SCHEDULE_PACK_S16(result) + +#define SCHEDULE_CMD_RET_NONE() \ + SCHEDULE_CMD_ID_RET_NONE + +#define SCHEDULE_CMD_RET_EMPTY() \ + SCHEDULE_CMD_ID_RET_EMPTY, + +#define SCHEDULE_CMD_NOP(unk0, unk1, unk2) \ + SCHEDULE_CMD_ID_NOP, (unk0), (unk1), (unk2) + +#define SCHEDULE_CMD_CHECK_MISC_S(which, offset) \ + SCHEDULE_CMD_ID_CHECK_MISC_S, (which), (offset) + +#define SCHEDULE_CMD_RET_VAL_S(result) \ + SCHEDULE_CMD_ID_RET_VAL_S, (result) + +#define SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(scene, offset) \ + SCHEDULE_CMD_ID_CHECK_NOT_IN_SCENE_S, SCHEDULE_PACK_S16(scene), (offset) + +#define SCHEDULE_CMD_CHECK_NOT_IN_SCENE_L(scene, offset) \ + SCHEDULE_CMD_ID_CHECK_NOT_IN_SCENE_L, SCHEDULE_PACK_S16(scene), SCHEDULE_PACK_S16(offset) + +#define SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(day, offset) \ + SCHEDULE_CMD_ID_CHECK_NOT_IN_DAY_S, SCHEDULE_PACK_S16(day), (offset) + +#define SCHEDULE_CMD_CHECK_NOT_IN_DAY_L(day, offset) \ + SCHEDULE_CMD_ID_CHECK_NOT_IN_DAY_L, SCHEDULE_PACK_S16(day), SCHEDULE_PACK_S16(offset) + +#define SCHEDULE_CMD_RET_TIME(time0Hr, time0Min, time1Hr, time1Min, result) \ + SCHEDULE_CMD_ID_RET_TIME, (time0Hr), (time0Min), (time1Hr), (time1Min), (result) + +#define SCHEDULE_CMD_CHECK_BEFORE_TIME_S(timeHr, timeMin, offset) \ + SCHEDULE_CMD_ID_CHECK_BEFORE_TIME_S, (timeHr), (timeMin), (offset) + +#define SCHEDULE_CMD_CHECK_BEFORE_TIME_L(timeHr, timeMin, offset) \ + SCHEDULE_CMD_ID_CHECK_BEFORE_TIME_L, (timeHr), (timeMin), SCHEDULE_PACK_S16(offset) + +#define SCHEDULE_CMD_BRANCH_S(offset) \ + SCHEDULE_CMD_ID_BRANCH_S, (offset) + +#define SCHEDULE_CMD_BRANCH_L(offset) \ + SCHEDULE_CMD_ID_BRANCH_L, SCHEDULE_PACK_S16(offset) + +#endif diff --git a/spec b/spec index 57a0441240..a2d9a9ef37 100644 --- a/spec +++ b/spec @@ -522,8 +522,7 @@ beginseg include "build/data/code/code_801C2730.data.o" include "build/src/code/z_scene_proc.o" include "build/src/code/z_scene_table.o" - include "build/src/code/code_801323D0.o" - include "build/data/code/code_801C5C50.data.o" + include "build/src/code/z_schedule.o" include "build/src/code/z_skelanime.o" include "build/src/code/z_skin.o" include "build/src/code/z_skin_awb.o" diff --git a/src/boot_O2_g3/idle.c b/src/boot_O2_g3/idle.c index 942435fa7b..da93f13fdb 100644 --- a/src/boot_O2_g3/idle.c +++ b/src/boot_O2_g3/idle.c @@ -1,3 +1,4 @@ +#include "prevent_bss_reordering.h" #include "global.h" u8 D_80096B20 = 1; diff --git a/src/code/code_801323D0.c b/src/code/code_801323D0.c deleted file mode 100644 index 1457f537d7..0000000000 --- a/src/code/code_801323D0.c +++ /dev/null @@ -1,41 +0,0 @@ -#include "global.h" - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_801323D0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80132428.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80132494.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_801326B8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_801328F0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80132920.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80132938.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80132954.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_8013296C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80132A18.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80132A3C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80132A80.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80132AD8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80132B24.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80132B84.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80132D70.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80132E9C.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80132FDC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80133000.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_801323D0/func_80133038.s") diff --git a/src/code/graph.c b/src/code/graph.c index 128aa0ee47..28327c35fa 100644 --- a/src/code/graph.c +++ b/src/code/graph.c @@ -1,4 +1,3 @@ -#include "prevent_bss_reordering.h" #include "global.h" #include "system_malloc.h" #include "overlays/gamestates/ovl_daytelop/z_daytelop.h" diff --git a/src/code/z_bgcheck.c b/src/code/z_bgcheck.c index 028f680118..f0ebe59113 100644 --- a/src/code/z_bgcheck.c +++ b/src/code/z_bgcheck.c @@ -1,4 +1,3 @@ -#include "prevent_bss_reordering.h" #include "global.h" #include "vt.h" diff --git a/src/code/z_collision_check.c b/src/code/z_collision_check.c index 4b7f48696e..a08e3f822a 100644 --- a/src/code/z_collision_check.c +++ b/src/code/z_collision_check.c @@ -1,4 +1,3 @@ -#include "prevent_bss_reordering.h" #include "global.h" Vec3f D_801EDE00; diff --git a/src/code/z_demo.c b/src/code/z_demo.c index 762be45385..c9c6253d30 100644 --- a/src/code/z_demo.c +++ b/src/code/z_demo.c @@ -1,4 +1,3 @@ -#include "prevent_bss_reordering.h" #include "global.h" #include "overlays/gamestates/ovl_daytelop/z_daytelop.h" diff --git a/src/code/z_schedule.c b/src/code/z_schedule.c new file mode 100644 index 0000000000..4c57a57d4f --- /dev/null +++ b/src/code/z_schedule.c @@ -0,0 +1,283 @@ +#include "global.h" + +#define SCHEDULE_CALC_TIME(hour, minute, dest, temp) \ + (temp) = (hour)*60.0f; \ + (temp) += (minute); \ + (dest) = (temp) * (0x10000 / 60 / 24.0f); \ + (dest) = SCHEDULE_CONVERT_TIME(dest); + +s32 Schedule_CheckFlagS(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + ScheduleCmdCheckFlagS* cmd = (ScheduleCmdCheckFlagS*)*script; + u16 flag = (cmd->flagByte << 8) | cmd->flagMask; + + if (gSaveContext.save.weekEventReg[flag >> 8] & (flag & 0xFF)) { + *script += cmd->offset; + } + + return false; +} + +s32 Schedule_CheckFlagL(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + ScheduleCmdCheckFlagL* cmd = (ScheduleCmdCheckFlagL*)*script; + u16 flag = (cmd->flagByte << 8) | cmd->flagMask; + + if (gSaveContext.save.weekEventReg[flag >> 8] & (flag & 0xFF)) { + *script += (s16)((cmd->offsetH << 8) | cmd->offsetL); + } + + return false; +} + +s32 Schedule_CheckTimeRangeS(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + s32 inRange = false; + ScheduleCmdCheckTimeRangeS* cmd = (ScheduleCmdCheckTimeRangeS*)*script; + f32 f; + u16 start; + u16 end; + u16 now; + + SCHEDULE_CALC_TIME(cmd->startHr, cmd->startMin, start, f); + + SCHEDULE_CALC_TIME(cmd->endHr, cmd->endMin, end, f); + end--; + + now = SCHEDULE_TIME_NOW; + + if ((start <= now) && (now <= end)) { + inRange = true; + } + + if (inRange == true) { + *script += cmd->offset; + } + + return false; +} + +s32 Schedule_CheckTimeRangeL(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + s32 inRange = false; + ScheduleCmdCheckTimeRangeL* cmd = (ScheduleCmdCheckTimeRangeL*)*script; + f32 f; + u16 start; + u16 end; + u16 now; + + SCHEDULE_CALC_TIME(cmd->startHr, cmd->startMin, start, f); + + SCHEDULE_CALC_TIME(cmd->endHr, cmd->endMin, end, f); + end--; + + now = SCHEDULE_TIME_NOW; + + if ((start <= now) && (now <= end)) { + inRange = true; + } + + if (inRange == true) { + *script += (s16)((cmd->offsetH << 8) | cmd->offsetL); + } + + return false; +} + +s32 Schedule_ReturnValueL(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + ScheduleCmdReturnValueL* cmd = (ScheduleCmdReturnValueL*)*script; + + //! @bug result is a u8, value is truncated + result->result = (cmd->retH << 8) | cmd->retL; + result->hasResult = true; + + return true; +} + +s32 Schedule_ReturnNone(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + result->hasResult = false; + + return true; +} + +s32 Schedule_ReturnEmpty(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + result->hasResult = true; + + return true; +} + +s32 Schedule_Nop(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + return false; +} + +s32 Schedule_CheckMiscS(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + ScheduleCmdCheckMiscS* cmd = (ScheduleCmdCheckMiscS*)*script; + + if (((cmd->which == SCHEDULE_CHECK_MISC_ROOM_KEY) && (INV_CONTENT(ITEM_ROOM_KEY) == ITEM_ROOM_KEY)) || + ((cmd->which == SCHEDULE_CHECK_MISC_LETTER_TO_KAFEI) && + (INV_CONTENT(ITEM_LETTER_TO_KAFEI) == ITEM_LETTER_TO_KAFEI)) || + ((cmd->which == SCHEDULE_CHECK_MISC_MASK_ROMANI) && (Player_GetMask(globalCtx) == PLAYER_MASK_ROMANI))) { + *script += cmd->offset; + } + + return false; +} + +s32 Schedule_ReturnValueS(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + ScheduleCmdReturnValueS* cmd = (ScheduleCmdReturnValueS*)*script; + + result->result = cmd->result; + result->hasResult = true; + + return true; +} + +s32 Schedule_CheckNotInSceneS(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + ScheduleCmdCheckNotInSceneS* cmd = (ScheduleCmdCheckNotInSceneS*)*script; + s16 scene = (cmd->sceneH << 8) | cmd->sceneL; + + if (scene != globalCtx->sceneNum) { + *script += cmd->offset; + } + + return false; +} + +s32 Schedule_CheckNotInSceneL(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + ScheduleCmdCheckNotInSceneL* cmd = (ScheduleCmdCheckNotInSceneL*)*script; + s16 scene = (cmd->sceneH << 8) | cmd->sceneL; + + if (scene != globalCtx->sceneNum) { + *script = *script + (s16)((cmd->offsetH << 8) | cmd->offsetL); + } + + return false; +} + +s32 Schedule_CheckNotInDayS(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + ScheduleCmdCheckNotInDayS* cmd = (ScheduleCmdCheckNotInDayS*)*script; + s16 day = (cmd->dayH << 8) | cmd->dayL; + + if (day != (s16)gSaveContext.save.day) { + *script += cmd->offset; + } + + return false; +} + +s32 Schedule_CheckNotInDayL(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + ScheduleCmdCheckNotInDayL* cmd = (ScheduleCmdCheckNotInDayL*)*script; + s16 day = (cmd->dayH << 8) | cmd->dayL; + + if (day != (s16)gSaveContext.save.day) { + *script += (s16)((cmd->offsetH << 8) | cmd->offsetL); + } + + return false; +} + +s32 Schedule_ReturnTime(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + ScheduleCmdReturnTime* cmd = (ScheduleCmdReturnTime*)*script; + f32 f; + u16 time0; + u16 time1; + + SCHEDULE_CALC_TIME(cmd->time0Hr, cmd->time0Min, time0, f); + + SCHEDULE_CALC_TIME(cmd->time1Hr, cmd->time1Min, time1, f); + time1--; + + result->result = cmd->result; + result->time0 = time0; + result->time1 = time1; + result->hasResult = true; + + return true; +} + +s32 Schedule_CheckBeforeTimeS(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + ScheduleCmdCheckBeforeTimeS* cmd = (ScheduleCmdCheckBeforeTimeS*)*script; + f32 f; + u16 testTime; + u16 now; + + SCHEDULE_CALC_TIME(cmd->timeHr, cmd->timeMin, testTime, f); + + now = SCHEDULE_TIME_NOW; + + if (now < testTime) { + *script += cmd->offset; + } + + return false; +} + +s32 Schedule_CheckBeforeTimeL(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + ScheduleCmdCheckBeforeTimeL* cmd = (ScheduleCmdCheckBeforeTimeL*)*script; + f32 f; + u16 testTime; + u16 now; + + SCHEDULE_CALC_TIME(cmd->timeHr, cmd->timeMin, testTime, f); + + now = SCHEDULE_TIME_NOW; + + if (now < testTime) { + *script += (s16)((cmd->offsetH << 8) | cmd->offsetL); + } + + return false; +} + +s32 Schedule_BranchS(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + ScheduleCmdBranchS* cmd = (ScheduleCmdBranchS*)*script; + + *script += cmd->offset; + return false; +} + +s32 Schedule_BranchL(GlobalContext* globalCtx, u8** script, ScheduleResult* result) { + ScheduleCmdBranchL* cmd = (ScheduleCmdBranchL*)*script; + + *script += (s16)((cmd->offsetH << 8) | cmd->offsetL); + return false; +} + +static s32 (*sScheduleCmdFuncs[])(GlobalContext*, u8**, ScheduleResult*) = { + Schedule_CheckFlagS, Schedule_CheckFlagL, Schedule_CheckTimeRangeS, Schedule_CheckTimeRangeL, + Schedule_ReturnValueL, Schedule_ReturnNone, Schedule_ReturnEmpty, Schedule_Nop, + Schedule_CheckMiscS, Schedule_ReturnValueS, Schedule_CheckNotInSceneS, Schedule_CheckNotInSceneL, + Schedule_CheckNotInDayS, Schedule_CheckNotInDayL, Schedule_ReturnTime, Schedule_CheckBeforeTimeS, + Schedule_CheckBeforeTimeL, Schedule_BranchS, Schedule_BranchL, +}; + +static u8 sScheduleCmdSizes[] = { + sizeof(ScheduleCmdCheckFlagS), + sizeof(ScheduleCmdCheckFlagL), + sizeof(ScheduleCmdCheckTimeRangeS), + sizeof(ScheduleCmdCheckTimeRangeL), + sizeof(ScheduleCmdReturnValueL), + sizeof(ScheduleCmdBase), + sizeof(ScheduleCmdBase), + sizeof(ScheduleCmdNop), + sizeof(ScheduleCmdCheckMiscS), + sizeof(ScheduleCmdReturnValueS), + sizeof(ScheduleCmdCheckNotInSceneS), + sizeof(ScheduleCmdCheckNotInSceneL), + sizeof(ScheduleCmdCheckNotInDayS), + sizeof(ScheduleCmdCheckNotInDayL), + sizeof(ScheduleCmdReturnTime), + sizeof(ScheduleCmdCheckBeforeTimeS), + sizeof(ScheduleCmdCheckBeforeTimeL), + sizeof(ScheduleCmdBranchS), + sizeof(ScheduleCmdBranchL), +}; + +s32 Schedule_RunScript(GlobalContext* globalCtx, u8* script, ScheduleResult* result) { + u8 size; + s32 stop; + + do { + size = sScheduleCmdSizes[*script]; + stop = (*sScheduleCmdFuncs[*script])(globalCtx, &script, result); + script += size; + } while (!stop); + + return result->hasResult; +} diff --git a/src/overlays/actors/ovl_Boss_06/z_boss_06.c b/src/overlays/actors/ovl_Boss_06/z_boss_06.c index 5a88f67c69..311d07a754 100644 --- a/src/overlays/actors/ovl_Boss_06/z_boss_06.c +++ b/src/overlays/actors/ovl_Boss_06/z_boss_06.c @@ -4,6 +4,7 @@ * Description: Igos du Ikana window - curtains and ray effects */ +#include "prevent_bss_reordering.h" #include "z_boss_06.h" #include "overlays/actors/ovl_En_Knight/z_en_knight.h" #include "objects/gameplay_keep/gameplay_keep.h" diff --git a/src/overlays/actors/ovl_En_Ah/z_en_ah.c b/src/overlays/actors/ovl_En_Ah/z_en_ah.c index 5f0f7a5b2f..732b3e37b3 100644 --- a/src/overlays/actors/ovl_En_Ah/z_en_ah.c +++ b/src/overlays/actors/ovl_En_Ah/z_en_ah.c @@ -19,9 +19,24 @@ void EnAh_Draw(Actor* thisx, GlobalContext* globalCtx); void func_80BD36B8(EnAh* this, GlobalContext* globalCtx); void func_80BD3768(EnAh* this, GlobalContext* globalCtx); -s32 D_80BD3DB0[] = { - 0x0A00611D, 0x0C000303, 0x0400010C, 0x00021102, 0x15001700, 0x08003220, 0x03040001, - 0x05040003, 0x050A0010, 0x120C0003, 0x0D021200, 0x06000105, 0x0E120006, 0x00020505, +static u8 D_80BD3DB0[] = { + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_YADOYA, 0x21 - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(3, 0x0B - 0x08), + /* 0x08 */ SCHEDULE_CMD_RET_VAL_L(1), + /* 0x0B */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(2, 0x20 - 0x0F), + /* 0x0F */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(21, 0, 23, 0, 0x1D - 0x15), + /* 0x15 */ SCHEDULE_CMD_CHECK_FLAG_S(0x32, 0x20, 0x1C - 0x19), + /* 0x19 */ SCHEDULE_CMD_RET_VAL_L(1), + /* 0x1C */ SCHEDULE_CMD_RET_NONE(), + /* 0x1D */ SCHEDULE_CMD_RET_VAL_L(3), + /* 0x20 */ SCHEDULE_CMD_RET_NONE(), + /* 0x21 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_OMOYA, 0x37 - 0x25), + /* 0x25 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(3, 0x36 - 0x29), + /* 0x29 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(18, 0, 6, 0, 0x30 - 0x2F), + /* 0x2F */ SCHEDULE_CMD_RET_NONE(), + /* 0x30 */ SCHEDULE_CMD_RET_TIME(18, 0, 6, 0, 2), + /* 0x36 */ SCHEDULE_CMD_RET_NONE(), + /* 0x37 */ SCHEDULE_CMD_RET_NONE(), }; s32 D_80BD3DE8[] = { 0x0E28FF0C, 0x10000000 }; @@ -361,7 +376,7 @@ s32 func_80BD3320(EnAh* this, GlobalContext* globalCtx, u8 actorCat, s16 actorId return ret; } -s32 func_80BD3374(EnAh* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BD3374(EnAh* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 pad; Math_Vec3f_Copy(&this->actor.world.pos, &D_80BD3EC4.pos); @@ -373,7 +388,7 @@ s32 func_80BD3374(EnAh* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return true; } -s32 func_80BD33FC(EnAh* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BD33FC(EnAh* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 pad; Math_Vec3f_Copy(&this->actor.world.pos, &D_80BD3ED8.pos); @@ -385,7 +400,7 @@ s32 func_80BD33FC(EnAh* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return true; } -s32 func_80BD3484(EnAh* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BD3484(EnAh* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret = false; if (func_80BD3320(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_AN)) { @@ -404,12 +419,12 @@ s32 func_80BD3484(EnAh* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80BD3548(EnAh* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BD3548(EnAh* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret; this->unk_2D8 = 0; - switch (arg2->unk0) { + switch (arg2->result) { default: ret = false; break; @@ -457,19 +472,18 @@ void func_80BD3658(EnAh* this, GlobalContext* globalCtx) { } void func_80BD36B8(EnAh* this, GlobalContext* globalCtx) { - s32 pad; - struct_80133038_arg2 sp18; + ScheduleResult sp18; - if (!func_80133038(globalCtx, D_80BD3DB0, &sp18) || - ((this->unk_1DC != sp18.unk0) && !func_80BD3548(this, globalCtx, &sp18))) { + if (!Schedule_RunScript(globalCtx, D_80BD3DB0, &sp18) || + ((this->unk_1DC != sp18.result) && !func_80BD3548(this, globalCtx, &sp18))) { this->actor.shape.shadowDraw = NULL; this->actor.flags &= ~ACTOR_FLAG_1; - sp18.unk0 = 0; + sp18.result = 0; } else { this->actor.shape.shadowDraw = ActorShadow_DrawCircle; this->actor.flags |= ACTOR_FLAG_1; } - this->unk_1DC = sp18.unk0; + this->unk_1DC = sp18.result; func_80BD3658(this, globalCtx); } diff --git a/src/overlays/actors/ovl_En_Al/z_en_al.c b/src/overlays/actors/ovl_En_Al/z_en_al.c index 259c526145..149f82d456 100644 --- a/src/overlays/actors/ovl_En_Al/z_en_al.c +++ b/src/overlays/actors/ovl_En_Al/z_en_al.c @@ -19,10 +19,22 @@ void EnAl_Draw(Actor* thisx, GlobalContext* globalCtx); void func_80BDF5E8(EnAl* this, GlobalContext* globalCtx); void func_80BDF6C4(EnAl* this, GlobalContext* globalCtx); -s32 D_80BDFC70[] = { - 0x0C00030D, 0x02120006, 0x0001050E, 0x12000600, 0x02020800, 0x0A002F02, 0x0A000A37, - 0x23020A37, 0x0B2D0D02, 0x0B2D1400, 0x01050E0B, 0x2D140001, 0x0C000206, 0x0E0A370B, - 0x2D010E0A, 0x370B2D03, 0x0E0A000A, 0x37010400, 0x01000000, +static u8 D_80BDFC70[] = { + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(3, 0x11 - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(18, 0, 6, 0, 0x0B - 0x0A), + /* 0x0A */ SCHEDULE_CMD_RET_NONE(), + /* 0x0B */ SCHEDULE_CMD_RET_TIME(18, 0, 6, 0, 2), + /* 0x11 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(8, 0, 10, 0, 0x46 - 0x17), + /* 0x17 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 0, 10, 55, 0x40 - 0x1D), + /* 0x1D */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 55, 11, 45, 0x30 - 0x23), + /* 0x23 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(11, 45, 20, 0, 0x2A - 0x29), + /* 0x29 */ SCHEDULE_CMD_RET_NONE(), + /* 0x2A */ SCHEDULE_CMD_RET_TIME(11, 45, 20, 0, 1), + /* 0x30 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(2, 0x3A - 0x34), + /* 0x34 */ SCHEDULE_CMD_RET_TIME(10, 55, 11, 45, 1), + /* 0x3A */ SCHEDULE_CMD_RET_TIME(10, 55, 11, 45, 3), + /* 0x40 */ SCHEDULE_CMD_RET_TIME(10, 0, 10, 55, 1), + /* 0x46 */ SCHEDULE_CMD_RET_VAL_L(1), }; s32 D_80BDFCBC[] = { @@ -623,7 +635,7 @@ s32 func_80BDF064(EnAl* this, GlobalContext* globalCtx) { return false; } -s32 func_80BDF244(EnAl* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BDF244(EnAl* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret = false; Actor* sp20 = func_80BDE1A0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_GM); Actor* temp_v0 = func_80BDE1A0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_TOTO); @@ -638,10 +650,10 @@ s32 func_80BDF244(EnAl* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80BDF308(EnAl* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BDF308(EnAl* this, GlobalContext* globalCtx, ScheduleResult* arg2) { SubS_UpdateFlags(&this->unk_4C2, 3, 7); - switch (arg2->unk0) { + switch (arg2->result) { case 1: func_80BDE27C(this, 0); break; @@ -655,7 +667,7 @@ s32 func_80BDF308(EnAl* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return true; } -s32 func_80BDF390(EnAl* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BDF390(EnAl* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret; this->actor.flags |= ACTOR_FLAG_1; @@ -664,7 +676,7 @@ s32 func_80BDF390(EnAl* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_4C2 = 0; this->unk_4D4 = 40.0f; - switch (arg2->unk0) { + switch (arg2->result) { case 3: ret = func_80BDF244(this, globalCtx, arg2); break; @@ -734,20 +746,19 @@ void func_80BDF578(EnAl* this, GlobalContext* globalCtx) { } void func_80BDF5E8(EnAl* this, GlobalContext* globalCtx) { - u32* unk14 = &gSaveContext.save.daySpeed; - struct_80133038_arg2 sp20; + ScheduleResult sp20; - this->unk_4E0 = REG(15) + *unk14; - if (!func_80133038(globalCtx, D_80BDFC70, &sp20) || - ((this->unk_35C != sp20.unk0) && !func_80BDF390(this, globalCtx, &sp20))) { + this->unk_4E0 = REG(15) + ((void)0, gSaveContext.save.daySpeed); + if (!Schedule_RunScript(globalCtx, D_80BDFC70, &sp20) || + ((this->unk_35C != sp20.result) && !func_80BDF390(this, globalCtx, &sp20))) { this->actor.shape.shadowDraw = NULL; this->actor.flags &= ~ACTOR_FLAG_1; - sp20.unk0 = 0; + sp20.result = 0; } else { this->actor.shape.shadowDraw = ActorShadow_DrawCircle; this->actor.flags |= ACTOR_FLAG_1; } - this->unk_35C = sp20.unk0; + this->unk_35C = sp20.result; this->unk_368 = func_80BDE384(this, globalCtx); func_80BDF578(this, globalCtx); } diff --git a/src/overlays/actors/ovl_En_Baba/z_en_baba.c b/src/overlays/actors/ovl_En_Baba/z_en_baba.c index a2f28a6ddd..4d9c7bad39 100644 --- a/src/overlays/actors/ovl_En_Baba/z_en_baba.c +++ b/src/overlays/actors/ovl_En_Baba/z_en_baba.c @@ -107,8 +107,16 @@ static DamageTable sDamageTable = { /* Powder Keg */ DMG_ENTRY(1, 0x0), }; -s32 D_80BAA488[] = { - 0x0C000119, 0x0A006E14, 0x02000000, 0x1E080F00, 0x1E030400, 0x01050E00, 0x00001E02, 0x05050000, +static u8 D_80BAA488[] = { + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(1, 0x1D - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_BACKTOWN, 0x1C - 0x08), + /* 0x08 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 0, 0, 30, 0x16 - 0x0E), + /* 0x0E */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(0, 30, 0x15 - 0x12), + /* 0x12 */ SCHEDULE_CMD_RET_VAL_L(1), + /* 0x15 */ SCHEDULE_CMD_RET_NONE(), + /* 0x16 */ SCHEDULE_CMD_RET_TIME(0, 0, 0, 30, 2), + /* 0x1C */ SCHEDULE_CMD_RET_NONE(), + /* 0x1D */ SCHEDULE_CMD_RET_NONE(), }; s32 D_80BAA4A8[] = { -1, -1, 0 }; @@ -305,13 +313,13 @@ void func_80BA8DF4(EnBaba* this, GlobalContext* globalCtx) { } } -s32 func_80BA8F88(EnBaba* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BA8F88(EnBaba* this, GlobalContext* globalCtx, ScheduleResult* arg2) { u16 sp26 = (u16)(gSaveContext.save.time - 0x3FFC); u16 temp; u8 sp23 = ENBABA_GET_3F00(&this->actor); - if (D_80BAA4A8[arg2->unk0] >= 0) { - this->unk_410 = SubS_GetAdditionalPath(globalCtx, sp23, D_80BAA4A8[arg2->unk0]); + if (D_80BAA4A8[arg2->result] >= 0) { + this->unk_410 = SubS_GetAdditionalPath(globalCtx, sp23, D_80BAA4A8[arg2->result]); } if (this->unk_410 == NULL) { @@ -321,13 +329,13 @@ s32 func_80BA8F88(EnBaba* this, GlobalContext* globalCtx, struct_80133038_arg2* if ((this->unk_434 != 0) && (this->unk_436 >= 0)) { temp = sp26; } else { - temp = arg2->unk4; + temp = arg2->time0; } - if (arg2->unk8 < temp) { - this->unk_424 = (temp - arg2->unk8) + 0xFFFF; + if (arg2->time1 < temp) { + this->unk_424 = (temp - arg2->time1) + 0xFFFF; } else { - this->unk_424 = arg2->unk8 - temp; + this->unk_424 = arg2->time1 - temp; } this->unk_430 = sp26 - temp; @@ -339,10 +347,10 @@ s32 func_80BA8F88(EnBaba* this, GlobalContext* globalCtx, struct_80133038_arg2* return true; } -s32 func_80BA9110(EnBaba* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BA9110(EnBaba* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret; - switch (arg2->unk0) { + switch (arg2->result) { default: ret = false; break; @@ -583,21 +591,20 @@ void func_80BA9B24(EnBaba* this, GlobalContext* globalCtx) { } void func_80BA9B80(EnBaba* this, GlobalContext* globalCtx) { - u32* unk14 = &gSaveContext.save.daySpeed; - struct_80133038_arg2 sp20; + ScheduleResult sp20; - this->unk_436 = REG(15) + *unk14; + this->unk_436 = REG(15) + ((void)0, gSaveContext.save.daySpeed); - if (!func_80133038(globalCtx, D_80BAA488, &sp20) || - ((this->unk_434 != sp20.unk0) && !func_80BA9110(this, globalCtx, &sp20))) { + if (!Schedule_RunScript(globalCtx, D_80BAA488, &sp20) || + ((this->unk_434 != sp20.result) && !func_80BA9110(this, globalCtx, &sp20))) { this->unk_40A &= ~0x80; this->actor.flags &= ~ACTOR_FLAG_1; - sp20.unk0 = false; + sp20.result = false; } else { this->unk_40A |= 0x80; this->actor.flags |= ACTOR_FLAG_1; } - this->unk_434 = sp20.unk0; + this->unk_434 = sp20.result; func_80BA93AC(this, globalCtx); diff --git a/src/overlays/actors/ovl_En_Door/z_en_door.c b/src/overlays/actors/ovl_En_Door/z_en_door.c index bb1c574e2d..fe65bb30d8 100644 --- a/src/overlays/actors/ovl_En_Door/z_en_door.c +++ b/src/overlays/actors/ovl_En_Door/z_en_door.c @@ -38,104 +38,243 @@ void func_808670F0(EnDoor*, GlobalContext*); void func_80866A5C(EnDoor*, GlobalContext*); u8 D_808675D0[] = { - 0x0C, 0x00, 0x03, 0x0E, 0x02, 0x06, 0x00, 0x17, 0x00, 0x08, - 0x02, 0x00, 0x00, 0x06, 0x00, 0x02, 0x09, 0x07, 0x05, 0x00, + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(3, 0x12 - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(6, 0, 23, 0, 0x12 - 0x0A), + /* 0x0A */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 0, 6, 0, 0x12 - 0x10), + /* 0x10 */ SCHEDULE_CMD_RET_VAL_S(7), + /* 0x12 */ SCHEDULE_CMD_RET_NONE(), }; u8 D_808675E4[] = { - 0x0F, 0x09, 0x00, 0x47, 0x0F, 0x0C, 0x00, 0x15, 0x0C, 0x00, 0x01, 0x13, 0x11, 0x00, 0x0F, 0x0D, - 0x00, 0x0A, 0x0F, 0x0F, 0x00, 0x07, 0x0F, 0x00, 0x00, 0x02, 0x09, 0x09, 0x05, 0x09, 0x08, 0x0C, - 0x00, 0x02, 0x19, 0x00, 0x1C, 0x08, 0x07, 0x0F, 0x0D, 0x00, 0x02, 0x09, 0x09, 0x05, 0x0F, 0x0D, - 0x00, 0xEA, 0x0F, 0x11, 0x00, 0xE7, 0x0F, 0x00, 0x00, 0xE2, 0x09, 0x09, 0x0F, 0x0D, 0x00, 0xDC, - 0x0F, 0x0D, 0x00, 0xD9, 0x0F, 0x12, 0x00, 0x01, 0x05, 0x09, 0x09, 0x09, 0x09, 0x00, 0x00, 0x00, + /* 0x00 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(9, 0, 0x4B - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(12, 0, 0x1D - 0x08), + /* 0x08 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(1, 0x1F - 0x0C), + /* 0x0C */ SCHEDULE_CMD_BRANCH_S(0x0), + /* 0x0E */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(13, 0, 0x1C - 0x12), + /* 0x12 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(15, 0, 0x1D - 0x16), + /* 0x16 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(0, 0, 0x1C - 0x1A), + /* 0x1A */ SCHEDULE_CMD_RET_VAL_S(9), + /* 0x1C */ SCHEDULE_CMD_RET_NONE(), + /* 0x1D */ SCHEDULE_CMD_RET_VAL_S(8), + /* 0x1F */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(2, 0x3C - 0x23), + /* 0x23 */ SCHEDULE_CMD_CHECK_FLAG_S(0x1C, 0x08, 0x2E - 0x27), + /* 0x27 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(13, 0, 0x2D - 0x2B), + /* 0x2B */ SCHEDULE_CMD_RET_VAL_S(9), + /* 0x2D */ SCHEDULE_CMD_RET_NONE(), + /* 0x2E */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(13, 0, 0x1C - 0x32), + /* 0x32 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(17, 0, 0x1D - 0x36), + /* 0x36 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(0, 0, 0x1C - 0x3A), + /* 0x3A */ SCHEDULE_CMD_RET_VAL_S(9), + /* 0x3C */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(13, 0, 0x1C - 0x40), + /* 0x40 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(13, 0, 0x1D - 0x44), + /* 0x44 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(18, 0, 0x49 - 0x48), + /* 0x48 */ SCHEDULE_CMD_RET_NONE(), + /* 0x49 */ SCHEDULE_CMD_RET_VAL_S(9), + /* 0x4B */ SCHEDULE_CMD_RET_VAL_S(9), }; u8 D_80867634[] = { - 0x02, 0x06, 0x00, 0x17, 0x00, 0x02, 0x09, 0x1C, 0x05, 0x00, 0x00, 0x00, + /* 0x0 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(6, 0, 23, 0, 0x8 - 0x6), + /* 0x6 */ SCHEDULE_CMD_RET_VAL_S(28), + /* 0x8 */ SCHEDULE_CMD_RET_NONE(), }; u8 D_80867640[] = { - 0x02, 0x15, 0x00, 0x16, 0x00, 0x01, 0x05, 0x09, 0x0B, 0x00, 0x00, 0x00, + /* 0x0 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(21, 0, 22, 0, 0x7 - 0x6), + /* 0x6 */ SCHEDULE_CMD_RET_NONE(), + /* 0x7 */ SCHEDULE_CMD_RET_VAL_S(11), }; + u8 D_8086764C[] = { - 0x02, 0x16, 0x00, 0x05, 0x00, 0x02, 0x09, 0x0A, 0x05, 0x00, 0x00, 0x00, + /* 0x0 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(22, 0, 5, 0, 0x8 - 0x6), + /* 0x6 */ SCHEDULE_CMD_RET_VAL_S(10), + /* 0x8 */ SCHEDULE_CMD_RET_NONE(), }; + u8 D_80867658[] = { - 0x0C, 0x00, 0x02, 0x0F, 0x00, 0x1C, 0x08, 0x02, 0x09, 0x0C, 0x02, 0x0F, 0x0A, 0x16, 0x00, - 0x02, 0x09, 0x0C, 0x05, 0x0C, 0x00, 0x03, 0x11, 0x0F, 0x0D, 0x00, 0x0D, 0x00, 0x33, 0x08, - 0x02, 0x09, 0x0C, 0x0F, 0x16, 0x00, 0x02, 0x09, 0x0C, 0x05, 0x09, 0x0C, 0x00, 0x00, + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(2, 0x13 - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_FLAG_S(0x1C, 0x08, 0x0A - 0x08), + /* 0x08 */ SCHEDULE_CMD_RET_VAL_S(12), + /* 0x0A */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(15, 10, 22, 0, 0x12 - 0x10), + /* 0x10 */ SCHEDULE_CMD_RET_VAL_S(12), + /* 0x12 */ SCHEDULE_CMD_RET_NONE(), + /* 0x13 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(3, 0x28 - 0x17), + /* 0x17 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(13, 0, 0x28 - 0x1B), + /* 0x1B */ SCHEDULE_CMD_CHECK_FLAG_S(0x33, 0x08, 0x21 - 0x1F), + /* 0x1F */ SCHEDULE_CMD_RET_VAL_S(12), + /* 0x21 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(22, 0, 0x27 - 0x25), + /* 0x25 */ SCHEDULE_CMD_RET_VAL_S(12), + /* 0x27 */ SCHEDULE_CMD_RET_NONE(), + /* 0x28 */ SCHEDULE_CMD_RET_VAL_S(12), }; -u8 D_80867684[] = { 0x05, 0x00, 0x00, 0x00 }; +u8 D_80867684[] = { + /* 0x0 */ SCHEDULE_CMD_RET_NONE(), +}; -u8 D_80867688[] = { 0x0F, 0x16, 0x00, 0x02, 0x09, 0x0F, 0x05, 0x00 }; +u8 D_80867688[] = { + /* 0x0 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(22, 0, 0x6 - 0x4), + /* 0x4 */ SCHEDULE_CMD_RET_VAL_S(15), + /* 0x6 */ SCHEDULE_CMD_RET_NONE(), +}; -u8 D_80867690[] = { 0x0F, 0x16, 0x00, 0x02, 0x09, 0x10, 0x05, 0x00 }; +u8 D_80867690[] = { + /* 0x0 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(22, 0, 0x6 - 0x4), + /* 0x4 */ SCHEDULE_CMD_RET_VAL_S(16), + /* 0x6 */ SCHEDULE_CMD_RET_NONE(), +}; -u8 D_80867698[] = { 0x0F, 0x16, 0x00, 0x02, 0x09, 0x11, 0x05, 0x00 }; +u8 D_80867698[] = { + /* 0x0 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(22, 0, 0x6 - 0x4), + /* 0x4 */ SCHEDULE_CMD_RET_VAL_S(17), + /* 0x6 */ SCHEDULE_CMD_RET_NONE(), +}; u8 D_808676A0[] = { - 0x02, 0x0A, 0x00, 0x15, 0x00, 0x0F, 0x02, 0x16, 0x00, 0x05, 0x00, 0x02, - 0x09, 0x12, 0x08, 0x02, 0x02, 0x09, 0x22, 0x09, 0x21, 0x05, 0x00, 0x00, + /* 0x00 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 0, 21, 0, 0x15 - 0x06), + /* 0x06 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(22, 0, 5, 0, 0x0E - 0x0C), + /* 0x0C */ SCHEDULE_CMD_RET_VAL_S(18), + /* 0x0E */ SCHEDULE_CMD_CHECK_MISC_S(SCHEDULE_CHECK_MISC_MASK_ROMANI, 0x13 - 0x11), + /* 0x11 */ SCHEDULE_CMD_RET_VAL_S(34), + /* 0x13 */ SCHEDULE_CMD_RET_VAL_S(33), + /* 0x15 */ SCHEDULE_CMD_RET_NONE(), }; u8 D_808676B8[] = { - 0x08, 0x00, 0x14, 0x0C, 0x00, 0x03, 0x07, 0x0F, 0x08, 0x00, 0x01, 0x05, - 0x09, 0x13, 0x02, 0x08, 0x00, 0x14, 0x1E, 0x02, 0x09, 0x13, 0x05, 0x05, + /* 0x00 */ SCHEDULE_CMD_CHECK_MISC_S(SCHEDULE_CHECK_MISC_ROOM_KEY, 0x17 - 0x03), + /* 0x03 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(3, 0x0E - 0x07), + /* 0x07 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(8, 0, 0x0C - 0x0B), + /* 0x0B */ SCHEDULE_CMD_RET_NONE(), + /* 0x0C */ SCHEDULE_CMD_RET_VAL_S(19), + /* 0x0E */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(8, 0, 20, 30, 0x16 - 0x14), + /* 0x14 */ SCHEDULE_CMD_RET_VAL_S(19), + /* 0x16 */ SCHEDULE_CMD_RET_NONE(), + /* 0x17 */ SCHEDULE_CMD_RET_NONE(), }; -u8 D_808676D0[] = { 0x05, 0x00, 0x00, 0x00 }; +u8 D_808676D0[] = { + /* 0x0 */ SCHEDULE_CMD_RET_NONE(), +}; -u8 D_808676D4[] = { 0x05, 0x00, 0x00, 0x00 }; +u8 D_808676D4[] = { + /* 0x0 */ SCHEDULE_CMD_RET_NONE(), +}; -u8 D_808676D8[] = { 0x0C, 0x00, 0x03, 0x05, 0x0F, 0x12, 0x00, 0x01, 0x05, 0x09, 0x14, 0x00 }; +u8 D_808676D8[] = { + /* 0x0 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(3, 0x9 - 0x4), + /* 0x4 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(18, 0, 0x9 - 0x8), + /* 0x8 */ SCHEDULE_CMD_RET_NONE(), + /* 0x9 */ SCHEDULE_CMD_RET_VAL_S(20), +}; -u8 D_808676E4[] = { 0x08, 0x00, 0x02, 0x09, 0x16, 0x05, 0x00, 0x00 }; +u8 D_808676E4[] = { + /* 0x0 */ SCHEDULE_CMD_CHECK_MISC_S(SCHEDULE_CHECK_MISC_ROOM_KEY, 0x5 - 0x3), + /* 0x3 */ SCHEDULE_CMD_RET_VAL_S(22), + /* 0x5 */ SCHEDULE_CMD_RET_NONE(), +}; -u8 D_808676EC[] = { 0x05, 0x00, 0x00, 0x00 }; +u8 D_808676EC[] = { + /* 0x0 */ SCHEDULE_CMD_RET_NONE(), +}; u8 D_808676F0[] = { - 0x0C, 0x00, 0x03, 0x05, 0x0F, 0x0A, 0x00, 0x07, 0x05, 0x02, - 0x0A, 0x00, 0x14, 0x00, 0xF9, 0x09, 0x15, 0x00, 0x00, 0x00, + /* 0x0 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(3, 0x9 - 0x4), + /* 0x4 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(10, 0, 0xF - 0x8), + /* 0x8 */ SCHEDULE_CMD_RET_NONE(), + /* 0x9 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 0, 20, 0, 0x8 - 0xF), + /* 0xF */ SCHEDULE_CMD_RET_VAL_S(21), }; -u8 D_80867704[] = { 0x05, 0x00, 0x00, 0x00 }; -u8 D_80867708[] = { 0x05, 0x00, 0x00, 0x00 }; -u8 D_8086770C[] = { 0x05, 0x00, 0x00, 0x00 }; -u8 D_80867710[] = { 0x05, 0x00, 0x00, 0x00 }; +u8 D_80867704[] = { + /* 0x0 */ SCHEDULE_CMD_RET_NONE(), +}; -u8 D_80867714[] = { 0x0F, 0x14, 0x00, 0x02, 0x09, 0x17, 0x05, 0x00 }; +u8 D_80867708[] = { + /* 0x0 */ SCHEDULE_CMD_RET_NONE(), +}; + +u8 D_8086770C[] = { + /* 0x0 */ SCHEDULE_CMD_RET_NONE(), +}; + +u8 D_80867710[] = { + /* 0x0 */ SCHEDULE_CMD_RET_NONE(), +}; + +u8 D_80867714[] = { + /* 0x0 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(20, 0, 0x6 - 0x4), + /* 0x4 */ SCHEDULE_CMD_RET_VAL_S(23), + /* 0x6 */ SCHEDULE_CMD_RET_NONE(), +}; u8 D_8086771C[] = { - 0x0C, 0x00, 0x01, 0x07, 0x0F, 0x02, 0x1E, 0x02, 0x09, 0x18, 0x05, 0x0C, - 0x00, 0x03, 0xFB, 0x0F, 0x14, 0x00, 0xF7, 0x09, 0x0C, 0x00, 0x00, 0x00, + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(1, 0x0B - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(2, 30, 0x0A - 0x08), + /* 0x08 */ SCHEDULE_CMD_RET_VAL_S(24), + /* 0x0A */ SCHEDULE_CMD_RET_NONE(), + /* 0x0B */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(3, 0x0A - 0x0F), + /* 0x0F */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(20, 0, 0x0A - 0x13), + /* 0x13 */ SCHEDULE_CMD_RET_VAL_S(12), }; -u8 D_80867734[] = { 0x0F, 0x14, 0x00, 0x02, 0x09, 0x19, 0x05, 0x00 }; +u8 D_80867734[] = { + /* 0x0 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(20, 0, 0x6 - 0x4), + /* 0x4 */ SCHEDULE_CMD_RET_VAL_S(25), + /* 0x6 */ SCHEDULE_CMD_RET_NONE(), +}; -u8 D_8086773C[] = { 0x0F, 0x14, 0x00, 0x02, 0x09, 0x1A, 0x05, 0x00 }; +u8 D_8086773C[] = { + /* 0x0 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(20, 0, 0x6 - 0x4), + /* 0x4 */ SCHEDULE_CMD_RET_VAL_S(26), + /* 0x6 */ SCHEDULE_CMD_RET_NONE(), +}; u8 D_80867744[] = { - 0x0C, 0x00, 0x02, 0x04, 0x00, 0x63, 0x80, 0x06, 0x0F, 0x14, 0x00, 0x08, - 0x09, 0x1B, 0x0F, 0x12, 0x00, 0x02, 0x09, 0x1B, 0x05, 0x00, 0x00, 0x00, + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(2, 0x08 - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_FLAG_S(0x63, 0x80, 0x0E - 0x08), + /* 0x08 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(20, 0, 0x14 - 0x0C), + /* 0x0C */ SCHEDULE_CMD_RET_VAL_S(27), + /* 0x0E */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(18, 0, 0x14 - 0x12), + /* 0x12 */ SCHEDULE_CMD_RET_VAL_S(27), + /* 0x14 */ SCHEDULE_CMD_RET_NONE(), }; u8 D_8086775C[] = { - 0x00, 0x34, 0x20, 0x17, 0x00, 0x4B, 0x20, 0x13, 0x00, 0x0E, 0x04, 0x02, 0x09, 0x1D, - 0x00, 0x3B, 0x01, 0x08, 0x00, 0x3D, 0x02, 0x02, 0x09, 0x1E, 0x09, 0x1F, 0x05, 0x05, + /* 0x00 */ SCHEDULE_CMD_CHECK_FLAG_S(0x34, 0x20, 0x1B - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_FLAG_S(0x4B, 0x20, 0x1B - 0x08), + /* 0x08 */ SCHEDULE_CMD_CHECK_FLAG_S(0x0E, 0x04, 0x0E - 0x0C), + /* 0x0C */ SCHEDULE_CMD_RET_VAL_S(29), + /* 0x0E */ SCHEDULE_CMD_CHECK_FLAG_S(0x3B, 0x01, 0x1A - 0x12), + /* 0x12 */ SCHEDULE_CMD_CHECK_FLAG_S(0x3D, 0x02, 0x18 - 0x16), + /* 0x16 */ SCHEDULE_CMD_RET_VAL_S(30), + /* 0x18 */ SCHEDULE_CMD_RET_VAL_S(31), + /* 0x1A */ SCHEDULE_CMD_RET_NONE(), + /* 0x1B */ SCHEDULE_CMD_RET_NONE(), }; -u8 D_80867778[] = { 0x09, 0x20, 0x00, 0x00 }; -u8 D_8086777C[] = { 0x05, 0x00, 0x00, 0x00 }; -u8 D_80867780[] = { 0x05, 0x00, 0x00, 0x00 }; -u8 D_80867784[] = { 0x0F, 0x16, 0x00, 0x02, 0x09, 0x23, 0x05, 0x00 }; +u8 D_80867778[] = { + /* 0x0 */ SCHEDULE_CMD_RET_VAL_S(32), +}; -// void* seems to keep the compiler happy. -void* D_8086778C[] = { - &D_808675D0, &D_808675E4, &D_80867634, &D_80867640, &D_8086764C, &D_80867658, &D_80867684, &D_80867688, - &D_80867690, &D_80867698, &D_808676A0, &D_808676B8, &D_808676D0, &D_808676D4, &D_808676D8, &D_808676E4, - &D_808676EC, &D_808676F0, &D_80867704, &D_80867708, &D_8086770C, &D_80867710, &D_80867714, &D_8086771C, - &D_80867734, &D_8086773C, &D_80867744, &D_8086775C, &D_80867778, &D_8086777C, &D_80867780, &D_80867784, +u8 D_8086777C[] = { + /* 0x0 */ SCHEDULE_CMD_RET_NONE(), +}; + +u8 D_80867780[] = { + /* 0x0 */ SCHEDULE_CMD_RET_NONE(), +}; + +u8 D_80867784[] = { + /* 0x0 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(22, 0, 0x6 - 0x4), + /* 0x4 */ SCHEDULE_CMD_RET_VAL_S(35), + /* 0x6 */ SCHEDULE_CMD_RET_NONE(), +}; + +u8* D_8086778C[] = { + D_808675D0, D_808675E4, D_80867634, D_80867640, D_8086764C, D_80867658, D_80867684, D_80867688, + D_80867690, D_80867698, D_808676A0, D_808676B8, D_808676D0, D_808676D4, D_808676D8, D_808676E4, + D_808676EC, D_808676F0, D_80867704, D_80867708, D_8086770C, D_80867710, D_80867714, D_8086771C, + D_80867734, D_8086773C, D_80867744, D_8086775C, D_80867778, D_8086777C, D_80867780, D_80867784, }; const ActorInit En_Door_InitVars = { @@ -336,7 +475,6 @@ void func_80866B20(EnDoor* this, GlobalContext* globalCtx) { s32 temp_a1_2; s32 temp_t0; u8 temp_a1; - s32 pad; if (Actor_ProcessTalkRequest(&this->dyna.actor, &globalCtx->state) && (this->dyna.actor.textId == 0x1821)) { D_80867BC0[0] = 1; @@ -396,10 +534,10 @@ void func_80866B20(EnDoor* this, GlobalContext* globalCtx) { this->dyna.actor.textId = baseTextId + textIdOffset; } } else if ((this->unk_1A4 == 5) && (playerPosRelToDoor.z > 0.0f)) { - struct_80133038_arg2 sp30; + ScheduleResult sp30; - if (func_80133038(globalCtx, D_8086778C[this->switchFlag], &sp30) != 0) { - this->dyna.actor.textId = sp30.unk0 + 0x1800; + if (Schedule_RunScript(globalCtx, D_8086778C[this->switchFlag], &sp30) != 0) { + this->dyna.actor.textId = sp30.result + 0x1800; player->doorType = ((this->dyna.actor.textId == 0x1821) && (D_80867BC0[0] != 0)) ? 5 : -1; } diff --git a/src/overlays/actors/ovl_En_Gm/z_en_gm.c b/src/overlays/actors/ovl_En_Gm/z_en_gm.c index 0c80ce319d..e598fe78f6 100644 --- a/src/overlays/actors/ovl_En_Gm/z_en_gm.c +++ b/src/overlays/actors/ovl_En_Gm/z_en_gm.c @@ -20,21 +20,102 @@ void EnGm_Draw(Actor* thisx, GlobalContext* globalCtx); void func_80950CDC(EnGm* this, GlobalContext* globalCtx); void func_80950DB8(EnGm* this, GlobalContext* globalCtx); -static u32 D_80951820[] = { - 0x0D000101, 0x360A0061, 0x25020600, 0x09001902, 0x0900090A, 0x0D02090A, 0x090F0105, 0x0E090A09, 0x0F0F0E09, - 0x00090A18, 0x0E060009, 0x00060A00, 0x6C490209, 0x0A090F3D, 0x02090F0A, 0x0031020A, 0x000A0525, 0x020C0F0C, - 0x1419020C, 0x140C320D, 0x020C320C, 0x3701050E, 0x0C320C37, 0x0C0E0C14, 0x0C32160E, 0x0C0F0C14, 0x0B0E0A00, - 0x0A050A0E, 0x090F0A00, 0x150E090A, 0x090F090B, 0x00120085, 0x020A000A, 0x0579020A, 0x050A0A6D, 0x020A0A0A, - 0x1E61020A, 0x1E0A2855, 0x020A280A, 0x2D49020A, 0x2D0A373D, 0x020A370B, 0x2D31020B, 0x2D0B3725, 0x020B370C, - 0x0019020C, 0x000C0F0D, 0x020C0F0C, 0x1401050E, 0x0C0F0C14, 0x110E0C00, 0x0C0F1D0E, 0x0B370C00, 0x130E0B2D, - 0x0B371C0E, 0x0A370B2D, 0x020E0A2D, 0x0A371B0E, 0x0A280A2D, 0x120E0A1E, 0x0A281A0E, 0x0A0A0A1E, 0x010E0A05, - 0x0A0A190E, 0x0A000A05, 0x100A0015, 0x31020C37, 0x0D002502, 0x0D000D19, 0x19020D19, 0x15050D02, 0x15370505, - 0x01050E15, 0x37050505, 0x0E0D1915, 0x05030E0D, 0x000D191E, 0x0E0C370D, 0x0014050D, 0x000200AB, 0x01320100, - 0x880A0061, 0x31020600, 0x12002502, 0x12001500, 0x19021500, 0x150A0D02, 0x150A150F, 0x01050E15, 0x0A150F0F, - 0x0E150015, 0x0A180E12, 0x00150006, 0x0E060012, 0x00070A00, 0x6C250215, 0x0A150F19, 0x02150F15, 0x190D0215, - 0x19151E01, 0x050E1519, 0x151E0E0E, 0x150F1519, 0x170E150A, 0x150F0D0A, 0x00152502, 0x151E152D, 0x1902152D, - 0x160A0D02, 0x160A0600, 0x01050E16, 0x0A060005, 0x0E152D16, 0x0A1E0E15, 0x1E152D14, 0x050A0061, 0x19020600, - 0x12000D02, 0x12000600, 0x01050E00, 0x00000008, 0x0E060012, 0x00070505, +static u8 D_80951820[] = { + /* 0x000 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_L(1, 0x13B - 0x005), + /* 0x005 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_YADOYA, 0x02E - 0x009), + /* 0x009 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(6, 0, 9, 0, 0x028 - 0x00F), + /* 0x00F */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(9, 0, 9, 10, 0x022 - 0x015), + /* 0x015 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(9, 10, 9, 15, 0x01C - 0x01B), + /* 0x01B */ SCHEDULE_CMD_RET_NONE(), + /* 0x01C */ SCHEDULE_CMD_RET_TIME(9, 10, 9, 15, 15), + /* 0x022 */ SCHEDULE_CMD_RET_TIME(9, 0, 9, 10, 24), + /* 0x028 */ SCHEDULE_CMD_RET_TIME(6, 0, 9, 0, 6), + /* 0x02E */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_TOWN, 0x07B - 0x032), + /* 0x032 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(9, 10, 9, 15, 0x075 - 0x038), + /* 0x038 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(9, 15, 10, 0, 0x06F - 0x03E), + /* 0x03E */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 0, 10, 5, 0x069 - 0x044), + /* 0x044 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(12, 15, 12, 20, 0x063 - 0x04A), + /* 0x04A */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(12, 20, 12, 50, 0x05D - 0x050), + /* 0x050 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(12, 50, 12, 55, 0x057 - 0x056), + /* 0x056 */ SCHEDULE_CMD_RET_NONE(), + /* 0x057 */ SCHEDULE_CMD_RET_TIME(12, 50, 12, 55, 12), + /* 0x05D */ SCHEDULE_CMD_RET_TIME(12, 20, 12, 50, 22), + /* 0x063 */ SCHEDULE_CMD_RET_TIME(12, 15, 12, 20, 11), + /* 0x069 */ SCHEDULE_CMD_RET_TIME(10, 0, 10, 5, 10), + /* 0x06F */ SCHEDULE_CMD_RET_TIME(9, 15, 10, 0, 21), + /* 0x075 */ SCHEDULE_CMD_RET_TIME(9, 10, 9, 15, 9), + /* 0x07B */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_L(SCENE_SONCHONOIE, 0x105 - 0x080), + /* 0x080 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 0, 10, 5, 0x0FF - 0x086), + /* 0x086 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 5, 10, 10, 0x0F9 - 0x08C), + /* 0x08C */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 10, 10, 30, 0x0F3 - 0x092), + /* 0x092 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 30, 10, 40, 0x0ED - 0x098), + /* 0x098 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 40, 10, 45, 0x0E7 - 0x09E), + /* 0x09E */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 45, 10, 55, 0x0E1 - 0x0A4), + /* 0x0A4 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 55, 11, 45, 0x0DB - 0x0AA), + /* 0x0AA */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(11, 45, 11, 55, 0x0D5 - 0x0B0), + /* 0x0B0 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(11, 55, 12, 0, 0x0CF - 0x0B6), + /* 0x0B6 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(12, 0, 12, 15, 0x0C9 - 0x0BC), + /* 0x0BC */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(12, 15, 12, 20, 0x0C3 - 0x0C2), + /* 0x0C2 */ SCHEDULE_CMD_RET_NONE(), + /* 0x0C3 */ SCHEDULE_CMD_RET_TIME(12, 15, 12, 20, 17), + /* 0x0C9 */ SCHEDULE_CMD_RET_TIME(12, 0, 12, 15, 29), + /* 0x0CF */ SCHEDULE_CMD_RET_TIME(11, 55, 12, 0, 19), + /* 0x0D5 */ SCHEDULE_CMD_RET_TIME(11, 45, 11, 55, 28), + /* 0x0DB */ SCHEDULE_CMD_RET_TIME(10, 55, 11, 45, 2), + /* 0x0E1 */ SCHEDULE_CMD_RET_TIME(10, 45, 10, 55, 27), + /* 0x0E7 */ SCHEDULE_CMD_RET_TIME(10, 40, 10, 45, 18), + /* 0x0ED */ SCHEDULE_CMD_RET_TIME(10, 30, 10, 40, 26), + /* 0x0F3 */ SCHEDULE_CMD_RET_TIME(10, 10, 10, 30, 1), + /* 0x0F9 */ SCHEDULE_CMD_RET_TIME(10, 5, 10, 10, 25), + /* 0x0FF */ SCHEDULE_CMD_RET_TIME(10, 0, 10, 5, 16), + /* 0x105 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_MILK_BAR, 0x13A - 0x109), + /* 0x109 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(12, 55, 13, 0, 0x134 - 0x10F), + /* 0x10F */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 0, 13, 25, 0x12E - 0x115), + /* 0x115 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 25, 21, 5, 0x128 - 0x11B), + /* 0x11B */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(21, 55, 5, 5, 0x122 - 0x121), + /* 0x121 */ SCHEDULE_CMD_RET_NONE(), + /* 0x122 */ SCHEDULE_CMD_RET_TIME(21, 55, 5, 5, 5), + /* 0x128 */ SCHEDULE_CMD_RET_TIME(13, 25, 21, 5, 3), + /* 0x12E */ SCHEDULE_CMD_RET_TIME(13, 0, 13, 25, 30), + /* 0x134 */ SCHEDULE_CMD_RET_TIME(12, 55, 13, 0, 20), + /* 0x13A */ SCHEDULE_CMD_RET_NONE(), + /* 0x13B */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_L(2, 0x1EB - 0x140), + /* 0x140 */ SCHEDULE_CMD_CHECK_FLAG_L(0x32, 0x01, 0x1CD - 0x145), + /* 0x145 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_YADOYA, 0x17A - 0x149), + /* 0x149 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(6, 0, 18, 0, 0x174 - 0x14F), + /* 0x14F */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(18, 0, 21, 0, 0x16E - 0x155), + /* 0x155 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(21, 0, 21, 10, 0x168 - 0x15B), + /* 0x15B */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(21, 10, 21, 15, 0x162 - 0x161), + /* 0x161 */ SCHEDULE_CMD_RET_NONE(), + /* 0x162 */ SCHEDULE_CMD_RET_TIME(21, 10, 21, 15, 15), + /* 0x168 */ SCHEDULE_CMD_RET_TIME(21, 0, 21, 10, 24), + /* 0x16E */ SCHEDULE_CMD_RET_TIME(18, 0, 21, 0, 6), + /* 0x174 */ SCHEDULE_CMD_RET_TIME(6, 0, 18, 0, 7), + /* 0x17A */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_TOWN, 0x1A3 - 0x17E), + /* 0x17E */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(21, 10, 21, 15, 0x19D - 0x184), + /* 0x184 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(21, 15, 21, 25, 0x197 - 0x18A), + /* 0x18A */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(21, 25, 21, 30, 0x191 - 0x190), + /* 0x190 */ SCHEDULE_CMD_RET_NONE(), + /* 0x191 */ SCHEDULE_CMD_RET_TIME(21, 25, 21, 30, 14), + /* 0x197 */ SCHEDULE_CMD_RET_TIME(21, 15, 21, 25, 23), + /* 0x19D */ SCHEDULE_CMD_RET_TIME(21, 10, 21, 15, 13), + /* 0x1A3 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_MILK_BAR, 0x1CC - 0x1A7), + /* 0x1A7 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(21, 30, 21, 45, 0x1C6 - 0x1AD), + /* 0x1AD */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(21, 45, 22, 10, 0x1C0 - 0x1B3), + /* 0x1B3 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(22, 10, 6, 0, 0x1BA - 0x1B9), + /* 0x1B9 */ SCHEDULE_CMD_RET_NONE(), + /* 0x1BA */ SCHEDULE_CMD_RET_TIME(22, 10, 6, 0, 5), + /* 0x1C0 */ SCHEDULE_CMD_RET_TIME(21, 45, 22, 10, 30), + /* 0x1C6 */ SCHEDULE_CMD_RET_TIME(21, 30, 21, 45, 20), + /* 0x1CC */ SCHEDULE_CMD_RET_NONE(), + /* 0x1CD */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_YADOYA, 0x1EA - 0x1D1), + /* 0x1D1 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(6, 0, 18, 0, 0x1E4 - 0x1D7), + /* 0x1D7 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(18, 0, 6, 0, 0x1DE - 0x1DD), + /* 0x1DD */ SCHEDULE_CMD_RET_NONE(), + /* 0x1DE */ SCHEDULE_CMD_RET_TIME(0, 0, 0, 0, 8), + /* 0x1E4 */ SCHEDULE_CMD_RET_TIME(6, 0, 18, 0, 7), + /* 0x1EA */ SCHEDULE_CMD_RET_NONE(), + /* 0x1EB */ SCHEDULE_CMD_RET_NONE(), }; static s32 D_80951A0C[] = { @@ -889,7 +970,7 @@ s32 func_8094F53C(EnGm* this, GlobalContext* globalCtx) { return false; } -s32 func_8094F7D0(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2, u8 arg3, s16 arg4) { +s32 func_8094F7D0(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2, u8 arg3, s16 arg4) { u8 sp4F = ENGM_GET_FF(&this->actor); Vec3s* sp48; Vec3f sp3C; @@ -901,8 +982,8 @@ s32 func_8094F7D0(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_234 = NULL; actor = func_8094DEE0(this, globalCtx, arg3, arg4); - if (D_80951A0C[arg2->unk0] >= 0) { - this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80951A0C[arg2->unk0]); + if (D_80951A0C[arg2->result] >= 0) { + this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80951A0C[arg2->result]); } if ((actor != NULL) && (actor->update != NULL)) { @@ -919,8 +1000,8 @@ s32 func_8094F7D0(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_8094F904(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { - u16 sp56 = gSaveContext.save.time - 0x3FFC; +s32 func_8094F904(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { + u16 sp56 = SCHEDULE_TIME_NOW; u8 sp55 = ENGM_GET_FF(&this->actor); EnDoor* door; Vec3s* sp4C; @@ -930,10 +1011,10 @@ s32 func_8094F904(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar s32 ret = false; this->unk_234 = NULL; - door = func_8094DF90(globalCtx, arg2->unk0); + door = func_8094DF90(globalCtx, arg2->result); - if (D_80951A0C[arg2->unk0] >= 0) { - this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp55, D_80951A0C[arg2->unk0]); + if (D_80951A0C[arg2->result] >= 0) { + this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp55, D_80951A0C[arg2->result]); } if ((door != NULL) && (door->dyna.actor.update != NULL)) { @@ -952,8 +1033,8 @@ s32 func_8094F904(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_261 = 75; } - this->unk_3B8 = arg2->unk8 - arg2->unk4; - this->unk_3BA = sp56 - arg2->unk4; + this->unk_3B8 = arg2->time1 - arg2->time0; + this->unk_3BA = sp56 - arg2->time0; this->actor.flags &= ~ACTOR_FLAG_1; this->unk_3A4 |= 0x100; this->unk_3A4 |= 0x200; @@ -965,16 +1046,16 @@ s32 func_8094F904(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_8094FAC4(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { - u16 sp2E = gSaveContext.save.time - 0x3FFC; +s32 func_8094FAC4(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { + u16 sp2E = SCHEDULE_TIME_NOW; u16 phi_v1; u8 sp2B = ENGM_GET_FF(&this->actor); s32 pad; s32 ret = false; this->unk_234 = NULL; - if (D_80951A0C[arg2->unk0] >= 0) { - this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp2B, D_80951A0C[arg2->unk0]); + if (D_80951A0C[arg2->result] >= 0) { + this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp2B, D_80951A0C[arg2->result]); } if ((this->unk_234 != NULL) && (this->unk_234->count < 3)) { @@ -985,13 +1066,13 @@ s32 func_8094FAC4(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar if ((this->unk_258 < 9) && (this->unk_258 != 0) && (this->unk_3C4 >= 0)) { phi_v1 = sp2E; } else { - phi_v1 = arg2->unk4; + phi_v1 = arg2->time0; } - if (arg2->unk8 < phi_v1) { - this->unk_248 = (phi_v1 - arg2->unk8) + 0xFFFF; + if (arg2->time1 < phi_v1) { + this->unk_248 = (phi_v1 - arg2->time1) + 0xFFFF; } else { - this->unk_248 = arg2->unk8 - phi_v1; + this->unk_248 = arg2->time1 - phi_v1; } this->unk_254 = sp2E - phi_v1; @@ -1010,7 +1091,7 @@ s32 func_8094FAC4(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_8094FCC4(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_8094FCC4(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { static Vec3f D_80951D90 = { 64.0f, 0.0f, -122.0f }; s32 ret = false; @@ -1030,7 +1111,7 @@ s32 func_8094FCC4(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_8094FD88(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_8094FD88(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret = false; if (func_8094F7D0(this, globalCtx, arg2, ACTORCAT_NPC, ACTOR_EN_RECEPGIRL)) { @@ -1043,7 +1124,7 @@ s32 func_8094FD88(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_8094FE10(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_8094FE10(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret = false; Actor* al; @@ -1064,7 +1145,7 @@ s32 func_8094FE10(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_8094FF04(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_8094FF04(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { static Vec3f D_80951D9C = { 64.0f, 0.0f, -122.0f }; u8 sp4F = ENGM_GET_FF(&this->actor); Vec3s* sp48; @@ -1075,8 +1156,8 @@ s32 func_8094FF04(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_234 = NULL; - if (D_80951A0C[arg2->unk0] >= 0) { - this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80951A0C[arg2->unk0]); + if (D_80951A0C[arg2->result] >= 0) { + this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80951A0C[arg2->result]); } if (this->unk_234 != NULL) { @@ -1106,7 +1187,7 @@ s32 func_8094FF04(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80950088(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80950088(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { static Vec3f D_80951DA8 = { 278.0f, 0.0f, 223.0f }; static Vec3s D_80951DB4 = { 0x0000, 0xC000, 0x0000 }; s32 pad; @@ -1121,7 +1202,7 @@ s32 func_80950088(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return true; } -s32 func_80950120(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80950120(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { static Vec3f D_80951DBC = { -525.0f, 214.0f, 515.0f }; static Vec3s D_80951DC8 = { 0x0000, 0x38E0, 0x0000 }; s32 pad; @@ -1136,7 +1217,7 @@ s32 func_80950120(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return true; } -s32 func_809501B8(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_809501B8(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { static Vec3f D_80951DD0 = { -334.0f, 225.0f, 903.0f }; static Vec3s D_80951DDC = { 0x0000, 0x7FFF, 0x0000 }; s32 pad; @@ -1157,7 +1238,7 @@ s32 func_809501B8(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return true; } -s32 func_80950280(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80950280(EnGm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 phi_v1; this->actor.flags |= ACTOR_FLAG_1; @@ -1168,7 +1249,7 @@ s32 func_80950280(EnGm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_3CC = 8; this->unk_3B4 = 40.0f; - switch (arg2->unk0) { + switch (arg2->result) { case 1: phi_v1 = func_8094FD88(this, globalCtx, arg2); break; @@ -1493,21 +1574,20 @@ void func_80950C24(EnGm* this, GlobalContext* globalCtx) { } void func_80950CDC(EnGm* this, GlobalContext* globalCtx) { - u32* unk_14 = &gSaveContext.save.daySpeed; - struct_80133038_arg2 sp20; + ScheduleResult sp20; - this->unk_3C4 = REG(15) + *unk_14; + this->unk_3C4 = REG(15) + ((void)0, gSaveContext.save.daySpeed); - if (!func_80133038(globalCtx, (void*)&D_80951820, &sp20) || - ((this->unk_258 != sp20.unk0) && !func_80950280(this, globalCtx, &sp20))) { + if (!Schedule_RunScript(globalCtx, D_80951820, &sp20) || + ((this->unk_258 != sp20.result) && !func_80950280(this, globalCtx, &sp20))) { this->actor.shape.shadowDraw = NULL; this->actor.flags &= ~ACTOR_FLAG_1; - sp20.unk0 = 0; + sp20.result = 0; } else { this->actor.shape.shadowDraw = ActorShadow_DrawCircle; this->actor.flags |= ACTOR_FLAG_1; } - this->unk_258 = sp20.unk0; + this->unk_258 = sp20.result; this->unk_268 = func_8094F074(this, globalCtx); func_80950C24(this, globalCtx); } diff --git a/src/overlays/actors/ovl_En_Ig/z_en_ig.c b/src/overlays/actors/ovl_En_Ig/z_en_ig.c index ed747c6401..bbb706326b 100644 --- a/src/overlays/actors/ovl_En_Ig/z_en_ig.c +++ b/src/overlays/actors/ovl_En_Ig/z_en_ig.c @@ -20,13 +20,44 @@ void EnIg_Draw(Actor* thisx, GlobalContext* globalCtx); void func_80BF2AF8(EnIg* this, GlobalContext* globalCtx); void func_80BF2BD4(EnIg* this, GlobalContext* globalCtx); -static s32 D_80BF3260[] = { - 0x0D000100, 0xB10A006C, 0x4E020F19, 0x0F2D4202, 0x0F2D0F32, 0x36004B10, 0x1050210, 0x32103725, - 0x02103711, 0x0F190211, 0x0F12000D, 0x02120006, 0x0001050E, 0x12000600, 0x040E110F, 0x0600020E, - 0x1037110F, 0x0B0E1032, 0x1037060E, 0x0F2D0F32, 0x050E0F19, 0x0F2D0A0A, 0x00615A02, 0x0F2D0F32, - 0x4E020F32, 0x100A4202, 0x100A101E, 0x36004B10, 0x1902101E, 0x10320D02, 0x10321037, 0x01050E10, - 0x32103708, 0x0E101E10, 0x320D0210, 0x1E10320D, 0x02103210, 0x3701050E, 0x10321037, 0x090E101E, - 0x10320E0E, 0x100A101E, 0x030E0F32, 0x100A0C0E, 0x0F2D0F32, 0x07050500, +static u8 D_80BF3260[] = { + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_L(1, 0xB6 - 0x05), + /* 0x05 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_TOWN, 0x57 - 0x09), + /* 0x09 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(15, 25, 15, 45, 0x51 - 0x0F), + /* 0x0F */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(15, 45, 15, 50, 0x4B - 0x15), + /* 0x15 */ SCHEDULE_CMD_CHECK_FLAG_S(0x4B, 0x10, 0x1A - 0x19), + /* 0x19 */ SCHEDULE_CMD_RET_NONE(), + /* 0x1A */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(16, 50, 16, 55, 0x45 - 0x20), + /* 0x20 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(16, 55, 17, 15, 0x3F - 0x26), + /* 0x26 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(17, 15, 18, 0, 0x39 - 0x2C), + /* 0x2C */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(18, 0, 6, 0, 0x33 - 0x32), + /* 0x32 */ SCHEDULE_CMD_RET_NONE(), + /* 0x33 */ SCHEDULE_CMD_RET_TIME(18, 0, 6, 0, 4), + /* 0x39 */ SCHEDULE_CMD_RET_TIME(17, 15, 6, 0, 2), + /* 0x3F */ SCHEDULE_CMD_RET_TIME(16, 55, 17, 15, 11), + /* 0x45 */ SCHEDULE_CMD_RET_TIME(16, 50, 16, 55, 6), + /* 0x4B */ SCHEDULE_CMD_RET_TIME(15, 45, 15, 50, 5), + /* 0x51 */ SCHEDULE_CMD_RET_TIME(15, 25, 15, 45, 10), + /* 0x57 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_YADOYA, 0xB5 - 0x5B), + /* 0x5B */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(15, 45, 15, 50, 0xAF - 0x61), + /* 0x61 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(15, 50, 16, 10, 0xA9 - 0x67), + /* 0x67 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(16, 10, 16, 30, 0xA3 - 0x6D), + /* 0x6D */ SCHEDULE_CMD_CHECK_FLAG_S(0x4B, 0x10, 0x8A - 0x71), + /* 0x71 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(16, 30, 16, 50, 0x84 - 0x77), + /* 0x77 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(16, 50, 16, 55, 0x7E - 0x7D), + /* 0x7D */ SCHEDULE_CMD_RET_NONE(), + /* 0x7E */ SCHEDULE_CMD_RET_TIME(16, 50, 16, 55, 8), + /* 0x84 */ SCHEDULE_CMD_RET_TIME(16, 30, 16, 50, 13), + /* 0x8A */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(16, 30, 16, 50, 0x9D - 0x90), + /* 0x90 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(16, 50, 16, 55, 0x97 - 0x96), + /* 0x96 */ SCHEDULE_CMD_RET_NONE(), + /* 0x97 */ SCHEDULE_CMD_RET_TIME(16, 50, 16, 55, 9), + /* 0x9D */ SCHEDULE_CMD_RET_TIME(16, 30, 16, 50, 14), + /* 0xA3 */ SCHEDULE_CMD_RET_TIME(16, 10, 16, 30, 3), + /* 0xA9 */ SCHEDULE_CMD_RET_TIME(15, 50, 16, 10, 12), + /* 0xAF */ SCHEDULE_CMD_RET_TIME(15, 45, 15, 50, 7), + /* 0xB5 */ SCHEDULE_CMD_RET_NONE(), + /* 0xB6 */ SCHEDULE_CMD_RET_NONE(), }; static s32 D_80BF3318[] = { -1, -1, 3, 1, 3, 1, 2, 0, 3, 5, 0, 3, 1, 2, 4 }; @@ -233,7 +264,7 @@ void func_80BF13E4(EnIg* this) { Actor* func_80BF146C(EnIg* this, GlobalContext* globalCtx) { Actor* retActor; - if (this->unk_298.unk0 == 3) { + if (this->scheduleResult == 3) { retActor = func_80BF1150(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_AN); } else { retActor = &GET_PLAYER(globalCtx)->actor; @@ -361,7 +392,7 @@ s32 func_80BF17BC(EnIg* this, GlobalContext* globalCtx) { } s32* func_80BF1920(EnIg* this, GlobalContext* globalCtx) { - switch (this->unk_298.unk0) { + switch (this->scheduleResult) { case 3: this->unk_3F8 = func_80BF17BC; return D_80BF335C; @@ -395,8 +426,8 @@ s32 func_80BF19A0(EnIg* this, GlobalContext* globalCtx) { this->unk_3F6 = 0; this->unk_3F8 = NULL; this->actor.child = this->unk_2A8; - this->unk_298.unk4 = func_80BF1920(this, globalCtx); - if ((this->unk_298.unk0 != 2) && (this->unk_298.unk0 != 3) && (this->unk_298.unk0 != 4)) { + this->unk_29C = func_80BF1920(this, globalCtx); + if ((this->scheduleResult != 2) && (this->scheduleResult != 3) && (this->scheduleResult != 4)) { this->unk_3D0 |= 0x20; } this->actionFunc = func_80BF2BD4; @@ -417,7 +448,7 @@ void func_80BF1A60(EnIg* this, GlobalContext* globalCtx) { } s32 func_80BF1AE0(EnIg* this, GlobalContext* globalCtx) { - switch (this->unk_298.unk0) { + switch (this->scheduleResult) { case 3: func_80BF1284(this, 0); break; @@ -465,7 +496,7 @@ s32 func_80BF1B40(EnIg* this, GlobalContext* globalCtx) { return false; } -s32 func_80BF1C44(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2, s32 arg3, s32 arg4) { +s32 func_80BF1C44(EnIg* this, GlobalContext* globalCtx, ScheduleResult* arg2, s32 arg3, s32 arg4) { u8 sp4F = ENIG_GET_FF(&this->actor); Vec3s* sp48; Vec3f sp3C; @@ -477,8 +508,8 @@ s32 func_80BF1C44(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar sp2C = func_80BF1150(this, globalCtx, arg3, arg4); this->unk_274 = NULL; - if (D_80BF3318[arg2->unk0] >= 0) { - this->unk_274 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80BF3318[arg2->unk0]); + if (D_80BF3318[arg2->result] >= 0) { + this->unk_274 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80BF3318[arg2->result]); } if ((sp2C != NULL) && (sp2C->update != NULL)) { @@ -495,7 +526,7 @@ s32 func_80BF1C44(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return sp24; } -s32 func_80BF1D78(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BF1D78(EnIg* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 sp2C = 0; if (func_80BF1C44(this, globalCtx, arg2, ACTORCAT_NPC, ACTOR_EN_AN)) { @@ -508,8 +539,8 @@ s32 func_80BF1D78(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return sp2C; } -s32 func_80BF1DF4(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { - u16 sp56 = gSaveContext.save.time - 0x3FFC; +s32 func_80BF1DF4(EnIg* this, GlobalContext* globalCtx, ScheduleResult* arg2) { + u16 sp56 = SCHEDULE_TIME_NOW; u8 sp55 = ENIG_GET_FF(&this->actor); EnDoor* door; Vec3s* sp4C; @@ -519,10 +550,10 @@ s32 func_80BF1DF4(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar s32 ret = false; this->unk_274 = NULL; - door = func_80BF1200(globalCtx, arg2->unk0); + door = func_80BF1200(globalCtx, arg2->result); - if (D_80BF3318[arg2->unk0] >= 0) { - this->unk_274 = SubS_GetAdditionalPath(globalCtx, sp55, D_80BF3318[arg2->unk0]); + if (D_80BF3318[arg2->result] >= 0) { + this->unk_274 = SubS_GetAdditionalPath(globalCtx, sp55, D_80BF3318[arg2->result]); } if ((door != NULL) && (door->dyna.actor.update != NULL)) { @@ -541,8 +572,8 @@ s32 func_80BF1DF4(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_2A4 = 75; } - this->unk_3E0 = arg2->unk8 - arg2->unk4; - this->unk_3E2 = sp56 - arg2->unk4; + this->unk_3E0 = arg2->time1 - arg2->time0; + this->unk_3E2 = sp56 - arg2->time0; this->actor.flags &= ~ACTOR_FLAG_1; this->unk_3D0 |= 0x100; func_80BF1284(this, 3); @@ -553,8 +584,8 @@ s32 func_80BF1DF4(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80BF1FA8(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { - u16 sp2E = gSaveContext.save.time - 0x3FFC; +s32 func_80BF1FA8(EnIg* this, GlobalContext* globalCtx, ScheduleResult* arg2) { + u16 sp2E = SCHEDULE_TIME_NOW; u16 phi_v1; u8 sp2B = ENIG_GET_FF(&this->actor); s32 temp_t8; @@ -562,8 +593,8 @@ s32 func_80BF1FA8(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_274 = NULL; - if (D_80BF3318[arg2->unk0] >= 0) { - this->unk_274 = SubS_GetAdditionalPath(globalCtx, sp2B, D_80BF3318[arg2->unk0]); + if (D_80BF3318[arg2->result] >= 0) { + this->unk_274 = SubS_GetAdditionalPath(globalCtx, sp2B, D_80BF3318[arg2->result]); } if ((this->unk_274 != NULL) && (this->unk_274->count < 3)) { @@ -571,17 +602,17 @@ s32 func_80BF1FA8(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar } if (this->unk_274 != NULL) { - temp_t8 = this->unk_298.unk0; + temp_t8 = this->scheduleResult; if ((temp_t8 < 10) && (temp_t8 != 0) && (this->unk_3EC >= 0)) { phi_v1 = sp2E; } else { - phi_v1 = arg2->unk4; + phi_v1 = arg2->time0; } - if (arg2->unk8 < phi_v1) { - this->unk_288 = (phi_v1 - arg2->unk8) + 0xFFFF; + if (arg2->time1 < phi_v1) { + this->unk_288 = (phi_v1 - arg2->time1) + 0xFFFF; } else { - this->unk_288 = arg2->unk8 - phi_v1; + this->unk_288 = arg2->time1 - phi_v1; } this->unk_294 = sp2E - phi_v1; @@ -602,7 +633,7 @@ s32 func_80BF1FA8(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80BF219C(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BF219C(EnIg* this, GlobalContext* globalCtx, ScheduleResult* arg2) { u8 sp4F = ENIG_GET_FF(&this->actor); Vec3f sp40; Vec3f sp34; @@ -612,8 +643,8 @@ s32 func_80BF219C(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_274 = NULL; - if (D_80BF3318[arg2->unk0] >= 0) { - this->unk_274 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80BF3318[arg2->unk0]); + if (D_80BF3318[arg2->result] >= 0) { + this->unk_274 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80BF3318[arg2->result]); } if ((this->unk_274 != 0) && (this->unk_274->count >= 2)) { @@ -625,7 +656,7 @@ s32 func_80BF219C(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar Math_Vec3f_Copy(&this->actor.world.pos, &sp40); Math_Vec3f_Copy(&this->actor.prevPos, &sp40); - switch (arg2->unk0) { + switch (arg2->result) { case 2: this->actor.home.rot.y = this->actor.world.rot.y; this->actor.home.rot.y += 0x8000; @@ -647,14 +678,14 @@ s32 func_80BF219C(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80BF2368(EnIg* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BF2368(EnIg* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret = false; this->actor.targetMode = 0; this->unk_3D0 = 0; this->actor.flags |= ACTOR_FLAG_1; - switch (arg2->unk0) { + switch (arg2->result) { case 5: case 6: case 7: @@ -697,7 +728,7 @@ s32 func_80BF2400(EnIg* this, GlobalContext* globalCtx) { } s32 func_80BF2470(EnIg* this, GlobalContext* globalCtx) { - EnDoor* door = func_80BF1200(globalCtx, this->unk_298.unk0); + EnDoor* door = func_80BF1200(globalCtx, this->scheduleResult); Vec3f sp38; f32 temp; s32 pad; @@ -807,7 +838,7 @@ s32 func_80BF293C(EnIg* this, GlobalContext* globalCtx) { } void func_80BF2A50(EnIg* this, GlobalContext* globalCtx) { - switch (this->unk_298.unk0) { + switch (this->scheduleResult) { case 10: case 11: case 12: @@ -840,22 +871,21 @@ void func_80BF2A50(EnIg* this, GlobalContext* globalCtx) { } void func_80BF2AF8(EnIg* this, GlobalContext* globalCtx) { - u32* unk_14 = &gSaveContext.save.daySpeed; - struct_80133038_arg2 sp20; + ScheduleResult sp20; - this->unk_3EC = REG(15) + *unk_14; + this->unk_3EC = REG(15) + ((void)0, gSaveContext.save.daySpeed); - if (!func_80133038(globalCtx, D_80BF3260, &sp20) || - ((this->unk_298.unk0 != sp20.unk0) && !func_80BF2368(this, globalCtx, &sp20))) { + if (!Schedule_RunScript(globalCtx, D_80BF3260, &sp20) || + ((this->scheduleResult != sp20.result) && !func_80BF2368(this, globalCtx, &sp20))) { this->actor.shape.shadowDraw = NULL; this->actor.flags &= ~ACTOR_FLAG_1; - sp20.unk0 = 0; + sp20.result = 0; } else { this->actor.shape.shadowDraw = ActorShadow_DrawCircle; this->actor.flags |= ACTOR_FLAG_1; } this->unk_2A8 = func_80BF146C(this, globalCtx); - this->unk_298.unk0 = sp20.unk0; + this->scheduleResult = sp20.result; func_80BF2A50(this, globalCtx); } @@ -864,14 +894,14 @@ void func_80BF2BD4(EnIg* this, GlobalContext* globalCtx) { Vec3f sp38; Vec3f sp2C; - if (func_8010BF58(&this->actor, globalCtx, this->unk_298.unk4, this->unk_3F8, &this->unk_298.unk8)) { + if (func_8010BF58(&this->actor, globalCtx, this->unk_29C, this->unk_3F8, &this->unk_2A0)) { SubS_UpdateFlags(&this->unk_3D0, 3, 7); this->unk_3D0 &= ~0x20; this->unk_3D0 |= 0x200; this->unk_3EE = 20; - this->unk_298.unk8 = 0; + this->unk_2A0 = 0; this->actionFunc = func_80BF2AF8; - } else if (((this->unk_298.unk0 != 2) && (this->unk_298.unk0 != 4)) && + } else if (((this->scheduleResult != 2) && (this->scheduleResult != 4)) && ((this->unk_2A8 != NULL) && (this->unk_2A8->update != NULL))) { Math_Vec3f_Copy(&sp38, &this->unk_2A8->world.pos); Math_Vec3f_Copy(&sp2C, &this->actor.world.pos); @@ -892,7 +922,7 @@ void EnIg_Init(Actor* thisx, GlobalContext* globalCtx) { Collider_InitAndSetSphere(globalCtx, &this->collider2, &this->actor, &sSphereInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); Actor_SetScale(&this->actor, 0.01f); - this->unk_298.unk0 = 0; + this->scheduleResult = 0; this->actor.gravity = 0.0f; this->actionFunc = func_80BF2AF8; this->actionFunc(this, globalCtx); @@ -914,7 +944,7 @@ void EnIg_Update(Actor* thisx, GlobalContext* globalCtx) { func_80BF1B40(this, globalCtx); - if (this->unk_298.unk0 != 0) { + if (this->scheduleResult != 0) { func_80BF1258(this); func_80BF13E4(this); func_80BF15EC(this); @@ -1003,7 +1033,7 @@ void EnIg_Draw(Actor* thisx, GlobalContext* globalCtx) { s32 pad; EnIg* this = THIS; - if (this->unk_298.unk0 != 0) { + if (this->scheduleResult != 0) { func_8012C28C(globalCtx->state.gfxCtx); OPEN_DISPS(globalCtx->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Ig/z_en_ig.h b/src/overlays/actors/ovl_En_Ig/z_en_ig.h index 200c751b12..21abb08ac8 100644 --- a/src/overlays/actors/ovl_En_Ig/z_en_ig.h +++ b/src/overlays/actors/ovl_En_Ig/z_en_ig.h @@ -26,7 +26,9 @@ typedef struct EnIg { /* 0x028C */ s32 unk_28C; /* 0x0290 */ s32 unk_290; /* 0x0294 */ s32 unk_294; - /* 0x0298 */ struct_80133038_arg2 unk_298; + /* 0x0298 */ u8 scheduleResult; + /* 0x029C */ s32* unk_29C; + /* 0x02A0 */ s32 unk_2A0; /* 0x02A4 */ s8 unk_2A4; /* 0x02A8 */ Actor* unk_2A8; /* 0x02AC */ UNK_TYPE1 unk2AC[0x4]; diff --git a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c index c80b9432ce..80a5c76516 100644 --- a/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c +++ b/src/overlays/actors/ovl_En_Invadepoh/z_en_invadepoh.c @@ -3,6 +3,8 @@ * Overlay: ovl_En_Invadepoh * Description: Ranch nighttime actors */ + +#include "prevent_bss_reordering.h" #include "z_en_invadepoh.h" #include "overlays/actors/ovl_En_Door/z_en_door.h" #include "objects/gameplay_keep/gameplay_keep.h" diff --git a/src/overlays/actors/ovl_En_Ja/z_en_ja.c b/src/overlays/actors/ovl_En_Ja/z_en_ja.c index 5c57c883ff..b02b6f4ee8 100644 --- a/src/overlays/actors/ovl_En_Ja/z_en_ja.c +++ b/src/overlays/actors/ovl_En_Ja/z_en_ja.c @@ -22,8 +22,16 @@ void func_80BC2EA4(EnJa* this); void func_80BC32D8(EnJa* this, GlobalContext* globalCtx); void func_80BC3594(EnJa* this, GlobalContext* globalCtx); -s32 D_80BC35F0[] = { - 0x0C000301, 0x05020600, 0x1200080A, 0x00610304, 0x0002050A, 0x006C0304, 0x00010500, +static u8 D_80BC35F0[] = { + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(3, 0x05 - 0x04), + /* 0x04 */ SCHEDULE_CMD_RET_NONE(), + /* 0x05 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(6, 0, 18, 0, 0x13 - 0x0B), + /* 0x0B */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_YADOYA, 0x12 - 0x0F), + /* 0x0F */ SCHEDULE_CMD_RET_VAL_L(2), + /* 0x12 */ SCHEDULE_CMD_RET_NONE(), + /* 0x13 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_TOWN, 0x1A - 0x17), + /* 0x17 */ SCHEDULE_CMD_RET_VAL_L(1), + /* 0x1A */ SCHEDULE_CMD_RET_NONE(), }; s32 D_80BC360C[] = { @@ -231,7 +239,7 @@ void func_80BC1E40(EnJa* this, GlobalContext* globalCtx) { this->unk_374 = sp20; } -s32 func_80BC1FC8(EnJa* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BC1FC8(EnJa* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret = false; if (func_80BC1AE0(this, globalCtx)) { @@ -244,7 +252,7 @@ s32 func_80BC1FC8(EnJa* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80BC203C(EnJa* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BC203C(EnJa* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret = false; if (func_80BC1AE0(this, globalCtx)) { @@ -261,12 +269,12 @@ s32 func_80BC203C(EnJa* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80BC20D0(EnJa* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BC20D0(EnJa* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret = false; this->unk_340 = 0; - switch (arg2->unk0) { + switch (arg2->result) { case 1: ret = func_80BC1FC8(this, globalCtx, arg2); if (ret == 1) {} @@ -291,20 +299,19 @@ void func_80BC2150(EnJa* this, GlobalContext* globalCtx) { } void func_80BC21A8(EnJa* this, GlobalContext* globalCtx) { - u32* unk_14 = &gSaveContext.save.daySpeed; - struct_80133038_arg2 sp18; + ScheduleResult sp18; - this->unk_35C = REG(15) + *unk_14; - if (!func_80133038(globalCtx, D_80BC35F0, &sp18) || - ((this->unk_1D8.unk_00 != sp18.unk0) && !func_80BC20D0(this, globalCtx, &sp18))) { + this->unk_35C = REG(15) + ((void)0, gSaveContext.save.daySpeed); + if (!Schedule_RunScript(globalCtx, D_80BC35F0, &sp18) || + ((this->unk_1D8.unk_00 != sp18.result) && !func_80BC20D0(this, globalCtx, &sp18))) { this->actor.shape.shadowDraw = NULL; this->actor.flags &= ~ACTOR_FLAG_1; - sp18.unk0 = 0; + sp18.result = 0; } else { this->actor.shape.shadowDraw = ActorShadow_DrawCircle; this->actor.flags |= ACTOR_FLAG_1; } - this->unk_1D8.unk_00 = sp18.unk0; + this->unk_1D8.unk_00 = sp18.result; func_80BC2150(this, globalCtx); } diff --git a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c index 02bd93aef8..4c9f10ff8e 100644 --- a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c +++ b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c @@ -4,6 +4,7 @@ * Description: Grass / Bush */ +#include "prevent_bss_reordering.h" #include "z_en_kusa.h" #include "objects/object_kusa/object_kusa.h" #include "objects/gameplay_keep/gameplay_keep.h" diff --git a/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c b/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c index 1b8d1ccbc5..e4e8214279 100644 --- a/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c +++ b/src/overlays/actors/ovl_En_Kusa2/z_en_kusa2.c @@ -4,6 +4,7 @@ * Description: Keaton grass */ +#include "prevent_bss_reordering.h" #include "z_en_kusa2.h" #include "objects/gameplay_field_keep/gameplay_field_keep.h" #include "objects/gameplay_keep/gameplay_keep.h" diff --git a/src/overlays/actors/ovl_En_Pm/z_en_pm.c b/src/overlays/actors/ovl_En_Pm/z_en_pm.c index 21f9487ada..4d59617326 100644 --- a/src/overlays/actors/ovl_En_Pm/z_en_pm.c +++ b/src/overlays/actors/ovl_En_Pm/z_en_pm.c @@ -20,69 +20,365 @@ void EnPm_Draw(Actor* thisx, GlobalContext* globalCtx); void func_80AFA4D0(EnPm* this, GlobalContext* globalCtx); void func_80AFA5FC(EnPm* this, GlobalContext* globalCtx); -// Game scripts -static UNK_TYPE D_80AFAD80[] = { - 0x0D000102, 0x3B030900, 0x0C00010B, 0x030C000D, 0x0100F902, 0x0D010F00, 0x12020F00, 0x00050105, 0x0A002E06, - 0x0E0F0000, 0x0508050A, 0x006D3102, 0x0D010D04, 0x25020D04, 0x0D151902, 0x0E300E38, 0x0D020E38, 0x0F000105, - 0x0E0E380F, 0x00020E0E, 0x300E383E, 0x0E0D040D, 0x15350E0D, 0x010D0401, 0x0A006F31, 0x020D040D, 0x1525020D, - 0x150D2719, 0x020E260E, 0x300D020E, 0x300E3801, 0x050E0E30, 0x0E383D0E, 0x0E260E30, 0x3C0E0D15, 0x0D27370E, - 0x0D040D15, 0x360A006C, 0x31020D27, 0x0D382502, 0x0D380E00, 0x19020E1A, 0x0E1E0D02, 0x0E1E0E26, 0x01050E0E, - 0x1E0E263B, 0x0E0E1A0E, 0x1E0B0E0D, 0x380E000A, 0x0E0D270D, 0x38380A00, 0x613D020D, 0x380E0031, 0x020E000E, - 0x0825020E, 0x080E1219, 0x020E120E, 0x1A0D020E, 0x1A0E1E01, 0x050E0E1A, 0x0E1E0D0E, 0x0E120E1A, 0x3A0E0E08, - 0x0E12100E, 0x0E000E08, 0x390E0D38, 0x0E000C05, 0x0A002E06, 0x0E0C000D, 0x0109050A, 0x006D3102, 0x09000903, - 0x25020903, 0x09111902, 0x0B2B0B39, 0x0D020B39, 0x0C000105, 0x0E0B390C, 0x00020E0B, 0x2B0B3934, 0x0E090309, - 0x11260E09, 0x00090301, 0x0A006F61, 0x02090309, 0x11550209, 0x11091F49, 0x02091F09, 0x233D0209, 0x23093131, - 0x020A390B, 0x0B25020B, 0x0B0B1919, 0x020B190B, 0x1D0D020B, 0x1D0B2B01, 0x050E0B1D, 0x0B2B320E, 0x0B190B1D, - 0x070E0B0B, 0x0B19300E, 0x0A390B0B, 0x2F0E0923, 0x0931290E, 0x091F0923, 0x030E0911, 0x091F280E, 0x09030911, - 0x270A006E, 0x25020931, 0x0A031902, 0x0A030A07, 0x0D020A07, 0x0A150105, 0x0E0A070A, 0x152B0E0A, 0x030A0704, - 0x0E09310A, 0x032A0A00, 0x6C61020A, 0x150A2355, 0x020A230A, 0x2749020A, 0x270A353D, 0x020A350A, 0x3931020A, - 0x390B0B25, 0x020B0B0B, 0x1919020B, 0x190B1D0D, 0x020B1D0B, 0x2B01050E, 0x0B1D0B2B, 0x330E0B19, 0x0B1D070E, - 0x0B0B0B19, 0x310E0A39, 0x0B0B2E0E, 0x0A350A39, 0x060E0A27, 0x0A352D0E, 0x0A230A27, 0x050E0A15, 0x0A232C05, - 0x0D000201, 0xCF011C08, 0x00A50309, 0x000C00FE, 0xC6030C00, 0x0D01008C, 0x020D010F, 0x007E0200, 0x00020001, - 0x050A006D, 0x31020000, 0x00042502, 0x0004001F, 0x1902011D, 0x01380D02, 0x01380200, 0x01050E01, 0x38020002, - 0x0E011D01, 0x384F0E00, 0x04001F4A, 0x0E000000, 0x04010A00, 0x6F3D0200, 0x04001F31, 0x02001F00, 0x3A250200, - 0x3A010219, 0x02010201, 0x1D0D0201, 0x1D013801, 0x050E011D, 0x01384E0E, 0x0102011D, 0x4D0E003A, 0x0102120E, - 0x001F003A, 0x4C0E0004, 0x001F4B05, 0x0A002E03, 0x04000E05, 0x0A002E06, 0x0E0C000D, 0x01140503, 0x09000C00, - 0xFE21030C, 0x000D0101, 0x0C020D01, 0x11001202, 0x11000005, 0x01050A00, 0x2E060E11, 0x00000508, 0x050A006D, - 0x31020D01, 0x0D042502, 0x0D040D0F, 0x19021023, 0x10390D02, 0x10391100, 0x01050E10, 0x39110002, 0x0E102310, - 0x39490E0D, 0x040D0F3F, 0x0E0D010D, 0x04010A00, 0x6F31020D, 0x040D0F25, 0x020D0F0D, 0x1E19020D, 0x340E2D0D, - 0x02100F10, 0x2301050E, 0x100F1023, 0x480E0D34, 0x0E2D430E, 0x0D0F0D1E, 0x410E0D04, 0x0D0F400A, 0x006C1902, - 0x0D1E0D34, 0x0D020D34, 0x0E320105, 0x0E0D340E, 0x32440E0D, 0x1E0D3442, 0x0A007068, 0x020E2D0F, 0x055C0C00, - 0x0231020F, 0x050F1425, 0x020F140F, 0x1919020F, 0x190F280D, 0x020F2810, 0x0F01050E, 0x0F28100F, 0x510E0F19, - 0x0F28110E, 0x0F140F19, 0x500E0F05, 0x0F141702, 0x0F050F14, 0x1B020F14, 0x0F320F02, 0x0F32100F, 0x03040000, - 0x0E0F3210, 0x0F470E0F, 0x140F3219, 0x0E0F050F, 0x14170E0E, 0x2D0F0546, 0x050A002E, 0x060E0C00, 0x0D011505, - 0x0D000301, 0x6F011C08, 0x013F011C, 0x10010C03, 0x09000C00, 0xFCED030C, 0x000D0100, 0xF6020D01, 0x0F000F02, - 0x12000600, 0x01050A00, 0x2E030400, 0x18050A00, 0x6D31020D, 0x000D0125, 0x020D050D, 0x0F19020E, 0x2D0E370D, - 0x020E370F, 0x0001050E, 0x0E370F00, 0x020E0E2D, 0x0E37340E, 0x0D050D0F, 0x260E0D00, 0x0D01010A, 0x006F4902, - 0x0D050D0F, 0x3D020D0F, 0x0D193102, 0x0D190D23, 0x25020E0F, 0x0E191902, 0x0E190E23, 0x0D020E23, 0x0E2D0105, - 0x0E0E230E, 0x2D320E0E, 0x190E2330, 0x0E0E0F0E, 0x192F0E0D, 0x190D2329, 0x0E0D0F0D, 0x19280E0D, 0x050D0F27, - 0x0A006E19, 0x020D230D, 0x2D0D020D, 0x2D0D3701, 0x050E0D2D, 0x0D372B0E, 0x0D230D2D, 0x2A0A006C, 0x3D020D37, - 0x0E053102, 0x0E050E0F, 0x25020E0F, 0x0E191902, 0x0E190E23, 0x0D020E23, 0x0E2D0105, 0x0E0E230E, 0x2D330E0E, - 0x190E2331, 0x0E0E0F0E, 0x192E0E0E, 0x050E0F2D, 0x0E0D370E, 0x052C050A, 0x002E0304, 0x00160503, 0x09000C00, - 0xFBE1020C, 0x000D0116, 0x030D0111, 0x00FDD202, 0x12000600, 0x01050A00, 0x2E030400, 0x18050A00, 0x2E060E0C, - 0x000D0115, 0x05030900, 0x0C00FBB3, 0x020C000D, 0x0116030D, 0x010F00FE, 0xD5021200, 0x06000105, 0x0A002E03, - 0x04001805, 0x0A002E03, 0x04001405, 0x05000000, +static u8 D_80AFAD80[] = { + /* 0x000 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_L(1, 0x240 - 0x005), + /* 0x005 */ SCHEDULE_CMD_CHECK_TIME_RANGE_L(9, 0, 12, 0, 0x117 - 0x00C), + /* 0x00C */ SCHEDULE_CMD_CHECK_TIME_RANGE_L(12, 0, 13, 1, 0x10C - 0x013), + /* 0x013 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 1, 15, 0, 0x02B - 0x019), + /* 0x019 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(15, 0, 0, 5, 0x020 - 0x01F), + /* 0x01F */ SCHEDULE_CMD_RET_NONE(), + /* 0x020 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_POSTHOUSE, 0x02A - 0x024), + /* 0x024 */ SCHEDULE_CMD_RET_TIME(15, 0, 0, 5, 8), + /* 0x02A */ SCHEDULE_CMD_RET_NONE(), + /* 0x02B */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_ICHIBA, 0x060 - 0x02F), + /* 0x02F */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 1, 13, 4, 0x05A - 0x035), + /* 0x035 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 4, 13, 21, 0x054 - 0x03B), + /* 0x03B */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 48, 14, 56, 0x04E - 0x041), + /* 0x041 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 56, 15, 0, 0x048 - 0x047), + /* 0x047 */ SCHEDULE_CMD_RET_NONE(), + /* 0x048 */ SCHEDULE_CMD_RET_TIME(14, 56, 15, 0, 2), + /* 0x04E */ SCHEDULE_CMD_RET_TIME(14, 48, 14, 56, 62), + /* 0x054 */ SCHEDULE_CMD_RET_TIME(13, 4, 13, 21, 53), + /* 0x05A */ SCHEDULE_CMD_RET_TIME(13, 1, 13, 4, 1), + /* 0x060 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_CLOCKTOWER, 0x095 - 0x064), + /* 0x064 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 4, 13, 21, 0x08F - 0x06A), + /* 0x06A */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 21, 13, 39, 0x089 - 0x070), + /* 0x070 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 38, 14, 48, 0x083 - 0x076), + /* 0x076 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 48, 14, 56, 0x07D - 0x07C), + /* 0x07C */ SCHEDULE_CMD_RET_NONE(), + /* 0x07D */ SCHEDULE_CMD_RET_TIME(14, 48, 14, 56, 61), + /* 0x083 */ SCHEDULE_CMD_RET_TIME(14, 38, 14, 48, 60), + /* 0x089 */ SCHEDULE_CMD_RET_TIME(13, 21, 13, 39, 55), + /* 0x08F */ SCHEDULE_CMD_RET_TIME(13, 4, 13, 21, 54), + /* 0x095 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_TOWN, 0x0CA - 0x099), + /* 0x099 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 39, 13, 56, 0x0C4 - 0x09F), + /* 0x09F */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 56, 14, 0, 0x0BE - 0x0A5), + /* 0x0A5 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 26, 14, 30, 0x0B8 - 0x0AB), + /* 0x0AB */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 30, 14, 38, 0x0B2 - 0x0B1), + /* 0x0B1 */ SCHEDULE_CMD_RET_NONE(), + /* 0x0B2 */ SCHEDULE_CMD_RET_TIME(14, 30, 14, 38, 59), + /* 0x0B8 */ SCHEDULE_CMD_RET_TIME(14, 26, 14, 30, 11), + /* 0x0BE */ SCHEDULE_CMD_RET_TIME(13, 56, 14, 0, 10), + /* 0x0C4 */ SCHEDULE_CMD_RET_TIME(13, 39, 13, 56, 56), + /* 0x0CA */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_YADOYA, 0x10B - 0x0CE), + /* 0x0CE */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 56, 14, 0, 0x105 - 0x0D4), + /* 0x0D4 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 0, 14, 8, 0x0FF - 0x0DA), + /* 0x0DA */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 8, 14, 18, 0x0F9 - 0x0E0), + /* 0x0E0 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 18, 14, 26, 0x0F3 - 0x0E6), + /* 0x0E6 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 26, 14, 30, 0x0ED - 0x0EC), + /* 0x0EC */ SCHEDULE_CMD_RET_NONE(), + /* 0x0ED */ SCHEDULE_CMD_RET_TIME(14, 26, 14, 30, 13), + /* 0x0F3 */ SCHEDULE_CMD_RET_TIME(14, 18, 14, 26, 58), + /* 0x0F9 */ SCHEDULE_CMD_RET_TIME(14, 8, 14, 18, 16), + /* 0x0FF */ SCHEDULE_CMD_RET_TIME(14, 0, 14, 8, 57), + /* 0x105 */ SCHEDULE_CMD_RET_TIME(13, 56, 14, 0, 12), + /* 0x10B */ SCHEDULE_CMD_RET_NONE(), + /* 0x10C */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_POSTHOUSE, 0x116 - 0x110), + /* 0x110 */ SCHEDULE_CMD_RET_TIME(12, 0, 13, 1, 9), + /* 0x116 */ SCHEDULE_CMD_RET_NONE(), + /* 0x117 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_ICHIBA, 0x14C - 0x11B), + /* 0x11B */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(9, 0, 9, 3, 0x146 - 0x121), + /* 0x121 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(9, 3, 9, 17, 0x140 - 0x127), + /* 0x127 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(11, 43, 11, 57, 0x13A - 0x12D), + /* 0x12D */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(11, 57, 12, 0, 0x134 - 0x133), + /* 0x133 */ SCHEDULE_CMD_RET_NONE(), + /* 0x134 */ SCHEDULE_CMD_RET_TIME(11, 57, 12, 0, 2), + /* 0x13A */ SCHEDULE_CMD_RET_TIME(11, 43, 11, 57, 52), + /* 0x140 */ SCHEDULE_CMD_RET_TIME(9, 3, 9, 17, 38), + /* 0x146 */ SCHEDULE_CMD_RET_TIME(9, 0, 9, 3, 1), + /* 0x14C */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_CLOCKTOWER, 0x1B1 - 0x150), + /* 0x150 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(9, 3, 9, 17, 0x1AB - 0x156), + /* 0x156 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(9, 17, 9, 31, 0x1A5 - 0x15C), + /* 0x15C */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(9, 31, 9, 35, 0x19F - 0x162), + /* 0x162 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(9, 35, 9, 49, 0x199 - 0x168), + /* 0x168 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 57, 11, 11, 0x193 - 0x16E), + /* 0x16E */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(11, 11, 11, 25, 0x18D - 0x174), + /* 0x174 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(11, 25, 11, 29, 0x187 - 0x17A), + /* 0x17A */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(11, 29, 11, 43, 0x181 - 0x180), + /* 0x180 */ SCHEDULE_CMD_RET_NONE(), + /* 0x181 */ SCHEDULE_CMD_RET_TIME(11, 29, 11, 43, 50), + /* 0x187 */ SCHEDULE_CMD_RET_TIME(11, 25, 11, 29, 7), + /* 0x18D */ SCHEDULE_CMD_RET_TIME(11, 11, 11, 25, 48), + /* 0x193 */ SCHEDULE_CMD_RET_TIME(10, 57, 11, 11, 47), + /* 0x199 */ SCHEDULE_CMD_RET_TIME(9, 35, 9, 49, 41), + /* 0x19F */ SCHEDULE_CMD_RET_TIME(9, 31, 9, 35, 3), + /* 0x1A5 */ SCHEDULE_CMD_RET_TIME(9, 17, 9, 31, 40), + /* 0x1AB */ SCHEDULE_CMD_RET_TIME(9, 3, 9, 17, 39), + /* 0x1B1 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_BACKTOWN, 0x1DA - 0x1B5), + /* 0x1B5 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(9, 49, 10, 3, 0x1D4 - 0x1BB), + /* 0x1BB */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 3, 10, 7, 0x1CE - 0x1C1), + /* 0x1C1 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 7, 10, 21, 0x1C8 - 0x1C7), + /* 0x1C7 */ SCHEDULE_CMD_RET_NONE(), + /* 0x1C8 */ SCHEDULE_CMD_RET_TIME(10, 7, 10, 21, 43), + /* 0x1CE */ SCHEDULE_CMD_RET_TIME(10, 3, 10, 7, 4), + /* 0x1D4 */ SCHEDULE_CMD_RET_TIME(9, 49, 10, 3, 42), + /* 0x1DA */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_TOWN, 0x23F - 0x1DE), + /* 0x1DE */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 21, 10, 35, 0x239 - 0x1E4), + /* 0x1E4 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 35, 10, 39, 0x233 - 0x1EA), + /* 0x1EA */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 39, 10, 53, 0x22D - 0x1F0), + /* 0x1F0 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 53, 10, 57, 0x227 - 0x1F6), + /* 0x1F6 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(10, 57, 11, 11, 0x221 - 0x1FC), + /* 0x1FC */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(11, 11, 11, 25, 0x21B - 0x202), + /* 0x202 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(11, 25, 11, 29, 0x215 - 0x208), + /* 0x208 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(11, 29, 11, 43, 0x20F - 0x20E), + /* 0x20E */ SCHEDULE_CMD_RET_NONE(), + /* 0x20F */ SCHEDULE_CMD_RET_TIME(11, 29, 11, 43, 51), + /* 0x215 */ SCHEDULE_CMD_RET_TIME(11, 25, 11, 29, 7), + /* 0x21B */ SCHEDULE_CMD_RET_TIME(11, 11, 11, 25, 49), + /* 0x221 */ SCHEDULE_CMD_RET_TIME(10, 57, 11, 11, 46), + /* 0x227 */ SCHEDULE_CMD_RET_TIME(10, 53, 10, 57, 6), + /* 0x22D */ SCHEDULE_CMD_RET_TIME(10, 39, 10, 53, 45), + /* 0x233 */ SCHEDULE_CMD_RET_TIME(10, 35, 10, 39, 5), + /* 0x239 */ SCHEDULE_CMD_RET_TIME(10, 21, 10, 35, 44), + /* 0x23F */ SCHEDULE_CMD_RET_NONE(), + /* 0x240 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_L(2, 0x414 - 0x245), + /* 0x245 */ SCHEDULE_CMD_CHECK_FLAG_L(0x1C, 0x08, 0x2EF - 0x24A), + /* 0x24A */ SCHEDULE_CMD_CHECK_TIME_RANGE_L(9, 0, 12, 0, 0x117 - 0x251), + /* 0x251 */ SCHEDULE_CMD_CHECK_TIME_RANGE_L(12, 0, 13, 1, 0x2E4 - 0x258), + /* 0x258 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 1, 15, 0, 0x2DC - 0x25E), + /* 0x25E */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 0, 2, 0, 0x265 - 0x264), + /* 0x264 */ SCHEDULE_CMD_RET_NONE(), + /* 0x265 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_ICHIBA, 0x29A - 0x269), + /* 0x269 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 0, 0, 4, 0x294 - 0x26F), + /* 0x26F */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 4, 0, 31, 0x28E - 0x275), + /* 0x275 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(1, 29, 1, 56, 0x288 - 0x27B), + /* 0x27B */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(1, 56, 2, 0, 0x282 - 0x281), + /* 0x281 */ SCHEDULE_CMD_RET_NONE(), + /* 0x282 */ SCHEDULE_CMD_RET_TIME(1, 56, 2, 0, 2), + /* 0x288 */ SCHEDULE_CMD_RET_TIME(1, 29, 1, 56, 79), + /* 0x28E */ SCHEDULE_CMD_RET_TIME(0, 4, 0, 31, 74), + /* 0x294 */ SCHEDULE_CMD_RET_TIME(0, 0, 0, 4, 1), + /* 0x29A */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_CLOCKTOWER, 0x2DB - 0x29E), + /* 0x29E */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 4, 0, 31, 0x2D5 - 0x2A4), + /* 0x2A4 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 31, 0, 58, 0x2CF - 0x2AA), + /* 0x2AA */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 58, 1, 2, 0x2C9 - 0x2B0), + /* 0x2B0 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(1, 2, 1, 29, 0x2C3 - 0x2B6), + /* 0x2B6 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(1, 29, 1, 56, 0x2BD - 0x2BC), + /* 0x2BC */ SCHEDULE_CMD_RET_NONE(), + /* 0x2BD */ SCHEDULE_CMD_RET_TIME(1, 29, 1, 56, 78), + /* 0x2C3 */ SCHEDULE_CMD_RET_TIME(1, 2, 1, 29, 77), + /* 0x2C9 */ SCHEDULE_CMD_RET_TIME(0, 58, 1, 2, 18), + /* 0x2CF */ SCHEDULE_CMD_RET_TIME(0, 31, 0, 58, 76), + /* 0x2D5 */ SCHEDULE_CMD_RET_TIME(0, 4, 0, 31, 75), + /* 0x2DB */ SCHEDULE_CMD_RET_NONE(), + /* 0x2DC */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_POSTHOUSE, 0x2E3 - 0x2E0), + /* 0x2E0 */ SCHEDULE_CMD_RET_VAL_L(14), + /* 0x2E3 */ SCHEDULE_CMD_RET_NONE(), + /* 0x2E4 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_POSTHOUSE, 0x2EE - 0x2E8), + /* 0x2E8 */ SCHEDULE_CMD_RET_TIME(12, 0, 13, 1, 20), + /* 0x2EE */ SCHEDULE_CMD_RET_NONE(), + /* 0x2EF */ SCHEDULE_CMD_CHECK_TIME_RANGE_L(9, 0, 12, 0, 0x117 - 0x2F6), + /* 0x2F6 */ SCHEDULE_CMD_CHECK_TIME_RANGE_L(12, 0, 13, 1, 0x409 - 0x2FD), + /* 0x2FD */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 1, 17, 0, 0x315 - 0x303), + /* 0x303 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(17, 0, 0, 5, 0x30A - 0x309), + /* 0x309 */ SCHEDULE_CMD_RET_NONE(), + /* 0x30A */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_POSTHOUSE, 0x314 - 0x30E), + /* 0x30E */ SCHEDULE_CMD_RET_TIME(17, 0, 0, 5, 8), + /* 0x314 */ SCHEDULE_CMD_RET_NONE(), + /* 0x315 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_ICHIBA, 0x34A - 0x319), + /* 0x319 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 1, 13, 4, 0x344 - 0x31F), + /* 0x31F */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 4, 13, 15, 0x33E - 0x325), + /* 0x325 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(16, 35, 16, 57, 0x338 - 0x32B), + /* 0x32B */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(16, 57, 17, 0, 0x332 - 0x331), + /* 0x331 */ SCHEDULE_CMD_RET_NONE(), + /* 0x332 */ SCHEDULE_CMD_RET_TIME(16, 57, 17, 0, 2), + /* 0x338 */ SCHEDULE_CMD_RET_TIME(16, 35, 16, 57, 73), + /* 0x33E */ SCHEDULE_CMD_RET_TIME(13, 4, 13, 15, 63), + /* 0x344 */ SCHEDULE_CMD_RET_TIME(13, 1, 13, 4, 1), + /* 0x34A */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_CLOCKTOWER, 0x37F - 0x34E), + /* 0x34E */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 4, 13, 15, 0x379 - 0x354), + /* 0x354 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 15, 13, 30, 0x373 - 0x35A), + /* 0x35A */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 52, 14, 45, 0x36D - 0x360), + /* 0x360 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(16, 15, 16, 35, 0x367 - 0x366), + /* 0x366 */ SCHEDULE_CMD_RET_NONE(), + /* 0x367 */ SCHEDULE_CMD_RET_TIME(16, 15, 16, 35, 72), + /* 0x36D */ SCHEDULE_CMD_RET_TIME(13, 52, 14, 45, 67), + /* 0x373 */ SCHEDULE_CMD_RET_TIME(13, 15, 13, 30, 65), + /* 0x379 */ SCHEDULE_CMD_RET_TIME(13, 4, 13, 15, 64), + /* 0x37F */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_TOWN, 0x39C - 0x383), + /* 0x383 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 30, 13, 52, 0x396 - 0x389), + /* 0x389 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 52, 14, 50, 0x390 - 0x38F), + /* 0x38F */ SCHEDULE_CMD_RET_NONE(), + /* 0x390 */ SCHEDULE_CMD_RET_TIME(13, 52, 14, 50, 68), + /* 0x396 */ SCHEDULE_CMD_RET_TIME(13, 30, 13, 52, 66), + /* 0x39C */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_ALLEY, 0x408 - 0x3A0), + /* 0x3A0 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 45, 15, 5, 0x402 - 0x3A6), + /* 0x3A6 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(2, 0x3DB - 0x3AA), + /* 0x3AA */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(15, 5, 15, 20, 0x3D5 - 0x3B0), + /* 0x3B0 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(15, 20, 15, 25, 0x3CF - 0x3B6), + /* 0x3B6 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(15, 25, 15, 40, 0x3C9 - 0x3BC), + /* 0x3BC */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(15, 40, 16, 15, 0x3C3 - 0x3C2), + /* 0x3C2 */ SCHEDULE_CMD_RET_NONE(), + /* 0x3C3 */ SCHEDULE_CMD_RET_TIME(15, 40, 16, 15, 81), + /* 0x3C9 */ SCHEDULE_CMD_RET_TIME(15, 25, 15, 40, 17), + /* 0x3CF */ SCHEDULE_CMD_RET_TIME(15, 20, 15, 25, 80), + /* 0x3D5 */ SCHEDULE_CMD_RET_TIME(15, 5, 15, 20, 23), + /* 0x3DB */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(15, 5, 15, 20, 0x3FC - 0x3E1), + /* 0x3E1 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(15, 20, 15, 50, 0x3F6 - 0x3E7), + /* 0x3E7 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(15, 50, 16, 15, 0x3F0 - 0x3ED), + /* 0x3ED */ SCHEDULE_CMD_RET_VAL_L(0), + /* 0x3F0 */ SCHEDULE_CMD_RET_TIME(15, 50, 16, 15, 71), + /* 0x3F6 */ SCHEDULE_CMD_RET_TIME(15, 20, 15, 50, 25), + /* 0x3FC */ SCHEDULE_CMD_RET_TIME(15, 5, 15, 20, 23), + /* 0x402 */ SCHEDULE_CMD_RET_TIME(14, 45, 15, 5, 70), + /* 0x408 */ SCHEDULE_CMD_RET_NONE(), + /* 0x409 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_POSTHOUSE, 0x413 - 0x40D), + /* 0x40D */ SCHEDULE_CMD_RET_TIME(12, 0, 13, 1, 21), + /* 0x413 */ SCHEDULE_CMD_RET_NONE(), + /* 0x414 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_L(3, 0x588 - 0x419), + /* 0x419 */ SCHEDULE_CMD_CHECK_FLAG_L(0x1C, 0x08, 0x55D - 0x41E), + /* 0x41E */ SCHEDULE_CMD_CHECK_FLAG_L(0x1C, 0x10, 0x52F - 0x423), + /* 0x423 */ SCHEDULE_CMD_CHECK_TIME_RANGE_L(9, 0, 12, 0, 0x117 - 0x42A), + /* 0x42A */ SCHEDULE_CMD_CHECK_TIME_RANGE_L(12, 0, 13, 1, 0x527 - 0x431), + /* 0x431 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 1, 15, 0, 0x446 - 0x437), + /* 0x437 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(18, 0, 6, 0, 0x43E - 0x43D), + /* 0x43D */ SCHEDULE_CMD_RET_NONE(), + /* 0x43E */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_POSTHOUSE, 0x445 - 0x442), + /* 0x442 */ SCHEDULE_CMD_RET_VAL_L(24), + /* 0x445 */ SCHEDULE_CMD_RET_NONE(), + /* 0x446 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_ICHIBA, 0x47B - 0x44A), + /* 0x44A */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 0, 13, 1, 0x475 - 0x450), + /* 0x450 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 5, 13, 15, 0x46F - 0x456), + /* 0x456 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 45, 14, 55, 0x469 - 0x45C), + /* 0x45C */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 55, 15, 0, 0x463 - 0x462), + /* 0x462 */ SCHEDULE_CMD_RET_NONE(), + /* 0x463 */ SCHEDULE_CMD_RET_TIME(14, 55, 15, 0, 2), + /* 0x469 */ SCHEDULE_CMD_RET_TIME(14, 45, 14, 55, 52), + /* 0x46F */ SCHEDULE_CMD_RET_TIME(13, 5, 13, 15, 38), + /* 0x475 */ SCHEDULE_CMD_RET_TIME(13, 0, 13, 1, 1), + /* 0x47B */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_CLOCKTOWER, 0x4C8 - 0x47F), + /* 0x47F */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 5, 13, 15, 0x4C2 - 0x485), + /* 0x485 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 15, 13, 25, 0x4BC - 0x48B), + /* 0x48B */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 25, 13, 35, 0x4B6 - 0x491), + /* 0x491 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 15, 14, 25, 0x4B0 - 0x497), + /* 0x497 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 25, 14, 35, 0x4AA - 0x49D), + /* 0x49D */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 35, 14, 45, 0x4A4 - 0x4A3), + /* 0x4A3 */ SCHEDULE_CMD_RET_NONE(), + /* 0x4A4 */ SCHEDULE_CMD_RET_TIME(14, 35, 14, 45, 50), + /* 0x4AA */ SCHEDULE_CMD_RET_TIME(14, 25, 14, 35, 48), + /* 0x4B0 */ SCHEDULE_CMD_RET_TIME(14, 15, 14, 25, 47), + /* 0x4B6 */ SCHEDULE_CMD_RET_TIME(13, 25, 13, 35, 41), + /* 0x4BC */ SCHEDULE_CMD_RET_TIME(13, 15, 13, 25, 40), + /* 0x4C2 */ SCHEDULE_CMD_RET_TIME(13, 5, 13, 15, 39), + /* 0x4C8 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_BACKTOWN, 0x4E5 - 0x4CC), + /* 0x4CC */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 35, 13, 45, 0x4DF - 0x4D2), + /* 0x4D2 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 45, 13, 55, 0x4D9 - 0x4D8), + /* 0x4D8 */ SCHEDULE_CMD_RET_NONE(), + /* 0x4D9 */ SCHEDULE_CMD_RET_TIME(13, 45, 13, 55, 43), + /* 0x4DF */ SCHEDULE_CMD_RET_TIME(13, 35, 13, 45, 42), + /* 0x4E5 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_TOWN, 0x526 - 0x4E9), + /* 0x4E9 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(13, 55, 14, 5, 0x520 - 0x4EF), + /* 0x4EF */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 5, 14, 15, 0x51A - 0x4F5), + /* 0x4F5 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 15, 14, 25, 0x514 - 0x4FB), + /* 0x4FB */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 25, 14, 35, 0x50E - 0x501), + /* 0x501 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(14, 35, 14, 45, 0x508 - 0x507), + /* 0x507 */ SCHEDULE_CMD_RET_NONE(), + /* 0x508 */ SCHEDULE_CMD_RET_TIME(14, 35, 14, 45, 51), + /* 0x50E */ SCHEDULE_CMD_RET_TIME(14, 25, 14, 35, 49), + /* 0x514 */ SCHEDULE_CMD_RET_TIME(14, 15, 14, 25, 46), + /* 0x51A */ SCHEDULE_CMD_RET_TIME(14, 5, 14, 15, 45), + /* 0x520 */ SCHEDULE_CMD_RET_TIME(13, 55, 14, 5, 44), + /* 0x526 */ SCHEDULE_CMD_RET_NONE(), + /* 0x527 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_POSTHOUSE, 0x52E - 0x52B), + /* 0x52B */ SCHEDULE_CMD_RET_VAL_L(22), + /* 0x52E */ SCHEDULE_CMD_RET_NONE(), + /* 0x52F */ SCHEDULE_CMD_CHECK_TIME_RANGE_L(9, 0, 12, 0, 0x117 - 0x536), + /* 0x536 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(12, 0, 13, 1, 0x552 - 0x53C), + /* 0x53C */ SCHEDULE_CMD_CHECK_TIME_RANGE_L(13, 1, 17, 0, 0x315 - 0x543), + /* 0x543 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(18, 0, 6, 0, 0x54A - 0x549), + /* 0x549 */ SCHEDULE_CMD_RET_NONE(), + /* 0x54A */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_POSTHOUSE, 0x551 - 0x54E), + /* 0x54E */ SCHEDULE_CMD_RET_VAL_L(24), + /* 0x551 */ SCHEDULE_CMD_RET_NONE(), + /* 0x552 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_POSTHOUSE, 0x55C - 0x556), + /* 0x556 */ SCHEDULE_CMD_RET_TIME(12, 0, 13, 1, 21), + /* 0x55C */ SCHEDULE_CMD_RET_NONE(), + /* 0x55D */ SCHEDULE_CMD_CHECK_TIME_RANGE_L(9, 0, 12, 0, 0x117 - 0x564), + /* 0x564 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(12, 0, 13, 1, 0x580 - 0x56A), + /* 0x56A */ SCHEDULE_CMD_CHECK_TIME_RANGE_L(13, 1, 15, 0, 0x446 - 0x571), + /* 0x571 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(18, 0, 6, 0, 0x578 - 0x577), + /* 0x577 */ SCHEDULE_CMD_RET_NONE(), + /* 0x578 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_POSTHOUSE, 0x57F - 0x57C), + /* 0x57C */ SCHEDULE_CMD_RET_VAL_L(24), + /* 0x57F */ SCHEDULE_CMD_RET_NONE(), + /* 0x580 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_POSTHOUSE, 0x587 - 0x584), + /* 0x584 */ SCHEDULE_CMD_RET_VAL_L(20), + /* 0x587 */ SCHEDULE_CMD_RET_NONE(), + /* 0x588 */ SCHEDULE_CMD_RET_NONE(), }; -static UNK_TYPE D_80AFB30C[] = { - 0x0A002E2E, 0x02000000, 0x0A220200, 0x0A000D19, 0x02000D00, 0x170D0200, 0x17001A01, 0x050E0017, 0x001A200E, - 0x000D0017, 0x5304001B, 0x0E000000, 0x0A520A00, 0x6D190200, 0x17001A0D, 0x02001A00, 0x2401050E, 0x001A0024, - 0x540E0017, 0x001A210A, 0x006F1902, 0x001A0024, 0x0D020024, 0x002E0105, 0x0E002400, 0x2E560E00, 0x1A002455, - 0x0A006C19, 0x02002E00, 0x380D0200, 0x38003B01, 0x050E0038, 0x003B220E, 0x002E0038, 0x570A0015, 0x25020038, - 0x003B1902, 0x003B0109, 0x0D020109, 0x01280105, 0x0E010901, 0x281C0E00, 0x3B010958, 0x0E003800, 0x3B240500, +static u8 D_80AFB30C[] = { + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_POSTHOUSE, 0x32 - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 0, 0, 10, 0x2C - 0x0A), + /* 0x0A */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 10, 0, 13, 0x29 - 0x10), + /* 0x10 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 13, 0, 23, 0x23 - 0x16), + /* 0x16 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 23, 0, 26, 0x1D - 0x1C), + /* 0x1C */ SCHEDULE_CMD_RET_NONE(), + /* 0x1D */ SCHEDULE_CMD_RET_TIME(0, 23, 0, 26, 32), + /* 0x23 */ SCHEDULE_CMD_RET_TIME(0, 13, 0, 23, 83), + /* 0x29 */ SCHEDULE_CMD_RET_VAL_L(27), + /* 0x2C */ SCHEDULE_CMD_RET_TIME(0, 0, 0, 10, 82), + /* 0x32 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_ICHIBA, 0x4F - 0x36), + /* 0x36 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 23, 0, 26, 0x49 - 0x3C), + /* 0x3C */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 26, 0, 36, 0x43 - 0x42), + /* 0x42 */ SCHEDULE_CMD_RET_NONE(), + /* 0x43 */ SCHEDULE_CMD_RET_TIME(0, 26, 0, 36, 84), + /* 0x49 */ SCHEDULE_CMD_RET_TIME(0, 23, 0, 26, 33), + /* 0x4F */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_CLOCKTOWER, 0x6C - 0x53), + /* 0x53 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 26, 0, 36, 0x66 - 0x59), + /* 0x59 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 36, 0, 46, 0x60 - 0x5F), + /* 0x5F */ SCHEDULE_CMD_RET_NONE(), + /* 0x60 */ SCHEDULE_CMD_RET_TIME(0, 36, 0, 46, 86), + /* 0x66 */ SCHEDULE_CMD_RET_TIME(0, 26, 0, 36, 85), + /* 0x6C */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_TOWN, 0x89 - 0x70), + /* 0x70 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 46, 0, 56, 0x83 - 0x76), + /* 0x76 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 56, 0, 59, 0x7D - 0x7C), + /* 0x7C */ SCHEDULE_CMD_RET_NONE(), + /* 0x7D */ SCHEDULE_CMD_RET_TIME(0, 56, 0, 59, 34), + /* 0x83 */ SCHEDULE_CMD_RET_TIME(0, 46, 0, 56, 87), + /* 0x89 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_MILK_BAR, 0xB2 - 0x8D), + /* 0x8D */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 56, 0, 59, 0xAC - 0x93), + /* 0x93 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 59, 1, 9, 0xA6 - 0x99), + /* 0x99 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(1, 9, 1, 40, 0xA0 - 0x9F), + /* 0x9F */ SCHEDULE_CMD_RET_NONE(), + /* 0xA0 */ SCHEDULE_CMD_RET_TIME(1, 9, 1, 40, 28), + /* 0xA6 */ SCHEDULE_CMD_RET_TIME(0, 59, 1, 9, 88), + /* 0xAC */ SCHEDULE_CMD_RET_TIME(0, 56, 0, 59, 36), + /* 0xB2 */ SCHEDULE_CMD_RET_NONE(), }; -static UNK_TYPE D_80AFB3C0[] = { - 0x0A006C19, 0x02000A00, 0x0D0D0200, 0x0D001701, 0x050E000D, 0x00175A0E, 0x000A000D, 0x230A0015, - 0x19020000, 0x000A0D02, 0x000A000D, 0x01050E00, 0x0A000D25, 0x0E000000, 0x0A590500, +static u8 D_80AFB3C0[] = { + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_TOWN, 0x1D - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 10, 0, 13, 0x17 - 0x0A), + /* 0x0A */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 13, 0, 23, 0x11 - 0x10), + /* 0x10 */ SCHEDULE_CMD_RET_NONE(), + /* 0x11 */ SCHEDULE_CMD_RET_TIME(0, 13, 0, 23, 90), + /* 0x17 */ SCHEDULE_CMD_RET_TIME(0, 10, 0, 13, 35), + /* 0x1D */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_MILK_BAR, 0x3A - 0x21), + /* 0x21 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 0, 0, 10, 0x34 - 0x27), + /* 0x27 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 10, 0, 13, 0x2E - 0x2D), + /* 0x2D */ SCHEDULE_CMD_RET_NONE(), + /* 0x2E */ SCHEDULE_CMD_RET_TIME(0, 10, 0, 13, 37), + /* 0x34 */ SCHEDULE_CMD_RET_TIME(0, 0, 0, 10, 89), + /* 0x3A */ SCHEDULE_CMD_RET_NONE(), }; -static UNK_TYPE D_80AFB3FC[] = { - 0x0A006C19, 0x02120006, 0x000D0205, 0x00050A01, 0x050E0500, 0x050A5B0E, 0x12000600, 0x1D050000, +static u8 D_80AFB3FC[] = { + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_TOWN, 0x1D - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(18, 0, 6, 0, 0x17 - 0x0A), + /* 0x0A */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(5, 0, 5, 10, 0x11 - 0x10), + /* 0x10 */ SCHEDULE_CMD_RET_NONE(), + /* 0x11 */ SCHEDULE_CMD_RET_TIME(5, 0, 5, 10, 91), + /* 0x17 */ SCHEDULE_CMD_RET_TIME(18, 0, 6, 0, 29), + /* 0x1D */ SCHEDULE_CMD_RET_NONE(), }; -static UNK_TYPE D_80AFB41C[] = { - 0x0A006C0D, 0x02000000, 0x0A01050E, 0x0000000A, 0x5B050000, +static u8 D_80AFB41C[] = { + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_TOWN, 0x11 - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 0, 0, 10, 0x0B - 0x0A), + /* 0x0A */ SCHEDULE_CMD_RET_NONE(), + /* 0x0B */ SCHEDULE_CMD_RET_TIME(0, 0, 0, 10, 91), + /* 0x11 */ SCHEDULE_CMD_RET_NONE(), }; static s32 D_80AFB430[] = { @@ -904,7 +1200,7 @@ s32 func_80AF8DD4(EnPm* this, GlobalContext* globalCtx) { return 0; } -s32 func_80AF8ED4(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2, u8 actorCat, s16 actorId) { +s32 func_80AF8ED4(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2, u8 actorCat, s16 actorId) { u8 sp4F = this->actor.params & 0xFF; Vec3s* sp48; Vec3f sp3C; @@ -915,8 +1211,8 @@ s32 func_80AF8ED4(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_234 = NULL; sp2C = func_80AF7CB0(this, globalCtx, actorCat, actorId); - if (D_80AFB430[arg2->unk0] >= 0) { - this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80AFB430[arg2->unk0]); + if (D_80AFB430[arg2->result] >= 0) { + this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80AFB430[arg2->result]); } if ((sp2C != NULL) && (sp2C->update != NULL)) { @@ -934,8 +1230,8 @@ s32 func_80AF8ED4(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80AF9008(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { - u16 sp56 = gSaveContext.save.time - 0x3FFC; +s32 func_80AF9008(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { + u16 sp56 = SCHEDULE_TIME_NOW; u8 sp55 = this->actor.params & 0xFF; EnDoor* door; Vec3s* sp4C; @@ -945,9 +1241,9 @@ s32 func_80AF9008(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar s32 ret = false; this->unk_234 = NULL; - door = func_80AF7D60(globalCtx, arg2->unk0); - if (D_80AFB430[arg2->unk0] >= 0) { - this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp55, D_80AFB430[arg2->unk0]); + door = func_80AF7D60(globalCtx, arg2->result); + if (D_80AFB430[arg2->result] >= 0) { + this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp55, D_80AFB430[arg2->result]); } if ((door != NULL) && (door->dyna.actor.update != NULL)) { @@ -966,8 +1262,8 @@ s32 func_80AF9008(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_260 = 0x4B; } - this->unk_36C = arg2->unk8 - arg2->unk4; - this->unk_36E = sp56 - arg2->unk4; + this->unk_36C = arg2->time1 - arg2->time0; + this->unk_36E = sp56 - arg2->time0; this->actor.flags &= ~ACTOR_FLAG_1; if (gSaveContext.save.weekEventReg[90] & 8) { this->unk_356 |= 0x800; @@ -982,8 +1278,8 @@ s32 func_80AF9008(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80AF91E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { - u16 sp2E = (u16)(gSaveContext.save.time - 0x3FFC); +s32 func_80AF91E8(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { + u16 sp2E = SCHEDULE_TIME_NOW; u16 phi_v1; u8 sp2B = this->actor.params & 0xFF; s32 pad; @@ -991,8 +1287,8 @@ s32 func_80AF91E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_234 = NULL; - if (D_80AFB430[arg2->unk0] >= 0) { - this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp2B, D_80AFB430[arg2->unk0]); + if (D_80AFB430[arg2->result] >= 0) { + this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp2B, D_80AFB430[arg2->result]); } if ((this->unk_234 != NULL) && (this->unk_234->count < 3)) { @@ -1003,13 +1299,13 @@ s32 func_80AF91E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar if ((this->unk_258 < 38) && (this->unk_258 != 0) && (this->unk_374 >= 0)) { phi_v1 = sp2E; } else { - phi_v1 = arg2->unk4; + phi_v1 = arg2->time0; } - if (arg2->unk8 < phi_v1) { - this->unk_248 = (phi_v1 - arg2->unk8) + 0xFFFF; + if (arg2->time1 < phi_v1) { + this->unk_248 = (phi_v1 - arg2->time1) + 0xFFFF; } else { - this->unk_248 = arg2->unk8 - phi_v1; + this->unk_248 = arg2->time1 - phi_v1; } this->unk_254 = sp2E - phi_v1; @@ -1023,7 +1319,7 @@ s32 func_80AF91E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar Flags_UnsetSwitch(globalCtx, 0); } - switch (arg2->unk0) { + switch (arg2->result) { case 83: case 84: case 85: @@ -1062,7 +1358,7 @@ s32 func_80AF91E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80AF94AC(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80AF94AC(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { u8 sp4F = this->actor.params & 0xFF; Vec3f sp40; Vec3f sp34; @@ -1071,8 +1367,8 @@ s32 func_80AF94AC(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar s32 ret = false; this->unk_234 = NULL; - if (D_80AFB430[arg2->unk0] >= 0) { - this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80AFB430[arg2->unk0]); + if (D_80AFB430[arg2->result] >= 0) { + this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, D_80AFB430[arg2->result]); } if ((this->unk_234 != 0) && (this->unk_234->count >= 2)) { @@ -1083,7 +1379,7 @@ s32 func_80AF94AC(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar Math_Vec3s_Copy(&this->actor.shape.rot, &this->actor.world.rot); Math_Vec3f_Copy(&this->actor.world.pos, &sp40); Math_Vec3f_Copy(&this->actor.prevPos, &sp40); - if (arg2->unk0 == 24) { + if (arg2->result == 24) { Flags_UnsetSwitch(globalCtx, 0); Flags_UnsetSwitch(globalCtx, 1); this->unk_394 = EXCH_ITEM_NONE; @@ -1095,7 +1391,7 @@ s32 func_80AF94AC(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80AF95E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80AF95E8(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { u8 sp4F = this->actor.params & 0xFF; Vec3f sp40; Vec3f sp34; @@ -1104,13 +1400,13 @@ s32 func_80AF95E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar s32 ret = false; s32 phi_a3 = -1; - switch (arg2->unk0) { + switch (arg2->result) { case 3: case 4: case 5: case 6: case 7: - phi_a3 = arg2->unk0 - 3; + phi_a3 = arg2->result - 3; break; case 19: @@ -1123,7 +1419,7 @@ s32 func_80AF95E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar } this->unk_234 = NULL; - phi_a3 = D_80AFB430[arg2->unk0]; + phi_a3 = D_80AFB430[arg2->result]; if (phi_a3 >= 0) { this->unk_234 = SubS_GetAdditionalPath(globalCtx, sp4F, phi_a3); } @@ -1137,7 +1433,7 @@ s32 func_80AF95E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar Math_Vec3f_Copy(&this->actor.world.pos, &sp40); Math_Vec3f_Copy(&this->actor.prevPos, &sp40); - switch (arg2->unk0) { + switch (arg2->result) { case 27: Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_ROOM_CARTAIN); Flags_SetSwitch(globalCtx, 0); @@ -1169,7 +1465,7 @@ s32 func_80AF95E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar gSaveContext.save.weekEventReg[60] |= 4; default: - if (arg2->unk0 == 0x1D) { + if (arg2->result == 0x1D) { this->actor.world.rot.y = BINANG_ROT180(this->actor.world.rot.y); } SubS_UpdateFlags(&this->unk_356, 3, 7); @@ -1182,7 +1478,7 @@ s32 func_80AF95E8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80AF98A0(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80AF98A0(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret = false; if (Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_EN_MM3, 116.0f, 26.0f, -219.0f, 0, @@ -1193,7 +1489,7 @@ s32 func_80AF98A0(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80AF992C(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80AF992C(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { static Vec3f D_80AFB8EC = { 116.0f, 26.0f, -219.0f }; static Vec3s D_80AFB8F8 = { 0x0000, 0xC0BA, 0x0000 }; s32 pad; @@ -1205,7 +1501,7 @@ s32 func_80AF992C(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->actor.targetMode = 6; this->actor.gravity = -1.0f; this->unk_368 = 80.0f; - if (arg2->unk0 == 14) { + if (arg2->result == 14) { this->unk_356 &= ~0x200; func_80AF7E98(this, 13); } else { @@ -1215,7 +1511,7 @@ s32 func_80AF992C(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return true; } -s32 func_80AF9A0C(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80AF9A0C(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret = false; if (func_80AF8ED4(this, globalCtx, arg2, ACTORCAT_NPC, ACTOR_EN_AN)) { @@ -1233,7 +1529,7 @@ s32 func_80AF9A0C(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80AF9AB0(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80AF9AB0(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret = false; if (func_80AF8ED4(this, globalCtx, arg2, ACTORCAT_NPC, ACTOR_EN_TEST3)) { @@ -1251,7 +1547,7 @@ s32 func_80AF9AB0(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80AF9B54(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80AF9B54(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret = false; if (func_80AF8ED4(this, globalCtx, arg2, ACTORCAT_NPC, ACTOR_EN_AL)) { @@ -1269,7 +1565,7 @@ s32 func_80AF9B54(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar return ret; } -s32 func_80AF9BF8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80AF9BF8(EnPm* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret; this->actor.flags |= ACTOR_FLAG_1; @@ -1278,7 +1574,7 @@ s32 func_80AF9BF8(EnPm* this, GlobalContext* globalCtx, struct_80133038_arg2* ar this->unk_356 = 0; this->unk_368 = 40.0f; - switch (arg2->unk0) { + switch (arg2->result) { case 16: ret = func_80AF9A0C(this, globalCtx, arg2); break; @@ -1688,13 +1984,13 @@ void func_80AFA438(EnPm* this, GlobalContext* globalCtx) { } void func_80AFA4D0(EnPm* this, GlobalContext* globalCtx) { - static UNK_PTR D_80AFB900[] = { + static u8* D_80AFB900[] = { D_80AFAD80, D_80AFB30C, D_80AFB3C0, D_80AFB3FC, D_80AFB41C, }; u16 time = gSaveContext.save.time; u16 sp3C = 0; + ScheduleResult sp2C; u32* unk_14 = &gSaveContext.save.daySpeed; - struct_80133038_arg2 sp2C; this->unk_374 = REG(15) + *unk_14; if (this->unk_38C != 0) { @@ -1703,17 +1999,17 @@ void func_80AFA4D0(EnPm* this, GlobalContext* globalCtx) { gSaveContext.save.time = time; } - if (!func_80133038(globalCtx, D_80AFB900[this->unk_38C], &sp2C) || - ((this->unk_258 != sp2C.unk0) && !func_80AF9BF8(this, globalCtx, &sp2C))) { + if (!Schedule_RunScript(globalCtx, D_80AFB900[this->unk_38C], &sp2C) || + ((this->unk_258 != sp2C.result) && !func_80AF9BF8(this, globalCtx, &sp2C))) { this->actor.shape.shadowDraw = NULL; this->actor.flags &= ~ACTOR_FLAG_1; - sp2C.unk0 = 0; + sp2C.result = 0; } else { this->actor.shape.shadowDraw = ActorShadow_DrawCircle; this->actor.flags |= ACTOR_FLAG_1; } - this->unk_258 = sp2C.unk0; + this->unk_258 = sp2C.result; this->unk_268 = func_80AF8040(this, globalCtx); func_80AFA438(this, globalCtx); if (this->unk_38C != 0) { diff --git a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c index 0503d0c56f..a4e6cfd419 100644 --- a/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c +++ b/src/overlays/actors/ovl_En_Suttari/z_en_suttari.c @@ -124,13 +124,54 @@ static u16 D_80BAE800[] = { 4000, 4, 1, 3, 6000, 4, 1, 6, 4000, 4, 1, 3, 6000, 4, 1, 6, }; -static UNK_TYPE D_80BAE820[] = { - 0xC00027C, 0x210877, 0xA006D31, 0x2000000, 0x19250200, 0x19001E19, 0x2010F01, 0x140D0201, 0x14012D01, - 0x50E0114, 0x12D0E0E, 0x10F0114, 0x70E0019, 0x1E060E, 0x19, 0xD0A000D, 0x3D020019, 0x1E3102, - 0x1E002D, 0x2502002D, 0x1001902, 0x100010F, 0xD02010F, 0x1140105, 0xE010F01, 0x14090E01, 0x10F0B, - 0xE002D01, 0x20E00, 0x1E002D0A, 0xE001900, 0x1E080505, 0xC000125, 0xA006E20, 0x2120000, 0x14140200, - 0x14001E08, 0xF001E03, 0x4000405, 0xE001400, 0x1E0F0E12, 0x1403, 0x50C0003, 0x270A0013, 0x22021200, - 0x13001602, 0x13001319, 0xD021319, 0x105, 0xE131900, 0x10400, 0x50E1200, 0x13000C05, 0x5000000, +static u8 D_80BAE820[] = { + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(2, 0x80 - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_FLAG_S(0x21, 0x08, 0x7F - 0x08), + /* 0x08 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_ICHIBA, 0x3D - 0x0C), + /* 0x0C */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 0, 0, 25, 0x37 - 0x12), + /* 0x12 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 25, 0, 30, 0x31 - 0x18), + /* 0x18 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(1, 15, 1, 20, 0x2B - 0x1E), + /* 0x1E */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(1, 20, 1, 45, 0x25 - 0x24), + /* 0x24 */ SCHEDULE_CMD_RET_NONE(), + /* 0x25 */ SCHEDULE_CMD_RET_TIME(1, 20, 1, 45, 14), + /* 0x2B */ SCHEDULE_CMD_RET_TIME(1, 15, 1, 20, 7), + /* 0x31 */ SCHEDULE_CMD_RET_TIME(0, 25, 0, 30, 6), + /* 0x37 */ SCHEDULE_CMD_RET_TIME(0, 0, 0, 25, 13), + /* 0x3D */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_AYASHIISHOP, 0x7E - 0x41), + /* 0x41 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 25, 0, 30, 0x78 - 0x47), + /* 0x47 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 30, 0, 45, 0x72 - 0x4D), + /* 0x4D */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 45, 1, 0, 0x6C - 0x53), + /* 0x53 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(1, 0, 1, 15, 0x66 - 0x59), + /* 0x59 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(1, 15, 1, 20, 0x60 - 0x5F), + /* 0x5F */ SCHEDULE_CMD_RET_NONE(), + /* 0x60 */ SCHEDULE_CMD_RET_TIME(1, 15, 1, 20, 9), + /* 0x66 */ SCHEDULE_CMD_RET_TIME(1, 0, 1, 15, 11), + /* 0x6C */ SCHEDULE_CMD_RET_TIME(0, 45, 1, 0, 2), + /* 0x72 */ SCHEDULE_CMD_RET_TIME(0, 30, 0, 45, 10), + /* 0x78 */ SCHEDULE_CMD_RET_TIME(0, 25, 0, 30, 8), + /* 0x7E */ SCHEDULE_CMD_RET_NONE(), + /* 0x7F */ SCHEDULE_CMD_RET_NONE(), + /* 0x80 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(1, 0xA9 - 0x84), + /* 0x84 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_BACKTOWN, 0xA8 - 0x88), + /* 0x88 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(18, 0, 0, 20, 0xA2 - 0x8E), + /* 0x8E */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(0, 20, 0, 30, 0x9C - 0x94), + /* 0x94 */ SCHEDULE_CMD_CHECK_BEFORE_TIME_S(0, 30, 0x9B - 0x98), + /* 0x98 */ SCHEDULE_CMD_RET_VAL_L(4), + /* 0x9B */ SCHEDULE_CMD_RET_NONE(), + /* 0x9C */ SCHEDULE_CMD_RET_TIME(0, 20, 0, 30, 15), + /* 0xA2 */ SCHEDULE_CMD_RET_TIME(18, 0, 0, 20, 3), + /* 0xA8 */ SCHEDULE_CMD_RET_NONE(), + /* 0xA9 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(3, 0xD4 - 0xAD), + /* 0xAD */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_IKANA, 0xD3 - 0xB1), + /* 0xB1 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(18, 0, 19, 0, 0xCD - 0xB7), + /* 0xB7 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(19, 0, 19, 25, 0xCA - 0xBD), + /* 0xBD */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(19, 25, 0, 0, 0xC4 - 0xC3), + /* 0xC3 */ SCHEDULE_CMD_RET_NONE(), + /* 0xC4 */ SCHEDULE_CMD_RET_TIME(19, 25, 0, 0, 1), + /* 0xCA */ SCHEDULE_CMD_RET_VAL_L(5), + /* 0xCD */ SCHEDULE_CMD_RET_TIME(18, 0, 19, 0, 12), + /* 0xD3 */ SCHEDULE_CMD_RET_NONE(), + /* 0xD4 */ SCHEDULE_CMD_RET_NONE(), }; static s32 D_80BAE8F8[] = { @@ -633,12 +674,12 @@ void func_80BABB90(EnSuttari* this, s32 arg1) { } } -s32 func_80BABC48(EnSuttari* this, GlobalContext* globalCtx, struct_80133038_arg2* unkStruct) { - u16 sp26 = gSaveContext.save.time - 0x3FFC; +s32 func_80BABC48(EnSuttari* this, GlobalContext* globalCtx, ScheduleResult* unkStruct) { + u16 sp26 = SCHEDULE_TIME_NOW; u16 pad1; u8 sp23 = ENSUTTARI_GET_PATH(&this->actor); u16 pad2; - UNK_TYPE sp1C = D_80BAE8F8[unkStruct->unk0]; + UNK_TYPE sp1C = D_80BAE8F8[unkStruct->result]; u16 phi_a0; if (sp1C >= 0) { @@ -650,12 +691,12 @@ s32 func_80BABC48(EnSuttari* this, GlobalContext* globalCtx, struct_80133038_arg if ((this->unk428 != 0 && this->unk428 < 0xC) && (this->unk42A >= 0)) { phi_a0 = sp26; } else { - phi_a0 = unkStruct->unk4; + phi_a0 = unkStruct->time0; } - if (unkStruct->unk8 < phi_a0) { - this->unk418 = (phi_a0 - unkStruct->unk8) + 0xFFFF; + if (unkStruct->time1 < phi_a0) { + this->unk418 = (phi_a0 - unkStruct->time1) + 0xFFFF; } else { - this->unk418 = unkStruct->unk8 - phi_a0; + this->unk418 = unkStruct->time1 - phi_a0; } this->unk424 = sp26 - phi_a0; phi_a0 = this->unk404->count - 2; @@ -666,7 +707,7 @@ s32 func_80BABC48(EnSuttari* this, GlobalContext* globalCtx, struct_80133038_arg return 1; } -s32 func_80BABDD8(EnSuttari* this, GlobalContext* globalCtx, struct_80133038_arg2* unkStruct) { +s32 func_80BABDD8(EnSuttari* this, GlobalContext* globalCtx, ScheduleResult* unkStruct) { s32 pad; EnDoor* sp48; u8 sp47; @@ -677,12 +718,12 @@ s32 func_80BABDD8(EnSuttari* this, GlobalContext* globalCtx, struct_80133038_arg UNK_TYPE sp24; sp47 = ENSUTTARI_GET_PATH(&this->actor); - sp44 = gSaveContext.save.time - 0x3FFC; + sp44 = SCHEDULE_TIME_NOW; if (this->unk428 == 10 || this->unk428 == 11 || this->unk428 == 2) { return 0; } sp48 = (EnDoor*)SubS_FindNearestActor(&this->actor, globalCtx, ACTORCAT_DOOR, ACTOR_EN_DOOR); - sp24 = D_80BAE8F8[unkStruct->unk0]; + sp24 = D_80BAE8F8[unkStruct->result]; if ((sp48 != NULL) && (sp24 >= 0)) { this->unk404 = SubS_GetAdditionalPath(globalCtx, sp47, sp24); } @@ -692,9 +733,9 @@ s32 func_80BABDD8(EnSuttari* this, GlobalContext* globalCtx, struct_80133038_arg sp28 = Lib_SegmentedToVirtual(this->unk404->points); Math_Vec3s_ToVec3f(&sp38, &sp28[0]); Math_Vec3s_ToVec3f(&sp2C, &sp28[1]); - this->unk434 = sp44 - unkStruct->unk4; - this->unk436 = unkStruct->unk8 - unkStruct->unk4; - if (unkStruct->unk0 != 10 && unkStruct->unk0 != 11) { + this->unk434 = sp44 - unkStruct->time0; + this->unk436 = unkStruct->time1 - unkStruct->time0; + if (unkStruct->result != 10 && unkStruct->result != 11) { sp48->unk_1A7 = 0x4B; } Math_Vec3f_Copy(&this->unk438, &sp38); @@ -704,10 +745,10 @@ s32 func_80BABDD8(EnSuttari* this, GlobalContext* globalCtx, struct_80133038_arg return 1; } -s32 func_80BABF64(EnSuttari* this, GlobalContext* globalCtx, struct_80133038_arg2* unkStruct) { +s32 func_80BABF64(EnSuttari* this, GlobalContext* globalCtx, ScheduleResult* unkStruct) { s32 ret; - switch (unkStruct->unk0) { + switch (unkStruct->result) { case 15: case 14: case 13: @@ -1059,18 +1100,17 @@ void func_80BACE4C(EnSuttari* this, GlobalContext* globalCtx) { } void func_80BACEE0(EnSuttari* this, GlobalContext* globalCtx) { - u32* unk_14 = &gSaveContext.save.daySpeed; - struct_80133038_arg2 unkStruct; + ScheduleResult unkStruct; - this->unk42A = REG(15) + *unk_14; - if (!func_80133038(globalCtx, D_80BAE820, &unkStruct) || - ((this->unk428 != unkStruct.unk0) && !func_80BABF64(this, globalCtx, &unkStruct))) { + this->unk42A = REG(15) + ((void)0, gSaveContext.save.daySpeed); + if (!Schedule_RunScript(globalCtx, D_80BAE820, &unkStruct) || + ((this->unk428 != unkStruct.result) && !func_80BABF64(this, globalCtx, &unkStruct))) { this->actor.flags &= ~ACTOR_FLAG_1; - unkStruct.unk0 = 0; + unkStruct.result = 0; } else { this->actor.flags |= ACTOR_FLAG_1; } - this->unk428 = unkStruct.unk0; + this->unk428 = unkStruct.result; func_80BAC2FC(this, globalCtx); func_80BAB434(this); if (this->unk428 == 5) { @@ -1084,18 +1124,17 @@ void func_80BACEE0(EnSuttari* this, GlobalContext* globalCtx) { } void func_80BAD004(EnSuttari* this, GlobalContext* globalCtx) { - u32* unk_14 = &gSaveContext.save.daySpeed; - struct_80133038_arg2 unkStruct; + ScheduleResult unkStruct; - this->unk42A = REG(15) + *unk_14; - if (!func_80133038(globalCtx, D_80BAE820, &unkStruct) || - ((this->unk428 != unkStruct.unk0) && !func_80BABF64(this, globalCtx, &unkStruct))) { + this->unk42A = REG(15) + ((void)0, gSaveContext.save.daySpeed); + if (!Schedule_RunScript(globalCtx, D_80BAE820, &unkStruct) || + ((this->unk428 != unkStruct.result) && !func_80BABF64(this, globalCtx, &unkStruct))) { this->actor.flags &= ~ACTOR_FLAG_1; - unkStruct.unk0 = 0; + unkStruct.result = 0; } else { this->actor.flags |= ACTOR_FLAG_1; } - this->unk428 = unkStruct.unk0; + this->unk428 = unkStruct.result; func_80BAC2FC(this, globalCtx); if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { Message_StartTextbox(globalCtx, 0x2A3A, &this->actor); @@ -1206,8 +1245,7 @@ void func_80BAD380(EnSuttari* this, GlobalContext* globalCtx) { } void func_80BAD5F8(EnSuttari* this, GlobalContext* globalCtx) { - u32* unk_14 = &gSaveContext.save.daySpeed; - struct_80133038_arg2 unkStruct; + ScheduleResult unkStruct; s16 curFrame = this->skelAnime.curFrame; s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); @@ -1215,22 +1253,22 @@ void func_80BAD5F8(EnSuttari* this, GlobalContext* globalCtx) { this->animationIndex = 2; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); } - this->unk42A = REG(15) + *unk_14; - if (!func_80133038(globalCtx, D_80BAE820, &unkStruct) || - ((this->unk428 != unkStruct.unk0) && !func_80BABF64(this, globalCtx, &unkStruct))) { + this->unk42A = REG(15) + ((void)0, gSaveContext.save.daySpeed); + if (!Schedule_RunScript(globalCtx, D_80BAE820, &unkStruct) || + ((this->unk428 != unkStruct.result) && !func_80BABF64(this, globalCtx, &unkStruct))) { this->actor.flags &= ~ACTOR_FLAG_1; - unkStruct.unk0 = 0; + unkStruct.result = 0; } else { this->actor.flags |= ACTOR_FLAG_1; } - this->unk428 = unkStruct.unk0; + this->unk428 = unkStruct.result; func_80BAC2FC(this, globalCtx); if ((this->unk430 == 1) && (this->unk404->unk1 == 0xFF)) { Actor_MarkForDeath(&this->actor); return; } func_80BAB434(this); - if ((this->flags1 & 0x20) && (this->unk430 == 0) && (unkStruct.unk0 != 7)) { + if ((this->flags1 & 0x20) && (this->unk430 == 0) && (unkStruct.result != 7)) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { Message_StartTextbox(globalCtx, 0x2A02, &this->actor); this->actionFunc = func_80BAD130; @@ -1242,8 +1280,7 @@ void func_80BAD5F8(EnSuttari* this, GlobalContext* globalCtx) { } void func_80BAD7F8(EnSuttari* this, GlobalContext* globalCtx) { - u32* unk_14 = &gSaveContext.save.daySpeed; - struct_80133038_arg2 unkStruct; + ScheduleResult unkStruct; s16 curFrame = this->skelAnime.curFrame; s16 frameCount = Animation_GetLastFrame(sAnimations[this->animationIndex].animation); @@ -1254,21 +1291,21 @@ void func_80BAD7F8(EnSuttari* this, GlobalContext* globalCtx) { this->animationIndex = 2; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, this->animationIndex); } - this->unk42A = REG(15) + *unk_14; - if (!func_80133038(globalCtx, D_80BAE820, &unkStruct) || - ((this->unk428 != unkStruct.unk0) && !func_80BABF64(this, globalCtx, &unkStruct))) { + this->unk42A = REG(15) + ((void)0, gSaveContext.save.daySpeed); + if (!Schedule_RunScript(globalCtx, D_80BAE820, &unkStruct) || + ((this->unk428 != unkStruct.result) && !func_80BABF64(this, globalCtx, &unkStruct))) { this->actor.flags &= ~ACTOR_FLAG_1; - unkStruct.unk0 = 0; + unkStruct.result = 0; } else { this->actor.flags |= ACTOR_FLAG_1; } - this->unk428 = unkStruct.unk0; + this->unk428 = unkStruct.result; func_80BAC2FC(this, globalCtx); if ((this->unk430 == 1) && (this->unk404->unk1 == 0xFF)) { Actor_MarkForDeath(&this->actor); return; } - if ((this->flags1 & 0x20) && (unkStruct.unk0 != 9)) { + if ((this->flags1 & 0x20) && (unkStruct.result != 9)) { if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { Message_StartTextbox(globalCtx, 0x2A02, &this->actor); this->actionFunc = func_80BAD130; diff --git a/src/overlays/actors/ovl_En_Tab/z_en_tab.c b/src/overlays/actors/ovl_En_Tab/z_en_tab.c index 2d3ae20404..f1c9c6bbce 100644 --- a/src/overlays/actors/ovl_En_Tab/z_en_tab.c +++ b/src/overlays/actors/ovl_En_Tab/z_en_tab.c @@ -20,9 +20,22 @@ void EnTab_Draw(Actor* thisx, GlobalContext* globalCtx); void func_80BE127C(EnTab* this, GlobalContext* globalCtx); void func_80BE1348(EnTab* this, GlobalContext* globalCtx); -s32 D_80BE18D0[] = { - 0x0C000320, 0x0A00151B, 0x02093212, 0x010F0212, 0x00060003, 0x0400000E, 0x12000600, 0x020E0932, 0x12010105, - 0x0A001519, 0x02093215, 0x050D0215, 0x37050501, 0x050E1537, 0x0505020E, 0x09321505, 0x01050000, +static u8 D_80BE18D0[] = { + /* 0x00 */ SCHEDULE_CMD_CHECK_NOT_IN_DAY_S(3, 0x24 - 0x04), + /* 0x04 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_MILK_BAR, 0x23 - 0x08), + /* 0x08 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(9, 50, 18, 1, 0x1D - 0x0E), + /* 0x0E */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(18, 0, 6, 0, 0x17 - 0x14), + /* 0x14 */ SCHEDULE_CMD_RET_VAL_L(0), + /* 0x17 */ SCHEDULE_CMD_RET_TIME(18, 0, 6, 0, 2), + /* 0x1D */ SCHEDULE_CMD_RET_TIME(9, 50, 18, 1, 1), + /* 0x23 */ SCHEDULE_CMD_RET_NONE(), + /* 0x24 */ SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S(SCENE_MILK_BAR, 0x41 - 0x28), + /* 0x28 */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(9, 50, 21, 5, 0x3B - 0x2E), + /* 0x2E */ SCHEDULE_CMD_CHECK_TIME_RANGE_S(21, 55, 5, 5, 0x35 - 0x34), + /* 0x34 */ SCHEDULE_CMD_RET_NONE(), + /* 0x35 */ SCHEDULE_CMD_RET_TIME(21, 55, 5, 5, 2), + /* 0x3B */ SCHEDULE_CMD_RET_TIME(9, 50, 21, 5, 1), + /* 0x41 */ SCHEDULE_CMD_RET_NONE(), }; s32 D_80BE1914[] = { @@ -353,7 +366,7 @@ s32* func_80BE0E04(EnTab* this, GlobalContext* globalCtx) { return NULL; } -s32 func_80BE0F04(EnTab* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BE0F04(EnTab* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret = false; EnGm* sp28 = func_80BE04E0(this, globalCtx, ACTORCAT_NPC, ACTOR_EN_GM); @@ -372,7 +385,7 @@ s32 func_80BE0F04(EnTab* this, GlobalContext* globalCtx, struct_80133038_arg2* a return ret; } -s32 func_80BE0FC4(EnTab* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BE0FC4(EnTab* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 pad; Math_Vec3f_Copy(&this->actor.world.pos, &D_80BE1B04); @@ -386,12 +399,12 @@ s32 func_80BE0FC4(EnTab* this, GlobalContext* globalCtx, struct_80133038_arg2* a return true; } -s32 func_80BE1060(EnTab* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80BE1060(EnTab* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 ret; this->unk_2FC = 0; - switch (arg2->unk0) { + switch (arg2->result) { case 1: ret = func_80BE0F04(this, globalCtx, arg2); break; @@ -459,21 +472,20 @@ void func_80BE1224(EnTab* this, GlobalContext* globalCtx) { } void func_80BE127C(EnTab* this, GlobalContext* globalCtx) { - u32* unk_14 = &gSaveContext.save.daySpeed; - struct_80133038_arg2 sp18; + ScheduleResult sp18; - this->unk_31A = REG(15) + *unk_14; + this->unk_31A = REG(15) + ((void)0, gSaveContext.save.daySpeed); - if (!func_80133038(globalCtx, D_80BE18D0, &sp18) || - ((this->unk_1D8 != sp18.unk0) && !func_80BE1060(this, globalCtx, &sp18))) { + if (!Schedule_RunScript(globalCtx, D_80BE18D0, &sp18) || + ((this->unk_1D8 != sp18.result) && !func_80BE1060(this, globalCtx, &sp18))) { this->actor.shape.shadowDraw = NULL; this->actor.flags &= ~ACTOR_FLAG_1; - sp18.unk0 = 0; + sp18.result = 0; } else { this->actor.shape.shadowDraw = ActorShadow_DrawCircle; this->actor.flags |= ACTOR_FLAG_1; } - this->unk_1D8 = sp18.unk0; + this->unk_1D8 = sp18.result; func_80BE1224(this, globalCtx); } diff --git a/src/overlays/actors/ovl_En_Tk/z_en_tk.c b/src/overlays/actors/ovl_En_Tk/z_en_tk.c index 830c86471c..d239a6cb70 100644 --- a/src/overlays/actors/ovl_En_Tk/z_en_tk.c +++ b/src/overlays/actors/ovl_En_Tk/z_en_tk.c @@ -24,8 +24,8 @@ void func_80AECB0C(EnTk* this, GlobalContext* globalCtx); void func_80AECB6C(EnTk* this, GlobalContext* globalCtx); void func_80AECE0C(EnTk* this, GlobalContext* globalCtx); s32 func_80AECE60(EnTk* this, GlobalContext* globalCtx); -s32 func_80AED354(EnTk* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2); -s32 func_80AED38C(EnTk* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2); +s32 func_80AED354(EnTk* this, GlobalContext* globalCtx, ScheduleResult* arg2); +s32 func_80AED38C(EnTk* this, GlobalContext* globalCtx, ScheduleResult* arg2); void func_80AED4F8(EnTk* this, GlobalContext* globalCtx); void func_80AED610(EnTk* this, GlobalContext* globalCtx); void func_80AED898(EnTk* this, GlobalContext* globalCtx); @@ -62,11 +62,11 @@ void func_80AEF5F4(Actor* thisx, GlobalContext* globalCtx); static s32 D_80AF0050; -static u32 D_80AEF800[] = { - 0x03060012, - 0x00000105, - 0x0E060012, - 0x00010500, +static u8 D_80AEF800[] = { + /* 0x0 */ SCHEDULE_CMD_CHECK_TIME_RANGE_L(6, 0, 18, 0, 0x8 - 0x7), + /* 0x7 */ SCHEDULE_CMD_RET_NONE(), + /* 0x8 */ SCHEDULE_CMD_RET_TIME(6, 0, 18, 0, 1), + /* 0xE */ SCHEDULE_CMD_RET_NONE(), }; const ActorInit En_Tk_InitVars = { @@ -313,8 +313,8 @@ void func_80AECB6C(EnTk* this, GlobalContext* globalCtx) { s32 temp3; f32 sp48; f32 sp44; + ScheduleResult sp34; u8 temp4; - struct_80133038_arg2 sp34; this->actor.textId = 0; if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) { @@ -347,14 +347,14 @@ void func_80AECB6C(EnTk* this, GlobalContext* globalCtx) { this->unk_2DC -= temp3; this->unk_2E0 += REG(15); - if (func_80133038(globalCtx, (UNK_TYPE*)D_80AEF800, &sp34)) { - if ((this->unk_3CC != sp34.unk0) && !func_80AED354(this, globalCtx, &sp34)) { + if (Schedule_RunScript(globalCtx, D_80AEF800, &sp34)) { + if ((this->unk_3CC != sp34.result) && !func_80AED354(this, globalCtx, &sp34)) { return; } - temp4 = sp34.unk0; + temp4 = sp34.result; } else { - sp34.unk0 = 0; - temp4 = sp34.unk0; + sp34.result = 0; + temp4 = sp34.result; } if (!temp4 && (this->unk_3CC != 0)) { @@ -365,7 +365,7 @@ void func_80AECB6C(EnTk* this, GlobalContext* globalCtx) { this->actor.draw = EnTk_Draw; } - this->unk_3CC = sp34.unk0; + this->unk_3CC = sp34.result; func_80AECE0C(this, globalCtx); if (this->unk_3CE & 8) { @@ -492,20 +492,20 @@ s32 func_80AECE60(EnTk* this, GlobalContext* globalCtx) { return false; } -s32 func_80AED354(EnTk* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { +s32 func_80AED354(EnTk* this, GlobalContext* globalCtx, ScheduleResult* arg2) { s32 phi_v1 = false; - if (arg2->unk0 != 0) { + if (arg2->result != 0) { phi_v1 = func_80AED38C(this, globalCtx, arg2); } return phi_v1; } -s32 func_80AED38C(EnTk* this, GlobalContext* globalCtx, struct_80133038_arg2* arg2) { - u16 sp1E = gSaveContext.save.time - 0x3FFC; +s32 func_80AED38C(EnTk* this, GlobalContext* globalCtx, ScheduleResult* arg2) { + u16 sp1E = SCHEDULE_TIME_NOW; u8 params = ENTK_GET_F800(&this->actor); u16 phi_a1; - s32 idx = arg2->unk0 - 1; + s32 idx = arg2->result - 1; this->unk_3C8 = SubS_GetAdditionalPath(globalCtx, params, D_80AEF8E8[idx + 1]); if (this->unk_3C8 == 0) { @@ -515,10 +515,10 @@ s32 func_80AED38C(EnTk* this, GlobalContext* globalCtx, struct_80133038_arg2* ar if ((this->unk_3CC <= 0) && (this->unk_3CC != 0) && (this->unk_3D0 >= 0)) { phi_a1 = sp1E; } else { - phi_a1 = arg2->unk4; + phi_a1 = arg2->time0; } - this->unk_3E4 = arg2->unk8 - phi_a1; + this->unk_3E4 = arg2->time1 - phi_a1; this->unk_3F0 = sp1E - phi_a1; phi_a1 = this->unk_3C8->count - 2; this->unk_3E8 = this->unk_3E4 / phi_a1; diff --git a/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c b/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c index a8745c0152..f91385daa2 100644 --- a/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c +++ b/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c @@ -4,6 +4,7 @@ * Description: Unused OoT Saria's Song Ocarina Effect */ +#include "prevent_bss_reordering.h" #include "z_oceff_wipe3.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_2000000) diff --git a/tools/disasm/files.txt b/tools/disasm/files.txt index cd1bbac2fd..d8cd09c995 100644 --- a/tools/disasm/files.txt +++ b/tools/disasm/files.txt @@ -418,7 +418,7 @@ 0x8012F2E0 : "z_scene", 0x801307C0 : "z_scene_proc", 0x801322C0 : "z_scene_table", - 0x801323D0 : "code_801323D0", + 0x801323D0 : "z_schedule", 0x801330E0 : "z_skelanime", 0x80137970 : "z_skin", 0x80138410 : "z_skin_awb", @@ -554,7 +554,7 @@ 0x801C2730 : "", 0x801C3B60 : "z_scene_proc", 0x801C3CA0 : "z_scene_table", - 0x801C5C50 : "", + 0x801C5C50 : "z_schedule", 0x801C5CB0 : "z_skelanime", 0x801C5CD0 : "z_skin_matrix", 0x801C5D10 : "z_sub_s", diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index e42433b9bb..fe4697ca9f 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -2499,26 +2499,26 @@ 0x80132338:("Entrance_GetSceneNumAbsolute",), 0x80132374:("Entrance_GetSpawnNum",), 0x801323A0:("Entrance_GetTransitionFlags",), - 0x801323D0:("func_801323D0",), - 0x80132428:("func_80132428",), - 0x80132494:("func_80132494",), - 0x801326B8:("func_801326B8",), - 0x801328F0:("func_801328F0",), - 0x80132920:("func_80132920",), - 0x80132938:("func_80132938",), - 0x80132954:("func_80132954",), - 0x8013296C:("func_8013296C",), - 0x80132A18:("func_80132A18",), - 0x80132A3C:("func_80132A3C",), - 0x80132A80:("func_80132A80",), - 0x80132AD8:("func_80132AD8",), - 0x80132B24:("func_80132B24",), - 0x80132B84:("func_80132B84",), - 0x80132D70:("func_80132D70",), - 0x80132E9C:("func_80132E9C",), - 0x80132FDC:("func_80132FDC",), - 0x80133000:("func_80133000",), - 0x80133038:("func_80133038",), + 0x801323D0:("Schedule_CheckFlagS",), + 0x80132428:("Schedule_CheckFlagL",), + 0x80132494:("Schedule_CheckTimeRangeS",), + 0x801326B8:("Schedule_CheckTimeRangeL",), + 0x801328F0:("Schedule_ReturnValueL",), + 0x80132920:("Schedule_ReturnNone",), + 0x80132938:("Schedule_ReturnEmpty",), + 0x80132954:("Schedule_Nop",), + 0x8013296C:("Schedule_CheckMiscS",), + 0x80132A18:("Schedule_ReturnValueS",), + 0x80132A3C:("Schedule_CheckSceneS",), + 0x80132A80:("Schedule_CheckSceneL",), + 0x80132AD8:("Schedule_CheckDayS",), + 0x80132B24:("Schedule_CheckDayL",), + 0x80132B84:("Schedule_ReturnTime",), + 0x80132D70:("Schedule_CheckBeforeTimeS",), + 0x80132E9C:("Schedule_CheckBeforeTimeL",), + 0x80132FDC:("Schedule_BranchL",), + 0x80133000:("Schedule_JumpL",), + 0x80133038:("Schedule_RunScript",), 0x801330E0:("SkelAnime_DrawLimbLod",), 0x801332F0:("SkelAnime_DrawLod",), 0x801334A0:("SkelAnime_DrawFlexLimbLod",), diff --git a/tools/namefixer.py b/tools/namefixer.py index 08621f709b..db7d97e822 100755 --- a/tools/namefixer.py +++ b/tools/namefixer.py @@ -494,7 +494,7 @@ wordReplace = { "func_80158FB0": "Message_LoadTimeNES", "func_8015926C": "Message_LoadAreaTextNES", "func_8015E750": "Message_FindCreditsMessage", - + "func_80133038": "Schedule_RunScript", # Struct members "skelAnime.unk03": "skelAnime.taper", diff --git a/tools/overlayhelpers/scheduledis.py b/tools/overlayhelpers/scheduledis.py new file mode 100755 index 0000000000..b441b94c7e --- /dev/null +++ b/tools/overlayhelpers/scheduledis.py @@ -0,0 +1,264 @@ +#!/usr/bin/env python3 +# +# MM Event Script Disassembler +# + +import argparse, os, struct, math +from actor_symbols import resolve_symbol + +cmd_info = [ + ('SCHEDULE_CMD_CHECK_FLAG_S', 0x04, '>BBb', (2, )), + ('SCHEDULE_CMD_CHECK_FLAG_L', 0x05, '>BBh', (2, )), + ('SCHEDULE_CMD_CHECK_TIME_RANGE_S', 0x06, '>BBBBb', (4, )), + ('SCHEDULE_CMD_CHECK_TIME_RANGE_L', 0x07, '>BBBBh', (4, )), + ('SCHEDULE_CMD_RET_VAL_L', 0x03, '>H', ( )), + ('SCHEDULE_CMD_RET_NONE', 0x01, '', ( )), + ('SCHEDULE_CMD_RET_EMPTY', 0x01, '', ( )), + ('SCHEDULE_CMD_NOP', 0x04, '>BBB', ( )), + ('SCHEDULE_CMD_CHECK_MISC_S', 0x03, '>Bb', (1, )), + ('SCHEDULE_CMD_RET_VAL_S', 0x02, '>B', ( )), + ('SCHEDULE_CMD_CHECK_NOT_IN_SCENE_S', 0x04, '>Hb', (1, )), + ('SCHEDULE_CMD_CHECK_NOT_IN_SCENE_L', 0x05, '>Hh', (1, )), + ('SCHEDULE_CMD_CHECK_NOT_IN_DAY_S', 0x04, '>Hb', (1, )), + ('SCHEDULE_CMD_CHECK_NOT_IN_DAY_L', 0x05, '>Hh', (1, )), + ('SCHEDULE_CMD_RET_TIME', 0x06, '>BBBBB', ( )), + ('SCHEDULE_CMD_CHECK_BEFORE_TIME_S', 0x04, '>BBb', (2, )), + ('SCHEDULE_CMD_CHECK_BEFORE_TIME_L', 0x05, '>BBh', (2, )), + ('SCHEDULE_CMD_BRANCH_S', 0x02, '>b', (0, )), + ('SCHEDULE_CMD_BRANCH_L', 0x03, '>h', (0, )), +] + +scene_names = [ + 'SCENE_20SICHITAI2', + 'SCENE_UNSET_1', + 'SCENE_UNSET_2', + 'SCENE_UNSET_3', + 'SCENE_UNSET_4', + 'SCENE_UNSET_5', + 'SCENE_UNSET_6', + 'SCENE_KAKUSIANA', + 'SCENE_SPOT00', + 'SCENE_UNSET_9', + 'SCENE_WITCH_SHOP', + 'SCENE_LAST_BS', + 'SCENE_HAKASHITA', + 'SCENE_AYASHIISHOP', + 'SCENE_UNSET_E', + 'SCENE_UNSET_F', + 'SCENE_OMOYA', + 'SCENE_BOWLING', + 'SCENE_SONCHONOIE', + 'SCENE_IKANA', + 'SCENE_KAIZOKU', + 'SCENE_MILK_BAR', + 'SCENE_INISIE_N', + 'SCENE_TAKARAYA', + 'SCENE_INISIE_R', + 'SCENE_OKUJOU', + 'SCENE_OPENINGDAN', + 'SCENE_MITURIN', + 'SCENE_13HUBUKINOMITI', + 'SCENE_CASTLE', + 'SCENE_DEKUTES', + 'SCENE_MITURIN_BS', + 'SCENE_SYATEKI_MIZU', + 'SCENE_HAKUGIN', + 'SCENE_ROMANYMAE', + 'SCENE_PIRATE', + 'SCENE_SYATEKI_MORI', + 'SCENE_SINKAI', + 'SCENE_YOUSEI_IZUMI', + 'SCENE_KINSTA1', + 'SCENE_KINDAN2', + 'SCENE_TENMON_DAI', + 'SCENE_LAST_DEKU', + 'SCENE_22DEKUCITY', + 'SCENE_KAJIYA', + 'SCENE_00KEIKOKU', + 'SCENE_POSTHOUSE', + 'SCENE_LABO', + 'SCENE_DANPEI2TEST', + 'SCENE_UNSET_31', + 'SCENE_16GORON_HOUSE', + 'SCENE_33ZORACITY', + 'SCENE_8ITEMSHOP', + 'SCENE_F01', + 'SCENE_INISIE_BS', + 'SCENE_30GYOSON', + 'SCENE_31MISAKI', + 'SCENE_TAKARAKUJI', + 'SCENE_UNSET_3A', + 'SCENE_TORIDE', + 'SCENE_FISHERMAN', + 'SCENE_GORONSHOP', + 'SCENE_DEKU_KING', + 'SCENE_LAST_GORON', + 'SCENE_24KEMONOMITI', + 'SCENE_F01_B', + 'SCENE_F01C', + 'SCENE_BOTI', + 'SCENE_HAKUGIN_BS', + 'SCENE_20SICHITAI', + 'SCENE_21MITURINMAE', + 'SCENE_LAST_ZORA', + 'SCENE_11GORONNOSATO2', + 'SCENE_SEA', + 'SCENE_35TAKI', + 'SCENE_REDEAD', + 'SCENE_BANDROOM', + 'SCENE_11GORONNOSATO', + 'SCENE_GORON_HAKA', + 'SCENE_SECOM', + 'SCENE_10YUKIYAMANOMURA', + 'SCENE_TOUGITES', + 'SCENE_DANPEI', + 'SCENE_IKANAMAE', + 'SCENE_DOUJOU', + 'SCENE_MUSICHOUSE', + 'SCENE_IKNINSIDE', + 'SCENE_MAP_SHOP', + 'SCENE_F40', + 'SCENE_F41', + 'SCENE_10YUKIYAMANOMURA2', + 'SCENE_14YUKIDAMANOMITI', + 'SCENE_12HAKUGINMAE', + 'SCENE_17SETUGEN', + 'SCENE_17SETUGEN2', + 'SCENE_SEA_BS', + 'SCENE_RANDOM', + 'SCENE_YADOYA', + 'SCENE_KONPEKI_ENT', + 'SCENE_INSIDETOWER', + 'SCENE_26SARUNOMORI', + 'SCENE_LOST_WOODS', + 'SCENE_LAST_LINK', + 'SCENE_SOUGEN', + 'SCENE_BOMYA', + 'SCENE_KYOJINNOMA', + 'SCENE_KOEPONARACE', + 'SCENE_GORONRACE', + 'SCENE_TOWN', + 'SCENE_ICHIBA', + 'SCENE_BACKTOWN', + 'SCENE_CLOCKTOWER', + 'SCENE_ALLEY' +] + +def read_bytes(data_file, offset, len): + data_file.seek(offset) + return bytearray(data_file.read(len)) + +def calc_length(data_file, offset): + off = 0 + cmd = None + branch_targets = [] + + # Parse script, just keeping track of branches, until we find the end + while any([branch >= off for branch in branch_targets]) or cmd not in [0x04, 0x05, 0x06, 0x09]: + cmd = read_bytes(data_file, offset + off, 1)[0] + + cmd_len = cmd_info[cmd][1] + cmd_args = cmd_info[cmd][2] + + if len(cmd_args) > 1: + arg_values = struct.unpack(cmd_args, read_bytes(data_file, offset + off + 1, cmd_len - 1)) + for i in cmd_info[cmd][3]: + branch_targets.append(off + arg_values[i] + cmd_len) + + off += cmd_len + + return off + +def disassemble_unk_script(data_file, offset): + off = 0 + cmd = None + branch_targets = [] + script_len = calc_length(data_file, offset); + script_len_num_digits = 0 if script_len == 1 else int(math.ceil(math.log(script_len - 1, 16))) + + out = "static u8 sScheduleScript[] = {\n" + + # Keep trying to disassemble until it hits a terminator and no commands branch past it + while any([branch >= off for branch in branch_targets]) or cmd not in [0x04, 0x05, 0x06, 0x09]: + cmd = read_bytes(data_file, offset + off, 1)[0] + + cmd_name = cmd_info[cmd][0] + cmd_len = cmd_info[cmd][1] + cmd_args = cmd_info[cmd][2] + + args_formatted = [] + if len(cmd_args) > 1: # handle args + arg_values = struct.unpack(cmd_args, read_bytes(data_file, offset + off + 1, cmd_len - 1)) + for i,(arg_value,arg_type) in enumerate(zip(arg_values, cmd_args[1:]),0): + arg_formatted = "" + if arg_type == "h": + arg_formatted = f"{arg_value:#x}" + elif arg_type == "b": + arg_formatted = f"{arg_value:#x}" + elif arg_type == "H": + if (cmd == 0x0A or cmd == 0x0B) and (arg_value < len(scene_names)): + arg_formatted = scene_names[arg_value] + else: + arg_formatted = f"{arg_value}" + elif arg_type == "B": + if cmd == 0x00 or cmd == 0x01: + arg_formatted = f"0x{arg_value:02X}" + elif cmd == 0x08: + if arg_value == 0: + arg_formatted = "SCHEDULE_CHECK_MISC_ROOM_KEY" + elif arg_value == 1: + arg_formatted = "SCHEDULE_CHECK_MISC_LETTER_TO_KAFEI" + elif arg_value == 2: + arg_formatted = "SCHEDULE_CHECK_MISC_MASK_ROMANI" + else: + arg_formatted = f"0x{arg_value:02X}" + else: + arg_formatted = f"{arg_value:2}" + elif arg_type == "S": + if arg_value < len(scene_names): + arg_formatted = scene_names[arg_value] + else: + arg_formatted = f"0x{arg_value:04X}" + + if i in cmd_info[cmd][3]: # skip argument indices + # add skip args to branch targets, and change the output to absolute differences rather than relative offsets + arg_value += cmd_len + branch_targets.append(off + arg_value) + if arg_value == cmd_len: + arg_formatted == "0" + else: + arg_formatted = f"0x{off + arg_value:0{script_len_num_digits}X} - 0x{off + cmd_len:0{script_len_num_digits}X}" + args_formatted.append(arg_formatted) + + args = ", ".join(args_formatted) if len(args_formatted) != 0 else "" + + out += f" /* 0x{off:0{script_len_num_digits}X} */ {cmd_name}({args}),\n" + + off += cmd_len + + out = out.strip() + out += "\n};" + + print(out) + +def hex_parse(s): + return int(s, 16) + +def main(): + parser = argparse.ArgumentParser(description="Disassembles MM event scripts") + parser.add_argument('address', help="VRAM or ROM address to disassemble at", type=hex_parse) + args = parser.parse_args() + + file_result = resolve_symbol(args.address) + + if file_result[0] is None: + print("Invalid address") + return + + print(hex(file_result[1]), "in", file_result[0].split(os.sep)[-1]) + + with open(file_result[0],"rb") as data_file: + disassemble_unk_script(data_file, file_result[1]) + +if __name__ == "__main__": + main()