diff --git a/include/functions.h b/include/functions.h index b9de153a78..c9636d2643 100644 --- a/include/functions.h +++ b/include/functions.h @@ -145,5 +145,6 @@ ScriptInstance* get_script_by_index(s32 index); void suspend_all_group(s32 groupFlags); void kill_script(ScriptInstance* instanceToKill); +void func_8010FD68(Entity* entity); #endif diff --git a/src/code_102610_len_2330.c b/src/code_102610_len_2330.c index 655f2acae3..0bd5f5fbe2 100644 --- a/src/code_102610_len_2330.c +++ b/src/code_102610_len_2330.c @@ -1,7 +1,5 @@ #include "common.h" -void func_8010FD68(Entity* entity); - void create_shadow_callback(Shadow* shadow) { shadow->scale.x = 0.1f; shadow->scale.y = 0.1f; @@ -21,14 +19,14 @@ INCLUDE_ASM(s32, "code_102610_len_2330", func_802E0DE0); typedef struct struct802E10F4 { char unk_0[4]; - Vec3s angle; // TODO: could be wrong, but based on the single usage, seems right to me. + s16 angle; } struct802E10F4; void func_802E10F4(Entity* entity) { struct802E10F4* temp; temp = (struct802E10F4*)entity->dataBuf; - temp->angle.x = clamp_angle(temp->angle.x + 6); + temp->angle = clamp_angle(temp->angle + 6); func_802E3650(entity); } diff --git a/src/code_109660_len_1270.c b/src/code_109660_len_1270.c index dfabb48d4c..af2b8b88fd 100644 --- a/src/code_109660_len_1270.c +++ b/src/code_109660_len_1270.c @@ -1,17 +1,87 @@ #include "common.h" #include "map.h" +MapConfig* get_current_map_header(void); +void disable_player_input(void); +void disable_player_static_collisions(void); +void move_player(s32, f32, f32); +s32 func_802E854C(); + +typedef struct struct802E7DE0 { + /* 0x000 */ s32 unk_000; + /* 0x004 */ s32 unk_004; + /* 0x008 */ u8* unk_008; + /* 0x00C */ s32 unk_00C; + /* 0x010 */ u8 unk_010[36]; + /* 0x034 */ s8 unk_034[36]; + /* 0x058 */ u8 unk_058[36]; + /* 0x07C */ u8 unk_07C[36]; + /* 0x0A0 */ u8 unk_0A0[36]; + /* 0x0C4 */ f32 unk_0C4[36]; + /* 0x154 */ f32 unk_154[36]; + /* 0x1E4 */ f32 unk_1E4[36]; + /* 0x274 */ f32 unk_274[36]; + /* 0x304 */ f32 unk_304[36]; +} struct802E7DE0; + INCLUDE_ASM(s32, "code_109660_len_1270", func_802E7DE0); -INCLUDE_ASM(s32, "code_109660_len_1270", func_802E7F40); +typedef struct struct802E7F40 { + /* 0x00 */ s32 unk_00; + /* 0x04 */ u16 unk_04; + /* 0x06 */ char unk_06[6]; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ char unk_10[4]; + /* 0x14 */ s32 unk_14; +} struct802E7F40; + +void func_802E7F40(Entity* entity) { + struct802E7F40* temp_v1; + + temp_v1 = entity->dataBuf; + entity->scale.y = 0.85714287f; + temp_v1->unk_04 = 0xFFFF; + temp_v1->unk_00 = D_8015C7D0; +} + +extern UNK_TYPE D_0A004350; +extern UNK_TYPE D_0A0026F0; INCLUDE_ASM(s32, "code_109660_len_1270", func_802E7F6C); +/*void func_802E7F6C(Entity* entity) { + struct802E7F40* temp = entity->dataBuf; + + temp->unk_0C = entity->position.y; + func_802E7DE0(entity, &D_0A004350, &D_0A0026F0); +}*/ INCLUDE_ASM(s32, "code_109660_len_1270", func_802E7FA0); INCLUDE_ASM(s32, "code_109660_len_1270", func_802E854C); +extern UNK_TYPE D_802EAE7C; +extern f64 D_802EB370; + INCLUDE_ASM(s32, "code_109660_len_1270", func_802E8858); +/*s32 func_802E8858(Entity* entity) { + PlayerStatus* playerStatus = &gPlayerStatus; + s32 phi_a0 = 0; + + if (entity->unk_06 & 1) { + if ((playerStatus->actionState == ActionState_GROUND_POUND) || (playerStatus->actionState == ActionState_ULTRA_POUND)) { + set_action_state(ActionState_FALLING); + phi_a0 = 1; + } + } + + if (phi_a0 != 0) { + func_802E7F6C(entity); + func_80110BCC(entity, &D_802EAE7C); + func_80110678(entity); + func_8010FD68(entity); + play_sound(0x20AE); + } +}*/ INCLUDE_ASM(s32, "code_109660_len_1270", func_802E88EC); @@ -23,48 +93,35 @@ INCLUDE_ASM(s32, "code_109660_len_1270", func_802E8A58); INCLUDE_ASM(s32, "code_109660_len_1270", func_802E8ADC); -// TODO: what is this struct? -typedef struct struct802E8BC0 { - /* 0x00 */ char unk_00[4]; - /* 0x04 */ s32 unk_04; - /* 0x08 */ char unk_08[4]; - /* 0x0C */ s32 unk_0C; -} struct802E8BC0; - -MapConfig* get_current_map_header(void); -void disable_player_input(void); -void disable_player_static_collisions(void); -void move_player(s32, f32, f32); - void func_802E8BC0(Entity* entity) { PlayerStatus* playerStatus = &gPlayerStatus; PlayerStatus* playerStatus2 = &gPlayerStatus; - struct802E8BC0* temp = (struct802E8BC0*)entity->dataBuf; + struct802E7DE0* temp = (struct802E7DE0*)entity->dataBuf; MapConfig* mapConfig = get_current_map_header(); f32 temp_f20; f32 entryX; f32 entryZ; - entryX = GET_MAP_ENTRY(mapConfig, temp->unk_0C)->x; - entryZ = GET_MAP_ENTRY(mapConfig, temp->unk_0C)->z; - temp->unk_04 = func_800E0088(entryX, entryZ) / playerStatus->runSpeed; - if (temp->unk_04 == 0) { - temp->unk_04 = 1; + entryX = GET_MAP_ENTRY(mapConfig, temp->unk_00C)->x; + entryZ = GET_MAP_ENTRY(mapConfig, temp->unk_00C)->z; + temp->unk_004 = func_800E0088(entryX, entryZ) / playerStatus->runSpeed; + if (temp->unk_004 == 0) { + temp->unk_004 = 1; } - entryX = GET_MAP_ENTRY(mapConfig, temp->unk_0C)->x; - entryZ = GET_MAP_ENTRY(mapConfig, temp->unk_0C)->z; + entryX = GET_MAP_ENTRY(mapConfig, temp->unk_00C)->x; + entryZ = GET_MAP_ENTRY(mapConfig, temp->unk_00C)->z; temp_f20 = atan2(playerStatus2->position.x, playerStatus2->position.z, entryX, entryZ); disable_player_input(); disable_player_static_collisions(); - move_player(temp->unk_04, temp_f20, playerStatus2->runSpeed); + move_player(temp->unk_004, temp_f20, playerStatus2->runSpeed); } void func_802E8C94(Entity* entity) { Trigger* trigger = (Trigger*)entity->dataBuf; // TODO: is Trigger correct? if (--trigger->params1.w == -1) { - func_8010FD68(); + func_8010FD68(entity); } } diff --git a/src/code_a5dd0_len_114e0.c b/src/code_a5dd0_len_114e0.c index 2a8479e85f..71698459bb 100644 --- a/src/code_a5dd0_len_114e0.c +++ b/src/code_a5dd0_len_114e0.c @@ -8,7 +8,7 @@ INCLUDE_ASM(s32, "code_a5dd0_len_114e0", func_8010FBC0); INCLUDE_ASM(s32, "code_a5dd0_len_114e0", func_8010FBD8); -INCLUDE_ASM(s32, "code_a5dd0_len_114e0", func_8010FD68); +INCLUDE_ASM(void, "code_a5dd0_len_114e0", func_8010FD68, Entity* entity); INCLUDE_ASM(s32, "code_a5dd0_len_114e0", func_8010FD98); diff --git a/src/si.c b/src/si.c index 884debba91..c86fae6af7 100644 --- a/src/si.c +++ b/src/si.c @@ -92,14 +92,12 @@ ApiStatus si_handle_sleep_frames(ScriptInstance* script) { script->blocked = 1; } - if (script->functionTemp[0].s) { - s32 todo = 1; // val can be anything - if (todo) { - script->functionTemp[0].s -= 1; - } - return !script->functionTemp[0].s; + if (script->functionTemp[0].s == 0) { + return ApiStatus_DONE2; } - return ApiStatus_DONE2; + + script->functionTemp[0].s -= 1; + return !script->functionTemp[0].s; } ApiStatus si_handle_sleep_seconds(ScriptInstance* script) { @@ -110,14 +108,12 @@ ApiStatus si_handle_sleep_seconds(ScriptInstance* script) { script->blocked = 1; } - if (script->functionTemp[0].s != 0) { - s32 todo = 1; // val can be anything - if (todo) { - script->functionTemp[0].s -= 1; - } - return !script->functionTemp[0].s; + if (script->functionTemp[0].s == 0) { + return ApiStatus_DONE2; } - return ApiStatus_DONE2; + + script->functionTemp[0].s -= 1; + return !script->functionTemp[0].s; } ApiStatus si_handle_if_equal(ScriptInstance* script) { @@ -248,6 +244,7 @@ ApiStatus si_handle_case_equal(ScriptInstance* script) { if (script->switchBlockState[switchDepth] <= 0) { script->ptrNextLine = si_goto_end_case(script); + return ApiStatus_DONE2; } else if (var != switchBlockValue) { script->ptrNextLine = si_goto_next_case(script); } else { @@ -255,7 +252,6 @@ ApiStatus si_handle_case_equal(ScriptInstance* script) { } return ApiStatus_DONE2; - do {} while (0); // Necessary to match } ApiStatus si_handle_case_not_equal(ScriptInstance* script) { @@ -271,6 +267,7 @@ ApiStatus si_handle_case_not_equal(ScriptInstance* script) { if (script->switchBlockState[switchDepth] <= 0) { script->ptrNextLine = si_goto_end_case(script); + return ApiStatus_DONE2; } else if (var == switchBlockValue) { script->ptrNextLine = si_goto_next_case(script); } else { @@ -278,7 +275,6 @@ ApiStatus si_handle_case_not_equal(ScriptInstance* script) { } return ApiStatus_DONE2; - do {} while (0); // Necessary to match } ApiStatus si_handle_case_less(ScriptInstance* script) { @@ -294,6 +290,7 @@ ApiStatus si_handle_case_less(ScriptInstance* script) { if (script->switchBlockState[switchDepth] <= 0) { script->ptrNextLine = si_goto_end_case(script); + return ApiStatus_DONE2; } else if (var <= switchBlockValue) { script->ptrNextLine = si_goto_next_case(script); } else { @@ -301,7 +298,6 @@ ApiStatus si_handle_case_less(ScriptInstance* script) { } return ApiStatus_DONE2; - do {} while (0); // Necessary to match } ApiStatus si_handle_case_less_equal(ScriptInstance* script) { @@ -317,6 +313,7 @@ ApiStatus si_handle_case_less_equal(ScriptInstance* script) { if (script->switchBlockState[switchDepth] <= 0) { script->ptrNextLine = si_goto_end_case(script); + return ApiStatus_DONE2; } else if (var < switchBlockValue) { script->ptrNextLine = si_goto_next_case(script); } else { @@ -324,7 +321,6 @@ ApiStatus si_handle_case_less_equal(ScriptInstance* script) { } return ApiStatus_DONE2; - do {} while (0); // Necessary to match } ApiStatus si_handle_case_greater(ScriptInstance* script) { @@ -340,6 +336,7 @@ ApiStatus si_handle_case_greater(ScriptInstance* script) { if (script->switchBlockState[switchDepth] <= 0) { script->ptrNextLine = si_goto_end_case(script); + return ApiStatus_DONE2; } else if (var >= switchBlockValue) { script->ptrNextLine = si_goto_next_case(script); } else { @@ -347,7 +344,6 @@ ApiStatus si_handle_case_greater(ScriptInstance* script) { } return ApiStatus_DONE2; - do {} while (0); // Necessary to match } ApiStatus si_handle_case_greater_equal(ScriptInstance* script) { @@ -363,6 +359,7 @@ ApiStatus si_handle_case_greater_equal(ScriptInstance* script) { if (script->switchBlockState[switchDepth] <= 0) { script->ptrNextLine = si_goto_end_case(script); + return ApiStatus_DONE2; } else if (var > switchBlockValue) { script->ptrNextLine = si_goto_next_case(script); } else { @@ -370,7 +367,6 @@ ApiStatus si_handle_case_greater_equal(ScriptInstance* script) { } return ApiStatus_DONE2; - do {} while (0); // Necessary to match } ApiStatus si_handle_case_range(ScriptInstance* script) { @@ -389,6 +385,7 @@ ApiStatus si_handle_case_range(ScriptInstance* script) { if (script->switchBlockState[switchDepth] <= 0) { script->ptrNextLine = si_goto_end_case(script); + return ApiStatus_DONE2; } else if ((var <= switchBlockValue) && (switchBlockValue <= var2)) { script->switchBlockState[switchDepth] = 0; } else { @@ -396,7 +393,6 @@ ApiStatus si_handle_case_range(ScriptInstance* script) { } return ApiStatus_DONE2; - do {} while (0); // Necessary to match } ApiStatus si_handle_case_else(ScriptInstance* script) { @@ -404,13 +400,14 @@ ApiStatus si_handle_case_else(ScriptInstance* script) { ASSERT(switchDepth >= 0); - if (script->switchBlockState[switchDepth] > 0) { - script->switchBlockState[switchDepth] = 0; - } else { + if (script->switchBlockState[switchDepth] <= 0) { script->ptrNextLine = si_goto_end_case(script); + return ApiStatus_DONE2; + } else { + script->switchBlockState[switchDepth] = 0; } + return ApiStatus_DONE2; - do {} while (0); // Necessary to match } ApiStatus si_handle_case_flag(ScriptInstance* script) { @@ -428,6 +425,7 @@ ApiStatus si_handle_case_flag(ScriptInstance* script) { if (switchBlockState <= 0) { script->ptrNextLine = si_goto_end_case(script); + return ApiStatus_DONE2; } else if ((var & switchBlockValue) == 0) { script->ptrNextLine = si_goto_next_case(script); } else { @@ -435,7 +433,6 @@ ApiStatus si_handle_case_flag(ScriptInstance* script) { } return ApiStatus_DONE2; - do {} while (0); // Necessary to match } ApiStatus si_handle_case_multi_or_equal(ScriptInstance* script) { @@ -453,6 +450,7 @@ ApiStatus si_handle_case_multi_or_equal(ScriptInstance* script) { if (switchBlockState == 0) { script->ptrNextLine = si_goto_end_case(script); + return ApiStatus_DONE2; } else if (var == switchBlockValue) { script->switchBlockState[switchDepth] = -1; } else if (switchBlockState != -1) { @@ -460,7 +458,6 @@ ApiStatus si_handle_case_multi_or_equal(ScriptInstance* script) { } return ApiStatus_DONE2; - do {} while (0); // Necessary to match } ApiStatus si_handle_case_multi_and_equal(ScriptInstance* script) { @@ -478,6 +475,7 @@ ApiStatus si_handle_case_multi_and_equal(ScriptInstance* script) { if (switchBlockState == 0) { script->ptrNextLine = si_goto_end_case(script); + return ApiStatus_DONE2; } else if (switchBlockState == -2) { script->ptrNextLine = si_goto_next_case(script); } else if (var == switchBlockValue) { @@ -488,7 +486,6 @@ ApiStatus si_handle_case_multi_and_equal(ScriptInstance* script) { } return ApiStatus_DONE2; - do {} while (0); // Necessary to match } ApiStatus si_handle_end_case_multi(ScriptInstance* script) { @@ -496,6 +493,7 @@ ApiStatus si_handle_end_case_multi(ScriptInstance* script) { if (script->switchBlockState[script->switchDepth] == 0) { script->ptrNextLine = si_goto_end_case(script); + return ApiStatus_DONE2; } else if (script->switchBlockState[script->switchDepth] != -1) { script->switchBlockState[script->switchDepth] = 1; script->ptrNextLine = si_goto_next_case(script); @@ -505,8 +503,6 @@ ApiStatus si_handle_end_case_multi(ScriptInstance* script) { } return ApiStatus_DONE2; - - do {} while (0); // Necessary to match } ApiStatus si_handle_break_match(ScriptInstance* script) {