diff --git a/config/rel_slices.yml b/config/rel_slices.yml index 00ee8d5d..c493b646 100644 --- a/config/rel_slices.yml +++ b/config/rel_slices.yml @@ -383,6 +383,11 @@ ac_animal_logo.c: .data: [0x8065FB68, 0x8065FBA8] ac_animal_logo_misc.c: .text: [0x804117D4, 0x80411A60] +ac_ball.c: + .text: [0x80411F64, 0x80413DD4] + .rodata: [0x80643A90,0x80643B60] + .data: [0x8065FBF8, 0x8065FC58] + .bss: [0x812F96E0, 0x812F96E8] ac_boat_demo.c: .text: [0x80414EC4, 0x80415BD8] .rodata: [0x80643B98, 0x80643BA0] diff --git a/include/ac_ball.h b/include/ac_ball.h index b57b7c3f..75bcdd4d 100644 --- a/include/ac_ball.h +++ b/include/ac_ball.h @@ -8,6 +8,30 @@ extern "C" { #endif +typedef void (*BALL_PROCESS_PROC)(ACTOR*, GAME*); + +typedef struct actor_ball_s { + ACTOR actor_class; + ClObjPipe_c ball_pipe; + u8 pad[0x40]; + xyz_t bgpos; + ACTOR* collider; + BALL_PROCESS_PROC process_proc; + int unk1E4; + f32 ball_y; + f32 ball_max_speed; + f32 ball_acceleration; + f32 ball_speed; + int type; + s16 timer; + s16 unk1FE; + s_xyz angle; + s16 unk206; + s16 unk208; + s16 unk20A; + s16 unk20C; +} BALL_ACTOR; + extern ACTOR_PROFILE Ball_Profile; #ifdef __cplusplus diff --git a/include/ac_gyoei_h.h b/include/ac_gyoei_h.h index 2b5a575e..9ac84f3d 100644 --- a/include/ac_gyoei_h.h +++ b/include/ac_gyoei_h.h @@ -19,7 +19,7 @@ typedef struct gyoei_init_s { typedef int (*aGYO_make_proc)(aGYO_Init_c*); typedef void (*aGYO_dt_proc)(ACTOR*, GAME*); -typedef void (*aGYO_ballcheck_proc)(xyz_t*, s16); +typedef void (*aGYO_ballcheck_proc)(xyz_t*, f32, s16); typedef void (*aGYO_hitcheck_proc)(xyz_t*, s16); typedef int (*aGYO_chk_live_proc)(int, int, GAME*); typedef int (*aGYO_search_near_proc)(f32, f32); diff --git a/include/libc64/qrand.h b/include/libc64/qrand.h index 03d5403a..e7df8901 100644 --- a/include/libc64/qrand.h +++ b/include/libc64/qrand.h @@ -6,6 +6,6 @@ u32 qrand(void); void sqrand(u32); f32 fqrand(void); -f64 fqrand2(void); +f32 fqrand2(void); #endif \ No newline at end of file diff --git a/include/m_collision_obj.h b/include/m_collision_obj.h index 4e9c1145..af9b96ab 100644 --- a/include/m_collision_obj.h +++ b/include/m_collision_obj.h @@ -161,60 +161,60 @@ typedef struct mco_work_s { extern McoWork mco_work; -typedef void (*CollisionOCFunction)(GAME_PLAY*, CollisionCheck_c*, ClObj_c*,ClObj_c*); -typedef int (*CollisionOCClear)(GAME_PLAY*, ClObj_c*); -typedef int (*CollisionClearFunction)(GAME_PLAY*, ClObj_c*); +typedef void (*CollisionOCFunction)(GAME*, CollisionCheck_c*, ClObj_c*,ClObj_c*); +typedef int (*CollisionOCClear)(GAME*, ClObj_c*); +typedef int (*CollisionClearFunction)(GAME*, ClObj_c*); extern void CollisionCheck_workTrisElemCenter(ClObjTrisElem_c *, xyz_t *); -extern int ClObj_ct(GAME_PLAY *, ClObj_c *); -extern int ClObj_dt(GAME_PLAY *, ClObj_c *); -extern int ClObj_set4(GAME_PLAY *, ClObj_c *, ACTOR *, ClObjData_c *); -extern void ClObj_OCClear(GAME_PLAY *, ClObj_c *); +extern int ClObj_ct(GAME *, ClObj_c *); +extern int ClObj_dt(GAME *, ClObj_c *); +extern int ClObj_set4(GAME *, ClObj_c *, ACTOR *, ClObjData_c *); +extern void ClObj_OCClear(GAME *, ClObj_c *); extern int ClObjElem_ct(ClObjElem_c *); extern int ClObjElem_set(ClObjElem_c *, ClObjElemData_c *); -extern void ClObjElem_OCClear(GAME_PLAY *, ClObjElem_c *); -extern int ClObjJntSphElem_OCClear(GAME_PLAY *, ClObjJntSphElem_c *); -extern int ClObjJntSph_OCClear(GAME_PLAY *, ClObj_c *); -extern int ClObjPipeAttr_ct(GAME_PLAY *, ClObjPipeAttr_c *); -extern int ClObjPipeAttr_dt(GAME_PLAY *, ClObjPipeAttr_c *); -extern int ClObjPipeAttr_set(GAME_PLAY *, ClObjPipeAttr_c *, ClObjPipeAttr_c *); -extern int ClObjPipe_ct(GAME_PLAY *, ClObjPipe_c *); -extern int ClObjPipe_dt(GAME_PLAY *, ClObjPipe_c *); -extern int ClObjPipe_set5(GAME_PLAY *, ClObjPipe_c *, ACTOR *, ClObjPipeData_c *); -extern int ClObjPipe_OCClear(GAME_PLAY *, ClObj_c *); -extern int ClObjTrisElemAttr_ct(GAME_PLAY *, ClObjTrisElemAttr_c *); -extern int ClObjTrisElemAttr_dt(GAME_PLAY *, ClObjTrisElemAttr_c *); -extern int ClObjTrisElemAttr_set(GAME_PLAY *, ClObjTrisElemAttr_c *, ClObjTrisElemAttrData_c *); -extern int ClObjTrisElem_ct(GAME_PLAY *, ClObjTrisElem_c *); -extern int ClObjTrisElem_dt(GAME_PLAY *, ClObjTrisElem_c *); -extern int ClObjTrisElem_set(GAME_PLAY *, ClObjTrisElem_c *, ClObjTrisElemData_c *); -extern int ClObjTrisElem_OCClear(GAME_PLAY *, ClObjTrisElem_c *); -extern int ClObjTris_ct(GAME_PLAY *, ClObjTris_c *); -extern int ClObjTris_dt_nzf(GAME_PLAY *, ClObjTris_c *); -extern int ClObjTris_set5_nzm(GAME_PLAY *, ClObjTris_c *, ACTOR *, ClObjTrisData_c *, ClObjTrisElem_c *); -extern int ClObjTris_OCClear(GAME_PLAY *, ClObj_c *); -extern void CollisionCheck_ct(GAME_PLAY *, CollisionCheck_c *); -extern void CollisionCheck_dt(GAME_PLAY *, CollisionCheck_c *); -extern void CollisionCheck_clear(GAME_PLAY *, CollisionCheck_c *); -extern int CollisionCheck_setOC(GAME_PLAY *, CollisionCheck_c *, ClObj_c *); +extern void ClObjElem_OCClear(GAME *, ClObjElem_c *); +extern int ClObjJntSphElem_OCClear(GAME *, ClObjJntSphElem_c *); +extern int ClObjJntSph_OCClear(GAME *, ClObj_c *); +extern int ClObjPipeAttr_ct(GAME *, ClObjPipeAttr_c *); +extern int ClObjPipeAttr_dt(GAME *, ClObjPipeAttr_c *); +extern int ClObjPipeAttr_set(GAME *, ClObjPipeAttr_c *, ClObjPipeAttr_c *); +extern int ClObjPipe_ct(GAME *, ClObjPipe_c *); +extern int ClObjPipe_dt(GAME *, ClObjPipe_c *); +extern int ClObjPipe_set5(GAME *, ClObjPipe_c *, ACTOR *, ClObjPipeData_c *); +extern int ClObjPipe_OCClear(GAME *, ClObj_c *); +extern int ClObjTrisElemAttr_ct(GAME *, ClObjTrisElemAttr_c *); +extern int ClObjTrisElemAttr_dt(GAME *, ClObjTrisElemAttr_c *); +extern int ClObjTrisElemAttr_set(GAME *, ClObjTrisElemAttr_c *, ClObjTrisElemAttrData_c *); +extern int ClObjTrisElem_ct(GAME *, ClObjTrisElem_c *); +extern int ClObjTrisElem_dt(GAME *, ClObjTrisElem_c *); +extern int ClObjTrisElem_set(GAME *, ClObjTrisElem_c *, ClObjTrisElemData_c *); +extern int ClObjTrisElem_OCClear(GAME *, ClObjTrisElem_c *); +extern int ClObjTris_ct(GAME *, ClObjTris_c *); +extern int ClObjTris_dt_nzf(GAME *, ClObjTris_c *); +extern int ClObjTris_set5_nzm(GAME *, ClObjTris_c *, ACTOR *, ClObjTrisData_c *, ClObjTrisElem_c *); +extern int ClObjTris_OCClear(GAME *, ClObj_c *); +extern void CollisionCheck_ct(GAME *, CollisionCheck_c *); +extern void CollisionCheck_dt(GAME *, CollisionCheck_c *); +extern void CollisionCheck_clear(GAME *, CollisionCheck_c *); +extern int CollisionCheck_setOC(GAME *, CollisionCheck_c *, ClObj_c *); extern int get_type(u8); extern void CollisionCheck_setOC_HitInfo(ClObj_c *, ClObjElem_c *, xyz_t *, ClObj_c *, ClObjElem_c *, xyz_t *, f32); -extern void CollisionCheck_OC_JntSph_Vs_JntSph(GAME_PLAY *, CollisionCheck_c *, ClObj_c *, ClObj_c *); -extern void CollisionCheck_OC_JntSph_Vs_Pipe(GAME_PLAY *, CollisionCheck_c *, ClObj_c *, ClObj_c *); -extern void CollisionCheck_OC_Pipe_Vs_JntSph(GAME_PLAY *, CollisionCheck_c *, ClObj_c *, ClObj_c *); -extern void CollisionCheck_OC_Pipe_Vs_Pipe(GAME_PLAY *, CollisionCheck_c *, ClObj_c *, ClObj_c *); +extern void CollisionCheck_OC_JntSph_Vs_JntSph(GAME *, CollisionCheck_c *, ClObj_c *, ClObj_c *); +extern void CollisionCheck_OC_JntSph_Vs_Pipe(GAME *, CollisionCheck_c *, ClObj_c *, ClObj_c *); +extern void CollisionCheck_OC_Pipe_Vs_JntSph(GAME *, CollisionCheck_c *, ClObj_c *, ClObj_c *); +extern void CollisionCheck_OC_Pipe_Vs_Pipe(GAME *, CollisionCheck_c *, ClObj_c *, ClObj_c *); extern int CollisionCheck_Check1ClObjNoOC(ClObj_c *); extern int CollisionCheck_Check2ClObjNoOC(ClObj_c *, ClObj_c *); -extern void CollisionCheck_OC(GAME_PLAY *, CollisionCheck_c *); -extern void CollisionCheck_setOCC_HitInfo(GAME_PLAY *, ClObj_c *, ClObjTrisElem_c *, xyz_t *, ClObj_c *, ClObjElem_c *, xyz_t *, xyz_t *); -extern void CollisionCheck_OCC_Tris_Vs_JntSph(GAME_PLAY *, CollisionCheck_c *, ClObjTris_c *, ClObjJntSph_c *); -extern void CollisionCheck_OCC_Tris_Vs_Pipe(GAME_PLAY *, CollisionCheck_c *, ClObjTris_c *, ClObjPipe_c *); +extern void CollisionCheck_OC(GAME *, CollisionCheck_c *); +extern void CollisionCheck_setOCC_HitInfo(GAME *, ClObj_c *, ClObjTrisElem_c *, xyz_t *, ClObj_c *, ClObjElem_c *, xyz_t *, xyz_t *); +extern void CollisionCheck_OCC_Tris_Vs_JntSph(GAME *, CollisionCheck_c *, ClObjTris_c *, ClObjJntSph_c *); +extern void CollisionCheck_OCC_Tris_Vs_Pipe(GAME *, CollisionCheck_c *, ClObjTris_c *, ClObjPipe_c *); extern int CollisionCheck_Check1ClObjNoOCC(ClObj_c *); -extern void CollisionCheck_OCC(GAME_PLAY *, CollisionCheck_c *); -extern int ClObjTrisElem_OCCClear(GAME_PLAY *, ClObjTrisElem_c *); -extern int ClObj_OCCClear(GAME_PLAY *, ClObj_c *); -extern int ClObjTris_OCCClear(GAME_PLAY *, ClObj_c *); -extern int CollisionCheck_setOCC(GAME_PLAY *, CollisionCheck_c *, ClObj_c *); +extern void CollisionCheck_OCC(GAME *, CollisionCheck_c *); +extern int ClObjTrisElem_OCCClear(GAME *, ClObjTrisElem_c *); +extern int ClObj_OCCClear(GAME *, ClObj_c *); +extern int ClObjTris_OCCClear(GAME *, ClObj_c *); +extern int CollisionCheck_setOCC(GAME *, CollisionCheck_c *, ClObj_c *); extern void CollisionCheck_Status_ct(Status_c *); extern void CollisionCheck_Status_Clear(Status_c *); extern void CollisionCheck_Status_set3(Status_c *, StatusData_c *); diff --git a/include/m_lib.h b/include/m_lib.h index 934c0297..dbc772be 100644 --- a/include/m_lib.h +++ b/include/m_lib.h @@ -21,6 +21,7 @@ extern "C" { #define SHT_MINV (1.0f / SHT_MAX) #define ABS(x) (((x) >= 0) ? (x) : -(x)) #define SQ(x) ((x)*(x)) +#define CLAMP_MAX(x, min) ((min) < (x) ? (min) : (x)) /* radians -> short angle */ #define RAD2SHORT_ANGLE(rad) ((s16)(int)((rad) * (65536.0f / (2.0f * F_PI)))) @@ -33,6 +34,8 @@ extern "C" { /* degrees -> short angle */ #define DEG2SHORT_ANGLE(deg) ((s16)((deg) * (65536.0f / 360.0f))) +#define DEG2SHORT_ANGLE2(deg) ((int)((deg) * (65536.0f / 360.0f))) + /* short angle -> degrees */ #define SHORT2DEG_ANGLE(s) ((((f32)(s)) / (65536.0f / 360.0f))) diff --git a/include/m_name_table.h b/include/m_name_table.h index fa4556b2..907783f0 100644 --- a/include/m_name_table.h +++ b/include/m_name_table.h @@ -1704,6 +1704,7 @@ extern int mNT_check_unknown(mActor_name_t item_no); #define ETC_START 0x8000 #define ETC_AIRPLANE ETC_START +#define ETC_BALL (ETC_START + 1) #define ETC_BOXTRICK (ETC_START + 4) #define ETC_BOXMANAGER (ETC_START + 5) #define ETC_SNOWMAN_BALL_A (ETC_START + 13) diff --git a/src/ac_ball.c b/src/ac_ball.c new file mode 100644 index 00000000..eb6b8e8d --- /dev/null +++ b/src/ac_ball.c @@ -0,0 +1,776 @@ +#include "ac_ball.h" +#include "m_actor_shadow.h" +#include "m_common_data.h" +#include "m_debug.h" +#include "m_field_info.h" +#include "m_lib.h" +#include "m_name_table.h" +#include "m_npc.h" +#include "m_player_lib.h" +#include "m_quest.h" +#include "m_random_field.h" +#include "m_roll_lib.h" +#include "sys_matrix.h" + +extern Gfx act_ball_b_model[]; +extern Gfx act_ball_d_model[]; +extern Gfx act_ball_s_model[]; + +Gfx* ball_model_tbl[] = { + act_ball_b_model, + act_ball_d_model, + act_ball_s_model, +}; + +static void aBALL_actor_ct(ACTOR* actor, GAME* game); +static void aBALL_actor_dt(ACTOR* actor, GAME* game); +static void aBALL_actor_move(ACTOR* actor, GAME* game); +static void aBALL_actor_draw(ACTOR* actor, GAME* game); + +ACTOR_PROFILE Ball_Profile = { + mAc_PROFILE_BALL, + ACTOR_PART_BG, + ACTOR_STATE_NO_MOVE_WHILE_CULLED, + ETC_BALL, + ACTOR_OBJ_BANK_KEEP, + sizeof(BALL_ACTOR), + &aBALL_actor_ct, + &aBALL_actor_dt, + &aBALL_actor_move, + &aBALL_actor_draw, + NULL, +}; + +BALL_ACTOR* Global_Actor_p; + +ClObjPipeData_c aBALL_CoInfoData = { + {0x39, 0x20, ClObj_TYPE_PIPE}, // collision data + {1}, // element data + // Pipe specs + { + 13, // radius + 30, // height + -10, // offset + + {0, 0, 0}, // center + }, +}; + +StatusData_c aBALL_StatusData = { + 0, 13, 30, -10, 100, +}; + +void aBALL_process_ground_init(ACTOR*, GAME*); +void aBALL_process_air_water(ACTOR*, GAME*); +void aBALL_process_ground_water(ACTOR*, GAME*); +void aBALL_process_ground(ACTOR*, GAME*); +void aBALL_process_air(ACTOR*, GAME*); +void aBALL_process_air_water_init(ACTOR* actor, GAME*); +void aBALL_process_ground_water_init(ACTOR* actor, GAME*); + +int aBALL_Random_pos_set(xyz_t* pos) { + int x_max; + int z_max; + int random_x; + int random_z; + int ut_x; + int ut_z; + int i; + int j; + + x_max = mFI_GetBlockXMax(); + z_max = mFI_GetBlockZMax(); + + random_x = RANDOM_F(x_max); + random_z = RANDOM_F(z_max); + + for (i = 0; i < x_max; i++) { + for (j = 0; j < z_max; j++) { + if ((mFI_CheckBlockKind_OR(random_x, random_z, + mRF_BLOCKKIND_PLAYER | mRF_BLOCKKIND_SHOP | mRF_BLOCKKIND_STATION | + mRF_BLOCKKIND_POOL | mRF_BLOCKKIND_OCEAN | mRF_BLOCKKIND_ISLAND | + mRF_BLOCKKIND_OFFING) == 0) && + (mNpc_GetMakeUtNuminBlock_hard_area(&ut_x, &ut_z, random_x, random_z, 2)) == TRUE) { + mFI_BkandUtNum2CenterWpos(pos, random_x, random_z, ut_x, ut_z); + return TRUE; + } + + if (random_z == z_max - 1) { + random_z = 0; + } else { + random_z += 1; + } + } + + if (random_x == x_max - 1) { + random_x = 0; + } else { + random_x += 1; + } + } + return FALSE; +} + +void aBALL_actor_ct(ACTOR* actor, GAME* game) { + BALL_ACTOR* ball = (BALL_ACTOR*)actor; + GAME_PLAY* play = (GAME_PLAY*)game; + + Global_Actor_p = ball; + + if ((0.0f == Common_Get(ball_pos).x) && (0.0f == Common_Get(ball_pos).y) && (0.0f == Common_Get(ball_pos).z)) { + if (aBALL_Random_pos_set(&actor->world.position) == 0) { + actor->world.position = actor->home.position; + } + actor->world.position.y = mCoBG_GetBgY_AngleS_FromWpos(NULL, actor->world.position, 0.0f); + Common_Set(ball_type, RANDOM(3.0f)); + Common_Set(ball_pos, actor->world.position); + ball->type = Common_Get(ball_type); + } else { + actor->world.position = Common_Get(ball_pos); + ball->type = Common_Get(ball_type); + } + Common_Get(clip).ball_redma_proc = NULL; + Shape_Info_init(actor, 0.0f, &mAc_ActorShadowEllipse, 9.0f, 17.0f); + ClObjPipe_ct(game, &ball->ball_pipe); + ClObjPipe_set5(game, &ball->ball_pipe, actor, &aBALL_CoInfoData); + CollisionCheck_Status_set3(&actor->status_data, &aBALL_StatusData); + ball->unk206 = 3; + aBALL_process_ground_init(actor, game); + ball->collider = NULL; + actor->max_velocity_y = -20.0f; + actor->gravity = 0.3f; + actor->speed = 0.0f; + + ball->ball_max_speed = 0.0f; + ball->ball_acceleration = 0.06f; + ball->ball_speed = 0.0f; + + actor->scale.x = 0.01f; + actor->scale.y = 0.01f; + actor->scale.z = 0.01f; + + ball->angle.x = qrand(); + ball->angle.y = qrand(); + ball->angle.z = qrand(); + + ball->unk20A = 0; + ball->unk20C = 0; +} + +void aBALL_actor_dt(ACTOR* actor, GAME* game) { + BALL_ACTOR* ball = (BALL_ACTOR*)actor; + + if ((ball->unk208 & 1) || (ball->unk208 & 2) || (mRlib_Set_Position_Check(actor) == 0)) { + Common_Set(ball_pos, ZeroVec); + } else { + Common_Set(ball_pos, actor->world.position); + } + Common_Get(clip).ball_redma_proc = NULL; + ClObjPipe_dt(game, &ball->ball_pipe); +} + +void aBALL_position_move(BALL_ACTOR* actor) { + xyz_t pos; + s_xyz angle; + + pos = actor->actor_class.world.position; + + mCoBG_GetBgY_AngleS_FromWpos(&angle, pos, 0.0f); + + if ((actor->actor_class.bg_collision_check.result.on_ground) || + (actor->actor_class.bg_collision_check.result.is_in_water)) { + chase_f(&actor->actor_class.speed, actor->ball_max_speed, actor->ball_acceleration); + } + + if (!(actor->unk208 & 2)) { + mRlib_spdF_Angle_to_spdXZ(&actor->actor_class.position_speed, &actor->actor_class.speed, + &actor->actor_class.world.angle.y); + chase_f(&actor->actor_class.position_speed.y, actor->actor_class.max_velocity_y, actor->actor_class.gravity); + + mRlib_position_move_for_sloop(&actor->actor_class, &angle); + + if (actor->actor_class.world.position.z < 840.0f) { + actor->actor_class.world.position.z = 840.0f; + } + } +} + +void aBALL_BGcheck(BALL_ACTOR* actor) { + f32 speed_y; + s16 hit_angle; + s16 rot; + xyz_t pos_speed; + f32 sin; + f32 cos; + f32 speed; + f32 speed_factor; + f32 sincos; + + speed_y = actor->actor_class.position_speed.y; + + if (((actor->process_proc == aBALL_process_air_water) || (actor->process_proc == aBALL_process_ground_water)) || + (actor->actor_class.bg_collision_check.result.unit_attribute == 11 || + actor->actor_class.bg_collision_check.result.unit_attribute == 22)) { + mCoBG_BgCheckControll(&actor->bgpos, &actor->actor_class, 12.0f, -12.0f, 0, 1, 0); + + if ((actor->actor_class.bg_collision_check.result.unit_attribute == 11 || + actor->actor_class.bg_collision_check.result.unit_attribute == 22) && + (actor->actor_class.bg_collision_check.result.on_ground)) { + f32 bg_y = actor->bgpos.y; + + bg_y *= (0.1f + GETREG(TAKREG, 7) * 0.01f); + actor->actor_class.world.position.y += bg_y; + } + actor->actor_class.world.position.x += actor->bgpos.x; + actor->actor_class.world.position.z += actor->bgpos.z; + actor->actor_class.world.position.x += actor->bgpos.x; + actor->actor_class.world.position.z += actor->bgpos.z; + } else { + mCoBG_BgCheckControll(&actor->bgpos, &actor->actor_class, 12.0f, -12.0f, 0, 0, 0); + mRlib_Station_step_modify_to_wall(&actor->actor_class); + } + + if (((actor->process_proc == aBALL_process_air) || (actor->process_proc == aBALL_process_air_water)) && + actor->actor_class.bg_collision_check.result.on_ground) { + if (actor->unk206 < 3) { + actor->unk206++; + if (actor->actor_class.bg_collision_check.result.is_in_water) { + actor->actor_class.position_speed.y = 0.2f; + } else { + actor->actor_class.position_speed.y = 0.7f * -speed_y; + } + } + } + + if (actor->actor_class.bg_collision_check.result.hit_wall & 1) { + hit_angle = mRlib_Get_HitWallAngleY(&actor->actor_class); + rot = actor->actor_class.world.angle.y - (hit_angle + 0x8000); + if (ABS(rot) < 0x4000) { + pos_speed = actor->actor_class.position_speed; + sin = sin_s(hit_angle); + cos = cos_s(hit_angle); + sincos = sin * cos; + speed = -((pos_speed.z * cos) + (pos_speed.x * sin)); + speed_factor = (speed * 0.07f) + 1.2f; + if (speed > 1.0f) { + sAdo_OngenTrgStartSpeed(speed, 0x8026, &actor->actor_class.world.position); + } + + actor->actor_class.position_speed.z = + ((1.0f - (speed_factor * cos * cos)) * pos_speed.z) - (pos_speed.x * speed_factor * sincos); + actor->actor_class.position_speed.x = + (-pos_speed.z * speed_factor * sincos) + (pos_speed.x * (1.0f - (speed_factor * sin * sin))); + mRlib_spdXZ_to_spdF_Angle(&actor->actor_class.position_speed, &actor->actor_class.speed, + &actor->actor_class.world.angle.y); + } + } +} + +void aBALL_OBJcheck(BALL_ACTOR* actor, GAME*) { + int wade; + ACTOR* collided; + xyz_t pos_speed; + s16 angle; + f32 sin; + f32 cos; + f32 fact; + f32 colliderSpeed; + f32 collidedSpeed; + f32 abs; + f32 newSins; + f32 newCos; + f32 newSpeedX; + f32 newSpeedZ; + f32 newFact; + f32 speedFactor; + int speedAngle; + xyz_t collisionSpeed; + xyz_t collision; + + wade = mFI_GetPlayerWade(); + + if (actor->ball_pipe.collision_obj.collision_flags0 & 2) { + collided = actor->ball_pipe.collision_obj.collided_actor; + actor->ball_pipe.collision_obj.collision_flags0 &= ~2; + + if (mQst_CheckSoccerTarget(collided) != 0) { + mQst_NextSoccer(collided); + actor->actor_class.speed = 0.0f; + actor->actor_class.position_speed = ZeroVec; + } else if ((collided != NULL) && (!(actor->unk208 & 2)) && (wade != 1) && (wade != 2)) { + if (actor->collider != collided) { + pos_speed = collided->position_speed; + actor->collider = collided; + actor->unk20C = GETREG(TAKREG, 15) + 30; + angle = atans_table(actor->actor_class.world.position.z - collided->world.position.z, + actor->actor_class.world.position.x - collided->world.position.x); + sin = sin_s(angle); + cos = cos_s(angle); + colliderSpeed = + (sin * actor->actor_class.position_speed.x) + (cos * actor->actor_class.position_speed.z); + + fact = sqrtf((pos_speed.x * pos_speed.x) + (pos_speed.z * pos_speed.z)); + + xyz_t_mult_v(&pos_speed, ((24.0f / 180.0f) * fact) * 0.9f + 0.1f); + collidedSpeed = (sin * pos_speed.x) + (cos * pos_speed.z); + abs = ABS(colliderSpeed + collidedSpeed); + + newSins = abs * sin_s(angle); + newCos = abs * cos_s(angle); + + newSpeedX = actor->actor_class.position_speed.x + newSins; + newSpeedZ = actor->actor_class.position_speed.z + newCos; + + newFact = sqrtf((newSpeedX * newSpeedX) + (newSpeedZ * newSpeedZ)); + newFact = CLAMP_MAX(newFact, 11.0f); + + speedFactor = newFact / 11.0f; + if (actor->actor_class.bg_collision_check.result.on_ground) { + /* TODO: this is fakematch right? */ + if (!actor->actor_class.speed) { + f32 angle = ((speedFactor * 90.0f) + (speedFactor * 35.0f) * fqrand2()); + speedAngle = DEG2SHORT_ANGLE(angle); + + actor->actor_class.speed = cos_s(speedAngle) * newFact; + actor->actor_class.position_speed.y = sin_s(speedAngle) * newFact; + } else { + actor->actor_class.speed = newFact * 0.75f; + } + } else { + actor->actor_class.speed = newFact * 0.75f; + } + + actor->actor_class.world.angle.y = atans_table(newSpeedZ, newSpeedX); + actor->actor_class.speed *= 0.9f; + sAdo_OngenTrgStartSpeed(actor->actor_class.speed, 0x25, &actor->actor_class.world.position); + actor->unk20C = GETREG(TAKREG, 15) + 30; + } else { + collision = actor->actor_class.status_data.collision_vec; + + xyz_t_add(&actor->actor_class.position_speed, &collision, &collisionSpeed); + + if ((wade != 1) && (wade != 2)) { + actor->actor_class.speed = + sqrtf((collisionSpeed.x * collisionSpeed.x) + (collisionSpeed.z * collisionSpeed.z)); + actor->actor_class.speed = CLAMP_MAX(actor->actor_class.speed, 11.0f); + actor->actor_class.world.angle.y = atans_table(collisionSpeed.z, collisionSpeed.x); + } + } + + } else { + if (actor->unk20C <= 0) { + actor->collider = NULL; + } else { + actor->unk20C--; + } + } + } else { + if (actor->unk20C <= 0) { + actor->collider = NULL; + } else { + actor->unk20C--; + } + } +} + +void aBALL_House_Tree_Rev_Check(BALL_ACTOR* actor) { + if (mRlib_HeightGapCheck_And_ReversePos(&actor->actor_class) != 1) { + actor->unk208 |= 1; + Actor_delete(&actor->actor_class); + } +} + +void aBALL_process_air_init(ACTOR* actor, GAME* game) { + BALL_ACTOR* ball = (BALL_ACTOR*)actor; + + f32 angle; + + angle = mCoBG_GetBgY_AngleS_FromWpos(NULL, actor->world.position, 0.0f); + actor->shape_info.draw_shadow = 1; + + if ((ball->process_proc == aBALL_process_ground) && ((actor->world.position.y - angle) > 20.0f)) { + sAdo_OngenTrgStart(0x43D, &actor->world.position); + } + + ball->process_proc = aBALL_process_air; +} + +void aBALL_process_air(ACTOR* actor, GAME* game) { + BALL_ACTOR* ball = (BALL_ACTOR*)actor; + + ball->ball_acceleration = 0.0f; + add_calc0(&ball->ball_y, 0.5f, 100.0f); + actor->max_velocity_y = -20.0f; + actor->gravity = 0.3f; + ball->ball_speed = actor->speed; + if (actor->bg_collision_check.result.on_ground) { + if (actor->bg_collision_check.result.is_in_water) { + aBALL_process_ground_water_init(actor, game); + } else { + aBALL_process_ground_init(actor, game); + } + } else if (actor->bg_collision_check.result.is_in_water) { + aBALL_process_air_water_init(actor, game); + } +} + +void aBALL_process_ground_init(ACTOR* actor, GAME* game) { + BALL_ACTOR* ball = (BALL_ACTOR*)actor; + + actor->shape_info.draw_shadow = 1; + + if (actor->position_speed.y > 0.0f) { + ball->process_proc = aBALL_process_air; + } else { + ball->process_proc = aBALL_process_ground; + } +} + +void aBALL_process_ground(ACTOR* actor, GAME* game) { + BALL_ACTOR* ball = (BALL_ACTOR*)actor; + f32 temp; + xyz_t norm; + s16 angle_rate; + s16 angle; + f32 distance; + + f32 speed_x; + f32 speed_z; + s16 effect_type; + + mCoBG_GetBgNorm_FromWpos(&norm, actor->world.position); + + if (mRlib_Get_ground_norm_inHole(actor, &norm, &distance, &angle, &angle_rate, 1.0f) != 0) { + f32 dist; + f32 distance_add; + + distance_add = (distance - 40.0f) - 5.0f; + dist = 0.0f; + + if (distance_add < 0.0f) { + dist = distance_add; + } + + dist *= 25.0f; + add_calc(&ball->ball_y, dist, 0.5f, 200.0f, 5.0f); + actor->position_speed.x *= 0.83666f; + actor->position_speed.z *= 0.83666f; + if (distance < 1.0f) { + speed_x = ABS(actor->position_speed.x); + if (speed_x < 1.0f) { + speed_z = ABS(actor->position_speed.z); + if (speed_z < 1.0f) { + ball->unk208 |= 2; + ball->ball_pipe.attribute.pipe.height = 20; + ball->ball_pipe.attribute.pipe.radius = 18; + actor->status_data.weight = MASSTYPE_HEAVY; + actor->speed = 0.0f; + return; + } + } + } + } else { + mRlib_Get_norm_Clif(actor, &norm); + add_calc0(&ball->ball_y, 0.5f, 100.0f); + } + + if (!F32_IS_ZERO(norm.x) || !F32_IS_ZERO(norm.z)) { + if (Math3d_normalizeXyz_t(&norm)) { + actor->position_speed.x += 1.35f * norm.x; + actor->position_speed.z += 1.35f * norm.z; + mRlib_spdXZ_to_spdF_Angle(&actor->position_speed, &ball->ball_max_speed, &actor->world.angle.y); + ball->ball_max_speed = (ball->ball_max_speed < 8.0f) ? ball->ball_max_speed : 8.0f; + ball->ball_acceleration = 0.05f; + } + } else { + ball->ball_max_speed = 0.0f; + ball->ball_acceleration = 0.06f; + } + + actor->max_velocity_y = -20.0f; + actor->gravity = 0.3f; + ball->ball_speed = actor->speed; + + if ((actor->bg_collision_check.result.is_in_water) || (actor->bg_collision_check.result.unit_attribute) == 11) { + if (actor->bg_collision_check.result.on_ground != 0) { + aBALL_process_ground_water_init(actor, game); + } else { + ball->unk206 = 0; + aBALL_process_air_water_init(actor, game); + } + } else if (actor->bg_collision_check.result.on_ground == 0) { + ball->unk206 = 0; + aBALL_process_air_init(actor, game); + return; + } + + if (!(game->frame_counter & 7) && (actor->bg_collision_check.result.unit_attribute) == 9) { + if (actor->speed > 1.0f) { + if (actor->speed > 4.0f) { + effect_type = 1; + } else { + effect_type = 0; + } + + Common_Get(clip).effect_clip->effect_make_proc(0x33, actor->world.position, 1, actor->world.angle.y, game, + actor->npc_id, 0, effect_type); + } + } +} + +void aBALL_set_spd_relations_in_water(ACTOR* actor, GAME* game) { + static s16 angl_add_table[] = { + 0x100, + 0x400, + }; + BALL_ACTOR* ball = (BALL_ACTOR*)actor; + xyz_t pos_flow; + f32 height; + + s16 angle; + + int apply_angle; + + height = mCoBG_GetWaterHeight_File(actor->world.position, "ac_ball.c", 0x361); + add_calc0(&ball->ball_y, 0.5f, 100.0f); + mCoBG_GetWaterFlow(&pos_flow, actor->bg_collision_check.result.unit_attribute); + + angle = atans_table(pos_flow.z, pos_flow.x); + apply_angle = ABS((s16)(actor->world.angle.y - angle)); + + chase_angle(&actor->world.angle.y, angle, angl_add_table[apply_angle > 0x4000]); + + if (actor->world.position.y < height) { + actor->max_velocity_y = 1.0f; + } else { + actor->max_velocity_y = -1.0f; + } + + if (ball->timer < 0x20) { + if (!(game->frame_counter & 3) && (ball->timer < 0x10) || !(game->frame_counter & 7)) { + Common_Get(clip).effect_clip->effect_make_proc(0x45, actor->world.position, 1, actor->world.angle.y, game, + actor->npc_id, 1, 0); + } + ball->timer++; + } + + actor->gravity = 0.1f; + ball->ball_max_speed = 1.0f; + ball->ball_acceleration = 0.1f; +} + +void aBALL_process_air_water_init(ACTOR* actor, GAME*) { + BALL_ACTOR* ball = (BALL_ACTOR*)actor; + + actor->shape_info.draw_shadow = 0; + ball->process_proc = aBALL_process_air_water; +} + +void aBALL_process_air_water(ACTOR* actor, GAME* game) { + BALL_ACTOR* ball = (BALL_ACTOR*)actor; + GAME_PLAY* play = (GAME_PLAY*)game; + f32 ball_speed; + + aBALL_set_spd_relations_in_water(actor, game); + add_calc0(&ball->ball_y, 0.5f, 100.0f); + + ball_speed = ball->ball_speed; + ball_speed -= 0.5f; + if (ball_speed < 0.0f) { + ball_speed = 0.0f; + } + ball->ball_speed = ball_speed; + + if (Common_Get(clip).gyo_clip != NULL) { + Common_Get(clip).gyo_clip->ballcheck_gyoei_proc(&actor->world.position, 20.0f, 1); + } + if (actor->bg_collision_check.result.on_ground) { + if (actor->bg_collision_check.result.is_in_water) { + aBALL_process_ground_water_init(actor, game); + } else if (actor->bg_collision_check.result.unit_attribute != 11) { + aBALL_process_ground_init(actor, game); + } + } else if (!actor->bg_collision_check.result.is_in_water) { + aBALL_process_air_init(actor, game); + } +} + +void aBALL_process_ground_water_init(ACTOR* actor, GAME*) { + BALL_ACTOR* ball = (BALL_ACTOR*)actor; + + actor->shape_info.draw_shadow = 0; + ball->timer = 0; + ball->process_proc = aBALL_process_ground_water; +} + +void aBALL_process_ground_water(ACTOR* actor, GAME* game) { + BALL_ACTOR* ball = (BALL_ACTOR*)actor; + + u32 currentUT; + xyz_t* pos; + f32 height; + + currentUT = actor->bg_collision_check.result.unit_attribute; + aBALL_set_spd_relations_in_water(actor, game); + ball->ball_speed = actor->speed; + + if (Common_Get(clip).gyo_clip != NULL) { + Common_Get(clip).gyo_clip->ballcheck_gyoei_proc(&actor->world.position, 20.0f, 1); + } + + if (actor->bg_collision_check.result.on_ground) { + if (!(actor->bg_collision_check.result.is_in_water) && (currentUT != 11) && currentUT != 22) { + aBALL_process_ground_init(actor, game); + } + } else if (!ball->actor_class.bg_collision_check.result.is_in_water) { + aBALL_process_air_init(actor, game); + } else { + aBALL_process_air_water_init(actor, game); + } + + if (currentUT == 11 || currentUT == 22) { + pos = &ball->bgpos; + + actor->world.position.y += (0.5f * pos->y); + + if (currentUT == 22) { + height = ABS(pos->y); + + if (height < 1.0f) { + aBALL_process_ground_init(actor, game); + } + } + } +} + +void aBALL_calc_axis(ACTOR* actor) { + BALL_ACTOR* ball = (BALL_ACTOR*)actor; + s16 angle; + f32 speed_fact; + + angle = (actor->speed * 434.81952f); + + if (ball->process_proc == aBALL_process_air_water || ball->process_proc == aBALL_process_ground_water) { + speed_fact = ((-1.0f) - actor->position_speed.y) / (-2.0f); + angle *= sin_s(DEG2SHORT_ANGLE2(30.0f + (60.0f * speed_fact))); + } + + mRlib_Roll_Matrix_to_s_xyz(actor, &ball->angle, angle); +} + +int aBALL_player_angle_distance_check(ACTOR* actor, PLAYER_ACTOR* player) { + f32 distance; + s16 angle; + int abs_angle; + + distance = search_position_distance(&actor->world.position, &player->actor_class.world.position); + angle = player->actor_class.shape_info.rotation.y - + search_position_angleY(&player->actor_class.world.position, &actor->world.position); + + if (distance < 60.0f) { + abs_angle = ABS(angle); + + if (abs_angle < 0x2000) { + return 1; + } + } + + return 0; +} + +void aBALL_status_check(ACTOR* actor, GAME* game) { + BALL_ACTOR* ball = (BALL_ACTOR*)actor; + GAME_PLAY* play = (GAME_PLAY*)game; + PLAYER_ACTOR* player; + PLAYER_ACTOR* player2; + int i; + + if (ball->unk208 & 4) { + player = GET_PLAYER_ACTOR(play); + ball->unk208 &= ~4; + if (aBALL_player_angle_distance_check(actor, player) || F32_IS_ZERO(actor->speed)) { + actor->world.angle.y = player->actor_class.shape_info.rotation.y; + actor->speed = 2.0f; + actor->position_speed.y = 4.5f; + if (ball->unk208 & 2) { + ball->ball_pipe.attribute.pipe.height = 30; + ball->ball_pipe.attribute.pipe.radius = 13; + ball->unk208 &= ~2; + actor->status_data.weight = 0x64; + } + } + } + if (ball->unk208 & 8) { + ball->unk208 &= ~8; + if (!(ball->unk208 & 2)) { + player2 = GET_PLAYER_ACTOR(play); + if (aBALL_player_angle_distance_check(actor, player2) || F32_IS_ZERO(actor->speed)) { + actor->world.angle.y = player2->actor_class.shape_info.rotation.y + 0x2000; + actor->speed = 4.5f; + actor->position_speed.y = 3.0f; + } + } + } + + if (!(ball->unk208 & 1)) { + if (actor->bg_collision_check.result.is_in_water) { + sAdo_OngenTrgStart(0x27, &actor->world.position); + ball->unk208 |= 1; + if (Common_Get(clip).gyo_clip != NULL) { + Common_Get(clip).gyo_clip->ballcheck_gyoei_proc(&actor->world.position, 20.0f, 0); + } + ball->ball_pipe.attribute.pipe.height = 10; + Common_Get(clip).effect_clip->effect_make_proc(0x3A, actor->world.position, 1, 0, game, actor->npc_id, 1, + 0); + + for (i = 2; i < 6; i++) { + Common_Get(clip).effect_clip->effect_make_proc(0x3B, actor->world.position, 1, actor->world.angle.y, + game, actor->npc_id, 0, i | FTR1_START); + } + } + } +} + +void aBALL_actor_move(ACTOR* actor, GAME* game) { + BALL_ACTOR* ball = (BALL_ACTOR*)actor; + GAME_PLAY* play = (GAME_PLAY*)game; + + aBALL_House_Tree_Rev_Check(ball); + + if (!(actor->state_bitfield & 0x40)) { + if (actor->bg_collision_check.result.is_in_water || (ball->unk208 & 2)) { + Actor_delete(actor); + } + if (actor->speed == 0.0f) { + return; + } + } + Common_Set(ball_pos, actor->world.position); + aBALL_position_move(ball); + ball->process_proc(actor, game); + aBALL_BGcheck(ball); + aBALL_OBJcheck(ball, game); + + CollisionCheck_Uty_ActorWorldPosSetPipeC(&ball->actor_class, &ball->ball_pipe); + CollisionCheck_setOC(game, &play->collision_check, &ball->ball_pipe.collision_obj); + aBALL_calc_axis(actor); + aBALL_status_check(actor, game); +} + +void aBALL_actor_draw(ACTOR* actor, GAME* game) { + BALL_ACTOR* ball = (BALL_ACTOR*)actor; + GRAPH* graph; + Gfx* gfx; + + graph = game->graph; + + OPEN_DISP(graph); + gfx = NOW_POLY_OPA_DISP; + Matrix_translate(0.0f, ball->ball_y, 0.0f, 1); + Matrix_rotateXYZ(ball->angle.x, ball->angle.y, ball->angle.z, 1); + gDPPipeSync(gfx++); + gSPMatrix(gfx++, _Matrix_to_Mtx_new(graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(gfx++, ball_model_tbl[ball->type]); + NOW_POLY_OPA_DISP = gfx; + CLOSE_DISP(graph); +} diff --git a/src/ac_haniwa.c b/src/ac_haniwa.c index 6ab7e0bf..d5045fc8 100644 --- a/src/ac_haniwa.c +++ b/src/ac_haniwa.c @@ -68,8 +68,8 @@ static void aHNW_actor_ct(ACTOR* actor, GAME* game) { cKF_SkeletonInfo_R_ct(keyframe, &cKF_bs_r_hnw, NULL, haniwa->keyframe_work_area, haniwa->keyframe_morph_area); pipe = &haniwa->col_pipe; - ClObjPipe_ct((GAME_PLAY*)game, pipe); - ClObjPipe_set5((GAME_PLAY*)game, pipe, actor, &AcHaniwaCoInfoData); + ClObjPipe_ct(game, pipe); + ClObjPipe_set5(game, pipe, actor, &AcHaniwaCoInfoData); CollisionCheck_Status_set3(&haniwa->actor_class.status_data, &AcHaniwaStatusData); { @@ -91,7 +91,7 @@ static void aHNW_actor_dt(ACTOR* actor, GAME* game) { } cKF_SkeletonInfo_R_dt(&haniwa->keyframe); - ClObjPipe_dt(play, &haniwa->col_pipe); + ClObjPipe_dt(game, &haniwa->col_pipe); } #include "../src/ac_haniwa_move.c_inc" diff --git a/src/ac_haniwa_move.c_inc b/src/ac_haniwa_move.c_inc index 29532144..626e9c6b 100644 --- a/src/ac_haniwa_move.c_inc +++ b/src/ac_haniwa_move.c_inc @@ -804,7 +804,7 @@ static void aHNW_actor_move(ACTOR* actor, GAME* game) { (*haniwa->action_proc)((ACTOR*)haniwa, game); aHNW_common_process(actor, game); CollisionCheck_Uty_ActorWorldPosSetPipeC(actor, &haniwa->col_pipe); - CollisionCheck_setOC(play, &play->collision_check, &haniwa->col_pipe.collision_obj); + CollisionCheck_setOC(game, &play->collision_check, &haniwa->col_pipe.collision_obj); Actor_world_to_eye(actor, 50.0f); } diff --git a/src/ac_sample.c b/src/ac_sample.c index a415cb91..d4516499 100644 --- a/src/ac_sample.c +++ b/src/ac_sample.c @@ -24,15 +24,15 @@ static ClObjPipeData_c Ac_Sample_OcInfoData_forStand = { static void Ac_Sample_ct_forCorect(ACTOR* actor, GAME* game) { GAME_PLAY* play = (GAME_PLAY*)game; SAMPLE_ACTOR* sample = (SAMPLE_ACTOR*)actor; - ClObjPipe_ct(play, &sample->stand); - ClObjPipe_set5(play, &sample->stand, (ACTOR*)actor, &Ac_Sample_OcInfoData_forStand); + ClObjPipe_ct(game, &sample->stand); + ClObjPipe_set5(game, &sample->stand, (ACTOR*)actor, &Ac_Sample_OcInfoData_forStand); } static void Ac_Sample_Excute_Corect(SAMPLE_ACTOR* actor, GAME_PLAY* play) { ClObjPipe_c* stand = &actor->stand; CollisionCheck_Uty_ActorWorldPosSetPipeC((ACTOR*)actor, stand); - CollisionCheck_setOC(play, &play->collision_check, (ClObj_c*)stand); + CollisionCheck_setOC(&play->game, &play->collision_check, (ClObj_c*)stand); } static void Ac_Sample_Actor_dt(ACTOR* actor, GAME* game) { @@ -43,7 +43,7 @@ static void Ac_Sample_Actor_dt(ACTOR* actor, GAME* game) { } cKF_SkeletonInfo_R_dt(keyframe); - ClObjPipe_dt((GAME_PLAY*)game, &sample->stand); + ClObjPipe_dt(game, &sample->stand); } static void Ac_Sample_Animation_Base(SAMPLE_ACTOR* actor) { diff --git a/src/m_collision_obj.c b/src/m_collision_obj.c index 2cea60e9..be366b83 100644 --- a/src/m_collision_obj.c +++ b/src/m_collision_obj.c @@ -16,7 +16,7 @@ void CollisionCheck_workTrisElemCenter(ClObjTrisElem_c* tri, xyz_t* vec) (1.0f / 3.0f); } -int ClObj_ct(GAME_PLAY* play, ClObj_c* cl) +int ClObj_ct(GAME* game, ClObj_c* cl) { static ClObj_c clobj_default = {NULL, NULL, 0, 0, 3}; @@ -25,12 +25,12 @@ int ClObj_ct(GAME_PLAY* play, ClObj_c* cl) return 1; } -int ClObj_dt(GAME_PLAY*, ClObj_c*) +int ClObj_dt(GAME*, ClObj_c*) { return 1; } -int ClObj_set4(GAME_PLAY*, ClObj_c* cl, ACTOR* actor, ClObjData_c* data) +int ClObj_set4(GAME*, ClObj_c* cl, ACTOR* actor, ClObjData_c* data) { cl->owner_actor = actor; @@ -41,7 +41,7 @@ int ClObj_set4(GAME_PLAY*, ClObj_c* cl, ACTOR* actor, ClObjData_c* data) return 1; } -void ClObj_OCClear(GAME_PLAY *, ClObj_c* cl) +void ClObj_OCClear(GAME *, ClObj_c* cl) { cl->collision_flags0 &= ~2; @@ -65,37 +65,37 @@ int ClObjElem_set(ClObjElem_c* elem, ClObjElemData_c* data) return 1; } -void ClObjElem_OCClear(GAME_PLAY*, ClObjElem_c* elem) +void ClObjElem_OCClear(GAME*, ClObjElem_c* elem) { elem->flags &= ~2; } -int ClObjJntSphElem_OCClear(GAME_PLAY* play, ClObjJntSphElem_c* col) +int ClObjJntSphElem_OCClear(GAME* game, ClObjJntSphElem_c* col) { - - ClObjElem_OCClear(play, &col->element); + GAME_PLAY* play = (GAME_PLAY*)game; + ClObjElem_OCClear(game, &col->element); return 1; } -int ClObjJntSph_OCClear(GAME_PLAY* play, ClObj_c* cl) +int ClObjJntSph_OCClear(GAME* game, ClObj_c* cl) { - + GAME_PLAY* play = (GAME_PLAY*)game; ClObjJntSph_c* jntsph = (ClObjJntSph_c*)cl; ClObjJntSphElem_c* elem; - ClObj_OCClear(play, &jntsph->collision_obj); + ClObj_OCClear(game, &jntsph->collision_obj); for (elem = jntsph->elements; elem < &jntsph->elements[jntsph->count]; elem++) { - ClObjJntSphElem_OCClear(play, elem); + ClObjJntSphElem_OCClear(game, elem); } return 1; } -int ClObjPipeAttr_ct(GAME_PLAY* play, ClObjPipeAttr_c* attribute) +int ClObjPipeAttr_ct(GAME* game, ClObjPipeAttr_c* attribute) { static ClObjPipeAttr_c default_pipe_attr = {0, 0, 0}; @@ -105,13 +105,13 @@ int ClObjPipeAttr_ct(GAME_PLAY* play, ClObjPipeAttr_c* attribute) return 1; } -int ClObjPipeAttr_dt(GAME_PLAY*, ClObjPipeAttr_c*) +int ClObjPipeAttr_dt(GAME*, ClObjPipeAttr_c*) { return 1; } -int ClObjPipeAttr_set(GAME_PLAY* play, ClObjPipeAttr_c* dst, ClObjPipeAttr_c* src) +int ClObjPipeAttr_set(GAME* game, ClObjPipeAttr_c* dst, ClObjPipeAttr_c* src) { *dst = *src; @@ -119,47 +119,47 @@ int ClObjPipeAttr_set(GAME_PLAY* play, ClObjPipeAttr_c* dst, ClObjPipeAttr_c* sr return 1; } -int ClObjPipe_ct(GAME_PLAY* play, ClObjPipe_c* pipe) +int ClObjPipe_ct(GAME* game, ClObjPipe_c* pipe) { - - ClObj_ct(play, &pipe->collision_obj); + GAME_PLAY* play = (GAME_PLAY*)game; + ClObj_ct(game, &pipe->collision_obj); ClObjElem_ct(&pipe->element); - ClObjPipeAttr_ct(play, &pipe->attribute); + ClObjPipeAttr_ct(game, &pipe->attribute); return 1; } -int ClObjPipe_dt(GAME_PLAY* play, ClObjPipe_c* pipe) +int ClObjPipe_dt(GAME* game, ClObjPipe_c* pipe) { - - ClObj_dt(play, &pipe->collision_obj); - ClObjPipeAttr_dt(play, &pipe->attribute); + GAME_PLAY* play = (GAME_PLAY*)game; + ClObj_dt(game, &pipe->collision_obj); + ClObjPipeAttr_dt(game, &pipe->attribute); return 1; } -int ClObjPipe_set5(GAME_PLAY* play, ClObjPipe_c* pipe, ACTOR* owner, ClObjPipeData_c* data) +int ClObjPipe_set5(GAME* game, ClObjPipe_c* pipe, ACTOR* owner, ClObjPipeData_c* data) { - - ClObj_set4(play, &pipe->collision_obj, owner, &data->collision_data); + GAME_PLAY* play = (GAME_PLAY*)game; + ClObj_set4(game, &pipe->collision_obj, owner, &data->collision_data); ClObjElem_set(&pipe->element, &data->element_data); - ClObjPipeAttr_set(play, &pipe->attribute, (ClObjPipeAttr_c *)&data->attribute_data); + ClObjPipeAttr_set(game, &pipe->attribute, (ClObjPipeAttr_c *)&data->attribute_data); return 1; } -int ClObjPipe_OCClear(GAME_PLAY* play, ClObj_c* cl) +int ClObjPipe_OCClear(GAME* game, ClObj_c* cl) { - + GAME_PLAY* play = (GAME_PLAY*)game; ClObjPipe_c* pipe = (ClObjPipe_c *)cl; - ClObj_OCClear(play, &pipe->collision_obj); - ClObjElem_OCClear(play, &pipe->element); + ClObj_OCClear(game, &pipe->collision_obj); + ClObjElem_OCClear(game, &pipe->element); return 1; } -int ClObjTrisElemAttr_ct(GAME_PLAY *play, ClObjTrisElemAttr_c *tris) +int ClObjTrisElemAttr_ct(GAME* game, ClObjTrisElemAttr_c *tris) { static ClObjTrisElemAttr_c default_clobjtriselem_attr = { @@ -170,13 +170,13 @@ int ClObjTrisElemAttr_ct(GAME_PLAY *play, ClObjTrisElemAttr_c *tris) return 1; } -int ClObjTrisElemAttr_dt(GAME_PLAY *play, ClObjTrisElemAttr_c *tris) +int ClObjTrisElemAttr_dt(GAME* game, ClObjTrisElemAttr_c *tris) { return 1; } -int ClObjTrisElemAttr_set(GAME_PLAY* play, ClObjTrisElemAttr_c* tris, ClObjTrisElemAttrData_c* data) +int ClObjTrisElemAttr_set(GAME* game, ClObjTrisElemAttr_c* tris, ClObjTrisElemAttrData_c* data) { xyz_t* dst; @@ -197,60 +197,60 @@ int ClObjTrisElemAttr_set(GAME_PLAY* play, ClObjTrisElemAttr_c* tris, ClObjTrisE return 1; } -int ClObjTrisElem_ct(GAME_PLAY* play, ClObjTrisElem_c* tris) +int ClObjTrisElem_ct(GAME* game, ClObjTrisElem_c* tris) { - + GAME_PLAY* play = (GAME_PLAY*)game; ClObjElem_ct(&tris->element); - ClObjTrisElemAttr_ct(play, &tris->attribute); + ClObjTrisElemAttr_ct(game, &tris->attribute); return 1; } -int ClObjTrisElem_dt(GAME_PLAY* play, ClObjTrisElem_c* tris) +int ClObjTrisElem_dt(GAME* game, ClObjTrisElem_c* tris) { - - ClObjTrisElemAttr_dt(play, &tris->attribute); + GAME_PLAY* play = (GAME_PLAY*)game; + ClObjTrisElemAttr_dt(game, &tris->attribute); return 1; } -int ClObjTrisElem_set(GAME_PLAY* play, ClObjTrisElem_c* tris, ClObjTrisElemData_c* data) +int ClObjTrisElem_set(GAME* game, ClObjTrisElem_c* tris, ClObjTrisElemData_c* data) { - + GAME_PLAY* play = (GAME_PLAY*)game; ClObjElem_set(&tris->element, &data->element); - ClObjTrisElemAttr_set(play, &tris->attribute, &data->data); + ClObjTrisElemAttr_set(game, &tris->attribute, &data->data); return 1; } -int ClObjTrisElem_OCClear(GAME_PLAY* play, ClObjTrisElem_c* tris) +int ClObjTrisElem_OCClear(GAME* game, ClObjTrisElem_c* tris) { - - ClObjElem_OCClear(play, &tris->element); + GAME_PLAY* play = (GAME_PLAY*)game; + ClObjElem_OCClear(game, &tris->element); return 1; } -int ClObjTris_ct(GAME_PLAY* play, ClObjTris_c* tris) +int ClObjTris_ct(GAME* game, ClObjTris_c* tris) { - - ClObj_ct(play, &tris->collision_obj); + GAME_PLAY* play = (GAME_PLAY*)game; + ClObj_ct(game, &tris->collision_obj); tris->count = 0; tris->elements = NULL; return 1; } -int ClObjTris_dt_nzf(GAME_PLAY *play, ClObjTris_c *tris) +int ClObjTris_dt_nzf(GAME* game, ClObjTris_c *tris) { - + GAME_PLAY* play = (GAME_PLAY*)game; ClObjTrisElem_c *element; - ClObj_dt(play, &tris->collision_obj); + ClObj_dt(game, &tris->collision_obj); for (element = tris->elements; element < &tris->elements[tris->count]; element++) { - ClObjTrisElem_dt(play, element); + ClObjTrisElem_dt(game, element); } tris->count = 0; tris->elements = NULL; @@ -258,14 +258,14 @@ int ClObjTris_dt_nzf(GAME_PLAY *play, ClObjTris_c *tris) return 1; } -int ClObjTris_set5_nzm(GAME_PLAY* play, ClObjTris_c* tris, ACTOR* actor, ClObjTrisData_c* data, +int ClObjTris_set5_nzm(GAME* game, ClObjTris_c* tris, ACTOR* actor, ClObjTrisData_c* data, ClObjTrisElem_c *elem) { - + GAME_PLAY* play = (GAME_PLAY*)game; ClObjTrisElem_c* element; ClObjTrisElemData_c* elementData; - ClObj_set4(play, &tris->collision_obj, actor, &data->data); + ClObj_set4(game, &tris->collision_obj, actor, &data->data); tris->count = data->count; tris->elements = elem; @@ -273,40 +273,42 @@ int ClObjTris_set5_nzm(GAME_PLAY* play, ClObjTris_c* tris, ACTOR* actor, ClObjTr for (element = tris->elements, elementData = data->elem_data; element < &tris->elements[tris->count]; element++, elementData++) { - ClObjTrisElem_ct(play, element); - ClObjTrisElem_set(play, element, elementData); + ClObjTrisElem_ct(game, element); + ClObjTrisElem_set(game, element, elementData); } return 1; } -int ClObjTris_OCClear(GAME_PLAY* play, ClObj_c* cl) +int ClObjTris_OCClear(GAME* game, ClObj_c* cl) { + GAME_PLAY* play = (GAME_PLAY*)game; ClObjTris_c* tris = (ClObjTris_c*)cl; ClObjTrisElem_c* element; - ClObj_OCClear(play, &tris->collision_obj); + + ClObj_OCClear(game, &tris->collision_obj); for (element = tris->elements; element < &tris->elements[tris->count]; element++) { - ClObjTrisElem_OCClear(play, element); + ClObjTrisElem_OCClear(game, element); } return 1; } -void CollisionCheck_ct(GAME_PLAY* play, CollisionCheck_c* col) +void CollisionCheck_ct(GAME* game, CollisionCheck_c* col) { - + GAME_PLAY* play = (GAME_PLAY*)game; col->flags = 0; - CollisionCheck_clear(play, col); + CollisionCheck_clear(game, col); } -void CollisionCheck_dt(GAME_PLAY* play, CollisionCheck_c* col) +void CollisionCheck_dt(GAME* game, CollisionCheck_c* col) { } -void CollisionCheck_clear(GAME_PLAY* play, CollisionCheck_c* col) +void CollisionCheck_clear(GAME* game, CollisionCheck_c* col) { ClObj_c** clp; @@ -350,9 +352,9 @@ CollisionOCClear OCCClearFunctionTable[ClObj_TYPE_NUM] = { NULL, NULL, ClObjTris_OCCClear}; -int CollisionCheck_setOC(GAME_PLAY* play, CollisionCheck_c* col, ClObj_c* cl) +int CollisionCheck_setOC(GAME* game, CollisionCheck_c* col, ClObj_c* cl) { - + GAME_PLAY* play = (GAME_PLAY*)game; int ret; if (_Game_play_isPause(play) == 1) @@ -361,7 +363,7 @@ int CollisionCheck_setOC(GAME_PLAY* play, CollisionCheck_c* col, ClObj_c* cl) } else { - OCClearFunctionTable[cl->collision_type](play, cl); + OCClearFunctionTable[cl->collision_type](game, cl); if ((cl->owner_actor != NULL) && (cl->owner_actor->mv_proc == NULL)) { @@ -553,7 +555,7 @@ void CollisionCheck_setOC_HitInfo(ClObj_c* col1, ClObjElem_c* colelem1, xyz_t* p } } -void CollisionCheck_OC_JntSph_Vs_JntSph(GAME_PLAY* play, CollisionCheck_c* check, ClObj_c* col1, +void CollisionCheck_OC_JntSph_Vs_JntSph(GAME* game, CollisionCheck_c* check, ClObj_c* col1, ClObj_c* col2) { @@ -599,7 +601,7 @@ void CollisionCheck_OC_JntSph_Vs_JntSph(GAME_PLAY* play, CollisionCheck_c* check } } -void CollisionCheck_OC_JntSph_Vs_Pipe(GAME_PLAY* play, CollisionCheck_c* check, ClObj_c* col1, +void CollisionCheck_OC_JntSph_Vs_Pipe(GAME* game, CollisionCheck_c* check, ClObj_c* col1, ClObj_c* col2) { @@ -639,14 +641,14 @@ void CollisionCheck_OC_JntSph_Vs_Pipe(GAME_PLAY* play, CollisionCheck_c* check, } } -void CollisionCheck_OC_Pipe_Vs_JntSph(GAME_PLAY* play, CollisionCheck_c* colcheck, ClObj_c* col1, +void CollisionCheck_OC_Pipe_Vs_JntSph(GAME* game, CollisionCheck_c* colcheck, ClObj_c* col1, ClObj_c* col2) { - - CollisionCheck_OC_JntSph_Vs_Pipe(play, colcheck, col2, col1); + GAME_PLAY* play = (GAME_PLAY*)game; + CollisionCheck_OC_JntSph_Vs_Pipe(game, colcheck, col2, col1); } -void CollisionCheck_OC_Pipe_Vs_Pipe(GAME_PLAY* play, CollisionCheck_c* colcheck, ClObj_c* col1, +void CollisionCheck_OC_Pipe_Vs_Pipe(GAME* game, CollisionCheck_c* colcheck, ClObj_c* col1, ClObj_c* col2) { @@ -697,9 +699,9 @@ int CollisionCheck_Check2ClObjNoOC(ClObj_c* col1, ClObj_c* col2) -void CollisionCheck_OC(GAME_PLAY* play, CollisionCheck_c* colcheck) +void CollisionCheck_OC(GAME* game, CollisionCheck_c* colcheck) { - + GAME_PLAY* play = (GAME_PLAY*)game; ClObj_c** col1p; ClObj_c** col2p; CollisionOCFunction current; @@ -727,13 +729,13 @@ void CollisionCheck_OC(GAME_PLAY* play, CollisionCheck_c* colcheck) continue; } - current(play, colcheck, *col1p, *col2p); + current(game, colcheck, *col1p, *col2p); } } - CollisionCheck_OCC(play, colcheck); + CollisionCheck_OCC(game, colcheck); } -void CollisionCheck_setOCC_HitInfo(GAME_PLAY* play, ClObj_c* col1, ClObjTrisElem_c* elem1, xyz_t* pos1, +void CollisionCheck_setOCC_HitInfo(GAME* game, ClObj_c* col1, ClObjTrisElem_c* elem1, xyz_t* pos1, ClObj_c* col2, ClObjElem_c* elem2, xyz_t* pos2, xyz_t* pos3) { @@ -746,10 +748,10 @@ void CollisionCheck_setOCC_HitInfo(GAME_PLAY* play, ClObj_c* col1, ClObjTrisElem } -void CollisionCheck_OCC_Tris_Vs_JntSph(GAME_PLAY* play, CollisionCheck_c* colcheck, ClObjTris_c* tris, +void CollisionCheck_OCC_Tris_Vs_JntSph(GAME* game, CollisionCheck_c* colcheck, ClObjTris_c* tris, ClObjJntSph_c* jntsph) { - + GAME_PLAY* play = (GAME_PLAY*)game; ClObjTrisElem_c* triselem; ClObjJntSphElem_c* jntsphelem; xyz_t pos; @@ -776,7 +778,7 @@ void CollisionCheck_OCC_Tris_Vs_JntSph(GAME_PLAY* play, CollisionCheck_c* colche xyz_t_move_s_xyz(&sphpos, &jntsphelem->attribute.s2.center); CollisionCheck_workTrisElemCenter(triselem, &trispos); - CollisionCheck_setOCC_HitInfo(play, &tris->collision_obj, triselem, &trispos, &jntsph->collision_obj, &jntsphelem->element, + CollisionCheck_setOCC_HitInfo(game, &tris->collision_obj, triselem, &trispos, &jntsph->collision_obj, &jntsphelem->element, &sphpos, &pos); } } @@ -785,9 +787,9 @@ void CollisionCheck_OCC_Tris_Vs_JntSph(GAME_PLAY* play, CollisionCheck_c* colche } -void CollisionCheck_OCC_Tris_Vs_Pipe(GAME_PLAY* play, CollisionCheck_c* colcheck, ClObjTris_c* tris, ClObjPipe_c* pipe) +void CollisionCheck_OCC_Tris_Vs_Pipe(GAME* game, CollisionCheck_c* colcheck, ClObjTris_c* tris, ClObjPipe_c* pipe) { - + GAME_PLAY* play = (GAME_PLAY*)game; ClObjTrisElem_c* triselem; xyz_t pos; xyz_t pipepos; @@ -809,7 +811,7 @@ void CollisionCheck_OCC_Tris_Vs_Pipe(GAME_PLAY* play, CollisionCheck_c* colcheck CollisionCheck_workTrisElemCenter(triselem, &trispos); xyz_t_move_s_xyz(&pipepos, &pipe->attribute.pipe.center); - CollisionCheck_setOCC_HitInfo(play, &tris->collision_obj, triselem, &trispos, &pipe->collision_obj, &pipe->element, &pipepos, &pos); + CollisionCheck_setOCC_HitInfo(game, &tris->collision_obj, triselem, &trispos, &pipe->collision_obj, &pipe->element, &pipepos, &pos); break; } } @@ -822,7 +824,7 @@ int CollisionCheck_Check1ClObjNoOCC(ClObj_c* col) return col->collision_flags1 >> 1 & 1 ^ 1; } -void CollisionCheck_OCC(GAME_PLAY* play, CollisionCheck_c* colcheck) +void CollisionCheck_OCC(GAME* game, CollisionCheck_c* colcheck) { @@ -863,12 +865,12 @@ void CollisionCheck_OCC(GAME_PLAY* play, CollisionCheck_c* colcheck) continue; } - current(play, colcheck, *col1p, *col2p); + current(game, colcheck, *col1p, *col2p); } } } -int ClObjTrisElem_OCCClear(GAME_PLAY* play, ClObjTrisElem_c* triselem) +int ClObjTrisElem_OCCClear(GAME* game, ClObjTrisElem_c* triselem) { triselem->attribute.t.x = 0.0f; @@ -877,33 +879,33 @@ int ClObjTrisElem_OCCClear(GAME_PLAY* play, ClObjTrisElem_c* triselem) return 1; } -int ClObj_OCCClear(GAME_PLAY* play, ClObj_c* col) +int ClObj_OCCClear(GAME* game, ClObj_c* col) { col->collided_actor = NULL; col->collision_flags1 &= ~4; } -int ClObjTris_OCCClear(GAME_PLAY* play, ClObj_c* col) +int ClObjTris_OCCClear(GAME* game, ClObj_c* col) { ClObjTris_c* tris = (ClObjTris_c*)col; ClObjTrisElem_c* triselem; - ClObj_OCCClear(play, &tris->collision_obj); + ClObj_OCCClear(game, &tris->collision_obj); for (triselem = tris->elements; triselem < &tris->elements[tris->count]; triselem++) { - ClObjTrisElem_OCCClear(play, triselem); + ClObjTrisElem_OCCClear(game, triselem); } return 1; } -int CollisionCheck_setOCC(GAME_PLAY* play, CollisionCheck_c* colcheck, ClObj_c* col) +int CollisionCheck_setOCC(GAME* game, CollisionCheck_c* colcheck, ClObj_c* col) { - + GAME_PLAY* play = (GAME_PLAY*)game; int ret; if (_Game_play_isPause(play) == 1) @@ -918,7 +920,7 @@ int CollisionCheck_setOCC(GAME_PLAY* play, CollisionCheck_c* colcheck, ClObj_c* return -1; } - OCCClearFunctionTable[col->collision_type](play, col); + OCCClearFunctionTable[col->collision_type](game, col); if ((col->owner_actor != NULL) && (col->owner_actor->mv_proc == NULL)) { diff --git a/src/m_play.c b/src/m_play.c index 18913bf1..de48908e 100644 --- a/src/m_play.c +++ b/src/m_play.c @@ -387,7 +387,7 @@ void play_cleanup(GAME* game){ play->submenu.mode = 0; PreRender_cleanup(&play->prerender); - CollisionCheck_dt(play, &play->collision_check); + CollisionCheck_dt(&play->game, &play->collision_check); if(play->fb_mode == 3){ fbdemo_cleanup(&fbdemo); @@ -455,7 +455,7 @@ void play_init(GAME* game){ initView(&play->view, graph); Init_Camera2(play); - CollisionCheck_ct(play, &play->collision_check); + CollisionCheck_ct(&play->game, &play->collision_check); mCoBG_InitMoveBgData(); mCoBG_InitBlockBgCheckMode(); @@ -554,9 +554,9 @@ void Game_play_move_fbdemo_not_move(GAME_PLAY* play){ play->game_frame++; mVibctl_clr_force_stop(2); play->game.doing_point = 7; - CollisionCheck_OC(play, &play->collision_check); + CollisionCheck_OC(&play->game, &play->collision_check); play->game.doing_point = 8; - CollisionCheck_clear(play, &play->collision_check); + CollisionCheck_clear(&play->game, &play->collision_check); play->game.doing_point = 9; play->game.doing_point = 0; play->game.doing_point_specific = 0x90; diff --git a/src/static/libc64/qrand.c b/src/static/libc64/qrand.c index 4a29e04b..32c58a65 100644 --- a/src/static/libc64/qrand.c +++ b/src/static/libc64/qrand.c @@ -19,7 +19,7 @@ float fqrand(void){ return *(float*)&__qrand_itemp - 1.0f; } -double fqrand2(void){ +float fqrand2(void){ __qrand_idum = __qrand_idum * 0x19660D + 0x3C6EF35F; __qrand_itemp = __qrand_idum >> 9 | 0x3F800000; return *(float*)&__qrand_itemp - 1.5f;