diff --git a/configure.py b/configure.py index 65753b81..dae8a0be 100644 --- a/configure.py +++ b/configure.py @@ -264,8 +264,8 @@ cflags_foresta = [ if version_num >= 1: cflags_foresta.append("-O4,p") cflags_foresta.append("-inline off") - config.linker_version = "GC/2.0" - foresta_compiler = "GC/2.0" + config.linker_version = "GC/2.6" + foresta_compiler = "GC/2.6" else: cflags_foresta.append("-O4,s") config.linker_version = "GC/1.3.2" @@ -930,7 +930,7 @@ config.libs = [ "foresta", [ Object(Matching, "audio.c"), - Object(Matching, "c_keyframe.c"), + Object(MatchingFor("GAFE01_00"), "c_keyframe.c"), Object(Matching, "ev_cherry_manager.c"), Object(Matching, "evw_anime.c"), Object(Matching, "executor.c"), @@ -1387,7 +1387,7 @@ config.libs = [ Object(Matching, "game/m_actor_shadow.c"), Object(Matching, "game/m_address_ovl.c"), Object(Matching, "game/m_all_grow.c"), - Object(Matching, "game/m_all_grow_ovl.c"), + Object(MatchingFor("GAFE01_00"), "game/m_all_grow_ovl.c"), Object(Matching, "game/m_bank_ovl.c"), Object(Matching, "game/m_banti.c"), Object(Matching, "game/m_bg_item.c"), @@ -1398,7 +1398,7 @@ config.libs = [ Object(Matching, "game/m_calendar.c"), Object(Matching, "game/m_calendar_ovl.c"), Object(Matching, "game/m_camera2.c"), - Object(Matching, "game/m_card.c"), + Object(MatchingFor("GAFE01_00"), "game/m_card.c"), Object(Matching, "game/m_catalog_ovl.c"), Object(Matching, "game/m_choice.c"), Object(Matching, "game/m_clip.c"), @@ -1416,7 +1416,7 @@ config.libs = [ Object(Matching, "game/m_cpwarning_ovl.c"), Object(Matching, "game/m_debug.c"), Object(Matching, "game/m_debug_display.c"), - Object(Matching, "game/m_debug_hayakawa.c"), + Object(MatchingFor("GAFE01"), "game/m_debug_hayakawa.c"), Object(Matching, "game/m_debug_mode.c"), Object(Matching, "game/m_demo.c"), Object(Matching, "game/m_design_ovl.c"), @@ -1425,7 +1425,7 @@ config.libs = [ Object(Matching, "game/m_eappli.c"), Object(Matching, "game/m_editEndChk_ovl.c"), Object(Matching, "game/m_editor_ovl.c"), - Object(Matching, "game/m_event.c"), + Object(MatchingFor("GAFE01"), "game/m_event.c"), Object(Matching, "game/m_event_map_npc.c"), Object(Matching, "game/m_fbdemo.c"), Object(Matching, "game/m_fbdemo_fade.c"), @@ -1433,7 +1433,7 @@ config.libs = [ Object(Matching, "game/m_fbdemo_wipe1.c"), Object(Matching, "game/m_field_assessment.c"), Object(Matching, "game/m_field_info.c"), - Object(Matching, "game/m_field_make.c"), + Object(MatchingFor("GAFE01"), "game/m_field_make.c"), Object(Matching, "game/m_fishrecord.c"), Object(Matching, "game/m_flashrom.c"), Object(Matching, "game/m_font.c"), @@ -1450,10 +1450,10 @@ config.libs = [ Object(Matching, "game/m_huusui_room.c"), Object(Matching, "game/m_huusui_room_ovl.c"), Object(Matching, "game/m_inventory_ovl.c"), - Object(Matching, "game/m_island.c"), + Object(MatchingFor("GAFE01"), "game/m_island.c"), Object(Matching, "game/m_item_name.c"), Object(Matching, "game/m_kabu_manager.c"), - Object(Matching, "game/m_kankyo.c"), + Object(MatchingFor("GAFE01"), "game/m_kankyo.c"), Object(Matching, "game/m_land.c"), Object(Matching, "game/m_ledit_ovl.c"), Object(Matching, "game/m_lib.c"), @@ -1461,7 +1461,7 @@ config.libs = [ Object(Matching, "game/m_mail.c"), Object(Matching, "game/m_mail_check.c"), Object(Matching, "game/m_mail_check_ovl.c"), - Object(Matching, "game/m_mail_password_check.c"), + Object(MatchingFor("GAFE01"), "game/m_mail_password_check.c"), Object(Matching, "game/m_mailbox_ovl.c"), Object(Matching, "game/m_malloc.c"), Object(Matching, "game/m_map_ovl.c"), @@ -1513,7 +1513,7 @@ config.libs = [ Object(Matching, "game/m_string.c"), Object(Matching, "game/m_submenu.c"), Object(Matching, "game/m_submenu_ovl.c"), - Object(Matching, "game/m_tag_ovl.c"), + Object(MatchingFor("GAFE01_00"), "game/m_tag_ovl.c"), Object(Matching, "game/m_time.c"), Object(Matching, "game/m_timeIn_ovl.c"), Object(Matching, "game/m_titledemo.c"), diff --git a/include/MSL_C/MSL_Common/float.h b/include/MSL_C/MSL_Common/float.h index 018d307a..7fd861bc 100644 --- a/include/MSL_C/MSL_Common/float.h +++ b/include/MSL_C/MSL_Common/float.h @@ -89,4 +89,4 @@ inline int __fpclassifyd(double __value) #define DBL_MAX_EXP 1024 #define DBL_MAX_10_EXP 308 -#endif /* _MSL_COMMON_FLOAT_H */ \ No newline at end of file +#endif /* _MSL_COMMON_FLOAT_H */ diff --git a/include/MSL_C/math.h b/include/MSL_C/math.h index a90549c7..27d18d4d 100644 --- a/include/MSL_C/math.h +++ b/include/MSL_C/math.h @@ -21,6 +21,17 @@ extern double sin(double deg); extern double cos(double deg); extern double tan(double deg); +float sinf(float); +float cosf(float); + +inline float sinf(float x) { + return (float)sin((double)x); +} + +inline float cosf(float x) { + return (float)cos((double)x); +} + extern double ceil(double); #ifdef __cplusplus diff --git a/include/audio.h b/include/audio.h index 60ef3b31..55affab7 100644 --- a/include/audio.h +++ b/include/audio.h @@ -115,8 +115,8 @@ extern int sAdo_SubGameOK(); extern void sAdo_Tenki(u8 mode); extern void sAdos_KishaStatusTrg(u8 state); -extern void sAdos_KishaStatusLevel(f32 speed, u32 ongenNum1, u16 angle1, f32 distance1, u32 ongenNum2, u16 angle2, - f32 distance2); +extern void sAdos_KishaStatusLevel(f32 speed, u32 ongenNum1, f32 distance1, u16 angle1, u32 ongenNum2, + f32 distance2, u16 angle2); extern int sAdos_GetRadioCounter(Radio_c* radio); extern void sAdos_GetKappaCounter(void* p); diff --git a/include/dolphin/os/OSThread.h b/include/dolphin/os/OSThread.h index 6a5a7869..50318bb7 100644 --- a/include/dolphin/os/OSThread.h +++ b/include/dolphin/os/OSThread.h @@ -67,6 +67,12 @@ struct OSThread u8 *stackBase; // the thread's designated stack (high address) u32 *stackEnd; // last word of stack (low address) + +// TODO: we should be using a newer SDK version +#if VERSION >= VER_GAFU01_00 + s32 error; + void* specific[2]; +#endif }; // Thread states diff --git a/include/irqmgr.h b/include/irqmgr.h index 245fee1c..38df8f30 100644 --- a/include/irqmgr.h +++ b/include/irqmgr.h @@ -12,32 +12,32 @@ extern "C" { #define IRQ_RESET_NORMAL 0 #define IRQ_RESET_PRENMI 1 -#define IRQ_RESET_DELAY 2 +#define IRQ_RESET_DELAY 2 #define IRQMGR_MESSAGES_MAX 8 typedef struct { - s16 type; - s8 data[30]; + s16 type; + s8 data[30]; } irqmgr_mesg_t; typedef struct irqmgr_client_s { - struct irqmgr_client_s* next; - OSMessageQueue* msgQueue; + struct irqmgr_client_s* next; + OSMessageQueue* msgQueue; } irqmgr_client_t; typedef struct { - irqmgr_mesg_t msgRetrace; - irqmgr_mesg_t msgPreNMI; - irqmgr_mesg_t msgDelayPreNMI; - OSMessageQueue _msgQueue; - OSMessage _msgBuf[IRQMGR_MESSAGES_MAX]; - OSThread thread; - irqmgr_client_t* clients; - u8 prenmi; - OSTime prenmi_time; - OSTimer timer; - OSTime retraceTime; + irqmgr_mesg_t msgRetrace; + irqmgr_mesg_t msgPreNMI; + irqmgr_mesg_t msgDelayPreNMI; + OSMessageQueue _msgQueue; + OSMessage _msgBuf[IRQMGR_MESSAGES_MAX]; + OSThread thread; + irqmgr_client_t* clients; + u8 prenmi; + OSTime prenmi_time; + OSTimer timer; + OSTime retraceTime; } irqmgr_t; extern void irqmgr_AddClient(irqmgr_client_t* client, OSMessageQueue* msgqueue); diff --git a/include/lb_reki.h b/include/lb_reki.h index 49b951ad..2fc9e8e8 100644 --- a/include/lb_reki.h +++ b/include/lb_reki.h @@ -22,8 +22,8 @@ extern "C" { #define lbRk_KYUU_DAY_START 1 -extern int lbRk_ToSeiyouReki(lbRTC_ymd_c* seiyo_ymd, const lbRTC_ymd_c* kyuu_ymd); -extern int lbRk_ToKyuuReki(lbRTC_ymd_c* kyuu_ymd, const lbRTC_ymd_c* seiyo_ymd); +extern int lbRk_ToSeiyouReki(lbRTC_ymd_c* seiyo_ymd, lbRTC_ymd_c* kyuu_ymd); +extern int lbRk_ToKyuuReki(lbRTC_ymd_c* kyuu_ymd, lbRTC_ymd_c* seiyo_ymd); extern int lbRk_VernalEquinoxDay(int year); extern int lbRk_AutumnalEquinoxDay(int year); extern void lbRk_HarvestMoonDay(lbRTC_ymd_c* harvest_moon_day, int year); diff --git a/include/m_camera2.h b/include/m_camera2.h index 521671a2..97797860 100644 --- a/include/m_camera2.h +++ b/include/m_camera2.h @@ -339,7 +339,7 @@ extern xyz_t* Camera2_getMicPos_p(GAME_PLAY* play); extern int Camera2NormalState_get(GAME_PLAY* play); extern int Camera2_request_main_wade(GAME_PLAY* play, xyz_t* pos, int priority, f32 goal_time); extern int Camera2_request_main_talk(GAME_PLAY* play, ACTOR* speaker, ACTOR* listener, int priority); -extern int Camera2_request_main_talk_pos(GAME_PLAY* play, ACTOR* speaker, xyz_t* listener_pos, int priority); +extern int Camera2_request_main_talk_pos(GAME_PLAY* play, ACTOR* speaker, const xyz_t* const listener_pos, int priority); extern int Camera2_request_main_normal(GAME_PLAY* play, int flags, int priority); extern int Camera2_request_main_demo(GAME_PLAY* play, const xyz_t* start_center, const f32 start_dist, const s_xyz* start_dir, const xyz_t* goal_center, const f32 goal_dist, @@ -351,16 +351,16 @@ extern int Camera2_request_main_demo_fromNowPos(GAME_PLAY* play, const xyz_t* go extern int Camera2_request_main_demo_fromNowPos2(GAME_PLAY* play, const xyz_t* goal_center, const f32 goal_delta, const f32 accel_delta, const f32 braking_delta, const int priority); extern int Camera2_request_main_item(GAME_PLAY* play, int type, int priority); -extern int Camera2_request_main_lock(GAME_PLAY* play, xyz_t* center_pos, xyz_t* eye_pos, f32 fov_y, int morph_counter, +extern int Camera2_request_main_lock(GAME_PLAY* play, const xyz_t* center_pos, const xyz_t* eye_pos, f32 fov_y, int morph_counter, f32 near, f32 far, int priority); extern int Camera2_request_main_door(GAME_PLAY* play, ACTOR* door_actor, u32 flags, int priority); -extern int Camera2_request_main_simple2(GAME_PLAY* play, xyz_t* center, s_xyz* dir, f32 dist, int morph_counter, +extern int Camera2_request_main_simple2(GAME_PLAY* play, const xyz_t* center, const s_xyz* dir, f32 dist, int morph_counter, int mode, int priority); extern int Camera2_request_main_simple_kirin(GAME_PLAY* play, const xyz_t* center, int priority); extern int Camera2_request_main_simple_fishing(GAME_PLAY* play, const xyz_t* player_pos, const xyz_t* bobber_pos, int priority); -extern int Camera2_request_main_simple_fishing_return(GAME_PLAY* play, xyz_t* player_pos, int priority); -extern int Camera2_request_main_simple(GAME_PLAY* play, xyz_t* pos, s_xyz* dir, f32 dist, int morph_counter, +extern int Camera2_request_main_simple_fishing_return(GAME_PLAY* play, const xyz_t* player_pos, int priority); +extern int Camera2_request_main_simple(GAME_PLAY* play, const xyz_t* pos, const s_xyz* dir, f32 dist, int morph_counter, int priority); extern void Camera2_main_Simple_AngleDistStd(GAME_PLAY* play, s_xyz* angle, f32* dist); extern int Camera2_request_main_listen_front_low_talk(GAME_PLAY* play, ACTOR* speaker, ACTOR* listener, int priority); @@ -369,8 +369,8 @@ extern int Camera2_request_main_cust_talk(GAME_PLAY* play, ACTOR* speaker, ACTOR int priority, s16 angle_x, s16 angle_y, f32 distance); extern int Camera2_request_BuySikimono_WallPaper(GAME_PLAY* play, xyz_t* center, xyz_t* eye); extern int Camera2_Inter_set_reverse_mode(GAME_PLAY* play); -extern int Camera2_request_main_inter(GAME_PLAY* play, xyz_t* start_center, xyz_t* start_eye, xyz_t* goal_center, - xyz_t* goal_eye, f32 s0, f32 s1, u32 flags, int morph_counter, int priority); +extern int Camera2_request_main_inter(GAME_PLAY* play, const xyz_t* start_center, const xyz_t* start_eye, const xyz_t* goal_center, + const xyz_t* goal_eye, f32 s0, f32 s1, u32 flags, int morph_counter, int priority); extern int Camera2_request_main_staff_roll(GAME_PLAY* play, ACTOR* speaker, ACTOR* listener, int priority); extern void Init_Camera2(GAME_PLAY* play); extern void Camera2_process(GAME_PLAY* play); diff --git a/include/m_collision_bg.h b/include/m_collision_bg.h index 559dfacd..8828a159 100644 --- a/include/m_collision_bg.h +++ b/include/m_collision_bg.h @@ -74,45 +74,45 @@ enum background_attribute { mCoBG_ATTRIBUTE_WOOD, mCoBG_ATTRIBUTE_SEA, - mCoBG_ATTRIBUTE_25, - mCoBG_ATTRIBUTE_26, - mCoBG_ATTRIBUTE_27, - mCoBG_ATTRIBUTE_28, - mCoBG_ATTRIBUTE_29, - mCoBG_ATTRIBUTE_30, - mCoBG_ATTRIBUTE_31, - mCoBG_ATTRIBUTE_32, - mCoBG_ATTRIBUTE_33, - mCoBG_ATTRIBUTE_34, - mCoBG_ATTRIBUTE_35, - mCoBG_ATTRIBUTE_36, - mCoBG_ATTRIBUTE_37, - mCoBG_ATTRIBUTE_38, - mCoBG_ATTRIBUTE_39, - mCoBG_ATTRIBUTE_40, - mCoBG_ATTRIBUTE_41, - mCoBG_ATTRIBUTE_42, - mCoBG_ATTRIBUTE_43, - mCoBG_ATTRIBUTE_44, - mCoBG_ATTRIBUTE_45, - mCoBG_ATTRIBUTE_46, - mCoBG_ATTRIBUTE_47, - mCoBG_ATTRIBUTE_48, - mCoBG_ATTRIBUTE_49, - mCoBG_ATTRIBUTE_50, - mCoBG_ATTRIBUTE_51, - mCoBG_ATTRIBUTE_52, - mCoBG_ATTRIBUTE_53, - mCoBG_ATTRIBUTE_54, - mCoBG_ATTRIBUTE_55, - mCoBG_ATTRIBUTE_56, - mCoBG_ATTRIBUTE_57, - mCoBG_ATTRIBUTE_58, - mCoBG_ATTRIBUTE_59, - mCoBG_ATTRIBUTE_60, - mCoBG_ATTRIBUTE_61, - mCoBG_ATTRIBUTE_62, - mCoBG_ATTRIBUTE_63, + mCoBG_ATTRIBUTE_25, // wave_se2 + mCoBG_ATTRIBUTE_26, // wave_sw2 + mCoBG_ATTRIBUTE_27, // wood bridge nw + mCoBG_ATTRIBUTE_28, // wood bridge sw + mCoBG_ATTRIBUTE_29, // wood bridge se + mCoBG_ATTRIBUTE_30, // wood bridge ne + mCoBG_ATTRIBUTE_31, // wood bridge center + mCoBG_ATTRIBUTE_32, // stone bridge n + mCoBG_ATTRIBUTE_33, // stone bridge e + mCoBG_ATTRIBUTE_34, // stone bridge w + mCoBG_ATTRIBUTE_35, // stone bridge s + mCoBG_ATTRIBUTE_36, // wave_s + mCoBG_ATTRIBUTE_37, // wave_se + mCoBG_ATTRIBUTE_38, // wave_sw + mCoBG_ATTRIBUTE_39, // river bank nw + mCoBG_ATTRIBUTE_40, // river bank sw + mCoBG_ATTRIBUTE_41, // river bank se + mCoBG_ATTRIBUTE_42, // river bank ne + mCoBG_ATTRIBUTE_43, // grass 3 north (river) + mCoBG_ATTRIBUTE_44, // grass 3 east (river) + mCoBG_ATTRIBUTE_45, // grass 3 west (river) + mCoBG_ATTRIBUTE_46, // grass 3 south (river) + mCoBG_ATTRIBUTE_47, // grass 4 north (cliff) + mCoBG_ATTRIBUTE_48, // grass 4 east (cliff) + mCoBG_ATTRIBUTE_49, // grass 4 west (cliff) + mCoBG_ATTRIBUTE_50, // grass 4 south (cliff) + mCoBG_ATTRIBUTE_51, // grass 4 tunnel left upper + mCoBG_ATTRIBUTE_52, // grass 4 tunnel left lower + mCoBG_ATTRIBUTE_53, // grass 4 tunnel right lower + mCoBG_ATTRIBUTE_54, // grass 4 tunnel right upper + mCoBG_ATTRIBUTE_55, // grass 3 north west (cliff) + mCoBG_ATTRIBUTE_56, // grass 3 south west (cliff) + mCoBG_ATTRIBUTE_57, // grass 3 south east (cliff) + mCoBG_ATTRIBUTE_58, // grass 3 north east (cliff) + mCoBG_ATTRIBUTE_59, // grass 3 north west (river bank) + mCoBG_ATTRIBUTE_60, // grass 3 south west (river bank) + mCoBG_ATTRIBUTE_61, // grass 3 south east (river bank) + mCoBG_ATTRIBUTE_62, // grass 3 north east (river bank) + mCoBG_ATTRIBUTE_63, // slate (slope) // ... mCoBG_ATTRIBUTE_NONE = 100 @@ -457,7 +457,11 @@ extern int mCoBG_CheckSandUt_ForFish(xyz_t* pos); extern int mCoBG_CheckSandHole_ClData(mCoBG_Collision_u* col); extern int mCoBG_BnumUnum2SandHole(int bx, int bz, int b_ux, int b_uz); extern int mCoBG_CheckHole(xyz_t pos); -extern int mCoBG_CheckSkySwing(xyz_t pos); +#if VERSION >= VER_GAFU01_00 +extern int mCoBG_CheckAirSwing(xyz_t pos); +#else +extern int mCoBG_CheckAirSwing(xyz_t pos); +#endif extern int mCoBG_CheckGrassX_ClData(mCoBG_Collision_u* col); extern int mCoBG_CheckGrassX(const xyz_t* pos); extern int mCoBG_CheckWave_ClData(mCoBG_Collision_u* col); @@ -496,7 +500,11 @@ extern void mCoBG_Ut2SetDefaultOffset(int ux, int uz); extern int mCoBG_LineCheck_RemoveFg(xyz_t* rev, xyz_t start_pos, xyz_t end_pos, mCoBG_COLUMN_CHECK_ITEM_TYPE_PROC check_proc, int line_check_type); +#if VERSION >= VER_GAFU01_00 +extern f32 mCoBG_Wpos2BgHeight_AngleSXXX(s_xyz* ground_angle, xyz_t pos, f32 ground_dist); +#else extern f32 mCoBG_GetBgY_AngleS_FromWpos2(s_xyz* ground_angle, xyz_t pos, f32 ground_dist); +#endif extern f32 mCoBG_GetWaterHeight_File(xyz_t pos, char* file, int line); #define mCoBG_GetWaterHeight(wpos) mCoBG_GetWaterHeight_File(wpos, __FILE__, __LINE__) extern int mCoBG_CheckWaterAttribute(u32 attr); diff --git a/include/m_fishrecord.h b/include/m_fishrecord.h index ec4c15a9..9949a53a 100644 --- a/include/m_fishrecord.h +++ b/include/m_fishrecord.h @@ -28,7 +28,7 @@ enum { extern void mEv_fishRecord_set(PersonalID_c* pid, int size); extern int mFR_fish_rndsize(int fish_size); extern int mFR_make_NpcRecord(lbRTC_hour_t hour); -extern void mEv_fishRecord_holder(PersonalID_c* winning_pid, u32* winning_size, lbRTC_ymd_c* contest_date); +extern void mEv_fishRecord_holder(PersonalID_c* winning_pid, u32* winning_size, const lbRTC_ymd_c* contest_date); extern int mEv_fishday(lbRTC_ymd_c* dates, lbRTC_time_c* time); extern void mFR_fishmail(); diff --git a/include/m_kankyo.h b/include/m_kankyo.h index 49c0d55d..cee2bb00 100644 --- a/include/m_kankyo.h +++ b/include/m_kankyo.h @@ -24,6 +24,12 @@ extern "C" { #define mEnv_WIND_TERM_NUM 4u #define mEnv_WIND_CHANGE_RATE (f32)(10 * mTM_SECONDS_IN_MINUTE * 60) // 60fps, 10 minutes +#if VERSION == VER_GAFU01_00 +#define mEnv_CHANGE_WEATHER_ENV_RATE (1.0f/250.0f); +#else +#define mEnv_CHANGE_WEATHER_ENV_RATE (1.0f/600.0f); +#endif + enum weather { mEnv_WEATHER_CLEAR, mEnv_WEATHER_RAIN, diff --git a/include/m_land.h b/include/m_land.h index 1dfe5705..6a7f55c0 100644 --- a/include/m_land.h +++ b/include/m_land.h @@ -17,7 +17,7 @@ extern "C" { extern void mLd_StartFlagOn(); extern int mLd_CheckStartFlag(); -extern int mLd_NullCheckLandName(const u8* land_name); +extern int mLd_NullCheckLandName(u8* land_name); extern int mLd_CheckId(u16 land_id); extern int mLd_CheckCmpLandName(u8* name_a, u8* name_b); extern int mLd_CheckCmpLand(u8* name_a, u16 id_a, u8* name_b, u16 id_b); diff --git a/include/m_player.h b/include/m_player.h index 71797f82..9447283f 100644 --- a/include/m_player.h +++ b/include/m_player.h @@ -2142,6 +2142,10 @@ struct player_actor_s { /* 0x0F24 */ u32 item_net_catch_label_request_force; /* 0x0F28 */ s8 item_net_catch_type_request_force; /* 0x0F2C */ int item_net_catch_insect_idx; +#if VERSION >= VER_GAFU01_00 + /* 0x0F30 */ xyz_t item_net_catch_correct_pos; + /* 0x0F3C */ int item_net_catch_correct_pos_set; +#endif /* 0x0F30 */ ACTOR* fishing_rod_actor_p; /* 0x0F34 */ xyz_t item_rod_top_pos; /* 0x0F40 */ xyz_t item_rod_virtual_top_pos; diff --git a/include/m_tag_ovl.h b/include/m_tag_ovl.h index cf946b2a..e569fc46 100644 --- a/include/m_tag_ovl.h +++ b/include/m_tag_ovl.h @@ -292,7 +292,7 @@ struct tag_ovl_s { }; extern int mTG_mark_main(Submenu*, mSM_MenuInfo_c*, int, int*); -extern int mTG_mark_mainX(Submenu*, mSM_MenuInfo_c*, int, int, int, int*); +extern int mTG_mark_mainX(Submenu*, const mSM_MenuInfo_c*, int, int, int, int*); extern void mTG_tag_ovl_construct(Submenu* submenu); extern void mTG_tag_ovl_destruct(Submenu* submenu); diff --git a/include/m_time.h b/include/m_time.h index f889bad9..46589d22 100644 --- a/include/m_time.h +++ b/include/m_time.h @@ -78,7 +78,7 @@ extern void mTM_set_season(); extern int mTM_check_renew_time(u8 renew_flag); extern void mTM_off_renew_time(u8 renew_flag); extern void mTM_set_renew_is(); -extern void mTM_set_renew_time(lbRTC_ymd_c* renew_time, const lbRTC_time_c* time); +extern void mTM_set_renew_time(lbRTC_ymd_c* renew_time, lbRTC_time_c* time); extern void mTM_ymd_2_time(lbRTC_time_c* time, lbRTC_ymd_c* ymd); extern void mTM_renewal_renew_time(); extern void mTM_clear_renew_is(); diff --git a/include/m_train_control.h b/include/m_train_control.h index 377e7580..e2b0a4df 100644 --- a/include/m_train_control.h +++ b/include/m_train_control.h @@ -8,8 +8,21 @@ extern "C" { #endif +#if VERSION >= VER_GAFU01_00 +#define mTRC_SLOW_SPEED 2.6f // speed stopping/starting +#define mTRC_FAST_SPEED 7.2f // speed when farther away from station +#define mTRC_SLOW_RATE (0.21000001f) // rate at which slowing down occurs +#define mTRC_STOP_RATE 0.0084f // rate at which stopping occurs +#define mTRC_START_RATE 0.0047f // rate at which starting occurs +#define mTRC_SPEEDUP_RATE 0.0047f // rate at which speeding up occurs +#else #define mTRC_SLOW_SPEED 2.0f // speed stopping/starting #define mTRC_FAST_SPEED 6.0f // speed when farther away from station +#define mTRC_SLOW_RATE 0.01f // rate at which slowing down occurs +#define mTRC_STOP_RATE 0.005f // rate at which stopping occurs +#define mTRC_START_RATE 0.00345f // rate at which starting occurs +#define mTRC_SPEEDUP_RATE 0.00345f // rate at which speeding up occurs +#endif enum { mTRC_ACTION_NONE, diff --git a/include/sys_math.h b/include/sys_math.h index 04834af5..f87b9233 100644 --- a/include/sys_math.h +++ b/include/sys_math.h @@ -24,7 +24,12 @@ extern "C" { #define USHT_MIN ((f32)USHT_MIN_S) #define USHT_MAX ((f32)USHT_MAX_S) +#if VERSION >= VER_GAFU01_00 +extern u32 __float_max[]; +#define FLT_MAX *(float*)__float_max; +#else #define FLT_MAX (3.4028235e+38f) +#endif /* Macro to generate a random float in the range of [0, n) */ #define RANDOM_F(n) (fqrand() * (f32)(n)) diff --git a/include/sys_math3d.h b/include/sys_math3d.h index 9fc85ff5..4132516c 100644 --- a/include/sys_math3d.h +++ b/include/sys_math3d.h @@ -73,13 +73,13 @@ extern f32 Math3DLength2D(f32 x0, f32 x1, f32 y0, f32 y1); extern f32 Math3DVecLengthSquare(xyz_t* v); extern f32 Math3DVecLength(xyz_t* v); extern f32 Math3DLengthSquare(xyz_t* a, xyz_t* b); -extern f32 Math3DLength(xyz_t* a, xyz_t* b); -extern void Math3DVectorProduct2Vec(const xyz_t* a, xyz_t* b, xyz_t* ret); +extern f32 Math3DLength(const xyz_t* a, const xyz_t* b); +extern void Math3DVectorProduct2Vec(const xyz_t* a, const xyz_t* b, xyz_t* ret); extern void Math3DVectorProductXYZ(xyz_t* va, xyz_t* vb, xyz_t* vc, xyz_t* ret); extern void Math3DPlane(xyz_t* va, xyz_t* vb, xyz_t* vc, f32* nox, f32* noy, f32* noz, f32* odist); -extern f32 Math3DPlaneFunc(f32 nox, f32 noy, f32 noz, f32 odist, xyz_t* pl); -extern f32 Math3DLengthPlaneAndPos(f32 nox, f32 noy, f32 noz, f32 odist, xyz_t* pl); -extern f32 Math3DSignedLengthPlaneAndPos(f32 nox, f32 noy, f32 noz, f32 odist, xyz_t* pl); +extern f32 Math3DPlaneFunc(f32 nox, f32 noy, f32 noz, f32 odist, const xyz_t* pl); +extern f32 Math3DLengthPlaneAndPos(f32 nox, f32 noy, f32 noz, f32 odist, const xyz_t* pl); +extern f32 Math3DSignedLengthPlaneAndPos(f32 nox, f32 noy, f32 noz, f32 odist, const xyz_t* pl); extern int Math3DTriangleCrossYCheck_general(xyz_t* v0, xyz_t* v1, xyz_t* v2, f32 z, f32 x, f32 dt, f32 dist, f32 noy); extern int Math3DTriangleCrossYLine_scope(xyz_t* v0, xyz_t* v1, xyz_t* v2, f32 nox, f32 noy, f32 noz, f32 dst, f32 z, f32 x, f32* yint, f32 y0, f32 y1); diff --git a/src/AUS/game/m_collision_bg.c b/src/AUS/game/m_collision_bg.c index f78a87d3..23100711 100644 --- a/src/AUS/game/m_collision_bg.c +++ b/src/AUS/game/m_collision_bg.c @@ -8,6 +8,8 @@ #include "m_random_field.h" #include "sys_matrix.h" +#define mCoBG_VIRTUAL_ACTOR_ID 2000 + typedef struct { xyz_t pos; f32 height; @@ -22,7 +24,7 @@ typedef struct { f32 start_btm; f32 end_top; f32 end_btm; - }mCoBG_WallBounds_c; +} mCoBG_WallBounds_c; typedef struct { f32 start[2]; @@ -62,13 +64,19 @@ static mCoBG_ActorInf_c l_ActorInf; static mCoBG_mBgMgr_c l_mBgMgr; static void mCoBG_SetMoveBgContactSide(mCoBG_bg_regist_c* regist_p, ACTOR* actorx, s16 angle); -static void mCoBG_MakeUnitVector(mCoBG_vec_info_c* vec_info, mCoBG_UnitInfo_c* ut_info, s16 unit_count, u8 check_type, s16 atr_wall, s16 old_on_ground, s16 old_in_water); -static void mCoBG_MakeMoveBgVector(mCoBG_vec_info_c* vec_info, mCoBG_mBgMgr_c* mbg_mgr, const xyz_t* pos, u8 check_type); -static void mCoBG_MakeColumnCollisionData(mCoBG_column_c* column, int* column_count, mCoBG_UnitInfo_c* ut_info, int unit_count, int old_on_ground, mCoBG_COLUMN_CHECK_ITEM_TYPE_PROC check_item_proc, int start, int end); +static void mCoBG_MakeUnitVector(mCoBG_vec_info_c* vec_info, mCoBG_UnitInfo_c* ut_info, s16 unit_count, u8 check_type, + s16 atr_wall, s16 old_on_ground, s16 old_in_water); +static void mCoBG_MakeMoveBgVector(mCoBG_vec_info_c* vec_info, mCoBG_mBgMgr_c* mbg_mgr, const xyz_t* pos, + u8 check_type); +static void mCoBG_MakeColumnCollisionData(ACTOR* actorx, mCoBG_column_c* col, int* col_count_p, + mCoBG_UnitInfo_c* ut_info, int count, int old_on_ground, + mCoBG_COLUMN_CHECK_ITEM_TYPE_PROC check_item_proc, int ux, int uz); static void mCoBG_MakeCircleDefenceWall(mCoBG_ActorInf_c* actor_info, s16 attr_wall); -static void mCoBG_ColumnWallCheck(xyz_t* rev, mCoBG_ActorInf_c* actor_info, const xyz_t* pos, mCoBG_column_c* column, int column_count, s16 atr_wall); +static void mCoBG_ColumnWallCheck(xyz_t* rev, mCoBG_ActorInf_c* actor_info, const xyz_t* pos, mCoBG_column_c* column, + int column_count, s16 atr_wall); static f32 mCoBG_GetBGHeight_Column(const xyz_t* pos, mCoBG_UnitInfo_c* unit_info); -static void mCoBG_MoveBgGroundCheck(xyz_t* rev_pos, mCoBG_ActorInf_c* actor_info, ACTOR* actorx, mCoBG_CheckResult_c* result, s_xyz* angle); +static void mCoBG_MoveBgGroundCheck(xyz_t* rev_pos, mCoBG_ActorInf_c* actor_info, ACTOR* actorx, + mCoBG_CheckResult_c* result, s_xyz* angle); static u8 mCoBG_bridge_search_water[] = { 3, 6, 12, 9, 240, 1, 8, 2, 4, 3, 6, 12, 9 }; static u8 mCoBG_grass3_search_water[] = { 3, 6, 12, 9 }; @@ -80,6 +88,7 @@ typedef struct { } mCoBG_forbid_vec_data_c; static mCoBG_forbid_vec_data_c mCoBG_make_vector_table[] = { + // clang-format off {DEG2SHORT_ANGLE2(0.0f), {0.0f, 1.0f}, mCoBG_WALL_UP}, {DEG2SHORT_ANGLE2(-90.0f), {-1.0f, 0.0f}, mCoBG_WALL_RIGHT}, {DEG2SHORT_ANGLE2(90.0f), {1.0f, 0.0f}, mCoBG_WALL_LEFT}, @@ -88,134 +97,134 @@ static mCoBG_forbid_vec_data_c mCoBG_make_vector_table[] = { {DEG2SHORT_ANGLE2(135.0f), {SQRT_OF_2_DIV_2, -SQRT_OF_2_DIV_2}, mCoBG_WALL_SLATE_DOWN}, {DEG2SHORT_ANGLE2(225.0f), {-SQRT_OF_2_DIV_2, -SQRT_OF_2_DIV_2}, mCoBG_WALL_SLATE_UP}, {DEG2SHORT_ANGLE2(315.0f), {-SQRT_OF_2_DIV_2, SQRT_OF_2_DIV_2}, mCoBG_WALL_SLATE_DOWN}, + // clang-format on }; static s16 mCoBG_forbid_vector_idx[][2] = { - {4, -1}, {5, -1}, {6, -1}, {7, -1}, {-1, -1}, {0, -1}, {1, -1}, {2, -1}, - {3, -1}, {3, -1}, {6, -1}, {5, -1}, {4, -1}, {5, -1}, {6, -1}, {7, -1}, - {0, -1}, {1, -1}, {2, -1}, {3, -1}, {0, -1}, {1, -1}, {2, -1}, {3, -1}, - {0, 2}, {3, 2}, {3, 1}, {0, 1}, {4, -1}, {5, -1}, {6, -1}, {7, -1}, - {0, 2}, {3, 2}, {3, 1}, {0, 1}, + { 4, -1 }, { 5, -1 }, { 6, -1 }, { 7, -1 }, { -1, -1 }, { 0, -1 }, { 1, -1 }, { 2, -1 }, { 3, -1 }, + { 3, -1 }, { 6, -1 }, { 5, -1 }, { 4, -1 }, { 5, -1 }, { 6, -1 }, { 7, -1 }, { 0, -1 }, { 1, -1 }, + { 2, -1 }, { 3, -1 }, { 0, -1 }, { 1, -1 }, { 2, -1 }, { 3, -1 }, { 0, 2 }, { 3, 2 }, { 3, 1 }, + { 0, 1 }, { 4, -1 }, { 5, -1 }, { 6, -1 }, { 7, -1 }, { 0, 2 }, { 3, 2 }, { 3, 1 }, { 0, 1 }, }; static xyz_t mCoBG_unit_offset[mCoBG_DIRECT_NUM] = { - { 0.0f, 0.0f, -mFI_UNIT_BASE_SIZE_F }, - { -mFI_UNIT_BASE_SIZE_F, 0.0f, 0.0f }, - { 0.0f, 0.0f, mFI_UNIT_BASE_SIZE_F }, - { mFI_UNIT_BASE_SIZE_F, 0.0f, 0.0f }, - { -mFI_UNIT_BASE_SIZE_F, 0.0f, -mFI_UNIT_BASE_SIZE_F }, - { -mFI_UNIT_BASE_SIZE_F, 0.0f, mFI_UNIT_BASE_SIZE_F }, - { mFI_UNIT_BASE_SIZE_F, 0.0f, mFI_UNIT_BASE_SIZE_F }, - { mFI_UNIT_BASE_SIZE_F, 0.0f, -mFI_UNIT_BASE_SIZE_F } + // clang-format off + { 0.0f, 0.0f, -mFI_UNIT_BASE_SIZE_F }, + { -mFI_UNIT_BASE_SIZE_F, 0.0f, 0.0f }, + { 0.0f, 0.0f, mFI_UNIT_BASE_SIZE_F }, + { mFI_UNIT_BASE_SIZE_F, 0.0f, 0.0f }, + { -mFI_UNIT_BASE_SIZE_F, 0.0f, -mFI_UNIT_BASE_SIZE_F }, + { -mFI_UNIT_BASE_SIZE_F, 0.0f, mFI_UNIT_BASE_SIZE_F }, + { mFI_UNIT_BASE_SIZE_F, 0.0f, mFI_UNIT_BASE_SIZE_F }, + { mFI_UNIT_BASE_SIZE_F, 0.0f, -mFI_UNIT_BASE_SIZE_F }, + // clang-format on }; static void mCoBG_PlussDirectOffset(xyz_t* ofs_wpos, xyz_t wpos, int direct) { - if (ofs_wpos != NULL && direct >= 0 && direct < mCoBG_DIRECT_NUM) { - ofs_wpos->x = wpos.x + mCoBG_unit_offset[direct].x; - ofs_wpos->y = wpos.y + mCoBG_unit_offset[direct].y; - ofs_wpos->z = wpos.z + mCoBG_unit_offset[direct].z; - } + if (ofs_wpos != NULL && direct >= 0 && direct < mCoBG_DIRECT_NUM) { + ofs_wpos->x = wpos.x + mCoBG_unit_offset[direct].x; + ofs_wpos->y = wpos.y + mCoBG_unit_offset[direct].y; + ofs_wpos->z = wpos.z + mCoBG_unit_offset[direct].z; + } } static void mCoBG_SetXyz_t(xyz_t* pos, f32 x, f32 y, f32 z) { - pos->x = x; - pos->y = y; - pos->z = z; + pos->x = x; + pos->y = y; + pos->z = z; } static void mCoBG_SetXZ(f32* xz, f32 x, f32 z) { - xz[0] = x; - xz[1] = z; + xz[0] = x; + xz[1] = z; } static void mCoBG_Wpos2Upos(xyz_t* upos, xyz_t wpos, int ut_x, int ut_z) { - upos->x = wpos.x - (ut_x * mFI_UT_WORLDSIZE_X_F); - upos->z = wpos.z - (ut_z * mFI_UT_WORLDSIZE_Z_F); + upos->x = wpos.x - (ut_x * mFI_UT_WORLDSIZE_X_F); + upos->z = wpos.z - (ut_z * mFI_UT_WORLDSIZE_Z_F); - upos->x -= mFI_UT_WORLDSIZE_HALF_X_F; - upos->z -= mFI_UT_WORLDSIZE_HALF_Z_F; + upos->x -= mFI_UT_WORLDSIZE_HALF_X_F; + upos->z -= mFI_UT_WORLDSIZE_HALF_Z_F; } static void mCoBG_Unit2UnitInfo_OutOfUnitPos(mCoBG_UnitInfo_c* unit_info, int ut_x, int ut_z) { - mActor_name_t* item_p; + mActor_name_t* item_p; - unit_info->ut_x = ut_x; - unit_info->ut_z = ut_z; - unit_info->collision = mFI_UtNum2UtCol(ut_x, ut_z); - unit_info->base_height = mFI_UtNum2BaseHeight(ut_x, ut_z); - unit_info->leftUp_offset = unit_info->collision->data.top_left * 10.0f + unit_info->base_height; - unit_info->leftDown_offset = unit_info->collision->data.bot_left * 10.0f + unit_info->base_height; - unit_info->rightDown_offset = unit_info->collision->data.bot_right * 10.0f + unit_info->base_height; - unit_info->rightUp_offset = unit_info->collision->data.top_right * 10.0f + unit_info->base_height; - unit_info->slate_flag = unit_info->collision->data.slate_flag; - unit_info->attribute = unit_info->collision->data.unit_attribute; + unit_info->ut_x = ut_x; + unit_info->ut_z = ut_z; + unit_info->collision = mFI_UtNum2UtCol(ut_x, ut_z); + unit_info->base_height = mFI_UtNum2BaseHeight(ut_x, ut_z); + unit_info->leftUp_offset = unit_info->collision->data.top_left * 10.0f + unit_info->base_height; + unit_info->leftDown_offset = unit_info->collision->data.bot_left * 10.0f + unit_info->base_height; + unit_info->rightDown_offset = unit_info->collision->data.bot_right * 10.0f + unit_info->base_height; + unit_info->rightUp_offset = unit_info->collision->data.top_right * 10.0f + unit_info->base_height; + unit_info->slate_flag = unit_info->collision->data.slate_flag; + unit_info->attribute = unit_info->collision->data.unit_attribute; - item_p = mFI_UtNum2UtFG(ut_x, ut_z); + item_p = mFI_UtNum2UtFG(ut_x, ut_z); - if (item_p != NULL) { - unit_info->item = *item_p; - } - else { - unit_info->item = EMPTY_NO; - } + if (item_p != NULL) { + unit_info->item = *item_p; + } else { + unit_info->item = EMPTY_NO; + } } static void mCoBG_Wpos2UnitInfo(mCoBG_UnitInfo_c* unit_info, xyz_t wpos) { - xyz_t upos = { 0.0f, 0.0f, 0.0f }; - int ut_x; - int ut_z; + xyz_t upos = { 0.0f, 0.0f, 0.0f }; + int ut_x; + int ut_z; - mFI_Wpos2UtNum(&ut_x, &ut_z, wpos); - mCoBG_Unit2UnitInfo_OutOfUnitPos(unit_info, ut_x, ut_z); - mCoBG_Wpos2Upos(&upos, wpos, ut_x, ut_z); - unit_info->unit_pos[0] = upos.x; - unit_info->unit_pos[1] = upos.z; + mFI_Wpos2UtNum(&ut_x, &ut_z, wpos); + mCoBG_Unit2UnitInfo_OutOfUnitPos(unit_info, ut_x, ut_z); + mCoBG_Wpos2Upos(&upos, wpos, ut_x, ut_z); + unit_info->unit_pos[0] = upos.x; + unit_info->unit_pos[1] = upos.z; } - /* Area unit triangle -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 -1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 3 -1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 -1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 3 -1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 3 3 -1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 3 3 3 -1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 3 3 3 3 -1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 3 3 3 3 3 -1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 3 3 3 3 3 3 -1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 3 3 3 3 3 3 3 -1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 3 3 3 3 3 3 3 3 -1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 3 3 3 3 3 3 3 3 3 -1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 3 3 3 3 3 3 3 3 3 3 -1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 3 3 3 3 3 3 3 3 3 3 3 3 3 3 -1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 -1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 -1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 -1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 -1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 -1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 -1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 -1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 -1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 -1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 -1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 -1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 -1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 -1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 -1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 -1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 -1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 -1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 -1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 -1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 -1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 -1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 -1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 -1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 +1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 3 +1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 +1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 3 +1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 3 3 +1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 3 3 3 +1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 3 3 3 3 +1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 3 3 3 3 3 +1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 3 3 3 3 3 3 +1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 3 3 3 3 3 3 3 +1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 3 3 3 3 3 3 3 3 +1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 3 3 3 3 3 3 3 3 3 +1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 3 3 3 3 3 3 3 3 3 3 +1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 3 3 3 3 3 3 3 3 3 3 3 3 3 3 +1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 +1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 +1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 +1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 +1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 +1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 +1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 +1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 +1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 +1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 +1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 +1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 +1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 +1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 +1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 +1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 +1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 +1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 +1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 +1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 +1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 +1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 +1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 +1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 Bias towards the top and left triangles. Top: 440 @@ -228,280 +237,292 @@ NOTE: The top of the triangle is denoted as the "bottom" by the devs as it is in /* This function works on a "unit position" which is [-20.0f, 20.0f) in XZ */ static void mCoBG_GetUnitArea(mCoBG_UnitInfo_c* unit_info, s16* unit_area) { - f32 x = unit_info->unit_pos[0]; - f32 z = unit_info->unit_pos[1]; + f32 x = unit_info->unit_pos[0]; + f32 z = unit_info->unit_pos[1]; - // Determine the triangle based on the x and z coordinates - if (x < z) { - if (z > -x) { - unit_area[0] = mCoBG_AREA_S; + // Determine the triangle based on the x and z coordinates + if (x < z) { + if (z > -x) { + unit_area[0] = mCoBG_AREA_S; + } else { + unit_area[0] = mCoBG_AREA_W; + } + } else if (z > -x) { + unit_area[0] = mCoBG_AREA_E; + } else { // z <= x && z <= -x + unit_area[0] = mCoBG_AREA_N; } - else { - unit_area[0] = mCoBG_AREA_W; - } - } - else if (z > -x) { - unit_area[0] = mCoBG_AREA_E; - } - else { // z <= x && z <= -x - unit_area[0] = mCoBG_AREA_N; - } } - static void mCoBG_GetGroundAngleFromVtx3(s_xyz* ground_angle, f32* v0, f32* v1, f32* v2, s16 unit_area) { - if (ground_angle != NULL) { - xyz_t avg; - f32 a0; - f32 a1; - - ground_angle->y = 0; - avg.x = 0.5f * (v1[0] + v2[0]); - avg.y = 0.5f * (v1[1] + v2[1]); - avg.z = 0.5f * (v1[2] + v2[2]); + if (ground_angle != NULL) { + xyz_t avg; + f32 a0; + f32 a1; - switch (unit_area) { - case mCoBG_AREA_N: - { - a0 = v0[2] - avg.z; - a1 = v0[1] - avg.y; - ground_angle->x = atans_table(a0, -a1); + ground_angle->y = 0; + avg.x = 0.5f * (v1[0] + v2[0]); + avg.y = 0.5f * (v1[1] + v2[1]); + avg.z = 0.5f * (v1[2] + v2[2]); - a0 = v1[0] - v2[0]; - a1 = v1[1] - v2[1]; - ground_angle->z = atans_table(a0, a1); - break; - } + switch (unit_area) { + case mCoBG_AREA_N: { + a0 = v0[2] - avg.z; + a1 = v0[1] - avg.y; + ground_angle->x = atans_table(a0, -a1); - case mCoBG_AREA_S: - { - a0 = avg.z - v0[2]; - a1 = -(avg.y - v0[1]); - ground_angle->x = atans_table(a0, a1); + a0 = v1[0] - v2[0]; + a1 = v1[1] - v2[1]; + ground_angle->z = atans_table(a0, a1); + break; + } - a0 = v2[0] - v1[0]; - a1 = v2[1] - v1[1]; - ground_angle->z = atans_table(a0, a1); - break; - } + case mCoBG_AREA_S: { + a0 = avg.z - v0[2]; + a1 = -(avg.y - v0[1]); + ground_angle->x = atans_table(a0, a1); - case mCoBG_AREA_W: - { - a0 = v2[2] - v1[2]; - a1 = v2[1] - v1[1]; - ground_angle->x = atans_table(a0, -a1); - - a0 = v0[0] - avg.x; - a1 = v0[1] - avg.y; - ground_angle->z = atans_table(a0, a1); - break; - } + a0 = v2[0] - v1[0]; + a1 = v2[1] - v1[1]; + ground_angle->z = atans_table(a0, a1); + break; + } - case mCoBG_AREA_E: - { - a0 = v1[2] - v2[2]; - a1 = -(v1[1] - v2[1]); - ground_angle->x = atans_table(a0, a1); + case mCoBG_AREA_W: { + a0 = v2[2] - v1[2]; + a1 = v2[1] - v1[1]; + ground_angle->x = atans_table(a0, -a1); - a0 = avg.x - v0[0]; - a1 = avg.y - v0[1]; - ground_angle->z = atans_table(a0, a1); - break; - } + a0 = v0[0] - avg.x; + a1 = v0[1] - avg.y; + ground_angle->z = atans_table(a0, a1); + break; + } + + case mCoBG_AREA_E: { + a0 = v1[2] - v2[2]; + a1 = -(v1[1] - v2[1]); + ground_angle->x = atans_table(a0, a1); + + a0 = avg.x - v0[0]; + a1 = avg.y - v0[1]; + ground_angle->z = atans_table(a0, a1); + break; + } + } } - } } static void mCoBG_GetArea3Point(s16 area, f32* v0, f32* v1, f32* v2, mCoBG_Collision_u* col) { - switch (area) { - case mCoBG_AREA_N: - { - v0[1] = col->data.center * 10.0f; - v1[0] = mFI_UT_WORLDSIZE_HALF_X_F; - v1[1] = col->data.top_right * 10.0f; - v1[2] = -mFI_UT_WORLDSIZE_HALF_Z_F; - v2[0] = -mFI_UT_WORLDSIZE_HALF_X_F; - v2[1] = col->data.top_left * 10.0f; /* BUG? Shouldn't this be bot_left (top = +Z, bot = -Z) of the triangle */ - v2[2] = -mFI_UT_WORLDSIZE_HALF_Z_F; - break; - } + switch (area) { + case mCoBG_AREA_N: { + v0[1] = col->data.center * 10.0f; + v1[0] = mFI_UT_WORLDSIZE_HALF_X_F; + v1[1] = col->data.top_right * 10.0f; + v1[2] = -mFI_UT_WORLDSIZE_HALF_Z_F; + v2[0] = -mFI_UT_WORLDSIZE_HALF_X_F; + v2[1] = + col->data.top_left * 10.0f; /* BUG? Shouldn't this be bot_left (top = +Z, bot = -Z) of the triangle */ + v2[2] = -mFI_UT_WORLDSIZE_HALF_Z_F; + break; + } - case mCoBG_AREA_W: - { - v0[1] = col->data.center * 10.0f; - v1[0] = -mFI_UT_WORLDSIZE_HALF_X_F; - v1[1] = col->data.top_left * 10.0f; - v1[2] = -mFI_UT_WORLDSIZE_HALF_Z_F; - v2[0] = -mFI_UT_WORLDSIZE_HALF_X_F; - v2[1] = col->data.bot_left * 10.0f; - v2[2] = mFI_UT_WORLDSIZE_HALF_Z_F; - break; - } + case mCoBG_AREA_W: { + v0[1] = col->data.center * 10.0f; + v1[0] = -mFI_UT_WORLDSIZE_HALF_X_F; + v1[1] = col->data.top_left * 10.0f; + v1[2] = -mFI_UT_WORLDSIZE_HALF_Z_F; + v2[0] = -mFI_UT_WORLDSIZE_HALF_X_F; + v2[1] = col->data.bot_left * 10.0f; + v2[2] = mFI_UT_WORLDSIZE_HALF_Z_F; + break; + } - case mCoBG_AREA_S: - { - v0[1] = col->data.center * 10.0f; - v1[0] = -mFI_UT_WORLDSIZE_HALF_X_F; - v1[1] = col->data.bot_left * 10.0f; /* BUG? Shouldn't this be top_left (top = +Z, bot = -Z) of the triangle */ - v1[2] = mFI_UT_WORLDSIZE_HALF_Z_F; - v2[0] = mFI_UT_WORLDSIZE_HALF_X_F; - v2[1] = col->data.bot_right * 10.0f; - v2[2] = mFI_UT_WORLDSIZE_HALF_Z_F; - break; - } + case mCoBG_AREA_S: { + v0[1] = col->data.center * 10.0f; + v1[0] = -mFI_UT_WORLDSIZE_HALF_X_F; + v1[1] = + col->data.bot_left * 10.0f; /* BUG? Shouldn't this be top_left (top = +Z, bot = -Z) of the triangle */ + v1[2] = mFI_UT_WORLDSIZE_HALF_Z_F; + v2[0] = mFI_UT_WORLDSIZE_HALF_X_F; + v2[1] = col->data.bot_right * 10.0f; + v2[2] = mFI_UT_WORLDSIZE_HALF_Z_F; + break; + } - case mCoBG_AREA_E: - { - v0[1] = col->data.center * 10.0f; - v1[0] = mFI_UT_WORLDSIZE_HALF_X_F; - v1[1] = col->data.bot_right * 10.0f; - v1[2] = mFI_UT_WORLDSIZE_HALF_Z_F; - v2[0] = mFI_UT_WORLDSIZE_HALF_X_F; - v2[1] = col->data.top_right * 10.0f; - v2[2] = -mFI_UT_WORLDSIZE_HALF_Z_F; - break; + case mCoBG_AREA_E: { + v0[1] = col->data.center * 10.0f; + v1[0] = mFI_UT_WORLDSIZE_HALF_X_F; + v1[1] = col->data.bot_right * 10.0f; + v1[2] = mFI_UT_WORLDSIZE_HALF_Z_F; + v2[0] = mFI_UT_WORLDSIZE_HALF_X_F; + v2[1] = col->data.top_right * 10.0f; + v2[2] = -mFI_UT_WORLDSIZE_HALF_Z_F; + break; + } } - } } static void mCoBG_GetNormTriangle(xyz_t* norm, s_xyz* ground_angle, mCoBG_Collision_u* col, s16 area) { - f32 v0[3] = { 0.0f, 0.0f, 0.0f }; - f32 v1[3] = { 0.0f, 0.0f, 0.0f }; - f32 v2[3] = { 0.0f, 0.0f, 0.0f }; + f32 v0[3] = { 0.0f, 0.0f, 0.0f }; + f32 v1[3] = { 0.0f, 0.0f, 0.0f }; + f32 v2[3] = { 0.0f, 0.0f, 0.0f }; - mCoBG_GetArea3Point(area, v0, v1, v2, col); - mCoBG_GetNorm_By3Point(norm, v0, v1, v2); - mCoBG_GetGroundAngleFromVtx3(ground_angle, v0, v1, v2, area); + mCoBG_GetArea3Point(area, v0, v1, v2, col); + mCoBG_GetNorm_By3Point(norm, v0, v1, v2); + mCoBG_GetGroundAngleFromVtx3(ground_angle, v0, v1, v2, area); } static mCoBG_ActorInf_c l_ActorInf; -static void mCoBG_AdjustActorY(xyz_t* rev_pos, ACTOR* actor, f32 ground_y, f32 water_y, f32 ground_dist, mCoBG_CheckResult_c* check_res, mCoBG_ActorInf_c* actor_info, int check_water) { - actor->bg_collision_check.ground_y = ground_y; +static void mCoBG_AdjustActorY(xyz_t* rev_pos, ACTOR* actor, f32 ground_y, f32 water_y, f32 ground_dist, + mCoBG_CheckResult_c* check_res, mCoBG_ActorInf_c* actor_info, int check_water) { + actor->bg_collision_check.ground_y = ground_y; - if (check_water) { - f32 actor_y = actor->world.position.y; - f32 actor_foot_y = actor_y + ground_dist; - f32 water_ground_y = (water_y - (mFI_UNIT_BASE_SIZE_F / 2.0f)); + if (check_water) { + f32 actor_y = actor->world.position.y; + f32 actor_foot_y = actor_y + ground_dist; + f32 water_ground_y = (water_y - (mFI_UNIT_BASE_SIZE_F / 2.0f)); - if (water_ground_y >= actor_foot_y) { - rev_pos->y = (water_ground_y - ground_dist) - actor_y; - check_res->is_in_water = TRUE; - check_res->on_ground = TRUE; - actor->position_speed.y = 0.0f; - } - else if (water_y >= actor_foot_y) { - check_res->is_in_water = TRUE; - } - } - else { - f32 actor_y = actor->world.position.y; - f32 actor_foot_y = actor_y + ground_dist; + if (water_ground_y >= actor_foot_y) { + rev_pos->y = (water_ground_y - ground_dist) - actor_y; + check_res->is_in_water = TRUE; + check_res->on_ground = TRUE; + actor->position_speed.y = 0.0f; + } else if (water_y >= actor_foot_y) { + check_res->is_in_water = TRUE; + } + } else { + f32 actor_y; + f32 actor_foot_y; - if (ground_y >= actor_foot_y) { - rev_pos->y = (ground_y - ground_dist) - actor_y; - check_res->on_ground = TRUE; - actor->position_speed.y = 0.0f; // stop actor from moving downward anymore - } - else if (actor_info->old_on_ground && actor_info->old_ground_y > actor_info->ground_y) { - f32 dist_to_ground = ABS(ground_y - actor_foot_y); - f32 xz_vel = sqrtf(SQ(actor_info->speed_xz0[0]) + SQ(actor_info->speed_xz0[1])); +// Aus version adds another water check for the case where +// an actor's foot position is at or below the water height. +#if VERSION >= VER_GAFU01_00 + if (water_y >= actor->world.position.y + ground_dist) { + check_res->is_in_water = TRUE; + } +#endif - if (dist_to_ground <= xz_vel) { - rev_pos->y = (ground_y - ground_dist) - actor->world.position.y; - check_res->on_ground = TRUE; - actor->position_speed.y = 0.0f; - } + actor_y = actor->world.position.y; + actor_foot_y = actor_y + ground_dist; + if (ground_y >= actor_foot_y) { + rev_pos->y = (ground_y - ground_dist) - actor_y; + check_res->on_ground = TRUE; + actor->position_speed.y = 0.0f; // stop actor from moving downward anymore + } else if (actor_info->old_on_ground && actor_info->old_ground_y > actor_info->ground_y) { + f32 dist_to_ground = ABS(ground_y - actor_foot_y); + f32 xz_vel = sqrtf(SQ(actor_info->speed_xz0[0]) + SQ(actor_info->speed_xz0[1])); + + if (dist_to_ground <= xz_vel) { + rev_pos->y = (ground_y - ground_dist) - actor->world.position.y; + check_res->on_ground = TRUE; + actor->position_speed.y = 0.0f; + } + } } - } } static f32 mCoBG_GroundPolygonInfo2BgHeight(xyz_t* norm, mCoBG_UnitInfo_c* unit_info) { - f32 dot = -(norm->y * (unit_info->collision->data.center * 10.0f)) + (norm->x * unit_info->unit_pos[0] + norm->z * unit_info->unit_pos[1]); - return dot / -norm->y; // dot product scaled by y normal + f32 dot = -(norm->y * (unit_info->collision->data.center * 10.0f)) + + (norm->x * unit_info->unit_pos[0] + norm->z * unit_info->unit_pos[1]); + return dot / -norm->y; // dot product scaled by y normal } static void mCoBG_GetSpeedByWpos(f32* speed, ACTOR* actor) { - speed[0] = actor->world.position.x - actor->last_world_position.x; - speed[1] = actor->world.position.z - actor->last_world_position.z; + speed[0] = actor->world.position.x - actor->last_world_position.x; + speed[1] = actor->world.position.z - actor->last_world_position.z; } static void mCoBG_CarryOutReverse(ACTOR* actor, xyz_t rev_pos, s16 type) { - if (type == 0) { - actor->world.position.x += rev_pos.x; - actor->world.position.y += rev_pos.y; - actor->world.position.z += rev_pos.z; - } - - if (actor->bg_collision_check.result.unit_attribute >= mCoBG_ATTRIBUTE_WATER && actor->bg_collision_check.result.unit_attribute <= mCoBG_ATTRIBUTE_RIVER_NE) { - xyz_t pos = actor->world.position; - - f32 water_height = mCoBG_GetWaterHeight_File(pos, __FILE__, 1303); - if ((pos.y + l_ActorInf.ground_dist) <= water_height) { - actor->bg_collision_check.result.is_in_water = TRUE; + if (type == 0) { + actor->world.position.x += rev_pos.x; + actor->world.position.y += rev_pos.y; + actor->world.position.z += rev_pos.z; + } + +// Aus version now considers all true water tile attributes when updating the 'is_in_water' +// flag during a position reversion. +#if VERSION >= VER_GAFU01_00 + if ((actor->bg_collision_check.result.unit_attribute >= mCoBG_ATTRIBUTE_WATER && + actor->bg_collision_check.result.unit_attribute <= mCoBG_ATTRIBUTE_RIVER_NE) || + actor->bg_collision_check.result.unit_attribute == mCoBG_ATTRIBUTE_SEA || + actor->bg_collision_check.result.unit_attribute == mCoBG_ATTRIBUTE_37 || + actor->bg_collision_check.result.unit_attribute == mCoBG_ATTRIBUTE_38) { +#else + if (actor->bg_collision_check.result.unit_attribute >= mCoBG_ATTRIBUTE_WATER && + actor->bg_collision_check.result.unit_attribute <= mCoBG_ATTRIBUTE_RIVER_NE) { +#endif + xyz_t pos = actor->world.position; + +#if VERSION == VER_GAFU01_00 + f32 water_height = mCoBG_GetWaterHeight_File(pos, __FILE__, 1399); +#elif VERSION == VER_GAFE01_00 + f32 water_height = mCoBG_GetWaterHeight_File(pos, __FILE__, 1303); +#endif + if ((pos.y + l_ActorInf.ground_dist) <= water_height) { + actor->bg_collision_check.result.is_in_water = TRUE; + } } - } } static void mCoBG_InitRevpos(xyz_t* rev_pos) { - rev_pos->x = 0.0f; - rev_pos->y = 0.0f; - rev_pos->z = 0.0f; + rev_pos->x = 0.0f; + rev_pos->y = 0.0f; + rev_pos->z = 0.0f; } -static void mCoBG_MakeSizeUnitInfo(mCoBG_UnitInfo_c *unit_info, int ut_x, int ut_z, s16 size) { - int x; - int z; - int start_x; - int start_z; - int end_x; - int end_z; - - start_z = ut_z - (size >> 1); - start_x = ut_x - (size >> 1); - end_z = start_z + size; - end_x = start_x + size; +static void mCoBG_MakeSizeUnitInfo(mCoBG_UnitInfo_c* unit_info, int ut_x, int ut_z, s16 size) { + int x; + int z; + int start_x; + int start_z; + int end_x; + int end_z; - for (z = start_z; z < end_z; z++) { - for (x = start_x; x < end_x; x++) { - mCoBG_Unit2UnitInfo_OutOfUnitPos(unit_info, x, z); - unit_info++; + start_z = ut_z - (size >> 1); + start_x = ut_x - (size >> 1); + end_z = start_z + size; + end_x = start_x + size; + + for (z = start_z; z < end_z; z++) { + for (x = start_x; x < end_x; x++) { + mCoBG_Unit2UnitInfo_OutOfUnitPos(unit_info, x, z); + unit_info++; + } } - } } - static void mCoBG_MakeTab2MoveTail(f32* dst_xz, f32* src_xz) { - f32 x_bias = ABS(src_xz[0]) / (ABS(src_xz[0]) + ABS(src_xz[1])); - f32 z_bias = 1.0f - x_bias; + f32 x_bias = ABS(src_xz[0]) / (ABS(src_xz[0]) + ABS(src_xz[1])); + f32 z_bias = 1.0f - x_bias; - if (src_xz[0] > 0.0f) { - dst_xz[0] -= x_bias * 0.2f; - } - else if (src_xz[0] < 0.0f) { - dst_xz[0] += x_bias * 0.2f; - } + if (src_xz[0] > 0.0f) { + dst_xz[0] -= x_bias * 0.2f; + } else if (src_xz[0] < 0.0f) { + dst_xz[0] += x_bias * 0.2f; + } - if (src_xz[1] > 0.0f) { - dst_xz[1] -= z_bias * 0.2f; - } - else if (src_xz[1] < 0.0f) { - dst_xz[1] += z_bias * 0.2f; - } + if (src_xz[1] > 0.0f) { + dst_xz[1] -= z_bias * 0.2f; + } else if (src_xz[1] < 0.0f) { + dst_xz[1] += z_bias * 0.2f; + } } static u32 mCoBG_SearchAttribute(xyz_t wpos, int direct, s8* cant_dig) { - xyz_t next_ut; + xyz_t next_ut; - wpos.y = 0.0f; - mCoBG_PlussDirectOffset(&next_ut, wpos, direct); - return mCoBG_Wpos2Attribute(next_ut, cant_dig); + wpos.y = 0.0f; + mCoBG_PlussDirectOffset(&next_ut, wpos, direct); + return mCoBG_Wpos2Attribute(next_ut, cant_dig); } -static void mCoBG_RegistCollisionWallInfo(mCoBG_ActorInf_c* actor_inf, mCoBG_WallInfo_c* wall_info, mCoBG_WallHeight_c* wall_height, s16 angle_y, s16 atr) { +static void mCoBG_RegistCollisionWallInfo(mCoBG_ActorInf_c* actor_inf, mCoBG_WallInfo_c* wall_info, + mCoBG_WallHeight_c* wall_height, s16 angle_y, s16 atr) { int i; int count; - + if (wall_height != NULL) { actor_inf->wall_height = *wall_height; } @@ -558,7 +579,7 @@ static void mCoBG_GetWallHeight(mCoBG_WallHeight_c* wall_height, mCoBG_unit_vec_ xyz_t vec; f32 p; f32 t; - + vec.x = end[0] - start[0]; vec.z = end[1] - start[1]; @@ -580,7 +601,8 @@ static void mCoBG_GetWallHeight(mCoBG_WallHeight_c* wall_height, mCoBG_unit_vec_ } } -static int mCoBG_CheckHeightExactly(mCoBG_WallHeight_c* wall_height, f32 pos_y, mCoBG_unit_vec_info_c* unit_vec, f32* point) { +static int mCoBG_CheckHeightExactly(mCoBG_WallHeight_c* wall_height, f32 pos_y, mCoBG_unit_vec_info_c* unit_vec, + f32* point) { mCoBG_WallBounds_c* bounds = &unit_vec->wall_bounds; f32* start = unit_vec->start; f32* end = unit_vec->end; @@ -594,13 +616,17 @@ static int mCoBG_CheckHeightExactly(mCoBG_WallHeight_c* wall_height, f32 pos_y, return TRUE; } } else { - switch(unit_vec->wall_name) { + switch (unit_vec->wall_name) { case mCoBG_WALL_LEFT: case mCoBG_WALL_RIGHT: div = end[1] - start[1]; if (!F32_IS_ZERO(div)) { - wall_height->top = bounds->start_top + (point[1] - start[1]) * ((bounds->end_top - bounds->start_top) / (end[1] - start[1])); - wall_height->bot = bounds->start_btm + (point[1] - start[1]) * ((bounds->end_btm - bounds->start_btm) / (end[1] - start[1])); + wall_height->top = + bounds->start_top + + (point[1] - start[1]) * ((bounds->end_top - bounds->start_top) / (end[1] - start[1])); + wall_height->bot = + bounds->start_btm + + (point[1] - start[1]) * ((bounds->end_btm - bounds->start_btm) / (end[1] - start[1])); if (pos_y + 3.0f <= wall_height->top) { return TRUE; @@ -611,8 +637,12 @@ static int mCoBG_CheckHeightExactly(mCoBG_WallHeight_c* wall_height, f32 pos_y, case mCoBG_WALL_DOWN: div = end[0] - start[0]; if (!F32_IS_ZERO(div)) { - wall_height->top = bounds->start_top + (point[0] - start[0]) * ((bounds->end_top - bounds->start_top) / (end[0] - start[0])); - wall_height->bot = bounds->start_btm + (point[0] - start[0]) * ((bounds->end_btm - bounds->start_btm) / (end[0] - start[0])); + wall_height->top = + bounds->start_top + + (point[0] - start[0]) * ((bounds->end_top - bounds->start_top) / (end[0] - start[0])); + wall_height->bot = + bounds->start_btm + + (point[0] - start[0]) * ((bounds->end_btm - bounds->start_btm) / (end[0] - start[0])); if (pos_y + 3.0f <= wall_height->top) { return TRUE; @@ -637,7 +667,8 @@ static int mCoBG_SearchWallFront(f32* point, mCoBG_unit_vec_info_c* unit_vec) { } static int mCoBG_Check45Angle(s16 angle0, s16 angle1) { - if (ABS(angle1 - angle0) <= (u16)DEG2SHORT_ANGLE(45.0f) || ABS(angle1 - angle0) >= (u16)(DEG2SHORT_ANGLE(-45.0f) - 1)) { + if (ABS(angle1 - angle0) <= (u16)DEG2SHORT_ANGLE(45.0f) || + ABS(angle1 - angle0) >= (u16)(DEG2SHORT_ANGLE(-45.0f) - 1)) { return TRUE; } @@ -665,7 +696,7 @@ static void mCoBG_RegistWallCount(mCoBG_CheckResult_c* col_res, mCoBG_WallInfo_c f32 z1 = cosf_table(r1); s16 avg_angle = atans_table((z0 + z1) * 0.5f, (x0 + x1) * 0.5f); - if (mCoBG_Check45Angle((DEG2SHORT_ANGLE2(180.0f)-1) + avg_angle, angle)) { + if (mCoBG_Check45Angle((DEG2SHORT_ANGLE2(180.0f) - 1) + avg_angle, angle)) { col_res->unk_flag4 = TRUE; } } @@ -687,7 +718,7 @@ static void mCoBG_MakeHitWallFalg(mCoBG_CheckResult_c* col_res, mCoBG_WallInfo_c } static void mCoBG_SearchColOwnPart(s16 actor_angleY, s16 wall_angleY, mCoBG_Check_c* check_p, s16 wall_type) { - if (mCoBG_Check45Angle((wall_angleY + DEG2SHORT_ANGLE2(180.0f)-1), actor_angleY)) { + if (mCoBG_Check45Angle((wall_angleY + DEG2SHORT_ANGLE2(180.0f) - 1), actor_angleY)) { if (wall_type == mCoBG_WALL_TYPE0) { check_p->result.hit_wall |= mCoBG_HIT_WALL_FRONT; check_p->in_front_wall_angle_y = wall_angleY; @@ -726,7 +757,8 @@ static void mCoBG_MakePartDirectHitWallFlag(ACTOR* actorx) { s16 actor_angleY = actorx->shape_info.rotation.y; int i; - if (check_p->result.hit_wall != mCoBG_DIDNT_HIT_WALL || check_p->result.hit_attribute_wall != mCoBG_DIDNT_HIT_WALL) { + if (check_p->result.hit_wall != mCoBG_DIDNT_HIT_WALL || + check_p->result.hit_attribute_wall != mCoBG_DIDNT_HIT_WALL) { for (i = 0; i < count; i++) { wall_angleY = check_p->wall_info[i].angleY; wall_type = check_p->wall_info[i].type; @@ -737,11 +769,12 @@ static void mCoBG_MakePartDirectHitWallFlag(ACTOR* actorx) { if (count == 2) { u16 dangle = check_p->wall_info[0].angleY - check_p->wall_info[1].angleY; - if (dangle > (DEG2SHORT_ANGLE2(180.0f)-3) && dangle < (DEG2SHORT_ANGLE2(180.0f)+3)) { + if (dangle > (DEG2SHORT_ANGLE2(180.0f) - 3) && dangle < (DEG2SHORT_ANGLE2(180.0f) + 3)) { check_p->result.unk_flag2 = TRUE; } - if (check_p->wall_info[0].type == mCoBG_WALL_TYPE0 && check_p->wall_info[1].type == mCoBG_WALL_TYPE0 && dangle < DEG2SHORT_ANGLE2(67.5f)) { + if (check_p->wall_info[0].type == mCoBG_WALL_TYPE0 && check_p->wall_info[1].type == mCoBG_WALL_TYPE0 && + dangle < DEG2SHORT_ANGLE2(67.5f)) { check_p->result.unk_flag2 = TRUE; } } @@ -767,7 +800,8 @@ static s16 mCoBG_GetWallKind(mCoBG_unit_vec_info_c* unit_vec) { return mCoBG_WALL_KIND_NORMAL; } -static void mCoBG_Cross2Reverse_NormalWall(f32* reverse, mCoBG_unit_vec_info_c* unit_vec, f32* actor_start, f32* actor_end, mCoBG_ActorInf_c* actor_inf, ACTOR* actorx) { +static void mCoBG_Cross2Reverse_NormalWall(f32* reverse, mCoBG_unit_vec_info_c* unit_vec, f32* actor_start, + f32* actor_end, mCoBG_ActorInf_c* actor_inf, ACTOR* actorx) { if (mCoBG_RoughCheckWallHeight(actor_inf->old_ground_y - 5.0f, &unit_vec->wall_bounds)) { mCoBG_WallHeight_c height; @@ -782,7 +816,8 @@ static void mCoBG_Cross2Reverse_NormalWall(f32* reverse, mCoBG_unit_vec_info_c* reverse[0] = unit_vec->normal[0] * rev_dist; reverse[1] = unit_vec->normal[1] * rev_dist; - mCoBG_RegistCollisionWallInfo(actor_inf, actor_inf->wall_info, &height, unit_vec->normal_angle, unit_vec->atr_wall); + mCoBG_RegistCollisionWallInfo(actor_inf, actor_inf->wall_info, &height, unit_vec->normal_angle, + unit_vec->atr_wall); if (unit_vec->regist_p != NULL) { mCoBG_SetMoveBgContactSide(unit_vec->regist_p, actorx, unit_vec->normal_angle); } @@ -791,34 +826,42 @@ static void mCoBG_Cross2Reverse_NormalWall(f32* reverse, mCoBG_unit_vec_info_c* } } -static void mCoBG_Cross2Reverse_AttributeWall(f32* reverse, mCoBG_unit_vec_info_c* unit_vec, f32* actor_start, f32* actor_end, mCoBG_ActorInf_c* actor_inf, ACTOR* actorx) { +static void mCoBG_Cross2Reverse_AttributeWall(f32* reverse, mCoBG_unit_vec_info_c* unit_vec, f32* actor_start, + f32* actor_end, mCoBG_ActorInf_c* actor_inf, ACTOR* actorx) { if (mCoBG_GetCrossJudge_2Vector(actor_start, actor_end, unit_vec->start, unit_vec->end)) { f32 cross[2]; - + mCoBG_GetCross2Line(cross, actor_start, actor_end, unit_vec->start, unit_vec->end); reverse[0] = cross[0] - actor_end[0]; reverse[1] = cross[1] - actor_end[1]; - mCoBG_RegistCollisionWallInfo(actor_inf, actor_inf->wall_info, NULL, unit_vec->normal_angle, unit_vec->atr_wall); + mCoBG_RegistCollisionWallInfo(actor_inf, actor_inf->wall_info, NULL, unit_vec->normal_angle, + unit_vec->atr_wall); } } -typedef void (*mCoBG_CROSS_REV_PROC)(f32* reverse, mCoBG_unit_vec_info_c* unit_vec, f32* actor_start, f32* actor_end, mCoBG_ActorInf_c* actor_inf, ACTOR* actorx); +typedef void (*mCoBG_CROSS_REV_PROC)(f32* reverse, mCoBG_unit_vec_info_c* unit_vec, f32* actor_start, f32* actor_end, + mCoBG_ActorInf_c* actor_inf, ACTOR* actorx); -static void mCoBG_Cross2Reverse(f32* reverse, mCoBG_unit_vec_info_c* unit_vec, int unit, f32* actor_start, f32* actor_end, mCoBG_ActorInf_c* actor_info, ACTOR* actorx) { +static void mCoBG_Cross2Reverse(f32* reverse, mCoBG_unit_vec_info_c* unit_vec, int unit, f32* actor_start, + f32* actor_end, mCoBG_ActorInf_c* actor_info, ACTOR* actorx) { f32 speed[2]; speed[0] = actor_end[0] - actor_start[0]; speed[1] = actor_end[1] - actor_start[1]; - if (mCoBG_GetPointInfoFrontLine(unit_vec->start, actor_start, unit_vec->normal) && mCoBG_JudgeWallFromVector(speed, unit_vec->normal)) { - static mCoBG_CROSS_REV_PROC cross_rev_proc[] = { &mCoBG_Cross2Reverse_NormalWall, &mCoBG_Cross2Reverse_AttributeWall, &mCoBG_Cross2Reverse_NormalWall }; + if (mCoBG_GetPointInfoFrontLine(unit_vec->start, actor_start, unit_vec->normal) && + mCoBG_JudgeWallFromVector(speed, unit_vec->normal)) { + static mCoBG_CROSS_REV_PROC cross_rev_proc[] = { &mCoBG_Cross2Reverse_NormalWall, + &mCoBG_Cross2Reverse_AttributeWall, + &mCoBG_Cross2Reverse_NormalWall }; s16 kind = mCoBG_GetWallKind(unit_vec); (*cross_rev_proc[kind])(reverse, unit_vec, actor_start, actor_end, actor_info, actorx); } } -static int mCoBG_Distance2Reverse_NormalWall(f32* reverse, mCoBG_unit_vec_info_c* unit_vec, f32* actor_start, f32* actor_end, mCoBG_ActorInf_c* actor_info, ACTOR* actorx) { +static int mCoBG_Distance2Reverse_NormalWall(f32* reverse, mCoBG_unit_vec_info_c* unit_vec, f32* actor_start, + f32* actor_end, mCoBG_ActorInf_c* actor_info, ACTOR* actorx) { f32 dist; if (mCoBG_GetDistPointAndLine2D_Norm(&dist, unit_vec->start, unit_vec->end, unit_vec->normal, actor_end)) { @@ -826,12 +869,14 @@ static int mCoBG_Distance2Reverse_NormalWall(f32* reverse, mCoBG_unit_vec_info_c if (dist < actor_info->range) { - if (mCoBG_RoughCheckWallHeight(actor_info->old_ground_y - 5.0f, &unit_vec->wall_bounds) && mCoBG_CheckHeightExactly(&height, actor_info->old_ground_y - 5.0f, unit_vec, actor_end)) { + if (mCoBG_RoughCheckWallHeight(actor_info->old_ground_y - 5.0f, &unit_vec->wall_bounds) && + mCoBG_CheckHeightExactly(&height, actor_info->old_ground_y - 5.0f, unit_vec, actor_end)) { f32 rev_dist = (actor_info->range - dist) + 0.00001f; reverse[0] = unit_vec->normal[0] * rev_dist; reverse[1] = unit_vec->normal[1] * rev_dist; - mCoBG_RegistCollisionWallInfo(actor_info, actor_info->wall_info, &height, unit_vec->normal_angle, unit_vec->atr_wall); + mCoBG_RegistCollisionWallInfo(actor_info, actor_info->wall_info, &height, unit_vec->normal_angle, + unit_vec->atr_wall); if (unit_vec->regist_p != NULL) { mCoBG_SetMoveBgContactSide(unit_vec->regist_p, actorx, unit_vec->normal_angle); @@ -839,8 +884,11 @@ static int mCoBG_Distance2Reverse_NormalWall(f32* reverse, mCoBG_unit_vec_info_c return TRUE; } - } else if (ABS(dist - actor_info->range) < 2.7f && mCoBG_RoughCheckWallHeight(actor_info->old_ground_y - 5.0f, &unit_vec->wall_bounds) && mCoBG_CheckHeightExactly(&height, actor_info->old_ground_y - 5.0f, unit_vec, actor_end)) { - mCoBG_RegistCollisionWallInfo(actor_info, actor_info->wall_info, &height, unit_vec->normal_angle, unit_vec->atr_wall); + } else if (ABS(dist - actor_info->range) < 2.7f && + mCoBG_RoughCheckWallHeight(actor_info->old_ground_y - 5.0f, &unit_vec->wall_bounds) && + mCoBG_CheckHeightExactly(&height, actor_info->old_ground_y - 5.0f, unit_vec, actor_end)) { + mCoBG_RegistCollisionWallInfo(actor_info, actor_info->wall_info, &height, unit_vec->normal_angle, + unit_vec->atr_wall); if (unit_vec->regist_p != NULL) { mCoBG_SetMoveBgContactSide(unit_vec->regist_p, actorx, unit_vec->normal_angle); @@ -853,7 +901,8 @@ static int mCoBG_Distance2Reverse_NormalWall(f32* reverse, mCoBG_unit_vec_info_c return FALSE; } -static void mCoBG_GetSpecialDistanceReverse(f32* reverse, f32* actor_end, mCoBG_unit_vec_info_c* unit_vec, f32* cross0, f32* cross1, f32* edge) { +static void mCoBG_GetSpecialDistanceReverse(f32* reverse, f32* actor_end, mCoBG_unit_vec_info_c* unit_vec, f32* cross0, + f32* cross1, f32* edge) { if (!mCoBG_GetPointInfoFrontLine(unit_vec->start, cross0, unit_vec->normal)) { reverse[0] = edge[0] - cross0[0]; reverse[1] = edge[1] - cross0[1]; @@ -877,7 +926,7 @@ static int mCoBG_CheckDistSPCheck(mCoBG_unit_vec_info_c* unit_vec, f32* point) { if ((ABS(start[0] - point[0]) < 0.1f && ABS(start[1] - point[1]) < 0.1f) || (ABS(end[0] - point[0]) < 0.1f && ABS(end[1] - point[1]) < 0.1f)) { - if ((u16)(unit_vec->normal_angle - cur_unit_vec_p->normal_angle) < (DEG2SHORT_ANGLE2(90.0f)-0x100)) { + if ((u16)(unit_vec->normal_angle - cur_unit_vec_p->normal_angle) < (DEG2SHORT_ANGLE2(90.0f) - 0x100)) { return FALSE; } } @@ -889,8 +938,10 @@ static int mCoBG_CheckDistSPCheck(mCoBG_unit_vec_info_c* unit_vec, f32* point) { return TRUE; } -static int mCoBG_Distance2Reverse_NormalWall_Special(f32* reverse, mCoBG_unit_vec_info_c* unit_vec, f32* actor_start, f32* actor_end, mCoBG_ActorInf_c* actor_info, ACTOR* actorx) { - if (mCoBG_GetPointInfoFrontLine(unit_vec->start, actor_end, unit_vec->normal) && mCoBG_GetPointInfoFrontLine(unit_vec->start, actor_start, unit_vec->normal)) { +static int mCoBG_Distance2Reverse_NormalWall_Special(f32* reverse, mCoBG_unit_vec_info_c* unit_vec, f32* actor_start, + f32* actor_end, mCoBG_ActorInf_c* actor_info, ACTOR* actorx) { + if (mCoBG_GetPointInfoFrontLine(unit_vec->start, actor_end, unit_vec->normal) && + mCoBG_GetPointInfoFrontLine(unit_vec->start, actor_start, unit_vec->normal)) { f32 dist; mCoBG_GetDistPointAndLine2D_Norm(&dist, unit_vec->start, unit_vec->end, unit_vec->normal, actor_end); @@ -903,14 +954,16 @@ static int mCoBG_Distance2Reverse_NormalWall_Special(f32* reverse, mCoBG_unit_ve return FALSE; } - if (mCoBG_GetCrossCircleAndLine2Dvector(cross0, cross1, unit_vec->start, unit_vec->normal, actor_end, actor_info->range)) { + if (mCoBG_GetCrossCircleAndLine2Dvector(cross0, cross1, unit_vec->start, unit_vec->normal, actor_end, + actor_info->range)) { mCoBG_WallHeight_c height; height.top = unit_vec->wall_bounds.start_top; height.bot = unit_vec->wall_bounds.start_btm; if ((actor_info->old_ground_y - 5.0f) + 3.0f <= height.top) { mCoBG_GetSpecialDistanceReverse(reverse, actor_end, unit_vec, cross0, cross1, unit_vec->start); - mCoBG_RegistCollisionWallInfo(actor_info, actor_info->wall_info, &height, unit_vec->normal_angle, unit_vec->atr_wall); + mCoBG_RegistCollisionWallInfo(actor_info, actor_info->wall_info, &height, + unit_vec->normal_angle, unit_vec->atr_wall); if (unit_vec->regist_p != NULL) { mCoBG_SetMoveBgContactSide(unit_vec->regist_p, actorx, unit_vec->normal_angle); } @@ -923,14 +976,16 @@ static int mCoBG_Distance2Reverse_NormalWall_Special(f32* reverse, mCoBG_unit_ve return FALSE; } - if (mCoBG_GetCrossCircleAndLine2Dvector(cross0, cross1, unit_vec->end, unit_vec->normal, actor_end, actor_info->range)) { + if (mCoBG_GetCrossCircleAndLine2Dvector(cross0, cross1, unit_vec->end, unit_vec->normal, actor_end, + actor_info->range)) { mCoBG_WallHeight_c height; height.top = unit_vec->wall_bounds.end_top; height.bot = unit_vec->wall_bounds.end_btm; if ((actor_info->old_ground_y - 5.0f) + 3.0f <= height.top) { mCoBG_GetSpecialDistanceReverse(reverse, actor_end, unit_vec, cross0, cross1, unit_vec->end); - mCoBG_RegistCollisionWallInfo(actor_info, actor_info->wall_info, &height, unit_vec->normal_angle, unit_vec->atr_wall); + mCoBG_RegistCollisionWallInfo(actor_info, actor_info->wall_info, &height, + unit_vec->normal_angle, unit_vec->atr_wall); if (unit_vec->regist_p != NULL) { mCoBG_SetMoveBgContactSide(unit_vec->regist_p, actorx, unit_vec->normal_angle); } @@ -945,7 +1000,8 @@ static int mCoBG_Distance2Reverse_NormalWall_Special(f32* reverse, mCoBG_unit_ve return FALSE; } -static int mCoBG_Distance2Reverse_AttributeWall(f32* reverse, mCoBG_unit_vec_info_c* unit_vec, f32* actor_start, f32* actor_end, mCoBG_ActorInf_c* actor_info, ACTOR* actorx) { +static int mCoBG_Distance2Reverse_AttributeWall(f32* reverse, mCoBG_unit_vec_info_c* unit_vec, f32* actor_start, + f32* actor_end, mCoBG_ActorInf_c* actor_info, ACTOR* actorx) { f32 dist; if (mCoBG_GetDistPointAndLine2D_Norm(&dist, unit_vec->start, unit_vec->end, unit_vec->normal, actor_end)) { @@ -954,10 +1010,12 @@ static int mCoBG_Distance2Reverse_AttributeWall(f32* reverse, mCoBG_unit_vec_inf reverse[0] = unit_vec->normal[0] * rev_dist; reverse[1] = unit_vec->normal[1] * rev_dist; - mCoBG_RegistCollisionWallInfo(actor_info, actor_info->wall_info, NULL, unit_vec->normal_angle, unit_vec->atr_wall); + mCoBG_RegistCollisionWallInfo(actor_info, actor_info->wall_info, NULL, unit_vec->normal_angle, + unit_vec->atr_wall); return TRUE; } else if (ABS(dist - actor_info->range) < 2.7f) { - mCoBG_RegistCollisionWallInfo(actor_info, actor_info->wall_info, NULL, unit_vec->normal_angle, unit_vec->atr_wall); + mCoBG_RegistCollisionWallInfo(actor_info, actor_info->wall_info, NULL, unit_vec->normal_angle, + unit_vec->atr_wall); return TRUE; } } @@ -965,8 +1023,10 @@ static int mCoBG_Distance2Reverse_AttributeWall(f32* reverse, mCoBG_unit_vec_inf return FALSE; } -static int mCoBG_Distance2Reverse_AttributeWall_Special(f32* reverse, mCoBG_unit_vec_info_c* unit_vec, f32* actor_start, f32* actor_end, mCoBG_ActorInf_c* actor_info, ACTOR* actorx) { - if (mCoBG_GetPointInfoFrontLine(unit_vec->start, actor_end, unit_vec->normal) && mCoBG_GetPointInfoFrontLine(unit_vec->start, actor_start, unit_vec->normal)) { +static int mCoBG_Distance2Reverse_AttributeWall_Special(f32* reverse, mCoBG_unit_vec_info_c* unit_vec, f32* actor_start, + f32* actor_end, mCoBG_ActorInf_c* actor_info, ACTOR* actorx) { + if (mCoBG_GetPointInfoFrontLine(unit_vec->start, actor_end, unit_vec->normal) && + mCoBG_GetPointInfoFrontLine(unit_vec->start, actor_start, unit_vec->normal)) { f32 dist; mCoBG_GetDistPointAndLine2D_Norm(&dist, unit_vec->start, unit_vec->end, unit_vec->normal, actor_end); @@ -979,9 +1039,11 @@ static int mCoBG_Distance2Reverse_AttributeWall_Special(f32* reverse, mCoBG_unit return FALSE; } - if (mCoBG_GetCrossCircleAndLine2Dvector(cross0, cross1, unit_vec->start, unit_vec->normal, actor_end, actor_info->range)) { + if (mCoBG_GetCrossCircleAndLine2Dvector(cross0, cross1, unit_vec->start, unit_vec->normal, actor_end, + actor_info->range)) { mCoBG_GetSpecialDistanceReverse(reverse, actor_end, unit_vec, cross0, cross1, unit_vec->start); - mCoBG_RegistCollisionWallInfo(actor_info, actor_info->wall_info, NULL, unit_vec->normal_angle, unit_vec->atr_wall); + mCoBG_RegistCollisionWallInfo(actor_info, actor_info->wall_info, NULL, unit_vec->normal_angle, + unit_vec->atr_wall); return TRUE; } } else if (mCoBG_JudgePointInCircle(unit_vec->end, actor_end, actor_info->range)) { @@ -989,9 +1051,11 @@ static int mCoBG_Distance2Reverse_AttributeWall_Special(f32* reverse, mCoBG_unit return FALSE; } - if (mCoBG_GetCrossCircleAndLine2Dvector(cross0, cross1, unit_vec->end, unit_vec->normal, actor_end, actor_info->range)) { + if (mCoBG_GetCrossCircleAndLine2Dvector(cross0, cross1, unit_vec->end, unit_vec->normal, actor_end, + actor_info->range)) { mCoBG_GetSpecialDistanceReverse(reverse, actor_end, unit_vec, cross0, cross1, unit_vec->end); - mCoBG_RegistCollisionWallInfo(actor_info, actor_info->wall_info, NULL, unit_vec->normal_angle, unit_vec->atr_wall); + mCoBG_RegistCollisionWallInfo(actor_info, actor_info->wall_info, NULL, unit_vec->normal_angle, + unit_vec->atr_wall); return TRUE; } } @@ -1001,20 +1065,40 @@ static int mCoBG_Distance2Reverse_AttributeWall_Special(f32* reverse, mCoBG_unit return FALSE; } -typedef int (*mCoBG_DIST_REV_PROC)(f32* reverse, mCoBG_unit_vec_info_c* unit_vec, f32* actor_start, f32* actor_end, mCoBG_ActorInf_c* actor_info, ACTOR* actorx); -typedef int (*mCoBG_DIST_REV_PLAYER_PROC)(f32* reverse, mCoBG_unit_vec_info_c* unit_vec, f32* actor_start, f32* actor_end, mCoBG_ActorInf_c* actor_info, ACTOR* actorx); +typedef int (*mCoBG_DIST_REV_PROC)(f32* reverse, mCoBG_unit_vec_info_c* unit_vec, f32* actor_start, f32* actor_end, + mCoBG_ActorInf_c* actor_info, ACTOR* actorx); +typedef int (*mCoBG_DIST_REV_PLAYER_PROC)(f32* reverse, mCoBG_unit_vec_info_c* unit_vec, f32* actor_start, + f32* actor_end, mCoBG_ActorInf_c* actor_info, ACTOR* actorx); -static void mCoBG_Distance2Reverse(f32* reverse, mCoBG_unit_vec_info_c* unit_vec, int unit, f32* actor_start, f32* actor_end, mCoBG_ActorInf_c* actor_info, ACTOR* actorx) { - static mCoBG_DIST_REV_PROC dist_rev_proc[] = { &mCoBG_Distance2Reverse_NormalWall, &mCoBG_Distance2Reverse_AttributeWall, &mCoBG_Distance2Reverse_NormalWall }; - static mCoBG_DIST_REV_PLAYER_PROC dist_rev_proc_player[] = { &mCoBG_Distance2Reverse_NormalWall_Special, &mCoBG_Distance2Reverse_AttributeWall_Special, &mCoBG_Distance2Reverse_NormalWall_Special }; +// GAFU01 adds a secondary distance check for the actor end pos if the actor +// is the "virtual" actor. +static void mCoBG_Distance2Reverse(f32* reverse, mCoBG_unit_vec_info_c* unit_vec, int unit, f32* actor_start, + f32* actor_end, mCoBG_ActorInf_c* actor_info, ACTOR* actorx) { + static mCoBG_DIST_REV_PROC dist_rev_proc[] = { + &mCoBG_Distance2Reverse_NormalWall, + &mCoBG_Distance2Reverse_AttributeWall, + &mCoBG_Distance2Reverse_NormalWall, + }; + static mCoBG_DIST_REV_PLAYER_PROC dist_rev_proc_player[] = { + &mCoBG_Distance2Reverse_NormalWall_Special, + &mCoBG_Distance2Reverse_AttributeWall_Special, + &mCoBG_Distance2Reverse_NormalWall_Special, + }; s16 kind; if (mCoBG_GetPointInfoFrontLine(unit_vec->start, actor_start, unit_vec->normal)) { switch (actor_info->check_type) { case mCoBG_CHECK_TYPE_NORMAL: if (mCoBG_RangeCheckLinePoint(unit_vec->start, unit_vec->end, actor_start)) { - kind = mCoBG_GetWallKind(unit_vec); - (*dist_rev_proc[kind])(reverse, unit_vec, actor_start, actor_end, actor_info, actorx); + if (actorx->id == mCoBG_VIRTUAL_ACTOR_ID) { + if (mCoBG_RangeCheckLinePoint(unit_vec->start, unit_vec->end, actor_end)) { + kind = mCoBG_GetWallKind(unit_vec); + (*dist_rev_proc[kind])(reverse, unit_vec, actor_start, actor_end, actor_info, actorx); + } + } else { + kind = mCoBG_GetWallKind(unit_vec); + (*dist_rev_proc[kind])(reverse, unit_vec, actor_start, actor_end, actor_info, actorx); + } } break; default: @@ -1055,9 +1139,9 @@ static void mCoBG_MergeSortFloat(f32* data, int first, int last) { bk = 0; while (pre < pre_count && bk < bk_count) { if (pre_work[pre] <= bk_work[bk]) { - data[set++] = pre_work[pre++]; + data[set++] = pre_work[pre++]; } else { - data[set++] = bk_work[bk++]; + data[set++] = bk_work[bk++]; } } @@ -1115,7 +1199,8 @@ static void mCoBG_GetWallPriority(u8* prio_tbl, mCoBG_vec_info_c* vec_info, f32* } } -static void mCoBG_GetWallReverse(mCoBG_ActorInf_c* actor_info, const xyz_t* pos, mCoBG_vec_info_c* vec_info, ACTOR* actorx) { +static void mCoBG_GetWallReverse(mCoBG_ActorInf_c* actor_info, const xyz_t* pos, mCoBG_vec_info_c* vec_info, + ACTOR* actorx) { mCoBG_unit_vec_info_c* unit_vec; f32 actor_start[2]; f32 actor_end[2]; @@ -1157,12 +1242,12 @@ static void mCoBG_GetWallReverse(mCoBG_ActorInf_c* actor_info, const xyz_t* pos, for (j = 0; j < count; j++) { rev[0] = 0.0f; rev[1] = 0.0f; - mCoBG_Distance2Reverse(rev, &unit_vec[prio_tbl[j]], prio_tbl[j], actor_start, actor_end, actor_info, actorx); + mCoBG_Distance2Reverse(rev, &unit_vec[prio_tbl[j]], prio_tbl[j], actor_start, actor_end, actor_info, + actorx); actor_end[0] += rev[0]; actor_end[1] += rev[1]; } - unit_vec = vec_info->unit; for (i = 0; i < count; i++) { rev[0] = 0.0f; @@ -1175,7 +1260,7 @@ static void mCoBG_GetWallReverse(mCoBG_ActorInf_c* actor_info, const xyz_t* pos, } else { f32 rev[2]; f32 spd = sqrtf(SQ(speed[0]) + SQ(speed[1])); - + if (spd > actor_info->range * 0.5f) { unit_vec = vec_info->unit; for (unit = 0; unit < count; unit++) { @@ -1222,61 +1307,65 @@ static mCoBG_UnitInfo_c l_crtutInf[50]; static void mCoBG_WallCheck(ACTOR* actorx, mCoBG_ActorInf_c* actor_info, s16 atr_wall, mCoBG_Check_c* check_p) { int ux; int uz; + // GAFU01 moves initialization to function start + xyz_t pos; + xyz_t rev0 = { 0.0f, 0.0f, 0.0f }; + xyz_t rev1 = { 0.0f, 0.0f, 0.0f }; bzero(l_crtutInf, sizeof(l_crtutInf)); bzero(&l_VecInf, sizeof(l_VecInf)); mCoBG_GetSpeedByWpos(l_ActorInf.speed_xz0, actorx); mFI_Wpos2UtNum(&ux, &uz, actor_info->center_pos); mCoBG_MakeSizeUnitInfo(l_crtutInf, ux, uz, actor_info->ut_count); - if (actorx->id == mAc_PROFILE_PLAYER && (ABS(l_ActorInf.speed_xz0[0]) > 100.0f || ABS(l_ActorInf.speed_xz0[1]) > 100.0f)) { + if (actorx->id == mAc_PROFILE_PLAYER && + (ABS(l_ActorInf.speed_xz0[0]) > 100.0f || ABS(l_ActorInf.speed_xz0[1]) > 100.0f)) { return; } - mCoBG_MakeUnitVector(&l_VecInf, l_crtutInf, actor_info->ut_count, actor_info->check_type, atr_wall, actor_info->old_on_ground, actor_info->old_in_water); - if (actorx->id != mAc_PROFILE_GYOEI) { + mCoBG_MakeUnitVector(&l_VecInf, l_crtutInf, actor_info->ut_count, actor_info->check_type, atr_wall, + actor_info->old_on_ground, actor_info->old_in_water); + + // GAFU01 added profile filter check for the gyoei shadow that happens when + // releasing a fish or scaring it away. + if (actorx->id != mAc_PROFILE_GYOEI && actorx->id != mAc_PROFILE_GYO_KAGE) { mCoBG_MakeMoveBgVector(&l_VecInf, &l_mBgMgr, &actorx->world.position, actor_info->check_type); } - mCoBG_MakeColumnCollisionData(l_VecInf.column, &l_VecInf.col_count, l_crtutInf, actor_info->ut_count, actor_info->old_on_ground, NULL, l_ActorInf._68, l_ActorInf._6C); + mCoBG_MakeColumnCollisionData(actorx, l_VecInf.column, &l_VecInf.col_count, l_crtutInf, actor_info->ut_count, + actor_info->old_on_ground, NULL, l_ActorInf._68, l_ActorInf._6C); mCoBG_MakeCircleDefenceWall(actor_info, atr_wall); + + pos.x = actorx->world.position.x + actor_info->rev_pos.x; + pos.y = actorx->world.position.y + actor_info->rev_pos.y; + pos.z = actorx->world.position.z + actor_info->rev_pos.z; + mCoBG_ColumnWallCheck(&rev0, actor_info, &pos, l_VecInf.column, l_VecInf.col_count, atr_wall); + actor_info->rev_pos.x += rev0.x; + actor_info->rev_pos.y += rev0.y; + actor_info->rev_pos.z += rev0.z; - { - xyz_t pos; - xyz_t rev0 = { 0.0f, 0.0f, 0.0f }; - xyz_t rev1 = { 0.0f, 0.0f, 0.0f }; + pos.x = actorx->world.position.x + actor_info->rev_pos.x; + pos.y = actorx->world.position.y + actor_info->rev_pos.y; + pos.z = actorx->world.position.z + actor_info->rev_pos.z; + mCoBG_ColumnWallCheck(&rev1, actor_info, &pos, mCoBG_decal_circle, mCoBG_regist_decal_circle_count, atr_wall); + actor_info->rev_pos.x += rev1.x; + actor_info->rev_pos.y += rev1.y; + actor_info->rev_pos.z += rev1.z; - pos.x = actorx->world.position.x + actor_info->rev_pos.x; - pos.y = actorx->world.position.y + actor_info->rev_pos.y; - pos.z = actorx->world.position.z + actor_info->rev_pos.z; - mCoBG_ColumnWallCheck(&rev0, actor_info, &pos, l_VecInf.column, l_VecInf.col_count, atr_wall); - actor_info->rev_pos.x += rev0.x; - actor_info->rev_pos.y += rev0.y; - actor_info->rev_pos.z += rev0.z; + actorx->world.position.x += actor_info->rev_pos.x; + actorx->world.position.y += actor_info->rev_pos.y; + actorx->world.position.z += actor_info->rev_pos.z; + mCoBG_GetWallReverse(actor_info, &actorx->world.position, &l_VecInf, actorx); + mCoBG_MakeHitWallFalg(&actorx->bg_collision_check.result, actor_info->wall_info); - pos.x = actorx->world.position.x + actor_info->rev_pos.x; - pos.y = actorx->world.position.y + actor_info->rev_pos.y; - pos.z = actorx->world.position.z + actor_info->rev_pos.z; - mCoBG_ColumnWallCheck(&rev1, actor_info, &pos, mCoBG_decal_circle, mCoBG_regist_decal_circle_count, atr_wall); - actor_info->rev_pos.x += rev1.x; - actor_info->rev_pos.y += rev1.y; - actor_info->rev_pos.z += rev1.z; + actorx->bg_collision_check.wall_bottom_y = actor_info->wall_height.bot; + actorx->bg_collision_check.wall_top_y = actor_info->wall_height.top; + actorx->bg_collision_check.wall_info[0].angleY = actor_info->wall_info[0].angleY; + actorx->bg_collision_check.wall_info[1].angleY = actor_info->wall_info[1].angleY; + actorx->bg_collision_check.wall_info[0].type = actor_info->wall_info[0].type; + actorx->bg_collision_check.wall_info[1].type = actor_info->wall_info[1].type; - actorx->world.position.x += actor_info->rev_pos.x; - actorx->world.position.y += actor_info->rev_pos.y; - actorx->world.position.z += actor_info->rev_pos.z; - mCoBG_GetWallReverse(actor_info, &actorx->world.position, &l_VecInf, actorx); - mCoBG_MakeHitWallFalg(&actorx->bg_collision_check.result, actor_info->wall_info); - - actorx->bg_collision_check.wall_bottom_y = actor_info->wall_height.bot; - actorx->bg_collision_check.wall_top_y = actor_info->wall_height.top; - actorx->bg_collision_check.wall_info[0].angleY = actor_info->wall_info[0].angleY; - actorx->bg_collision_check.wall_info[1].angleY = actor_info->wall_info[1].angleY; - actorx->bg_collision_check.wall_info[0].type = actor_info->wall_info[0].type; - actorx->bg_collision_check.wall_info[1].type = actor_info->wall_info[1].type; - - mCoBG_RegistWallCount(&actorx->bg_collision_check.result, actor_info->wall_info, actorx->shape_info.rotation.y); - mCoBG_MakePartDirectHitWallFlag(actorx); - } + mCoBG_RegistWallCount(&actorx->bg_collision_check.result, actor_info->wall_info, actorx->shape_info.rotation.y); + mCoBG_MakePartDirectHitWallFlag(actorx); } static f32 mCoBG_GetAreaYSlatingUnit(mCoBG_UnitInfo_c* unit_info, s16 type, s16 area) { @@ -1306,7 +1395,7 @@ static f32 mCoBG_GetAreaYSlatingUnit(mCoBG_UnitInfo_c* unit_info, s16 type, s16 } break; } - + return 0.0f; } @@ -1318,27 +1407,32 @@ static void mCoBG_GetOldCenterPosition(xyz_t* old_center_pos, ACTOR* actorx) { *old_center_pos = actorx->last_world_position; } +// GAFU01 adds a temp 0.0f and adds to ground_normal_y. static f32 mCoBG_GetBGHeight_Normal_NormalGround(s_xyz* angle, mCoBG_UnitInfo_c* unit_info) { xyz_t normal; s16 area; f32 ground_normal_y; + f32 tmp = 0.0f; - if ( - unit_info->collision->data.center != unit_info->collision->data.top_left || + if (unit_info->collision->data.center != unit_info->collision->data.top_left || unit_info->collision->data.center != unit_info->collision->data.bot_left || unit_info->collision->data.center != unit_info->collision->data.bot_right || - unit_info->collision->data.center != unit_info->collision->data.top_right - ) { + unit_info->collision->data.center != unit_info->collision->data.top_right) { mCoBG_GetUnitArea(unit_info, &area); mCoBG_GetNormTriangle(&normal, angle, unit_info->collision, area); - ground_normal_y = mCoBG_GroundPolygonInfo2BgHeight(&normal, unit_info) + mFI_UtNum2BaseHeight(unit_info->ut_x, unit_info->ut_z); + ground_normal_y = mCoBG_GroundPolygonInfo2BgHeight(&normal, unit_info) + + mFI_UtNum2BaseHeight(unit_info->ut_x, unit_info->ut_z); + ground_normal_y += tmp; } else { - ground_normal_y = unit_info->collision->data.center * 10.0f + mFI_UtNum2BaseHeight(unit_info->ut_x, unit_info->ut_z); + ground_normal_y = + unit_info->collision->data.center * 10.0f + mFI_UtNum2BaseHeight(unit_info->ut_x, unit_info->ut_z); + if (angle != NULL) { angle->x = 0; angle->y = 0; angle->z = 0; } + ground_normal_y += tmp; } return ground_normal_y; @@ -1350,10 +1444,12 @@ static f32 mCoBG_GetBGHeight_Normal_SlateGround(s_xyz* angle, mCoBG_UnitInfo_c* if (unit_info->collision->data.top_left != unit_info->collision->data.bot_right) { mCoBG_GetUnitArea(unit_info, &area); - ground_normal_y = mCoBG_GetAreaYSlatingUnit(unit_info, mCoBG_WALL_SLATE_UP, area) + mFI_UtNum2BaseHeight(unit_info->ut_x, unit_info->ut_z); + ground_normal_y = mCoBG_GetAreaYSlatingUnit(unit_info, mCoBG_WALL_SLATE_UP, area) + + mFI_UtNum2BaseHeight(unit_info->ut_x, unit_info->ut_z); } else { mCoBG_GetUnitArea(unit_info, &area); - ground_normal_y = mCoBG_GetAreaYSlatingUnit(unit_info, mCoBG_WALL_SLATE_DOWN, area) + mFI_UtNum2BaseHeight(unit_info->ut_x, unit_info->ut_z); + ground_normal_y = mCoBG_GetAreaYSlatingUnit(unit_info, mCoBG_WALL_SLATE_DOWN, area) + + mFI_UtNum2BaseHeight(unit_info->ut_x, unit_info->ut_z); } if (angle != NULL) { @@ -1368,25 +1464,31 @@ static f32 mCoBG_GetBGHeight_Normal_SlateGround(s_xyz* angle, mCoBG_UnitInfo_c* typedef f32 (*mCoBG_GET_BG_Y_NORMAL_PROC)(s_xyz* angle, mCoBG_UnitInfo_c* unit_info); static f32 mCoBG_GetBGHeight_Normal(s_xyz* angle, mCoBG_UnitInfo_c* unit_info) { - static mCoBG_GET_BG_Y_NORMAL_PROC get_bg_y_normal_proc[] = { &mCoBG_GetBGHeight_Normal_NormalGround, &mCoBG_GetBGHeight_Normal_SlateGround }; + static mCoBG_GET_BG_Y_NORMAL_PROC get_bg_y_normal_proc[] = { &mCoBG_GetBGHeight_Normal_NormalGround, + &mCoBG_GetBGHeight_Normal_SlateGround }; return (*get_bg_y_normal_proc[unit_info->collision->data.slate_flag])(angle, unit_info); } -static void mCoBG_MakeJumpFlag_NotOldOnGround(mCoBG_CheckResult_c* result, mCoBG_ActorInf_c* actor_info, xyz_t* rev, f32 ground_normal_y) { +static void mCoBG_MakeJumpFlag_NotOldOnGround(mCoBG_CheckResult_c* result, mCoBG_ActorInf_c* actor_info, xyz_t* rev, + f32 ground_normal_y) { // nothing } -static void mCoBG_MakeJumpFlag_OldOnGround(mCoBG_CheckResult_c* result, mCoBG_ActorInf_c* actor_info, xyz_t* rev, f32 ground_normal_y) { +static void mCoBG_MakeJumpFlag_OldOnGround(mCoBG_CheckResult_c* result, mCoBG_ActorInf_c* actor_info, xyz_t* rev, + f32 ground_normal_y) { if (actor_info->ground_y + rev->y > (ground_normal_y + 0.01f)) { result->jump_flag = TRUE; } } -typedef void (*mCoBG_MAKE_JUMP_FLAG_PROC)(mCoBG_CheckResult_c* result, mCoBG_ActorInf_c* actor_info, xyz_t* rev, f32 ground_normal_y); +typedef void (*mCoBG_MAKE_JUMP_FLAG_PROC)(mCoBG_CheckResult_c* result, mCoBG_ActorInf_c* actor_info, xyz_t* rev, + f32 ground_normal_y); -static void mCoBG_MakeJumpFlag(mCoBG_CheckResult_c* result, mCoBG_ActorInf_c* actor_info, xyz_t* rev, f32 ground_normal_y) { - static mCoBG_MAKE_JUMP_FLAG_PROC make_jump_flag_proc[] = { &mCoBG_MakeJumpFlag_NotOldOnGround, &mCoBG_MakeJumpFlag_OldOnGround }; +static void mCoBG_MakeJumpFlag(mCoBG_CheckResult_c* result, mCoBG_ActorInf_c* actor_info, xyz_t* rev, + f32 ground_normal_y) { + static mCoBG_MAKE_JUMP_FLAG_PROC make_jump_flag_proc[] = { &mCoBG_MakeJumpFlag_NotOldOnGround, + &mCoBG_MakeJumpFlag_OldOnGround }; (*make_jump_flag_proc[actor_info->old_on_ground & 1])(result, actor_info, rev, ground_normal_y); } @@ -1460,31 +1562,36 @@ static u32 mCoBG_CheckWaveAtrDetail(xyz_t* point, mCoBG_wave_c* wave_p) { static u32 mCoBG_GetWaveDynamicAttr(u32 orig_attr, xyz_t* pos) { if (orig_attr == mCoBG_ATTRIBUTE_36) { - static mCoBG_wave_c wave_s_info = { { 0.0f, 0.0f, mFI_UT_WORLDSIZE_HALF_Z_F }, { 0.0f, 0.0f, -mFI_UT_WORLDSIZE_HALF_Z_F } }; + static mCoBG_wave_c wave_s_info = { { 0.0f, 0.0f, mFI_UT_WORLDSIZE_HALF_Z_F }, + { 0.0f, 0.0f, -mFI_UT_WORLDSIZE_HALF_Z_F } }; return mCoBG_CheckWaveAtrDetail(pos, &wave_s_info); } if (orig_attr == mCoBG_ATTRIBUTE_37) { - static mCoBG_wave_c wave_se_info = { { 0.0f, 0.0f, 0.0f }, { -mFI_UT_WORLDSIZE_HALF_X_F, 0.0f, -mFI_UT_WORLDSIZE_HALF_Z_F } }; + static mCoBG_wave_c wave_se_info = { { 0.0f, 0.0f, 0.0f }, + { -mFI_UT_WORLDSIZE_HALF_X_F, 0.0f, -mFI_UT_WORLDSIZE_HALF_Z_F } }; return mCoBG_CheckWaveAtrDetail(pos, &wave_se_info); } if (orig_attr == mCoBG_ATTRIBUTE_38) { - static mCoBG_wave_c wave_sw_info = { { 0.0f, 0.0f, 0.0f }, { mFI_UT_WORLDSIZE_HALF_X_F, 0.0f, mFI_UT_WORLDSIZE_HALF_Z_F } }; + static mCoBG_wave_c wave_sw_info = { { 0.0f, 0.0f, 0.0f }, + { mFI_UT_WORLDSIZE_HALF_X_F, 0.0f, mFI_UT_WORLDSIZE_HALF_Z_F } }; return mCoBG_CheckWaveAtrDetail(pos, &wave_sw_info); } if (orig_attr == mCoBG_ATTRIBUTE_25) { - static mCoBG_wave_c wave_se2_info = { { mFI_UT_WORLDSIZE_HALF_X_F, 0.0f, mFI_UT_WORLDSIZE_HALF_Z_F }, { 0.0f, 0.0f, 0.0f } }; + static mCoBG_wave_c wave_se2_info = { { mFI_UT_WORLDSIZE_HALF_X_F, 0.0f, mFI_UT_WORLDSIZE_HALF_Z_F }, + { 0.0f, 0.0f, 0.0f } }; return mCoBG_CheckWaveAtrDetail(pos, &wave_se2_info); } if (orig_attr == mCoBG_ATTRIBUTE_26) { - static mCoBG_wave_c wave_sw2_info = { { -mFI_UT_WORLDSIZE_HALF_X_F, 0.0f, mFI_UT_WORLDSIZE_HALF_Z_F }, { 0.0f, 0.0f, 0.0f } }; + static mCoBG_wave_c wave_sw2_info = { { -mFI_UT_WORLDSIZE_HALF_X_F, 0.0f, mFI_UT_WORLDSIZE_HALF_Z_F }, + { 0.0f, 0.0f, 0.0f } }; return mCoBG_CheckWaveAtrDetail(pos, &wave_sw2_info); } @@ -1516,7 +1623,7 @@ extern u32 mCoBG_Wpos2Attribute(xyz_t pos, s8* cant_dig) { mCoBG_UnitInfo_c unit_info; u32 attr; s16 area; - + pos.y = 0.0f; mCoBG_Wpos2UnitInfo(&unit_info, pos); attr = unit_info.collision->data.unit_attribute; @@ -1588,7 +1695,8 @@ extern u32 mCoBG_Wpos2Attribute(xyz_t pos, s8* cant_dig) { mCoBG_GetUnitArea(&unit_info, &area); idx = attr - mCoBG_ATTRIBUTE_39; - if ((mCoBG_grass3_water_info[idx][area] <= mCoBG_ATTRIBUTE_GRASS3 && Common_Get(field_type) != mFI_FIELDTYPE2_FG) == FALSE) { + if ((mCoBG_grass3_water_info[idx][area] <= mCoBG_ATTRIBUTE_GRASS3 && + Common_Get(field_type) != mFI_FIELDTYPE2_FG) == FALSE) { return mCoBG_grass3_water_info[idx][area]; } else { return mCoBG_ATTRIBUTE_FLOOR; @@ -1681,9 +1789,6 @@ static u32 mCoBG_SearchWaterAttributeFrom4Area(xyz_t pos) { return mCoBG_unit_attribute_water_info[attr]; } -#include "../src/AUS/game/m_collision_bg_info.c_inc" -#include "../src/AUS/game/m_collision_bg_rewrite.c_inc" - static f32 mCoBG_GetBGHeight_NormalColumn(mCoBG_UnitInfo_c* unit_info, s_xyz* ground_angle, const xyz_t* pos) { static s_xyz ground_angle0; // @BUG - shouldn't this be initialized? s_xyz normal_ground_angle; @@ -1709,7 +1814,11 @@ static f32 mCoBG_GetBGHeight_NormalColumn(mCoBG_UnitInfo_c* unit_info, s_xyz* gr } } -static void mCoBG_GroundCheck(xyz_t* rev, mCoBG_ActorInf_c* actor_info, ACTOR* actorx, f32 actor_ground_dist, mCoBG_CheckResult_c* result, s_xyz* angle, s16 attribute_wall) { +// GAFU01 adds more checks for sea and corner wave attributes to determine when an +// actor is in water. It also only allows the fishing bobber, gyoei, and gyoei shadow actors +// to be in water while in the sea and corner wave attribute tiles. +static void mCoBG_GroundCheck(xyz_t* rev, mCoBG_ActorInf_c* actor_info, ACTOR* actorx, f32 actor_ground_dist, + mCoBG_CheckResult_c* result, s_xyz* angle, s16 attribute_wall) { mCoBG_UnitInfo_c unit_info; xyz_t pos; f32 ground_y; @@ -1725,7 +1834,8 @@ static void mCoBG_GroundCheck(xyz_t* rev, mCoBG_ActorInf_c* actor_info, ACTOR* a attr = unit_info.collision->data.unit_attribute; if (attr == mCoBG_ATTRIBUTE_63 || (attr >= mCoBG_ATTRIBUTE_27 && attr <= mCoBG_ATTRIBUTE_62)) { - if (attribute_wall == FALSE && actor_info->old_in_water == TRUE && (attr >= mCoBG_ATTRIBUTE_27 && attr <= mCoBG_ATTRIBUTE_35)) { + if (attribute_wall == FALSE && actor_info->old_in_water == TRUE && + (attr >= mCoBG_ATTRIBUTE_27 && attr <= mCoBG_ATTRIBUTE_35)) { int idx = attr - mCoBG_ATTRIBUTE_27; int flags = mCoBG_bridge_search_water[idx]; xyz_t next_pos; @@ -1735,9 +1845,12 @@ static void mCoBG_GroundCheck(xyz_t* rev, mCoBG_ActorInf_c* actor_info, ACTOR* a if ((flags & (1 << i)) != 0) { mCoBG_PlussDirectOffset(&next_pos, pos, i); next_unit_attr = mCoBG_SearchWaterAttributeFrom4Area(next_pos); - if (next_unit_attr >= mCoBG_ATTRIBUTE_WATER && next_unit_attr <= mCoBG_ATTRIBUTE_RIVER_NE) { + if (next_unit_attr == mCoBG_ATTRIBUTE_SEA || next_unit_attr == mCoBG_ATTRIBUTE_37 || next_unit_attr == mCoBG_ATTRIBUTE_38) { water_flag = TRUE; - water_y = mCoBG_GetWaterHeight_File(pos, __FILE__, 3883); + water_y = 20.0f; + } else if (next_unit_attr >= mCoBG_ATTRIBUTE_WATER && next_unit_attr <= mCoBG_ATTRIBUTE_RIVER_NE) { + water_flag = TRUE; + water_y = mCoBG_GetWaterHeight_File(pos, __FILE__, 4058); } } @@ -1751,10 +1864,16 @@ static void mCoBG_GroundCheck(xyz_t* rev, mCoBG_ActorInf_c* actor_info, ACTOR* a } } else { if (attr >= mCoBG_ATTRIBUTE_WATER && attr <= mCoBG_ATTRIBUTE_RIVER_NE) { - water_flag = TRUE; + if (actorx->id == mAc_PROFILE_UKI || actorx->id == mAc_PROFILE_GYOEI || actorx->id == mAc_PROFILE_GYO_KAGE) { + water_flag = TRUE; + } + water_y = 20.0f + mCoBG_GetBgY_AngleS_FromWpos(NULL, pos, 0.0f); - } else if (attr == mCoBG_ATTRIBUTE_SEA) { - water_flag = TRUE; + } else if (attr == mCoBG_ATTRIBUTE_SEA || attr == mCoBG_ATTRIBUTE_37 || attr == mCoBG_ATTRIBUTE_38) { + if (actorx->id == mAc_PROFILE_UKI || actorx->id == mAc_PROFILE_GYOEI || actorx->id == mAc_PROFILE_GYO_KAGE) { + water_flag = TRUE; + } + water_y = 20.0f; } else { attr = mCoBG_Wpos2Attribute(pos, NULL); @@ -1768,10 +1887,6 @@ static void mCoBG_GroundCheck(xyz_t* rev, mCoBG_ActorInf_c* actor_info, ACTOR* a mCoBG_MakeJumpFlag(result, actor_info, rev, ground_y); } -#include "../src/AUS/game/m_collision_bg_block.c_inc" -#include "../src/AUS/game/m_collision_bg_line.c_inc" -#include "../src/AUS/game/m_collision_bg_water.c_inc" - extern void mCoBG_InitBgCheckResult(mCoBG_CheckResult_c* result) { result->on_ground = FALSE; result->is_on_move_bg_obj = FALSE; @@ -1812,7 +1927,11 @@ static s16 mCoBG_ActorFearture2CheckRange(mCoBG_ActorInf_c* actor_info) { return 7; } -static void mCoBG_MakeActorInf(mCoBG_ActorInf_c* actor_info, ACTOR* actorx, f32 range, f32 ground_dist, s16 check_type, int ux, int uz) { +#include "../src/AUS/game/m_collision_bg_info.c_inc" +#include "../src/AUS/game/m_collision_bg_line.c_inc" + +static void mCoBG_MakeActorInf(mCoBG_ActorInf_c* actor_info, ACTOR* actorx, f32 range, f32 ground_dist, s16 check_type, + int ux, int uz) { actor_info->_68 = ux; actor_info->_6C = uz; actor_info->old_in_water = actorx->bg_collision_check.result.is_in_water; @@ -1874,27 +1993,49 @@ static void mCoBG_MoveActorWithMoveBg_OnMoveBg(ACTOR* actorx) { typedef void (*mCoBG_MOVE_BG_MOVE_ACTOR_PROC)(ACTOR* actorx); static void mCoBG_MoveActorWithMoveBg(ACTOR* actorx) { - static mCoBG_MOVE_BG_MOVE_ACTOR_PROC move_bg_move_actor_proc[] = { &mCoBG_MoveActorWithMoveBg_NotOnMoveBg, &mCoBG_MoveActorWithMoveBg_OnMoveBg }; + static mCoBG_MOVE_BG_MOVE_ACTOR_PROC move_bg_move_actor_proc[] = { &mCoBG_MoveActorWithMoveBg_NotOnMoveBg, + &mCoBG_MoveActorWithMoveBg_OnMoveBg }; (*move_bg_move_actor_proc[actorx->bg_collision_check.result.is_on_move_bg_obj])(actorx); } +// GAFU01 adds more checks for the basement and player cottage +// in scope check for house cockroach actor static void mCoBG_RoomScopeCheck(ACTOR* actorx, f32 range, f32 ground_dist) { if (actorx->id == mAc_PROFILE_HOUSE_GOKI) { int scene = Save_Get(scene_no); static xyz_t base_pos = { mFI_UT_WORLDSIZE_X_F, 0.0f, mFI_UT_WORLDSIZE_Z_F }; - if (scene == SCENE_MY_ROOM_S) { - mCoBG_ScopeWallCheck(actorx, &base_pos, 160.0f, 160.0f, range, ground_dist); - } else if (scene == SCENE_MY_ROOM_M || scene == SCENE_MY_ROOM_LL2) { - mCoBG_ScopeWallCheck(actorx, &base_pos, 240.0f, 240.0f, range, ground_dist); - } else if (scene == SCENE_MY_ROOM_L || scene == SCENE_MY_ROOM_LL1) { - mCoBG_ScopeWallCheck(actorx, &base_pos, 320.0f, 320.0f, range, ground_dist); + switch (scene) { + case SCENE_MY_ROOM_S: { + mCoBG_ScopeWallCheck(actorx, &base_pos, 160.0f, 160.0f, range, ground_dist); + break; + } + + case SCENE_MY_ROOM_M: + case SCENE_MY_ROOM_LL2: { + mCoBG_ScopeWallCheck(actorx, &base_pos, 240.0f, 240.0f, range, ground_dist); + break; + } + + case SCENE_MY_ROOM_L: + case SCENE_MY_ROOM_LL1: + case SCENE_MY_ROOM_BASEMENT_S: + case SCENE_MY_ROOM_BASEMENT_M: + case SCENE_MY_ROOM_BASEMENT_L: + case SCENE_MY_ROOM_BASEMENT_LL1: + case SCENE_COTTAGE_MY: { + mCoBG_ScopeWallCheck(actorx, &base_pos, 320.0f, 320.0f, range, ground_dist); + break; + } } } } -extern void mCoBG_BgCheckControll_RemoveDirectedUnitColumn(xyz_t* actor_revpos, ACTOR* actorx, f32 range, f32 ground_dist, s16 attr_wall, s16 rev_type, s16 check_type, int ux, int uz) { +// GAFU01 removes the unknown flag1 being set to actor_info's _64 field +extern void mCoBG_BgCheckControll_RemoveDirectedUnitColumn(xyz_t* actor_revpos, ACTOR* actorx, f32 range, + f32 ground_dist, s16 attr_wall, s16 rev_type, s16 check_type, + int ux, int uz) { s_xyz angle = { 0.0f, 0.0f, 0.0f }; mCoBG_Check_c prev_check = actorx->bg_collision_check; @@ -1904,8 +2045,9 @@ extern void mCoBG_BgCheckControll_RemoveDirectedUnitColumn(xyz_t* actor_revpos, mCoBG_GetOldCenterPosition(&l_ActorInf.old_center_pos, actorx); mCoBG_MakeActorInf(&l_ActorInf, actorx, range, ground_dist, check_type, ux, uz); mCoBG_WallCheck(actorx, &l_ActorInf, attr_wall, &prev_check); - actorx->bg_collision_check.result.unk_flag1 = l_ActorInf._64; - mCoBG_GroundCheck(&l_ActorInf.rev_pos, &l_ActorInf, actorx, ground_dist, &actorx->bg_collision_check.result, &angle, attr_wall); + // actorx->bg_collision_check.result.unk_flag1 = l_ActorInf._64; + mCoBG_GroundCheck(&l_ActorInf.rev_pos, &l_ActorInf, actorx, ground_dist, &actorx->bg_collision_check.result, &angle, + attr_wall); mCoBG_MoveBgGroundCheck(&l_ActorInf.rev_pos, &l_ActorInf, actorx, &actorx->bg_collision_check.result, &angle); mCoBG_CarryOutReverse(actorx, l_ActorInf.rev_pos, rev_type); mCoBG_GiveRevposToActor(actor_revpos, l_ActorInf.rev_pos); @@ -1914,11 +2056,15 @@ extern void mCoBG_BgCheckControll_RemoveDirectedUnitColumn(xyz_t* actor_revpos, l_ActorInf._6C = -1; } -extern void mCoBG_BgCheckControll(xyz_t* actor_revpos, ACTOR* actorx, f32 range, f32 ground_dist, s16 attr_wall, s16 rev_type, s16 check_type) { - mCoBG_BgCheckControll_RemoveDirectedUnitColumn(actor_revpos, actorx, range, ground_dist, attr_wall, rev_type, check_type, -1, -1); +extern void mCoBG_BgCheckControll(xyz_t* actor_revpos, ACTOR* actorx, f32 range, f32 ground_dist, s16 attr_wall, + s16 rev_type, s16 check_type) { + mCoBG_BgCheckControll_RemoveDirectedUnitColumn(actor_revpos, actorx, range, ground_dist, attr_wall, rev_type, + check_type, -1, -1); } -extern void mCoBG_WallCheckOnly(xyz_t* actor_revpos, ACTOR* actorx, f32 range, f32 ground_dist, s16 rev_type, s16 check_type) { +// GAFU01 removes the unknown flag1 being set to actor_info's _64 field +extern void mCoBG_WallCheckOnly(xyz_t* actor_revpos, ACTOR* actorx, f32 range, f32 ground_dist, s16 rev_type, + s16 check_type) { s16 attr_wall = FALSE; mCoBG_Check_c prev_check = actorx->bg_collision_check; @@ -1927,7 +2073,7 @@ extern void mCoBG_WallCheckOnly(xyz_t* actor_revpos, ACTOR* actorx, f32 range, f mCoBG_GetOldCenterPosition(&l_ActorInf.old_center_pos, actorx); mCoBG_MakeActorInf(&l_ActorInf, actorx, range, ground_dist, check_type, -1, -1); mCoBG_WallCheck(actorx, &l_ActorInf, attr_wall, &prev_check); - actorx->bg_collision_check.result.unk_flag1 = l_ActorInf._64; + // actorx->bg_collision_check.result.unk_flag1 = l_ActorInf._64; mCoBG_CarryOutReverse(actorx, l_ActorInf.rev_pos, rev_type); mCoBG_GiveRevposToActor(actor_revpos, l_ActorInf.rev_pos); mCoBG_RoomScopeCheck(actorx, range, ground_dist); @@ -1942,19 +2088,22 @@ extern void mCoBG_GroundCheckOnly(xyz_t* actor_revpos, ACTOR* actorx, f32 range, mCoBG_GetOldCenterPosition(&l_ActorInf.old_center_pos, actorx); mCoBG_GetSpeedByWpos(l_ActorInf.speed_xz0, actorx); mCoBG_MakeActorInf(&l_ActorInf, actorx, 0.0f, ground_dist, mCoBG_CHECK_TYPE_NORMAL, -1, -1); - mCoBG_GroundCheck(&l_ActorInf.rev_pos, &l_ActorInf, actorx, ground_dist, &actorx->bg_collision_check.result, &angle, FALSE); + mCoBG_GroundCheck(&l_ActorInf.rev_pos, &l_ActorInf, actorx, ground_dist, &actorx->bg_collision_check.result, &angle, + FALSE); mCoBG_CarryOutReverse(actorx, l_ActorInf.rev_pos, rev_type); mCoBG_GiveRevposToActor(actor_revpos, l_ActorInf.rev_pos); } static ACTOR Virtual_Actor; +// GAFU01 adds a special profile ID for the virtual actor extern void mCoBG_VirtualBGCheck(xyz_t* rev_pos_p, mCoBG_Check_c* bg_check, const xyz_t* start_pos_p, const xyz_t* end_pos_p, s16 angle_y, s16 water_flag, s16 ground_flag, f32 range, f32 ground_dist, s16 attr_wall, s16 rev_type, s16 check_type) { ACTOR* actorx = &Virtual_Actor; bzero(actorx, sizeof(ACTOR)); + actorx->id = mCoBG_VIRTUAL_ACTOR_ID; actorx->world.position = *end_pos_p; actorx->last_world_position = *start_pos_p; actorx->bg_collision_check.result.is_in_water = (s16)water_flag; diff --git a/src/AUS/game/m_collision_bg_block.c_inc b/src/AUS/game/m_collision_bg_block.c_inc deleted file mode 100644 index a4978635..00000000 --- a/src/AUS/game/m_collision_bg_block.c_inc +++ /dev/null @@ -1,88 +0,0 @@ -int mCoBG_block_bgcheck_mode = mCoBG_BLOCK_BGCHECK_MODE_NORMAL; - -extern void mCoBG_InitBlockBgCheckMode(void) { - mCoBG_block_bgcheck_mode = mCoBG_BLOCK_BGCHECK_MODE_NORMAL; -} - -extern int mCoBG_ChangeBlockBgCheckMode(int mode) { - mCoBG_block_bgcheck_mode = mode & 1; - return mCoBG_block_bgcheck_mode; -} - -extern int mCoBG_GetBlockBgCheckMode(void) { - return mCoBG_block_bgcheck_mode & 1; -} - -extern xyz_t mCoBG_UniqueWallCheck(ACTOR* actorx, f32 range, f32 y_ofs) { - int bx; - int bz; - xyz_t ret = { 0.0f, 0.0f, 0.0f }; - - mCoBG_InitRevpos(&l_ActorInf.rev_pos); - mCoBG_GetCurrentCenterPosition(&l_ActorInf.center_pos, actorx); - mCoBG_GetOldCenterPosition(&l_ActorInf.old_center_pos, actorx); - mCoBG_GetSpeedByWpos(l_ActorInf.speed_xz0, actorx); - - if (mFI_Wpos2BlockNum(&bx, &bz, l_ActorInf.old_center_pos)) { - xyz_t block_base = { 0.0f, 0.0f, 0.0f }; - - mCoBG_SetXyz_t(&l_ActorInf.rev_pos, 0.0f, 0.0f, 0.0f); - mFI_BkNum2WposXZ(&block_base.x, &block_base.z, bx, bz); - if (mCoBG_GetBlockBgCheckMode() == mCoBG_BLOCK_BGCHECK_MODE_INTRO_DEMO && - (mFI_BkNum2BlockKind(bx, bz) & mRF_BLOCKKIND_PLAYER) != 0 - ) { - block_base.x += mFI_UT_WORLDSIZE_X_F; - block_base.z += mFI_UT_WORLDSIZE_Z_F; - return mCoBG_ScopeWallCheck(actorx, &block_base, mFI_BK_WORLDSIZE_X - 2 * mFI_UT_WORLDSIZE_X, mFI_BK_WORLDSIZE_Z - 2 * mFI_UT_WORLDSIZE_Z, range, y_ofs); - } else { - return mCoBG_ScopeWallCheck(actorx, &block_base, mFI_BK_WORLDSIZE_X, mFI_BK_WORLDSIZE_Z, range, y_ofs); - } - } - - return ret; -} - -extern xyz_t mCoBG_ScopeWallCheck(ACTOR* actorx, const xyz_t* base_pos, f32 x, f32 z, f32 range, f32 y_ofs) { - f32 start[2]; - f32 end[2]; - s16 rev_type; - xyz_t rev = { 0.0f, 0.0f, 0.0f }; - - mCoBG_InitRevpos(&l_ActorInf.rev_pos); - mCoBG_GetCurrentCenterPosition(&l_ActorInf.center_pos, actorx); - mCoBG_GetOldCenterPosition(&l_ActorInf.old_center_pos, actorx); - mCoBG_GetSpeedByWpos(l_ActorInf.speed_xz0, actorx); - - if (l_ActorInf.speed_xz0[0] != 0.0f || l_ActorInf.speed_xz0[1] != 0.0f) { - start[0] = (base_pos->x); - start[1] = (base_pos->z); - end[0] = start[0] + x; - end[1] = start[1] + z; - - start[0] += range; - start[1] += range; - - end[0] -= range; - end[1] -= range; - - mCoBG_SetXyz_t(&l_ActorInf.rev_pos, 0.0f, 0.0f, 0.0f); - - if (l_ActorInf.center_pos.x < start[0]) { - l_ActorInf.rev_pos.x = start[0] - l_ActorInf.center_pos.x; - } else if (l_ActorInf.center_pos.x > end[0]) { - l_ActorInf.rev_pos.x = end[0] - l_ActorInf.center_pos.x; - } - - if (l_ActorInf.center_pos.z < start[1]) { - l_ActorInf.rev_pos.z = start[1] - l_ActorInf.center_pos.z; - } else if (l_ActorInf.center_pos.z > end[1]) { - l_ActorInf.rev_pos.z = end[1] - l_ActorInf.center_pos.z; - } - - mCoBG_GroundCheck(&l_ActorInf.rev_pos, &l_ActorInf, actorx, y_ofs, &actorx->bg_collision_check.result, NULL, FALSE); - mCoBG_CarryOutReverse(actorx, l_ActorInf.rev_pos, mCoBG_REVERSE_TYPE_REVERSE); - return l_ActorInf.rev_pos; - } - - return rev; -} diff --git a/src/AUS/game/m_collision_bg_column.c_inc b/src/AUS/game/m_collision_bg_column.c_inc index e8eea076..b5d80a2c 100644 --- a/src/AUS/game/m_collision_bg_column.c_inc +++ b/src/AUS/game/m_collision_bg_column.c_inc @@ -1,3 +1,121 @@ +// GAFU01 reworks how fg collisions are processed + +static int mCoBG_it_is_hole(mActor_name_t item, ACTOR* actorx) { + if (ITEM_IS_HOLE(item) || item == HOLE_SHINE || item == RSV_HOLE) { + return TRUE; + } + + return FALSE; +} + +static int mCoBG_it_is_tree_level2(mActor_name_t item, ACTOR* actorx) { + return IS_ITEM_SMALL_TREE(item) != FALSE; +} + +static int mCoBG_it_is_tree_level3(mActor_name_t item, ACTOR* actorx) { + return IS_ITEM_MED_TREE(item) != FALSE; +} + +static int mCoBG_it_is_tree_level4(mActor_name_t item, ACTOR* actorx) { + return IS_ITEM_LARGE_TREE(item) != FALSE; +} + +static int mCoBG_it_is_tree_level5(mActor_name_t item, ACTOR* actorx) { + return IS_ITEM_FULL_TREE(item) != FALSE; +} + +static int mCoBG_it_is_stump0(mActor_name_t item, ACTOR* actorx) { + // OK, this is just bad. There was no need to wastefully use the + // 'IS_ITEM_TREE_STUMP' macro only to filter out the size 0 stumps. + if (IS_ITEM_TREE_STUMP(item) && (item == TREE_STUMP001 || item == TREE_PALM_STUMP001 || item == CEDAR_TREE_STUMP001 || item == GOLD_TREE_STUMP001)) { + return TRUE; + } + + return FALSE; +} + +static int mCoBG_it_is_stump1(mActor_name_t item, ACTOR* actorx) { + // This just keeps getting worse haha + if (IS_ITEM_TREE_STUMP(item) && !mCoBG_it_is_stump0(item, actorx)) { + return TRUE; + } + + return FALSE; +} + +static int mCoBG_it_is_stone(mActor_name_t item, ACTOR* actorx) { + return (IS_ITEM_STONE(item) || IS_ITEM_STONE_TC(item)) != FALSE; +} + +static int mCoBG_it_is_post(mActor_name_t item, ACTOR* actorx) { + if (item == DUMMY_MAILBOX0 || item == DUMMY_MAILBOX1 || item == DUMMY_MAILBOX2 || item == DUMMY_MAILBOX3) { + return TRUE; + } + + return FALSE; +} + +static int mCoBG_it_is_sign(mActor_name_t item, ACTOR* actorx) { + if (item == DUMMY_RESERVE || ITEM_IS_SIGNBOARD(item)) { + return TRUE; + } + + return FALSE; +} + +static int mCoBG_it_is_sign_dummy(mActor_name_t item, ACTOR* actorx) { + return item == RSV_SIGNBOARD; +} + +static int mCoBG_it_is_flag(mActor_name_t item, ACTOR* actorx) { + if (item == DUMMY_KOINOBORI || item == DUMMY_FLAG) { + return TRUE; + } + + return FALSE; +} + +typedef int (*mCoBG_COL_ITEM_CHK_PROC)(mActor_name_t item, ACTOR* actorx); + +typedef struct { + mCoBG_COL_ITEM_CHK_PROC chk_proc; + f32 radius; + f32 height; + int chk_old_on_ground; +} mCoBG_fg_collision_data_c; + +static mCoBG_fg_collision_data_c mCoBG_fg_collision_data[] = { + // clang-format off + { mCoBG_it_is_hole, 19.0f, 0.0f, TRUE }, + { mCoBG_it_is_tree_level2, 19.0f, 30.0f, FALSE }, + { mCoBG_it_is_tree_level3, 19.0f, 40.0f, FALSE }, + { mCoBG_it_is_tree_level4, 19.0f, 60.0f, FALSE }, + { mCoBG_it_is_tree_level5, 19.0f, 80.0f, FALSE }, + { mCoBG_it_is_stump0, 10.0f, 30.0f, FALSE }, + { mCoBG_it_is_stump1, 18.0f, 30.0f, FALSE }, + { mCoBG_it_is_stone, 19.0f, 31.5f, FALSE }, + { mCoBG_it_is_post, 15.0f, 50.0f, FALSE }, + { mCoBG_it_is_sign, 19.0f, 45.0f, FALSE }, + { mCoBG_it_is_sign_dummy, 10.0f, 45.0f, FALSE }, + { mCoBG_it_is_flag, 19.0f, 160.0f, FALSE }, + // clang-format on +}; + +static mCoBG_fg_collision_data_c* mCoBG_get_fg_collision_data_p(ACTOR* actorx, mActor_name_t item) { + u32 i; + mCoBG_fg_collision_data_c* col_p = mCoBG_fg_collision_data; + + for (i = 0; i < ARRAY_COUNT(mCoBG_fg_collision_data); i++) { + if (col_p->chk_proc(item, actorx) == TRUE) { + return col_p; + } + + col_p++; + } + + return NULL; +} + typedef struct { xyz_t pos; int in_use; @@ -133,153 +251,31 @@ extern void mCoBG_CrossOffDecalCircle(int idx) { } } -static int mCoBG_MakeOneColumnCollisionData(mCoBG_column_c* col, mCoBG_UnitInfo_c* ut_info, int old_on_ground, mCoBG_COLUMN_CHECK_ITEM_TYPE_PROC check_proc, int ux, int uz) { +// GAFU01 passes in the actor and uses data driven approach +// to process +static int mCoBG_MakeOneColumnCollisionData(ACTOR* actorx, mCoBG_column_c* col, mCoBG_UnitInfo_c* ut_info, int old_on_ground, mCoBG_COLUMN_CHECK_ITEM_TYPE_PROC check_proc, int ux, int uz) { if ((check_proc != NULL && (*check_proc)(ut_info->item) == FALSE) || check_proc == NULL) { + mCoBG_fg_collision_data_c* col_data_p; + if (ut_info->ut_x == ux && ut_info->ut_z == uz) { return FALSE; } - if (old_on_ground == TRUE && (ITEM_IS_HOLE(ut_info->item) || ut_info->item == HOLE_SHINE || ut_info->item == RSV_HOLE)) { - col->pos.x = mFI_UT_WORLDSIZE_HALF_X_F + mFI_UT_WORLDSIZE_X_F * ut_info->ut_x; - col->pos.z = mFI_UT_WORLDSIZE_HALF_Z_F + mFI_UT_WORLDSIZE_Z_F * ut_info->ut_z; - col->pos.y = 0.0f; - col->ux = ut_info->ut_x; - col->uz = ut_info->ut_z; - col->pos.y = mCoBG_GetBgY_OnlyCenter_FromWpos2(col->pos, 0.0f); - col->height = col->pos.y; - col->radius = 19.0f; - col->atr_wall = TRUE; - return TRUE; - } - - if (IS_ITEM_SMALL_TREE(ut_info->item)) { - col->pos.x = mFI_UT_WORLDSIZE_HALF_X_F + mFI_UT_WORLDSIZE_X_F * ut_info->ut_x; - col->pos.z = mFI_UT_WORLDSIZE_HALF_Z_F + mFI_UT_WORLDSIZE_Z_F * ut_info->ut_z; - col->pos.y = 0.0f; - col->pos.y = mCoBG_GetBgY_OnlyCenter_FromWpos2(col->pos, 0.0f); - col->height = col->pos.y + 30.0f; - col->ux = ut_info->ut_x; - col->uz = ut_info->ut_z; - col->radius = 19.0f; - col->atr_wall = FALSE; - return TRUE; - } - - if (IS_ITEM_MED_TREE(ut_info->item)) { - col->pos.x = mFI_UT_WORLDSIZE_HALF_X_F + mFI_UT_WORLDSIZE_X_F * ut_info->ut_x; - col->pos.z = mFI_UT_WORLDSIZE_HALF_Z_F + mFI_UT_WORLDSIZE_Z_F * ut_info->ut_z; - col->pos.y = 0.0f; - col->pos.y = mCoBG_GetBgY_OnlyCenter_FromWpos2(col->pos, 0.0f); - col->height = col->pos.y + 40.0f; - col->ux = ut_info->ut_x; - col->uz = ut_info->ut_z; - col->radius = 19.0f; - col->atr_wall = FALSE; - return TRUE; - } - - if (IS_ITEM_LARGE_TREE(ut_info->item)) { - col->pos.x = mFI_UT_WORLDSIZE_HALF_X_F + mFI_UT_WORLDSIZE_X_F * ut_info->ut_x; - col->pos.z = mFI_UT_WORLDSIZE_HALF_Z_F + mFI_UT_WORLDSIZE_Z_F * ut_info->ut_z; - col->pos.y = 0.0f; - col->pos.y = mCoBG_GetBgY_OnlyCenter_FromWpos2(col->pos, 0.0f); - col->height = col->pos.y + 60.0f; - col->ux = ut_info->ut_x; - col->uz = ut_info->ut_z; - col->radius = 19.0f; - col->atr_wall = FALSE; - return TRUE; - } - - if (IS_ITEM_FULL_TREE(ut_info->item) || ut_info->item == RSV_TREE) { - col->pos.x = mFI_UT_WORLDSIZE_HALF_X_F + mFI_UT_WORLDSIZE_X_F * ut_info->ut_x; - col->pos.z = mFI_UT_WORLDSIZE_HALF_Z_F + mFI_UT_WORLDSIZE_Z_F * ut_info->ut_z; - col->pos.y = 0.0f; - col->pos.y = mCoBG_GetBgY_OnlyCenter_FromWpos2(col->pos, 0.0f); - col->height = col->pos.y + 80.0f; - col->ux = ut_info->ut_x; - col->uz = ut_info->ut_z; - col->radius = 19.0f; - col->atr_wall = FALSE; - return TRUE; - } - - if (IS_ITEM_TREE_STUMP(ut_info->item)) { - col->pos.x = mFI_UT_WORLDSIZE_HALF_X_F + mFI_UT_WORLDSIZE_X_F * ut_info->ut_x; - col->pos.z = mFI_UT_WORLDSIZE_HALF_Z_F + mFI_UT_WORLDSIZE_Z_F * ut_info->ut_z; - col->pos.y = 0.0f; - col->pos.y = mCoBG_GetBgY_OnlyCenter_FromWpos2(col->pos, 0.0f); - col->ux = ut_info->ut_x; - col->uz = ut_info->ut_z; - - if (ut_info->item == TREE_STUMP001 || ut_info->item == TREE_PALM_STUMP001 || ut_info->item == CEDAR_TREE_STUMP001 || ut_info->item == GOLD_TREE_STUMP001) { - col->radius = 10.0f; - col->height = col->pos.y + 30.0f; - } else { - col->radius = 18.0f; - col->height = col->pos.y + 30.0f; + col_data_p = mCoBG_get_fg_collision_data_p(actorx, ut_info->item); + if (col_data_p != NULL) { + if (col_data_p->chk_old_on_ground == TRUE && old_on_ground != TRUE) { + return FALSE; } - col->atr_wall = FALSE; - return TRUE; - } - if (IS_ITEM_ROCK(ut_info->item)) { - col->pos.x = mFI_UT_WORLDSIZE_HALF_X_F + mFI_UT_WORLDSIZE_X_F * ut_info->ut_x; - col->pos.z = mFI_UT_WORLDSIZE_HALF_Z_F + mFI_UT_WORLDSIZE_Z_F * ut_info->ut_z; - col->pos.y = mCoBG_GetBgY_OnlyCenter_FromWpos2(col->pos, 0.0f); + col->pos.x = ut_info->ut_x * mFI_UT_WORLDSIZE_X_F + mFI_UT_WORLDSIZE_HALF_X_F; + col->pos.z = ut_info->ut_z * mFI_UT_WORLDSIZE_Z_F + mFI_UT_WORLDSIZE_HALF_Z_F; + col->pos.y = 0.0f; col->ux = ut_info->ut_x; col->uz = ut_info->ut_z; - col->radius = 19.0f; - col->height = col->pos.y + 31.5f; - col->atr_wall = FALSE; - return TRUE; - } - - if (ut_info->item == DUMMY_MAILBOX0 || ut_info->item == DUMMY_MAILBOX1 || ut_info->item == DUMMY_MAILBOX2 || ut_info->item == DUMMY_MAILBOX3) { - col->pos.x = mFI_UT_WORLDSIZE_HALF_X_F + mFI_UT_WORLDSIZE_X_F * ut_info->ut_x; - col->pos.z = mFI_UT_WORLDSIZE_HALF_Z_F + mFI_UT_WORLDSIZE_Z_F * ut_info->ut_z; col->pos.y = mCoBG_GetBgY_OnlyCenter_FromWpos2(col->pos, 0.0f); - col->ux = ut_info->ut_x; - col->uz = ut_info->ut_z; - col->radius = 15.0f; - col->height = col->pos.y + 50.0f; - col->atr_wall = FALSE; - return TRUE; - } - - if (ITEM_IS_SIGN(ut_info->item)) { - col->pos.x = mFI_UT_WORLDSIZE_HALF_X_F + mFI_UT_WORLDSIZE_X_F * ut_info->ut_x; - col->pos.z = mFI_UT_WORLDSIZE_HALF_Z_F + mFI_UT_WORLDSIZE_Z_F * ut_info->ut_z; - col->pos.y = mCoBG_GetBgY_OnlyCenter_FromWpos2(col->pos, 0.0f); - col->radius = 19.0f; - col->height = col->pos.y + 45.0f; - col->ux = ut_info->ut_x; - col->uz = ut_info->ut_z; - col->atr_wall = FALSE; - return TRUE; - } - - if (ut_info->item == RSV_SIGNBOARD) { - col->pos.x = mFI_UT_WORLDSIZE_HALF_X_F + mFI_UT_WORLDSIZE_X_F * ut_info->ut_x; - col->pos.z = mFI_UT_WORLDSIZE_HALF_Z_F + mFI_UT_WORLDSIZE_Z_F * ut_info->ut_z; - col->pos.y = mCoBG_GetBgY_OnlyCenter_FromWpos2(col->pos, 0.0f); - col->radius = 10.0f; - col->height = col->pos.y + 45.0f; - col->ux = ut_info->ut_x; - col->uz = ut_info->ut_z; - col->atr_wall = FALSE; - return TRUE; - } - - if (ut_info->item == DUMMY_KOINOBORI || ut_info->item == DUMMY_FLAG) { - col->pos.x = mFI_UT_WORLDSIZE_HALF_X_F + mFI_UT_WORLDSIZE_X_F * ut_info->ut_x; - col->pos.z = mFI_UT_WORLDSIZE_HALF_Z_F + mFI_UT_WORLDSIZE_Z_F * ut_info->ut_z; - col->pos.y = mCoBG_GetBgY_OnlyCenter_FromWpos2(col->pos, 0.0f); - col->radius = 19.0f; - col->height = col->pos.y + 160.0f; - col->ux = ut_info->ut_x; - col->uz = ut_info->ut_z; - col->atr_wall = FALSE; + col->height = col->pos.y + col_data_p->height; + col->radius = col_data_p->radius; + col->atr_wall = col_data_p->chk_old_on_ground; return TRUE; } } @@ -287,16 +283,19 @@ static int mCoBG_MakeOneColumnCollisionData(mCoBG_column_c* col, mCoBG_UnitInfo_ return FALSE; } -static void mCoBG_MakeColumnCollisionData(mCoBG_column_c* col, int* col_count_p, mCoBG_UnitInfo_c* ut_info, int count, int old_on_ground, mCoBG_COLUMN_CHECK_ITEM_TYPE_PROC check_item_proc, int ux, int uz) { +// GAFU01 passes in the actor +static void mCoBG_MakeColumnCollisionData(ACTOR* actorx, mCoBG_column_c* col, int* col_count_p, mCoBG_UnitInfo_c* ut_info, int count, int old_on_ground, mCoBG_COLUMN_CHECK_ITEM_TYPE_PROC check_item_proc, int ux, int uz) { int count_sq = SQ(count); int i; *col_count_p = 0; for (i = 0; i < count_sq; i++) { if (*col_count_p < 16) { - mCoBG_MakeOneColumnCollisionData(col, ut_info, old_on_ground, check_item_proc, ux, uz); - col++; - (*col_count_p)++; + // GAFU01 checks the collision exists instead of just processing it always + if (mCoBG_MakeOneColumnCollisionData(actorx, col, ut_info, old_on_ground, check_item_proc, ux, uz)) { + col++; + (*col_count_p)++; + } } ut_info++; @@ -444,7 +443,7 @@ static void mCoBG_ColumnWallCheck(xyz_t* rev, mCoBG_ActorInf_c* actor_info, cons static f32 mCoBG_GetBGHeight_Column(const xyz_t* pos, mCoBG_UnitInfo_c* ut_info) { mCoBG_column_c col; - if (mCoBG_MakeOneColumnCollisionData(&col, ut_info, FALSE, NULL, -1, -1) && mCoBG_JudgePointInCircle_Xyz(pos, &col.pos, col.radius)) { + if (mCoBG_MakeOneColumnCollisionData(NULL, &col, ut_info, FALSE, NULL, -1, -1) && mCoBG_JudgePointInCircle_Xyz(pos, &col.pos, col.radius)) { return col.height; } @@ -553,11 +552,12 @@ static int mCoBG_LineGroundCheck_Column(xyz_t* rev, mCoBG_column_c* col, int col tmp_end.z = end_pos->z + reverse.z; reverse = reverse0; + vec_y = col->height - tmp_end.y; + vec_end_start.x = start_pos->x - tmp_end.x; vec_end_start.y = start_pos->y - tmp_end.y; vec_end_start.z = start_pos->z - tmp_end.z; - vec_y = col->height - tmp_end.y; if (!F32_IS_ZERO(vec_end_start.y)) { f32 mult = vec_y / vec_end_start.y; diff --git a/src/AUS/game/m_collision_bg_info.c_inc b/src/AUS/game/m_collision_bg_info.c_inc index 83ef04f7..f039a4bd 100644 --- a/src/AUS/game/m_collision_bg_info.c_inc +++ b/src/AUS/game/m_collision_bg_info.c_inc @@ -62,7 +62,7 @@ extern f32 mCoBG_Wpos2BgUtCenterHeight_AddColumn(xyz_t pos) { mCoBG_column_c column; mCoBG_Wpos2UnitInfo(&ut_info, pos); - if (mCoBG_MakeOneColumnCollisionData(&column, &ut_info, FALSE, NULL, -1, -1)) { + if (mCoBG_MakeOneColumnCollisionData(NULL, &column, &ut_info, FALSE, NULL, -1, -1)) { return column.height; } @@ -160,11 +160,12 @@ extern int mCoBG_ScrollCheck(xyz_t start, xyz_t end, f32 radius) { { mCoBG_column_c* col2; int count; + int i; column = l_VecInf.column; - mCoBG_MakeColumnCollisionData(column, &l_VecInf.col_count, l_crtutInf, 3, TRUE, NULL, -1, -1); + mCoBG_MakeColumnCollisionData(NULL, column, &l_VecInf.col_count, l_crtutInf, 3, TRUE, NULL, -1, -1); count = l_VecInf.col_count; - if (count != 0) { + if (count > 0) { col2 = column; for (i = 0; i < count; i++) { f32 dx = end.x - col2->pos.x; @@ -597,7 +598,7 @@ extern int mCoBG_CheckHole(xyz_t pos) { return FALSE; } -extern int mCoBG_CheckSkySwing(xyz_t pos) { +extern int mCoBG_CheckAirSwing(xyz_t pos) { mCoBG_Collision_u* col = mFI_GetUnitCol(pos); u32 attr = col->data.unit_attribute; @@ -779,7 +780,7 @@ extern int mCoBG_SearchWaterLimitDistN(xyz_t* water_pos, xyz_t pos, s16 angle, f if (water_count == ARRAY_COUNT(offset)) { *water_pos = search; - water_pos->y = mCoBG_GetWaterHeight_File(search, __FILE__, 1137); + water_pos->y = mCoBG_GetWaterHeight_File(search, __FILE__, 1310); return TRUE; } @@ -819,6 +820,7 @@ extern int mCoBG_CheckRoughPathInRoom(const xyz_t* pos) { return p; } +// GAFU01 checks for sea wave attributes extern f32 mCoBG_GetBalloonGroundY(const xyz_t* pos) { mCoBG_UnitInfo_c ut_info; s_xyz normal_ground_angle; @@ -832,7 +834,8 @@ extern f32 mCoBG_GetBalloonGroundY(const xyz_t* pos) { u32 block_kind = mFI_BkNum2BlockKind(bx, bz); if ((block_kind & mRF_BLOCKKIND_MARINE) != 0) { - if (mCoBG_CheckWaterAttribute(attr) == TRUE || attr == mCoBG_ATTRIBUTE_WAVE || attr == mCoBG_ATTRIBUTE_SAND || attr == mCoBG_ATTRIBUTE_SEA) { + if (mCoBG_CheckWaterAttribute(attr) == TRUE || attr == mCoBG_ATTRIBUTE_WAVE || attr == mCoBG_ATTRIBUTE_SAND || + attr == mCoBG_ATTRIBUTE_SEA || attr == mCoBG_ATTRIBUTE_37 || attr == mCoBG_ATTRIBUTE_38) { return mFI_UNIT_BASE_SIZE_F; } } @@ -894,13 +897,7 @@ static f32 mCoBG_CheckBallRollingAreaRate(const xyz_t* pos, const xyz_t* start_p f32 dist_start_cross_x = cross[0] - start[0]; f32 dist_start_cross_z = cross[1] - start[1]; f32 dist_start_cross = sqrtf(SQ(dist_start_cross_x) + SQ(dist_start_cross_z)); - f32 rate; - - if (F32_IS_ZERO(dist_start_end) == FALSE) { - rate = dist_start_cross / dist_start_end; - } else { - rate = -1.0f; - } + f32 rate = !F32_IS_ZERO(dist_start_end) ? dist_start_cross / dist_start_end : -1.0f; if (mCoBG_RangeCheckLinePoint(start, end, cross) == FALSE) { rate = -1.0f; @@ -1144,3 +1141,477 @@ extern int mCoBG_Height2GetLayer(f32 height) { extern int mCoBG_GetLayer(const xyz_t* pos) { return mCoBG_Height2GetLayer(mCoBG_GetBgY_OnlyCenter_FromWpos2(*pos, 0.0f)); } + +// GAFU01 renames mCoBG_GetBgY_AngleS_FromWpos2 to this +extern f32 mCoBG_Wpos2BgHeight_AngleSXXX(s_xyz* ground_angle, xyz_t pos, f32 ground_dist) { + mCoBG_UnitInfo_c ut_info; + s_xyz normal_ground_angle; + f32 normal_y; + f32 column_y; + static s_xyz ground_angle0 = { 0, 0, 0 }; + f32 t0; + f32 t1; + f32 ret; + + if (ground_angle != NULL) { + *ground_angle = ground_angle0; + } + + mCoBG_Wpos2UnitInfo(&ut_info, pos); + normal_y = mCoBG_GetBGHeight_Normal(&normal_ground_angle, &ut_info); + column_y = mCoBG_GetBGHeight_Column(&pos, &ut_info); + + if (ground_angle != NULL && normal_y >= column_y && normal_y >= -100.0f) { + *ground_angle = normal_ground_angle; + return normal_y - ground_dist; + } + + t0 = MAX(normal_y, -100.0f); + t1 = MAX(normal_y, column_y); + if (t1 > t0) { + ret = MAX(normal_y, column_y); + } else { + ret = MAX(normal_y, -100.0f); + } + + return ret - ground_dist; +} + + + +// GAFU01 adds checks for sea attributes when checking from bridge tiles +extern f32 mCoBG_GetWaterHeight_File(xyz_t pos, char* file, int line) { + u32 attr; + int ux; + int uz; + mCoBG_Collision_u* col; + xyz_t mod_pos = pos; + + mFI_Wpos2UtNum(&ux, &uz, pos); + col = mFI_UtNum2UtCol(ux, uz); + attr = col->data.unit_attribute; + + if (attr == mCoBG_ATTRIBUTE_SEA || attr == mCoBG_ATTRIBUTE_37 || attr == mCoBG_ATTRIBUTE_38) { + return 20.0f; + } + + if (attr >= mCoBG_ATTRIBUTE_WATER && attr <= mCoBG_ATTRIBUTE_RIVER_NE) { + return 20.0f + mCoBG_Wpos2BgHeight_AngleSXXX(NULL, pos, 0.0f); + } + + if (attr >= mCoBG_ATTRIBUTE_27 && attr <= mCoBG_ATTRIBUTE_35) { + int idx = attr - mCoBG_ATTRIBUTE_27; + int search = mCoBG_bridge_search_water[idx]; + u32 new_attr; + int i; + + for (i = 0; i < mSc_DIRECT_NUM; i++) { + if ((search & (1 << i)) != 0) { + int ux; + int uz; + + mCoBG_PlussDirectOffset(&mod_pos, pos, i); + mFI_Wpos2UtNum(&ux, &uz, mod_pos); + new_attr = mFI_UtNum2UtCol(ux, uz)->data.unit_attribute; + + if (new_attr == mCoBG_ATTRIBUTE_SEA || new_attr == mCoBG_ATTRIBUTE_37 || new_attr == mCoBG_ATTRIBUTE_38) { + return 20.0f; + } + + if (new_attr >= mCoBG_ATTRIBUTE_WATER && new_attr <= mCoBG_ATTRIBUTE_RIVER_NE) { + return 20.0f + mCoBG_Wpos2BgHeight_AngleSXXX(NULL, mod_pos, 0.0f); + } + } + } + } else if (attr >= mCoBG_ATTRIBUTE_39 && attr <= mCoBG_ATTRIBUTE_42) { + u32 attr2 = mCoBG_Wpos2Attribute(pos, NULL); + + if (attr2 >= mCoBG_ATTRIBUTE_WATER && attr2 <= mCoBG_ATTRIBUTE_RIVER_NE) { + int i; + u32 new_attr; + xyz_t new_pos; + int idx = attr - mCoBG_ATTRIBUTE_39; + int search = mCoBG_grass3_search_water[idx]; + + for (i = 0; i < mSc_DIRECT_NUM; i++) { + if ((search & (1 << i)) != 0) { + int ux; + int uz; + + mCoBG_PlussDirectOffset(&new_pos, pos, i); + mFI_Wpos2UtNum(&ux, &uz, new_pos); + new_attr = mFI_UtNum2UtCol(ux, uz)->data.unit_attribute; + + if (new_attr >= mCoBG_ATTRIBUTE_WATER && new_attr <= mCoBG_ATTRIBUTE_RIVER_NE) { + return 20.0f + mCoBG_Wpos2BgHeight_AngleSXXX(NULL, new_pos, 0.0f); + } + } + } + } + } + + return -100.0f; +} + +// GAFU01 checks two missing sea attributes +extern int mCoBG_CheckWaterAttribute(u32 attr) { + if (attr == mCoBG_ATTRIBUTE_SEA || attr == mCoBG_ATTRIBUTE_37 || attr == mCoBG_ATTRIBUTE_38) { + return TRUE; + } + + if (attr >= mCoBG_ATTRIBUTE_WATER && attr <= mCoBG_ATTRIBUTE_RIVER_NE) { + return TRUE; + } + + return FALSE; +} + +extern int mCoBG_CheckWaterAttribute_OutOfSea(u32 attr) { + return (attr >= mCoBG_ATTRIBUTE_WATER && attr <= mCoBG_ATTRIBUTE_RIVER_NE) != FALSE; +} + +static f32 mCoBG_wave_cos = 0.0f; + +extern void mCoBG_WaveCos2BgCheck(f32 value) { + mCoBG_wave_cos = value; +} + +extern f32 mCoBG_WaveCos(void) { + return mCoBG_wave_cos; +} + +extern int mCoBG_GetWaterFlow(xyz_t* flow, u32 attr) { + static xyz_t flow_data[] = { + {0.0f, 0.0f, 0.0f}, + {0.0f, -5.0f, 0.0f}, + {0.0f, 0.0f, -0.5f}, + {-0.35355338f, 0.0f, -0.35355338f}, + {-0.5f, 0.0f, 0.0f}, + {-0.35355338f, 0.0f, 0.35355338f}, + {0.0f, 0.0f, 0.5f}, + {0.35355338f, 0.0f, 0.35355338f}, + {0.5f, 0.0f, 0.0f}, + {0.35355338f, 0.0f, -0.35355338f}, + }; + + if (attr == mCoBG_ATTRIBUTE_SEA) { + static const xyz_t sea_flow = { 0.0f, 0.0f, -1.0f }; + + *flow = sea_flow; + return TRUE; + } + + if (mCoBG_CheckWaterAttribute(attr)) { + int idx = attr - mCoBG_ATTRIBUTE_WATER; + + *flow = flow_data[idx]; + return TRUE; + } + + *flow = flow_data[0]; + return FALSE; +} + +extern int mCoBG_CheckWaveAttr(u32 attr) { + switch (attr) { + case mCoBG_ATTRIBUTE_WAVE: + case mCoBG_ATTRIBUTE_36: + case mCoBG_ATTRIBUTE_25: + case mCoBG_ATTRIBUTE_26: + return TRUE; + default: + return FALSE; + } +} + +// @unused, @fabricated +extern int mCoBG_CheckSand2Sea(xyz_t* pos) { + u32 attr = mCoBG_Wpos2BgAttribute_Original(*pos); + + if (attr == mCoBG_ATTRIBUTE_SEA || mCoBG_CheckWaveAttr(attr)) { + return TRUE; + } + + return FALSE; +} + + +static u32 mCoBG_OffsetInRule(int ofs) { + if (ofs > 31) { + return 31; + } + + return CLAMP(ofs, 0, ofs); +} + +static void mCoBG_SetBestBgY(mCoBG_Collision_u* col, s16* change_ofs) { + u32 max = mCoBG_GetMaxOffset(col->data.center, col->data.top_left, col->data.bot_left, col->data.bot_right, col->data.top_right); + u32 min = mCoBG_GetMinOffset(col->data.center, col->data.top_left, col->data.bot_left, col->data.bot_right, col->data.top_right); +} + +static void mCoBG_TidyChangeOffset(s16* change_ofs, mCoBG_Collision_u* col) { + if ( + // clang-format off + col->data.center + *change_ofs > 31 || + col->data.top_left + *change_ofs > 31 || + col->data.bot_left + *change_ofs > 31 || + col->data.bot_right + *change_ofs > 31 || + col->data.top_right + *change_ofs > 31 || + col->data.center + *change_ofs < 0 || + col->data.top_left + *change_ofs < 0 || + col->data.bot_left + *change_ofs < 0 || + col->data.bot_right + *change_ofs < 0 || + col->data.top_right + *change_ofs < 0 + // clang-format on + ) { + mCoBG_SetBestBgY(col, change_ofs); + } +} + +// @unused, @fabricated +extern void mCoBG_Ut2SetPlussOffset(int ux, int uz, s16 change_ofs, s16 attr) { + xyz_t pos = { 0.0f, 0.0f, 0.0f }; + + if (mFI_UtNum2CenterWpos(&pos, ux, uz)) { + mCoBG_SetPlussOffset(pos, change_ofs, attr); + } +} + +extern void mCoBG_SetPlussOffset(xyz_t wpos, s16 change_ofs, s16 attr) { + int ux; + int uz; + + if (mFI_Wpos2UtNum(&ux, &uz, wpos)) { + mCoBG_Collision_u* col = mFI_UtNum2UtCol(ux, uz); + u8 keep_h = mFI_UtNum2UtKeepH(ux, uz); + + if (keep_h == col->data.center) { + mCoBG_TidyChangeOffset(&change_ofs, col); + } else { + u32 gap = keep_h - col->data.center; + + col->data.center = (u8)keep_h; + col->data.top_left += gap; + col->data.bot_left += gap; + col->data.bot_right += gap; + col->data.top_right += gap; + mCoBG_TidyChangeOffset(&change_ofs, col); + } + + col->data.center += change_ofs; + col->data.bot_left += change_ofs; + col->data.top_left += change_ofs; + col->data.top_right += change_ofs; + col->data.bot_right += change_ofs; + + if (attr != mCoBG_ATTRIBUTE_NONE) { + col->data.unit_attribute = (s16)attr; + } + + } +} + +extern void mCoBG_SetAttribute(xyz_t pos, s16 attr) { + mCoBG_Collision_u* col; + int ux; + int uz; + + if (mFI_Wpos2UtNum(&ux, &uz, pos)) { + col = mFI_UtNum2UtCol(ux, uz); + if (attr != mCoBG_ATTRIBUTE_NONE) { + col->data.unit_attribute = (s16)attr; + } + } +} + +extern void mCoBG_Ut2SetPluss5PointOffset_file(int ux, int uz, mCoBG_OffsetTable_c ofs_data, char* file, int line) { + xyz_t pos = { 0.0f, 0.0f, 0.0f }; + + if (mFI_UtNum2CenterWpos(&pos, ux, uz)) { + mCoBG_SetPluss5PointOffset_file(pos, ofs_data, file, line); + } +} + +extern void mCoBG_SetPluss5PointOffset_file(xyz_t pos, mCoBG_OffsetTable_c ofs_data, char* file, int line) { + int ux; + int uz; + + if (mFI_Wpos2UtNum(&ux, &uz, pos)) { + u8 keep_h = mFI_UtNum2UtKeepH(ux, uz); + mCoBG_Collision_u* col = mFI_UtNum2UtCol(ux, uz); + + if ( + // clang-format off + col->data.center == col->data.top_left && + col->data.center == col->data.bot_left && + col->data.center == col->data.bot_right && + col->data.center == col->data.top_right + // clang-format on + ) { + col->data.center = mCoBG_OffsetInRule(keep_h + ofs_data.centerRight_offset); + col->data.top_left = mCoBG_OffsetInRule(keep_h + ofs_data.leftUp_offset); + col->data.bot_left = mCoBG_OffsetInRule(keep_h + ofs_data.leftDown_offset); + col->data.bot_right = mCoBG_OffsetInRule(keep_h + ofs_data.rightDown_offset); + col->data.top_right = mCoBG_OffsetInRule(keep_h + ofs_data.rightUp_offset); + col->data.slate_flag = (s8)ofs_data.shape; + + if (ofs_data.unit_attribute != mCoBG_ATTRIBUTE_NONE) { + col->data.unit_attribute = ofs_data.unit_attribute; + } + } else if ( + // clang-format off + ofs_data.centerRight_offset == 0 && + ofs_data.leftUp_offset == 0 && + ofs_data.leftDown_offset == 0 && + ofs_data.rightDown_offset == 0 && + ofs_data.rightUp_offset == 0 + // clang-format on + ) { + if (col->data.slate_flag) { + col->data.center = keep_h; + col->data.top_left = keep_h; + col->data.bot_left = keep_h; + col->data.bot_right = keep_h; + col->data.top_right = keep_h; + col->data.slate_flag = FALSE; + } else { + col->data.center = keep_h; + col->data.top_left = keep_h; + col->data.bot_left = keep_h; + col->data.bot_right = keep_h; + col->data.top_right = keep_h; + } + + if (ofs_data.unit_attribute != mCoBG_ATTRIBUTE_NONE) { + col->data.unit_attribute = ofs_data.unit_attribute; + } + } + } +} + +typedef struct { + u8 src; + u8 dst; +} mCoBG_change_poor_c; + +extern int mCoBG_Change2PoorAttr(mCoBG_Collision_u* col) { + static mCoBG_change_poor_c change_data[] = { + { mCoBG_ATTRIBUTE_GRASS0, mCoBG_ATTRIBUTE_GRASS2 }, + { mCoBG_ATTRIBUTE_GRASS1, mCoBG_ATTRIBUTE_GRASS2 }, + { mCoBG_ATTRIBUTE_SOIL0, mCoBG_ATTRIBUTE_SOIL2 }, + { mCoBG_ATTRIBUTE_SOIL1, mCoBG_ATTRIBUTE_SOIL2 }, + }; + const u8 attr = col->data.unit_attribute; + int i; + + for (i = 0; i < ARRAY_COUNT(change_data); i++) { + if (attr == change_data[i].src) { + col->data.unit_attribute = change_data[i].dst; + return TRUE; + } + } + + return FALSE; +} + +extern void mCoBG_Ut2SetDefaultOffset(int ux, int uz) { + static mCoBG_OffsetTable_c offset_data = { mCoBG_ATTRIBUTE_NONE, 0, 0, 0, 0, 0, FALSE }; + + mCoBG_Ut2SetPluss5PointOffset_file(ux, uz, offset_data, __FILE__, 2724); +} + +int mCoBG_block_bgcheck_mode = mCoBG_BLOCK_BGCHECK_MODE_NORMAL; + +extern void mCoBG_InitBlockBgCheckMode(void) { + mCoBG_block_bgcheck_mode = mCoBG_BLOCK_BGCHECK_MODE_NORMAL; +} + +extern int mCoBG_ChangeBlockBgCheckMode(int mode) { + mCoBG_block_bgcheck_mode = mode & 1; + return mCoBG_block_bgcheck_mode; +} + +extern int mCoBG_GetBlockBgCheckMode(void) { + return mCoBG_block_bgcheck_mode & 1; +} + +extern xyz_t mCoBG_UniqueWallCheck(ACTOR* actorx, f32 range, f32 y_ofs) { + int bx; + int bz; + xyz_t ret = { 0.0f, 0.0f, 0.0f }; + + mCoBG_InitRevpos(&l_ActorInf.rev_pos); + mCoBG_GetCurrentCenterPosition(&l_ActorInf.center_pos, actorx); + mCoBG_GetOldCenterPosition(&l_ActorInf.old_center_pos, actorx); + mCoBG_GetSpeedByWpos(l_ActorInf.speed_xz0, actorx); + + if (mFI_Wpos2BlockNum(&bx, &bz, l_ActorInf.old_center_pos)) { + xyz_t block_base = { 0.0f, 0.0f, 0.0f }; + + mCoBG_SetXyz_t(&l_ActorInf.rev_pos, 0.0f, 0.0f, 0.0f); + mFI_BkNum2WposXZ(&block_base.x, &block_base.z, bx, bz); + if (mCoBG_GetBlockBgCheckMode() == mCoBG_BLOCK_BGCHECK_MODE_INTRO_DEMO && + (mFI_BkNum2BlockKind(bx, bz) & mRF_BLOCKKIND_PLAYER) != 0 + ) { + block_base.x += mFI_UT_WORLDSIZE_X_F; + block_base.z += mFI_UT_WORLDSIZE_Z_F; + return mCoBG_ScopeWallCheck(actorx, &block_base, mFI_BK_WORLDSIZE_X - 2 * mFI_UT_WORLDSIZE_X, mFI_BK_WORLDSIZE_Z - 2 * mFI_UT_WORLDSIZE_Z, range, y_ofs); + } else { + return mCoBG_ScopeWallCheck(actorx, &block_base, mFI_BK_WORLDSIZE_X, mFI_BK_WORLDSIZE_Z, range, y_ofs); + } + } + + return ret; +} + +// GAFU01 reworks this to check based on the actor's world position, use stack xyz_t instead of l_ActorInf.rev_pos, +// and moves carry out reverse to before the ground check. +extern xyz_t mCoBG_ScopeWallCheck(ACTOR* actorx, const xyz_t* base_pos, f32 x, f32 z, f32 range, f32 y_ofs) { + f32 start[2]; + f32 end[2]; + s16 rev_type; + xyz_t rev = { 0.0f, 0.0f, 0.0f }; + xyz_t rev_new; + xyz_t xyz_t_why; + + mCoBG_InitRevpos(&l_ActorInf.rev_pos); + mCoBG_GetCurrentCenterPosition(&l_ActorInf.center_pos, actorx); + mCoBG_GetOldCenterPosition(&l_ActorInf.old_center_pos, actorx); + mCoBG_GetSpeedByWpos(l_ActorInf.speed_xz0, actorx); + + if (l_ActorInf.speed_xz0[0] != 0.0f || l_ActorInf.speed_xz0[1] != 0.0f) { + start[0] = (base_pos->x); + start[1] = (base_pos->z); + end[0] = start[0] + x; + end[1] = start[1] + z; + + start[0] += range; + start[1] += range; + + end[0] -= range; + end[1] -= range; + + mCoBG_SetXyz_t(&rev_new, 0.0f, 0.0f, 0.0f); + + if (actorx->world.position.x < start[0]) { + rev_new.x = start[0] - actorx->world.position.x; + } else if (actorx->world.position.x > end[0]) { + rev_new.x = end[0] - actorx->world.position.x; + } + + if (actorx->world.position.z < start[1]) { + rev_new.z = start[1] - actorx->world.position.z; + } else if (actorx->world.position.z > end[1]) { + rev_new.z = end[1] - actorx->world.position.z; + } + + mCoBG_CarryOutReverse(actorx, rev_new, mCoBG_REVERSE_TYPE_REVERSE); + mCoBG_GroundCheck(&l_ActorInf.rev_pos, &l_ActorInf, actorx, y_ofs, &actorx->bg_collision_check.result, NULL, FALSE); + xyz_t_why.x = rev_new.x; + xyz_t_why.y = l_ActorInf.rev_pos.y; + xyz_t_why.z = rev_new.z; + return xyz_t_why; + } + + return rev; +} diff --git a/src/AUS/game/m_collision_bg_line.c_inc b/src/AUS/game/m_collision_bg_line.c_inc index 9fa215f7..c7ae6fc5 100644 --- a/src/AUS/game/m_collision_bg_line.c_inc +++ b/src/AUS/game/m_collision_bg_line.c_inc @@ -1,4 +1,5 @@ -static void mCoBG_GetSpeedXZ(f32* speed, xyz_t* start, xyz_t* end) { +// GAFU01 changed start & end to const +static void mCoBG_GetSpeedXZ(f32* speed, const xyz_t* start, const xyz_t* end) { speed[0] = end->x - start->x; speed[1] = end->z - start->z; } @@ -295,7 +296,8 @@ static void mCoBG_GetFlatGroundPolygon(xyz_t* v0, xyz_t* v1, xyz_t* v2, f32 bg_y v2->z = z + ofs[2].z; } -static int mCoBG_GetRevGroundAndLine(xyz_t* rev, mCoBG_UnitInfo_c* ut_info, xyz_t start_pos, xyz_t end_pos) { +// GAFU01 changed start_pos & end_pos to be const xyz_t* instead of struct copies +static int mCoBG_GetRevGroundAndLine(xyz_t* rev, mCoBG_UnitInfo_c* ut_info, const xyz_t* start_pos, const xyz_t* end_pos) { xyz_t v0; xyz_t v1; xyz_t v2; @@ -307,6 +309,7 @@ static int mCoBG_GetRevGroundAndLine(xyz_t* rev, mCoBG_UnitInfo_c* ut_info, xyz_ f32 d; f32 dist_start; f32 dist_end; + xyz_t tmp; if ( // clang-format off @@ -321,7 +324,7 @@ static int mCoBG_GetRevGroundAndLine(xyz_t* rev, mCoBG_UnitInfo_c* ut_info, xyz_ f32 z; int i; - if (start_pos.y >= end_pos.y) { + if (start_pos->y >= end_pos->y) { bg_y = ut_info->leftUp_offset; x = ut_info->ut_x * mFI_UT_WORLDSIZE_X_F; z = ut_info->ut_z * mFI_UT_WORLDSIZE_Z_F; @@ -330,13 +333,13 @@ static int mCoBG_GetRevGroundAndLine(xyz_t* rev, mCoBG_UnitInfo_c* ut_info, xyz_ mCoBG_GetFlatGroundPolygon(&v0, &v1, &v2, bg_y, x, z, i); Math3DPlane(&v0, &v1, &v2, &a, &b, &c, &d); - dist_start = Math3DSignedLengthPlaneAndPos(a, b, c, d, &start_pos); - dist_end = Math3DSignedLengthPlaneAndPos(a, b, c, d, &end_pos); + dist_start = Math3DSignedLengthPlaneAndPos(a, b, c, d, start_pos); + dist_end = Math3DSignedLengthPlaneAndPos(a, b, c, d, end_pos); if (dist_start >= 0.0f && dist_end <= 0.0f) { - if (mCoBG_GetCrossTriangleAndLine3D(&cross, v0, v1, v2, start_pos, end_pos)) { - rev->x = cross.x - end_pos.x; - rev->y = cross.y - end_pos.y; - rev->z = cross.z - end_pos.z; + if (mCoBG_GetCrossTriangleAndLine3D(&cross, v0, v1, v2, *start_pos, *end_pos)) { + rev->x = cross.x - end_pos->x; + rev->y = cross.y - end_pos->y; + rev->z = cross.z - end_pos->z; return TRUE; } } @@ -347,13 +350,13 @@ static int mCoBG_GetRevGroundAndLine(xyz_t* rev, mCoBG_UnitInfo_c* ut_info, xyz_ mCoBG_GetAreaPolygon(&v0, &v1, &v2, ut_info, area); Math3DPlane(&v0, &v1, &v2, &a, &b, &c, &d); - dist_start = Math3DSignedLengthPlaneAndPos(a, b, c, d, &start_pos); - dist_end = Math3DSignedLengthPlaneAndPos(a, b, c, d, &end_pos); + dist_start = Math3DSignedLengthPlaneAndPos(a, b, c, d, start_pos); + dist_end = Math3DSignedLengthPlaneAndPos(a, b, c, d, end_pos); if (dist_start >= 0.0f && dist_end <= 0.0f) { - if (mCoBG_GetCrossTriangleAndLine3D(&cross, v0, v1, v2, start_pos, end_pos)) { - rev->x = cross.x - end_pos.x; - rev->y = cross.y - end_pos.y; - rev->z = cross.z - end_pos.z; + if (mCoBG_GetCrossTriangleAndLine3D(&cross, v0, v1, v2, *start_pos, *end_pos)) { + rev->x = cross.x - end_pos->x; + rev->y = cross.y - end_pos->y; + rev->z = cross.z - end_pos->z; return TRUE; } } @@ -363,7 +366,8 @@ static int mCoBG_GetRevGroundAndLine(xyz_t* rev, mCoBG_UnitInfo_c* ut_info, xyz_ return FALSE; } -static int mCoBG_LineGroundCheck_Move(xyz_t* rev, xyz_t* start_pos, xyz_t* end_pos) { +// GAFU01 changed start_pos & end_pos to be const +static int mCoBG_LineGroundCheck_Move(xyz_t* rev, const xyz_t* start_pos, const xyz_t* end_pos) { mCoBG_bg_regist_c* regist_p; mCoBG_mBgMgr_c* bg_mgr = &l_mBgMgr; mCoBG_bg_regist_c** regist_pp = bg_mgr->regist_p; @@ -477,7 +481,8 @@ static int mCoBG_LineGroundCheck_Move(xyz_t* rev, xyz_t* start_pos, xyz_t* end_p return FALSE; } -static int mCoBG_LineGroundCheck(xyz_t* rev, xyz_t start_pos, xyz_t end_pos) { +// GAFU01 changed start_pos and end_pos to be const xyz_t* +static int mCoBG_LineGroundCheck(xyz_t* rev, const xyz_t* start_pos, const xyz_t* end_pos) { mCoBG_UnitInfo_c* ut_info = l_crtutInf; int i; xyz_t ground_rev = { 0.0f, 0.0f, 0.0f }; @@ -492,7 +497,7 @@ static int mCoBG_LineGroundCheck(xyz_t* rev, xyz_t start_pos, xyz_t end_pos) { ut_info++; } - if (mCoBG_LineGroundCheck_Move(&move_rev, &start_pos, &end_pos)) { + if (mCoBG_LineGroundCheck_Move(&move_rev, start_pos, end_pos)) { *rev = move_rev; return TRUE; } @@ -500,24 +505,26 @@ static int mCoBG_LineGroundCheck(xyz_t* rev, xyz_t start_pos, xyz_t end_pos) { return FALSE; } -static void mCoBG_MakeLineCheckCollisionData(xyz_t start_pos, xyz_t end_pos) { +// GAFU01 changed start_pos and end_pos to be const xyz_t* +static void mCoBG_MakeLineCheckCollisionData(const xyz_t* start_pos, const xyz_t* end_pos) { int ux; int uz; f32 speed[2]; - mCoBG_GetSpeedXZ(speed, &start_pos, &end_pos); - mFI_Wpos2UtNum(&ux, &uz, start_pos); + mCoBG_GetSpeedXZ(speed, start_pos, end_pos); + mFI_Wpos2UtNum(&ux, &uz, *start_pos); mCoBG_TransCenter(&ux, &uz, speed, 3); mCoBG_MakeSizeUnitInfo(l_crtutInf, ux, uz, 3); mCoBG_MakeUnitVector(&l_VecInf, l_crtutInf, 3, mCoBG_CHECK_TYPE_NORMAL, TRUE, FALSE, FALSE); } -static int mCoBG_JudgeStartLineCheck(xyz_t* rev, xyz_t start_pos, xyz_t end_pos) { +// GAFU01 changed start_pos and end_pos to be const xyz_t* +static int mCoBG_JudgeStartLineCheck(xyz_t* rev, const xyz_t* start_pos, const xyz_t* end_pos) { if (rev != NULL) { mCoBG_InitRevpos(rev); } - if (F32_IS_ZERO(start_pos.x - end_pos.x) && F32_IS_ZERO(start_pos.y - end_pos.y) && F32_IS_ZERO(start_pos.z - end_pos.z)) { + if (F32_IS_ZERO(start_pos->x - end_pos->x) && F32_IS_ZERO(start_pos->y - end_pos->y) && F32_IS_ZERO(start_pos->z - end_pos->z)) { return FALSE; } @@ -532,21 +539,27 @@ static void mCoBG_SetWallGroundReverse(xyz_t* rev, const xyz_t* wall_rev, const } } +static void mCoBG_PlusEqualPos(xyz_t* p0, xyz_t* p1) { + p0->x += p1->x; + p0->y += p1->y; + p0->z += p1->z; +} + extern int mCoBG_LineCheck_RemoveFg(xyz_t* rev, xyz_t start_pos, xyz_t end_pos, mCoBG_COLUMN_CHECK_ITEM_TYPE_PROC check_proc, int line_check_type) { int ret = 0; bzero(l_crtutInf, sizeof(l_crtutInf)); bzero(&l_VecInf, sizeof(l_VecInf)); - if (mCoBG_JudgeStartLineCheck(rev, start_pos, end_pos)) { + if (mCoBG_JudgeStartLineCheck(rev, &start_pos, &end_pos)) { xyz_t wall_rev = { 0.0f, 0.0f, 0.0f }; xyz_t ground_rev = { 0.0f, 0.0f, 0.0f }; xyz_t wall_col_rev = { 0.0f, 0.0f, 0.0f }; xyz_t ground_col_rev = { 0.0f, 0.0f, 0.0f }; - mCoBG_MakeLineCheckCollisionData(start_pos, end_pos); + mCoBG_MakeLineCheckCollisionData(&start_pos, &end_pos); mCoBG_MakeMoveBgVector(&l_VecInf, &l_mBgMgr, &end_pos, mCoBG_CHECK_TYPE_PLAYER); - mCoBG_MakeColumnCollisionData(l_VecInf.column, &l_VecInf.col_count, l_crtutInf, 3, FALSE, check_proc, -1, -1); + mCoBG_MakeColumnCollisionData(NULL, l_VecInf.column, &l_VecInf.col_count, l_crtutInf, 3, FALSE, check_proc, -1, -1); if ((line_check_type & mCoBG_LINE_CHECK_WALL) != 0) { if (mCoBG_LineWallCheck(&wall_rev, start_pos, end_pos)) { @@ -561,7 +574,7 @@ extern int mCoBG_LineCheck_RemoveFg(xyz_t* rev, xyz_t start_pos, xyz_t end_pos, } if ((line_check_type & mCoBG_LINE_CHECK_GROUND) != 0) { - if (mCoBG_LineGroundCheck(&ground_rev, start_pos, end_pos)) { + if (mCoBG_LineGroundCheck(&ground_rev, &start_pos, &end_pos)) { ret |= mCoBG_LINE_CHECK_GROUND; } mCoBG_PlusEqualPos(&end_pos, &ground_rev); @@ -577,7 +590,7 @@ extern int mCoBG_LineCheck_RemoveFg(xyz_t* rev, xyz_t start_pos, xyz_t end_pos, ret |= mCoBG_LINE_CHECK_WATER; } else { if (mCoBG_CheckWaterAttribute(mCoBG_Wpos2Attribute(end_pos, NULL))) { - f32 water_y = mCoBG_GetWaterHeight_File(end_pos, __FILE__, 880); + f32 water_y = mCoBG_GetWaterHeight_File(end_pos, __FILE__, 894); if (end_pos.y <= water_y + 1.0f) { ret |= mCoBG_LINE_CHECK_UNDERWATER; diff --git a/src/AUS/game/m_collision_bg_math.c b/src/AUS/game/m_collision_bg_math.c index 2767aaca..33f3f251 100644 --- a/src/AUS/game/m_collision_bg_math.c +++ b/src/AUS/game/m_collision_bg_math.c @@ -110,7 +110,7 @@ extern int mCoBG_GetDimension2Idx(f32 p0, f32 p1, f32 p2) { return mCoBG_DIM_ALL; } -extern int mCoBG_GetCrossTriangleAndLine3D(xyz_t* cross, xyz_t v0, xyz_t v1, xyz_t v2, xyz_t line0, xyz_t line1) { +extern int mCoBG_GetCrossTriangleAndLine3D(xyz_t* cross, xyz_t v0, xyz_t v1, xyz_t v2, const xyz_t line0, const xyz_t line1) { f32 x; f32 y; f32 z; @@ -127,10 +127,10 @@ extern int mCoBG_GetCrossTriangleAndLine3D(xyz_t* cross, xyz_t v0, xyz_t v1, xyz cross->z = 0.0f; Math3DPlane(&v0, &v1, &v2, &nox, &noy, &noz, &dist); - t = (nox * line0.x + noy * line0.y + noz * line0.z) + dist; x = line0.x - line1.x; y = line0.y - line1.y; z = line0.z - line1.z; + t = (nox * line0.x + noy * line0.y + noz * line0.z) + dist; ldist = nox * x + noy * y + noz * z; if (!F32_IS_ZERO(ldist)) { int dim; diff --git a/src/AUS/game/m_collision_bg_move.c_inc b/src/AUS/game/m_collision_bg_move.c_inc index 75e11199..ec6bcb3e 100644 --- a/src/AUS/game/m_collision_bg_move.c_inc +++ b/src/AUS/game/m_collision_bg_move.c_inc @@ -31,12 +31,6 @@ static void mCoBG_PlusLinePos(f32* line, f32 x, f32 z) { line[1] += z; } -static void mCoBG_PlusEqualPos(xyz_t* p0, xyz_t* p1) { - p0->x += p1->x; - p0->y += p1->y; - p0->z += p1->z; -} - extern int mCoBG_GetMoveBgHeight(f32* move_bg_height, xyz_t* pos_p) { mCoBG_mBgMgr_c* bg_mgr = &l_mBgMgr; mCoBG_bg_regist_c* regist_p; diff --git a/src/AUS/game/m_collision_bg_rewrite.c_inc b/src/AUS/game/m_collision_bg_rewrite.c_inc index 0422f1ca..e69de29b 100644 --- a/src/AUS/game/m_collision_bg_rewrite.c_inc +++ b/src/AUS/game/m_collision_bg_rewrite.c_inc @@ -1,183 +0,0 @@ -static u32 mCoBG_OffsetInRule(int ofs) { - if (ofs > 31) { - return 31; - } - - return CLAMP(ofs, 0, ofs); -} - -static void mCoBG_SetBestBgY(mCoBG_Collision_u* col, s16* change_ofs) { - u32 max = mCoBG_GetMaxOffset(col->data.center, col->data.top_left, col->data.bot_left, col->data.bot_right, col->data.top_right); - u32 min = mCoBG_GetMinOffset(col->data.center, col->data.top_left, col->data.bot_left, col->data.bot_right, col->data.top_right); -} - -static void mCoBG_TidyChangeOffset(s16* change_ofs, mCoBG_Collision_u* col) { - if ( - // clang-format off - col->data.center + *change_ofs > 31 || - col->data.top_left + *change_ofs > 31 || - col->data.bot_left + *change_ofs > 31 || - col->data.bot_right + *change_ofs > 31 || - col->data.top_right + *change_ofs > 31 || - col->data.center + *change_ofs < 0 || - col->data.top_left + *change_ofs < 0 || - col->data.bot_left + *change_ofs < 0 || - col->data.bot_right + *change_ofs < 0 || - col->data.top_right + *change_ofs < 0 - // clang-format on - ) { - mCoBG_SetBestBgY(col, change_ofs); - } -} - -// @unused, @fabricated -extern void mCoBG_Ut2SetPlussOffset(int ux, int uz, s16 change_ofs, s16 attr) { - xyz_t pos = { 0.0f, 0.0f, 0.0f }; - - if (mFI_UtNum2CenterWpos(&pos, ux, uz)) { - mCoBG_SetPlussOffset(pos, change_ofs, attr); - } -} - -extern void mCoBG_SetPlussOffset(xyz_t wpos, s16 change_ofs, s16 attr) { - int ux; - int uz; - - if (mFI_Wpos2UtNum(&ux, &uz, wpos)) { - mCoBG_Collision_u* col = mFI_UtNum2UtCol(ux, uz); - u8 keep_h = mFI_UtNum2UtKeepH(ux, uz); - - if (keep_h == col->data.center) { - mCoBG_TidyChangeOffset(&change_ofs, col); - } else { - u32 gap = keep_h - col->data.center; - - col->data.center = (u8)keep_h; - col->data.top_left += gap; - col->data.bot_left += gap; - col->data.bot_right += gap; - col->data.top_right += gap; - mCoBG_TidyChangeOffset(&change_ofs, col); - } - - col->data.center += change_ofs; - col->data.bot_left += change_ofs; - col->data.top_left += change_ofs; - col->data.top_right += change_ofs; - col->data.bot_right += change_ofs; - - if (attr != mCoBG_ATTRIBUTE_NONE) { - col->data.unit_attribute = (s16)attr; - } - - } -} - -extern void mCoBG_SetAttribute(xyz_t pos, s16 attr) { - mCoBG_Collision_u* col; - int ux; - int uz; - - if (mFI_Wpos2UtNum(&ux, &uz, pos)) { - col = mFI_UtNum2UtCol(ux, uz); - if (attr != mCoBG_ATTRIBUTE_NONE) { - col->data.unit_attribute = (s16)attr; - } - } -} - -extern void mCoBG_Ut2SetPluss5PointOffset_file(int ux, int uz, mCoBG_OffsetTable_c ofs_data, char* file, int line) { - xyz_t pos = { 0.0f, 0.0f, 0.0f }; - - if (mFI_UtNum2CenterWpos(&pos, ux, uz)) { - mCoBG_SetPluss5PointOffset_file(pos, ofs_data, file, line); - } -} - -extern void mCoBG_SetPluss5PointOffset_file(xyz_t pos, mCoBG_OffsetTable_c ofs_data, char* file, int line) { - int ux; - int uz; - - if (mFI_Wpos2UtNum(&ux, &uz, pos)) { - u8 keep_h = mFI_UtNum2UtKeepH(ux, uz); - mCoBG_Collision_u* col = mFI_UtNum2UtCol(ux, uz); - - if ( - // clang-format off - col->data.center == col->data.top_left && - col->data.center == col->data.bot_left && - col->data.center == col->data.bot_right && - col->data.center == col->data.top_right - // clang-format on - ) { - col->data.center = mCoBG_OffsetInRule(keep_h + ofs_data.centerRight_offset); - col->data.top_left = mCoBG_OffsetInRule(keep_h + ofs_data.leftUp_offset); - col->data.bot_left = mCoBG_OffsetInRule(keep_h + ofs_data.leftDown_offset); - col->data.bot_right = mCoBG_OffsetInRule(keep_h + ofs_data.rightDown_offset); - col->data.top_right = mCoBG_OffsetInRule(keep_h + ofs_data.rightUp_offset); - col->data.slate_flag = (s8)ofs_data.shape; - - if (ofs_data.unit_attribute != mCoBG_ATTRIBUTE_NONE) { - col->data.unit_attribute = ofs_data.unit_attribute; - } - } else if ( - // clang-format off - ofs_data.centerRight_offset == 0 && - ofs_data.leftUp_offset == 0 && - ofs_data.leftDown_offset == 0 && - ofs_data.rightDown_offset == 0 && - ofs_data.rightUp_offset == 0 - // clang-format on - ) { - if (col->data.slate_flag) { - col->data.center = keep_h; - col->data.top_left = keep_h; - col->data.bot_left = keep_h; - col->data.bot_right = keep_h; - col->data.top_right = keep_h; - col->data.slate_flag = FALSE; - } else { - col->data.center = keep_h; - col->data.top_left = keep_h; - col->data.bot_left = keep_h; - col->data.bot_right = keep_h; - col->data.top_right = keep_h; - } - - if (ofs_data.unit_attribute != mCoBG_ATTRIBUTE_NONE) { - col->data.unit_attribute = ofs_data.unit_attribute; - } - } - } -} - -typedef struct { - u8 src; - u8 dst; -} mCoBG_change_poor_c; - -extern int mCoBG_Change2PoorAttr(mCoBG_Collision_u* col) { - static mCoBG_change_poor_c change_data[] = { - { mCoBG_ATTRIBUTE_GRASS0, mCoBG_ATTRIBUTE_GRASS2 }, - { mCoBG_ATTRIBUTE_GRASS1, mCoBG_ATTRIBUTE_GRASS2 }, - { mCoBG_ATTRIBUTE_SOIL0, mCoBG_ATTRIBUTE_SOIL2 }, - { mCoBG_ATTRIBUTE_SOIL1, mCoBG_ATTRIBUTE_SOIL2 }, - }; - u8 attr = col->data.unit_attribute; - int i; - - for (i = 0; i < ARRAY_COUNT(change_data); i++) { - if (attr == change_data[i].src) { - col->data.unit_attribute = change_data[i].dst; - return TRUE; - } - } - - return FALSE; -} - -extern void mCoBG_Ut2SetDefaultOffset(int ux, int uz) { - static mCoBG_OffsetTable_c offset_data = { mCoBG_ATTRIBUTE_NONE, 0, 0, 0, 0, 0, FALSE }; - - mCoBG_Ut2SetPluss5PointOffset_file(ux, uz, offset_data, __FILE__, 515); -} diff --git a/src/AUS/game/m_collision_bg_water.c_inc b/src/AUS/game/m_collision_bg_water.c_inc index a6bfc7a3..e69de29b 100644 --- a/src/AUS/game/m_collision_bg_water.c_inc +++ b/src/AUS/game/m_collision_bg_water.c_inc @@ -1,184 +0,0 @@ -extern f32 mCoBG_GetBgY_AngleS_FromWpos2(s_xyz* ground_angle, xyz_t pos, f32 ground_dist) { - mCoBG_UnitInfo_c ut_info; - s_xyz normal_ground_angle; - f32 normal_y; - f32 column_y; - static s_xyz ground_angle0 = { 0, 0, 0 }; - f32 t0; - f32 t1; - f32 ret; - - if (ground_angle != NULL) { - *ground_angle = ground_angle0; - } - - mCoBG_Wpos2UnitInfo(&ut_info, pos); - normal_y = mCoBG_GetBGHeight_Normal(&normal_ground_angle, &ut_info); - column_y = mCoBG_GetBGHeight_Column(&pos, &ut_info); - - if (ground_angle != NULL && normal_y >= column_y && normal_y >= -100.0f) { - *ground_angle = normal_ground_angle; - return normal_y - ground_dist; - } - - t0 = MAX(normal_y, -100.0f); - t1 = MAX(normal_y, column_y); - if (t1 > t0) { - ret = MAX(normal_y, column_y); - } else { - ret = MAX(normal_y, -100.0f); - } - - return ret - ground_dist; -} - -extern f32 mCoBG_GetWaterHeight_File(xyz_t pos, char* file, int line) { - u32 attr; - int ux; - int uz; - mCoBG_Collision_u* col; - xyz_t mod_pos = pos; - - mFI_Wpos2UtNum(&ux, &uz, pos); - col = mFI_UtNum2UtCol(ux, uz); - attr = col->data.unit_attribute; - - if (attr == mCoBG_ATTRIBUTE_SEA || attr == mCoBG_ATTRIBUTE_37 || attr == mCoBG_ATTRIBUTE_38) { - return 20.0f; - } - - if (attr >= mCoBG_ATTRIBUTE_WATER && attr <= mCoBG_ATTRIBUTE_RIVER_NE) { - return 20.0f + mCoBG_GetBgY_AngleS_FromWpos2(NULL, pos, 0.0f); - } - - if (attr >= mCoBG_ATTRIBUTE_27 && attr <= mCoBG_ATTRIBUTE_35) { - int idx = attr - mCoBG_ATTRIBUTE_27; - int search = mCoBG_bridge_search_water[idx]; - u32 new_attr; - int i; - - for (i = 0; i < mSc_DIRECT_NUM; i++) { - if ((search & (1 << i)) != 0) { - int ux; - int uz; - - mCoBG_PlussDirectOffset(&mod_pos, pos, i); - mFI_Wpos2UtNum(&ux, &uz, mod_pos); - new_attr = mFI_UtNum2UtCol(ux, uz)->data.unit_attribute; - - if (new_attr >= mCoBG_ATTRIBUTE_WATER && new_attr <= mCoBG_ATTRIBUTE_RIVER_NE) { - return 20.0f + mCoBG_GetBgY_AngleS_FromWpos2(NULL, mod_pos, 0.0f); - } - } - } - } else if (attr >= mCoBG_ATTRIBUTE_39 && attr <= mCoBG_ATTRIBUTE_42) { - u32 attr2 = mCoBG_Wpos2Attribute(pos, NULL); - - if (attr2 >= mCoBG_ATTRIBUTE_WATER && attr2 <= mCoBG_ATTRIBUTE_RIVER_NE) { - int i; - u32 new_attr; - xyz_t new_pos; - int idx = attr - mCoBG_ATTRIBUTE_39; - int search = mCoBG_grass3_search_water[idx]; - - for (i = 0; i < mSc_DIRECT_NUM; i++) { - if ((search & (1 << i)) != 0) { - int ux; - int uz; - - mCoBG_PlussDirectOffset(&new_pos, pos, i); - mFI_Wpos2UtNum(&ux, &uz, new_pos); - new_attr = mFI_UtNum2UtCol(ux, uz)->data.unit_attribute; - - if (new_attr >= mCoBG_ATTRIBUTE_WATER && new_attr <= mCoBG_ATTRIBUTE_RIVER_NE) { - return 20.0f + mCoBG_GetBgY_AngleS_FromWpos2(NULL, new_pos, 0.0f); - } - } - } - } - } - - return -100.0f; -} - - -extern int mCoBG_CheckWaterAttribute(u32 attr) { - if (attr == mCoBG_ATTRIBUTE_SEA) { - return TRUE; - } - - if (attr >= mCoBG_ATTRIBUTE_WATER && attr <= mCoBG_ATTRIBUTE_RIVER_NE) { - return TRUE; - } - - return FALSE; -} - -extern int mCoBG_CheckWaterAttribute_OutOfSea(u32 attr) { - if (attr >= mCoBG_ATTRIBUTE_WATER && attr <= mCoBG_ATTRIBUTE_RIVER_NE) { - return TRUE; - } - - return FALSE; -} - -static f32 mCoBG_wave_cos = 0.0f; - -extern void mCoBG_WaveCos2BgCheck(f32 value) { - mCoBG_wave_cos = value; -} - -extern f32 mCoBG_WaveCos(void) { - return mCoBG_wave_cos; -} - -extern int mCoBG_GetWaterFlow(xyz_t* flow, u32 attr) { - static xyz_t flow_data[] = { - {0.0f, 0.0f, 0.0f}, - {0.0f, -5.0f, 0.0f}, - {0.0f, 0.0f, -0.5f}, - {-0.35355338f, 0.0f, -0.35355338f}, - {-0.5f, 0.0f, 0.0f}, - {-0.35355338f, 0.0f, 0.35355338f}, - {0.0f, 0.0f, 0.5f}, - {0.35355338f, 0.0f, 0.35355338f}, - {0.5f, 0.0f, 0.0f}, - {0.35355338f, 0.0f, -0.35355338f}, - }; - - if (attr == mCoBG_ATTRIBUTE_SEA) { - static const xyz_t sea_flow = { 0.0f, 0.0f, -1.0f }; - - *flow = sea_flow; - return TRUE; - } - - if (mCoBG_CheckWaterAttribute(attr)) { - int idx = attr - mCoBG_ATTRIBUTE_WATER; - - *flow = flow_data[idx]; - return TRUE; - } - - *flow = flow_data[0]; - return FALSE; -} - -extern int mCoBG_CheckWaveAttr(u32 attr) { - if (attr == mCoBG_ATTRIBUTE_WAVE || attr == mCoBG_ATTRIBUTE_36 || attr == mCoBG_ATTRIBUTE_25 || attr == mCoBG_ATTRIBUTE_26) { - return TRUE; - } - - return FALSE; -} - -// @unused, @fabricated -extern int mCoBG_CheckSand2Sea(xyz_t* pos) { - u32 attr = mCoBG_Wpos2BgAttribute_Original(*pos); - - if (attr == mCoBG_ATTRIBUTE_SEA || mCoBG_CheckWaveAttr(attr)) { - return TRUE; - } - - return FALSE; -} diff --git a/src/actor/ac_quest_talk_island.c b/src/actor/ac_quest_talk_island.c index 29e5841a..e88c99a3 100644 --- a/src/actor/ac_quest_talk_island.c +++ b/src/actor/ac_quest_talk_island.c @@ -192,7 +192,7 @@ static void aQMgr_normal_set_free_str(QUEST_MANAGER_ACTOR* manager) { mMsg_SET_FREE_STR(mMsg_FREE_STR12, animal->parent_name, LAND_NAME_SIZE); } -typedef int (*aQMgr_CALENDAR_CONV_PROC)(lbRTC_ymd_c*, const lbRTC_ymd_c*); +typedef int (*aQMgr_CALENDAR_CONV_PROC)(lbRTC_ymd_c*, lbRTC_ymd_c*); static void aQMgr_set_calendar_free_str(aQMgr_CALENDAR_CONV_PROC conv_proc, int month_str_no, int day_str_no, u8 month, u8 day) { static u8 uru_tuki[10] = "leap month"; @@ -1600,18 +1600,15 @@ static int aQMgr_decide_player_msg_no(QUEST_MANAGER_ACTOR* manager, int looks) { static Anmmem_c* aQMgr_get_other_memory(Anmmem_c* memory, int cnt, PersonalID_c* pid, int needs_letter) { int j; int mem_cnt; - Anmmem_c* mem; - int i; Anmmem_c* ret_mem = NULL; + int i; int sel_idx; ret_mem = NULL; mem_cnt = 0; for (i = 0; i < cnt; i++) { - mem = &memory[i]; - - if (!mNpc_CheckFreeAnimalMemory(mem) && mPr_CheckCmpPersonalID(pid, &mem->memory_player_id) != TRUE && (!needs_letter || mem->letter_info.exists == TRUE)) { + if (!mNpc_CheckFreeAnimalMemory(&memory[i]) && mPr_CheckCmpPersonalID(pid, &memory[i].memory_player_id) != TRUE && (!needs_letter || memory[i].letter_info.exists == TRUE)) { mem_cnt++; } } @@ -1620,11 +1617,9 @@ static Anmmem_c* aQMgr_get_other_memory(Anmmem_c* memory, int cnt, PersonalID_c* sel_idx = RANDOM(mem_cnt); for (j = 0; j < cnt; j++) { - mem = &memory[j]; - - if (!mNpc_CheckFreeAnimalMemory(mem) && !mPr_CheckCmpPersonalID(pid, &mem->memory_player_id) && (!needs_letter || mem->letter_info.exists == TRUE)) { + if (!mNpc_CheckFreeAnimalMemory(&memory[j]) && !mPr_CheckCmpPersonalID(pid, &memory[j].memory_player_id) && (!needs_letter || memory[j].letter_info.exists == TRUE)) { if (sel_idx == 0) { - ret_mem = mem; + ret_mem = &memory[j]; break; } diff --git a/src/actor/ac_quest_talk_normal_init.c b/src/actor/ac_quest_talk_normal_init.c index ca2ea51a..a9fe1248 100644 --- a/src/actor/ac_quest_talk_normal_init.c +++ b/src/actor/ac_quest_talk_normal_init.c @@ -822,7 +822,7 @@ static void aQMgr_set_free_str_memory(Anmmem_c* memory) { aQMgr_set_number_free_str_add_nichi(memory->last_speak_time.day, mMsg_FREE_STR19); } -typedef int (*aQMgr_CALENDAR_CONV_PROC)(lbRTC_ymd_c*, const lbRTC_ymd_c*); +typedef int (*aQMgr_CALENDAR_CONV_PROC)(lbRTC_ymd_c*, lbRTC_ymd_c*); static void aQMgr_set_calendar_free_str(aQMgr_CALENDAR_CONV_PROC conv_proc, int month_str_no, int day_str_no, u8 month, u8 day) { static u8 uru_tuki[10] = "leap month"; diff --git a/src/audio.c b/src/audio.c index c9e712d3..0111b093 100644 --- a/src/audio.c +++ b/src/audio.c @@ -253,8 +253,8 @@ extern void sAdos_KishaStatusTrg(u8 state) { Na_KishaStatusTrg(state); } -extern void sAdos_KishaStatusLevel(f32 speed, u32 ongenNum1, u16 angle1, f32 distance1, u32 ongenNum2, u16 angle2, - f32 distance2) { +extern void sAdos_KishaStatusLevel(f32 speed, u32 ongenNum1, f32 distance1, u16 angle1, u32 ongenNum2, + f32 distance2, u16 angle2) { Na_KishaStatusLevel(speed, ongenNum1, angle1, distance1, ongenNum2, angle2, distance2); } diff --git a/src/c_keyframe.c b/src/c_keyframe.c index d5feea14..bebd350e 100644 --- a/src/c_keyframe.c +++ b/src/c_keyframe.c @@ -365,10 +365,16 @@ extern void cKF_SkeletonInfo_R_init(cKF_SkeletonInfo_R_c* keyframe, cKF_Skeleton * @param keyframe Pointer to the skeleton info structure containing joint and target positions. */ static void cKF_SkeletonInfo_R_morphJoint(cKF_SkeletonInfo_R_c* keyframe) { - f32 step; int i; s_xyz* current_joint = keyframe->current_joint; s_xyz* target_joint = keyframe->target_joint; + f32 step; + s16 next_joint_x; + s16 next_joint_y; + s16 next_joint_z; + s16 next_target_x; + s16 next_target_y; + s16 next_target_z; if (!(F32_IS_ZERO(keyframe->morph_counter))) { step = 0.5f / fabsf(keyframe->morph_counter); @@ -382,14 +388,14 @@ static void cKF_SkeletonInfo_R_morphJoint(cKF_SkeletonInfo_R_c* keyframe) { target_joint++; for (i = 0; i < keyframe->skeleton->num_joints; i++) { - s16 next_joint_x = current_joint->x; - s16 next_target_x = target_joint->x; + next_joint_x = current_joint->x; + next_target_x = target_joint->x; - s16 next_joint_y = current_joint->y; - s16 next_joint_z = current_joint->z; + next_joint_y = current_joint->y; + next_joint_z = current_joint->z; - s16 next_target_y = target_joint->y; - s16 next_target_z = target_joint->z; + next_target_y = target_joint->y; + next_target_z = target_joint->z; if (next_joint_x != next_target_x || next_joint_y != next_target_y || next_joint_z != next_target_z) { f32 difxyz = fabsf((f32)next_target_x - (f32)next_joint_x) + fabsf((f32)next_target_y - (f32)next_joint_y) + @@ -417,6 +423,129 @@ static void cKF_SkeletonInfo_R_morphJoint(cKF_SkeletonInfo_R_c* keyframe) { } } +// TODO: There's probably no difference between this and US. +// The inlines used to match US are fake. +#if VERSION >= VER_GAFU01_00 +extern int cKF_SkeletonInfo_R_play(cKF_SkeletonInfo_R_c* keyframe) { + int i; + int j; + u8* flagTable; + int keyTableIndex = 0; + int fixedTableIndex = 0; + int dataIndex = 0; + s16* jointValuePtr; + s16* fixedTable; + s16* dataTable; + s16* keyTable; + u32 jointFlag; // Check translation (xyz) + + // Choose between current and target joint based on morph counter + if (F32_IS_ZERO(keyframe->morph_counter)) { + jointValuePtr = &keyframe->current_joint->x; + } else { + jointValuePtr = &keyframe->target_joint->x; + } + + jointFlag = cKF_ANIMATION_BIT_TRANS_X; + + // Retrieve animation tables + fixedTable = keyframe->animation->fixed_table; + keyTable = keyframe->animation->key_table; + dataTable = keyframe->animation->data_table; + flagTable = keyframe->animation->flag_table; + + + + // Process root translation x -> y -> z + for (j = 0; j < 3; j++) { + if (*flagTable & jointFlag) { + // Apply joint translation + *jointValuePtr = + cKF_KeyCalc(dataIndex, keyTable[keyTableIndex], dataTable, keyframe->frame_control.current_frame); + dataIndex += keyTable[keyTableIndex]; + keyTableIndex++; + } else { + // Use fixed value if not flagged for keyframe animation + *jointValuePtr = fixedTable[fixedTableIndex]; + fixedTableIndex++; + } + + jointFlag >>= 1; // Shift x -> y -> z + jointValuePtr++; // Move to next joint + } + + // Process remaining joint rotations + for (i = 0; i < keyframe->skeleton->num_joints; i++) { + jointFlag = cKF_ANIMATION_BIT_ROT_X; // Reset flag for new joint + + // Process each joint x -> y -> z + for (j = 0; j < 3; j++) { + f32 adjustedJointValue; + f32 mod; + + // Similar logic to above, but for each joint in the skeleton + if (jointFlag & flagTable[i]) { + *jointValuePtr = + cKF_KeyCalc(dataIndex, keyTable[keyTableIndex], dataTable, keyframe->frame_control.current_frame); + dataIndex += keyTable[keyTableIndex]; + keyTableIndex++; + } else { + *jointValuePtr = fixedTable[fixedTableIndex]; + fixedTableIndex++; + } + + // Reduce the value by 90% and clamp to [0, 360) degrees converted back to binangle (s16) + // This effectively limits any joint's maximum rotation to be in the range of [-36.8, 36.7] degrees + adjustedJointValue = *jointValuePtr * 0.1f; + mod = MOD_F(adjustedJointValue, 360.0f); + *jointValuePtr = DEG2SHORT_ANGLE(mod); + jointValuePtr++; + + + jointFlag >>= 1; // Shift flag for next component x -> y -> z + } + + // flagTable++; + } + + // Apply rotation differences if available + if (keyframe->rotation_diff_table != NULL) { + s_xyz* currentJointPtr = (F32_IS_ZERO(keyframe->morph_counter)) ? keyframe->current_joint : keyframe->target_joint; + + currentJointPtr++; // Skip first joint, usually root, which is handled separately + for (j = 0; j < keyframe->skeleton->num_joints; j++) { + // Apply rotation differences to each joint + currentJointPtr->x += keyframe->rotation_diff_table[j].x; + currentJointPtr->y += keyframe->rotation_diff_table[j].y; + currentJointPtr->z += keyframe->rotation_diff_table[j].z; + + currentJointPtr++; // Move to next joint + } + } + + // Handle morphing and play control based on morph counter + if (F32_IS_ZERO(keyframe->morph_counter)) { + // Play normally if no morphing is needed + return cKF_FrameControl_play(&keyframe->frame_control); + } else if (keyframe->morph_counter > 0.0f) { + // Morph towards target, decreasing morph counter + cKF_SkeletonInfo_R_morphJoint(keyframe); + keyframe->morph_counter -= 0.5f; + if (keyframe->morph_counter <= 0.0f) { + keyframe->morph_counter = 0.0f; // Clamp to zero if over-decremented + } + return cKF_STATE_NONE; + } else { + // Morph from target, increasing morph counter towards zero + cKF_SkeletonInfo_R_morphJoint(keyframe); + keyframe->morph_counter += 0.5f; + if (keyframe->morph_counter >= 0.0f) { + keyframe->morph_counter = 0.0f; // Clamp to zero if over-incremented + } + return cKF_FrameControl_play(&keyframe->frame_control); + } +} +#else /** * Retrieves the flag table from an animation structure. * @@ -574,6 +703,7 @@ extern int cKF_SkeletonInfo_R_play(cKF_SkeletonInfo_R_c* keyframe) { return state; } +#endif extern void cKF_Si3_draw_SV_R_child(GAME* game, cKF_SkeletonInfo_R_c* keyframe, int* joint_num, cKF_draw_callback prerender_callback, cKF_draw_callback postrender_callback, @@ -909,7 +1039,11 @@ extern int cKF_SkeletonInfo_R_combine_play(cKF_SkeletonInfo_R_c* info1, cKF_Skel cKF_SkeletonInfo_R_combine_rotation(&joint, &combinet, &combine[0], part_table); if (info1->rotation_diff_table != NULL) { - applyjoint = (F32_IS_ZERO(info1->morph_counter)) ? info1->current_joint : info1->target_joint; + if (F32_IS_ZERO(info1->morph_counter)) { + applyjoint = info1->current_joint; + } else { + applyjoint = info1->target_joint; + } applyjoint += 1; for (i = 0; i < info1->skeleton->num_joints; i++) { @@ -972,7 +1106,11 @@ extern void cKF_SkeletonInfo_R_T_combine_play(int* state1, int* state2, int* sta cKF_SkeletonInfo_R_combine_rotation(&joint, &combinet, &combine[0], part_table); if (info1->rotation_diff_table != NULL) { - applyjoint = (F32_IS_ZERO(info1->morph_counter)) ? info1->current_joint : info1->target_joint; + if (F32_IS_ZERO(info1->morph_counter)) { + applyjoint = info1->current_joint; + } else { + applyjoint = info1->target_joint; + } applyjoint += 1; for (i = 0; i < info1->skeleton->num_joints; i++) { diff --git a/src/evw_anime.c b/src/evw_anime.c index 11c2059f..b30a1bd2 100644 --- a/src/evw_anime.c +++ b/src/evw_anime.c @@ -4,302 +4,301 @@ #include "libforest/gbi_extensions.h" #include "m_rcp.h" -static Gfx* evw_tex_scroll_set(GAME_PLAY* play, EVW_ANIME_SCROLL* scroll) { - int scroll_x = scroll->x * play->game_frame; - int scroll_y = scroll->y * play->game_frame; +static Gfx* evw_tex_scroll_set(GAME_PLAY* play, const EVW_ANIME_SCROLL* scroll) { + int scroll_x = scroll->x * play->game_frame; + int scroll_y = scroll->y * play->game_frame; - return tex_scroll2_dolphin(play->game.graph, scroll_x, -scroll_y, scroll->width, scroll->height); + return tex_scroll2_dolphin(play->game.graph, scroll_x, -scroll_y, scroll->width, scroll->height); } static void evw_anime_scroll1(GAME_PLAY* play, int segment, void* evw_data) { - EVW_ANIME_SCROLL* scroll = (EVW_ANIME_SCROLL*)evw_data; - Gfx* scroll_gfx = evw_tex_scroll_set(play, scroll); - GRAPH* g = play->game.graph; + EVW_ANIME_SCROLL* scroll = (EVW_ANIME_SCROLL*)evw_data; + Gfx* scroll_gfx = evw_tex_scroll_set(play, scroll); + GRAPH* g = play->game.graph; - OPEN_DISP(g); + OPEN_DISP(g); - gSPSegment(NOW_BG_OPA_DISP++, segment, scroll_gfx); - gSPSegment(NOW_POLY_OPA_DISP++, segment, scroll_gfx); - gSPSegment(NOW_POLY_XLU_DISP++, segment, scroll_gfx); + gSPSegment(NOW_BG_OPA_DISP++, segment, scroll_gfx); + gSPSegment(NOW_POLY_OPA_DISP++, segment, scroll_gfx); + gSPSegment(NOW_POLY_XLU_DISP++, segment, scroll_gfx); - CLOSE_DISP(g); + CLOSE_DISP(g); } -static Gfx* evw_two_tex_scroll_set(GAME_PLAY* play, EVW_ANIME_SCROLL* scrolls) { - u32 frame = play->game_frame; - - int x0 = scrolls[0].x * frame; - int y0 = scrolls[0].y * frame; +static Gfx* evw_two_tex_scroll_set(GAME_PLAY* play, const EVW_ANIME_SCROLL* scrolls) { + u32 frame = play->game_frame; - int x1 = scrolls[1].x * frame; - int y1 = scrolls[1].y * frame; + int x0 = scrolls[0].x * frame; + int y0 = scrolls[0].y * frame; - return two_tex_scroll_dolphin( - play->game.graph, - 0, - x0, -y0, scrolls[0].width, scrolls[0].height, - 1, - x1, -y1, scrolls[1].width, scrolls[1].height - ); + int x1 = scrolls[1].x * frame; + int y1 = scrolls[1].y * frame; + + return two_tex_scroll_dolphin(play->game.graph, 0, x0, -y0, scrolls[0].width, scrolls[0].height, 1, x1, -y1, + scrolls[1].width, scrolls[1].height); } static void evw_anime_scroll2(GAME_PLAY* play, int segment, void* evw_data) { - EVW_ANIME_SCROLL* scrolls = (EVW_ANIME_SCROLL*)evw_data; - Gfx* scroll_gfx = evw_two_tex_scroll_set(play, scrolls); - GRAPH* g = play->game.graph; + EVW_ANIME_SCROLL* scrolls = (EVW_ANIME_SCROLL*)evw_data; + Gfx* scroll_gfx = evw_two_tex_scroll_set(play, scrolls); + GRAPH* g = play->game.graph; - OPEN_DISP(g); + OPEN_DISP(g); - gSPSegment(NOW_BG_OPA_DISP++, segment, scroll_gfx); - gSPSegment(NOW_POLY_OPA_DISP++, segment, scroll_gfx); - gSPSegment(NOW_POLY_XLU_DISP++, segment, scroll_gfx); + gSPSegment(NOW_BG_OPA_DISP++, segment, scroll_gfx); + gSPSegment(NOW_POLY_OPA_DISP++, segment, scroll_gfx); + gSPSegment(NOW_POLY_XLU_DISP++, segment, scroll_gfx); - CLOSE_DISP(g); + CLOSE_DISP(g); } -static void evw_color_set(GAME_PLAY* play, int segment, EVW_ANIME_COL_PRIM* prim, EVW_ANIME_COL_ENV* env) { - Gfx* col_gfx = GRAPH_ALLOC_TYPE(play->game.graph, Gfx, 3); +static void evw_color_set(GAME_PLAY* play, int segment, const EVW_ANIME_COL_PRIM* prim, const EVW_ANIME_COL_ENV* env) { + Gfx* col_gfx = GRAPH_ALLOC_TYPE(play->game.graph, Gfx, 3); - /* Setup small display list for initializing color settings */ - gDPSetPrimColor(col_gfx + 0, 0, prim->l, prim->r, prim->g, prim->b, prim->a); - gDPSetEnvColor(col_gfx + 1, env->r, env->g, env->b, env->a); - gSPEndDisplayList(col_gfx + 2); + /* Setup small display list for initializing color settings */ + gDPSetPrimColor(col_gfx + 0, 0, prim->l, prim->r, prim->g, prim->b, prim->a); + gDPSetEnvColor(col_gfx + 1, env->r, env->g, env->b, env->a); + gSPEndDisplayList(col_gfx + 2); - OPEN_DISP(play->game.graph); + OPEN_DISP(play->game.graph); - /* Point the necessary Gfx buffers to our color display list */ - gSPSegment(NOW_BG_OPA_DISP++, segment, col_gfx); - gSPSegment(NOW_POLY_OPA_DISP++, segment, col_gfx); - gSPSegment(NOW_POLY_XLU_DISP++, segment, col_gfx); + /* Point the necessary Gfx buffers to our color display list */ + gSPSegment(NOW_BG_OPA_DISP++, segment, col_gfx); + gSPSegment(NOW_POLY_OPA_DISP++, segment, col_gfx); + gSPSegment(NOW_POLY_XLU_DISP++, segment, col_gfx); - CLOSE_DISP(play->game.graph); + CLOSE_DISP(play->game.graph); } static void evw_anime_colreg_manual(GAME_PLAY* play, int segment, void* evw_data) { - EVW_ANIME_COLREG* color_reg = (EVW_ANIME_COLREG*)evw_data; - - int frame_idx = play->game_frame % color_reg->frame_count; - EVW_ANIME_COL_PRIM* prim = color_reg->prim_colors; - EVW_ANIME_COL_ENV* env = color_reg->env_colors; + EVW_ANIME_COLREG* color_reg = (EVW_ANIME_COLREG*)evw_data; - prim += frame_idx; - env += frame_idx; + int frame_idx = play->game_frame % color_reg->frame_count; + EVW_ANIME_COL_PRIM* prim = color_reg->prim_colors; + EVW_ANIME_COL_ENV* env = color_reg->env_colors; - evw_color_set(play, segment, prim, env); + prim += frame_idx; + env += frame_idx; + + evw_color_set(play, segment, prim, env); } static int morf_calc(int now, int target, f32 rate) { - return now + (int)(rate * (f32)(target - now)); + return now + (int)(rate * (f32)(target - now)); } static void evw_anime_colreg_linear(GAME_PLAY* play, int segment, void* evw_data) { - EVW_ANIME_COLREG* color_reg = (EVW_ANIME_COLREG*)evw_data; - EVW_ANIME_COL_PRIM* src_prim = color_reg->prim_colors; - EVW_ANIME_COL_ENV* src_env = color_reg->env_colors; + EVW_ANIME_COLREG* color_reg = (EVW_ANIME_COLREG*)evw_data; + EVW_ANIME_COL_PRIM* src_prim = color_reg->prim_colors; + EVW_ANIME_COL_ENV* src_env = color_reg->env_colors; - u16* keyframe = color_reg->keyframes; - u32 game_frame = play->game_frame; - int anime_frame = game_frame % color_reg->frame_count; - int now_keyframe; - int last_keyframe; - int frame_idx = 1; - int i; - - keyframe++; - for (i = 1; i < color_reg->key_count; i++) { - if (anime_frame < *keyframe) { - break; - } + u16* keyframe = color_reg->keyframes; + u32 game_frame = play->game_frame; + int anime_frame = game_frame % color_reg->frame_count; + int now_keyframe; + int last_keyframe; + int frame_idx = 1; + int i; keyframe++; - frame_idx++; - } + for (i = 1; i < color_reg->key_count; i++) { + if (anime_frame < *keyframe) { + break; + } - { - EVW_ANIME_COL_PRIM inter_prim; - EVW_ANIME_COL_ENV inter_env; - int a; - int b; + keyframe++; + frame_idx++; + } - now_keyframe = keyframe[0]; - last_keyframe = keyframe[-1]; - a = anime_frame - last_keyframe; - b = now_keyframe - last_keyframe; + { + EVW_ANIME_COL_PRIM inter_prim; + EVW_ANIME_COL_ENV inter_env; + int a; + int b; - src_prim += frame_idx; - src_env += frame_idx; + now_keyframe = keyframe[0]; + last_keyframe = keyframe[-1]; + a = anime_frame - last_keyframe; + b = now_keyframe - last_keyframe; - /* Interpolate primitive color */ - inter_prim.r = morf_calc(src_prim[-1].r, src_prim[0].r, (f32)a / (f32)b); - inter_prim.g = morf_calc(src_prim[-1].g, src_prim[0].g, (f32)a / (f32)b); - inter_prim.b = morf_calc(src_prim[-1].b, src_prim[0].b, (f32)a / (f32)b); - inter_prim.a = morf_calc(src_prim[-1].a, src_prim[0].a, (f32)a / (f32)b); - inter_prim.l = morf_calc(src_prim[-1].l, src_prim[0].l, (f32)a / (f32)b); + src_prim += frame_idx; + src_env += frame_idx; - /* Interpolate environment color */ - inter_env.r = morf_calc(src_env[-1].r, src_env[0].r, (f32)a / (f32)b); - inter_env.g = morf_calc(src_env[-1].g, src_env[0].g, (f32)a / (f32)b); - inter_env.b = morf_calc(src_env[-1].b, src_env[0].b, (f32)a / (f32)b); - inter_env.a = morf_calc(src_env[-1].a, src_env[0].a, (f32)a / (f32)b); + /* Interpolate primitive color */ + inter_prim.r = morf_calc(src_prim[-1].r, src_prim[0].r, (f32)a / (f32)b); + inter_prim.g = morf_calc(src_prim[-1].g, src_prim[0].g, (f32)a / (f32)b); + inter_prim.b = morf_calc(src_prim[-1].b, src_prim[0].b, (f32)a / (f32)b); + inter_prim.a = morf_calc(src_prim[-1].a, src_prim[0].a, (f32)a / (f32)b); + inter_prim.l = morf_calc(src_prim[-1].l, src_prim[0].l, (f32)a / (f32)b); - evw_color_set(play, segment, &inter_prim, &inter_env); - } + /* Interpolate environment color */ + inter_env.r = morf_calc(src_env[-1].r, src_env[0].r, (f32)a / (f32)b); + inter_env.g = morf_calc(src_env[-1].g, src_env[0].g, (f32)a / (f32)b); + inter_env.b = morf_calc(src_env[-1].b, src_env[0].b, (f32)a / (f32)b); + inter_env.a = morf_calc(src_env[-1].a, src_env[0].a, (f32)a / (f32)b); + + evw_color_set(play, segment, &inter_prim, &inter_env); + } } // Ragrange is probably Lagrange static f32 RagrangeInt(int num_keyframes, f32* keyframes, f32* values, f32 now_frame) { - f32 stack[EVW_COLOR_BUF_MAX]; - f32 res; - f32 n; - f32 m; - int i; + f32 stack[EVW_COLOR_BUF_MAX]; + f32 res; + f32 n; + f32 m; + int i; - /* BUG: fixed stack buffer size but no input length validation. */ - for (i = 0; i < num_keyframes; i++) { - int j; - int k; - n = keyframes[i]; - m = 1.0f; + /* BUG: fixed stack buffer size but no input length validation. */ + for (i = 0; i < num_keyframes; i++) { + int j; + n = keyframes[i]; + m = 1.0f; - /* Adjust keyframe by difference between all previous keyframes and the current keyframe */ - for (j = 0; j < i; j++) { - m *= n - keyframes[j]; + /* Adjust keyframe by difference between all previous keyframes and the current keyframe */ + for (j = 0; j < i; j++) { + m *= n - keyframes[j]; + } + + j++; + for (j; j < num_keyframes; j++) { + m *= n - keyframes[j]; + } + + stack[i] = values[i] / m; } - for (k = j + 1; k < num_keyframes; k++) { - m *= n - keyframes[k]; + res = 0.0f; + for (i = 0; i < num_keyframes; i++) { + int j; + m = 1.0f; + + for (j = 0; j < i; j++) { + m *= now_frame - keyframes[j]; + } + + j++; + for (j; j < num_keyframes; j++) { + m *= now_frame - keyframes[j]; + } + + res += m * stack[i]; } - stack[i] = values[i] / m; - } - - res = 0.0f; - for (i = 0; i < num_keyframes; i++) { - int j; - int k; - m = 1.0f; - - for (j = 0; j < i; j++) { - m *= now_frame - keyframes[j]; - } - - for (k = j + 1; k < num_keyframes; k++) { - m *= now_frame - keyframes[k]; - } - - res += m * stack[i]; - } - - return res; + return res; } static u8 RagrangeInt_Color(int num_keyframes, f32* keyframes, f32* values, f32 now_frame) { - return (u8)(int)RagrangeInt(num_keyframes, keyframes, values, now_frame); + return (u8)(int)RagrangeInt(num_keyframes, keyframes, values, now_frame); } typedef struct { - f32 keyframe_stack[EVW_COLOR_BUF_MAX]; - - f32 prim_r_stack[EVW_COLOR_BUF_MAX]; - f32 prim_g_stack[EVW_COLOR_BUF_MAX]; - f32 prim_b_stack[EVW_COLOR_BUF_MAX]; - f32 prim_a_stack[EVW_COLOR_BUF_MAX]; - f32 prim_l_stack[EVW_COLOR_BUF_MAX]; - - f32 env_r_stack[EVW_COLOR_BUF_MAX]; - f32 env_g_stack[EVW_COLOR_BUF_MAX]; - f32 env_b_stack[EVW_COLOR_BUF_MAX]; - f32 env_a_stack[EVW_COLOR_BUF_MAX]; + f32 keyframe_stack[EVW_COLOR_BUF_MAX]; + + f32 prim_r_stack[EVW_COLOR_BUF_MAX]; + f32 prim_g_stack[EVW_COLOR_BUF_MAX]; + f32 prim_b_stack[EVW_COLOR_BUF_MAX]; + f32 prim_a_stack[EVW_COLOR_BUF_MAX]; + f32 prim_l_stack[EVW_COLOR_BUF_MAX]; + + f32 env_r_stack[EVW_COLOR_BUF_MAX]; + f32 env_g_stack[EVW_COLOR_BUF_MAX]; + f32 env_b_stack[EVW_COLOR_BUF_MAX]; + f32 env_a_stack[EVW_COLOR_BUF_MAX]; } EVW_ANIME_COLREG_F; static void evw_anime_colreg_nonlinear(GAME_PLAY* play, int segment, void* evw_data) { - EVW_ANIME_COLREG* colreg = (EVW_ANIME_COLREG*)evw_data; + EVW_ANIME_COLREG* colreg = (EVW_ANIME_COLREG*)evw_data; - EVW_ANIME_COL_PRIM* prim_p; - EVW_ANIME_COL_ENV* env_p; - EVW_ANIME_COL_PRIM* prim_src = colreg->prim_colors; - EVW_ANIME_COL_ENV* env_src = colreg->env_colors; - u16* keyframes = colreg->keyframes; - f32 now_frame = play->game_frame % colreg->frame_count; - int i; + EVW_ANIME_COL_PRIM* prim_p; + EVW_ANIME_COL_ENV* env_p; + EVW_ANIME_COL_PRIM* prim_src = colreg->prim_colors; + EVW_ANIME_COL_ENV* env_src = colreg->env_colors; + u16* keyframes = colreg->keyframes; + f32 now_frame = play->game_frame % colreg->frame_count; + int i; - EVW_ANIME_COLREG_F colreg_float; - + EVW_ANIME_COLREG_F colreg_float; - /* BUG: fixed stack buffer size but no input length validation. */ - for (i = 0; i < colreg->key_count; i++) { - colreg_float.keyframe_stack[i] = (int)keyframes[i]; + /* BUG: fixed stack buffer size but no input length validation. */ + for (i = 0; i < colreg->key_count; i++) { + colreg_float.keyframe_stack[i] = (int)keyframes[i]; - prim_p = &prim_src[i]; - env_p = &env_src[i]; + prim_p = &prim_src[i]; + env_p = &env_src[i]; - colreg_float.prim_r_stack[i] = (int)prim_p->r; - colreg_float.prim_g_stack[i] = (int)prim_p->g; - colreg_float.prim_b_stack[i] = (int)prim_p->b; - colreg_float.prim_a_stack[i] = (int)prim_p->a; - colreg_float.prim_l_stack[i] = (int)prim_p->l; + colreg_float.prim_r_stack[i] = (int)prim_p->r; + colreg_float.prim_g_stack[i] = (int)prim_p->g; + colreg_float.prim_b_stack[i] = (int)prim_p->b; + colreg_float.prim_a_stack[i] = (int)prim_p->a; + colreg_float.prim_l_stack[i] = (int)prim_p->l; - colreg_float.env_r_stack[i] = (int)env_p->r; - colreg_float.env_g_stack[i] = (int)env_p->g; - colreg_float.env_b_stack[i] = (int)env_p->b; - colreg_float.env_a_stack[i] = (int)env_p->a; - } + colreg_float.env_r_stack[i] = (int)env_p->r; + colreg_float.env_g_stack[i] = (int)env_p->g; + colreg_float.env_b_stack[i] = (int)env_p->b; + colreg_float.env_a_stack[i] = (int)env_p->a; + } - { - EVW_ANIME_COL_PRIM nonlinear_prim; - EVW_ANIME_COL_ENV nonlinear_env; + { + EVW_ANIME_COL_PRIM nonlinear_prim; + EVW_ANIME_COL_ENV nonlinear_env; - nonlinear_prim.r = RagrangeInt_Color(colreg->key_count, colreg_float.keyframe_stack, colreg_float.prim_r_stack, now_frame); - nonlinear_prim.g = RagrangeInt_Color(colreg->key_count, colreg_float.keyframe_stack, colreg_float.prim_g_stack, now_frame); - nonlinear_prim.b = RagrangeInt_Color(colreg->key_count, colreg_float.keyframe_stack, colreg_float.prim_b_stack, now_frame); - nonlinear_prim.a = RagrangeInt_Color(colreg->key_count, colreg_float.keyframe_stack, colreg_float.prim_a_stack, now_frame); - nonlinear_prim.l = RagrangeInt_Color(colreg->key_count, colreg_float.keyframe_stack, colreg_float.prim_l_stack, now_frame); + nonlinear_prim.r = + RagrangeInt_Color(colreg->key_count, colreg_float.keyframe_stack, colreg_float.prim_r_stack, now_frame); + nonlinear_prim.g = + RagrangeInt_Color(colreg->key_count, colreg_float.keyframe_stack, colreg_float.prim_g_stack, now_frame); + nonlinear_prim.b = + RagrangeInt_Color(colreg->key_count, colreg_float.keyframe_stack, colreg_float.prim_b_stack, now_frame); + nonlinear_prim.a = + RagrangeInt_Color(colreg->key_count, colreg_float.keyframe_stack, colreg_float.prim_a_stack, now_frame); + nonlinear_prim.l = + RagrangeInt_Color(colreg->key_count, colreg_float.keyframe_stack, colreg_float.prim_l_stack, now_frame); - nonlinear_env.r = RagrangeInt_Color(colreg->key_count, colreg_float.keyframe_stack, colreg_float.env_r_stack, now_frame); - nonlinear_env.g = RagrangeInt_Color(colreg->key_count, colreg_float.keyframe_stack, colreg_float.env_g_stack, now_frame); - nonlinear_env.b = RagrangeInt_Color(colreg->key_count, colreg_float.keyframe_stack, colreg_float.env_b_stack, now_frame); - nonlinear_env.a = RagrangeInt_Color(colreg->key_count, colreg_float.keyframe_stack, colreg_float.env_a_stack, now_frame); + nonlinear_env.r = + RagrangeInt_Color(colreg->key_count, colreg_float.keyframe_stack, colreg_float.env_r_stack, now_frame); + nonlinear_env.g = + RagrangeInt_Color(colreg->key_count, colreg_float.keyframe_stack, colreg_float.env_g_stack, now_frame); + nonlinear_env.b = + RagrangeInt_Color(colreg->key_count, colreg_float.keyframe_stack, colreg_float.env_b_stack, now_frame); + nonlinear_env.a = + RagrangeInt_Color(colreg->key_count, colreg_float.keyframe_stack, colreg_float.env_a_stack, now_frame); - evw_color_set(play, segment, &nonlinear_prim, &nonlinear_env); - } + evw_color_set(play, segment, &nonlinear_prim, &nonlinear_env); + } } static void evw_anime_texanime(GAME_PLAY* play, int segment, void* evw_data) { - EVW_ANIME_TEXANIME* texanime = (EVW_ANIME_TEXANIME*)evw_data; - GRAPH* g = play->game.graph; - int frame = play->game_frame % (texanime->frame_count * 2); // 30fps pattern -> 60fps pattern - void* tex_p = texanime->texture_tbl[texanime->animation_pattern[frame / 2]]; // 60fps pattern back to 30fps + EVW_ANIME_TEXANIME* texanime = (EVW_ANIME_TEXANIME*)evw_data; + GRAPH* g = play->game.graph; + int frame = play->game_frame % (texanime->frame_count * 2); // 30fps pattern -> 60fps pattern + void* tex_p = texanime->texture_tbl[texanime->animation_pattern[frame / 2]]; // 60fps pattern back to 30fps - OPEN_DISP(g); + OPEN_DISP(g); - gSPSegment(NOW_BG_OPA_DISP++, segment, tex_p); - gSPSegment(NOW_POLY_OPA_DISP++, segment, tex_p); - gSPSegment(NOW_POLY_XLU_DISP++, segment, tex_p); + gSPSegment(NOW_BG_OPA_DISP++, segment, tex_p); + gSPSegment(NOW_POLY_OPA_DISP++, segment, tex_p); + gSPSegment(NOW_POLY_XLU_DISP++, segment, tex_p); - CLOSE_DISP(g); + CLOSE_DISP(g); } typedef void (*EVW_ANIME_PROC)(GAME_PLAY*, int, void*); extern void Evw_Anime_Set(GAME_PLAY* play, EVW_ANIME_DATA* evw_anime_data) { - static EVW_ANIME_PROC evw_anime_proc[EVW_ANIME_TYPE_NUM] = { - &evw_anime_scroll1, - &evw_anime_scroll2, - &evw_anime_colreg_manual, - &evw_anime_colreg_linear, - &evw_anime_colreg_nonlinear, - &evw_anime_texanime - }; + static EVW_ANIME_PROC evw_anime_proc[EVW_ANIME_TYPE_NUM] = { + &evw_anime_scroll1, &evw_anime_scroll2, &evw_anime_colreg_manual, + &evw_anime_colreg_linear, &evw_anime_colreg_nonlinear, &evw_anime_texanime, + }; - if (evw_anime_data != NULL) { - int segment = evw_anime_data->segment; + if (evw_anime_data != NULL) { + int segment = evw_anime_data->segment; - if (segment != 0) { - do { - segment = evw_anime_data->segment; - (*evw_anime_proc[evw_anime_data->type])(play, G_MWO_SEGMENT_7 + ABS(segment), evw_anime_data->data_p); - evw_anime_data++; - } while (segment >= 0); + if (segment != 0) { + do { + segment = evw_anime_data->segment; + (*evw_anime_proc[evw_anime_data->type])(play, G_MWO_SEGMENT_7 + ABS(segment), evw_anime_data->data_p); + evw_anime_data++; + } while (segment >= 0); + } } - } } diff --git a/src/game.c b/src/game.c index 4894770b..96ebba69 100644 --- a/src/game.c +++ b/src/game.c @@ -156,7 +156,11 @@ static void game_init_hyral(GAME* this, size_t size) { THA_ct(&this->tha, (char*)hyral, size); } else { THA_ct(&this->tha, NULL, 0); +#if VERSION == VER_GAFU01_00 + _dbg_hungup(__FILE__, 565); +#elif VERSION == VER_GAFE01_00 _dbg_hungup(__FILE__, 559); +#endif } } @@ -187,7 +191,11 @@ extern void game_resize_hyral(GAME* this, int size) { THA_ct(&this->tha, (char*)hyral, (u32)size); } else { THA_ct(&this->tha, NULL, 0); +#if VERSION == VER_GAFU01_00 + _dbg_hungup(__FILE__, 639); +#elif VERSION == VER_GAFE01_00 _dbg_hungup(__FILE__, 633); +#endif } } @@ -208,7 +216,9 @@ extern void game_ct(GAME* this, void (*init)(GAME*), GRAPH* graph) { __gfxprint_default_flags |= GFXPRINT_FLAG_HIGHRES; init(this); mBGM_init(); +#if VERSION < VER_GAFU01_00 GBAInit(); +#endif mVibctl_init(); } diff --git a/src/game/m_actor.c b/src/game/m_actor.c index 07f20876..1f625f54 100644 --- a/src/game/m_actor.c +++ b/src/game/m_actor.c @@ -145,7 +145,7 @@ static void Actor_ct(ACTOR* actor, GAME* game) { actor->scale.y = 0.01f; actor->scale.z = 0.01f; actor->max_velocity_y = -20.0f; - actor->player_distance = 3.4028235E+38; + actor->player_distance = FLT_MAX; //3.4028235E+38; actor->cull_width = 350.0f; actor->cull_height = 700.0f; actor->cull_distance = 1000.0f; @@ -274,8 +274,9 @@ extern int Actor_draw_actor_no_culling_check2(ACTOR* actor, xyz_t* camera_pos, f if (-actor->cull_radius < camera_pos->z && camera_pos->z < actor->cull_distance + actor->cull_radius) { f32 m = camera_w < 1.0f ? 1.0f : 1.0f / camera_w; + int width_OK = (m * (fabsf(camera_pos->x) - actor->cull_width)) < 1.0f; - if ((m * (fabsf(camera_pos->x) - actor->cull_width)) < 1.0f && + if (width_OK && (m * (camera_pos->y + actor->cull_height)) > -1.0f && (m * (camera_pos->y - actor->cull_radius) < 1.0f)) { res = TRUE; } diff --git a/src/game/m_address_ovl.c b/src/game/m_address_ovl.c index cd7c2e58..945f29fa 100644 --- a/src/game/m_address_ovl.c +++ b/src/game/m_address_ovl.c @@ -311,10 +311,10 @@ static void mAD_turn_page_proc(Submenu* submenu, mSM_MenuInfo_c* menu_info) { int i; f32 pos; - pos = adrs_ovl->pos_x; - if (fabsf(pos) < 14.0f) { + pos = fabsf(adrs_ovl->pos_x); + if (pos < 14.0f) { adrs_ovl->speed_x *= sqrtf(2.0f); - } else if (fabsf(pos) > 30.0f) { + } else if (pos > 30.0f) { adrs_ovl->speed_x *= sqrtf(0.5f); if (fabsf(adrs_ovl->speed_x) < 0.25f) { @@ -345,11 +345,10 @@ static void mAD_turn_page2_proc(Submenu* submenu, mSM_MenuInfo_c* menu_info) { mAD_Ovl_c* adrs_ovl = submenu->overlay->address_ovl; f32 pos; - pos = adrs_ovl->pos_x; - - if (fabsf(pos) > 30.0f) { + pos = fabsf(adrs_ovl->pos_x); + if (pos > 30.0f) { adrs_ovl->speed_x *= sqrtf(2.0f); - } else if (fabsf(pos) < 14.0f) { + } else if (pos < 14.0f) { adrs_ovl->speed_x *= sqrtf(0.5f); } diff --git a/src/game/m_all_grow_ovl.c b/src/game/m_all_grow_ovl.c index 64d4aec9..3c3b22e0 100644 --- a/src/game/m_all_grow_ovl.c +++ b/src/game/m_all_grow_ovl.c @@ -917,8 +917,8 @@ static void mAGrw_ChangeItemBlock2(mActor_name_t* block_items, u8 changeable_num mActor_name_t* source_table, int table_num) { int changed = FALSE; int selected = RANDOM(changeable_num); - int i; int j; + int i; for (i = 0; i < UT_TOTAL_NUM; i++) { for (j = 0; j < table_num; j++) { @@ -1519,8 +1519,10 @@ static void mAGrw_SetCarpOnHomeBlock(mAGrw_CarpInfo_c* carp_info, mFM_fg_c* fg_b } else { block_house_info[0]++; } - } + } + + fg_block++; block_info++; } @@ -1807,8 +1809,21 @@ typedef int (*mAGrw_CHECK_FG_PROC)(mActor_name_t); static void mAGrw_LimitTreeLineIsland(mFM_fg_c* island_block) { static mAGrw_CHECK_FG_PROC check_fg[mAGrw_TREE_STAGE_NUM] = { &mAGrw_CheckTree000, &mAGrw_CheckTree001, &mAGrw_CheckTree002, &mAGrw_CheckTree003, - &mAGrw_CheckTree004 }; - + &mAGrw_CheckTree004, }; +// TODO: Ordering needs to be fixed, this seems fake +#if VERSION >= VER_GAFU01_00 + int tree_size_count_tbl[mAGrw_TREE_STAGE_NUM]; + mFM_fg_c* island_block_p; + u8 ignored_record; + int max_trees; + int selected; + mActor_name_t* items; + int trees; + int ut_x; + int ut_z; + int tree_size; + int block; +#else int tree_size_count_tbl[mAGrw_TREE_STAGE_NUM]; mFM_fg_c* island_block_p; u8 ignored_record; @@ -1820,6 +1835,7 @@ static void mAGrw_LimitTreeLineIsland(mFM_fg_c* island_block) { int trees; int tree_size; int block; +#endif island_block_p = island_block; @@ -2157,9 +2173,9 @@ static void mAGrw_SetblockCancelUtInfo(u16* cancel_ut, mActor_name_t* items, int &mAGrw_CheckCancel57, &mAGrw_CheckCancel68, &mAGrw_CheckCancel77 }; + int proc; int ut_z; int ut_x; - int proc; for (ut_z = 0; ut_z < UT_Z_NUM; ut_z++) { for (ut_x = 0; ut_x < UT_X_NUM; ut_x++) { diff --git a/src/game/m_bank_ovl.c b/src/game/m_bank_ovl.c index 21abb6b7..df02ddb5 100644 --- a/src/game/m_bank_ovl.c +++ b/src/game/m_bank_ovl.c @@ -7,233 +7,207 @@ #include "m_lib.h" #include "m_common_data.h" -static int aNSM_sack_amount[MONEY_NUM] = { - 100, - 1000, - 10000, - 30000 -}; +static int aNSM_sack_amount[MONEY_NUM] = { 100, 1000, 10000, 30000 }; -static mActor_name_t aNSM_itemNo[MONEY_NUM] = { - ITM_MONEY_100, - ITM_MONEY_1000, - ITM_MONEY_10000, - ITM_MONEY_30000 -}; +static mActor_name_t aNSM_itemNo[MONEY_NUM] = { ITM_MONEY_100, ITM_MONEY_1000, ITM_MONEY_10000, ITM_MONEY_30000 }; static void mBN_now_bell_2_bell(mBN_Ovl_c* bank_ovl) { - int diff = bank_ovl->now_bell - bank_ovl->player_bell; - bank_ovl->bell = ABS(diff); + int diff = bank_ovl->now_bell - bank_ovl->player_bell; + bank_ovl->bell = ABS(diff); } static int mBN_cursol_2_keta(int cursol) { - int keta = 1; - int i; + int keta = 1; - for (i = cursol; i < mBN_CURSOL_MAX; i++) { - keta *= 10; - } + while (cursol++ < mBN_CURSOL_MAX) { + keta *= 10; + } - return keta; + return keta; } static int mBN_total_item_bell() { - int i; - int total_item_bell = 0; + int i; + int total_item_bell = 0; - for (i = 0; i < MONEY_NUM; i++) { - int possess = mPr_GetPossessionItemSumWithCond(Common_Get(now_private), aNSM_itemNo[i], mPr_ITEM_COND_NORMAL); + for (i = 0; i < MONEY_NUM; i++) { + int possess = mPr_GetPossessionItemSumWithCond(Common_Get(now_private), aNSM_itemNo[i], mPr_ITEM_COND_NORMAL); - total_item_bell += possess * aNSM_sack_amount[i]; - } + total_item_bell += possess * aNSM_sack_amount[i]; + } - return total_item_bell; + return total_item_bell; } static void mBN_bank_ok(Submenu* submenu, mSM_MenuInfo_c* menu, mBN_Ovl_c* bank_ovl) { - if (bank_ovl->bank_bell < 0) { - bank_ovl->bank_bell = 0; - } + int total_item_bell; + int remain_item_bell; + int sack_idx; + int i; - if (bank_ovl->bank_bell > mBN_DEPOSIT_MAX) { - bank_ovl->bank_bell = mBN_DEPOSIT_MAX; - } + if (bank_ovl->bank_bell < 0) { + bank_ovl->bank_bell = 0; + } - Common_Get(now_private)->bank_account = bank_ovl->bank_bell; + if (bank_ovl->bank_bell > mBN_DEPOSIT_MAX) { + bank_ovl->bank_bell = mBN_DEPOSIT_MAX; + } - { - int total_item_bell = mBN_total_item_bell(); - int i = 0; + Common_Get(now_private)->bank_account = bank_ovl->bank_bell; + + total_item_bell = mBN_total_item_bell(); + i = 0; /* Replace all money sack items with EMPTY_NO */ while (bank_ovl->now_bell < total_item_bell && i < MONEY_NUM) { - int sack_idx = mPr_GetPossessionItemIdxWithCond(Common_Get(now_private), aNSM_itemNo[i], mPr_ITEM_COND_NORMAL); - if (sack_idx == -1) { - i++; /* move onto next sack amount */ - } - else { - mPr_SetPossessionItem(Common_Get(now_private), sack_idx, EMPTY_NO, mPr_ITEM_COND_NORMAL); - } + sack_idx = + mPr_GetPossessionItemIdxWithCond(Common_Get(now_private), aNSM_itemNo[i], mPr_ITEM_COND_NORMAL); + if (sack_idx == -1) { + i++; /* move onto next sack amount */ + } else { + mPr_SetPossessionItem(Common_Get(now_private), sack_idx, EMPTY_NO, mPr_ITEM_COND_NORMAL); + } - total_item_bell = mBN_total_item_bell(); /* update total bell count in sacks */ + total_item_bell = mBN_total_item_bell(); /* update total bell count in sacks */ } - } - - { - /* Replace non-30k bell bags with 30k bell bags */ - int i; - int total_item_bell = bank_ovl->now_bell - mBN_total_item_bell(); + /* Replace non-30k bell bags with 30k bell bags */ + remain_item_bell = bank_ovl->now_bell - mBN_total_item_bell(); i = 0; - - while (total_item_bell > mPr_WALLET_MAX && i < MONEY_NUM - 1) { - int sack_idx = mPr_GetPossessionItemIdxWithCond(Common_Get(now_private), aNSM_itemNo[i], mPr_ITEM_COND_NORMAL); - if (sack_idx == -1) { - i++; - } - else { - mPr_SetPossessionItem(Common_Get(now_private), sack_idx, ITM_MONEY_30000, mPr_ITEM_COND_NORMAL); - total_item_bell -= 30000 - aNSM_sack_amount[i]; - } + while (remain_item_bell > mPr_WALLET_MAX && i < MONEY_NUM - 1) { + sack_idx = + mPr_GetPossessionItemIdxWithCond(Common_Get(now_private), aNSM_itemNo[i], mPr_ITEM_COND_NORMAL); + + if (sack_idx == -1) { + i++; + } else { + mPr_SetPossessionItem(Common_Get(now_private), sack_idx, ITM_MONEY_30000, mPr_ITEM_COND_NORMAL); + remain_item_bell -= 30000 - aNSM_sack_amount[i]; + } } /* Add 30k bell bags to the inventory where empty spaces are */ i = 0; + while (remain_item_bell > mPr_WALLET_MAX && i < 1) { + int sack_idx = mPr_GetPossessionItemIdxWithCond(Common_Get(now_private), EMPTY_NO, mPr_ITEM_COND_NORMAL); - while (total_item_bell > mPr_WALLET_MAX && i < 1) { - int sack_idx = mPr_GetPossessionItemIdxWithCond(Common_Get(now_private), EMPTY_NO, mPr_ITEM_COND_NORMAL); - - if (sack_idx == -1) { - i++; - } - else { - mPr_SetPossessionItem(Common_Get(now_private), sack_idx, ITM_MONEY_30000, mPr_ITEM_COND_NORMAL); - total_item_bell -= 30000; - } + if (sack_idx == -1) { + i++; + } else { + mPr_SetPossessionItem(Common_Get(now_private), sack_idx, ITM_MONEY_30000, mPr_ITEM_COND_NORMAL); + remain_item_bell -= 30000; + } } bank_ovl->now_bell -= mBN_total_item_bell(); if (bank_ovl->now_bell < 0) { - bank_ovl->now_bell = 0; - } - else if (bank_ovl->now_bell > mPr_WALLET_MAX) { - bank_ovl->now_bell = mPr_WALLET_MAX; + bank_ovl->now_bell = 0; + } else if (bank_ovl->now_bell > mPr_WALLET_MAX) { + bank_ovl->now_bell = mPr_WALLET_MAX; } Common_Get(now_private)->inventory.wallet = bank_ovl->now_bell; (*submenu->overlay->move_chg_base_proc)(menu, mSM_MOVE_OUT_TOP); sAdo_SysTrgStart(NA_SE_MENU_EXIT); - } } static void mBN_move_Move(Submenu* submenu, mSM_MenuInfo_c* menu) { - (*submenu->overlay->move_Move_proc)(submenu, menu); + (*submenu->overlay->move_Move_proc)(submenu, menu); } static void mBN_move_Play(Submenu* submenu, mSM_MenuInfo_c* menu) { - Submenu_Overlay_c* overlay = submenu->overlay; - int trigger = overlay->menu_control.trigger; - mBN_Ovl_c* bank_ovl = overlay->bank_ovl; + Submenu_Overlay_c* overlay = submenu->overlay; + int trigger = overlay->menu_control.trigger; + mBN_Ovl_c* bank_ovl = overlay->bank_ovl; - if (trigger & BUTTON_B) { - (*overlay->move_chg_base_proc)(menu, mSM_MOVE_OUT_TOP); - sAdo_SysTrgStart(NA_SE_MENU_EXIT); - } - else if (trigger & BUTTON_START) { - mBN_bank_ok(submenu, menu, bank_ovl); - } - else { - int cursol = bank_ovl->cursol; - - if (cursol == mBN_CUSROL_OK) { - if (trigger & BUTTON_A) { + if (trigger & BUTTON_B) { + (*overlay->move_chg_base_proc)(menu, mSM_MOVE_OUT_TOP); + sAdo_SysTrgStart(NA_SE_MENU_EXIT); + } else if (trigger & BUTTON_START) { mBN_bank_ok(submenu, menu, bank_ovl); - } - else if (trigger & (BUTTON_CLEFT | BUTTON_CUP)) { - bank_ovl->cursol = cursol - 1; - sAdo_SysTrgStart(NA_SE_CURSOL); - } + } else { + int cursol = bank_ovl->cursol; + + if (cursol == mBN_CUSROL_OK) { + if (trigger & BUTTON_A) { + mBN_bank_ok(submenu, menu, bank_ovl); + } else if (trigger & (BUTTON_CLEFT | BUTTON_CUP)) { + bank_ovl->cursol = cursol - 1; + sAdo_SysTrgStart(NA_SE_CURSOL); + } + } else if ((trigger & BUTTON_CLEFT) && cursol > 0) { + bank_ovl->cursol = cursol - 1; + sAdo_SysTrgStart(NA_SE_CURSOL); + } else if (trigger & BUTTON_CRIGHT) { + bank_ovl->cursol += 1; + sAdo_SysTrgStart(NA_SE_CURSOL); + } else if ((trigger & BUTTON_CDOWN) || (trigger & BUTTON_CUP)) { + int keta = mBN_cursol_2_keta(cursol); + + if (trigger & BUTTON_CUP) { + if (bank_ovl->now_bell < keta) { + keta = bank_ovl->now_bell; + } + + if (keta + bank_ovl->bank_bell > mBN_DEPOSIT_MAX) { + keta = mBN_DEPOSIT_MAX - bank_ovl->bank_bell; + } + + if (keta == 0) { + sAdo_SysTrgStart(MONO(3)); + return; + } + + if (bank_ovl->now_bell > bank_ovl->player_bell && (bank_ovl->now_bell - keta) < bank_ovl->player_bell) { + keta = bank_ovl->now_bell - bank_ovl->player_bell; + } + + bank_ovl->bank_bell += keta; + bank_ovl->now_bell -= keta; + } else { + if (bank_ovl->bank_bell < keta) { + keta = bank_ovl->bank_bell; + } + + if ((bank_ovl->now_bell + keta) > bank_ovl->player_max_bell) { + keta = bank_ovl->player_max_bell - bank_ovl->now_bell; + } + + if (keta == 0) { + sAdo_SysTrgStart(MONO(3)); + return; + } + + if (bank_ovl->now_bell < bank_ovl->player_bell && (bank_ovl->now_bell + keta) > bank_ovl->player_bell) { + keta = bank_ovl->player_bell - bank_ovl->now_bell; + } + + bank_ovl->bank_bell -= keta; + bank_ovl->now_bell += keta; + } + + mBN_now_bell_2_bell(bank_ovl); + sAdo_SysTrgStart(0x426); + } } - else if ((trigger & BUTTON_CLEFT) && cursol > 0) { - bank_ovl->cursol = cursol - 1; - sAdo_SysTrgStart(NA_SE_CURSOL); - } - else if (trigger & BUTTON_CRIGHT) { - bank_ovl->cursol += 1; - sAdo_SysTrgStart(NA_SE_CURSOL); - } - else if ((trigger & BUTTON_CDOWN) || (trigger & BUTTON_CUP)) { - int keta = mBN_cursol_2_keta(cursol); - - if (trigger & BUTTON_CUP) { - if (bank_ovl->now_bell < keta) { - keta = bank_ovl->now_bell; - } - - if (keta + bank_ovl->bank_bell > mBN_DEPOSIT_MAX) { - keta = mBN_DEPOSIT_MAX - bank_ovl->bank_bell; - } - - if (keta == 0) { - sAdo_SysTrgStart(MONO(3)); - return; - } - - if (bank_ovl->now_bell > bank_ovl->player_bell && (bank_ovl->now_bell - keta) < bank_ovl->player_bell) { - keta = bank_ovl->now_bell - bank_ovl->player_bell; - } - - bank_ovl->bank_bell += keta; - bank_ovl->now_bell -= keta; - } - else { - if (bank_ovl->bank_bell < keta) { - keta = bank_ovl->bank_bell; - } - - if ((bank_ovl->now_bell + keta) > bank_ovl->player_max_bell) { - keta = bank_ovl->player_max_bell - bank_ovl->now_bell; - } - - if (keta == 0) { - sAdo_SysTrgStart(MONO(3)); - return; - } - - if (bank_ovl->now_bell < bank_ovl->player_bell && (bank_ovl->now_bell + keta) > bank_ovl->player_bell) { - keta = bank_ovl->player_bell - bank_ovl->now_bell; - } - - bank_ovl->bank_bell -= keta; - bank_ovl->now_bell += keta; - } - - mBN_now_bell_2_bell(bank_ovl); - sAdo_SysTrgStart(0x426); - } - } } static void mBN_move_End(Submenu* submenu, mSM_MenuInfo_c* menu) { - (*submenu->overlay->move_End_proc)(submenu, menu); + (*submenu->overlay->move_End_proc)(submenu, menu); } static void mBN_bank_ovl_move(Submenu* submenu) { - static mSM_MOVE_PROC ovl_move_proc[5] = { - &mBN_move_Move, - &mBN_move_Play, - (mSM_MOVE_PROC)&none_proc1, - (mSM_MOVE_PROC)&none_proc1, - &mBN_move_End - }; + static mSM_MOVE_PROC ovl_move_proc[5] = { + &mBN_move_Move, &mBN_move_Play, (mSM_MOVE_PROC)&none_proc1, (mSM_MOVE_PROC)&none_proc1, &mBN_move_End, + }; - Submenu_Overlay_c* overlay = submenu->overlay; - mSM_MenuInfo_c* menu = &overlay->menu_info[mSM_OVL_BANK]; + Submenu_Overlay_c* overlay = submenu->overlay; + mSM_MenuInfo_c* menu = &overlay->menu_info[mSM_OVL_BANK]; - (*menu->pre_move_func)(submenu); - (*ovl_move_proc[menu->proc_status])(submenu, menu); + (*menu->pre_move_func)(submenu); + (*ovl_move_proc[menu->proc_status])(submenu, menu); } extern Gfx tyo_win_mode[]; @@ -242,209 +216,178 @@ extern Gfx tyo_win_moji2T_model[]; extern Gfx tyo_win_moji3T_model[]; static void mBN_set_frame_dl(Submenu* submenu, GAME* game, mSM_MenuInfo_c* menu) { - GRAPH* g = game->graph; - mBN_Ovl_c* bank_ovl = submenu->overlay->bank_ovl; - Gfx* gfx; - u8 s; - u8 t; + GRAPH* g = game->graph; + mBN_Ovl_c* bank_ovl = submenu->overlay->bank_ovl; + Gfx* gfx; + u8 s; + u8 t; - Matrix_translate(menu->position[0] * 16.0f, menu->position[1] * 16.0f, 140.0f, MTX_LOAD); - Matrix_scale(16.0f, 16.0f, 1.0f, MTX_MULT); + Matrix_translate(menu->position[0] * 16.0f, menu->position[1] * 16.0f, 140.0f, MTX_LOAD); + Matrix_scale(16.0f, 16.0f, 1.0f, MTX_MULT); - OPEN_DISP(g); - gfx = NOW_POLY_OPA_DISP; + OPEN_DISP(g); + gfx = NOW_POLY_OPA_DISP; + gSPDisplayList(gfx++, tyo_win_mode); + gSPMatrix(gfx++, _Matrix_to_Mtx_new(g), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + s = -submenu->overlay->menu_control.texture_pos[0] * 4.0f; + t = -submenu->overlay->menu_control.texture_pos[1] * 4.0f; + gDPSetTileSize_Dolphin(gfx++, 0, s, t, 32, 32); + gSPDisplayList(gfx++, tyo_win_model); - gSPDisplayList(gfx++, tyo_win_mode); - gSPMatrix(gfx++, _Matrix_to_Mtx_new(g), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - s = -submenu->overlay->menu_control.texture_pos[0] * 4.0f; - t = -submenu->overlay->menu_control.texture_pos[1] * 4.0f; - gDPSetTileSize_Dolphin(gfx++, 0, s, t, 32, 32); - gSPDisplayList(gfx++, tyo_win_model); + if (bank_ovl->now_bell <= bank_ovl->player_bell) { + gDPSetPrimColor(gfx++, 0, 255, 165, 50, 50, 255); + gDPSetEnvColor(gfx++, 255, 255, 255, 255); + } else { + gDPSetPrimColor(gfx++, 0, 255, 100, 80, 80, 255); + gDPSetEnvColor(gfx++, 165, 155, 155, 255); + } - if (bank_ovl->now_bell <= bank_ovl->player_bell) { - gDPSetPrimColor(gfx++, 0, 255, 165, 50, 50, 255); - gDPSetEnvColor(gfx++, 255, 255, 255, 255); - } - else { - gDPSetPrimColor(gfx++, 0, 255, 100, 80, 80, 255); - gDPSetEnvColor(gfx++, 165, 155, 155, 255); - } + gSPDisplayList(gfx++, tyo_win_moji2T_model); - gSPDisplayList(gfx++, tyo_win_moji2T_model); - - if (bank_ovl->now_bell >= bank_ovl->player_bell) { - gDPSetPrimColor(gfx++, 0, 255, 20, 205, 20, 255); - gDPSetEnvColor(gfx++, 255, 255, 255, 255); - } - else { - gDPSetPrimColor(gfx++, 0, 255, 70, 95, 70, 255); - gDPSetEnvColor(gfx++, 155, 165, 155, 255); - } + if (bank_ovl->now_bell >= bank_ovl->player_bell) { + gDPSetPrimColor(gfx++, 0, 255, 20, 205, 20, 255); + gDPSetEnvColor(gfx++, 255, 255, 255, 255); + } else { + gDPSetPrimColor(gfx++, 0, 255, 70, 95, 70, 255); + gDPSetEnvColor(gfx++, 155, 165, 155, 255); + } - gSPDisplayList(gfx++, tyo_win_moji3T_model); + gSPDisplayList(gfx++, tyo_win_moji3T_model); - - SET_POLY_OPA_DISP(gfx); - CLOSE_DISP(g); + SET_POLY_OPA_DISP(gfx); + CLOSE_DISP(g); } static void mBN_set_num_str(f32 x, f32 y, GAME* game, u32 num, f32 scale, rgba_t* color) { - u8 str[11]; - f32 width; + u8 str[11]; + f32 width; - mFont_UnintToString(str, 11, num, 9, FALSE, FALSE, TRUE); - width = mFont_GetStringWidth(str, 11, TRUE); - x -= scale * width; + mFont_UnintToString(str, 11, num, 9, FALSE, FALSE, TRUE); + width = mFont_GetStringWidth(str, 11, TRUE); + x -= scale * width; - mFont_SetLineStrings( - game, - str, 11, - x, y, - color->r, color->g, color->b, 255, - FALSE, TRUE, - scale, scale, - mFont_MODE_POLY - ); + mFont_SetLineStrings(game, str, 11, x, y, color->r, color->g, color->b, 255, FALSE, TRUE, scale, scale, + mFont_MODE_POLY); } static void mBN_set_character_dl(Submenu* submenu, GAME* game, mSM_MenuInfo_c* menu) { - static u8 kingaku_str[] = { CHAR_Y, CHAR_o, CHAR_u, CHAR_r, CHAR_SPACE, CHAR_A, CHAR_c, CHAR_c, CHAR_o, CHAR_u, CHAR_n, CHAR_t }; - static u8 end_str[] = { CHAR_O, CHAR_K }; - static rgba_t normal_col = { 0, 50, 255, 255 }; - static rgba_t select_col = { 195, 20, 20, 255 }; - static rgba_t bank_bell_col = { 170, 60, 145, 255 }; - static rgba_t now_bell_col = { 115, 50, 215, 255 }; - - mBN_Ovl_c* bank_ovl; - int cursol; - f32 width; - f32 digit_x; - int i; - u8 str[7]; - f32 pos_x = menu->position[0]; - f32 pos_y = menu->position[1]; + static u8 kingaku_str[] = { CHAR_Y, CHAR_o, CHAR_u, CHAR_r, CHAR_SPACE, CHAR_A, + CHAR_c, CHAR_c, CHAR_o, CHAR_u, CHAR_n, CHAR_t }; + static u8 end_str[] = { CHAR_O, CHAR_K }; + static rgba_t normal_col = { 0, 50, 255, 255 }; + static rgba_t select_col = { 195, 20, 20, 255 }; + static rgba_t bank_bell_col = { 170, 60, 145, 255 }; + static rgba_t now_bell_col = { 115, 50, 215, 255 }; - bank_ovl = submenu->overlay->bank_ovl; + mBN_Ovl_c* bank_ovl; + int cursol; + f32 width; + f32 digit_x; + int i; + u8 str[7]; + f32 pos_x = menu->position[0]; + f32 pos_y = menu->position[1]; - (*submenu->overlay->set_char_matrix_proc)(game->graph); - mFont_SetLineStrings( - game, - kingaku_str, sizeof(kingaku_str), - 145.0f + pos_x, 65.0f - pos_y, - 255, 255, 255, 255, - FALSE, TRUE, - 0.875f, 0.875f, - mFont_MODE_POLY - ); + bank_ovl = submenu->overlay->bank_ovl; - mBN_set_num_str(211.0f + pos_x, 157.0f - pos_y, game, bank_ovl->bank_bell, 0.875f, &bank_bell_col); - mBN_set_num_str(211.0f + pos_x, 98.0f - pos_y, game, bank_ovl->now_bell, 0.875f, &now_bell_col); + (*submenu->overlay->set_char_matrix_proc)(game->graph); + mFont_SetLineStrings(game, kingaku_str, sizeof(kingaku_str), 145.0f + pos_x, 65.0f - pos_y, 255, 255, 255, 255, + FALSE, TRUE, 0.875f, 0.875f, mFont_MODE_POLY); - cursol = bank_ovl->cursol; + mBN_set_num_str(211.0f + pos_x, 157.0f - pos_y, game, bank_ovl->bank_bell, 0.875f, &bank_bell_col); + mBN_set_num_str(211.0f + pos_x, 98.0f - pos_y, game, bank_ovl->now_bell, 0.875f, &now_bell_col); - if (cursol >= 3) { - cursol++; - } + cursol = bank_ovl->cursol; - mFont_UnintToString(str, 7, bank_ovl->bell, 6, FALSE, TRUE, TRUE); - width = mFont_GetStringWidth(str, 7, TRUE); + if (cursol >= 3) { + cursol++; + } - /* Draw each digit one by one */ - digit_x = 211.0f + (pos_x - width); - for (i = 0; i < 7; i++) { - rgba_t* color = cursol == i ? &select_col : &normal_col; + mFont_UnintToString(str, 7, bank_ovl->bell, 6, FALSE, TRUE, TRUE); + width = mFont_GetStringWidth(str, 7, TRUE); - mFont_SetLineStrings( - game, - str + i, 1, - digit_x, 124.0f - pos_y, - color->r, color->g, color->b, 255, - FALSE, TRUE, - 1.0f, 1.0f, - mFont_MODE_POLY - ); + /* Draw each digit one by one */ + digit_x = 211.0f + (pos_x - width); + for (i = 0; i < 7; i++) { + rgba_t* color = cursol == i ? &select_col : &normal_col; - width = mFont_GetStringWidth(str + i, 1, TRUE); - digit_x += width; - } + mFont_SetLineStrings(game, str + i, 1, digit_x, 124.0f - pos_y, color->r, color->g, color->b, 255, FALSE, TRUE, + 1.0f, 1.0f, mFont_MODE_POLY); - { - rgba_t* color = bank_ovl->cursol < mBN_CUSROL_OK ? &normal_col : &select_col; + width = mFont_GetStringWidth(str + i, 1, TRUE); + digit_x += width; + } - mFont_SetLineStrings( - game, - end_str, sizeof(end_str), - 208.0f + pos_x, 140.0f - pos_y, - color->r, color->g, color->b, 255, - FALSE, TRUE, - 0.875f, 0.875f, - mFont_MODE_POLY - ); - } + { + rgba_t* color = bank_ovl->cursol < mBN_CUSROL_OK ? &normal_col : &select_col; + + mFont_SetLineStrings(game, end_str, sizeof(end_str), 208.0f + pos_x, 140.0f - pos_y, color->r, color->g, + color->b, 255, FALSE, TRUE, 0.875f, 0.875f, mFont_MODE_POLY); + } } static void mBN_bank_ovl_draw(Submenu* submenu, GAME* game) { - mSM_MenuInfo_c* menu = &submenu->overlay->menu_info[mSM_OVL_BANK]; - - (*menu->pre_draw_func)(submenu, game); - mBN_set_frame_dl(submenu, game, menu); - mBN_set_character_dl(submenu, game, menu); + mSM_MenuInfo_c* menu = &submenu->overlay->menu_info[mSM_OVL_BANK]; + + (*menu->pre_draw_func)(submenu, game); + mBN_set_frame_dl(submenu, game, menu); + mBN_set_character_dl(submenu, game, menu); } extern void mBN_bank_ovl_set_proc(Submenu* submenu) { - Submenu_Overlay_c* overlay = submenu->overlay; + Submenu_Overlay_c* overlay = submenu->overlay; - overlay->menu_control.menu_move_func = &mBN_bank_ovl_move; - overlay->menu_control.menu_draw_func = &mBN_bank_ovl_draw; + overlay->menu_control.menu_move_func = &mBN_bank_ovl_move; + overlay->menu_control.menu_draw_func = &mBN_bank_ovl_draw; } static void mBN_bank_ovl_init(Submenu* submenu) { - Submenu_Overlay_c* overlay = submenu->overlay; - mBN_Ovl_c* bank_ovl = overlay->bank_ovl; - int i; + Submenu_Overlay_c* overlay = submenu->overlay; + mBN_Ovl_c* bank_ovl = overlay->bank_ovl; + int i; - overlay->menu_control.animation_flag = FALSE; - overlay->menu_info[mSM_OVL_BANK].proc_status = 0; - overlay->menu_info[mSM_OVL_BANK].next_proc_status = 1; - overlay->menu_info[mSM_OVL_BANK].move_drt = 5; + overlay->menu_control.animation_flag = FALSE; + overlay->menu_info[mSM_OVL_BANK].proc_status = 0; + overlay->menu_info[mSM_OVL_BANK].next_proc_status = 1; + overlay->menu_info[mSM_OVL_BANK].move_drt = 5; - bank_ovl->now_bell = Common_Get(now_private)->inventory.wallet; - bank_ovl->now_bell += mBN_total_item_bell(); - bank_ovl->player_bell = bank_ovl->now_bell; + bank_ovl->now_bell = Common_Get(now_private)->inventory.wallet; + bank_ovl->now_bell += mBN_total_item_bell(); + bank_ovl->player_bell = bank_ovl->now_bell; - mBN_now_bell_2_bell(bank_ovl); - bank_ovl->player_max_bell = mPr_WALLET_MAX; + mBN_now_bell_2_bell(bank_ovl); + bank_ovl->player_max_bell = mPr_WALLET_MAX; - for (i = 0; i < MONEY_NUM; i++) { - int sack_sum = mPr_GetPossessionItemSumWithCond(Common_Get(now_private), aNSM_itemNo[i], mPr_ITEM_COND_NORMAL); - - bank_ovl->player_max_bell += sack_sum * aNSM_sack_amount[3]; - } + for (i = 0; i < MONEY_NUM; i++) { + int sack_sum = mPr_GetPossessionItemSumWithCond(Common_Get(now_private), aNSM_itemNo[i], mPr_ITEM_COND_NORMAL); - { - int sack_sum = mPr_GetPossessionItemSumWithCond(Common_Get(now_private), EMPTY_NO, mPr_ITEM_COND_NORMAL); - - bank_ovl->player_max_bell += sack_sum * aNSM_sack_amount[3]; - } - bank_ovl->bank_bell = Common_Get(now_private)->bank_account; - bank_ovl->cursol = 0; + bank_ovl->player_max_bell += sack_sum * aNSM_sack_amount[3]; + } + + { + int sack_sum = mPr_GetPossessionItemSumWithCond(Common_Get(now_private), EMPTY_NO, mPr_ITEM_COND_NORMAL); + + bank_ovl->player_max_bell += sack_sum * aNSM_sack_amount[3]; + } + bank_ovl->bank_bell = Common_Get(now_private)->bank_account; + bank_ovl->cursol = 0; } static mBN_Ovl_c bn_ovl_data; extern void mBN_bank_ovl_construct(Submenu* submenu) { - Submenu_Overlay_c* overlay = submenu->overlay; + Submenu_Overlay_c* overlay = submenu->overlay; - if (overlay->bank_ovl == NULL) { - mem_clear((u8*)&bn_ovl_data, sizeof(mBN_Ovl_c), 0); - overlay->bank_ovl = &bn_ovl_data; - } + if (overlay->bank_ovl == NULL) { + mem_clear((u8*)&bn_ovl_data, sizeof(mBN_Ovl_c), 0); + overlay->bank_ovl = &bn_ovl_data; + } - mBN_bank_ovl_init(submenu); - mBN_bank_ovl_set_proc(submenu); + mBN_bank_ovl_init(submenu); + mBN_bank_ovl_set_proc(submenu); } extern void mBN_bank_ovl_destruct(Submenu* submenu) { - submenu->overlay->bank_ovl = NULL; + submenu->overlay->bank_ovl = NULL; } diff --git a/src/game/m_banti.c b/src/game/m_banti.c index 6fa01a4a..f24011db 100644 --- a/src/game/m_banti.c +++ b/src/game/m_banti.c @@ -186,10 +186,10 @@ static void banti_chk_anime_start() { u8 banti_min; u8 rtc_min; - int work1; - int work0; int disp0; int disp1; + int work0; + int work1; if (banti.month_anim.state == banti_ANIM_STATE_STOPPED && banti.displayed_time.month != Common_GetPointer(time.rtc_time)->month) { @@ -203,22 +203,20 @@ static void banti_chk_anime_start() { banti.day_anim.state = banti_ANIM_STATE_PLAYING; } - banti_hour = banti.displayed_time.hour; - if (banti_hour == 0 || banti_hour == 12) { + if (banti.displayed_time.hour == 0 || banti.displayed_time.hour == 12) { work0 = 12; - } else if (banti_hour > 11) { - work0 = banti_hour - 12; + } else if (banti.displayed_time.hour > 11) { + work0 = banti.displayed_time.hour - 12; } else { - work0 = banti_hour; + work0 = banti.displayed_time.hour; } - rtc_hour = Common_GetPointer(time.rtc_time)->hour; - if (rtc_hour == 0 || rtc_hour == 12) { + if (Common_Get(time.rtc_time.hour) == 0 || Common_Get(time.rtc_time.hour) == 12) { work1 = 12; - } else if (rtc_hour > 11) { - work1 = rtc_hour - 12; + } else if (Common_Get(time.rtc_time.hour) > 11) { + work1 = Common_Get(time.rtc_time.hour) - 12; } else { - work1 = rtc_hour; + work1 = Common_Get(time.rtc_time.hour); } disp0 = work0 / 10; diff --git a/src/game/m_calendar_ovl.c b/src/game/m_calendar_ovl.c index a9a984d1..21379d83 100644 --- a/src/game/m_calendar_ovl.c +++ b/src/game/m_calendar_ovl.c @@ -32,7 +32,11 @@ static u32 mCD_sp_soncho_chk(lbRTC_year_t year, lbRTC_month_t month, lbRTC_day_t switch (month) { case lbRTC_JUNE: +#if VERSION == VER_GAFU01_00 + wday = lbRTC_Week(year, month, day); +#else wday = lbRTC_Week(year, month, day + 1); +#endif if (wday == lbRTC_SUNDAY && 1 + ((day - wday) / lbRTC_WEEK) == 3) { chk = (1 << 0); } diff --git a/src/game/m_calendar_ovl_draw.c_inc b/src/game/m_calendar_ovl_draw.c_inc index 350d1826..27b661a0 100644 --- a/src/game/m_calendar_ovl_draw.c_inc +++ b/src/game/m_calendar_ovl_draw.c_inc @@ -168,15 +168,14 @@ static void mCD_set_base_dl(Submenu* submenu, GAME* game, f32 pos_x, f32 pos_y, int year_ofs; int t0; int flag; - int k; int j; + int k; int i; int type; int day; int day_type; u8* prim_p; u8* env_p; - int tex_idx; lbRTC_time_c* rtc_time; calendar = submenu->overlay->calendar_ovl; @@ -224,12 +223,9 @@ static void mCD_set_base_dl(Submenu* submenu, GAME* game, f32 pos_x, f32 pos_y, gSPDisplayList(POLY_OPA_DISP++, cal_win_nen_before); - t0 = (rtc_time->year + year_ofs); - t0--; - for (j = 0; j < 4; j++) { - tex_idx = t0 % 10; - - gDPLoadTextureBlock_4b_Dolphin(POLY_OPA_DISP++, cal_win_nen_txt_table[tex_idx], G_IM_FMT_I, 16, 16, 15, GX_MIRROR, GX_MIRROR, 0, 0); + t0 = rtc_time->year - 1 + year_ofs; + for (j = 0; j < 4; j++, t0) { + gDPLoadTextureBlock_4b_Dolphin(POLY_OPA_DISP++, cal_win_nen_txt_table[t0 % 10], G_IM_FMT_I, 16, 16, 15, GX_MIRROR, GX_MIRROR, 0, 0); gSPDisplayList(POLY_OPA_DISP++, cal_win_nen_table[j]); t0 /= 10; diff --git a/src/game/m_camera2.c b/src/game/m_camera2.c index d090bcfa..4c469b58 100644 --- a/src/game/m_camera2.c +++ b/src/game/m_camera2.c @@ -10,6 +10,14 @@ #include "m_scene_table.h" #include "m_common_data.h" +#if VERSION >= VER_GAFU01_00 +#define CAMERA2_STAFFROLL_CENTER_X_ROT_STEP_DIVISOR 3333 +#define CAMERA2_STAFFROLL_CENTER_Y_ROT_STEP_DIVISOR 2166 +#else +#define CAMERA2_STAFFROLL_CENTER_X_ROT_STEP_DIVISOR 4000 +#define CAMERA2_STAFFROLL_CENTER_Y_ROT_STEP_DIVISOR 2600 +#endif + static void Camera2_main_Normal_AdjustDistanceAndDirection(GAME_PLAY* play, f32* dist, s_xyz* dir); static void Camera2_change_main_index(GAME_PLAY* play); @@ -67,25 +75,19 @@ static f32 Camera2_GetUnderBorderAdjust() { } } -static void Camera2_PolaPosCalc(xyz_t* eye, s16 inv_dir_x, s16 inv_dir_y, xyz_t* center, f32 dist) { - f32 dist_x; - f32 inv_dir_x_f; - f32 inv_dir_y_f; - f32 x; - f32 y; - f32 z; +static void Camera2_PolaPosCalc(xyz_t* eye, s16 inv_dir_x, s16 inv_dir_y, const xyz_t* center, f32 dist) { + f32 dist_xz; + f32 angle_x; + f32 angle_y; + + angle_x = SHORTANGLE2RAD(inv_dir_x); + angle_y = SHORTANGLE2RAD(inv_dir_y); *eye = *center; - inv_dir_x_f = inv_dir_x * SHORTANGLE2RAD(1); - inv_dir_y_f = inv_dir_y * SHORTANGLE2RAD(1); - y = sin(inv_dir_x_f); - eye->y += dist * y; - x = cos(inv_dir_x_f); - dist_x = dist * x; - x = sin(inv_dir_y_f); - eye->x += dist_x * x; - z = cos(inv_dir_y_f); - eye->z += dist_x * z; + eye->y += dist * sinf(angle_x); + dist_xz = dist * cosf(angle_x); + eye->x += dist_xz * sinf(angle_y); + eye->z += dist_xz * cosf(angle_y); } static void Camera2_SetEyePos_fromCenterPosCalc(GAME_PLAY* play, xyz_t* center, xyz_t* eye) { @@ -161,7 +163,7 @@ static void Camera2_MoveDirectionAngleXYZ(GAME_PLAY* play, const s_xyz* goal_dir } } -static void Camera2_SetDirectionAngleXYZ(GAME_PLAY* play, s_xyz* goal_dir, int delta) { +static void Camera2_SetDirectionAngleXYZ(GAME_PLAY* play, const s_xyz* goal_dir, int delta) { Camera2* camera = &play->camera; s_xyz* dir = &camera->direction; s_xyz* dir_vel = &camera->direction_velocity; @@ -766,11 +768,12 @@ extern int Camera2_CheckEnterCullingArea(f32 pos_x, f32 pos_z, f32 width) { extern void Camera2_ClearActorTalking_Cull(GAME_PLAY* play) { Actor_list* actor_list; - ACTOR* actor; int i; actor_list = play->actor_info.list; for (i = 0; i < ACTOR_PART_NUM; i++) { + ACTOR* actor; + for (actor = actor_list->actor; actor != NULL; actor = actor->next_actor) { actor->cull_while_talking = FALSE; } @@ -1002,17 +1005,21 @@ extern int Camera2_request_main_talk(GAME_PLAY* play, ACTOR* speaker, ACTOR* lis return FALSE; } -extern int Camera2_request_main_talk_pos(GAME_PLAY* play, ACTOR* speaker, xyz_t* listener_pos, int priority) { - if ((play->camera.now_main_index == CAMERA2_PROCESS_TALK || - play->camera.requested_main_index == CAMERA2_PROCESS_TALK) && - (Math3DLength(&play->camera.request_data.talk.listener_pos, listener_pos) < 1.0f)) { +extern int Camera2_request_main_talk_pos(GAME_PLAY* play, ACTOR* speaker, const xyz_t* const listener_pos, + int priority) { + Camera2* camera = &play->camera; + + if ((camera->now_main_index == CAMERA2_PROCESS_TALK || camera->requested_main_index == CAMERA2_PROCESS_TALK) && + (Math3DLength(&camera->request_data.talk.listener_pos, listener_pos) < 1.0f)) { return FALSE; } else { if (Camera2_check_request_main_priority(play, priority) > 0) { - play->camera.request_data.talk.speaker_actor = speaker; - play->camera.request_data.talk.listener_actor = NULL; - play->camera.request_data.talk.listener_pos = *listener_pos; - play->camera.request_data.talk.flags = 1; + CameraRequestTalk* req_p = &camera->request_data.talk; + + req_p->speaker_actor = speaker; + req_p->listener_actor = NULL; + req_p->listener_pos = *listener_pos; + req_p->flags = 1; Camera2_request_main_index(play, CAMERA2_PROCESS_TALK, priority); return TRUE; } @@ -1689,8 +1696,8 @@ static void Camera2_setup_main_Item(GAME_PLAY* play) { play->camera.requested_main_index_priority = 0; } -extern int Camera2_request_main_lock(GAME_PLAY* play, xyz_t* center_pos, xyz_t* eye_pos, f32 fov_y, int morph_counter, - f32 near, f32 far, int priority) { +extern int Camera2_request_main_lock(GAME_PLAY* play, const xyz_t* center_pos, const xyz_t* eye_pos, f32 fov_y, + int morph_counter, f32 near, f32 far, int priority) { if (Camera2_check_request_main_priority(play, priority) > 0) { play->camera.request_data.lock.center_pos = *center_pos; play->camera.request_data.lock.eye_pos = *eye_pos; @@ -1718,7 +1725,7 @@ static void Camera2_setup_main_Lock(GAME_PLAY* play) { Camera2_setup_main_Base(play); } -static void Camera2_Lock_SetCenterPos(GAME_PLAY* play, xyz_t* center_pos, int step) { +static void Camera2_Lock_SetCenterPos(GAME_PLAY* play, const xyz_t* center_pos, int step) { Camera2* camera = &play->camera; xyz_t* center_vel_p = &camera->movement_velocity; @@ -1734,7 +1741,7 @@ static void Camera2_Lock_SetCenterPos(GAME_PLAY* play, xyz_t* center_pos, int st center_vel_p->z = center_p->z - pre_center.z; } -static void Camera2_Lock_SetEyePos(GAME_PLAY* play, xyz_t* eye, int step) { +static void Camera2_Lock_SetEyePos(GAME_PLAY* play, const xyz_t* eye, int step) { xyz_t* eye_p = &play->camera.lookat.eye; inter_float(&eye_p->x, eye->x, step); @@ -1907,8 +1914,8 @@ static void Camera2_main_Door(GAME_PLAY* play) { Camera2_change_main_index(play); } -extern int Camera2_request_main_simple2(GAME_PLAY* play, xyz_t* center, s_xyz* dir, f32 dist, int morph_counter, - int mode, int priority) { +extern int Camera2_request_main_simple2(GAME_PLAY* play, const xyz_t* center, const s_xyz* dir, f32 dist, + int morph_counter, int mode, int priority) { if (Camera2_check_request_main_priority(play, priority) > 0) { play->camera.request_data.simple.center_pos = *center; play->camera.request_data.simple.angle = *dir; @@ -1969,7 +1976,7 @@ extern int Camera2_request_main_simple_fishing(GAME_PLAY* play, const xyz_t* pla return Camera2_request_main_simple(play, ¢er, &dir, dist * dist_mult, 40, priority); } -extern int Camera2_request_main_simple_fishing_return(GAME_PLAY* play, xyz_t* player_pos, int priority) { +extern int Camera2_request_main_simple_fishing_return(GAME_PLAY* play, const xyz_t* player_pos, int priority) { xyz_t center_pos; s_xyz dir; f32 dist; @@ -1979,7 +1986,7 @@ extern int Camera2_request_main_simple_fishing_return(GAME_PLAY* play, xyz_t* pl return Camera2_request_main_simple(play, ¢er_pos, &dir, dist, 30, priority); } -extern int Camera2_request_main_simple(GAME_PLAY* play, xyz_t* pos, s_xyz* dir, f32 dist, int morph_counter, +extern int Camera2_request_main_simple(GAME_PLAY* play, const xyz_t* pos, const s_xyz* dir, f32 dist, int morph_counter, int priority) { if (Camera2_check_request_main_priority(play, priority) > 0) { play->camera.request_data.simple.center_pos = *pos; @@ -2116,8 +2123,9 @@ extern int Camera2_request_main_needlework_talk(GAME_PLAY* play, ACTOR* speaker, angle_y = DEG2SHORT_ANGLE(-180.0f); } + diff_x = fabsf(diff_x); angle_x = DEG2SHORT_ANGLE(5.495f); - if (fabsf(diff_x) < mFI_UT_WORLDSIZE_X_F) { + if (diff_x < mFI_UT_WORLDSIZE_X_F) { angle_x = DEG2SHORT_ANGLE(13.735f); } @@ -2161,6 +2169,7 @@ static void Camera2_Cust_Talk_ChangeCameraCenterPos_BetweenSpeakerToListener(GAM xyz_t* pos0; xyz_t* pos1; xyz_t center; + f32 unused; if (speaker == NULL) { pos0 = &listener->eye.position; @@ -2173,6 +2182,7 @@ static void Camera2_Cust_Talk_ChangeCameraCenterPos_BetweenSpeakerToListener(GAM pos0 = &speaker->eye.position; } + unused = fabsf(dist); center.x = pos0->x + center_ratio * (pos1->x - pos0->x); center.y = pos0->y + center_ratio * (pos1->y - pos0->y); center.z = pos0->z + center_ratio * (pos1->z - pos0->z); @@ -2247,8 +2257,9 @@ extern int Camera2_Inter_set_reverse_mode(GAME_PLAY* play) { return TRUE; } -extern int Camera2_request_main_inter(GAME_PLAY* play, xyz_t* start_center, xyz_t* start_eye, xyz_t* goal_center, - xyz_t* goal_eye, f32 s0, f32 s1, u32 flags, int morph_counter, int priority) { +extern int Camera2_request_main_inter(GAME_PLAY* play, const xyz_t* start_center, const xyz_t* start_eye, + const xyz_t* goal_center, const xyz_t* goal_eye, f32 s0, f32 s1, u32 flags, + int morph_counter, int priority) { if (Camera2_check_request_main_priority(play, priority) > 0) { play->camera.request_data.inter.starting_center_pos = *start_center; play->camera.request_data.inter.starting_eye_pos = *start_eye; @@ -2457,17 +2468,23 @@ static void Camera2_Staff_Roll_Center(GAME_PLAY* play, ACTOR* speaker, ACTOR* li h *= ((1.0f + sin_s(temp2) * 0.2f) - 0.2f) * 45.0f; // likely fakematch - temp = (int)((-(f32)camera->main_data.staff_roll.rotation_y_delta / 2600.0f) * 65535.0f) + 0x10000; + temp = + (int)((-(f32)camera->main_data.staff_roll.rotation_y_delta / CAMERA2_STAFFROLL_CENTER_Y_ROT_STEP_DIVISOR) * + 65535.0f) + + 0x10000; temp += camera->main_data.staff_roll.last_direction.y; - y_rot_x = sin_s(temp + -0x4000); + y_rot_x = sin_s(temp + DEG2SHORT_ANGLE2(-90.0f)); goal_center.y = center_y; goal_center.x = center_x + h * y_rot_x; // likely fakematch - temp = (int)((-(f32)camera->main_data.staff_roll.rotation_y_delta / 2600.0f) * 65535.0f) + 0x10000; + temp = + (int)((-(f32)camera->main_data.staff_roll.rotation_y_delta / CAMERA2_STAFFROLL_CENTER_Y_ROT_STEP_DIVISOR) * + 65535.0f) + + 0x10000; temp += camera->main_data.staff_roll.last_direction.y; - y_rot_z = cos_s(temp + -0x4000); + y_rot_z = cos_s(temp + DEG2SHORT_ANGLE2(-90.0f)); goal_center.z = center_z + h * y_rot_z; @@ -2486,10 +2503,10 @@ static void Camera2_Staff_Roll_DistAngle(GAME_PLAY* play, ACTOR* speaker, ACTOR* temp = ((f32)camera->main_data.staff_roll.r_delta / 4600.0f) * 65535.0f; dist = ((sin_s(temp) * 0.2f + 1.0f) - 0.2f) * 575.0f; - temp = ((f32)camera->main_data.staff_roll.rotation_x_delta / 4000.0f) * 65536.0f; + temp = ((f32)camera->main_data.staff_roll.rotation_x_delta / CAMERA2_STAFFROLL_CENTER_X_ROT_STEP_DIVISOR) * 65536.0f; angle->x = (s16)(sin_s(temp) * 5000.0f); - angle->y = (s16)((-(f32)camera->main_data.staff_roll.rotation_y_delta / 2600.0f) * 65535.0f) + + angle->y = (s16)((-(f32)camera->main_data.staff_roll.rotation_y_delta / CAMERA2_STAFFROLL_CENTER_Y_ROT_STEP_DIVISOR) * 65535.0f) + camera->main_data.staff_roll.last_direction.y + (u16)SHT_MIN_S; angle->z = 0; @@ -2575,13 +2592,13 @@ static void Camera2_main_Staff_Roll_SetPos(GAME_PLAY* play) { } main_data->staff_roll.rotation_x_delta++; - if (main_data->staff_roll.rotation_x_delta > 4000) { + if (main_data->staff_roll.rotation_x_delta > CAMERA2_STAFFROLL_CENTER_X_ROT_STEP_DIVISOR) { main_data->staff_roll.rotation_x_delta = 0; } } main_data->staff_roll.rotation_y_delta++; - if (main_data->staff_roll.rotation_y_delta > 2600) { + if (main_data->staff_roll.rotation_y_delta > CAMERA2_STAFFROLL_CENTER_Y_ROT_STEP_DIVISOR) { main_data->staff_roll.rotation_y_delta = 0; } diff --git a/src/game/m_card.c b/src/game/m_card.c index 19295c1d..cebd8ecf 100644 --- a/src/game/m_card.c +++ b/src/game/m_card.c @@ -2479,7 +2479,7 @@ static void mCD_get_passport_comment1(char* comment1, u8* player_name) { } } -static void mCD_get_present_comment1(char* comment1, int num, const char* src_comment, int src_len) { +static void mCD_get_present_comment1(char* comment1, int num, char* src_comment, int src_len) { int i; mem_clear((u8*)comment1, 32, 0); @@ -2502,8 +2502,8 @@ extern int mCD_card_format_bg(s32 chan) { static int mCD_get_this_land_slot_no(mCD_memMgr_c* mgr) { mCD_memMgr_card_info_c* card_info = mgr->cards; Save_t* buf_save = (Save_t*)mgr->workArea; - int i; int res = mCD_RESULT_ERROR; + int i; for (i = 0; i < CARD_NUM_CHANS; i++) { card_info[i].result = CARD_RESULT_NOCARD; @@ -2535,8 +2535,8 @@ static int mCD_get_this_land_slot_no(mCD_memMgr_c* mgr) { static int mCD_get_this_land_slot_no_game_start(mCD_memMgr_c* mgr) { mCD_memMgr_card_info_c* card_info = mgr->cards; Save_t* buf_save = (Save_t*)mgr->workArea; - int i; int res = mCD_RESULT_ERROR; + int i; for (i = 0; i < CARD_NUM_CHANS; i++) { card_info[i].result = CARD_RESULT_NOCARD; @@ -2570,8 +2570,8 @@ static int mCD_get_this_land_slot_no_game_start(mCD_memMgr_c* mgr) { static int mCD_get_this_land_slot_no_nes(mCD_memMgr_c* mgr) { mCD_memMgr_card_info_c* card_info = mgr->cards; Save_t* buf_save = (Save_t*)mgr->workArea; - int i; int res = mCD_RESULT_ERROR; + int i; for (i = 0; i < CARD_NUM_CHANS; i++) { card_info[i].result = CARD_RESULT_NOCARD; @@ -2854,7 +2854,7 @@ static int mCD_CheckPresentFile(char* filename, s32* fileNo, s32 chan, s32* resu static int mCD_SaveHome_bg_read_send_present(mCD_memMgr_c* mgr, mCD_memMgr_fileInfo_c* fileInfo) { static int icon_fileNo[mCD_PRESENT_TYPE_NUM] = { RESOURCE_TEGAMI, RESOURCE_TEGAMI2 }; - static const char* comment_p_table[mCD_PRESENT_TYPE_NUM] = { l_comment_present_1_str, l_comment_gift_1_str }; + static char* comment_p_table[mCD_PRESENT_TYPE_NUM] = { l_comment_present_1_str, l_comment_gift_1_str }; static int comment_len_table[mCD_PRESENT_TYPE_NUM] = { 14, 13 }; void* workArea = mgr->workArea; mCD_file_entry_c* present_entry; @@ -3303,8 +3303,10 @@ static void mCD_SetResetInfo(Private_c* priv) { } } -static int mCD_get_land_copyProtect(void) { - return 1 + (u16)RANDOM(0xFFF0); +static u16 mCD_get_land_copyProtect(void) { + u16 code = RANDOM(0xFFF0); + code++; + return code; } static int mCD_SaveHome_bg_set_data(mCD_memMgr_c* mgr, mCD_memMgr_fileInfo_c* fileInfo) { @@ -6236,16 +6238,19 @@ static void mCD_ReplaceKeep(Private_c* priv, mCD_PrivateItem_c* privItem) { } } +// TODO: probably fakematch +#if VERSION == VER_GAFU01_00 static int mCD_SaveStation_NextLand_set_data(mCD_memMgr_c* mgr, mCD_memMgr_fileInfo_c* fileInfo) { - Private_c* priv; Save_t* save; + Private_c* priv; + mCD_persistent_data_c* persistant = Common_GetPointer(travel_persistent_data); + int i; mActor_name_t* pocket_p; Animal_c* in_animal; - mCD_persistent_data_c* persistant = Common_GetPointer(travel_persistent_data); + int j; u16 copy_protect; s32 chan; int ret = mCD_RESULT_BUSY; - int i; chan = mgr->chan; save = (Save_t*)mgr->workArea; @@ -6254,12 +6259,10 @@ static int mCD_SaveStation_NextLand_set_data(mCD_memMgr_c* mgr, mCD_memMgr_fileI mCkRh_SavePlayTime(Common_Get(player_no)); if (priv != NULL) { pocket_p = priv->inventory.pockets; - for (i = 0; i < mPr_POCKETS_SLOT_COUNT; i++) { + for (j = 0; j < mPr_POCKETS_SLOT_COUNT; j++, pocket_p++) { if (ITEM_IS_WISP(*pocket_p)) { - mPr_SetPossessionItem(priv, i, EMPTY_NO, mPr_ITEM_COND_NORMAL); + mPr_SetPossessionItem(priv, j, EMPTY_NO, mPr_ITEM_COND_NORMAL); } - - pocket_p++; } } @@ -6301,6 +6304,71 @@ static int mCD_SaveStation_NextLand_set_data(mCD_memMgr_c* mgr, mCD_memMgr_fileI return ret; } +#else +static int mCD_SaveStation_NextLand_set_data(mCD_memMgr_c* mgr, mCD_memMgr_fileInfo_c* fileInfo) { + Save_t* save; + Private_c* priv; + mCD_persistent_data_c* persistant = Common_GetPointer(travel_persistent_data); + mActor_name_t* pocket_p; + Animal_c* in_animal; + int i; + u16 copy_protect; + s32 chan; + int ret = mCD_RESULT_BUSY; + + chan = mgr->chan; + save = (Save_t*)mgr->workArea; + if (save != NULL && chan != -1) { + priv = Now_Private; + mCkRh_SavePlayTime(Common_Get(player_no)); + if (priv != NULL) { + pocket_p = priv->inventory.pockets; + for (i = 0; i < mPr_POCKETS_SLOT_COUNT; i++, pocket_p++) { + if (ITEM_IS_WISP(*pocket_p)) { + mPr_SetPossessionItem(priv, i, EMPTY_NO, mPr_ITEM_COND_NORMAL); + } + } + } + + mCD_ClearResetCode(); + mHm_KeepHouseSize(Common_Get(player_no)); + in_animal = mNpc_GetInAnimalP(); + mNpc_GetRemoveAnimal(in_animal, TRUE); + mCD_SetForeignerFile(&l_mcd_foreigner_file.file, priv, in_animal); + if (mLd_PlayerManKindCheckNo(Common_Get(player_no)) == FALSE) { + priv->exists = FALSE; + mCD_ClearPrivateItem(priv, &mgr->private_item); + mgr->_0198 = 1; + } + + bcopy(Save_GetPointer(land_info), &persistant->land, sizeof(mLd_land_info_c)); + // priv = Save_Get(private_data); + for (i = 0; i < PLAYER_NUM; i++) { + mPr_CopyPersonalID(&persistant->pid[i], &Save_Get(private_data[i]).player_ID); + } + + mAGrw_ClearMoneyStoneShineGround(); + Save_Set(travel_hard_time, lbRTC_HardTime()); + mgr->copy_protect = Common_Get(copy_protect); + copy_protect = mCD_get_land_copyProtect(); + Common_Set(copy_protect, copy_protect); + Save_Set(copy_protect, copy_protect); + bcopy(Common_GetPointer(save), save, sizeof(Save)); + save->save_check.version = 6; + mFRm_SetSaveCheckData(&save->save_check); + save->save_check.checksum = mFRm_GetFlatCheckSum((u16*)save, sizeof(Save), save->save_check.checksum); + mgr->loaded_file_type = mCD_FILE_SAVE_MAIN; + mgr->workArea_size = mCD_get_size(mgr->loaded_file_type); + fileInfo->proc++; + ret = mCD_RESULT_SUCCESS; + } else { + fileInfo->_04 = mCD_TRANS_ERR_NOCARD; + ret = mCD_RESULT_ERROR; + } + + return ret; +} +#endif static int mCD_SaveStation_NextLand_write_main(mCD_memMgr_c* mgr, mCD_memMgr_fileInfo_c* fileInfo) { s32 result; @@ -6789,10 +6857,8 @@ static int mCD_SaveStation_Passport_make_file_name(mCD_memMgr_c* mgr, mCD_memMgr } if (count > 0) { - u8* cond_p = cond; - - for (i = 0; i < CARD_MAX_FILE; i++, cond_p++) { - if (*cond_p == FALSE) { + for (i = 0; i < CARD_MAX_FILE; i++) { + if (cond[i] == FALSE) { filename_idx = i; break; } diff --git a/src/game/m_choice.c b/src/game/m_choice.c index 9d5f8e52..d0c897be 100644 --- a/src/game/m_choice.c +++ b/src/game/m_choice.c @@ -35,67 +35,67 @@ static void mChoice_Main_Normal(mChoice_c*, GAME*); static void mChoice_Main_Disappear(mChoice_c*, GAME*); static void mChoice_MainSetup(mChoice_c* choice, GAME* game) { - static mChoice_MAIN_PROC proc[mChoice_MAIN_INDEX_NUM] = { - &mChoice_MainSetup_Hide, - &mChoice_MainSetup_Appear, - &mChoice_MainSetup_Normal, - &mChoice_MainSetup_Disappear - }; + static mChoice_MAIN_PROC proc[mChoice_MAIN_INDEX_NUM] = { + &mChoice_MainSetup_Hide, + &mChoice_MainSetup_Appear, + &mChoice_MainSetup_Normal, + &mChoice_MainSetup_Disappear, + }; - int index = choice->requested_main_index; + int index = choice->requested_main_index; - /* This is necessary lol */ - if (index < 0) { - return; - } - else if (index < 0 || index >= mChoice_MAIN_INDEX_NUM || proc[index] == NULL) { - return; - } + /* This is necessary lol */ + if (index < 0) { + return; + } else if (index < 0 || index >= mChoice_MAIN_INDEX_NUM || proc[index] == NULL) { + return; + } - (*proc[index])(choice, game); + (*proc[index])(choice, game); } extern void mChoice_Main(mChoice_c* choice, GAME* game) { - static mChoice_MAIN_PROC proc[mChoice_MAIN_INDEX_NUM] = { - &mChoice_Main_Hide, - &mChoice_Main_Appear, - &mChoice_Main_Normal, - &mChoice_Main_Disappear - }; + static mChoice_MAIN_PROC proc[mChoice_MAIN_INDEX_NUM] = { + &mChoice_Main_Hide, + &mChoice_Main_Appear, + &mChoice_Main_Normal, + &mChoice_Main_Disappear, + }; - int index = choice->main_index; + int index = choice->main_index; - if (index < 0 || index >= mChoice_MAIN_INDEX_NUM || proc[index] == NULL) { - return; - } + if (index < 0 || index >= mChoice_MAIN_INDEX_NUM || proc[index] == NULL) { + return; + } - (*proc[index])(choice, game); + (*proc[index])(choice, game); } extern void mChoice_Draw(mChoice_c* choice, GAME* game, int mode) { - if (choice->window_visible_flag) { - mFont_SetMatrix(game->graph, mode); - mChoice_SetMatrix(choice, game, mode); - mChoice_SetMatrixDisplay(choice, game, mode); - mChoice_DrawWindowBody(choice, game, mode); - mChoice_UnSetMatrixDisplay(game, mode); - mChoice_DrawFont(choice, game, mode); - mChoice_UnSetMatrix(); - mFont_UnSetMatrix(game->graph, mode); - } + if (choice->window_visible_flag) { + mFont_SetMatrix(game->graph, mode); + mChoice_SetMatrix(choice, game, mode); + mChoice_SetMatrixDisplay(choice, game, mode); + mChoice_DrawWindowBody(choice, game, mode); + mChoice_UnSetMatrixDisplay(game, mode); + mChoice_DrawFont(choice, game, mode); + mChoice_UnSetMatrix(); + mFont_UnSetMatrix(game->graph, mode); + } } extern void mChoice_aram_init() { - Choice_table_rom_start = JW_GetAramAddress(RESOURCE_SELECT_TABLE); - Choice_rom_start = JW_GetAramAddress(RESOURCE_SELECT); + Choice_table_rom_start = JW_GetAramAddress(RESOURCE_SELECT_TABLE); + Choice_rom_start = JW_GetAramAddress(RESOURCE_SELECT); } extern void mChoice_ct(mChoice_c* choice, GAME* game) { - mChoice_check_ct(choice); - mChoice_init(choice, game); + mChoice_check_ct(choice); + mChoice_init(choice, game); } -extern void mChoice_dt(mChoice_c* choice, GAME* game) { } +extern void mChoice_dt(mChoice_c* choice, GAME* game) { +} #include "../src/game/m_choice_main.c_inc" #include "../src/game/m_choice_sound.c_inc" diff --git a/src/game/m_choice_draw.c_inc b/src/game/m_choice_draw.c_inc index 1eddcfc8..ab4042b9 100644 --- a/src/game/m_choice_draw.c_inc +++ b/src/game/m_choice_draw.c_inc @@ -1,168 +1,147 @@ static void mChoice_SetMatrix(mChoice_c* choice, GAME* game, int type) { - GRAPH* graph = game->graph; - f32 scale = choice->scale; - f32 x = ( choice->center_x - 160.0f) * 16.0f; - f32 y = (-choice->center_y + 120.0f) * 16.0f; + GRAPH* graph = game->graph; + f32 scale = choice->scale; + f32 x = (choice->center_x - 160.0f) * 16.0f; + f32 y = (-choice->center_y + 120.0f) * 16.0f; - Matrix_push(); - Matrix_translate(x, y, 0.0f, MTX_MULT); - Matrix_scale(scale, scale, 1.0f, MTX_MULT); + Matrix_push(); + Matrix_translate(x, y, 0.0f, MTX_MULT); + Matrix_scale(scale, scale, 1.0f, MTX_MULT); - OPEN_DISP(graph); + OPEN_DISP(graph); - if (type == mFont_MODE_FONT) { - gSPMatrix(NOW_FONT_DISP++, _Matrix_to_Mtx_new(graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - } - else { - gSPMatrix(NOW_POLY_OPA_DISP++, _Matrix_to_Mtx_new(graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - } + if (type == mFont_MODE_FONT) { + gSPMatrix(NOW_FONT_DISP++, _Matrix_to_Mtx_new(graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + } else { + gSPMatrix(NOW_POLY_OPA_DISP++, _Matrix_to_Mtx_new(graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + } - CLOSE_DISP(graph); + CLOSE_DISP(graph); } static void mChoice_SetMatrixDisplay(mChoice_c* choice, GAME* game, int type) { - GRAPH* graph = game->graph; - f32 scale_x = choice->scale_x; - f32 scale_y = choice->scale_y; + GRAPH* graph = game->graph; + f32 scale_x = choice->scale_x; + f32 scale_y = choice->scale_y; - Matrix_push(); - Matrix_scale(scale_x, scale_y, 1.0f, MTX_MULT); + Matrix_push(); + Matrix_scale(scale_x, scale_y, 1.0f, MTX_MULT); - OPEN_DISP(graph); + OPEN_DISP(graph); - if (type == mFont_MODE_FONT) { - gSPMatrix(NOW_FONT_DISP++, _Matrix_to_Mtx_new(graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - } - else { - gSPMatrix(NOW_POLY_OPA_DISP++, _Matrix_to_Mtx_new(graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - } + if (type == mFont_MODE_FONT) { + gSPMatrix(NOW_FONT_DISP++, _Matrix_to_Mtx_new(graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + } else { + gSPMatrix(NOW_POLY_OPA_DISP++, _Matrix_to_Mtx_new(graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + } - CLOSE_DISP(graph); + CLOSE_DISP(graph); } static void mChoice_UnSetMatrix() { - Matrix_pull(); + Matrix_pull(); } static void mChoice_UnSetMatrixDisplay(GAME* game, int type) { - GRAPH* graph = game->graph; - - Matrix_pull(); + GRAPH* graph = game->graph; - OPEN_DISP(graph); + Matrix_pull(); - if (type == mFont_MODE_FONT) { - gSPMatrix(NOW_FONT_DISP++, _Matrix_to_Mtx_new(graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - } - else { - gSPMatrix(NOW_POLY_OPA_DISP++, _Matrix_to_Mtx_new(graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - } + OPEN_DISP(graph); - CLOSE_DISP(graph); + if (type == mFont_MODE_FONT) { + gSPMatrix(NOW_FONT_DISP++, _Matrix_to_Mtx_new(graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + } else { + gSPMatrix(NOW_POLY_OPA_DISP++, _Matrix_to_Mtx_new(graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + } + + CLOSE_DISP(graph); } static u8 con_waku_swaku3_tex[] ATTRIBUTE_ALIGN(32) = { - #ifndef __INTELLISENSE__ - #include "assets/con_waku_swaku3_tex.inc" - #endif +#ifndef __INTELLISENSE__ +#include "assets/con_waku_swaku3_tex.inc" +#endif }; static Vtx con_sentaku2_v[] = { - #ifndef __INTELLISENSE__ - #include "assets/con_sentaku2_v.inc" - #endif +#ifndef __INTELLISENSE__ +#include "assets/con_sentaku2_v.inc" +#endif }; static Gfx con_sentaku2_modelT[] = { - gsSPTexture(0, 0, 0, 0, G_ON), - gsDPSetPrimColor(0, 255, 255, 255, 155, 255), - gsDPLoadTextureBlock_4b_Dolphin(con_waku_swaku3_tex, G_IM_FMT_I, 128, 64, 15, GX_MIRROR, GX_MIRROR, 0, 0), - gsSPVertex(&con_sentaku2_v[0], 4, 0), - gsSPNTrianglesInit_5b( - 2, // tri count - 0, 1, 2, // tri0 - 0, 2, 3, // tri1 - 0, 0, 0 // tri2 - ), - gsSPEndDisplayList() + gsSPTexture(0, 0, 0, 0, G_ON), + gsDPSetPrimColor(0, 255, 255, 255, 155, 255), + gsDPLoadTextureBlock_4b_Dolphin(con_waku_swaku3_tex, G_IM_FMT_I, 128, 64, 15, GX_MIRROR, GX_MIRROR, 0, 0), + gsSPVertex(&con_sentaku2_v[0], 4, 0), + gsSPNTrianglesInit_5b(2, // tri count + 0, 1, 2, // tri0 + 0, 2, 3, // tri1 + 0, 0, 0 // tri2 + ), + gsSPEndDisplayList(), }; static Gfx mChoice_init_disp[] = { - gsDPPipeSync(), - gsSPClearGeometryMode(G_ZBUFFER | G_SHADE | G_CULL_BOTH | G_FOG | G_LIGHTING | G_TEXTURE_GEN | G_TEXTURE_GEN_LINEAR | G_LOD | G_SHADING_SMOOTH), - gsDPSetTextureLOD(G_TL_TILE), - gsDPSetTextureConvert(G_TC_FILT), - gsDPSetTextureFilter(G_TF_BILERP), - gsDPSetCycleType(G_CYC_1CYCLE), - gsDPSetTexturePersp(G_TP_PERSP), - gsDPSetAlphaDither(G_AD_DISABLE), - gsDPSetColorDither(G_CD_DISABLE), - gsDPSetCombineKey(G_CK_NONE), - gsDPSetCombineLERP(0, 0, 0, PRIMITIVE, 0, 0, 0, TEXEL0, 0, 0, 0, PRIMITIVE, 0, 0, 0, TEXEL0), - gsDPSetRenderMode(G_RM_XLU_SURF, G_RM_XLU_SURF2), - gsSPEndDisplayList() + gsDPPipeSync(), + gsSPClearGeometryMode(G_ZBUFFER | G_SHADE | G_CULL_BOTH | G_FOG | G_LIGHTING | G_TEXTURE_GEN | + G_TEXTURE_GEN_LINEAR | G_LOD | G_SHADING_SMOOTH), + gsDPSetTextureLOD(G_TL_TILE), + gsDPSetTextureConvert(G_TC_FILT), + gsDPSetTextureFilter(G_TF_BILERP), + gsDPSetCycleType(G_CYC_1CYCLE), + gsDPSetTexturePersp(G_TP_PERSP), + gsDPSetAlphaDither(G_AD_DISABLE), + gsDPSetColorDither(G_CD_DISABLE), + gsDPSetCombineKey(G_CK_NONE), + gsDPSetCombineLERP(0, 0, 0, PRIMITIVE, 0, 0, 0, TEXEL0, 0, 0, 0, PRIMITIVE, 0, 0, 0, TEXEL0), + gsDPSetRenderMode(G_RM_XLU_SURF, G_RM_XLU_SURF2), + gsSPEndDisplayList(), }; static void mChoice_DrawWindowBody(mChoice_c* choice, GAME* game, int type) { - GRAPH* graph = game->graph; + GRAPH* graph = game->graph; - OPEN_DISP(graph); + OPEN_DISP(graph); - if (type == mFont_MODE_FONT) { - gSPDisplayList(NOW_FONT_DISP++, mChoice_init_disp); - gSPDisplayList(NOW_FONT_DISP++, con_sentaku2_modelT); - } - else { - gSPDisplayList(NOW_POLY_OPA_DISP++, mChoice_init_disp); - gSPDisplayList(NOW_POLY_OPA_DISP++, con_sentaku2_modelT); - } + if (type == mFont_MODE_FONT) { + gSPDisplayList(NOW_FONT_DISP++, mChoice_init_disp); + gSPDisplayList(NOW_FONT_DISP++, con_sentaku2_modelT); + } else { + gSPDisplayList(NOW_POLY_OPA_DISP++, mChoice_init_disp); + gSPDisplayList(NOW_POLY_OPA_DISP++, con_sentaku2_modelT); + } - CLOSE_DISP(graph); + CLOSE_DISP(graph); } static void mChoice_DrawFont(mChoice_c* choice, GAME* game, int type) { - int i; - int choice_num = choice->data.choice_num; - f32 x = choice->text_x; - f32 y = choice->text_y; - int selected_idx = choice->selected_choice_idx; - int r; - int g; - int b; + int i; + int choice_num = choice->data.choice_num; + f32 x = choice->text_x; + f32 y = choice->text_y; + int selected_idx = choice->selected_choice_idx; + int r; + int g; + int b; - for (i = 0; i < choice_num; i++) { - if (i == selected_idx) { - r = choice->selected_choice_text_color.r; - g = choice->selected_choice_text_color.g; - b = choice->selected_choice_text_color.b; - mFont_SetMarkChar( - game, - mFont_MARKTYPE_CHOICE, - x - 16.0f, y, - choice->background_color.r, choice->background_color.g, choice->background_color.b, 255, - FALSE, - 1.0f, 1.0f, - type - ); + for (i = 0; i < choice_num; i++) { + if (i == selected_idx) { + r = choice->selected_choice_text_color.r; + g = choice->selected_choice_text_color.g; + b = choice->selected_choice_text_color.b; + mFont_SetMarkChar(game, mFont_MARKTYPE_CHOICE, x - 16.0f, y, choice->background_color.r, + choice->background_color.g, choice->background_color.b, 255, FALSE, 1.0f, 1.0f, type); + } else { + r = choice->text_color.r; + g = choice->text_color.g; + b = choice->text_color.b; + } + + mFont_SetLineStrings_AndSpace(game, choice->data.strings[i], choice->data.string_lens[i], x, y, r, g, b, 255, + FALSE, TRUE, 0, 1.0f, 1.0f, type); + + y += 16.0f; } - else { - r = choice->text_color.r; - g = choice->text_color.g; - b = choice->text_color.b; - } - - mFont_SetLineStrings_AndSpace( - game, - choice->data.strings[i], choice->data.string_lens[i], - x, y, - r, g, b, 255, - FALSE, - TRUE, - 0, - 1.0f, 1.0f, - type - ); - - y += 16.0f; - } } diff --git a/src/game/m_choice_main.c_inc b/src/game/m_choice_main.c_inc index b47f0657..4a8197e5 100644 --- a/src/game/m_choice_main.c_inc +++ b/src/game/m_choice_main.c_inc @@ -1,583 +1,573 @@ extern mChoice_c* mChoice_Get_base_window_p() { - return &mMsg_Get_base_window_p()->choice_window; + return &mMsg_Get_base_window_p()->choice_window; } static void mChoice_init(mChoice_c* choice, GAME* game) { - choice->center_x = 191.0f; - choice->center_y = 83.0f; - choice->text_color.r = 180; - choice->text_color.g = 150; - choice->text_color.b = 110; - choice->text_color.a = 255; - choice->text_scale_x = 1.0f; - choice->text_scale_y = 1.0f; - choice->text_x = 104.0f; - choice->text_y = 96.0f; - choice->scale_x = 1.0f; - choice->scale_y = 1.0f; - choice->data.choice_num = mChoice_CHOICE_NUM; - choice->selected_choice_idx = mChoice_CHOICE0; - choice->selected_choice_text_color.r = 120; - choice->selected_choice_text_color.g = 50; - choice->selected_choice_text_color.b = 50; - choice->selected_choice_text_color.a = 255; - choice->background_color.r = 0; - choice->background_color.g = 195; - choice->background_color.b = 185; - choice->background_color.a = 255; - choice->choice_automove_timer = 0.0f; - choice->_D4 = 232.0f; - choice->_D8 = 104.0f; - choice->scale = 0.0f; - choice->main_index = mChoice_MAIN_HIDE; - choice->requested_main_index = -1; - choice->window_visible_flag = FALSE; - choice->font_visible_flag = FALSE; - choice->choice_automove_type = mChoice_AUTOMOVE_STOPPED; - choice->choice_automove_timer = 0.0f; // duplicate set - choice->timer = 0.0f; - choice->no_b_flag = FALSE; - choice->no_close_flag = FALSE; + choice->center_x = 191.0f; + choice->center_y = 83.0f; + choice->text_color.r = 180; + choice->text_color.g = 150; + choice->text_color.b = 110; + choice->text_color.a = 255; + choice->text_scale_x = 1.0f; + choice->text_scale_y = 1.0f; + choice->text_x = 104.0f; + choice->text_y = 96.0f; + choice->scale_x = 1.0f; + choice->scale_y = 1.0f; + choice->data.choice_num = mChoice_CHOICE_NUM; + choice->selected_choice_idx = mChoice_CHOICE0; + choice->selected_choice_text_color.r = 120; + choice->selected_choice_text_color.g = 50; + choice->selected_choice_text_color.b = 50; + choice->selected_choice_text_color.a = 255; + choice->background_color.r = 0; + choice->background_color.g = 195; + choice->background_color.b = 185; + choice->background_color.a = 255; + choice->choice_automove_timer = 0.0f; + choice->_D4 = 232.0f; + choice->_D8 = 104.0f; + choice->scale = 0.0f; + choice->main_index = mChoice_MAIN_HIDE; + choice->requested_main_index = -1; + choice->window_visible_flag = FALSE; + choice->font_visible_flag = FALSE; + choice->choice_automove_type = mChoice_AUTOMOVE_STOPPED; + choice->choice_automove_timer = 0.0f; // duplicate set + choice->timer = 0.0f; + choice->no_b_flag = FALSE; + choice->no_close_flag = FALSE; } extern void mChoice_Change_request_main_index(mChoice_c* choice, int request_main_index) { - choice->requested_main_index = request_main_index; + choice->requested_main_index = request_main_index; } extern int mChoice_check_main_index(mChoice_c* choice) { - return choice->main_index; + return choice->main_index; } extern int mChoice_check_main_normal(mChoice_c* choice) { - if (mChoice_check_main_index(choice) == mChoice_MAIN_NORMAL) { - return TRUE; - } + if (mChoice_check_main_index(choice) == mChoice_MAIN_NORMAL) { + return TRUE; + } - return FALSE; + return FALSE; } static void mChoice_Init_choice_data(mChoice_c* choice) { - choice->data.choice_num = 0; + choice->data.choice_num = 0; } static int mChoice_Add_choice_data(mChoice_c* choice, u8* str, int max_len) { - if (str != NULL && max_len > 0 && max_len <= mChoice_CHOICE_STRING_LEN) { - int num = choice->data.choice_num; + if (str != NULL && max_len > 0 && max_len <= mChoice_CHOICE_STRING_LEN) { + int num = choice->data.choice_num; - if (num < mChoice_CHOICE_NUM) { - int len = mMsg_Get_Length_String(str, max_len); - u8* dst = choice->data.strings[num]; - int i; + if (num < mChoice_CHOICE_NUM) { + int i; + int len = mMsg_Get_Length_String(str, max_len); + u8* dst = choice->data.strings[num]; - for (i = 0; i < len; i++) { - *dst++ = *str++; - } + for (i = 0; i < len; i++) { + *dst++ = *str++; + } - choice->data.string_lens[num] = len; - choice->data.choice_num++; - return num; + choice->data.string_lens[num] = len; + choice->data.choice_num++; + return num; + } } - } - return -1; + return -1; } -extern void mChoice_Set_choice_data( - mChoice_c* choice, - u8* str0, int str0_len, - u8* str1, int str1_len, - u8* str2, int str2_len, - u8* str3, int str3_len, - u8* str4, int str4_len, - u8* str5, int str5_len -) { - mChoice_Init_choice_data(choice); +extern void mChoice_Set_choice_data(mChoice_c* choice, u8* str0, int str0_len, u8* str1, int str1_len, u8* str2, + int str2_len, u8* str3, int str3_len, u8* str4, int str4_len, u8* str5, + int str5_len) { + mChoice_Init_choice_data(choice); - if (str0 != NULL && str0_len > 0 && str0_len <= mChoice_CHOICE_STRING_LEN) { - mChoice_Add_choice_data(choice, str0, str0_len); - } + if (str0 != NULL && str0_len > 0 && str0_len <= mChoice_CHOICE_STRING_LEN) { + mChoice_Add_choice_data(choice, str0, str0_len); + } - if (str1 != NULL && str1_len > 0 && str1_len <= mChoice_CHOICE_STRING_LEN) { - mChoice_Add_choice_data(choice, str1, str1_len); - } + if (str1 != NULL && str1_len > 0 && str1_len <= mChoice_CHOICE_STRING_LEN) { + mChoice_Add_choice_data(choice, str1, str1_len); + } - if (str2 != NULL && str2_len > 0 && str2_len <= mChoice_CHOICE_STRING_LEN) { - mChoice_Add_choice_data(choice, str2, str2_len); - } + if (str2 != NULL && str2_len > 0 && str2_len <= mChoice_CHOICE_STRING_LEN) { + mChoice_Add_choice_data(choice, str2, str2_len); + } - if (str3 != NULL && str3_len > 0 && str3_len <= mChoice_CHOICE_STRING_LEN) { - mChoice_Add_choice_data(choice, str3, str3_len); - } + if (str3 != NULL && str3_len > 0 && str3_len <= mChoice_CHOICE_STRING_LEN) { + mChoice_Add_choice_data(choice, str3, str3_len); + } - if (str4 != NULL && str4_len > 0 && str4_len <= mChoice_CHOICE_STRING_LEN) { - mChoice_Add_choice_data(choice, str4, str4_len); - } + if (str4 != NULL && str4_len > 0 && str4_len <= mChoice_CHOICE_STRING_LEN) { + mChoice_Add_choice_data(choice, str4, str4_len); + } - if (str5 != NULL && str5_len > 0 && str5_len <= mChoice_CHOICE_STRING_LEN) { - mChoice_Add_choice_data(choice, str5, str5_len); - } + if (str5 != NULL && str5_len > 0 && str5_len <= mChoice_CHOICE_STRING_LEN) { + mChoice_Add_choice_data(choice, str5, str5_len); + } } static int mChoice_Get_MaxStringDotWidth(mChoice_c* choice) { - int i; - int choice_num = choice->data.choice_num; - int max_width = 0; + int i; + int choice_num = choice->data.choice_num; + int max_width = 0; - for (i = 0; i < choice_num; i++) { - u8* str = choice->data.strings[i]; - int len = choice->data.string_lens[i]; - int width = mFont_GetStringWidth(str, len, TRUE); + for (i = 0; i < choice_num; i++) { + u8* str = choice->data.strings[i]; + int len = choice->data.string_lens[i]; + int width = mFont_GetStringWidth(str, len, TRUE); - if (width > max_width) { - max_width = width; + if (width > max_width) { + max_width = width; + } } - } - return max_width; + return max_width; } static int mChoice_Get_MaxStringDotHeight(mChoice_c* choice) { - return choice->data.choice_num * 16; + return choice->data.choice_num * 16; } static void mChoice_Set_DisplayScaleAndDisplayPos(mChoice_c* choice) { - int dw = mChoice_Get_MaxStringDotWidth(choice); - f32 dotW = ((f32)dw - 24.0f) / 96.0f; - int dh = mChoice_Get_MaxStringDotHeight(choice); - f32 dotH = ((f32)dh - 32.0f) / 32.0f; - f32 scaleX = (dotW * 0.5833333730697632f) + (1.0f/2.4f); - f32 scaleY = (dotH * 0.3142857f) + (0.6857143f); - int choice_num = choice->data.choice_num; - f32 tempDotH; + int dw = mChoice_Get_MaxStringDotWidth(choice); + f32 dotW = ((f32)dw - 24.0f) / 96.0f; + int dh = mChoice_Get_MaxStringDotHeight(choice); + f32 dotH = ((f32)dh - 32.0f) / 32.0f; + f32 scaleX = (dotW * 0.5833333730697632f) + (1.0f / 2.4f); + f32 scaleY = (dotH * 0.3142857f) + (0.6857143f); + int choice_num = choice->data.choice_num; + f32 tempDotH; - choice->scale_x = scaleX; - choice->scale_y = scaleY; - tempDotH = dotH * -20.057144f; - choice->text_x = (dotW * -48.0f) + 152.0f; - - if (choice_num > 4) { - choice->text_y = tempDotH + 105.0f + (f32)(choice_num - 3) * 2.0f; - } - else { - choice->text_y = tempDotH + 105.0f; - } + choice->scale_x = scaleX; + choice->scale_y = scaleY; + tempDotH = dotH * -20.057144f; + choice->text_x = (dotW * -48.0f) + 152.0f; - tempDotH = dotH * 20.057144f; - choice->center_x = 242.0f; - choice->center_x_begin = 242.0f; - choice->center_x_target = 242.0f + (dotW * -35.0f); + if (choice_num > 4) { + choice->text_y = tempDotH + 105.0f + (f32)(choice_num - 3) * 2.0f; + } else { + choice->text_y = tempDotH + 105.0f; + } - choice->center_y = 169.0f; - choice->center_y_begin = 169.0f; + tempDotH = dotH * 20.057144f; + choice->center_x = 242.0f; + choice->center_x_begin = 242.0f; + choice->center_x_target = 242.0f + (dotW * -35.0f); - if (choice_num > 4) { - choice->center_y_target = (169.0f + tempDotH) - (f32)(choice_num - 4) * 16.0f; - } - else { - choice->center_y_target = 169.0f + tempDotH; - } + choice->center_y = 169.0f; + choice->center_y_begin = 169.0f; + + if (choice_num > 4) { + choice->center_y_target = (169.0f + tempDotH) - (f32)(choice_num - 4) * 16.0f; + } else { + choice->center_y_target = 169.0f + tempDotH; + } } extern int mChoice_Get_ChoseNum(mChoice_c* choice) { - return choice->data.selected_choice_idx; + return choice->data.selected_choice_idx; } extern void mChoice_Clear_ChoseNum(mChoice_c* choice) { - choice->data.selected_choice_idx = -1; + choice->data.selected_choice_idx = -1; } -static void mChoice_check_ct(mChoice_c* choice) { } +static void mChoice_check_ct(mChoice_c* choice) { +} static void mChoice_Get_StringDataAddressAndSize(int idx, u32* addr, u32* size) { - mMsg_Get_BodyParam(Choice_table_rom_start, Choice_rom_start, idx, addr, size); + mMsg_Get_BodyParam(Choice_table_rom_start, Choice_rom_start, idx, addr, size); } static int mChoice_Put_String_PLAYER_NAME(u8* data, int idx, int max_size, ACTOR* actor) { - return mMsg_CopyPlayerName(data, idx, max_size, FALSE); + return mMsg_CopyPlayerName(data, idx, max_size, FALSE); } static int mChoice_Put_String_TALK_NAME(u8* data, int idx, int max_size, ACTOR* actor) { - return mMsg_CopyTalkName(actor, data, idx, max_size, FALSE); + return mMsg_CopyTalkName(actor, data, idx, max_size, FALSE); } static int mChoice_Put_String_TAIL(u8* data, int idx, int max_size, ACTOR* actor) { - return mMsg_CopyTail(actor, data, idx, max_size, FALSE); + return mMsg_CopyTail(actor, data, idx, max_size, FALSE); } static int mChoice_Put_String_YEAR(u8* data, int idx, int max_size, ACTOR* actor) { - return mMsg_CopyYear(data, idx, max_size); + return mMsg_CopyYear(data, idx, max_size); } static int mChoice_Put_String_MONTH(u8* data, int idx, int max_size, ACTOR* actor) { - return mMsg_CopyMonth(data, idx, max_size); + return mMsg_CopyMonth(data, idx, max_size); } static int mChoice_Put_String_WEEK(u8* data, int idx, int max_size, ACTOR* actor) { - return mMsg_CopyWeek(data, idx, max_size); + return mMsg_CopyWeek(data, idx, max_size); } static int mChoice_Put_String_DAY(u8* data, int idx, int max_size, ACTOR* actor) { - return mMsg_CopyDay(data, idx, max_size); + return mMsg_CopyDay(data, idx, max_size); } static int mChoice_Put_String_HOUR(u8* data, int idx, int max_size, ACTOR* actor) { - mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); - int hour = Common_Get(time.rtc_time.hour); + mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); + int hour = Common_Get(time.rtc_time.hour); - if (hour < 12) { - msg_p->status_flags |= mMsg_STATUS_FLAG_USE_AM; - } - else { - msg_p->status_flags &= ~mMsg_STATUS_FLAG_USE_AM; - } + if (hour < 12) { + msg_p->status_flags |= mMsg_STATUS_FLAG_USE_AM; + } else { + msg_p->status_flags &= ~mMsg_STATUS_FLAG_USE_AM; + } - return mMsg_CopyHour(data, idx, max_size); + return mMsg_CopyHour(data, idx, max_size); } static int mChoice_Put_String_MIN(u8* data, int idx, int max_size, ACTOR* actor) { - return mMsg_CopyMin(data, idx, max_size); + return mMsg_CopyMin(data, idx, max_size); } static int mChoice_Put_String_SEC(u8* data, int idx, int max_size, ACTOR* actor) { - return mMsg_CopySec(data, idx, max_size); + return mMsg_CopySec(data, idx, max_size); } static int mChoice_Put_String_FREE(u8* data, int idx, int max_size, ACTOR* actor, int free_idx) { - return mMsg_CopyFree(mMsg_Get_base_window_p(), free_idx, data, idx, max_size, mIN_ARTICLE_NUM, FALSE); + return mMsg_CopyFree(mMsg_Get_base_window_p(), free_idx, data, idx, max_size, mIN_ARTICLE_NUM, FALSE); } static int mChoice_Put_String_FREE0(u8* data, int idx, int max_size, ACTOR* actor) { - return mChoice_Put_String_FREE(data, idx, max_size, actor, mMsg_FREE_STR0); + return mChoice_Put_String_FREE(data, idx, max_size, actor, mMsg_FREE_STR0); } static int mChoice_Put_String_FREE1(u8* data, int idx, int max_size, ACTOR* actor) { - return mChoice_Put_String_FREE(data, idx, max_size, actor, mMsg_FREE_STR1); + return mChoice_Put_String_FREE(data, idx, max_size, actor, mMsg_FREE_STR1); } static int mChoice_Put_String_FREE2(u8* data, int idx, int max_size, ACTOR* actor) { - return mChoice_Put_String_FREE(data, idx, max_size, actor, mMsg_FREE_STR2); + return mChoice_Put_String_FREE(data, idx, max_size, actor, mMsg_FREE_STR2); } static int mChoice_Put_String_FREE3(u8* data, int idx, int max_size, ACTOR* actor) { - return mChoice_Put_String_FREE(data, idx, max_size, actor, mMsg_FREE_STR3); + return mChoice_Put_String_FREE(data, idx, max_size, actor, mMsg_FREE_STR3); } static int mChoice_Put_String_FREE4(u8* data, int idx, int max_size, ACTOR* actor) { - return mChoice_Put_String_FREE(data, idx, max_size, actor, mMsg_FREE_STR4); + return mChoice_Put_String_FREE(data, idx, max_size, actor, mMsg_FREE_STR4); } static int mChoice_Put_String_FREE5(u8* data, int idx, int max_size, ACTOR* actor) { - return mChoice_Put_String_FREE(data, idx, max_size, actor, mMsg_FREE_STR5); + return mChoice_Put_String_FREE(data, idx, max_size, actor, mMsg_FREE_STR5); } static int mChoice_Put_String_FREE6(u8* data, int idx, int max_size, ACTOR* actor) { - return mChoice_Put_String_FREE(data, idx, max_size, actor, mMsg_FREE_STR6); + return mChoice_Put_String_FREE(data, idx, max_size, actor, mMsg_FREE_STR6); } static int mChoice_Put_String_FREE7(u8* data, int idx, int max_size, ACTOR* actor) { - return mChoice_Put_String_FREE(data, idx, max_size, actor, mMsg_FREE_STR7); + return mChoice_Put_String_FREE(data, idx, max_size, actor, mMsg_FREE_STR7); } static int mChoice_Put_String_FREE8(u8* data, int idx, int max_size, ACTOR* actor) { - return mChoice_Put_String_FREE(data, idx, max_size, actor, mMsg_FREE_STR8); + return mChoice_Put_String_FREE(data, idx, max_size, actor, mMsg_FREE_STR8); } static int mChoice_Put_String_FREE9(u8* data, int idx, int max_size, ACTOR* actor) { - return mChoice_Put_String_FREE(data, idx, max_size, actor, mMsg_FREE_STR9); + return mChoice_Put_String_FREE(data, idx, max_size, actor, mMsg_FREE_STR9); } static int mChoice_Put_String_FREE10(u8* data, int idx, int max_size, ACTOR* actor) { - return mChoice_Put_String_FREE(data, idx, max_size, actor, mMsg_FREE_STR10); + return mChoice_Put_String_FREE(data, idx, max_size, actor, mMsg_FREE_STR10); } static int mChoice_Put_String_FREE11(u8* data, int idx, int max_size, ACTOR* actor) { - return mChoice_Put_String_FREE(data, idx, max_size, actor, mMsg_FREE_STR11); + return mChoice_Put_String_FREE(data, idx, max_size, actor, mMsg_FREE_STR11); } static int mChoice_Put_String_FREE12(u8* data, int idx, int max_size, ACTOR* actor) { - return mChoice_Put_String_FREE(data, idx, max_size, actor, mMsg_FREE_STR12); + return mChoice_Put_String_FREE(data, idx, max_size, actor, mMsg_FREE_STR12); } static int mChoice_Put_String_FREE13(u8* data, int idx, int max_size, ACTOR* actor) { - return mChoice_Put_String_FREE(data, idx, max_size, actor, mMsg_FREE_STR13); + return mChoice_Put_String_FREE(data, idx, max_size, actor, mMsg_FREE_STR13); } static int mChoice_Put_String_FREE14(u8* data, int idx, int max_size, ACTOR* actor) { - return mChoice_Put_String_FREE(data, idx, max_size, actor, mMsg_FREE_STR14); + return mChoice_Put_String_FREE(data, idx, max_size, actor, mMsg_FREE_STR14); } static int mChoice_Put_String_FREE15(u8* data, int idx, int max_size, ACTOR* actor) { - return mChoice_Put_String_FREE(data, idx, max_size, actor, mMsg_FREE_STR15); + return mChoice_Put_String_FREE(data, idx, max_size, actor, mMsg_FREE_STR15); } static int mChoice_Put_String_FREE16(u8* data, int idx, int max_size, ACTOR* actor) { - return mChoice_Put_String_FREE(data, idx, max_size, actor, mMsg_FREE_STR16); + return mChoice_Put_String_FREE(data, idx, max_size, actor, mMsg_FREE_STR16); } static int mChoice_Put_String_FREE17(u8* data, int idx, int max_size, ACTOR* actor) { - return mChoice_Put_String_FREE(data, idx, max_size, actor, mMsg_FREE_STR17); + return mChoice_Put_String_FREE(data, idx, max_size, actor, mMsg_FREE_STR17); } static int mChoice_Put_String_FREE18(u8* data, int idx, int max_size, ACTOR* actor) { - return mChoice_Put_String_FREE(data, idx, max_size, actor, mMsg_FREE_STR18); + return mChoice_Put_String_FREE(data, idx, max_size, actor, mMsg_FREE_STR18); } static int mChoice_Put_String_FREE19(u8* data, int idx, int max_size, ACTOR* actor) { - return mChoice_Put_String_FREE(data, idx, max_size, actor, mMsg_FREE_STR19); + return mChoice_Put_String_FREE(data, idx, max_size, actor, mMsg_FREE_STR19); } static int mChoice_Put_String_DETERMINATION(u8* data, int idx, int max_size, ACTOR* actor) { - return mMsg_CopyDetermination(mMsg_Get_base_window_p(), data, idx, max_size); + return mMsg_CopyDetermination(mMsg_Get_base_window_p(), data, idx, max_size); } static int mChoice_Put_String_COUNTRY_NAME(u8* data, int idx, int max_size, ACTOR* actor) { - return mMsg_CopyCountryName(data, idx, max_size, FALSE); + return mMsg_CopyCountryName(data, idx, max_size, FALSE); } static int mChoice_Put_String_RAMDOM_NUMBER2(u8* data, int idx, int max_size, ACTOR* actor) { - return mMsg_CopyRamdomNumber2(data, idx, max_size); + return mMsg_CopyRamdomNumber2(data, idx, max_size); } static int mChoice_Put_String_ITEM(u8* data, int idx, int max_size, ACTOR* actor, int item_idx) { - return mMsg_CopyItem(mMsg_Get_base_window_p(), item_idx, data, idx, max_size, mIN_ARTICLE_NUM, FALSE); + return mMsg_CopyItem(mMsg_Get_base_window_p(), item_idx, data, idx, max_size, mIN_ARTICLE_NUM, FALSE); } static int mChoice_Put_String_ITEM0(u8* data, int idx, int max_size, ACTOR* actor) { - return mChoice_Put_String_ITEM(data, idx, max_size, actor, mMsg_ITEM_STR0); + return mChoice_Put_String_ITEM(data, idx, max_size, actor, mMsg_ITEM_STR0); } static int mChoice_Put_String_ITEM1(u8* data, int idx, int max_size, ACTOR* actor) { - return mChoice_Put_String_ITEM(data, idx, max_size, actor, mMsg_ITEM_STR1); + return mChoice_Put_String_ITEM(data, idx, max_size, actor, mMsg_ITEM_STR1); } static int mChoice_Put_String_ITEM2(u8* data, int idx, int max_size, ACTOR* actor) { - return mChoice_Put_String_ITEM(data, idx, max_size, actor, mMsg_ITEM_STR2); + return mChoice_Put_String_ITEM(data, idx, max_size, actor, mMsg_ITEM_STR2); } static int mChoice_Put_String_ITEM3(u8* data, int idx, int max_size, ACTOR* actor) { - return mChoice_Put_String_ITEM(data, idx, max_size, actor, mMsg_ITEM_STR3); + return mChoice_Put_String_ITEM(data, idx, max_size, actor, mMsg_ITEM_STR3); } static int mChoice_Put_String_ITEM4(u8* data, int idx, int max_size, ACTOR* actor) { - return mChoice_Put_String_ITEM(data, idx, max_size, actor, mMsg_ITEM_STR4); + return mChoice_Put_String_ITEM(data, idx, max_size, actor, mMsg_ITEM_STR4); } static int mChoice_Put_String_ISLAND_NAME(u8* data, int idx, int max_size, ACTOR* actor) { - return mMsg_CopyIslandName(data, idx, max_size, FALSE); + return mMsg_CopyIslandName(data, idx, max_size, FALSE); } static int mChoice_Put_String_AMPM(u8* data, int idx, int max_size, ACTOR* actor) { - return mMsg_CopyAmPm(mMsg_Get_base_window_p(), data, idx, max_size); + return mMsg_CopyAmPm(mMsg_Get_base_window_p(), data, idx, max_size); } typedef int (*mChoice_PUT_STRING_PROC)(u8*, int, int, ACTOR*); static int mChoice_Put_String(u8* data, int idx, int max_size, ACTOR* actor) { - static const mChoice_PUT_STRING_PROC proc[mFont_CONT_CODE_NUM] = { - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - &mChoice_Put_String_PLAYER_NAME, - &mChoice_Put_String_TALK_NAME, - &mChoice_Put_String_TAIL, - &mChoice_Put_String_YEAR, - &mChoice_Put_String_MONTH, - &mChoice_Put_String_WEEK, - &mChoice_Put_String_DAY, - &mChoice_Put_String_HOUR, - &mChoice_Put_String_MIN, - &mChoice_Put_String_SEC, - &mChoice_Put_String_FREE0, - &mChoice_Put_String_FREE1, - &mChoice_Put_String_FREE2, - &mChoice_Put_String_FREE3, - &mChoice_Put_String_FREE4, - &mChoice_Put_String_FREE5, - &mChoice_Put_String_FREE6, - &mChoice_Put_String_FREE7, - &mChoice_Put_String_FREE8, - &mChoice_Put_String_FREE9, - &mChoice_Put_String_DETERMINATION, - &mChoice_Put_String_COUNTRY_NAME, - &mChoice_Put_String_RAMDOM_NUMBER2, - &mChoice_Put_String_ITEM0, - &mChoice_Put_String_ITEM1, - &mChoice_Put_String_ITEM2, - &mChoice_Put_String_ITEM3, - &mChoice_Put_String_ITEM4, - &mChoice_Put_String_FREE10, - &mChoice_Put_String_FREE11, - &mChoice_Put_String_FREE12, - &mChoice_Put_String_FREE13, - &mChoice_Put_String_FREE14, - &mChoice_Put_String_FREE15, - &mChoice_Put_String_FREE16, - &mChoice_Put_String_FREE17, - &mChoice_Put_String_FREE18, - &mChoice_Put_String_FREE19, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - &mChoice_Put_String_ISLAND_NAME, - NULL, - NULL, - NULL, - NULL, - &mChoice_Put_String_AMPM, - NULL, - NULL, - NULL, - NULL - }; + static const mChoice_PUT_STRING_PROC proc[mFont_CONT_CODE_NUM] = { + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + &mChoice_Put_String_PLAYER_NAME, + &mChoice_Put_String_TALK_NAME, + &mChoice_Put_String_TAIL, + &mChoice_Put_String_YEAR, + &mChoice_Put_String_MONTH, + &mChoice_Put_String_WEEK, + &mChoice_Put_String_DAY, + &mChoice_Put_String_HOUR, + &mChoice_Put_String_MIN, + &mChoice_Put_String_SEC, + &mChoice_Put_String_FREE0, + &mChoice_Put_String_FREE1, + &mChoice_Put_String_FREE2, + &mChoice_Put_String_FREE3, + &mChoice_Put_String_FREE4, + &mChoice_Put_String_FREE5, + &mChoice_Put_String_FREE6, + &mChoice_Put_String_FREE7, + &mChoice_Put_String_FREE8, + &mChoice_Put_String_FREE9, + &mChoice_Put_String_DETERMINATION, + &mChoice_Put_String_COUNTRY_NAME, + &mChoice_Put_String_RAMDOM_NUMBER2, + &mChoice_Put_String_ITEM0, + &mChoice_Put_String_ITEM1, + &mChoice_Put_String_ITEM2, + &mChoice_Put_String_ITEM3, + &mChoice_Put_String_ITEM4, + &mChoice_Put_String_FREE10, + &mChoice_Put_String_FREE11, + &mChoice_Put_String_FREE12, + &mChoice_Put_String_FREE13, + &mChoice_Put_String_FREE14, + &mChoice_Put_String_FREE15, + &mChoice_Put_String_FREE16, + &mChoice_Put_String_FREE17, + &mChoice_Put_String_FREE18, + &mChoice_Put_String_FREE19, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + &mChoice_Put_String_ISLAND_NAME, + NULL, + NULL, + NULL, + NULL, + &mChoice_Put_String_AMPM, + NULL, + NULL, + NULL, + NULL, + }; - int type = data[idx + 1]; + int type = data[idx + 1]; - if (type >= 0 && type < mFont_CONT_CODE_NUM && proc[type] != NULL) { - return (*proc[type])(data, idx, max_size, actor); - } + if (type >= 0 && type < mFont_CONT_CODE_NUM && proc[type] != NULL) { + return (*proc[type])(data, idx, max_size, actor); + } - return max_size; + return max_size; } static void mChoice_Change_ControlCode(u8* data, int max_size, ACTOR* actor) { - u8* src_p = data; - int new_max_size = max_size; - int idx = 0; - u8 code; + u8* src_p = data; + int new_max_size = max_size; + int idx = 0; + u8 code; - while (idx < new_max_size) { - code = *src_p; + while (idx < new_max_size) { + code = *src_p; - if (code == CHAR_CONTROL_CODE) { - new_max_size = mChoice_Put_String(data, idx, new_max_size, actor); + if (code == CHAR_CONTROL_CODE) { + new_max_size = mChoice_Put_String(data, idx, new_max_size, actor); + } else { + idx++; + src_p++; + } } - else { - idx++; - src_p++; - } - } } extern void mChoice_Load_ChoseStringFromRom(mChoice_c* choice, u8* str, int str_no, ACTOR* actor) { - if (str_no >= 0 && str_no < mChoice_SELECT_STR_NUM) { - u32 addr; - u32 size; + if (str_no >= 0 && str_no < mChoice_SELECT_STR_NUM) { + u32 addr; + u32 size; - mChoice_Get_StringDataAddressAndSize(str_no, &addr, &size); + mChoice_Get_StringDataAddressAndSize(str_no, &addr, &size); - if (size == 0) { - mem_clear(str, mChoice_CHOICE_STRING_LEN, CHAR_SPACE); + if (size == 0) { + mem_clear(str, mChoice_CHOICE_STRING_LEN, CHAR_SPACE); + } else if (addr != 0) { + static u8 buff[80] ATTRIBUTE_ALIGN(32); + u32 align_addr = ALIGN_PREV(addr, 32); + u32 ofs = addr - align_addr; + u32 align_size = ALIGN_NEXT(ofs + size, 32); + int max; + int i; + u8* dst_p; + u8* src_p; + + _JW_GetResourceAram(align_addr, buff, align_size); + + max = mChoice_CHOICE_STRING_LEN; + if (size < mChoice_CHOICE_STRING_LEN) { + max = size; + } + + src_p = &buff[ofs]; + dst_p = str; + + /* Copy string from the temp aligned buffer to the destination */ + for (i = 0; i < max; i++) { + *dst_p++ = *src_p++; + } + + /* Fill remaining space with space characters */ + for (i; i < mChoice_CHOICE_STRING_LEN; i++) { + *dst_p++ = CHAR_SPACE; + } + + /* Process any control codes */ + mChoice_Change_ControlCode(str, mChoice_CHOICE_STRING_LEN, actor); + } } - else if (addr != 0) { - static u8 buff[80] ATTRIBUTE_ALIGN(32); - u32 align_addr = ALIGN_PREV(addr, 32); - u32 ofs = addr - align_addr; - u32 align_size = ALIGN_NEXT(ofs + size, 32); - int max; - int i; - u8* src_p; - u8* dst_p; - - _JW_GetResourceAram(align_addr, buff, align_size); - - max = mChoice_CHOICE_STRING_LEN; - if (size < mChoice_CHOICE_STRING_LEN) { - max = size; - } - - src_p = &buff[ofs]; - dst_p = str; - - /* Copy string from the temp aligned buffer to the destination */ - for (i = 0; i < max; i++) { - *dst_p++ = *src_p++; - } - - /* Fill remaining space with space characters */ - for (i; i < mChoice_CHOICE_STRING_LEN; i++) { - *dst_p++ = CHAR_SPACE; - } - - /* Process any control codes */ - mChoice_Change_ControlCode(str, mChoice_CHOICE_STRING_LEN, actor); - } - } } extern void mChoice_no_b_set(mChoice_c* choice) { - choice->no_b_flag = TRUE; + choice->no_b_flag = TRUE; } extern void mChoice_no_b_close_set(mChoice_c* choice) { - choice->no_b_flag = TRUE; - choice->no_close_flag = TRUE; + choice->no_b_flag = TRUE; + choice->no_close_flag = TRUE; } diff --git a/src/game/m_choice_main_hide.c_inc b/src/game/m_choice_main_hide.c_inc index 94a1a79d..85fb2cb0 100644 --- a/src/game/m_choice_main_hide.c_inc +++ b/src/game/m_choice_main_hide.c_inc @@ -1,7 +1,7 @@ static void mChoice_Main_Hide(mChoice_c* choice, GAME* game) { - mChoice_MainSetup(choice, game); + mChoice_MainSetup(choice, game); } static void mChoice_MainSetup_Hide(mChoice_c* choice, GAME* game) { - mChoice_init(choice, game); + mChoice_init(choice, game); } diff --git a/src/game/m_choice_main_normal.c_inc b/src/game/m_choice_main_normal.c_inc index 4f2850dd..5a412873 100644 --- a/src/game/m_choice_main_normal.c_inc +++ b/src/game/m_choice_main_normal.c_inc @@ -1,162 +1,148 @@ static void mChoice_determimation_set(mChoice_c* choice) { - mChoice_Data_c* choice_data = &choice->data; - int idx = choice->selected_choice_idx; + mChoice_Data_c* choice_data = &choice->data; + int idx = choice->selected_choice_idx; - bcopy(choice_data->strings[idx], choice_data->determination_string, mChoice_CHOICE_STRING_LEN); - choice_data->determination_len = choice_data->string_lens[idx]; - choice_data->selected_choice_idx = idx; + bcopy(choice_data->strings[idx], choice_data->determination_string, mChoice_CHOICE_STRING_LEN); + choice_data->determination_len = choice_data->string_lens[idx]; + choice_data->selected_choice_idx = idx; } static int mChoice_Main_Normal_SetChoice(mChoice_c* choice, GAME* game) { - int res = FALSE; + int res = FALSE; - if (chkTrigger(BUTTON_A)) { - mChoice_determimation_set(choice); - res = TRUE; - } - else if (choice->no_b_flag && chkTrigger(BUTTON_B)) { - choice->selected_choice_idx = choice->data.choice_num - 1; - mChoice_determimation_set(choice); - res = TRUE; - } - else { - f32 percent = gamePT->mcon.adjusted_pY; - int* choice_automove_p = &choice->choice_automove_type; - f32* choice_automove_timer_p = &choice->choice_automove_timer; - int* selected_idx_p = &choice->selected_choice_idx; - int cursor_sfx = FALSE; + if (chkTrigger(BUTTON_A)) { + mChoice_determimation_set(choice); + res = TRUE; + } else if (choice->no_b_flag && chkTrigger(BUTTON_B)) { + choice->selected_choice_idx = choice->data.choice_num - 1; + mChoice_determimation_set(choice); + res = TRUE; + } else { + f32 percent = gamePT->mcon.adjusted_pY; + int* choice_automove_p = &choice->choice_automove_type; + f32* choice_automove_timer_p = &choice->choice_automove_timer; + int* selected_idx_p = &choice->selected_choice_idx; + int cursor_sfx = FALSE; - switch (*choice_automove_p) { - case mChoice_AUTOMOVE_INCREMENT_WAIT: - { - if (percent < 0.0f || chkButton(BUTTON_CDOWN)) { - (*choice_automove_timer_p) += 1.0f; + switch (*choice_automove_p) { + case mChoice_AUTOMOVE_INCREMENT_WAIT: { + if (percent < 0.0f || chkButton(BUTTON_CDOWN)) { + (*choice_automove_timer_p) += 1.0f; - if (*choice_automove_timer_p >= 18.0f) { - *choice_automove_timer_p = 0.0f; - *choice_automove_p = mChoice_AUTOMOVE_INCREMENT; - (*selected_idx_p)++; - cursor_sfx = TRUE; - } - } - else { - *choice_automove_p = mChoice_AUTOMOVE_STOPPED; - *choice_automove_timer_p = 0.0f; + if (*choice_automove_timer_p >= 18.0f) { + *choice_automove_timer_p = 0.0f; + *choice_automove_p = mChoice_AUTOMOVE_INCREMENT; + (*selected_idx_p)++; + cursor_sfx = TRUE; + } + } else { + *choice_automove_p = mChoice_AUTOMOVE_STOPPED; + *choice_automove_timer_p = 0.0f; + } + + break; + } + + case mChoice_AUTOMOVE_INCREMENT: { + if (percent < 0.0f || chkButton(BUTTON_CDOWN)) { + (*choice_automove_timer_p) += 1.0f; + + if (*choice_automove_timer_p >= 9.0f) { + *choice_automove_timer_p = 0.0f; + (*selected_idx_p)++; + cursor_sfx = TRUE; + } + } else { + *choice_automove_p = mChoice_AUTOMOVE_STOPPED; + *choice_automove_timer_p = 0.0f; + } + + break; + } + + case mChoice_AUTOMOVE_DECREMENT_WAIT: { + if (percent > 0.0f || chkButton(BUTTON_CUP)) { + (*choice_automove_timer_p) += 1.0f; + + if (*choice_automove_timer_p >= 18.0f) { + *choice_automove_timer_p = 0.0f; + *choice_automove_p = mChoice_AUTOMOVE_DECREMENT; + (*selected_idx_p)--; + cursor_sfx = TRUE; + } + } else { + *choice_automove_p = mChoice_AUTOMOVE_STOPPED; + *choice_automove_timer_p = 0.0f; + } + + break; + } + + case mChoice_AUTOMOVE_DECREMENT: { + if (percent > 0.0f || chkButton(BUTTON_CUP)) { + (*choice_automove_timer_p) += 1.0f; + + if (*choice_automove_timer_p >= 9.0f) { + *choice_automove_timer_p = 0.0f; + (*selected_idx_p)--; + cursor_sfx = TRUE; + } + } else { + *choice_automove_p = mChoice_AUTOMOVE_STOPPED; + *choice_automove_timer_p = 0.0f; + } + + break; + } + + default: { + if (percent > 0.0f || chkTrigger(BUTTON_CUP)) { + *choice_automove_p = mChoice_AUTOMOVE_DECREMENT_WAIT; + *choice_automove_timer_p = 0.0f; + (*selected_idx_p)--; + cursor_sfx = TRUE; + } else if (percent < 0.0f || chkTrigger(BUTTON_CDOWN)) { + *choice_automove_p = mChoice_AUTOMOVE_INCREMENT_WAIT; + *choice_automove_timer_p = 0.0f; + (*selected_idx_p)++; + cursor_sfx = TRUE; + } + + break; + } } - break; - } - - case mChoice_AUTOMOVE_INCREMENT: - { - if (percent < 0.0f || chkButton(BUTTON_CDOWN)) { - (*choice_automove_timer_p) += 1.0f; - - if (*choice_automove_timer_p >= 9.0f) { - *choice_automove_timer_p = 0.0f; - (*selected_idx_p)++; - cursor_sfx = TRUE; - } + if ((*selected_idx_p) < 0) { + *selected_idx_p = 0; + } else if ((*selected_idx_p) >= choice->data.choice_num) { + *selected_idx_p = choice->data.choice_num - 1; + } else { + if (cursor_sfx) { + mChoice_sound_CURSOL(); + } } - else { - *choice_automove_p = mChoice_AUTOMOVE_STOPPED; - *choice_automove_timer_p = 0.0f; - } - - break; - } - - case mChoice_AUTOMOVE_DECREMENT_WAIT: - { - if (percent > 0.0f || chkButton(BUTTON_CUP)) { - (*choice_automove_timer_p) += 1.0f; - - if (*choice_automove_timer_p >= 18.0f) { - *choice_automove_timer_p = 0.0f; - *choice_automove_p = mChoice_AUTOMOVE_DECREMENT; - (*selected_idx_p)--; - cursor_sfx = TRUE; - } - } - else { - *choice_automove_p = mChoice_AUTOMOVE_STOPPED; - *choice_automove_timer_p = 0.0f; - } - - break; - } - - case mChoice_AUTOMOVE_DECREMENT: - { - if (percent > 0.0f || chkButton(BUTTON_CUP)) { - (*choice_automove_timer_p) += 1.0f; - - if (*choice_automove_timer_p >= 9.0f) { - *choice_automove_timer_p = 0.0f; - (*selected_idx_p)--; - cursor_sfx = TRUE; - } - } - else { - *choice_automove_p = mChoice_AUTOMOVE_STOPPED; - *choice_automove_timer_p = 0.0f; - } - - break; - } - - default: - { - if (percent > 0.0f || chkTrigger(BUTTON_CUP)) { - *choice_automove_p = mChoice_AUTOMOVE_DECREMENT_WAIT; - *choice_automove_timer_p = 0.0f; - (*selected_idx_p)--; - cursor_sfx = TRUE; - } - else if (percent < 0.0f || chkTrigger(BUTTON_CDOWN)) { - *choice_automove_p = mChoice_AUTOMOVE_INCREMENT_WAIT; - *choice_automove_timer_p = 0.0f; - (*selected_idx_p)++; - cursor_sfx = TRUE; - } - - break; - } } - if ((*selected_idx_p) < 0) { - *selected_idx_p = 0; - } - else if ((*selected_idx_p) >= choice->data.choice_num) { - *selected_idx_p = choice->data.choice_num - 1; - } - else { - if (cursor_sfx) { - mChoice_sound_CURSOL(); - } - } - } - - return res; + return res; } static void mChoice_request_main_index_fromNormal(mChoice_c* choice, GAME* game, int close_flag) { - if (close_flag) { - mChoice_Change_request_main_index(choice, mChoice_MAIN_DISAPPEAR); - } + if (close_flag) { + mChoice_Change_request_main_index(choice, mChoice_MAIN_DISAPPEAR); + } } static void mChoice_Main_Normal(mChoice_c* choice, GAME* game) { - int close_flag = mChoice_Main_Normal_SetChoice(choice, game); + int close_flag = mChoice_Main_Normal_SetChoice(choice, game); - mChoice_request_main_index_fromNormal(choice, game, close_flag); - mChoice_MainSetup(choice, game); + mChoice_request_main_index_fromNormal(choice, game, close_flag); + mChoice_MainSetup(choice, game); } static void mChoice_MainSetup_Normal(mChoice_c* choice, GAME* game) { - choice->scale = 1.0f; - choice->timer = 0.0f; - choice->requested_main_index = -1; - choice->main_index = mChoice_MAIN_NORMAL; - choice->font_visible_flag = TRUE; + choice->scale = 1.0f; + choice->timer = 0.0f; + choice->requested_main_index = -1; + choice->main_index = mChoice_MAIN_NORMAL; + choice->font_visible_flag = TRUE; } diff --git a/src/game/m_choice_sound.c_inc b/src/game/m_choice_sound.c_inc index ccf76ea8..9baf1791 100644 --- a/src/game/m_choice_sound.c_inc +++ b/src/game/m_choice_sound.c_inc @@ -1,19 +1,19 @@ static void mChoice_sound_SENTAKU_KETTEI() { - sAdo_SysTrgStart(NA_SE_SENTAKU_KETTEI); + sAdo_SysTrgStart(NA_SE_SENTAKU_KETTEI); } static void mChoice_sound_SENTAKU_OPEN() { - sAdo_SysTrgStart(NA_SE_SENTAKU_OPEN); + sAdo_SysTrgStart(NA_SE_SENTAKU_OPEN); } static void mChoice_sound_CURSOL() { - sAdo_SysTrgStart(NA_SE_CURSOL); + sAdo_SysTrgStart(NA_SE_CURSOL); } static void mChoice_sound_ZOOMDOWN_SHORT() { - sAdo_SysTrgStart(SE_SINGLETON(NA_SE_ZOOMDOWN_SHORT)); + sAdo_SysTrgStart(SE_SINGLETON(NA_SE_ZOOMDOWN_SHORT)); } static void mChoice_sound_ZOOMDOWN_LONG() { - sAdo_SysTrgStart(SE_SINGLETON(NA_SE_ZOOMDOWN_LONG)); + sAdo_SysTrgStart(SE_SINGLETON(NA_SE_ZOOMDOWN_LONG)); } diff --git a/src/game/m_cockroach.c b/src/game/m_cockroach.c index cb0a6055..f970b267 100644 --- a/src/game/m_cockroach.c +++ b/src/game/m_cockroach.c @@ -9,16 +9,16 @@ /** * @brief Clamps the input cockroach count between [0, mCkRh_MAX_NUM]. - * + * * @param count The new cockroach count * @return The clamped cockroach count **/ static int mCkRh_GokiFamilyCount2Good(int count) { - if (count < 0) { - return 0; - } + if (count < 0) { + return 0; + } - return (count <= mCkRh_MAX_NUM ? count : mCkRh_MAX_NUM); + return (count <= mCkRh_MAX_NUM ? count : mCkRh_MAX_NUM); } /** @@ -26,285 +26,306 @@ static int mCkRh_GokiFamilyCount2Good(int count) { * when a new Player is created. **/ extern void mCkRh_InitGokiSaveData_InitNewPlayer() { - int i; + int i; - for (i = 0; i < PLAYER_NUM; i++) { - if (mHS_get_pl_no_detail(i) == -1) { - mCkRh_InitGokiSaveData_1Room(i); + for (i = 0; i < PLAYER_NUM; i++) { + if (mHS_get_pl_no_detail(i) == -1) { + mCkRh_InitGokiSaveData_1Room(i); + } } - } } /** * @brief Initializes a single house's cockroach data by house index. - * + * * @param home_no The house index whose cockroach data will be initialized **/ extern void mCkRh_InitGokiSaveData_1Room(int home_no) { - mCkRh_InitGokiSaveData_1Room_ByHomeData(Save_GetPointer(homes[home_no])); + mCkRh_InitGokiSaveData_1Room_ByHomeData(Save_GetPointer(homes[home_no])); } /** * @brief Initializes a single house's cockroach data. - * + * * @param home The mHm_hs_c house whose cockroach data wil be initialized. **/ extern void mCkRh_InitGokiSaveData_1Room_ByHomeData(mHm_hs_c* home) { - home->goki.num = 0; - home->goki.pad = 0; + home->goki.num = 0; + home->goki.pad = 0; - home->goki.time = Common_Get(time.rtc_time); + home->goki.time = Common_Get(time.rtc_time); } +// Aus changed init time to all 0 +#if VERSION >= VER_GAFU01_00 /** * @brief Initializes island cottage cockroach data. **/ extern void mCkRh_InitGokiSaveData_IslandPlayerRoom() { - const lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); - - Save_Set(island.cottage.goki.num, 0); - Save_Set(island.cottage.goki.pad, 0); - Save_Set(island.cottage.goki.time.year, rtc_time->year); - Save_Set(island.cottage.goki.time.month, rtc_time->month); - Save_Set(island.cottage.goki.time.day, rtc_time->day); + Save_Set(island.cottage.goki.num, 0); + Save_Set(island.cottage.goki.pad, 0); + Save_Set(island.cottage.goki.time.year, 0); + Save_Set(island.cottage.goki.time.month, 0); + Save_Set(island.cottage.goki.time.day, 0); } +#else +/** + * @brief Initializes island cottage cockroach data. + **/ +extern void mCkRh_InitGokiSaveData_IslandPlayerRoom() { + const lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); + + Save_Set(island.cottage.goki.num, 0); + Save_Set(island.cottage.goki.pad, 0); + Save_Set(island.cottage.goki.time.year, rtc_time->year); + Save_Set(island.cottage.goki.time.month, rtc_time->month); + Save_Set(island.cottage.goki.time.day, rtc_time->day); +} +#endif /** * @brief Initializes all houses' cockroach data even if a player owns it. **/ extern void mCkRh_InitGokiSaveData_AllRoom() { - int i; + int i; - for (i = 0; i < PLAYER_NUM; i++) { - mCkRh_InitGokiSaveData_1Room(i); - } + for (i = 0; i < PLAYER_NUM; i++) { + mCkRh_InitGokiSaveData_1Room(i); + } } /** * @brief Updates the cockroach 'last entered' time for the island cottage. - * + * * @param scene_id The current scene id **/ extern void mCkRh_SetGoingOutCottageTime(int scene_id) { - if (scene_id == SCENE_COTTAGE_MY) { - Save_Set(island.cottage.goki.time.year, Common_Get(time.rtc_time.year)); - Save_Set(island.cottage.goki.time.month, Common_Get(time.rtc_time.month)); - Save_Set(island.cottage.goki.time.day, Common_Get(time.rtc_time.day)); - } + if (scene_id == SCENE_COTTAGE_MY) { + Save_Set(island.cottage.goki.time.year, Common_Get(time.rtc_time.year)); + Save_Set(island.cottage.goki.time.month, Common_Get(time.rtc_time.month)); + Save_Set(island.cottage.goki.time.day, Common_Get(time.rtc_time.day)); + } } /** * @brief Updates the cockroach 'last entered' time for a player's house. - * + * * @param player_no The index of the player whose cockroach data will be updated **/ extern void mCkRh_SavePlayTime(int player_no) { - if (player_no < PLAYER_NUM) { - int home_no = mHS_get_arrange_idx(player_no); - Save_Set(homes[home_no & 3].goki.time, Common_Get(time.rtc_time)); - } + if (player_no < PLAYER_NUM) { + int home_no = mHS_get_arrange_idx(player_no); + Save_Set(homes[home_no & 3].goki.time, Common_Get(time.rtc_time)); + } } /** * @brief Returns the inverval in days between the current time and * the last time that the player's cockroach 'last enter time'. - * + * * @param player_no The index of the player whose 'days gap' will be calculated * @return When a foriegner, 0, otherwise day interval **/ static int mCkRh_DaysGapCompareWithSaveTime(int player_no) { - int homeid; - lbRTC_time_c goki_time; - int interval; + int homeid; + lbRTC_time_c goki_time; + int interval; - if (player_no < PLAYER_NUM) { - homeid = mHS_get_arrange_idx(player_no) & 3; - goki_time.year = Save_Get(homes[homeid].goki.time.year); - goki_time.month = Save_Get(homes[homeid].goki.time.month); - goki_time.day = Save_Get(homes[homeid].goki.time.day); - goki_time.weekday = lbRTC_Week(goki_time.year, goki_time.month, goki_time.day); - goki_time.hour = 1; - goki_time.min = 1; - goki_time.sec = 1; + if (player_no < PLAYER_NUM) { + homeid = mHS_get_arrange_idx(player_no) & 3; + goki_time.year = Save_Get(homes[homeid].goki.time.year); + goki_time.month = Save_Get(homes[homeid].goki.time.month); + goki_time.day = Save_Get(homes[homeid].goki.time.day); + goki_time.weekday = lbRTC_Week(goki_time.year, goki_time.month, goki_time.day); + goki_time.hour = 1; + goki_time.min = 1; + goki_time.sec = 1; - interval = lbRTC_GetIntervalDays(&goki_time, Common_GetPointer(time.rtc_time)); - } - else { - interval = 0; - } + interval = lbRTC_GetIntervalDays(&goki_time, Common_GetPointer(time.rtc_time)); + } else { + interval = 0; + } - return interval; + return interval; } /** * @brief Gets the day interval between current time and the island cottage * cockroach last enter time. - * + * * @return days between current time and last island cottage enter time **/ static int mCkRh_DaysGapCompareWithCottageSaveTime() { - lbRTC_time_c goki_time; + lbRTC_time_c goki_time; - goki_time.year = Save_Get(island.cottage.goki.time.year); - goki_time.month = Save_Get(island.cottage.goki.time.month); - goki_time.day = Save_Get(island.cottage.goki.time.day); - goki_time.weekday = lbRTC_Week(goki_time.year, goki_time.month, goki_time.day); - goki_time.hour = 1; - goki_time.min = 1; - goki_time.sec = 1; + goki_time.year = Save_Get(island.cottage.goki.time.year); + goki_time.month = Save_Get(island.cottage.goki.time.month); + goki_time.day = Save_Get(island.cottage.goki.time.day); + goki_time.weekday = lbRTC_Week(goki_time.year, goki_time.month, goki_time.day); + goki_time.hour = 1; + goki_time.min = 1; + goki_time.sec = 1; - return lbRTC_GetIntervalDays(&goki_time, Common_GetPointer(time.rtc_time)); + return lbRTC_GetIntervalDays(&goki_time, Common_GetPointer(time.rtc_time)); } /** * @brief Determines and updates the saved cockroach number for a player. - * + * * The minimum day interval between the current time and the cockroach's * 'last entered time' is 7 days. The amount you get scales linearly, * starting with 1 new cockroach on day 7, 2 new on day 8, ... - * + * * The maximum number of cockroaches is clamped to mCkRh_MAX_NUM which stock * is 10 cockroaches. - * + * * @param player_no The inex of the player whose cockroach data will be updated **/ extern void mCkRh_DecideNowGokiFamilyCount(int player_no) { - int count; - int day_gap; - int home_no; - int goki_num; + int count; + int day_gap; + int home_no; + int goki_num; - /* player must live in town */ - if (player_no < PLAYER_NUM) { - day_gap = mCkRh_DaysGapCompareWithSaveTime(player_no); - home_no = mHS_get_arrange_idx(player_no) & 3; - if (day_gap > mCkRh_INTERVAL_DAYS) { - goki_num = Save_Get(homes[home_no].goki.num); - count = goki_num > 0 ? day_gap : day_gap - mCkRh_INTERVAL_DAYS; - Save_Set(homes[home_no].goki.num, mCkRh_GokiFamilyCount2Good(count + goki_num)); + /* player must live in town */ + if (player_no < PLAYER_NUM) { + day_gap = mCkRh_DaysGapCompareWithSaveTime(player_no); + home_no = mHS_get_arrange_idx(player_no) & 3; + if (day_gap > mCkRh_INTERVAL_DAYS) { + goki_num = Save_Get(homes[home_no].goki.num); + count = goki_num > 0 ? day_gap : day_gap - mCkRh_INTERVAL_DAYS; + Save_Set(homes[home_no].goki.num, mCkRh_GokiFamilyCount2Good(count + goki_num)); + } } - } - day_gap = mCkRh_DaysGapCompareWithCottageSaveTime(); - if (day_gap > mCkRh_INTERVAL_DAYS) { - u8* goki_num = Save_GetPointer(island.cottage.goki.num); - count = (int)*goki_num > 0 ? day_gap : day_gap - mCkRh_INTERVAL_DAYS; - *goki_num = mCkRh_GokiFamilyCount2Good(count + (int)*goki_num); - } +// Aus checks the year isn't set to 0 +#if VERSION >= VER_GAFU01_00 + if (Save_Get(island).cottage.goki.time.year != 0) { + day_gap = mCkRh_DaysGapCompareWithCottageSaveTime(); + if (day_gap > mCkRh_INTERVAL_DAYS) { + u8* goki_num = Save_GetPointer(island.cottage.goki.num); + count = (int)*goki_num > 0 ? day_gap : day_gap - mCkRh_INTERVAL_DAYS; + *goki_num = mCkRh_GokiFamilyCount2Good(count + (int)*goki_num); + } + } +#else + day_gap = mCkRh_DaysGapCompareWithCottageSaveTime(); + if (day_gap > mCkRh_INTERVAL_DAYS) { + u8* goki_num = Save_GetPointer(island.cottage.goki.num); + count = (int)*goki_num > 0 ? day_gap : day_gap - mCkRh_INTERVAL_DAYS; + *goki_num = mCkRh_GokiFamilyCount2Good(count + (int)*goki_num); + } +#endif } - /** * @brief Adds a specific amount of cockroaches to the current player's house. - * + * * @param count The number of cockroaches to add (total clamped to mCkRh_MAX_NUM) * @return TRUE/FALSE cockroach data was updated **/ extern int mCkRh_PlussGokiN_NowRoom(int count, int scene_no) { - mActor_name_t fieldid = mFI_GetFieldId(); + mActor_name_t fieldid = mFI_GetFieldId(); - if (mFI_IS_PLAYER_ROOM(fieldid)) { - int player_no = Common_Get(player_no); - int house_field_id = mFI_GET_PLAYER_ROOM_NO(fieldid); - int home_id = mHS_get_arrange_idx(player_no) & 3; - if ((player_no < PLAYER_NUM) && (house_field_id == home_id)) { - Save_Set(homes[home_id].goki.num, mCkRh_GokiFamilyCount2Good(count + Save_Get(homes[home_id].goki.num))); - return TRUE; + if (mFI_IS_PLAYER_ROOM(fieldid)) { + int player_no = Common_Get(player_no); + int house_field_id = mFI_GET_PLAYER_ROOM_NO(fieldid); + int home_id = mHS_get_arrange_idx(player_no) & 3; + if ((player_no < PLAYER_NUM) && (house_field_id == home_id)) { + Save_Set(homes[home_id].goki.num, mCkRh_GokiFamilyCount2Good(count + Save_Get(homes[home_id].goki.num))); + return TRUE; + } + } else if (scene_no == SCENE_COTTAGE_MY) { + u8* goki_num = Save_GetPointer(island.cottage.goki.num); + *goki_num = mCkRh_GokiFamilyCount2Good(count + *goki_num); } - } - else if (scene_no == SCENE_COTTAGE_MY) { - u8* goki_num = Save_GetPointer(island.cottage.goki.num); - *goki_num = mCkRh_GokiFamilyCount2Good(count + *goki_num); - } - return FALSE; + return FALSE; } /** * @brief Removes a specific amount of cockroaches to the current player's house. - * + * * @param count The number of cockroaches to remove (minimum clamped to 0) * @return TRUE/FALSE cockroach data was updated **/ extern int mCkRh_MinusGokiN_NowRoom(int count, int scene_id) { - mActor_name_t field_id = mFI_GetFieldId(); - if (mFI_IS_PLAYER_ROOM(field_id)) { - int player_no = Common_Get(player_no); - int house_field_id = mFI_GET_PLAYER_ROOM_NO(field_id); - int home_no = mHS_get_arrange_idx(player_no) & 3; - if (player_no < PLAYER_NUM && house_field_id == home_no) { - Save_Set(homes[home_no].goki.num, mCkRh_GokiFamilyCount2Good(Save_Get(homes[home_no].goki.num) - count)); - return TRUE; + mActor_name_t field_id = mFI_GetFieldId(); + if (mFI_IS_PLAYER_ROOM(field_id)) { + int player_no = Common_Get(player_no); + int house_field_id = mFI_GET_PLAYER_ROOM_NO(field_id); + int home_no = mHS_get_arrange_idx(player_no) & 3; + if (player_no < PLAYER_NUM && house_field_id == home_no) { + Save_Set(homes[home_no].goki.num, mCkRh_GokiFamilyCount2Good(Save_Get(homes[home_no].goki.num) - count)); + return TRUE; + } + } else if (scene_id == SCENE_COTTAGE_MY) { + u8* goki_num = Save_GetPointer(island.cottage.goki.num); + *goki_num = mCkRh_GokiFamilyCount2Good(*goki_num - count); } - } - else if (scene_id == SCENE_COTTAGE_MY) { - u8* goki_num = Save_GetPointer(island.cottage.goki.num); - *goki_num = mCkRh_GokiFamilyCount2Good(*goki_num - count); - } - - return FALSE; + + return FALSE; } /** * @brief Gets the cockroach count for the current scene id. - * - * @return + * + * @return * - in player house: house cockroach count * - in island octtage: island cottage cockroach count * - elsewhere: 0 **/ extern int mCkRh_NowSceneGokiFamilyCount() { - mActor_name_t fieldid = mFI_GetFieldId(); - if (mFI_IS_PLAYER_ROOM(fieldid)) { - return Save_Get(homes[mFI_GET_PLAYER_ROOM_NO(fieldid)].goki.num); - } - else if (Save_Get(scene_no) == SCENE_COTTAGE_MY) { - return Save_Get(island.cottage.goki.num); - } + mActor_name_t fieldid = mFI_GetFieldId(); + if (mFI_IS_PLAYER_ROOM(fieldid)) { + return Save_Get(homes[mFI_GET_PLAYER_ROOM_NO(fieldid)].goki.num); + } else if (Save_Get(scene_no) == SCENE_COTTAGE_MY) { + return Save_Get(island.cottage.goki.num); + } - return 0; + return 0; } /** * @brief Initializes the 'can_look_goki_count' variable to 0. - * + * * This variable controls how many cockroaches are currently * visible to the player in a room. **/ extern void mCkRh_InitCanLookGokiCount() { - Common_Set(can_look_goki_count, 0); + Common_Set(can_look_goki_count, 0); } /** * @brief Changes the 'can_look_goki_count' variable by 'count'. - * - * 'can_look_goki_count' is clamped between - * + * + * 'can_look_goki_count' is clamped between + * * @param count The number of visible cockroaches to add/remove * @return TRUE/FALSE were number of visible cockroaches updated? **/ extern int mCkRh_CalcCanLookGokiCount(int count) { - count += Common_Get(can_look_goki_count); + count += Common_Get(can_look_goki_count); - if (count < 0) { - Common_Set(can_look_goki_count, 0); - return FALSE; - } + if (count < 0) { + Common_Set(can_look_goki_count, 0); + return FALSE; + } - if (count > mCkRh_CAN_LOOK_GOKI_NUM) { - Common_Set(can_look_goki_count, mCkRh_CAN_LOOK_GOKI_NUM); - return FALSE; - } + if (count > mCkRh_CAN_LOOK_GOKI_NUM) { + Common_Set(can_look_goki_count, mCkRh_CAN_LOOK_GOKI_NUM); + return FALSE; + } - Common_Set(can_look_goki_count, count); - return TRUE; + Common_Set(can_look_goki_count, count); + return TRUE; } /** * @brief Retrieves the 'can_look_gooki_count' value. - * + * * @return number of cockroaches currently visible to the player **/ extern int mCkRh_GetCanLookGokiCount() { - return Common_Get(can_look_goki_count); + return Common_Get(can_look_goki_count); } diff --git a/src/game/m_collision_bg_info.c_inc b/src/game/m_collision_bg_info.c_inc index 8c43eb4b..fa681c1f 100644 --- a/src/game/m_collision_bg_info.c_inc +++ b/src/game/m_collision_bg_info.c_inc @@ -567,7 +567,9 @@ extern int mCoBG_CheckHole(xyz_t pos) { return FALSE; } -extern int mCoBG_CheckSkySwing(xyz_t pos) { +// Renamed in Aus version +#if VERSION >= VER_GAFU01_00 +extern int mCoBG_CheckAirSwing(xyz_t pos) { mCoBG_Collision_u* col = mFI_GetUnitCol(pos); u32 attr = col->data.unit_attribute; @@ -589,6 +591,30 @@ extern int mCoBG_CheckSkySwing(xyz_t pos) { return FALSE; } +#else +extern int mCoBG_CheckAirSwing(xyz_t pos) { + mCoBG_Collision_u* col = mFI_GetUnitCol(pos); + u32 attr = col->data.unit_attribute; + + if (attr >= mCoBG_ATTRIBUTE_WAVE && attr <= mCoBG_ATTRIBUTE_RIVER_NE) { + return TRUE; + } + + if (attr == mCoBG_ATTRIBUTE_SEA || attr == mCoBG_ATTRIBUTE_37 || attr == mCoBG_ATTRIBUTE_38) { + return TRUE; + } + + if (attr >= mCoBG_ATTRIBUTE_39 && attr <= mCoBG_ATTRIBUTE_62) { + if (attr >= mCoBG_ATTRIBUTE_47 && attr <= mCoBG_ATTRIBUTE_54) { + return FALSE; + } else { + return TRUE; + } + } + + return FALSE; +} +#endif extern int mCoBG_CheckGrassX_ClData(mCoBG_Collision_u* col) { u32 attr = col->data.unit_attribute; diff --git a/src/game/m_collision_obj.c b/src/game/m_collision_obj.c index 0164dc7f..6508d8c9 100644 --- a/src/game/m_collision_obj.c +++ b/src/game/m_collision_obj.c @@ -347,8 +347,8 @@ void CollisionCheck_setOC_HitInfo(ClObj_c* col1, ClObjElem_c* colelem1, xyz_t* p f32 weight1; f32 weight2; - f32 minweight; f32 comweight; + f32 minweight; f32 coldis1; f32 coldis2; diff --git a/src/game/m_cpmail_ovl.c b/src/game/m_cpmail_ovl.c index 54ff95f5..8bfd92e5 100644 --- a/src/game/m_cpmail_ovl.c +++ b/src/game/m_cpmail_ovl.c @@ -347,6 +347,7 @@ static void mCM_cpmail_ovl_draw(Submenu* submenu, GAME* game) { } static void mCM_cpmail_draw_init(mSM_MenuInfo_c* menu_info) { +#if VERSION < VER_GAFU01_00 mCM_disp_data_c* disp_data_p = &mCM_disp_data[0]; int i; @@ -356,6 +357,7 @@ static void mCM_cpmail_draw_init(mSM_MenuInfo_c* menu_info) { disp_data_p->tex_p = (u8*)disp_data_p->tex_p; disp_data_p++; } +#endif } extern void mCM_cpmail_ovl_set_proc(Submenu* submenu) { diff --git a/src/game/m_cporiginal_ovl.c b/src/game/m_cporiginal_ovl.c index ca0b7d26..26de2a7c 100644 --- a/src/game/m_cporiginal_ovl.c +++ b/src/game/m_cporiginal_ovl.c @@ -571,15 +571,13 @@ static void mCO_set_frame_main_dl(Submenu* submenu, GAME* game, int folder) { idx = 0; for (k = 0; k < 4; k++) { - for (j = 0; j < 3; j++) { + for (j = 0; j < 3; j++, idx++) { if (mCO_check_mark_flg(submenu, idx)) { Matrix_push(); mNW_draw_sav_mark(game, 32 * j, 44 + -k * 29); Matrix_pull(); } - - idx++; } } diff --git a/src/game/m_debug_hayakawa.c b/src/game/m_debug_hayakawa.c index fa39c6aa..2aba2713 100644 --- a/src/game/m_debug_hayakawa.c +++ b/src/game/m_debug_hayakawa.c @@ -32,51 +32,51 @@ /** * @brief Set or retrieve bits of a Hayakawa register based on the current state. - * + * * This function updates the bits of a Hayakawa register if the current state * matches the given state. If the state matches and the Hayakawa register has * been initialized, the bits are set according to the given register. * Otherwise, the bits are saved to the given register. - * + * * @param n The Hayakawa state to check against the current state. * @param reg The index of the Hayakawa register to set or retrieve bits from. */ static void debug_hayakawa_bitset(const int n, const int reg) { - // Check if the current Hayakawa state matches the given state. - if (GETREG(HREG, HREG_STATE_IDX) == n) { - // If the Hayakawa register has been initialized, set its bits. - if (hreg_init_check(n)) { - int set; - int i; - int setbit = GETREG(HREG, reg); - int bit = 1; + // Check if the current Hayakawa state matches the given state. + if (GETREG(HREG, HREG_STATE_IDX) == n) { + // If the Hayakawa register has been initialized, set its bits. + if (hreg_init_check(n)) { + int set; + int i; + int setbit = GETREG(HREG, reg); + int bit = 1; - // Loop through each bit in the register, setting the corresponding flag. - for (i = 0; i < HREG_STATE_ARGS_COUNT; i++) { - set = (setbit & bit) != 0; - bit <<= 1; + // Loop through each bit in the register, setting the corresponding flag. + for (i = 0; i < HREG_STATE_ARGS_COUNT; i++) { + set = (setbit & bit) != 0; + bit <<= 1; - SETREG(HREG, HREG_STATE_ARGS_START + i, set); - } - } - // If the Hayakawa register hasn't been initialized, save its bits. - else { - int i; - int savebit = 0; - int bit = 1; - - // Loop through each bit in the register, saving the corresponding flag. - for (i = 0; i < HREG_STATE_ARGS_COUNT; i++) { - if (GETREG(HREG, HREG_STATE_ARGS_START + i) != 0) { - savebit |= bit; + SETREG(HREG, HREG_STATE_ARGS_START + i, set); + } } + // If the Hayakawa register hasn't been initialized, save its bits. + else { + int savebit = 0; + int bit = 1; + int i; - bit <<= 1; - } + // Loop through each bit in the register, saving the corresponding flag. + for (i = 0; i < HREG_STATE_ARGS_COUNT; i++) { + if (GETREG(HREG, HREG_STATE_ARGS_START + i) != 0) { + savebit |= bit; + } - SETREG(HREG, reg, savebit); + bit <<= 1; + } + + SETREG(HREG, reg, savebit); + } } - } } /** @@ -89,348 +89,314 @@ static void debug_hayakawa_bitset(const int n, const int reg) { * @param pad Pointer to the pad_t structure, representing the input gamepad. */ extern void debug_hayakawa_move(pad_t* pad) { - debug_hayakawa_bitset(116, 16); - debug_hayakawa_bitset(117, 17); - debug_hayakawa_bitset(139, 39); - debug_hayakawa_bitset(140, 40); - debug_hayakawa_bitset(141, 41); - debug_hayakawa_bitset(142, 42); - debug_hayakawa_bitset(143, 43); - debug_hayakawa_bitset(144, 44); - debug_hayakawa_bitset(145, 45); - debug_hayakawa_bitset(146, 46); - debug_hayakawa_bitset(147, 47); - debug_hayakawa_bitset( 10, 46); + int i; - switch ((int)GETREG(HREG, HREG_STATE_IDX)) { - /** - * Loads/Stores HREG settings into emu64 aflags. - * HREG[81] = saved emu64 aflag load/store start index - * HREG[95] = now emu64 aflag load/store start index - * - * HREG[81] == HREG[95]: Store 12 HREG values (82 - 93) into aflags - * HREG[81] != HREG[95]: Load 12 HREG values (82 - 93) from aflags - */ - case 1: - { - if (hreg_init_check(1)) { - SETREG(HREG, 95, -1); - } + debug_hayakawa_bitset(116, 16); + debug_hayakawa_bitset(117, 17); + debug_hayakawa_bitset(139, 39); + debug_hayakawa_bitset(140, 40); + debug_hayakawa_bitset(141, 41); + debug_hayakawa_bitset(142, 42); + debug_hayakawa_bitset(143, 43); + debug_hayakawa_bitset(144, 44); + debug_hayakawa_bitset(145, 45); + debug_hayakawa_bitset(146, 46); + debug_hayakawa_bitset(147, 47); + debug_hayakawa_bitset(10, 46); - if (GETREG(HREG, HREG_STATE_ARGS_START) != GETREG(HREG, 95)) { - int i; - - SETREG(HREG, 95, GETREG(HREG, HREG_STATE_ARGS_START)); - for (i = 0; i < 12; i++) { - SETREG(HREG, 82 + i, emu64_get_aflags(GETREG(HREG, HREG_STATE_ARGS_START) + i)); + switch ((int)GETREG(HREG, HREG_STATE_IDX)) { + /** + * Loads/Stores HREG settings into emu64 aflags. + * HREG[81] = saved emu64 aflag load/store start index + * HREG[95] = now emu64 aflag load/store start index + * + * HREG[81] == HREG[95]: Store 12 HREG values (82 - 93) into aflags + * HREG[81] != HREG[95]: Load 12 HREG values (82 - 93) from aflags + */ + case 1: { + if (hreg_init_check(1)) { + SETREG(HREG, 95, -1); + } + + if (GETREG(HREG, HREG_STATE_ARGS_START) != GETREG(HREG, 95)) { + SETREG(HREG, 95, GETREG(HREG, HREG_STATE_ARGS_START)); + for (i = 0; i < 12; i++) { + SETREG(HREG, 82 + i, emu64_get_aflags(GETREG(HREG, HREG_STATE_ARGS_START) + i)); + } + } else { + for (i = 0; i < 12; i++) { + emu64_set_aflags(GETREG(HREG, HREG_STATE_ARGS_START) + i, GETREG(HREG, 82 + i)); + } + } } - } - else { - int i; - for (i = 0; i < 12; i++) { - emu64_set_aflags(GETREG(HREG, HREG_STATE_ARGS_START) + i, GETREG(HREG, 82 + i)); + /* Fallthrough 1 -> 2 -> 3 -> 4 -> 6 */ + /** + * Loads the active thread count into HREG. + * HREG[81] = < 0, load threads + * HREG[82] = current active thread count + */ + case 2: { + hreg_init_check(2); + if (GETREG(HREG, HREG_STATE_ARGS_START) < 0) { + SETREG(HREG, HREG_STATE_ARGS_START, 0); + SETREG(HREG, 82, OSCheckActiveThreads()); + } } - } - } - /* Fallthrough 1 -> 2 -> 3 -> 4 -> 6 */ - /** - * Loads the active thread count into HREG. - * HREG[81] = < 0, load threads - * HREG[82] = current active thread count - */ - case 2: - { - hreg_init_check(2); - if (GETREG(HREG, HREG_STATE_ARGS_START) < 0) { - SETREG(HREG, HREG_STATE_ARGS_START, 0); - SETREG(HREG, 82, OSCheckActiveThreads()); - } - } - /* Fallthrough 2 -> 3 -> 4 -> 6 */ - /** - * Dumps the root heap info to console along with free size of the heap. - * HREG[81] = < 0, check should dump - * HREG[82] = 1, print dump - */ - case 3: - { - hreg_init_check(3); - if (GETREG(HREG, HREG_STATE_ARGS_START) < 0) { - SETREG(HREG, HREG_STATE_ARGS_START, 0); + /* Fallthrough 2 -> 3 -> 4 -> 6 */ + /** + * Dumps the root heap info to console along with free size of the heap. + * HREG[81] = < 0, check should dump + * HREG[82] = 1, print dump + */ + case 3: { + hreg_init_check(3); + if (GETREG(HREG, HREG_STATE_ARGS_START) < 0) { + SETREG(HREG, HREG_STATE_ARGS_START, 0); - switch (GETREG(HREG, 82)) { - case 1: - { - OSReport("*** RootHeapDump ***\n"); - JC_JKRHeap_dump(JC_JFWSystem_getRootHeap()); - OSReport("RootHeapFree=%08x\n", JC_JKRHeap_getTotalFreeSize(JC_JFWSystem_getRootHeap())); - } - break; + switch (GETREG(HREG, 82)) { + case 1: { + OSReport("*** RootHeapDump ***\n"); + JC_JKRHeap_dump(JC_JFWSystem_getRootHeap()); + OSReport("RootHeapFree=%08x\n", JC_JKRHeap_getTotalFreeSize(JC_JFWSystem_getRootHeap())); + } break; + } + } } - } - } - /* Fallthrough 3 -> 4 -> 6 */ - //break; + /* Fallthrough 3 -> 4 -> 6 */ + // break; - /** - * Modifies video settings - * HREG[81] = < 0, switch mode - * HREG[82]: - * 1: Disable progressive mode - * 2: Enable progressive mode - * 3: Disable low resolution mode - * 4: Enable low resolution mode - */ - case 4: - { - hreg_init_check(4); - if (GETREG(HREG, HREG_STATE_ARGS_START) < 0) { - SETREG(HREG, HREG_STATE_ARGS_START, 0); - switch (GETREG(HREG, 82)) { - case 1: - JW_SetProgressiveMode(FALSE); - break; - - case 2: - JW_SetProgressiveMode(TRUE); - break; + /** + * Modifies video settings + * HREG[81] = < 0, switch mode + * HREG[82]: + * 1: Disable progressive mode + * 2: Enable progressive mode + * 3: Disable low resolution mode + * 4: Enable low resolution mode + */ + case 4: { + hreg_init_check(4); + if (GETREG(HREG, HREG_STATE_ARGS_START) < 0) { + SETREG(HREG, HREG_STATE_ARGS_START, 0); + switch (GETREG(HREG, 82)) { + case 1: + JW_SetProgressiveMode(FALSE); + break; - case 3: - JW_SetLowResoMode(FALSE); - break; + case 2: + JW_SetProgressiveMode(TRUE); + break; - case 4: - JW_SetLowResoMode(TRUE); - break; + case 3: + JW_SetLowResoMode(FALSE); + break; + + case 4: + JW_SetLowResoMode(TRUE); + break; + } + } } - } - } - /* Fallthrough 4 -> 6 */ - case 6: - { - if (hreg_init_check(6)) { - SETREG(HREG, HREG_STATE_ARGS_START, 1); - SETREG(HREG, 82, 1); - } - } - break; + /* Fallthrough 4 -> 6 */ + case 6: { + if (hreg_init_check(6)) { + SETREG(HREG, HREG_STATE_ARGS_START, 1); + SETREG(HREG, 82, 1); + } + } break; - case 7: - break; + case 7: + break; - case 8: - { - hreg_init_check(8); - if (GETREG(HREG, HREG_STATE_ARGS_START) < 0) { - SETREG(HREG, HREG_STATE_ARGS_START, 0); - } - } - break; + case 8: { + hreg_init_check(8); + if (GETREG(HREG, HREG_STATE_ARGS_START) < 0) { + SETREG(HREG, HREG_STATE_ARGS_START, 0); + } + } break; - /** - * Unknown function, but may relate to toggling some debug - * drawing feature which is removed. - * - * HREG[81]: - * 1: Set bit 3 (enable) - * 2: Clear bit 3 (disable) - * - * HREG[47] = modified register - */ - case 15: - { - hreg_init_check(15); - if (GETREG(HREG, HREG_STATE_ARGS_START) == 1) { - SETREG(HREG, 47, GETREG(HREG, 47) | 8); - } - else if (GETREG(HREG, HREG_STATE_ARGS_START) == 2) { - SETREG(HREG, 47, GETREG(HREG, 47) & (~8)); - } - } - break; + /** + * Unknown function, but may relate to toggling some debug + * drawing feature which is removed. + * + * HREG[81]: + * 1: Set bit 3 (enable) + * 2: Clear bit 3 (disable) + * + * HREG[47] = modified register + */ + case 15: { + hreg_init_check(15); + if (GETREG(HREG, HREG_STATE_ARGS_START) == 1) { + SETREG(HREG, 47, GETREG(HREG, 47) | 8); + } else if (GETREG(HREG, HREG_STATE_ARGS_START) == 2) { + SETREG(HREG, 47, GETREG(HREG, 47) & (~8)); + } + } break; - /** - * Toggles 'FreeBlockTest' mode for __osMalloc. - * HREG[82] = BOOL enable - */ - case 20: - { - hreg_init_check(20); - __osMalloc_FreeBlockTest_Enable = GETREG(HREG, 82); - } - break; + /** + * Toggles 'FreeBlockTest' mode for __osMalloc. + * HREG[82] = BOOL enable + */ + case 20: { + hreg_init_check(20); + __osMalloc_FreeBlockTest_Enable = GETREG(HREG, 82); + } break; - /** - * Safety frame bounds - * Sets the bounds for drawing saftey frame boundary in - * debug_hayakawa_draw. Minimum bounds are (0, 0) and - * maximum bounds are (ScreenWidth, ScreenHeight). - * - * HREG[81]: - * 1: Bounds set to [(0, 0), (SCREEN_WIDTH, SCREEN_HEIGHT)] - * 2: Bounds set to [(0, 0), (ScreenWidth, ScreenHeight)] - * - * HREG[82]: upper left y (uly) - * HREG[83]: lower right y (lry) - * HREG[84]: upper left x (ulx) - * HREG[85]: lower right x (lrx) - */ - case 25: - { - if (hreg_init_check(25)) { - SETREG(HREG, HREG_STATE_ARGS_START, 0); - SETREG(HREG, 82, 0); - SETREG(HREG, 83, ScreenHeight); - SETREG(HREG, 84, 0); - SETREG(HREG, 85, ScreenWidth); - } + /** + * Safety frame bounds + * Sets the bounds for drawing saftey frame boundary in + * debug_hayakawa_draw. Minimum bounds are (0, 0) and + * maximum bounds are (ScreenWidth, ScreenHeight). + * + * HREG[81]: + * 1: Bounds set to [(0, 0), (SCREEN_WIDTH, SCREEN_HEIGHT)] + * 2: Bounds set to [(0, 0), (ScreenWidth, ScreenHeight)] + * + * HREG[82]: upper left y (uly) + * HREG[83]: lower right y (lry) + * HREG[84]: upper left x (ulx) + * HREG[85]: lower right x (lrx) + */ + case 25: { + if (hreg_init_check(25)) { + SETREG(HREG, HREG_STATE_ARGS_START, 0); + SETREG(HREG, 82, 0); + SETREG(HREG, 83, ScreenHeight); + SETREG(HREG, 84, 0); + SETREG(HREG, 85, ScreenWidth); + } - switch (GETREG(HREG, HREG_STATE_ARGS_START)) { - case 1: - { - SETREG(HREG, 82, 0); - SETREG(HREG, 83, SCREEN_HEIGHT); - SETREG(HREG, 84, 0); - SETREG(HREG, 85, SCREEN_WIDTH); + switch (GETREG(HREG, HREG_STATE_ARGS_START)) { + case 1: { + SETREG(HREG, 82, 0); + SETREG(HREG, 83, SCREEN_HEIGHT); + SETREG(HREG, 84, 0); + SETREG(HREG, 85, SCREEN_WIDTH); + } break; + + case 2: { + SETREG(HREG, 82, 0); + SETREG(HREG, 83, ScreenHeight); + SETREG(HREG, 84, 0); + SETREG(HREG, 85, ScreenWidth); + } break; + } + + if (GETREG(HREG, 82) < 0) { + SETREG(HREG, 82, 0); + } + + if (GETREG(HREG, 83) > ScreenHeight) { + SETREG(HREG, 83, ScreenHeight); + } + + if (GETREG(HREG, 84) < 0) { + SETREG(HREG, 84, 0); + } + + if (GETREG(HREG, 85) > ScreenWidth) { + SETREG(HREG, 85, ScreenWidth); + } + } break; + + /** + * Unknown function. + * HREG[82], HREG[83], HREG[84] all contain bytes. Two of which are concatenated + * depending on value in HREG[81]. Result is stored in HREG[48] or HREG[49]. + * + * HREG[81] = Mode + * HREG[82] = byte0 + * HREG[83] = byte1 + * HREG[84] = byte2 + * HREG[48] = result_byte0_byte1 + * HREG[49] = result_byte1_byte2 + */ + case 39: { + hreg_init_check(39); + + switch (GETREG(HREG, HREG_STATE_ARGS_START)) { + case 0: + break; + + case 1: { + u16 v = ((GETREG(HREG, 82) & 0xFF) << 8) | (GETREG(HREG, 83) & 0xFF); + if (GETREG(HREG, 48) != v) { + SETREG(HREG, 48, v); + } + } break; + + case 2: { + if (GETREG(HREG, 48) != 0) { + SETREG(HREG, 48, 0); + } + } break; + + case 3: { + u16 v = ((GETREG(HREG, 83) & 0xFF) << 8) | (GETREG(HREG, 84) & 0xFF); + if (GETREG(HREG, 49) != v) { + SETREG(HREG, 49, v); + } + } break; + } + } break; + + /* Clear state arg for memory block (1MB blocks) */ + case 600: { + hreg_init_check(600); + + if (GETREG(HREG, HREG_STATE_ARGS_START) < 0) { + SETREG(HREG, HREG_STATE_ARGS_START, 0); + } } - break; + /* Fallthrough 600 -> 666 */ + /* Get/Set byte at beginning of 1MB boundary blocks */ + case 666: { + /** + * HREG[82] = index of 1MB block + * HREG[83] = byte to get/set for block + */ + hreg_init_check(666); - case 2: - { - SETREG(HREG, 82, 0); - SETREG(HREG, 83, ScreenHeight); - SETREG(HREG, 84, 0); - SETREG(HREG, 85, ScreenWidth); - } - break; - } + switch (GETREG(HREG, HREG_STATE_ARGS_START)) { + /* Load */ + case 1: { + SETREG(HREG, 83, *(u8*)(GETREG(HREG, 82) * 0x100000 - 0x80000000)); + } break; - if (GETREG(HREG, 82) < 0) { - SETREG(HREG, 82, 0); - } - - if (GETREG(HREG, 83) > ScreenHeight) { - SETREG(HREG, 83, ScreenHeight); - } - - if (GETREG(HREG, 84) < 0) { - SETREG(HREG, 84, 0); - } - - if (GETREG(HREG, 85) > ScreenWidth) { - SETREG(HREG, 85, ScreenWidth); - } - } - break; - - /** - * Unknown function. - * HREG[82], HREG[83], HREG[84] all contain bytes. Two of which are concatenated - * depending on value in HREG[81]. Result is stored in HREG[48] or HREG[49]. - * - * HREG[81] = Mode - * HREG[82] = byte0 - * HREG[83] = byte1 - * HREG[84] = byte2 - * HREG[48] = result_byte0_byte1 - * HREG[49] = result_byte1_byte2 - */ - case 39: - { - hreg_init_check(39); - - switch (GETREG(HREG, HREG_STATE_ARGS_START)) { - case 0: - break; - - case 1: - { - u16 v = ((GETREG(HREG, 82) & 0xFF) << 8) | (GETREG(HREG, 83) & 0xFF); - if (GETREG(HREG, 48) != v) { - SETREG(HREG, 48, v); - } - } - break; - - case 2: - { - if (GETREG(HREG, 48) != 0) { - SETREG(HREG, 48, 0); - } - } - break; - - case 3: - { - u16 v = ((GETREG(HREG, 83) & 0xFF) << 8) | (GETREG(HREG, 84) & 0xFF); - if (GETREG(HREG, 49) != v) { - SETREG(HREG, 49, v); - } - } - break; - } - } - break; - - /* Clear state arg for memory block (1MB blocks) */ - case 600: - { - hreg_init_check(600); - - if (GETREG(HREG, HREG_STATE_ARGS_START) < 0) { - SETREG(HREG, HREG_STATE_ARGS_START, 0); - } - } - /* Fallthrough 600 -> 666 */ - /* Get/Set byte at beginning of 1MB boundary blocks */ - case 666: - { - /** - * HREG[82] = index of 1MB block - * HREG[83] = byte to get/set for block - */ - hreg_init_check(666); - - switch (GETREG(HREG, HREG_STATE_ARGS_START)) { - /* Load */ - case 1: - { - SETREG(HREG, 83, *(u8*)(GETREG(HREG, 82) * 0x100000 - 0x80000000)); - } - break; - - /* Store */ - case 2: - { - *(u8*)(GETREG(HREG, 82) * 0x100000 - 0x80000000) = (u8)GETREG(HREG, 83); - } - break; - } - } - break; - } - - hreg_init_check(667); - hreg_init_check(34); - hreg_init_check(35); - hreg_init_check(38); - - if (GETREG(SREG, 21)) { - if (GETREG(SREG, 21) & 1) { - OSReportDisable(); - } - else { - if (OS_CONSOLE_IS_DEV()) { - OSReportEnable(); - } + /* Store */ + case 2: { + *(u8*)(GETREG(HREG, 82) * 0x100000 - 0x80000000) = (u8)GETREG(HREG, 83); + } break; + } + } break; } - JC_JUTDbPrint_setVisible(JC_JUTDbPrint_getManager(), !(GETREG(SREG, 21) & 2)); - JC_JUTProcBar_setVisible(JC_JUTProcBar_getManager(), !(GETREG(SREG, 21) & 4)); - JC_JUTProcBar_setVisibleHeapBar(JC_JUTProcBar_getManager(), !(GETREG(SREG, 21) & 4)); - } + hreg_init_check(667); + hreg_init_check(34); + hreg_init_check(35); + hreg_init_check(38); + + if (GETREG(SREG, 21)) { + if (GETREG(SREG, 21) & 1) { + OSReportDisable(); + } else { + if (OS_CONSOLE_IS_DEV()) { + OSReportEnable(); + } + } + + JC_JUTDbPrint_setVisible(JC_JUTDbPrint_getManager(), !(GETREG(SREG, 21) & 2)); + JC_JUTProcBar_setVisible(JC_JUTProcBar_getManager(), !(GETREG(SREG, 21) & 4)); + JC_JUTProcBar_setVisibleHeapBar(JC_JUTProcBar_getManager(), !(GETREG(SREG, 21) & 4)); + } } +typedef union { + rgba_t color; + u32 raw; +} rgba_u; + /** * @brief Displays a visualization of the input device state, including button press indicators. * @@ -443,50 +409,56 @@ extern void debug_hayakawa_move(pad_t* pad) { * @param gfx_pp Pointer to a pointer of Gfx type, which will be used to draw the button states. */ static void pad_disp(u8 pad, u16 button, Gfx** gfx_pp) { - static const rgba_t pad_color2[16] = { - /* Yellow for C-Stick */ - { 255, 255, 0, 255 }, /* C-Stick Right */ - { 255, 255, 0, 255 }, /* C-Stick Left */ - { 255, 255, 0, 255 }, /* C-Stick Down */ - { 255, 255, 0, 255 }, /* C-Stick Up */ - /* Gray for L, R, X, Y, D-Pad, & Start */ - { 127, 127, 127, 255 }, /* R */ - { 127, 127, 127, 255 }, /* L */ - { 127, 127, 127, 255 }, /* X */ - { 127, 127, 127, 255 }, /* Y */ - { 127, 127, 127, 255 }, /* D-Pad Right */ - { 127, 127, 127, 255 }, /* D-Pad Left */ - { 127, 127, 127, 255 }, /* D-Pad Down */ - { 127, 127, 127, 255 }, /* D-Pad Up */ - { 127, 127, 127, 255 }, /* Start */ - /* Blue for Z */ - { 0, 0, 255, 255 }, /* Z */ - /* Red for B */ - { 255, 0, 0, 255 }, /* B */ - /* Green for A */ - { 0, 255, 0, 255 } /* A */ - }; + static const rgba_u pad_color2[16] = { + /* Yellow for C-Stick */ + { 255, 255, 0, 255 }, /* C-Stick Right */ + { 255, 255, 0, 255 }, /* C-Stick Left */ + { 255, 255, 0, 255 }, /* C-Stick Down */ + { 255, 255, 0, 255 }, /* C-Stick Up */ + /* Gray for L, R, X, Y, D-Pad, & Start */ + { 127, 127, 127, 255 }, /* R */ + { 127, 127, 127, 255 }, /* L */ + { 127, 127, 127, 255 }, /* X */ + { 127, 127, 127, 255 }, /* Y */ + { 127, 127, 127, 255 }, /* D-Pad Right */ + { 127, 127, 127, 255 }, /* D-Pad Left */ + { 127, 127, 127, 255 }, /* D-Pad Down */ + { 127, 127, 127, 255 }, /* D-Pad Up */ + { 127, 127, 127, 255 }, /* Start */ + /* Blue for Z */ + { 0, 0, 255, 255 }, /* Z */ + /* Red for B */ + { 255, 0, 0, 255 }, /* B */ + /* Green for A */ + { 0, 255, 0, 255 }, /* A */ + }; - int i; - int pad_start_x = pad * 70 + 20; - Gfx* gfx = *gfx_pp; - - gDPPipeSync(gfx++); - gDPSetOtherMode(gfx++, G_AD_DISABLE | G_CD_DISABLE | G_CK_NONE | G_TC_FILT | G_TF_BILERP | G_TT_NONE | G_TL_TILE | G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_1PRIMITIVE, G_AC_NONE | G_ZS_PIXEL | G_RM_OPA_SURF | G_RM_OPA_SURF2); - gDPSetCombineMode(gfx++, G_CC_PRIMITIVE, G_CC_PRIMITIVE); - gDPSetPrimColor(gfx++, 0, 0, 0, 0, 0, 0); - gfx = gfx_gDPFillRectangle1(gfx, pad_start_x - 1, 225, pad_start_x + 65, 231); + const int pad_start_x = pad * 70 + 20; + Gfx* gfx = *gfx_pp; + int i; + int x0; + int x1; - for (i = 0; i < 16; i++) { - if (button & (1 << i)) { - /* pad_color2 might be a union or a u32 array */ - gDPSetColor(gfx++, G_SETPRIMCOLOR, ((u32*)pad_color2)[i]); - gfx = gfx_gDPFillRectangle1(gfx, pad_start_x + (i * 4), 226, (pad_start_x + (i + 1) * 4) - 1, 229); + gDPPipeSync(gfx++); + gDPSetOtherMode(gfx++, + G_AD_DISABLE | G_CD_DISABLE | G_CK_NONE | G_TC_FILT | G_TF_BILERP | G_TT_NONE | G_TL_TILE | + G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_1PRIMITIVE, + G_AC_NONE | G_ZS_PIXEL | G_RM_OPA_SURF | G_RM_OPA_SURF2); + gDPSetCombineMode(gfx++, G_CC_PRIMITIVE, G_CC_PRIMITIVE); + gDPSetPrimColor(gfx++, 0, 0, 0, 0, 0, 0); + gfx = gfx_gDPFillRectangle1(gfx, pad_start_x - 1, 225, pad_start_x + 65, 231); + + for (i = 0; i < 16; i++) { + if (button & (1 << i)) { + gDPSetColor(gfx++, G_SETPRIMCOLOR, pad_color2[i].raw); + x0 = pad_start_x + (int)(i * 4); + x1 = pad_start_x + (int)((i + 1) * 4); + gfx = gfx_gDPFillRectangle1(gfx, x0, 226, x1 - 1, 229); + } } - } - gDPPipeSync(gfx++); - *gfx_pp = gfx; + gDPPipeSync(gfx++); + *gfx_pp = gfx; } /** @@ -503,30 +475,33 @@ static void pad_disp(u8 pad, u16 button, Gfx** gfx_pp) { * @param lry Lower-right y coordinate of the region. */ static void debug_hayakawa_draw_safetyframe(Gfx** gfx_pp, u32 ulx, u32 uly, u32 lrx, u32 lry) { - Gfx* gfx = *gfx_pp; + Gfx* gfx = *gfx_pp; - gDPPipeSync(gfx++); - gDPSetOtherMode(gfx++, G_AD_PATTERN | G_CD_MAGICSQ | G_CK_NONE | G_TC_CONV | G_TF_POINT | G_TT_NONE | G_TL_TILE | G_TD_CLAMP | G_TP_NONE | G_CYC_FILL | G_PM_NPRIMITIVE, G_AC_NONE | G_ZS_PIXEL | G_RM_NOOP | G_RM_NOOP2); - gDPSetFillColor(gfx++, 0xFFFFFFFF); + gDPPipeSync(gfx++); + gDPSetOtherMode(gfx++, + G_AD_PATTERN | G_CD_MAGICSQ | G_CK_NONE | G_TC_CONV | G_TF_POINT | G_TT_NONE | G_TL_TILE | + G_TD_CLAMP | G_TP_NONE | G_CYC_FILL | G_PM_NPRIMITIVE, + G_AC_NONE | G_ZS_PIXEL | G_RM_NOOP | G_RM_NOOP2); + gDPSetFillColor(gfx++, 0xFFFFFFFF); - if (uly > 1) { - gfx = gfx_gDPFillRectangleF(gfx, ulx, uly - 1, lrx + 1, uly); - } + if (uly > 1) { + gfx = gfx_gDPFillRectangleF(gfx, ulx, uly - 1, lrx + 1, uly); + } - if (ulx > 1) { - gfx = gfx_gDPFillRectangleF(gfx, ulx - 1, uly, ulx, lry + 1); - } + if (ulx > 1) { + gfx = gfx_gDPFillRectangleF(gfx, ulx - 1, uly, ulx, lry + 1); + } - if (lry < SCREEN_HEIGHT - 1) { - gfx = gfx_gDPFillRectangleF(gfx, ulx, lry, lrx + 1, lry + 1); - } + if (lry < SCREEN_HEIGHT - 1) { + gfx = gfx_gDPFillRectangleF(gfx, ulx, lry, lrx + 1, lry + 1); + } - if (lrx < SCREEN_WIDTH - 1) { - gfx = gfx_gDPFillRectangleF(gfx, lrx, uly, lrx + 1, lry + 1); - } + if (lrx < SCREEN_WIDTH - 1) { + gfx = gfx_gDPFillRectangleF(gfx, lrx, uly, lrx + 1, lry + 1); + } - gDPPipeSync(gfx++); - *gfx_pp = gfx; + gDPPipeSync(gfx++); + *gfx_pp = gfx; } #define DRAW_MAX_X (u32)(SCREEN_WIDTH - 1) @@ -538,93 +513,92 @@ static void debug_hayakawa_draw_safetyframe(Gfx** gfx_pp, u32 ulx, u32 uly, u32 * @param graph Pointer to the GRAPH struct which will be drawn to. */ extern void debug_hayakawa_draw(GRAPH* graph) { - Gfx* poly_opa_gfx; - Gfx* opened_gfx; - gfxprint_t gfxprint; - gfxprint_t* gfxprint_p = &gfxprint; + Gfx* poly_opa_gfx; + Gfx* opened_gfx; + gfxprint_t gfxprint; + gfxprint_t* gfxprint_p = &gfxprint; - OPEN_DISP(graph); + OPEN_DISP(graph); - poly_opa_gfx = NOW_POLY_OPA_DISP; - opened_gfx = gfxopen(poly_opa_gfx); + poly_opa_gfx = NOW_POLY_OPA_DISP; + opened_gfx = gfxopen(poly_opa_gfx); - gSPDisplayList(NOW_OVERLAY_DISP++, opened_gfx); + gSPDisplayList(NOW_OVERLAY_DISP++, opened_gfx); - /* Draw pad input */ - if (GETREG(HREG, 47) & 1) { - int i; - for (i = 0; i < MAXCONTROLLERS; i++) { - s16 button = GETREG(HREG, 40 + i); - if (button != 0) { - pad_disp(i, button, &opened_gfx); - } - } - } - - if (GETREG(HREG, HREG_STATE_IDX) == 41 && hreg_init_check(41)) { - SETREG(HREG, HREG_STATE_ARGS_START, (GETREG(HREG, 39) >> 1) & 1); - SETREG(HREG, 82, 31); - SETREG(HREG, 83, 22); - SETREG(HREG, 84, 289); - SETREG(HREG, 85, 218); - } - - /* Safety frame drawing check */ - if ((GETREG(HREG, 39) & 2) || (GETREG(HREG, HREG_STATE_IDX) == 41 && GETREG(HREG, HREG_STATE_ARGS_START) != 0)) { - u32 a = 31; - u32 b = 22; - u32 c = 289; - u32 d = 218; - - u32 ulx, uly, - lrx, lry; - - if (GETREG(HREG, HREG_STATE_IDX) == 41) { - a = GETREG(HREG, 82); - b = GETREG(HREG, 83); - c = GETREG(HREG, 84); - d = GETREG(HREG, 85); + /* Draw pad input */ + if (GETREG(HREG, 47) & 1) { + int i; + for (i = 0; i < MAXCONTROLLERS; i++) { + s16 button = GETREG(HREG, 40 + i); + if (button != 0) { + pad_disp(i, button, &opened_gfx); + } + } } - ulx = a <= DRAW_MAX_X ? a : DRAW_MAX_X; - uly = b <= DRAW_MAX_Y ? b : DRAW_MAX_Y; - lrx = c < ulx ? ulx : (c <= DRAW_MAX_X - 1 ? c : DRAW_MAX_X - 1); - lry = d < uly ? uly : (d <= DRAW_MAX_Y - 1 ? d : DRAW_MAX_Y - 1); - - debug_hayakawa_draw_safetyframe(&opened_gfx, ulx, uly, lrx, lry); - } - - /* Vertical Interrupt Pan Configuration */ - if (GETREG(HREG, HREG_STATE_IDX) == 42) { - if (hreg_init_check(42) || (GETREG(HREG, HREG_STATE_IDX) == 42 && GETREG(HREG, HREG_STATE_ARGS_START) != 0)) { - SETREG(HREG, HREG_STATE_ARGS_START, 0); - /* 4:5 aspect ratio? */ - SETREG(HREG, 82, 30); /* Pan x origin */ - SETREG(HREG, 83, 6); /* Pan y origin */ - SETREG(HREG, 84, 580); /* Pan width */ - SETREG(HREG, 85, 464); /* Pan height */ + if (GETREG(HREG, HREG_STATE_IDX) == 41 && hreg_init_check(41)) { + SETREG(HREG, HREG_STATE_ARGS_START, (GETREG(HREG, 39) >> 1) & 1); + SETREG(HREG, 82, 31); + SETREG(HREG, 83, 22); + SETREG(HREG, 84, 289); + SETREG(HREG, 85, 218); } - VIConfigurePan(GETREG(HREG, 82) & ~1, GETREG(HREG, 83) & ~1, GETREG(HREG, 84) & ~1, GETREG(HREG, 85) & ~1); - } + /* Safety frame drawing check */ + if ((GETREG(HREG, 39) & 2) || (GETREG(HREG, HREG_STATE_IDX) == 41 && GETREG(HREG, HREG_STATE_ARGS_START) != 0)) { + u32 a = 31; + u32 b = 22; + u32 c = 289; + u32 d = 218; - /* Initialize display list segment at specific 1MB region */ - if (GETREG(HREG, HREG_STATE_IDX) == 667 && GETREG(HREG, HREG_STATE_ARGS_START)) { - int block = GETREG(HREG, 82) * 0x100000 + 0x80000000; - /* TODO: segment id 8 definitely needs a definition somewhere */ - gSPSegment(opened_gfx++, 8, block); - } + u32 ulx, uly, lrx, lry; - gfxprint_init(gfxprint_p); - gfxprint_open(gfxprint_p, opened_gfx); - /* removed/debug code I guess? */ - opened_gfx = gfxprint_close(gfxprint_p); - gSPEndDisplayList(opened_gfx++); - gfxclose(poly_opa_gfx, opened_gfx); - SET_POLY_OPA_DISP(opened_gfx); - gfxprint_cleanup(gfxprint_p); + if (GETREG(HREG, HREG_STATE_IDX) == 41) { + a = GETREG(HREG, 82); + b = GETREG(HREG, 83); + c = GETREG(HREG, 84); + d = GETREG(HREG, 85); + } - CLOSE_DISP(graph); + ulx = a <= DRAW_MAX_X ? a : DRAW_MAX_X; + uly = b <= DRAW_MAX_Y ? b : DRAW_MAX_Y; + lrx = c < ulx ? ulx : (c <= DRAW_MAX_X - 1 ? c : DRAW_MAX_X - 1); + lry = d < uly ? uly : (d <= DRAW_MAX_Y - 1 ? d : DRAW_MAX_Y - 1); + + debug_hayakawa_draw_safetyframe(&opened_gfx, ulx, uly, lrx, lry); + } + + /* Vertical Interrupt Pan Configuration */ + if (GETREG(HREG, HREG_STATE_IDX) == 42) { + if (hreg_init_check(42) || (GETREG(HREG, HREG_STATE_IDX) == 42 && GETREG(HREG, HREG_STATE_ARGS_START) != 0)) { + SETREG(HREG, HREG_STATE_ARGS_START, 0); + /* 4:5 aspect ratio? */ + SETREG(HREG, 82, 30); /* Pan x origin */ + SETREG(HREG, 83, 6); /* Pan y origin */ + SETREG(HREG, 84, 580); /* Pan width */ + SETREG(HREG, 85, 464); /* Pan height */ + } + + VIConfigurePan(GETREG(HREG, 82) & ~1, GETREG(HREG, 83) & ~1, GETREG(HREG, 84) & ~1, GETREG(HREG, 85) & ~1); + } + + /* Initialize display list segment at specific 1MB region */ + if (GETREG(HREG, HREG_STATE_IDX) == 667 && GETREG(HREG, HREG_STATE_ARGS_START)) { + int block = GETREG(HREG, 82) * 0x100000 + 0x80000000; + /* TODO: segment id 8 definitely needs a definition somewhere */ + gSPSegment(opened_gfx++, 8, block); + } + + gfxprint_init(gfxprint_p); + gfxprint_open(gfxprint_p, opened_gfx); + /* removed/debug code I guess? */ + opened_gfx = gfxprint_close(gfxprint_p); + gSPEndDisplayList(opened_gfx++); + gfxclose(poly_opa_gfx, opened_gfx); + SET_POLY_OPA_DISP(opened_gfx); + gfxprint_cleanup(gfxprint_p); + + CLOSE_DISP(graph); } /** @@ -638,25 +612,22 @@ extern void debug_hayakawa_draw(GRAPH* graph) { */ extern int hreg_init_check(const int n) { - // Check if the current hreg state index is different from the previous one - if (GETREG(HREG, HREG_STATE_IDX) == n && GETREG(HREG, 55) != n) { - int i; - int reg; + // Check if the current hreg state index is different from the previous one + if (GETREG(HREG, HREG_STATE_IDX) == n && GETREG(HREG, 55) != n) { + int i; - // Set the previous hreg state index to the current one - SETREG(HREG, 55, n); - reg = HREG_STATE_ARGS_START; + // Set the previous hreg state index to the current one + SETREG(HREG, 55, n); - // Initialize the hreg state arguments to 0 - for (i = 0; i < 15; i++, reg++) { - SETREG(HREG, reg, 0); + // Initialize the hreg state arguments to 0 + for (i = HREG_STATE_ARGS_START; i < HREG_STATE_ARGS_START + 15; i++) { + SETREG(HREG, i, 0); + } + + // Return TRUE if the hreg state index has changed and arguments have been initialized + return TRUE; } - // Return TRUE if the hreg state index has changed and arguments have been initialized - return TRUE; - } - - // Return FALSE if the hreg state index has not changed - return FALSE; + // Return FALSE if the hreg state index has not changed + return FALSE; } - diff --git a/src/game/m_debug_mode.c b/src/game/m_debug_mode.c index 0dce9818..d6fb36e9 100644 --- a/src/game/m_debug_mode.c +++ b/src/game/m_debug_mode.c @@ -40,197 +40,183 @@ static int debug_print_flg; static s16 debug_print2_count; typedef struct debug_mode_print_buffer_s { - u8 color; - u8 msg[11]; + u8 color; + u8 msg[11]; } debug_mode_print_buf_t; static debug_mode_print_buf_t debug_print_buffer[DEBUG_MODE_PRINT_BUF_COUNT] = { - { - DEBUG_PRINT_COLOR_BLACK, - " \0", - }, - { - DEBUG_PRINT_COLOR_BLACK, - " \0", - }, - { - DEBUG_PRINT_COLOR_BLACK, - " \0", - }, - { - DEBUG_PRINT_COLOR_BLACK, - " \0", - }, - { - DEBUG_PRINT_COLOR_BLACK, - " \0", - }, - { - DEBUG_PRINT_COLOR_BLACK, - " \0", - } + { + DEBUG_PRINT_COLOR_BLACK, + " \0", + }, + { + DEBUG_PRINT_COLOR_BLACK, + " \0", + }, + { + DEBUG_PRINT_COLOR_BLACK, + " \0", + }, + { + DEBUG_PRINT_COLOR_BLACK, + " \0", + }, + { + DEBUG_PRINT_COLOR_BLACK, + " \0", + }, + { + DEBUG_PRINT_COLOR_BLACK, + " \0", + }, }; void Debug_Print_reset() { - debug_print_flg = 0; + debug_print_flg = 0; } void Debug_Print_write() { - debug_print2_count = 0; + debug_print2_count = 0; } static void Debug_Print_output(gfxprint_t* gfxprint) { - static rgba_t print_color[8] = { - { 0, 0, 0, 64 }, /* Black */ - { 0, 0, 255, 64 }, /* Blue */ - { 255, 0, 0, 64 }, /* Red */ - { 255, 0, 255, 64 }, /* Magenta */ - { 0, 255, 0, 64 }, /* Green */ - { 0, 255, 255, 64 }, /* Cyan */ - { 255, 255, 0, 64 }, /* Yellow */ - { 255, 255, 255, 64 } /* White */ - }; + static rgba_t print_color[8] = { + { 0, 0, 0, 64 }, /* Black */ + { 0, 0, 255, 64 }, /* Blue */ + { 255, 0, 0, 64 }, /* Red */ + { 255, 0, 255, 64 }, /* Magenta */ + { 0, 255, 0, 64 }, /* Green */ + { 0, 255, 255, 64 }, /* Cyan */ + { 255, 255, 0, 64 }, /* Yellow */ + { 255, 255, 255, 64 }, /* White */ + }; - debug_mode_print_buf_t* print_buf = debug_print_buffer; - int y; + debug_mode_print_buf_t* print_buf = debug_print_buffer; + int y; - for (y = DEBUG_MODE_PRINT_OUTPUT_Y; y < DEBUG_MODE_PRINT_OUTPUT_Y_LAST;) { - rgba_t* color; - gfxprint_locate8x8(gfxprint, DEBUG_MODE_PRINT_OUTPUT_X, y); - color = print_color + print_buf->color; - gfxprint_color(gfxprint, color->r, color->g, color->b, color->a); - gfxprint_printf(gfxprint, "%s", print_buf->msg); + for (y = DEBUG_MODE_PRINT_OUTPUT_Y; y < DEBUG_MODE_PRINT_OUTPUT_Y_LAST;) { + rgba_t* color; + gfxprint_locate8x8(gfxprint, DEBUG_MODE_PRINT_OUTPUT_X, y); + color = print_color + print_buf->color; + gfxprint_color(gfxprint, color->r, color->g, color->b, color->a); + gfxprint_printf(gfxprint, "%s", print_buf->msg); - y++; - print_buf->msg[0] = '\0'; - print_buf++; - } + y++; + print_buf->msg[0] = '\0'; + print_buf++; + } } #define DEBUG_MODE_PRINT2_BUF_COUNT 80 typedef struct debug_mode_print2_buffer_s { - u8 x; - u8 y; - u8 color; - u8 msg[41]; + u8 x; + u8 y; + u8 color; + u8 msg[41]; } debug_mode_print2_buf_t; static debug_mode_print2_buf_t debug_print2_buffer[DEBUG_MODE_PRINT2_BUF_COUNT]; static void Debug_Print2_output(gfxprint_t* gfxprint) { - static rgba_t print_color[8] = { - { 255, 255, 32, 192 }, /* Yellow */ - { 255, 150, 128, 192 }, /* Pink */ - { 128, 96, 0, 64 }, /* Brown */ - { 192, 128, 16, 128 }, /* Dark Orange */ - { 255, 192, 32, 128 }, /* Light Orange */ - { 230, 230, 220, 64 }, /* White/Gray */ - { 128, 150, 255, 128 }, /* Lilac */ - { 128, 255, 32, 128 } /* Lime green */ - }; + static rgba_t print_color[8] = { + { 255, 255, 32, 192 }, /* Yellow */ + { 255, 150, 128, 192 }, /* Pink */ + { 128, 96, 0, 64 }, /* Brown */ + { 192, 128, 16, 128 }, /* Dark Orange */ + { 255, 192, 32, 128 }, /* Light Orange */ + { 230, 230, 220, 64 }, /* White/Gray */ + { 128, 150, 255, 128 }, /* Lilac */ + { 128, 255, 32, 128 } /* Lime green */ + }; - int i; - for (i = 0; i < debug_print2_count; i++) { - gfxprint_color( - gfxprint, - print_color[debug_print2_buffer[i].color].r, - print_color[debug_print2_buffer[i].color].g, - print_color[debug_print2_buffer[i].color].b, - print_color[debug_print2_buffer[i].color].a - ); + int i; + for (i = 0; i < debug_print2_count; i++) { + gfxprint_color(gfxprint, print_color[debug_print2_buffer[i].color].r, + print_color[debug_print2_buffer[i].color].g, print_color[debug_print2_buffer[i].color].b, + print_color[debug_print2_buffer[i].color].a); - gfxprint_locate8x8(gfxprint, debug_print2_buffer[i].x, debug_print2_buffer[i].y); - gfxprint_printf(gfxprint, "%s", debug_print2_buffer[i].msg); - } + gfxprint_locate8x8(gfxprint, debug_print2_buffer[i].x, debug_print2_buffer[i].y); + gfxprint_printf(gfxprint, "%s", debug_print2_buffer[i].msg); + } } #define PAD_BUTTON_IS_DOWN(buttons, button) (((int)(buttons) | (~(int)(button))) == -1) static int Debug_console(pad_t* pad) { - static f32 console_scroll; - static f32 console_offset_x; - static f32 font_scale_x[] = { - 1.0f, 0.9f, 0.8f, 0.7f, 0.6f, 0.5f, 0.4f, 0.3f, - }; - static f32 font_scale_y[] = { - 1.0f, 0.9f, 0.8f, 0.7f, 0.6f, 0.5f, 0.4f, 0.3f, - }; + static f32 console_scroll; + static f32 console_offset_x; + static f32 font_scale_x[] = { + 1.0f, 0.9f, 0.8f, 0.7f, 0.6f, 0.5f, 0.4f, 0.3f, + }; + static f32 font_scale_y[] = { + 1.0f, 0.9f, 0.8f, 0.7f, 0.6f, 0.5f, 0.4f, 0.3f, + }; - void* sys_console = JC_JFWSystem_getSystemConsole(); + void* sys_console = JC_JFWSystem_getSystemConsole(); - if (sys_console != NULL) { - /* Toggle console visiblity when Z button is released */ - if (PAD_BUTTON_IS_DOWN(pad->on.button, BUTTON_Z) && (pad->now.button & (~BUTTON_Z)) == 0) { - JC_JUTConsole_setVisible(sys_console, !JC_JUTConsole_isVisible(sys_console)); + if (sys_console != NULL) { + /* Toggle console visiblity when Z button is released */ + if (PAD_BUTTON_IS_DOWN(pad->on.button, BUTTON_Z) && (pad->now.button & (~BUTTON_Z)) == 0) { + JC_JUTConsole_setVisible(sys_console, !JC_JUTConsole_isVisible(sys_console)); + } + + if (JC_JUTConsole_isVisible(sys_console)) { + int scroll_x, scroll_y; + f32 log_stick_x = (f32)pad->off.stick_x / 60.0f; + f32 log_stick_y = (f32)pad->off.stick_y / 60.0f; + + /* B button clears console */ + if (PAD_BUTTON_IS_DOWN(pad->on.button, BUTTON_B)) { + JC_JUTConsole_clear(sys_console); + } + + /* L button to scroll */ + if (PAD_BUTTON_IS_DOWN(pad->now.button, BUTTON_L)) { + console_scroll -= log_stick_y; + + if (console_scroll > 1.0f) { + scroll_y = (int)console_scroll; + } else if (console_scroll < -1.0f) { + scroll_y = -(int)-console_scroll; /* nice double neg */ + } else { + scroll_y = 0; + } + + if (scroll_y != 0) { + console_scroll -= scroll_y; + JC_JUTConsole_scroll(sys_console, scroll_y); + } + + console_offset_x -= log_stick_x; + if (console_offset_x > 1.0f) { + scroll_x = (int)console_offset_x; + } else if (console_offset_x < -1.0f) { + scroll_x = -(int)-console_offset_x; /* nice double neg */ + } else { + scroll_x = 0; + } + + if (scroll_x != 0) { + console_offset_x -= scroll_x; + JC_JUTConsole_setPosition(sys_console, scroll_x + JC_JUTConsole_getPositionX(sys_console), 42); + } + + JW_JUTReport(30, 440, 1, "SCROLL:%3d %3d Output=%1x", JC_JUTConsole_getLineOffset(sys_console), + JC_JUTConsole_getPositionX(sys_console), JC_JUTConsole_getOutput(sys_console)); + } + + /* R button re-prints console */ + if (PAD_BUTTON_IS_DOWN(pad->on.button, BUTTON_R)) { + JC_JUTConsole_dumpToTerminal(sys_console, -1); /* -1 is probably a define */ + JC_JUTConsole_setOutput(sys_console, 3); /* Again, 3 is probably a define */ + } + + return TRUE; + } } - if (JC_JUTConsole_isVisible(sys_console)) { - int scroll_x, scroll_y; - f32 log_stick_x = (f32)pad->off.stick_x / 60.0f; - f32 log_stick_y = (f32)pad->off.stick_y / 60.0f; - - /* B button clears console */ - if (PAD_BUTTON_IS_DOWN(pad->on.button, BUTTON_B)) { - JC_JUTConsole_clear(sys_console); - } - - /* L button to scroll */ - if (PAD_BUTTON_IS_DOWN(pad->now.button, BUTTON_L)) { - console_scroll -= log_stick_y; - - if (console_scroll > 1.0f) { - scroll_y = (int)console_scroll; - } - else if (console_scroll < -1.0f) { - scroll_y = -(int)-console_scroll; /* nice double neg */ - } - else { - scroll_y = 0; - } - - if (scroll_y != 0) { - console_scroll -= scroll_y; - JC_JUTConsole_scroll(sys_console, scroll_y); - } - - console_offset_x -= log_stick_x; - if (console_offset_x > 1.0f) { - scroll_x = (int)console_offset_x; - } - else if (console_offset_x < -1.0f) { - scroll_x = -(int)-console_offset_x; /* nice double neg */ - } - else { - scroll_x = 0; - } - - if (scroll_x != 0) { - console_offset_x -= scroll_x; - JC_JUTConsole_setPosition(sys_console, scroll_x + JC_JUTConsole_getPositionX(sys_console), 42); - } - - JW_JUTReport( - 30, 440, - 1, - "SCROLL:%3d %3d Output=%1x", - JC_JUTConsole_getLineOffset(sys_console), - JC_JUTConsole_getPositionX(sys_console), - JC_JUTConsole_getOutput(sys_console) - ); - } - - /* R button re-prints console */ - if (PAD_BUTTON_IS_DOWN(pad->on.button, BUTTON_R)) { - JC_JUTConsole_dumpToTerminal(sys_console, -1); /* -1 is probably a define */ - JC_JUTConsole_setOutput(sys_console, 3); /* Again, 3 is probably a define */ - } - - return TRUE; - } - } - - return FALSE; + return FALSE; } static u32 draw_status = 0; @@ -239,528 +225,523 @@ static u32 bg_draw_status2 = 0; static u32 quest_draw_status = 0; static u32 shop_draw_status = 0; static u32 event_status = 0; -static u32 zelda_malloc_status = 0; -static u32 famicom_status = 0; +static u32 zelda_malloc_status = 0; +static u32 famicom_status = 0; static u32 npc_draw_status = 0; static u32 field_assessment_status = 0; typedef struct debug_reg_keycombo_s { - u16 held; /* Previously held */ - u16 pressed; /* Pressed this frame */ + u16 held; /* Previously held */ + u16 pressed; /* Pressed this frame */ } debug_reg_keycombo_t; extern void Debug_mode_input(pad_t* pad) { - int r_ofs = (-1 + debug_mode->mode + debug_mode->type * DEBUG_REG_GROUP) * DEBUG_REG_SIZE; + int r_ofs = (-1 + debug_mode->mode + debug_mode->type * DEBUG_REG_GROUP) * DEBUG_REG_SIZE; - if (famicom_status != 0 || Debug_console(pad) == 0) { - u16 now_button = pad->now.button; - int dpad = now_button & (BUTTON_DRIGHT | BUTTON_DLEFT | BUTTON_DDOWN | BUTTON_DUP); + if (famicom_status != 0 || Debug_console(pad) == 0) { + u16 now_button = pad->now.button; + int dpad = now_button & (BUTTON_DRIGHT | BUTTON_DLEFT | BUTTON_DDOWN | BUTTON_DUP); - /* L + R held shows the disk info, copy date, and zurumode/appNMI buffer state */ - if (PAD_BUTTON_IS_DOWN(now_button, BUTTON_L) && PAD_BUTTON_IS_DOWN(now_button, BUTTON_R)) { - DVDDiskID* diskid = DVDGetCurrentDiskID(); - if (diskid != NULL) { - JW_JUTReport(50, 50, 1, "%.4s %.2s 0x%02x(%d)", diskid->gameName, diskid->company, diskid->gameVersion, diskid->gameVersion); - } + /* L + R held shows the disk info, copy date, and zurumode/appNMI buffer state */ + if (PAD_BUTTON_IS_DOWN(now_button, BUTTON_L) && PAD_BUTTON_IS_DOWN(now_button, BUTTON_R)) { + DVDDiskID* diskid = DVDGetCurrentDiskID(); + if (diskid != NULL) { + JW_JUTReport(50, 50, 1, "%.4s %.2s 0x%02x(%d)", diskid->gameName, diskid->company, diskid->gameVersion, + diskid->gameVersion); + } - if (boot_copyDate != NULL) { - JW_JUTReport(320, 50, 1, "%.19s", boot_copyDate); - } + if (boot_copyDate != NULL) { + JW_JUTReport(320, 50, 1, "%.19s", boot_copyDate); + } - JW_JUTReport(50, 60, 1, "Z=%d Z2=%d ANB=%08x", zurumode_flag != 0, zurumode_flag >= 2, APPNMI_GETVAL()); + JW_JUTReport(50, 60, 1, "Z=%d Z2=%d ANB=%08x", zurumode_flag != 0, zurumode_flag >= 2, APPNMI_GETVAL()); - /* Additionally, pressing Z after L + R will print out each bit in debug appNMI buffer */ - if (PAD_BUTTON_IS_DOWN(pad->now.button, BUTTON_Z)) { - int i; - for (i = 0; i < 32; i++) { - JW_JUTReport(50 + i * 12, 70, 1, "%1x", (APPNMI_GETVAL() >> (31 - i)) & 1); + /* Additionally, pressing Z after L + R will print out each bit in debug appNMI buffer */ + if (PAD_BUTTON_IS_DOWN(pad->now.button, BUTTON_Z)) { + int i; + for (i = 0; i < 32; i++) { + JW_JUTReport(50 + i * 12, 70, 1, "%1x", (APPNMI_GETVAL() >> (31 - i)) & 1); + } + } } - } - } - if (zurumode_flag >= 2 && (PAD_BUTTON_IS_DOWN(pad->now.button, BUTTON_L) || PAD_BUTTON_IS_DOWN(pad->now.button, BUTTON_R) || PAD_BUTTON_IS_DOWN(pad->now.button, BUTTON_START))) { - /* Button combos to get to each register */ - static debug_reg_keycombo_t key_data[DEBUG_REG_MAX] = { - {BUTTON_L, BUTTON_CUP}, /* REG */ - {BUTTON_L, BUTTON_CLEFT}, /* SREG */ - {BUTTON_L, BUTTON_CDOWN}, /* OREG */ - {BUTTON_L, BUTTON_A}, /* PREG */ - {BUTTON_R, BUTTON_CDOWN}, /* QREG */ - {BUTTON_L, BUTTON_CRIGHT}, /* MREG */ - {BUTTON_L, BUTTON_R}, /* SBREG */ - {BUTTON_L, BUTTON_DLEFT}, /* DREG */ - {BUTTON_L, BUTTON_DRIGHT}, /* UREG */ - {BUTTON_L, BUTTON_DUP}, /* IREG */ - {BUTTON_L, BUTTON_B}, /* ZREG */ - {BUTTON_L, BUTTON_Z}, /* CRV */ - {BUTTON_L, BUTTON_DDOWN}, /* NS1 */ - {BUTTON_R, BUTTON_A}, /* SND */ - {BUTTON_R, BUTTON_B}, /* XREG */ - {BUTTON_R, BUTTON_Z}, /* CRV2 */ - {BUTTON_R, BUTTON_L}, /* DEMOREG */ - {BUTTON_R, BUTTON_CUP}, /* TREG */ - {BUTTON_R, BUTTON_CRIGHT}, /* WREG */ - {BUTTON_R, BUTTON_DLEFT}, /* AREG */ - {BUTTON_R, BUTTON_CLEFT}, /* VREG */ - {BUTTON_R, BUTTON_START}, /* HREG */ - {BUTTON_L, BUTTON_START}, /* GREG */ - {BUTTON_R, BUTTON_DRIGHT}, /* mREG */ - {BUTTON_R, BUTTON_DUP}, /* nREG */ - {BUTTON_START, BUTTON_R}, /* BREG */ - {BUTTON_START, BUTTON_A}, /* DORO */ - {BUTTON_START, BUTTON_Y}, /* kREG */ - {BUTTON_START, BUTTON_CRIGHT}, /* BAK */ - {BUTTON_START, BUTTON_CLEFT}, /* PLAYERREG */ - {BUTTON_START, BUTTON_CDOWN}, /* NMREG */ - {BUTTON_START, BUTTON_L}, /* NIIREG */ - {BUTTON_START, BUTTON_Z}, /* GENREG */ - {BUTTON_START, BUTTON_CUP}, /* MYKREG */ - {BUTTON_START, BUTTON_DUP}, /* CAMREG */ - {BUTTON_START, BUTTON_DRIGHT}, /* SAKREG */ - {BUTTON_START, BUTTON_DLEFT}, /* TAKREG */ - {BUTTON_START, BUTTON_DDOWN} /* PL2REG */ - }; + if (zurumode_flag >= 2 && + (PAD_BUTTON_IS_DOWN(pad->now.button, BUTTON_L) || PAD_BUTTON_IS_DOWN(pad->now.button, BUTTON_R) || + PAD_BUTTON_IS_DOWN(pad->now.button, BUTTON_START))) { + /* Button combos to get to each register */ + static debug_reg_keycombo_t key_data[DEBUG_REG_MAX] = { + { BUTTON_L, BUTTON_CUP }, /* REG */ + { BUTTON_L, BUTTON_CLEFT }, /* SREG */ + { BUTTON_L, BUTTON_CDOWN }, /* OREG */ + { BUTTON_L, BUTTON_A }, /* PREG */ + { BUTTON_R, BUTTON_CDOWN }, /* QREG */ + { BUTTON_L, BUTTON_CRIGHT }, /* MREG */ + { BUTTON_L, BUTTON_R }, /* SBREG */ + { BUTTON_L, BUTTON_DLEFT }, /* DREG */ + { BUTTON_L, BUTTON_DRIGHT }, /* UREG */ + { BUTTON_L, BUTTON_DUP }, /* IREG */ + { BUTTON_L, BUTTON_B }, /* ZREG */ + { BUTTON_L, BUTTON_Z }, /* CRV */ + { BUTTON_L, BUTTON_DDOWN }, /* NS1 */ + { BUTTON_R, BUTTON_A }, /* SND */ + { BUTTON_R, BUTTON_B }, /* XREG */ + { BUTTON_R, BUTTON_Z }, /* CRV2 */ + { BUTTON_R, BUTTON_L }, /* DEMOREG */ + { BUTTON_R, BUTTON_CUP }, /* TREG */ + { BUTTON_R, BUTTON_CRIGHT }, /* WREG */ + { BUTTON_R, BUTTON_DLEFT }, /* AREG */ + { BUTTON_R, BUTTON_CLEFT }, /* VREG */ + { BUTTON_R, BUTTON_START }, /* HREG */ + { BUTTON_L, BUTTON_START }, /* GREG */ + { BUTTON_R, BUTTON_DRIGHT }, /* mREG */ + { BUTTON_R, BUTTON_DUP }, /* nREG */ + { BUTTON_START, BUTTON_R }, /* BREG */ + { BUTTON_START, BUTTON_A }, /* DORO */ + { BUTTON_START, BUTTON_Y }, /* kREG */ + { BUTTON_START, BUTTON_CRIGHT }, /* BAK */ + { BUTTON_START, BUTTON_CLEFT }, /* PLAYERREG */ + { BUTTON_START, BUTTON_CDOWN }, /* NMREG */ + { BUTTON_START, BUTTON_L }, /* NIIREG */ + { BUTTON_START, BUTTON_Z }, /* GENREG */ + { BUTTON_START, BUTTON_CUP }, /* MYKREG */ + { BUTTON_START, BUTTON_DUP }, /* CAMREG */ + { BUTTON_START, BUTTON_DRIGHT }, /* SAKREG */ + { BUTTON_START, BUTTON_DLEFT }, /* TAKREG */ + { BUTTON_START, BUTTON_DDOWN } /* PL2REG */ + }; - int i; + int i; - for (i = 0; i < DEBUG_REG_MAX; i++) { - if (PAD_BUTTON_IS_DOWN(pad->now.button, key_data[i].held) && - PAD_BUTTON_IS_DOWN(pad->on.button, key_data[i].pressed)) { - break; - } - } + for (i = 0; i < DEBUG_REG_MAX; i++) { + if (PAD_BUTTON_IS_DOWN(pad->now.button, key_data[i].held) && + PAD_BUTTON_IS_DOWN(pad->on.button, key_data[i].pressed)) { + break; + } + } - if (i < DEBUG_REG_MAX) { - if (i == debug_mode->type) { - /* Switch register group */ - debug_mode->mode = (debug_mode->mode + 1) % (DEBUG_REG_GROUP + 1); + if (i < DEBUG_REG_MAX) { + if (i == debug_mode->type) { + /* Switch register group */ + debug_mode->mode = (debug_mode->mode + 1) % (DEBUG_REG_GROUP + 1); + } else { + /* Switch registers */ + debug_mode->type = i; + debug_mode->mode = 0; + } + } } else { - /* Switch registers */ - debug_mode->type = i; - debug_mode->mode = 0; + int increment; + switch ((int)debug_mode->mode) { + default: + break; + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: { + if (dpad == debug_mode->old_key) { + if (debug_mode->key_wait <= 0) { + debug_mode->key_wait = 1; + } else { + debug_mode->key_wait--; + dpad ^= debug_mode->old_key; + } + } else { + debug_mode->key_wait = 16; + debug_mode->old_key = dpad; + } + + /** + * Register increment key combos: + * - D-Pad Right: positive + * - D-Pad Left: negative + * + * Increment modifiers (held) + * - C-Stick Up: 0x1000 + * - C-Stick Down: 0x100 + * - A + B: 1000 + * - A: 100 + * - B: 10 + * - Default: 1 + **/ + if (dpad & BUTTON_DRIGHT) { + u16 btn = pad->now.button; + if (PAD_BUTTON_IS_DOWN(btn, BUTTON_CUP)) { + increment = 0x1000; + } else if (PAD_BUTTON_IS_DOWN(btn, BUTTON_CDOWN)) { + increment = 0x100; + } else if (PAD_BUTTON_IS_DOWN(btn, BUTTON_A | BUTTON_B)) { + increment = 1000; + } else if (PAD_BUTTON_IS_DOWN(btn, BUTTON_A)) { + increment = 100; + } else { + increment = 1; + if (PAD_BUTTON_IS_DOWN(btn, BUTTON_B)) { + increment = 10; + } + } + } else if (dpad & BUTTON_DLEFT) { + u16 btn = pad->now.button; + if (PAD_BUTTON_IS_DOWN(btn, BUTTON_CUP)) { + increment = -0x1000; + } else if (PAD_BUTTON_IS_DOWN(btn, BUTTON_CDOWN)) { + increment = -0x100; + } else if (PAD_BUTTON_IS_DOWN(btn, BUTTON_A | BUTTON_B)) { + increment = -1000; + } + /* lol the missed duplicated case */ + else if (PAD_BUTTON_IS_DOWN(btn, BUTTON_A | BUTTON_B)) { + increment = -1000; + } else if (PAD_BUTTON_IS_DOWN(btn, BUTTON_A)) { + increment = -100; + } else { + increment = -1; + if (PAD_BUTTON_IS_DOWN(btn, BUTTON_B)) { + increment = -10; + } + } + } else { + increment = 0; + } + + /* Adjust selected register value */ + debug_mode->r[debug_mode->input_r + r_ofs] += increment; + + /* Adjust selected register index */ + if (dpad & BUTTON_DUP) { + if (debug_mode->input_r <= 0) { + debug_mode->input_r = (DEBUG_REG_SIZE - 1); + } else { + debug_mode->input_r--; + } + } else if (dpad & BUTTON_DDOWN) { + if (debug_mode->input_r >= (DEBUG_REG_SIZE - 1)) { + debug_mode->input_r = 0; + } else { + debug_mode->input_r++; + } + } + } break; + } + } + + /* Hayakawa debug functions controlled by previous controller */ + debug_hayakawa_move(pad - 1); + + /** + * Summary of display toggle buttons + * A: + * - bg_draw_status + * - quest_draw_status + * - event_status (non-special) + * - draw_status + * D-Pad Left: + * - event_status (special) + * D-Pad Up: + * - shop_draw_status + * C-Stick Up + * - zelda_malloc_status + * D-Pad Down (zurumode 2 enabled): + * - famicom_status + * (missing: C-Stick Down, perhaps for bg_draw_status2) + * D-Pad Right: + * - npc_draw_status + * C-Stick Right: + * - field_assessment_status + **/ + + if (DEBUG_MODE_CHECK_TRIGGER_GAME(BUTTON_A)) { + bg_draw_status ^= 1; + } + + if (DEBUG_MODE_CHECK_TRIGGER_GAME(BUTTON_A)) { + quest_draw_status ^= 1; + } + + if (DEBUG_MODE_CHECK_TRIGGER_GAME(BUTTON_A)) { + event_status ^= 1; + } + + if (DEBUG_MODE_CHECK_TRIGGER_GAME(BUTTON_DLEFT)) { + event_status ^= 2; + } + + if (DEBUG_MODE_CHECK_TRIGGER_GAME(BUTTON_A)) { + draw_status ^= 1; + } + + if (DEBUG_MODE_CHECK_TRIGGER_GAME(BUTTON_DUP)) { + shop_draw_status ^= 1; + } + + if (DEBUG_MODE_CHECK_TRIGGER_GAME(BUTTON_CUP)) { + zelda_malloc_status ^= 1; + } + + if (zurumode_flag >= 2 && DEBUG_MODE_CHECK_TRIGGER_GAME(BUTTON_DDOWN)) { + famicom_status ^= 1; + } + + if (DEBUG_MODE_CHECK_TRIGGER_GAME(BUTTON_DRIGHT)) { + npc_draw_status ^= 1; + } + + if (DEBUG_MODE_CHECK_TRIGGER_GAME(BUTTON_CRIGHT)) { + field_assessment_status ^= 1; } - } } - else { - int increment; - switch ((int)debug_mode->mode) { - default: - break; - case 1: - case 2: - case 3: - case 4: - case 5: - case 6: { - if (dpad == debug_mode->old_key) { - if (debug_mode->key_wait <= 0) { - debug_mode->key_wait = 1; - } else { - debug_mode->key_wait--; - dpad ^= debug_mode->old_key; - } - } else { - debug_mode->key_wait = 16; - debug_mode->old_key = dpad; - } - - /** - * Register increment key combos: - * - D-Pad Right: positive - * - D-Pad Left: negative - * - * Increment modifiers (held) - * - C-Stick Up: 0x1000 - * - C-Stick Down: 0x100 - * - A + B: 1000 - * - A: 100 - * - B: 10 - * - Default: 1 - **/ - if (dpad & BUTTON_DRIGHT) { - u16 btn = pad->now.button; - if (PAD_BUTTON_IS_DOWN(btn, BUTTON_CUP)) { - increment = 0x1000; - } else if (PAD_BUTTON_IS_DOWN(btn, BUTTON_CDOWN)) { - increment = 0x100; - } else if (PAD_BUTTON_IS_DOWN(btn, BUTTON_A | BUTTON_B)) { - increment = 1000; - } else if (PAD_BUTTON_IS_DOWN(btn, BUTTON_A)) { - increment = 100; - } else { - increment = 1; - if (PAD_BUTTON_IS_DOWN(btn, BUTTON_B)) { - increment = 10; - } - } - } else if (dpad & BUTTON_DLEFT) { - u16 btn = pad->now.button; - if (PAD_BUTTON_IS_DOWN(btn, BUTTON_CUP)) { - increment = -0x1000; - } else if (PAD_BUTTON_IS_DOWN(btn, BUTTON_CDOWN)) { - increment = -0x100; - } else if (PAD_BUTTON_IS_DOWN(btn, BUTTON_A | BUTTON_B)) { - increment = -1000; - } - /* lol the missed duplicated case */ - else if (PAD_BUTTON_IS_DOWN(btn, BUTTON_A | BUTTON_B)) { - increment = -1000; - } else if (PAD_BUTTON_IS_DOWN(btn, BUTTON_A)) { - increment = -100; - } else { - increment = -1; - if (PAD_BUTTON_IS_DOWN(btn, BUTTON_B)) { - increment = -10; - } - } - } else { - increment = 0; - } - - /* Adjust selected register value */ - debug_mode->r[debug_mode->input_r + r_ofs] += increment; - - /* Adjust selected register index */ - if (dpad & BUTTON_DUP) { - if (debug_mode->input_r <= 0) { - debug_mode->input_r = (DEBUG_REG_SIZE - 1); - } else { - debug_mode->input_r--; - } - } else if (dpad & BUTTON_DDOWN) { - if (debug_mode->input_r >= (DEBUG_REG_SIZE - 1)) { - debug_mode->input_r = 0; - } else { - debug_mode->input_r++; - } - } - } break; - } - } - - /* Hayakawa debug functions controlled by previous controller */ - debug_hayakawa_move(pad - 1); - - /** - * Summary of display toggle buttons - * A: - * - bg_draw_status - * - quest_draw_status - * - event_status (non-special) - * - draw_status - * D-Pad Left: - * - event_status (special) - * D-Pad Up: - * - shop_draw_status - * C-Stick Up - * - zelda_malloc_status - * D-Pad Down (zurumode 2 enabled): - * - famicom_status - * (missing: C-Stick Down, perhaps for bg_draw_status2) - * D-Pad Right: - * - npc_draw_status - * C-Stick Right: - * - field_assessment_status - **/ - - if (DEBUG_MODE_CHECK_TRIGGER_GAME(BUTTON_A)) { - bg_draw_status ^= 1; - } - - if (DEBUG_MODE_CHECK_TRIGGER_GAME(BUTTON_A)) { - quest_draw_status ^= 1; - } - - if (DEBUG_MODE_CHECK_TRIGGER_GAME(BUTTON_A)) { - event_status ^= 1; - } - - if (DEBUG_MODE_CHECK_TRIGGER_GAME(BUTTON_DLEFT)) { - event_status ^= 2; - } - - if (DEBUG_MODE_CHECK_TRIGGER_GAME(BUTTON_A)) { - draw_status ^= 1; - } - - if (DEBUG_MODE_CHECK_TRIGGER_GAME(BUTTON_DUP)) { - shop_draw_status ^= 1; - } - - if (DEBUG_MODE_CHECK_TRIGGER_GAME(BUTTON_CUP)) { - zelda_malloc_status ^= 1; - } - - if (zurumode_flag >= 2 && DEBUG_MODE_CHECK_TRIGGER_GAME(BUTTON_DDOWN)) { - famicom_status ^= 1; - } - - if (DEBUG_MODE_CHECK_TRIGGER_GAME(BUTTON_DRIGHT)) { - npc_draw_status ^= 1; - } - - if (DEBUG_MODE_CHECK_TRIGGER_GAME(BUTTON_CRIGHT)) { - field_assessment_status ^= 1; - } - } } static void Debug_mode_output_sub(gfxprint_t* gfxprint) { - static u8 reg_name_data[] = " SOPQMYDUIZCNKXcsiWAVHGmnBdkb*********"; - static char* long_reg_name_data[] = { - "REG", - "SREG", - "OREG", - "PREG", - "QREG", - "MREG", - "SBREG", - "DREG", - "UREG", - "IREG", - "ZREG", - "CRV", - "NS1", - "SND", - "XREG", - "CRV2", - "DEMOREG", - "TREG", - "WREG", - "AREG", - "VREG", - "HREG", - "GREG", - "mREG", - "nREG", - "BREG", - "DORO", - "kREG", - "BAK", - "PLAYERREG", - "NMREG", - "NIIREG", - "GENREG", - "MYKREG", - "CAMREG", - "SAKREG", - "TAKREG", - "PL2REG" - }; + static u8 reg_name_data[38] = " SOPQMYDUIZCNKXcsiWAVHGmnBdkb*********"; + // clang-format off + static char* long_reg_name_data[] = { + "REG", + "SREG", + "OREG", + "PREG", + "QREG", + "MREG", + "SBREG", + "DREG", + "UREG", + "IREG", + "ZREG", + "CRV", + "NS1", + "SND", + "XREG", + "CRV2", + "DEMOREG", + "TREG", + "WREG", + "AREG", + "VREG", + "HREG", + "GREG", + "mREG", + "nREG", + "BREG", + "DORO", + "kREG", + "BAK", + "PLAYERREG", + "NMREG", + "NIIREG", + "GENREG", + "MYKREG", + "CAMREG", + "SAKREG", + "TAKREG", + "PL2REG", + }; + // clang-format on - int i; - int mode; - int adj; - int ofs; + int i; + int mode; + int adj; + int ofs; - mode = (debug_mode->mode - 1); - adj = mode * DEBUG_REG_SIZE; - ofs = (mode + debug_mode->type * DEBUG_REG_GROUP) * DEBUG_REG_SIZE; + mode = (debug_mode->mode - 1); + adj = mode * DEBUG_REG_SIZE; + ofs = (mode + debug_mode->type * DEBUG_REG_GROUP) * DEBUG_REG_SIZE; - gfxprint_color(gfxprint, 0, 128, 128, 128); /* Color -> xlu dark cyan */ - gfxprint_locate8x8(gfxprint, 3, 8); - gfxprint_printf(gfxprint, "%c(%s)", reg_name_data[debug_mode->type], long_reg_name_data[debug_mode->type]); - gfxprint_color(gfxprint, 0, 128, 128, 128); /* Reset color... back to dark cyan? */ + gfxprint_color(gfxprint, 0, 128, 128, 128); /* Color -> xlu dark cyan */ + gfxprint_locate8x8(gfxprint, 3, 8); + gfxprint_printf(gfxprint, "%c(%s)", reg_name_data[debug_mode->type], long_reg_name_data[debug_mode->type]); + gfxprint_color(gfxprint, 0, 128, 128, 128); /* Reset color... back to dark cyan? */ - for (i = 0; i < DEBUG_REG_SIZE; i++) { - if (i == debug_mode->input_r) { - gfxprint_color(gfxprint, 0, 255, 255, 255); /* Color -> opaque cyan */ + for (i = 0; i < DEBUG_REG_SIZE; i++) { + if (i == debug_mode->input_r) { + gfxprint_color(gfxprint, 0, 255, 255, 255); /* Color -> opaque cyan */ + } + + gfxprint_locate8x8(gfxprint, 3, i + 9); + gfxprint_printf(gfxprint, "%02d%6d", i + adj, debug_mode->r[i + ofs]); + + if (i == debug_mode->input_r) { + gfxprint_color(gfxprint, 0, 128, 128, 128); /* Color -> xlu dark cyan */ + } } - - gfxprint_locate8x8(gfxprint, 3, i + 9); - gfxprint_printf(gfxprint, "%02d%6d", i + adj, debug_mode->r[i + ofs]); - - if (i == debug_mode->input_r) { - gfxprint_color(gfxprint, 0, 128, 128, 128); /* Color -> xlu dark cyan */ - } - } } static void Debug_mode_zelda_malloc_info_output(gfxprint_t* gfxprint) { - u32 max, free, alloc; - u32 graph_alloc; + u32 max, free, alloc; + u32 graph_alloc; - if (zelda_MallocIsInitalized()) { - graph_alloc = THA_GA_getFreeBytes(&gamePT->graph->polygon_opaque_thaga); - zelda_GetFreeArena(&max, &free, &alloc); + if (zelda_MallocIsInitalized()) { + graph_alloc = THA_GA_getFreeBytes(&gamePT->graph->polygon_opaque_thaga); + zelda_GetFreeArena(&max, &free, &alloc); - gfxprint_color(gfxprint, 200, 200, 250, 255); /* color -> opaque lilac */ - gfxprint_locate8x8(gfxprint, 3, 23); - gfxprint_printf(gfxprint, "zelda_malloc サイダイアキ%x", max); - gfxprint_locate8x8(gfxprint, 3, 24); - gfxprint_printf(gfxprint, " アキ%x", free); - gfxprint_locate8x8(gfxprint, 3, 25); - gfxprint_printf(gfxprint, "graph_alloc ノコリ %x", graph_alloc); - } + gfxprint_color(gfxprint, 200, 200, 250, 255); /* color -> opaque lilac */ + gfxprint_locate8x8(gfxprint, 3, 23); + gfxprint_printf(gfxprint, "zelda_malloc サイダイアキ%x", max); + gfxprint_locate8x8(gfxprint, 3, 24); + gfxprint_printf(gfxprint, " アキ%x", free); + gfxprint_locate8x8(gfxprint, 3, 25); + gfxprint_printf(gfxprint, "graph_alloc ノコリ %x", graph_alloc); + } } /* sizeof(haniwa_tempo_data) == 6 */ typedef struct { - /* 0x00 */ TempoBeat_c Gt; - /* 0x02 */ TempoBeat_c BS; - /* 0x04 */ TempoBeat_c AS; + /* 0x00 */ TempoBeat_c Gt; + /* 0x02 */ TempoBeat_c BS; + /* 0x04 */ TempoBeat_c AS; } haniwa_tempo_data; static haniwa_tempo_data tempo_data[PLAYER_NUM] = { - { {0, 0}, {0, 0}, {0, 0} }, /* House 0 */ - { {0, 0}, {0, 0}, {0, 0} }, /* House 1 */ - { {0, 0}, {0, 0}, {0, 0} }, /* House 2 */ - { {0, 0}, {0, 0}, {0, 0} } /* House 3 */ + { { 0, 0 }, { 0, 0 }, { 0, 0 } }, /* House 0 */ + { { 0, 0 }, { 0, 0 }, { 0, 0 } }, /* House 1 */ + { { 0, 0 }, { 0, 0 }, { 0, 0 } }, /* House 2 */ + { { 0, 0 }, { 0, 0 }, { 0, 0 } }, /* House 3 */ }; static void DebugHaniwaTempo(gfxprint_t* gfxprint) { - int i; - for (i = 0; i < PLAYER_NUM; i++) { - gfxprint_color(gfxprint, 250, 200, 200, 255); - gfxprint_locate8x8(gfxprint, 3, 23 + i); - gfxprint_printf( - gfxprint, - "S%d,%dGt%d,%dBS%d,%dAS%d,%d", - Save_Get(homes[i].haniwa_tempo.tempo), - Save_Get(homes[i].haniwa_tempo.beat), - tempo_data[i].Gt.tempo, - tempo_data[i].Gt.beat, - tempo_data[i].BS.tempo, - tempo_data[i].BS.beat, - tempo_data[i].AS.tempo, - tempo_data[i].AS.beat - ); - } + int i; + for (i = 0; i < PLAYER_NUM; i++) { + gfxprint_color(gfxprint, 250, 200, 200, 255); + gfxprint_locate8x8(gfxprint, 3, 23 + i); + gfxprint_printf(gfxprint, "S%d,%dGt%d,%dBS%d,%dAS%d,%d", Save_Get(homes[i].haniwa_tempo.tempo), + Save_Get(homes[i].haniwa_tempo.beat), tempo_data[i].Gt.tempo, tempo_data[i].Gt.beat, + tempo_data[i].BS.tempo, tempo_data[i].BS.beat, tempo_data[i].AS.tempo, tempo_data[i].AS.beat); + } } #define GFXLIST_RESERVED_SIZE (int)(512 * sizeof(Gfx)) /* requires 0x1000 bytes, or 512 free Gfx */ extern void Debug_mode_output(GRAPH* graph) { - static int glist_used_bytes; - static int console_position_x; - static int console_position_y; - static int font_scale_select; + static int glist_used_bytes; + static int console_position_x; + static int console_position_y; + static int font_scale_select; - Gfx* start_gfx; - Gfx* last_gfx; - int poly_free_bytes; - int d_col_r; - int d_col_g; - gfxprint_t gfxprint; - gfxprint_t* print_p = &gfxprint; + Gfx* start_gfx; + Gfx* last_gfx; + int poly_free_bytes; + int d_col_r; + int d_col_g; + gfxprint_t gfxprint; + gfxprint_t* print_p = &gfxprint; - debug_hayakawa_draw(graph); - poly_free_bytes = THA_GA_getFreeBytes(&graph->polygon_opaque_thaga); - if (poly_free_bytes >= glist_used_bytes + GFXLIST_RESERVED_SIZE) { - Gfx* gfx; - gfxprint_init(print_p); + debug_hayakawa_draw(graph); + poly_free_bytes = THA_GA_getFreeBytes(&graph->polygon_opaque_thaga); + if (poly_free_bytes >= glist_used_bytes + GFXLIST_RESERVED_SIZE) { + Gfx* gfx; + gfxprint_init(print_p); - OPEN_DISP(graph); + OPEN_DISP(graph); - start_gfx = NOW_POLY_OPA_DISP; - gfx = gfxopen(start_gfx); - gSPDisplayList(NOW_OVERLAY_DISP++, gfx); + start_gfx = NOW_POLY_OPA_DISP; + gfx = gfxopen(start_gfx); + gSPDisplayList(NOW_OVERLAY_DISP++, gfx); - gfxprint_open(print_p, gfx); + gfxprint_open(print_p, gfx); - if (debug_print_flg & DEBUG_MODE_PRINT2_FLAG) { - Debug_Print2_output(print_p); - } - - if (debug_mode->mode != 0) { - Debug_mode_output_sub(print_p); - } - - debug_print2_count = 0; - - if (debug_print_flg & DEBUG_MODE_PRINT_FLAG) { - Debug_Print_output(print_p); - } - - if (debug_mode->mode == 0) { - fuusen_DEBUG_mode_flag = 1; - - if (bg_draw_status & 1) { - mFI_PrintNowBGNum(print_p); - mFI_PrintFgAttr(print_p); - gfxprint_color(print_p, 200, 200, 250, 255); /* color -> lilac */ - gfxprint_locate8x8(print_p, 3, 9); - gfxprint_printf(print_p, "%3d %3d", mPr_GetMoneyPower(), mPr_GetGoodsPower()); - } - - if (quest_draw_status & 1) { - mQst_PrintQuestInfo(print_p); - } - - if (event_status & 1) { - mEv_debug_print4f(print_p); - } - - if (event_status & 2) { - mEv_sp_debug_print4f(print_p); - } - - if (draw_status & 1) { - mMsg_debug_draw(print_p); - } - - if (zurumode_flag >= 2) { - mItemDebug_ItemDebugMain(); - mItemDebug_ItemDebugDraw(print_p); - } - - if (shop_draw_status & 1) { - mSP_PrintNowShopSalesSum(print_p); - DebugHaniwaTempo(print_p); - } - - if (zelda_malloc_status & 1) { - Debug_mode_zelda_malloc_info_output(print_p); - } - - if (zurumode_flag >= 2 && (famicom_status & 1)) { - mRmTp_DrawFamicomInfo(print_p); - mRmTp_MakeFamicom_Fdebug(); - } - - d_col_g = APPNMI_RESETEXEMPT_GET() ? 125 : 250; - d_col_r = zurumode_flag >= 2 ? 125 : 250; - - /** - * debug 'D' colors: - * Base: Yellow - * ResetExempt: Pink - * Zurumode2/Zurumode3: Green - * ResetExempt & Zurumode2/Zurumode3: Blue-gray - */ - gfxprint_color(print_p, d_col_r, d_col_g, 140, 255); - gfxprint_locate8x8(print_p, 36, 3); - gfxprint_printf(print_p, "D"); - - if (npc_draw_status & 1) { - mNpc_PrintRemoveInfo(print_p); - } - - if (field_assessment_status & 1) { - mFAs_PrintFieldAssessment(print_p); - mAGrw_PrintFossilHaniwa_debug(print_p); - - /* Maybe a macro like 'IS_FDEBUG()' */ - if (zurumode_flag >= 2) { - mNpc_PrintFriendship_fdebug(print_p); + if (debug_print_flg & DEBUG_MODE_PRINT2_FLAG) { + Debug_Print2_output(print_p); } - mPr_PrintMapInfo_debug(print_p); - } + if (debug_mode->mode != 0) { + Debug_mode_output_sub(print_p); + } - mFRm_PrintSavedDebug(print_p); - mCD_PrintErrInfo(print_p); - mFRm_display_errInfo(print_p); + debug_print2_count = 0; + + if (debug_print_flg & DEBUG_MODE_PRINT_FLAG) { + Debug_Print_output(print_p); + } + + if (debug_mode->mode == 0) { + fuusen_DEBUG_mode_flag = 1; + + if (bg_draw_status & 1) { + mFI_PrintNowBGNum(print_p); + mFI_PrintFgAttr(print_p); + gfxprint_color(print_p, 200, 200, 250, 255); /* color -> lilac */ + gfxprint_locate8x8(print_p, 3, 9); + gfxprint_printf(print_p, "%3d %3d", mPr_GetMoneyPower(), mPr_GetGoodsPower()); + } + + if (quest_draw_status & 1) { + mQst_PrintQuestInfo(print_p); + } + + if (event_status & 1) { + mEv_debug_print4f(print_p); + } + + if (event_status & 2) { + mEv_sp_debug_print4f(print_p); + } + + if (draw_status & 1) { + mMsg_debug_draw(print_p); + } + + if (zurumode_flag >= 2) { + mItemDebug_ItemDebugMain(); + mItemDebug_ItemDebugDraw(print_p); + } + + if (shop_draw_status & 1) { + mSP_PrintNowShopSalesSum(print_p); + DebugHaniwaTempo(print_p); + } + + if (zelda_malloc_status & 1) { + Debug_mode_zelda_malloc_info_output(print_p); + } + + if (zurumode_flag >= 2 && (famicom_status & 1)) { + mRmTp_DrawFamicomInfo(print_p); + mRmTp_MakeFamicom_Fdebug(); + } + + d_col_g = APPNMI_RESETEXEMPT_GET() ? 125 : 250; + d_col_r = zurumode_flag >= 2 ? 125 : 250; + + /** + * debug 'D' colors: + * Base: Yellow + * ResetExempt: Pink + * Zurumode2/Zurumode3: Green + * ResetExempt & Zurumode2/Zurumode3: Blue-gray + */ + gfxprint_color(print_p, d_col_r, d_col_g, 140, 255); + gfxprint_locate8x8(print_p, 36, 3); + gfxprint_printf(print_p, "D"); + + if (npc_draw_status & 1) { + mNpc_PrintRemoveInfo(print_p); + } + + if (field_assessment_status & 1) { + mFAs_PrintFieldAssessment(print_p); + mAGrw_PrintFossilHaniwa_debug(print_p); + + /* Maybe a macro like 'IS_FDEBUG()' */ + if (zurumode_flag >= 2) { + mNpc_PrintFriendship_fdebug(print_p); + } + + mPr_PrintMapInfo_debug(print_p); + } + + mFRm_PrintSavedDebug(print_p); + mCD_PrintErrInfo(print_p); + mFRm_display_errInfo(print_p); + } + + last_gfx = gfxprint_close(print_p); + gSPEndDisplayList(last_gfx++); + + glist_used_bytes = (int)last_gfx - (int)start_gfx; + gfxclose(start_gfx, last_gfx); + SET_POLY_OPA_DISP(last_gfx); + gfxprint_cleanup(print_p); + + CLOSE_DISP(graph); } - - last_gfx = gfxprint_close(print_p); - gSPEndDisplayList(last_gfx++); - - glist_used_bytes = (int)last_gfx - (int)start_gfx; - gfxclose(start_gfx, last_gfx); - SET_POLY_OPA_DISP(last_gfx); - gfxprint_cleanup(print_p); - - CLOSE_DISP(graph); - } } diff --git a/src/game/m_design_ovl.c b/src/game/m_design_ovl.c index 8e2f7bbd..027a62f5 100644 --- a/src/game/m_design_ovl.c +++ b/src/game/m_design_ovl.c @@ -254,6 +254,8 @@ enum { void mDE_setup_action(mDE_Ovl_c* design_ovl, int param_2); +#define mDE_EXTRACT_COMPONENT(c, s, b) (((c) & (((1 << (b)) - 1)) << (s)) >> (s)) + static void mDE_pallet_RGB5A3_to_RGB24(mDE_Ovl_c* design_ovl) { int i; @@ -262,14 +264,20 @@ static void mDE_pallet_RGB5A3_to_RGB24(mDE_Ovl_c* design_ovl) { if (color & 0x8000) { // fully opaque, a1r5g5b5 - design_ovl->rgb8_pal[i].r = (((color >> 10) & 0x1F) * 255) / 31; - design_ovl->rgb8_pal[i].g = (((color >> 5) & 0x1F) * 255) / 31; - design_ovl->rgb8_pal[i].b = (((color >> 0) & 0x1F) * 255) / 31; + // design_ovl->rgb8_pal[i].r = (((color >> 10) & 0x1F) * 255) / 31; + // design_ovl->rgb8_pal[i].g = (((color >> 5) & 0x1F) * 255) / 31; + // design_ovl->rgb8_pal[i].b = (((color >> 0) & 0x1F) * 255) / 31; + design_ovl->rgb8_pal[i].r = (mDE_EXTRACT_COMPONENT(color, 10, 5) * 255) / 31; + design_ovl->rgb8_pal[i].g = (mDE_EXTRACT_COMPONENT(color, 5, 5) * 255) / 31; + design_ovl->rgb8_pal[i].b = (mDE_EXTRACT_COMPONENT(color, 0, 5) * 255) / 31; } else { // transparent color, a3r4g4b4 - design_ovl->rgb8_pal[i].r = ((color >> 8) & 0xF) * 17; - design_ovl->rgb8_pal[i].g = ((color >> 4) & 0xF) * 17; - design_ovl->rgb8_pal[i].b = ((color >> 0) & 0xF) * 17; + // design_ovl->rgb8_pal[i].r = ((color >> 8) & 0xF) * 17; + // design_ovl->rgb8_pal[i].g = ((color >> 4) & 0xF) * 17; + // design_ovl->rgb8_pal[i].b = ((color >> 0) & 0xF) * 17; + design_ovl->rgb8_pal[i].r = mDE_EXTRACT_COMPONENT(color, 8, 4) * 17; + design_ovl->rgb8_pal[i].g = mDE_EXTRACT_COMPONENT(color, 4, 4) * 17; + design_ovl->rgb8_pal[i].b = mDE_EXTRACT_COMPONENT(color, 0, 4) * 17; } } } diff --git a/src/game/m_eappli.c b/src/game/m_eappli.c index 63530579..8b12e37b 100644 --- a/src/game/m_eappli.c +++ b/src/game/m_eappli.c @@ -13,124 +13,115 @@ static u32 crcTable[256]; static u32 getcrc(u8* data, size_t len) { - u32 crc = CRC32_START_VALUE; - size_t i = 0; + u32 crc = CRC32_START_VALUE; + size_t i = 0; - do { - crc = (crc >> 8) ^ crcTable[(crc ^ data[i]) & 0xFF]; - i++; - } while (i != len); + do { + crc = (crc >> 8) ^ crcTable[(crc ^ data[i]) & 0xFF]; + i++; + } while (i != len); - return crc; + return crc; } static void crcgen() { - int bit; - u32 c; - int i; - - for (i = 0; i < 256; i++) { + u32 c; + int i; int j; - c = i; - - for (j = 0; j < 8; j++) { - bit = c & 1; - c >>= 1; - if (bit) { - c ^= CRC32_POLYNOMIAL; - } - } - crcTable[i] = c; - } + for (i = 0; i < 256; i++) { + c = i; + + for (j = 0; j < 8; j++) { + c = (c & 1) ? ((c >> 1) ^ CRC32_POLYNOMIAL) : (c >> 1); + } + + crcTable[i] = c; + } } static u32 mEA_GetCRC(u8* data, size_t len) { - crcgen(); - return getcrc(data, len); + crcgen(); + return getcrc(data, len); } static void putLEWord(u8* dst, u32 word) { - dst[0] = word >> 0; - dst[1] = word >> 8; - dst[2] = word >> 16; - dst[3] = word >> 24; + dst[0] = word >> 0; + dst[1] = word >> 8; + dst[2] = word >> 16; + dst[3] = word >> 24; } extern void mEA_InitLetterCardE() { - mPr_carde_data_c* carde_data = &Common_Get(now_private)->ecard_letter_data; - lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); + mPr_carde_data_c* carde_data = &Common_Get(now_private)->ecard_letter_data; + lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); - /* only reset if current date isn't same as last scan date */ - u16 year = carde_data->letter_send_date.year; - u8 month = carde_data->letter_send_date.month; - u8 day = carde_data->letter_send_date.day; - if (rtc_time->year != year || rtc_time->month != month || rtc_time->day != day) { - int i; - for (i = 0; i < mPr_ECARD_LETTER_NUM; i++) { - carde_data->card_letters_sent[i] = 0; + /* only reset if current date isn't same as last scan date */ + u16 year = carde_data->letter_send_date.year; + u8 month = carde_data->letter_send_date.month; + u8 day = carde_data->letter_send_date.day; + if (rtc_time->year != year || rtc_time->month != month || rtc_time->day != day) { + int i; + for (i = 0; i < mPr_ECARD_LETTER_NUM; i++) { + carde_data->card_letters_sent[i] = 0; + } } - } } extern int mEA_CheckLetterCardE(int card_no) { - mPr_carde_data_c* card_data = &Common_Get(now_private)->ecard_letter_data; - int index = card_no < mPr_ECARD_NUM ? card_no : mPr_ECARD_NUM - 1; + mPr_carde_data_c* card_data = &Common_Get(now_private)->ecard_letter_data; + int index = card_no < mPr_ECARD_NUM ? card_no : mPr_ECARD_NUM - 1; - if (index == mPr_ECARD_NUM - 1) { - return ((card_data->card_letters_sent[index >> 3] >> (index & 7)) & 1) ? 2 : 0; - } + if (index == mPr_ECARD_NUM - 1) { + return ((card_data->card_letters_sent[index >> 3] >> (index & 7)) & 1) ? 2 : 0; + } - return (card_data->card_letters_sent[index >> 3] >> (index & 7)) & 1; + return (card_data->card_letters_sent[index >> 3] >> (index & 7)) & 1; } extern void mEA_SetLetterCardE(int card_no) { - mPr_carde_data_c* card_data = &Common_Get(now_private)->ecard_letter_data; - int index = card_no < mPr_ECARD_NUM ? card_no : mPr_ECARD_NUM - 1; - lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); + mPr_carde_data_c* card_data = &Common_Get(now_private)->ecard_letter_data; + int index = card_no < mPr_ECARD_NUM ? card_no : mPr_ECARD_NUM - 1; + lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); - card_data->card_letters_sent[index >> 3] |= 1 << (index & 7); - card_data->letter_send_date.year = rtc_time->year; - card_data->letter_send_date.month = rtc_time->month; - card_data->letter_send_date.day = rtc_time->day; + card_data->card_letters_sent[index >> 3] |= 1 << (index & 7); + card_data->letter_send_date.year = rtc_time->year; + card_data->letter_send_date.month = rtc_time->month; + card_data->letter_send_date.day = rtc_time->day; } -#define MY_ORIGINAL_DESIGN_DATA_SIZE (4*(32/2)*32) +#define MY_ORIGINAL_DESIGN_DATA_SIZE (4 * (32 / 2) * 32) extern void mEA_GetCardDLProgram() { - if (Save_Get(scene_no) != SCENE_TITLE_DEMO && Common_Get(carde_program_p) == NULL) { - u32 crc; - - Common_Set(carde_program_size, JW_GetResSizeFileNo(RESOURCE_MY_ORIGINAL) - MY_ORIGINAL_DESIGN_DATA_SIZE); // my_original.bin also contains texture data - Common_Set(carde_program_p, (u8*)zelda_malloc_align(Common_Get(carde_program_size), 32)); - _JW_GetResourceAram(JW_GetAramAddress(RESOURCE_MY_ORIGINAL) + MY_ORIGINAL_DESIGN_DATA_SIZE, Common_Get(carde_program_p), Common_Get(carde_program_size)); - - /* write compressed program size to vpk payload */ - putLEWord( - Common_Get(carde_program_p) + 0x2C, - Common_Get(carde_program_size) - 0x34 - ); + if (Save_Get(scene_no) != SCENE_TITLE_DEMO && Common_Get(carde_program_p) == NULL) { + u32 crc; - /* write vpk CRC32 */ - crc = mEA_GetCRC(Common_Get(carde_program_p) + sizeof(u32), Common_Get(carde_program_size) - sizeof(u32)); - putLEWord( - Common_Get(carde_program_p), - crc - ); - } + Common_Set(carde_program_size, JW_GetResSizeFileNo(RESOURCE_MY_ORIGINAL) - + MY_ORIGINAL_DESIGN_DATA_SIZE); // my_original.bin also contains texture data + Common_Set(carde_program_p, (u8*)zelda_malloc_align(Common_Get(carde_program_size), 32)); + _JW_GetResourceAram(JW_GetAramAddress(RESOURCE_MY_ORIGINAL) + MY_ORIGINAL_DESIGN_DATA_SIZE, + Common_Get(carde_program_p), Common_Get(carde_program_size)); + + /* write compressed program size to vpk payload */ + putLEWord(Common_Get(carde_program_p) + 0x2C, Common_Get(carde_program_size) - 0x34); + + /* write vpk CRC32 */ + crc = mEA_GetCRC(Common_Get(carde_program_p) + sizeof(u32), Common_Get(carde_program_size) - sizeof(u32)); + putLEWord(Common_Get(carde_program_p), crc); + } } extern void mEA_CleanCardDLProgram() { - if (Common_Get(carde_program_p) != NULL) { - zelda_free(Common_Get(carde_program_p)); - Common_Set(carde_program_p, NULL); - Common_Set(carde_program_size, 0); - } + if (Common_Get(carde_program_p) != NULL) { + zelda_free(Common_Get(carde_program_p)); + Common_Set(carde_program_p, NULL); + Common_Set(carde_program_size, 0); + } } extern u8* mEA_dl_carde_program_p() { - return Common_Get(carde_program_p); + return Common_Get(carde_program_p); } extern size_t mEA_dl_carde_program_size() { - return Common_Get(carde_program_size); + return Common_Get(carde_program_size); } diff --git a/src/game/m_editor_ovl.c b/src/game/m_editor_ovl.c index 9d7f7351..2b24413f 100644 --- a/src/game/m_editor_ovl.c +++ b/src/game/m_editor_ovl.c @@ -17,1903 +17,1765 @@ #include "m_lib.h" static u8 mED_ornament_table[] = { - 0x21, 0x3f, 0x03, 0x04, 0x05, 0x06, 0x07, 0x41, - 0x43, 0x0a, 0x0b, 0x0c, 0x45, 0x0e, 0x0f, 0x10, - 0x49, 0x44, 0x4e, 0x14, 0x15, 0x16, 0x17, 0x4f, - 0x8d, 0x1a, 0x1b, 0x1c, 0x55, 0x1d, 0x95, 0x23, - 0x20, 0x00, 0xa4, 0x24, 0x5b, 0x25, 0x26, 0x27, - 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, - 0x18, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x01, - 0x40, 0x02, 0x42, 0x08, 0x11, 0x09, 0x46, 0x47, - 0x48, 0x0d, 0x4a, 0x4b, 0x4c, 0x4d, 0x12, 0x13, - 0x50, 0x51, 0x52, 0x53, 0x54, 0x19, 0x56, 0x57, - 0x58, 0x96, 0x5a, 0x5d, 0x5c, 0x5e, 0x61, 0x5f, - 0x63, 0x1f, 0x62, 0x60, 0x64, 0x7b, 0x66, 0x67, - 0x68, 0x81, 0x6a, 0x6b, 0x6c, 0x6d, 0x87, 0x88, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x8e, 0x76, 0x77, - 0x78, 0x93, 0x7a, 0x7c, 0x7d, 0x7e, 0x65, 0x7f, - 0x80, 0x82, 0x83, 0x84, 0x69, 0x85, 0x86, 0x6e, - 0x89, 0x8a, 0x8b, 0x8c, 0x6f, 0x30, 0x8f, 0x91, - 0x90, 0x92, 0x75, 0x94, 0x79, 0x1e, 0x59, 0x97, - 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, - 0xa0, 0xa1, 0xa3, 0xa2, 0x22, 0xa5, 0xa6, 0xa7, - 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, - 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, - 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, - 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, - 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, - 0xd0, 0xd1, 0xff, 0xd2, 0xd4, 0xd5, 0xd6, 0xd7, - 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, - 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, - 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, - 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, - 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xd3 + // clang-format off + 0x21, 0x3f, 0x03, 0x04, 0x05, 0x06, 0x07, 0x41, + 0x43, 0x0a, 0x0b, 0x0c, 0x45, 0x0e, 0x0f, 0x10, + 0x49, 0x44, 0x4e, 0x14, 0x15, 0x16, 0x17, 0x4f, + 0x8d, 0x1a, 0x1b, 0x1c, 0x55, 0x1d, 0x95, 0x23, + 0x20, 0x00, 0xa4, 0x24, 0x5b, 0x25, 0x26, 0x27, + 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, + 0x18, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, + 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x01, + 0x40, 0x02, 0x42, 0x08, 0x11, 0x09, 0x46, 0x47, + 0x48, 0x0d, 0x4a, 0x4b, 0x4c, 0x4d, 0x12, 0x13, + 0x50, 0x51, 0x52, 0x53, 0x54, 0x19, 0x56, 0x57, + 0x58, 0x96, 0x5a, 0x5d, 0x5c, 0x5e, 0x61, 0x5f, + 0x63, 0x1f, 0x62, 0x60, 0x64, 0x7b, 0x66, 0x67, + 0x68, 0x81, 0x6a, 0x6b, 0x6c, 0x6d, 0x87, 0x88, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x8e, 0x76, 0x77, + 0x78, 0x93, 0x7a, 0x7c, 0x7d, 0x7e, 0x65, 0x7f, + 0x80, 0x82, 0x83, 0x84, 0x69, 0x85, 0x86, 0x6e, + 0x89, 0x8a, 0x8b, 0x8c, 0x6f, 0x30, 0x8f, 0x91, + 0x90, 0x92, 0x75, 0x94, 0x79, 0x1e, 0x59, 0x97, + 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, + 0xa0, 0xa1, 0xa3, 0xa2, 0x22, 0xa5, 0xa6, 0xa7, + 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, + 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, + 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, + 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, + 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, + 0xd0, 0xd1, 0xff, 0xd2, 0xd4, 0xd5, 0xd6, 0xd7, + 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, + 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, + 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, + 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, + 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xd3 + // clang-format on }; static void mED_open_warning_window(Submenu* submenu, mSM_MenuInfo_c* menu_info, int warning) { - mWR_SHOW_WARNING(submenu, warning); - menu_info->proc_status = mSM_OVL_PROC_WAIT; - menu_info->next_proc_status = mSM_OVL_PROC_WAIT; - sAdo_SysTrgStart(0x1003); + mWR_SHOW_WARNING(submenu, warning); + menu_info->proc_status = mSM_OVL_PROC_WAIT; + menu_info->next_proc_status = mSM_OVL_PROC_WAIT; + sAdo_SysTrgStart(0x1003); } static int mED_get_code(mED_Ovl_c* editor_ovl, int col, int row) { - static u8 letterS_table[] = { - 0x21, 0x3f, 0x22, 0x2d, 0x2a, 0x90, 0x27, 0xd0, - 0x3a, 0xd4, 0x71, 0x77, 0x65, 0x72, 0x74, 0x79, - 0x75, 0x69, 0x6f, 0x70, 0x61, 0x73, 0x64, 0x66, - 0x67, 0x68, 0x6a, 0x6b, 0x6c, 0xcd, 0x7a, 0x78, - 0x63, 0x76, 0x62, 0x6e, 0x6d, 0x2c, 0x2e, 0x20 - }; + static u8 letterS_table[] = { + // clang-format off + 0x21, 0x3f, 0x22, 0x2d, 0x2a, 0x90, 0x27, 0xd0, + 0x3a, 0xd4, 0x71, 0x77, 0x65, 0x72, 0x74, 0x79, + 0x75, 0x69, 0x6f, 0x70, 0x61, 0x73, 0x64, 0x66, + 0x67, 0x68, 0x6a, 0x6b, 0x6c, 0xcd, 0x7a, 0x78, + 0x63, 0x76, 0x62, 0x6e, 0x6d, 0x2c, 0x2e, 0x20, + // clang-format on + }; - static u8 letterS_table2[] = { - 0x21, 0x3f, 0x22, 0x2d, 0x2a, 0x90, 0x27, 0xd0, - 0x3a, 0x85, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, - 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, - 0x6f, 0x70, 0x71, 0x72, 0x73, 0xcd, 0x74, 0x75, - 0x76, 0x77, 0x78, 0x79, 0x7a, 0x2c, 0x2e, 0x20 - }; + static u8 letterS_table2[] = { + // clang-format off + 0x21, 0x3f, 0x22, 0x2d, 0x2a, 0x90, 0x27, 0xd0, + 0x3a, 0x85, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, + 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, + 0x6f, 0x70, 0x71, 0x72, 0x73, 0xcd, 0x74, 0x75, + 0x76, 0x77, 0x78, 0x79, 0x7a, 0x2c, 0x2e, 0x20, + // clang-format on + }; - static u8 letterL_table[] = { - 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, - 0x39, 0x30, 0x51, 0x57, 0x45, 0x52, 0x54, 0x59, - 0x55, 0x49, 0x4f, 0x50, 0x41, 0x53, 0x44, 0x46, - 0x47, 0x48, 0x4a, 0x4b, 0x4c, 0xcd, 0x5a, 0x58, - 0x43, 0x56, 0x42, 0x4e, 0x4d, 0x2c, 0x2e, 0x20 - }; + static u8 letterL_table[] = { + // clang-format off + 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, + 0x39, 0x30, 0x51, 0x57, 0x45, 0x52, 0x54, 0x59, + 0x55, 0x49, 0x4f, 0x50, 0x41, 0x53, 0x44, 0x46, + 0x47, 0x48, 0x4a, 0x4b, 0x4c, 0xcd, 0x5a, 0x58, + 0x43, 0x56, 0x42, 0x4e, 0x4d, 0x2c, 0x2e, 0x20, + // clang-format on + }; - static u8 letterL_table2[] = { - 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, - 0x39, 0x30, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, - 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, - 0x4f, 0x50, 0x51, 0x52, 0x53, 0xcd, 0x54, 0x55, - 0x56, 0x57, 0x58, 0x59, 0x5a, 0x2c, 0x2e, 0x20 - }; + static u8 letterL_table2[] = { + // clang-format off + 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, + 0x39, 0x30, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, + 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, + 0x4f, 0x50, 0x51, 0x52, 0x53, 0xcd, 0x54, 0x55, + 0x56, 0x57, 0x58, 0x59, 0x5a, 0x2c, 0x2e, 0x20, + // clang-format on + }; - static u8 sign_table[] = { - 0xd1, 0x3f, 0x22, 0x2d, 0x2a, 0x90, 0x85, 0xd0, - 0x3a, 0xa2, 0x25, 0x26, 0x40, 0x5f, 0xa0, 0xae, - 0x97, 0xc0, 0xc1, 0x3d, 0x28, 0x29, 0x3c, 0x3e, - 0xa5, 0xa6, 0xac, 0xad, 0xb4, 0xcd, 0x1d, 0x1e, - 0x86, 0x98, 0x9b, 0x9c, 0xa1, 0x2c, 0x2e, 0x20 - }; + static u8 sign_table[] = { + // clang-format off + 0xd1, 0x3f, 0x22, 0x2d, 0x2a, 0x90, 0x85, 0xd0, + 0x3a, 0xa2, 0x25, 0x26, 0x40, 0x5f, 0xa0, 0xae, + 0x97, 0xc0, 0xc1, 0x3d, 0x28, 0x29, 0x3c, 0x3e, + 0xa5, 0xa6, 0xac, 0xad, 0xb4, 0xcd, 0x1d, 0x1e, + 0x86, 0x98, 0x9b, 0x9c, 0xa1, 0x2c, 0x2e, 0x20, + // clang-format on + }; - static u8 mark_table[] = { - 0x2b, 0xb9, 0x2f, 0x3b, 0x5c, 0xb8, 0xc6, 0xb6, - 0xb7, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xba, 0xbb, - 0xbc, 0xbd, 0xbe, 0xbf, 0xa7, 0xa8, 0xa9, 0xab, - 0xaa, 0xb5, 0xc2, 0xc3, 0xc4, 0xcd, 0xc7, 0xc8, - 0xc9, 0xca, 0xcb, 0xcc, 0xc5, 0xce, 0xcf, 0x20 - }; + static u8 mark_table[] = { + // clang-format off + 0x2b, 0xb9, 0x2f, 0x3b, 0x5c, 0xb8, 0xc6, 0xb6, + 0xb7, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xba, 0xbb, + 0xbc, 0xbd, 0xbe, 0xbf, 0xa7, 0xa8, 0xa9, 0xab, + 0xaa, 0xb5, 0xc2, 0xc3, 0xc4, 0xcd, 0xc7, 0xc8, + 0xc9, 0xca, 0xcb, 0xcc, 0xc5, 0xce, 0xcf, 0x20, + // clang-format on + }; - static u8* dataS_table[] = { - letterS_table, - sign_table, - mark_table - }; + static u8* dataS_table[] = { letterS_table, sign_table, mark_table }; - static u8* dataS_table2[] = { - letterS_table2, - sign_table, - mark_table - }; + static u8* dataS_table2[] = { letterS_table2, sign_table, mark_table }; - static u8* dataL_table[] = { - letterL_table, - sign_table, - mark_table - }; + static u8* dataL_table[] = { letterL_table, sign_table, mark_table }; - static u8* dataL_table2[] = { - letterL_table2, - sign_table, - mark_table - }; + static u8* dataL_table2[] = { letterL_table2, sign_table, mark_table }; - static u8** data_table[2][2] = { - { dataS_table, dataL_table }, - { dataS_table2, dataL_table2 } - }; + static u8** data_table[2][2] = { { dataS_table, dataL_table }, { dataS_table2, dataL_table2 } }; - u8* table = data_table[editor_ovl->arrange][editor_ovl->shift_mode][editor_ovl->input_mode]; - int idx = col + row * mED_COLUMNS; - - return table[idx]; + u8* table = data_table[editor_ovl->arrange][editor_ovl->shift_mode][editor_ovl->input_mode]; + int idx = col + row * mED_COLUMNS; + + return table[idx]; } static void mED_set_stick_area(mED_Ovl_c* editor_ovl) { - u8 prev_stick_area = editor_ovl->stick_area; + u8 prev_stick_area = editor_ovl->stick_area; - if (gamePT->mcon.adjusted_pR < 0.2f) { - /* Stick is in deadzone */ - editor_ovl->stick_area = mED_STICK_AREA_CENTER; - } - else { - s16 angle = gamePT->mcon.move_angle; + if (gamePT->mcon.adjusted_pR < 0.2f) { + /* Stick is in deadzone */ + editor_ovl->stick_area = mED_STICK_AREA_CENTER; + } else { + s16 angle = gamePT->mcon.move_angle; - /* [-180, -157.5) 22.5 degrees */ - if (angle < DEG2SHORT_ANGLE(-157.5f)) { - editor_ovl->stick_area = mED_STICK_AREA_LEFT; + /* [-180, -157.5) 22.5 degrees */ + if (angle < DEG2SHORT_ANGLE(-157.5f)) { + editor_ovl->stick_area = mED_STICK_AREA_LEFT; + } + /* [-157.5, -112.5) 45 degrees */ + else if (angle >= DEG2SHORT_ANGLE(-157.5f) && angle < DEG2SHORT_ANGLE(-112.5f)) { + editor_ovl->stick_area = prev_stick_area; + } + /* [-112.5, -67.5) 45 degrees */ + else if (angle < DEG2SHORT_ANGLE(-67.5f)) { + editor_ovl->stick_area = mED_STICK_AREA_BOTTOM; + } + /* [-67.5, -22.5) 45 degrees */ + else if (angle < DEG2SHORT_ANGLE(-22.5f)) { + editor_ovl->stick_area = prev_stick_area; + } + /* [-22.5, 22.5) 45 degrees */ + else if (angle < DEG2SHORT_ANGLE(22.5f)) { + editor_ovl->stick_area = mED_STICK_AREA_RIGHT; + } + /* [22.5, 67.5) 45 degrees */ + else if (angle < DEG2SHORT_ANGLE(67.5f)) { + editor_ovl->stick_area = prev_stick_area; + } + /* [67.5, 112.5) 45 degrees */ + else if (angle < DEG2SHORT_ANGLE(112.5f)) { + editor_ovl->stick_area = mED_STICK_AREA_TOP; + } + /* [112.5, 157.5) 45 degrees */ + else if (angle < DEG2SHORT_ANGLE(157.5f)) { + editor_ovl->stick_area = prev_stick_area; + } + /* [157.5, 180] 22.5 degrees */ + else { + editor_ovl->stick_area = mED_STICK_AREA_LEFT; + } } - /* [-157.5, -112.5) 45 degrees */ - else if (angle >= DEG2SHORT_ANGLE(-157.5f) && angle < DEG2SHORT_ANGLE(-112.5f)) { - editor_ovl->stick_area = prev_stick_area; - } - /* [-112.5, -67.5) 45 degrees */ - else if (angle < DEG2SHORT_ANGLE( -67.5f)) { - editor_ovl->stick_area = mED_STICK_AREA_BOTTOM; - } - /* [-67.5, -22.5) 45 degrees */ - else if (angle < DEG2SHORT_ANGLE( -22.5f)) { - editor_ovl->stick_area = prev_stick_area; - } - /* [-22.5, 22.5) 45 degrees */ - else if (angle < DEG2SHORT_ANGLE( 22.5f)) { - editor_ovl->stick_area = mED_STICK_AREA_RIGHT; - } - /* [22.5, 67.5) 45 degrees */ - else if (angle < DEG2SHORT_ANGLE( 67.5f)) { - editor_ovl->stick_area = prev_stick_area; - } - /* [67.5, 112.5) 45 degrees */ - else if (angle < DEG2SHORT_ANGLE( 112.5f)) { - editor_ovl->stick_area = mED_STICK_AREA_TOP; - } - /* [112.5, 157.5) 45 degrees */ - else if (angle < DEG2SHORT_ANGLE( 157.5f)) { - editor_ovl->stick_area = prev_stick_area; - } - /* [157.5, 180] 22.5 degrees */ - else { - editor_ovl->stick_area = mED_STICK_AREA_LEFT; - } - } - if (editor_ovl->stick_area != prev_stick_area) { - editor_ovl->stick_area_changed = TRUE; - } - else { - editor_ovl->stick_area_changed = FALSE; - } + if (editor_ovl->stick_area != prev_stick_area) { + editor_ovl->stick_area_changed = TRUE; + } else { + editor_ovl->stick_area_changed = FALSE; + } } static int mED_check_pw_usable_letter_sub(u8 letter) { - static u8 usable_str_table[] = { - 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, - 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, - 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, - 0x59, 0x5a, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, - 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, - 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, - 0x77, 0x78, 0x79, 0x7a, 0x25, 0x26, 0xd1, 0x40, - 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39 - }; + static u8 usable_str_table[] = { + // clang-format off + 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, + 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, + 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, + 0x59, 0x5a, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, + 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, + 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, + 0x77, 0x78, 0x79, 0x7a, 0x25, 0x26, 0xd1, 0x40, + 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, + // clang-format on + }; - int res = FALSE; - u8* useable_p; - int i; + int i; + int res = FALSE; - switch (letter) { - case CHAR_ZERO: - letter = CHAR_O; - break; - case CHAR_ONE: - letter = CHAR_l; - break; - } - - useable_p = usable_str_table; - for (i = 0; i < ARRAY_COUNT(usable_str_table); i++) { - if (letter == *useable_p) { - res = TRUE; - break; + switch (letter) { + case CHAR_ZERO: + letter = CHAR_O; + break; + case CHAR_ONE: + letter = CHAR_l; + break; } - useable_p++; - } + for (i = 0; i < ARRAY_COUNT(usable_str_table); i++) { + if (letter == usable_str_table[i]) { + res = TRUE; + break; + } + } - return res; + return res; } static int mED_check_pw_usable_letter(mPC_Ovl_c* passwordChk_ovl) { - u8* line; - int i; - int res = TRUE; - - line = passwordChk_ovl->line0; - for (i = 0; i < ARRAY_COUNT(passwordChk_ovl->line0); i++) { - if (mED_check_pw_usable_letter_sub(*line) == FALSE) { - res = FALSE; - break; + u8* line; + int i; + int res = TRUE; + + line = passwordChk_ovl->line0; + for (i = 0; i < ARRAY_COUNT(passwordChk_ovl->line0); i++) { + if (mED_check_pw_usable_letter_sub(*line) == FALSE) { + res = FALSE; + break; + } + + line++; } - line++; - } + line = passwordChk_ovl->line1; + for (i = 0; i < ARRAY_COUNT(passwordChk_ovl->line1); i++) { + if (mED_check_pw_usable_letter_sub(*line) == FALSE) { + res = FALSE; + break; + } - line = passwordChk_ovl->line1; - for (i = 0; i < ARRAY_COUNT(passwordChk_ovl->line1); i++) { - if (mED_check_pw_usable_letter_sub(*line) == FALSE) { - res = FALSE; - break; + line++; } - line++; - } - - return res; + return res; } static void mED_move_keyboard_cursor(mED_Ovl_c* editor_ovl) { - static int add_w[mED_STICK_AREA_NUM] = { - -1, - 0, - 0, - 0, - 1, - 0, - 0, - 0, - 0 - }; + static int add_w[mED_STICK_AREA_NUM] = { -1, 0, 0, 0, 1, 0, 0, 0, 0 }; - static int add_h[mED_STICK_AREA_NUM] = { - 0, - 0, - -1, - 0, - 0, - 0, - 1, - 0, - 0 - }; + static int add_h[mED_STICK_AREA_NUM] = { 0, 0, -1, 0, 0, 0, 1, 0, 0 }; - int move = FALSE; - int stick_area = editor_ovl->stick_area; + int move = FALSE; + int stick_area = editor_ovl->stick_area; - if (stick_area != mED_STICK_AREA_CENTER) { - if (editor_ovl->stick_area_changed == TRUE) { - editor_ovl->stick_area_held_frames = 0; - move = TRUE; - } - else { - editor_ovl->stick_area_held_frames++; + if (stick_area != mED_STICK_AREA_CENTER) { + if (editor_ovl->stick_area_changed == TRUE) { + editor_ovl->stick_area_held_frames = 0; + move = TRUE; + } else { + editor_ovl->stick_area_held_frames++; - if (editor_ovl->stick_area_held_frames >= 16) { - editor_ovl->stick_area_held_frames = 12; - move = TRUE; - } - } - } - - if (move == TRUE) { - int move2 = TRUE; - int next_col = editor_ovl->select_col + add_w[stick_area]; - int next_row = editor_ovl->select_row + add_h[stick_area]; - - if (next_col < 0) { - next_col = 0; - move2 = FALSE; - } - else if (next_col >= mED_COLUMNS) { - next_col = mED_COLUMNS - 1; - move2 = FALSE; + if (editor_ovl->stick_area_held_frames >= 16) { + editor_ovl->stick_area_held_frames = 12; + move = TRUE; + } + } } - if (next_row < 0) { - next_row = 0; - move2 = FALSE; - } - else if (next_row >= mED_ROWS) { - next_row = mED_ROWS - 1; - move2 = FALSE; - } + if (move == TRUE) { + int move2 = TRUE; + int next_col = editor_ovl->select_col + add_w[stick_area]; + int next_row = editor_ovl->select_row + add_h[stick_area]; - editor_ovl->select_col = next_col; - editor_ovl->select_row = next_row; + if (next_col < 0) { + next_col = 0; + move2 = FALSE; + } else if (next_col >= mED_COLUMNS) { + next_col = mED_COLUMNS - 1; + move2 = FALSE; + } - if (move2 == TRUE) { - sAdo_SysTrgStart(0x411); + if (next_row < 0) { + next_row = 0; + move2 = FALSE; + } else if (next_row >= mED_ROWS) { + next_row = mED_ROWS - 1; + move2 = FALSE; + } + + editor_ovl->select_col = next_col; + editor_ovl->select_row = next_row; + + if (move2 == TRUE) { + sAdo_SysTrgStart(0x411); + } } - } } static int mED_check_move_cursol(mED_Ovl_c* editor_ovl) { - u32 buttons = (getButton() | getTrigger()) & (BUTTON_B | BUTTON_DRIGHT | BUTTON_DLEFT | BUTTON_DDOWN | BUTTON_DUP); - int res = 0; + u32 buttons = (getButton() | getTrigger()) & (BUTTON_B | BUTTON_DRIGHT | BUTTON_DLEFT | BUTTON_DDOWN | BUTTON_DUP); + int res = 0; - if (buttons == BUTTON_NONE) { - editor_ovl->last_buttons = 0; - editor_ovl->_10 = 30; - editor_ovl->_0F = 26; - editor_ovl->_0E = 0; - } - else { - if (buttons == editor_ovl->last_buttons) { - if (editor_ovl->_0E == 1 && editor_ovl->_0F != 0) { - editor_ovl->_0F--; - } + if (buttons == BUTTON_NONE) { + editor_ovl->last_buttons = 0; + editor_ovl->_10 = 30; + editor_ovl->_0F = 26; + editor_ovl->_0E = 0; + } else { + if (buttons == editor_ovl->last_buttons) { + if (editor_ovl->_0E == 1 && editor_ovl->_0F != 0) { + editor_ovl->_0F--; + } - if (editor_ovl->_10 != 0) { - editor_ovl->_10--; - return mED_COMMAND_9; - } + if (editor_ovl->_10 != 0) { + editor_ovl->_10--; + return mED_COMMAND_9; + } - if (editor_ovl->_0F == 0) { - editor_ovl->_10 = 2; - editor_ovl->_34 = 3; - } - else { - editor_ovl->_10 = 6; - editor_ovl->_0E = 1; - editor_ovl->_34 = 2; - } - } - else { - editor_ovl->last_buttons = buttons; - editor_ovl->_10 = 30; - editor_ovl->_0F = 26; - editor_ovl->_0E = 0; + if (editor_ovl->_0F == 0) { + editor_ovl->_10 = 2; + editor_ovl->_34 = 3; + } else { + editor_ovl->_10 = 6; + editor_ovl->_0E = 1; + editor_ovl->_34 = 2; + } + } else { + editor_ovl->last_buttons = buttons; + editor_ovl->_10 = 30; + editor_ovl->_0F = 26; + editor_ovl->_0E = 0; + } + + if ((buttons & BUTTON_B) != 0) { + res = mED_COMMAND_BACKSPACE; + } else if ((buttons & BUTTON_DLEFT) != 0) { + res = mED_COMMAND_CURSOL_LEFT; + } else if ((buttons & BUTTON_DDOWN) != 0) { + res = mED_COMMAND_CURSOL_LOWER; + } else if ((buttons & BUTTON_DUP) != 0) { + res = mED_COMMAND_CURSOL_UPPER; + } else if ((buttons & BUTTON_DRIGHT) != 0) { + res = mED_COMMAND_CURSOL_RIGHT; + } } - if ((buttons & BUTTON_B) != 0) { - res = mED_COMMAND_BACKSPACE; - } - else if ((buttons & BUTTON_DLEFT) != 0) { - res = mED_COMMAND_CURSOL_LEFT; - } - else if ((buttons & BUTTON_DDOWN) != 0) { - res = mED_COMMAND_CURSOL_LOWER; - } - else if ((buttons & BUTTON_DUP) != 0) { - res = mED_COMMAND_CURSOL_UPPER; - } - else if ((buttons & BUTTON_DRIGHT) != 0) { - res = mED_COMMAND_CURSOL_RIGHT; - } - } - - return res; + return res; } static int mED_check_shift(mED_Ovl_c* editor_ovl) { - int res = FALSE; + int res = FALSE; - if (chkTrigger(BUTTON_L)) { - if (editor_ovl->shift_mode == mED_SHIFT_LOWER) { - editor_ovl->shift_mode = mED_SHIFT_UPPER; - } - else { - editor_ovl->shift_mode = mED_SHIFT_LOWER; + if (chkTrigger(BUTTON_L)) { + if (editor_ovl->shift_mode == mED_SHIFT_LOWER) { + editor_ovl->shift_mode = mED_SHIFT_UPPER; + } else { + editor_ovl->shift_mode = mED_SHIFT_LOWER; + } + + res = TRUE; } - res = TRUE; - } - - return res; + return res; } static int mED_check_arrange(mED_Ovl_c* editor_ovl) { - int res = FALSE; + int res = FALSE; - if (chkTrigger(BUTTON_Z)) { - if (editor_ovl->arrange == mED_ARRANGE_QWERTY) { - editor_ovl->arrange = mED_ARRANGE_ALPHA; - } - else { - editor_ovl->arrange = mED_ARRANGE_QWERTY; + if (chkTrigger(BUTTON_Z)) { + if (editor_ovl->arrange == mED_ARRANGE_QWERTY) { + editor_ovl->arrange = mED_ARRANGE_ALPHA; + } else { + editor_ovl->arrange = mED_ARRANGE_QWERTY; + } + + res = TRUE; } - res = TRUE; - } - - return res; + return res; } static int mED_check_input_mode(mED_Ovl_c* editor_ovl) { - int res = FALSE; + int res = FALSE; - if (chkTrigger(BUTTON_Y)) { - editor_ovl->input_mode++; - editor_ovl->shift_mode = mED_SHIFT_LOWER; + if (chkTrigger(BUTTON_Y)) { + editor_ovl->input_mode++; + editor_ovl->shift_mode = mED_SHIFT_LOWER; - if (editor_ovl->input_mode >= mED_INPUT_MODE_NUM) { - editor_ovl->input_mode = mED_INPUT_MODE_LETTER; + if (editor_ovl->input_mode >= mED_INPUT_MODE_NUM) { + editor_ovl->input_mode = mED_INPUT_MODE_LETTER; + } + + res = TRUE; } - res = TRUE; - } - - return res; + return res; } static int mED_check_now_code(mED_Ovl_c* editor_ovl) { - int res = FALSE; + int res = FALSE; - if (chkTrigger(BUTTON_A)) { - int code = mED_get_code(editor_ovl, editor_ovl->select_col, editor_ovl->select_row); + if (chkTrigger(BUTTON_A)) { + int code = mED_get_code(editor_ovl, editor_ovl->select_col, editor_ovl->select_row); - if (code != CHAR_SPACE_3) { - editor_ovl->now_code = code; - res = TRUE; + if (code != CHAR_SPACE_3) { + editor_ovl->now_code = code; + res = TRUE; + } + } else if (chkTrigger(BUTTON_R)) { + editor_ovl->now_code = CHAR_SPACE; + res = TRUE; } - } - else if (chkTrigger(BUTTON_R)) { - editor_ovl->now_code = CHAR_SPACE; - res = TRUE; - } - return res; + return res; } static int mED_check_output_code(mED_Ovl_c* editor_ovl) { - int res = mED_COMMAND_NONE; + int res = mED_COMMAND_NONE; - if (mED_check_shift(editor_ovl) == TRUE) { - if (editor_ovl->input_mode == mED_INPUT_MODE_LETTER) { - sAdo_SysTrgStart(0x37); + if (mED_check_shift(editor_ovl) == TRUE) { + if (editor_ovl->input_mode == mED_INPUT_MODE_LETTER) { + sAdo_SysTrgStart(0x37); + } + } else if (mED_check_arrange(editor_ovl) == TRUE) { + sAdo_SysTrgStart(0x37); + } else if (mED_check_input_mode(editor_ovl) == TRUE) { + sAdo_SysTrgStart(0x37); + } else if (mED_check_now_code(editor_ovl) == TRUE) { + res = mED_COMMAND_OUTPUT_CODE; } - } - else if (mED_check_arrange(editor_ovl) == TRUE) { - sAdo_SysTrgStart(0x37); - } - else if (mED_check_input_mode(editor_ovl) == TRUE) { - sAdo_SysTrgStart(0x37); - } - else if (mED_check_now_code(editor_ovl) == TRUE) { - res = mED_COMMAND_OUTPUT_CODE; - } - return res; + return res; } static void mED_set_command(mED_Ovl_c* editor_ovl) { - if (chkTrigger(BUTTON_START)) { - editor_ovl->command = mED_COMMAND_END_EDIT; - } - else if (chkTrigger(BUTTON_X)) { - editor_ovl->command = mED_COMMAND_EXCHANGE_CODE; - } - else { - editor_ovl->command = mED_check_move_cursol(editor_ovl); + if (chkTrigger(BUTTON_START)) { + editor_ovl->command = mED_COMMAND_END_EDIT; + } else if (chkTrigger(BUTTON_X)) { + editor_ovl->command = mED_COMMAND_EXCHANGE_CODE; + } else { + editor_ovl->command = mED_check_move_cursol(editor_ovl); - if (editor_ovl->command == mED_COMMAND_NONE) { - editor_ovl->command = mED_check_output_code(editor_ovl); + if (editor_ovl->command == mED_COMMAND_NONE) { + editor_ovl->command = mED_check_output_code(editor_ovl); + } } - } } -static int mED_get_col_line_width(mSM_MenuInfo_c* menu_info, mED_Ovl_c* editor_ovl, s16* param_3, s16* param_4, s16* param_5, int max) { - u8* str_p = editor_ovl->input_str; - int i; - s16 temp0; - s16 temp1; - int cut; - int res; +static int mED_get_col_line_width(mSM_MenuInfo_c* menu_info, mED_Ovl_c* editor_ovl, s16* param_3, s16* param_4, + s16* param_5, int max) { + u8* str_p = editor_ovl->input_str; + int i; + s16 temp0; + s16 temp1; + int cut; + int res; - temp0 = 0; - temp1 = 0; + temp0 = 0; + temp1 = 0; - cut = TRUE; - param_4[0] = 0; - param_3[0] = 0; - param_5[0] = 0; - res = mED_LINE_OK; + cut = TRUE; + param_4[0] = 0; + param_3[0] = 0; + param_5[0] = 0; + res = mED_LINE_OK; - if (menu_info->data0 == mED_TYPE_PASSWORDCHK) { - cut = FALSE; - } - - for (i = 0; i < max; i++) { - int temp_res; - - if (*str_p == CHAR_NEW_LINE) { - temp0 = *param_3; - temp1 = *param_5; - param_3[0] = 0; - param_5[0] = 0; - param_4[0]++; - temp_res = mED_LINE_NEWLINE; - } - else { - s16 width = mFont_GetCodeWidth(*str_p, cut); - s16 t = *param_5; - - if (t + width > editor_ovl->line_width) { - temp0 = *param_3; - temp1 = t; - param_3[0] = 1; - param_5[0] = width; - param_4[0]++; - temp_res = mED_LINE_WIDTH_OVER; - } - else { - param_3[0]++; - param_5[0] += width; - temp_res = mED_LINE_OK; - } + if (menu_info->data0 == mED_TYPE_PASSWORDCHK) { + cut = FALSE; } - if (*param_4 >= editor_ovl->max_line_no) { - param_3[0] = temp0 + 1; - param_4[0] = editor_ovl->max_line_no - 1; - param_5[0] = temp1; + for (i = 0; i < max; i++) { + int temp_res; - if (temp_res == mED_LINE_OK) { - res = mED_LINE_NUM_OVER; - } - else { - res = temp_res; - } + if (*str_p == CHAR_NEW_LINE) { + temp0 = *param_3; + temp1 = *param_5; + param_3[0] = 0; + param_5[0] = 0; + param_4[0]++; + temp_res = mED_LINE_NEWLINE; + } else { + s16 width = mFont_GetCodeWidth(*str_p, cut); + s16 t = *param_5; - break; + if (t + width > editor_ovl->line_width) { + temp0 = *param_3; + temp1 = t; + param_3[0] = 1; + param_5[0] = width; + param_4[0]++; + temp_res = mED_LINE_WIDTH_OVER; + } else { + param_3[0]++; + param_5[0] += width; + temp_res = mED_LINE_OK; + } + } + + if (*param_4 >= editor_ovl->max_line_no) { + param_3[0] = temp0 + 1; + param_4[0] = editor_ovl->max_line_no - 1; + param_5[0] = temp1; + + if (temp_res == mED_LINE_OK) { + res = mED_LINE_NUM_OVER; + } else { + res = temp_res; + } + + break; + } + + str_p++; } - str_p++; - } - - return res; + return res; } static void mED_check_line_over(mED_Ovl_c* editor_ovl) { - if ( - editor_ovl->max_line_no > 1 && - editor_ovl->_24 < (editor_ovl->max_line_no - 1) && - editor_ovl->input_str[editor_ovl->cursor_idx] != CHAR_NEW_LINE - ) { - s16 width = mFont_GetCodeWidth(editor_ovl->input_str[editor_ovl->cursor_idx], TRUE); + if (editor_ovl->max_line_no > 1 && editor_ovl->_24 < (editor_ovl->max_line_no - 1) && + editor_ovl->input_str[editor_ovl->cursor_idx] != CHAR_NEW_LINE) { + s16 width = mFont_GetCodeWidth(editor_ovl->input_str[editor_ovl->cursor_idx], TRUE); - if ((editor_ovl->_26 + width) > editor_ovl->line_width) { - editor_ovl->_22 = 0; - editor_ovl->_26 = 0; - editor_ovl->_24++; + if ((editor_ovl->_26 + width) > editor_ovl->line_width) { + editor_ovl->_22 = 0; + editor_ovl->_26 = 0; + editor_ovl->_24++; + } } - } } static void mED_set_idxcol_inLineWidth(mED_Ovl_c* editor_ovl) { - u8* str_p = editor_ovl->input_str; - int i; - int _22; - int _26; - int lines; - int r25; - int r24; - int r23; - int _24; + u8* str_p = editor_ovl->input_str; + int i; + int _22; + int _26; + int lines; + int r25; + int r24; + int r23; + int _24; - _22 = 0; - lines = 0; - _26 = 0; - r25 = 0; - r23 = 0; - r24 = 0; - _24 = editor_ovl->_24; + _22 = 0; + lines = 0; + _26 = 0; + r25 = 0; + r23 = 0; + r24 = 0; + _24 = editor_ovl->_24; - for (i = 0; i < editor_ovl->now_str_len; i++) { - if (*str_p == CHAR_NEW_LINE) { - _26 = 0; - _22 = 0; - lines++; - } - else { - int width = mFont_GetCodeWidth(*str_p, TRUE); + for (i = 0; i < editor_ovl->now_str_len; i++) { + if (*str_p == CHAR_NEW_LINE) { + _26 = 0; + _22 = 0; + lines++; + } else { + int width = mFont_GetCodeWidth(*str_p, TRUE); - if ((_26 + width) > editor_ovl->line_width) { - r23 = lines + 1; - _26 = width; - r25 = 0; - r24 = 0; - _22 = 1; - lines++; - } - else { - _26 += width; - } - } - - if (lines > _24) { - if (r23 == _24) { - _26 = r24; - _22 = r25; - } - - break; - } - else if (lines == _24) { - int temp = editor_ovl->_26; - - if (_26 >= temp) { - if (r23 == _24 && (temp - r24) < (_26 - temp)) { - _26 = r24; - _22 = r25; - i--; + if ((_26 + width) > editor_ovl->line_width) { + r23 = lines + 1; + _26 = width; + r25 = 0; + r24 = 0; + _22 = 1; + lines++; + } else { + _26 += width; + } } + if (lines > _24) { + if (r23 == _24) { + _26 = r24; + _22 = r25; + } + + break; + } else if (lines == _24) { + int temp = editor_ovl->_26; + + if (_26 >= temp) { + if (r23 == _24 && (temp - r24) < (_26 - temp)) { + _26 = r24; + _22 = r25; + i--; + } + + _22++; + i++; + break; + } + } + + r25 = _22; + r23 = lines; + r24 = _26; + str_p++; _22++; - i++; - break; - } } - r25 = _22; - r23 = lines; - r24 = _26; - str_p++; - _22++; - } - - editor_ovl->_26 = _26; - editor_ovl->cursor_idx = i; - editor_ovl->_22 = _22; + editor_ovl->_26 = _26; + editor_ovl->cursor_idx = i; + editor_ovl->_22 = _22; } static void mED_init(Submenu* submenu, mSM_MenuInfo_c* menu_info) { - static s16 edit_line[mED_TYPE_NUM] = { - 6, - 4, - 6, - 1, - 1, - 31, - 1, - 1 - }; - - mED_Ovl_c* editor_ovl = submenu->overlay->editor_ovl; + static s16 edit_line[mED_TYPE_NUM] = { 6, 4, 6, 1, 1, 31, 1, 1 }; - editor_ovl->stick_area = mED_STICK_AREA_CENTER; - editor_ovl->stick_area_changed = FALSE; - editor_ovl->input_mode = mED_INPUT_MODE_LETTER; - editor_ovl->shift_mode = mED_SHIFT_LOWER; - editor_ovl->arrange = mED_ARRANGE_QWERTY; - editor_ovl->select_col = 0; - editor_ovl->select_row = 0; - editor_ovl->stick_area_held_frames = 0; - editor_ovl->command = mED_COMMAND_NONE; - editor_ovl->now_code = 0; - editor_ovl->max_line_no = edit_line[menu_info->data0]; - editor_ovl->input_str = (u8*)menu_info->data2; - editor_ovl->line_width = menu_info->data3; + mED_Ovl_c* editor_ovl = submenu->overlay->editor_ovl; - if (menu_info->data1 > 0) { - editor_ovl->input_length = menu_info->data1; - - if (menu_info->data0 == mED_TYPE_DIARY) { - editor_ovl->now_str_len = mDi_strlen(editor_ovl->input_str, editor_ovl->input_length * editor_ovl->max_line_no, CHAR_SPACE); - } - else { - editor_ovl->now_str_len = mMl_strlen(editor_ovl->input_str, editor_ovl->input_length * editor_ovl->max_line_no, CHAR_SPACE); - } - } - else { - int type = menu_info->data0; - - if (type == mED_TYPE_BOARD) { - editor_ovl->input_length = 32; - editor_ovl->now_str_len = submenu->overlay->board_ovl->lengths[mBD_FIELD_BODY]; - } - else if (type == mED_TYPE_PASSWORDMAKE) { - editor_ovl->input_length = LAND_NAME_SIZE; - editor_ovl->now_str_len = submenu->overlay->passwordMake_ovl->lengths[mPM_ENTRY_TOWN]; - } - else if (type == mED_TYPE_PASSWORDCHK) { - editor_ovl->input_length = mPC_STR_SIZE; - editor_ovl->now_str_len = mPC_STR_SIZE; - } - } - - if (menu_info->data0 == mED_TYPE_DIARY) { - mDI_Ovl_c* diary_ovl = submenu->overlay->diary_ovl; + editor_ovl->stick_area = mED_STICK_AREA_CENTER; + editor_ovl->stick_area_changed = FALSE; + editor_ovl->input_mode = mED_INPUT_MODE_LETTER; + editor_ovl->shift_mode = mED_SHIFT_LOWER; + editor_ovl->arrange = mED_ARRANGE_QWERTY; + editor_ovl->select_col = 0; + editor_ovl->select_row = 0; + editor_ovl->stick_area_held_frames = 0; + editor_ovl->command = mED_COMMAND_NONE; + editor_ovl->now_code = 0; + editor_ovl->max_line_no = edit_line[menu_info->data0]; + editor_ovl->input_str = (u8*)menu_info->data2; + editor_ovl->line_width = menu_info->data3; if (menu_info->data1 > 0) { - editor_ovl->cursor_idx = editor_ovl->now_str_len; - mED_get_col_line_width(menu_info, editor_ovl, &editor_ovl->_22, &editor_ovl->_24, &editor_ovl->_26, editor_ovl->cursor_idx); - } - else { - editor_ovl->cursor_idx = diary_ovl->cursor_idx; - editor_ovl->_22 = diary_ovl->_48; - editor_ovl->_24 = diary_ovl->_46; - mED_set_idxcol_inLineWidth(editor_ovl); - } - } - else { - editor_ovl->cursor_idx = 0; - editor_ovl->_22 = 0; - editor_ovl->_24 = 0; - editor_ovl->_26 = 0; - } + editor_ovl->input_length = menu_info->data1; - editor_ovl->exchange_code = -1; + if (menu_info->data0 == mED_TYPE_DIARY) { + editor_ovl->now_str_len = + mDi_strlen(editor_ovl->input_str, editor_ovl->input_length * editor_ovl->max_line_no, CHAR_SPACE); + } else { + editor_ovl->now_str_len = + mMl_strlen(editor_ovl->input_str, editor_ovl->input_length * editor_ovl->max_line_no, CHAR_SPACE); + } + } else { + int type = menu_info->data0; + + if (type == mED_TYPE_BOARD) { + editor_ovl->input_length = 32; + editor_ovl->now_str_len = submenu->overlay->board_ovl->lengths[mBD_FIELD_BODY]; + } else if (type == mED_TYPE_PASSWORDMAKE) { + editor_ovl->input_length = LAND_NAME_SIZE; + editor_ovl->now_str_len = submenu->overlay->passwordMake_ovl->lengths[mPM_ENTRY_TOWN]; + } else if (type == mED_TYPE_PASSWORDCHK) { + editor_ovl->input_length = mPC_STR_SIZE; + editor_ovl->now_str_len = mPC_STR_SIZE; + } + } + + if (menu_info->data0 == mED_TYPE_DIARY) { + mDI_Ovl_c* diary_ovl = submenu->overlay->diary_ovl; + + if (menu_info->data1 > 0) { + editor_ovl->cursor_idx = editor_ovl->now_str_len; + mED_get_col_line_width(menu_info, editor_ovl, &editor_ovl->_22, &editor_ovl->_24, &editor_ovl->_26, + editor_ovl->cursor_idx); + } else { + editor_ovl->cursor_idx = diary_ovl->cursor_idx; + editor_ovl->_22 = diary_ovl->_48; + editor_ovl->_24 = diary_ovl->_46; + mED_set_idxcol_inLineWidth(editor_ovl); + } + } else { + editor_ovl->cursor_idx = 0; + editor_ovl->_22 = 0; + editor_ovl->_24 = 0; + editor_ovl->_26 = 0; + } + + editor_ovl->exchange_code = -1; } static void mED_set_se(Submenu* submenu) { - static u16 se_no[mED_COMMAND_NUM] = { - 0x0000, - 0x0035, - 0x0035, - 0x0035, - 0x0035, - 0x005F, - 0x1034, - 0x0036, - 0x0033, - 0x0000 - }; + static u16 se_no[mED_COMMAND_NUM] = { + 0x0000, 0x0035, 0x0035, 0x0035, 0x0035, 0x005F, 0x1034, 0x0036, 0x0033, 0x0000 + }; - static u8 mED_exchange_se_list[TOTAL_CHARS] = { - TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, - TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, - FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, - FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, - FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, - FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, - TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, - FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, - FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, - FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, - TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, - TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, - TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, - TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, - TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, - TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE - }; + static u8 mED_exchange_se_list[TOTAL_CHARS] = { + TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, + TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, + FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, + FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, + FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, + FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, + TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, + FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, + FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, + FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, + TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, + TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, + TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, + TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, + TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, + TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE + }; - mED_Ovl_c* editor_ovl = submenu->overlay->editor_ovl; - int command = editor_ovl->command; + mED_Ovl_c* editor_ovl = submenu->overlay->editor_ovl; + int command = editor_ovl->command; - if (command == mED_COMMAND_OUTPUT_CODE) { - int voice = mMsg_sound_voice_get_for_editor(editor_ovl->now_code); + if (command == mED_COMMAND_OUTPUT_CODE) { + int voice = mMsg_sound_voice_get_for_editor(editor_ovl->now_code); - if (voice == 0x85 || voice == 0x80 || voice == 0x81 || voice == 0x82 || voice == 0x83 || voice == -1) { - voice = 0x86; + if (voice == 0x85 || voice == 0x80 || voice == 0x81 || voice == 0x82 || voice == 0x83 || voice == -1) { + voice = 0x86; + } + + sAdo_VoiceSe(voice, 0xFF, 0xFF, 0, 32, 1); + } else if (command == mED_COMMAND_EXCHANGE_CODE) { + int exchange_code = editor_ovl->exchange_code; + + if (exchange_code != -1 && mED_exchange_se_list[exchange_code] != FALSE) { + int voice = mMsg_sound_voice_get_for_editor(exchange_code); + + sAdo_VoiceSe(voice, 0xFF, 0xFF, 0, 32, 1); + } else { + sAdo_SysTrgStart(0x36); + } + } else { + sAdo_SysTrgStart(se_no[command]); } - - sAdo_VoiceSe(voice, 0xFF, 0xFF, 0, 32, 1); - } - else if (command == mED_COMMAND_EXCHANGE_CODE) { - int exchange_code = editor_ovl->exchange_code; - - if (exchange_code != -1 && mED_exchange_se_list[exchange_code] != FALSE) { - int voice = mMsg_sound_voice_get_for_editor(exchange_code); - - sAdo_VoiceSe(voice, 0xFF, 0xFF, 0, 32, 1); - } - else { - sAdo_SysTrgStart(0x36); - } - } - else { - sAdo_SysTrgStart(se_no[command]); - } } static void mED_output_code(mED_Ovl_c* editor_ovl) { - int len = editor_ovl->now_str_len; - u8* output_p = editor_ovl->input_str + len; - int i; + int len = editor_ovl->now_str_len; + u8* output_p = editor_ovl->input_str + len; + int i; - for (i = len; i > editor_ovl->cursor_idx; i--) { - output_p[0] = output_p[-1]; - output_p--; - } + for (i = len; i > editor_ovl->cursor_idx; i--) { + output_p[0] = output_p[-1]; + output_p--; + } - editor_ovl->cursor_idx++; - editor_ovl->now_str_len++; - output_p[0] = editor_ovl->now_code; - editor_ovl->command_processed = TRUE; + editor_ovl->cursor_idx++; + editor_ovl->now_str_len++; + output_p[0] = editor_ovl->now_code; + editor_ovl->command_processed = TRUE; } static int mED_get_single_line_width(mED_Ovl_c* editor_ovl) { - u8* str_p = editor_ovl->input_str; - int i; - int width = 0; + u8* str_p = editor_ovl->input_str; + int i; + int width = 0; - for (i = editor_ovl->now_str_len; i > 0; i--) { - width += mFont_GetCodeWidth(*str_p, TRUE); + for (i = editor_ovl->now_str_len; i > 0; i--) { + width += mFont_GetCodeWidth(*str_p, TRUE); - if (*str_p == CHAR_NEW_LINE) { - break; + if (*str_p == CHAR_NEW_LINE) { + break; + } + + str_p++; } - str_p++; - } - - return width; + return width; } static void mED_input_single_line(Submenu* submenu, mED_Ovl_c* editor_ovl) { - if (editor_ovl->now_code != CHAR_NEW_LINE) { - int line_width = mED_get_single_line_width(editor_ovl); - int now_code_width = mFont_GetCodeWidth(editor_ovl->now_code, TRUE); - int width = line_width + now_code_width; + if (editor_ovl->now_code != CHAR_NEW_LINE) { + int line_width = mED_get_single_line_width(editor_ovl); + int now_code_width = mFont_GetCodeWidth(editor_ovl->now_code, TRUE); + int width = line_width + now_code_width; - if (editor_ovl->now_str_len < editor_ovl->input_length && width <= editor_ovl->line_width) { - mED_output_code(editor_ovl); + if (editor_ovl->now_str_len < editor_ovl->input_length && width <= editor_ovl->line_width) { + mED_output_code(editor_ovl); + } else { + mED_open_warning_window(submenu, &submenu->overlay->menu_info[mSM_OVL_EDITOR], mWR_WARNING_WORD_OVER); + } } - else { - mED_open_warning_window(submenu, &submenu->overlay->menu_info[mSM_OVL_EDITOR], mWR_WARNING_WORD_OVER); - } - } } static void mED_input_multi_line_R(Submenu* submenu, mED_Ovl_c* editor_ovl, u8* buf) { - mSM_MenuInfo_c* menu_info; - u8* input_p; - u8* str_p; - u8* buf_p; - int i; - int res; - int total_characters; - s16 b; - s16 a; - s16 c; + mSM_MenuInfo_c* menu_info; + u8* input_p; + u8* str_p; + u8* buf_p; + int i; + int res; + int total_characters; + s16 b; + s16 a; + s16 c; - menu_info = &submenu->overlay->menu_info[mSM_OVL_EDITOR]; - total_characters = editor_ovl->input_length * editor_ovl->max_line_no; + menu_info = &submenu->overlay->menu_info[mSM_OVL_EDITOR]; + total_characters = editor_ovl->input_length * editor_ovl->max_line_no; - if (total_characters <= editor_ovl->now_str_len) { - mED_open_warning_window(submenu, menu_info, mWR_WARNING_WORD_OVER); - } - else { - str_p = editor_ovl->input_str; - buf_p = buf; - - /* Copy string up to cursor */ - for (i = 0; i < editor_ovl->cursor_idx; i++) { - *buf_p++ = *str_p++; - } - - *buf_p++ = editor_ovl->now_code; // insert character - - /* Copy the remaining string after the cursor */ - for (i; i < total_characters; i++) { - *buf_p++ = *str_p++; - } - - input_p = editor_ovl->input_str; // save pointer - editor_ovl->input_str = buf; - res = mED_get_col_line_width(menu_info, editor_ovl, &a, &b, &c, editor_ovl->now_str_len + 1); - editor_ovl->input_str = input_p; // restore pointer - - switch (res) { - case mED_LINE_OK: - mED_output_code(editor_ovl); - break; - case mED_LINE_WIDTH_OVER: - case mED_LINE_NUM_OVER: + if (total_characters <= editor_ovl->now_str_len) { mED_open_warning_window(submenu, menu_info, mWR_WARNING_WORD_OVER); - break; - case mED_LINE_NEWLINE: - if (editor_ovl->_24 != (editor_ovl->max_line_no - 1)) { - mED_open_warning_window(submenu, menu_info, mWR_WARNING_WORD_OVER); + } else { + str_p = editor_ovl->input_str; + buf_p = buf; + + /* Copy string up to cursor */ + for (i = 0; i < editor_ovl->cursor_idx; i++) { + *buf_p++ = *str_p++; + } + + *buf_p++ = editor_ovl->now_code; // insert character + + /* Copy the remaining string after the cursor */ + for (i; i < total_characters; i++) { + *buf_p++ = *str_p++; + } + + input_p = editor_ovl->input_str; // save pointer + editor_ovl->input_str = buf; + res = mED_get_col_line_width(menu_info, editor_ovl, &a, &b, &c, editor_ovl->now_str_len + 1); + editor_ovl->input_str = input_p; // restore pointer + + switch (res) { + case mED_LINE_OK: + mED_output_code(editor_ovl); + break; + case mED_LINE_WIDTH_OVER: + case mED_LINE_NUM_OVER: + mED_open_warning_window(submenu, menu_info, mWR_WARNING_WORD_OVER); + break; + case mED_LINE_NEWLINE: + if (editor_ovl->_24 != (editor_ovl->max_line_no - 1)) { + mED_open_warning_window(submenu, menu_info, mWR_WARNING_WORD_OVER); + } + break; } - break; } - } } static void mED_input_multi_line(Submenu* submenu, mED_Ovl_c* editor_ovl) { - u8 buf[1000]; - - mED_input_multi_line_R(submenu, editor_ovl, buf); + u8 buf[1000]; + + mED_input_multi_line_R(submenu, editor_ovl, buf); } static void mED_input_pw_make_line(Submenu* submenu, mED_Ovl_c* editor_ovl) { - if (editor_ovl->now_code != CHAR_NEW_LINE) { - int line_width = mED_get_single_line_width(editor_ovl); - int char_width = mFont_GetCodeWidth(editor_ovl->now_code, TRUE); - int width = line_width + char_width; + if (editor_ovl->now_code != CHAR_NEW_LINE) { + int line_width = mED_get_single_line_width(editor_ovl); + int char_width = mFont_GetCodeWidth(editor_ovl->now_code, TRUE); + int width = line_width + char_width; - if (editor_ovl->now_str_len < editor_ovl->input_length && width <= editor_ovl->line_width) { - mED_output_code(editor_ovl); + if (editor_ovl->now_str_len < editor_ovl->input_length && width <= editor_ovl->line_width) { + mED_output_code(editor_ovl); + } else { + mED_open_warning_window(submenu, &submenu->overlay->menu_info[mSM_OVL_EDITOR], mWR_WARNING_WORD_OVER); + } } - else { - mED_open_warning_window(submenu, &submenu->overlay->menu_info[mSM_OVL_EDITOR], mWR_WARNING_WORD_OVER); - } - } } static void mED_input_pw_chk_line(Submenu* submenu, mED_Ovl_c* editor_ovl) { - if (editor_ovl->now_code != CHAR_NEW_LINE) { - u8* str_p; - u8* src_p; - u8* dst_p; - int cursor_idx; - int size; - int i; - int len; + if (editor_ovl->now_code != CHAR_NEW_LINE) { + u8* str_p; + u8* src_p; + u8* dst_p; + int cursor_idx; + int size; + int i; + int len; - if (editor_ovl->input_str[editor_ovl->input_length - 1] == CHAR_SPACE) { - str_p = editor_ovl->input_str + editor_ovl->input_length; - cursor_idx = editor_ovl->cursor_idx; - - if (cursor_idx < editor_ovl->input_length) { - len = editor_ovl->input_length; - src_p = str_p - 2; - dst_p = str_p - 1; - - for (i = 0; i < (len - 1) - cursor_idx; i++) { - *dst_p-- = *src_p--; + if (editor_ovl->input_str[editor_ovl->input_length - 1] == CHAR_SPACE) { + str_p = editor_ovl->input_str + editor_ovl->input_length; + cursor_idx = editor_ovl->cursor_idx; + + if (cursor_idx < editor_ovl->input_length) { + len = editor_ovl->input_length; + src_p = str_p - 2; + dst_p = str_p - 1; + + for (i = (len - 1) - cursor_idx; i > 0; i--) { + *dst_p-- = *src_p--; + } + + editor_ovl->input_str[editor_ovl->cursor_idx] = editor_ovl->now_code; + editor_ovl->cursor_idx++; + + if (editor_ovl->cursor_idx >= editor_ovl->input_length) { + mPC_Ovl_c* passwordChk_ovl = submenu->overlay->passwordChk_ovl; + + if (passwordChk_ovl->selected_line == 0) { + passwordChk_ovl->selected_line = 1; + editor_ovl->input_str = passwordChk_ovl->line1; + editor_ovl->cursor_idx = 0; + } else { + editor_ovl->cursor_idx = editor_ovl->input_length; + } + } + + editor_ovl->command_processed = TRUE; + return; + } } - editor_ovl->input_str[editor_ovl->cursor_idx] = editor_ovl->now_code; - editor_ovl->cursor_idx++; - - if (editor_ovl->cursor_idx >= editor_ovl->input_length) { - mPC_Ovl_c* passwordChk_ovl = submenu->overlay->passwordChk_ovl; - - if (passwordChk_ovl->selected_line == 0) { - passwordChk_ovl->selected_line = 1; - editor_ovl->input_str = passwordChk_ovl->line1; - editor_ovl->cursor_idx = 0; - } - else { - editor_ovl->cursor_idx = editor_ovl->input_length; - } - } - - editor_ovl->command_processed = TRUE; - return; - } + sAdo_SysTrgStart(0x1003); + } else { + sAdo_SysTrgStart(0x1003); } - - sAdo_SysTrgStart(0x1003); - } - else { - sAdo_SysTrgStart(0x1003); - } } static void mED_move_cursol_right(Submenu* submenu, mED_Ovl_c* editor_ovl, int line_type) { - s16 now_str_len; - s16 cursor_idx; + s16 now_str_len; + s16 cursor_idx; - cursor_idx = editor_ovl->cursor_idx; - now_str_len = editor_ovl->now_str_len; + cursor_idx = editor_ovl->cursor_idx; + now_str_len = editor_ovl->now_str_len; - if (cursor_idx < now_str_len && now_str_len > 0) { - editor_ovl->cursor_idx = cursor_idx + 1; - editor_ovl->command_processed = TRUE; - } - else if (cursor_idx == now_str_len) { - editor_ovl->now_code = CHAR_SPACE; + if (cursor_idx < now_str_len && now_str_len > 0) { + editor_ovl->cursor_idx = cursor_idx + 1; + editor_ovl->command_processed = TRUE; + } else if (cursor_idx == now_str_len) { + editor_ovl->now_code = CHAR_SPACE; - switch (line_type) { - case mED_LINETYPE_MULTI: - mED_input_multi_line(submenu, editor_ovl); - break; - case mED_LINETYPE_SINGLE: - mED_input_single_line(submenu, editor_ovl); - break; - case mED_LINETYPE_PW: - mED_input_pw_make_line(submenu, editor_ovl); - break; + switch (line_type) { + case mED_LINETYPE_MULTI: + mED_input_multi_line(submenu, editor_ovl); + break; + case mED_LINETYPE_SINGLE: + mED_input_single_line(submenu, editor_ovl); + break; + case mED_LINETYPE_PW: + mED_input_pw_make_line(submenu, editor_ovl); + break; + } + + if (editor_ovl->command_processed != FALSE) { + editor_ovl->command = mED_COMMAND_OUTPUT_CODE; + } } - - if (editor_ovl->command_processed != FALSE) { - editor_ovl->command = mED_COMMAND_OUTPUT_CODE; - } - } } static void mED_move_cursol_left(mED_Ovl_c* editor_ovl) { - if (editor_ovl->cursor_idx > 0) { - editor_ovl->cursor_idx--; - editor_ovl->command_processed = TRUE; - } + if (editor_ovl->cursor_idx > 0) { + editor_ovl->cursor_idx--; + editor_ovl->command_processed = TRUE; + } } static void mED_move_cursol_upper(mED_Ovl_c* editor_ovl) { - if (editor_ovl->_24 > 0) { - editor_ovl->_24--; - mED_set_idxcol_inLineWidth(editor_ovl); - editor_ovl->command_processed = TRUE; - } + if (editor_ovl->_24 > 0) { + editor_ovl->_24--; + mED_set_idxcol_inLineWidth(editor_ovl); + editor_ovl->command_processed = TRUE; + } } static void mED_move_cursol_lower(Submenu* submenu, mED_Ovl_c* editor_ovl) { - s16 a; - s16 b; - s16 c; + s16 a; + s16 b; + s16 c; - mED_get_col_line_width(&submenu->overlay->menu_info[mSM_OVL_EDITOR], editor_ovl, &a, &b, &c, editor_ovl->now_str_len); + mED_get_col_line_width(&submenu->overlay->menu_info[mSM_OVL_EDITOR], editor_ovl, &a, &b, &c, + editor_ovl->now_str_len); - if (editor_ovl->_24 < b) { - editor_ovl->_24++; - mED_set_idxcol_inLineWidth(editor_ovl); - editor_ovl->command_processed = TRUE; - } - else if (editor_ovl->cursor_idx == editor_ovl->now_str_len) { - editor_ovl->now_code = CHAR_NEW_LINE; - mED_input_multi_line(submenu, editor_ovl); - - if (editor_ovl->command_processed == TRUE) { - editor_ovl->command = mED_COMMAND_OUTPUT_CODE; + if (editor_ovl->_24 < b) { + editor_ovl->_24++; + mED_set_idxcol_inLineWidth(editor_ovl); + editor_ovl->command_processed = TRUE; + } else if (editor_ovl->cursor_idx == editor_ovl->now_str_len) { + editor_ovl->now_code = CHAR_NEW_LINE; + mED_input_multi_line(submenu, editor_ovl); + + if (editor_ovl->command_processed == TRUE) { + editor_ovl->command = mED_COMMAND_OUTPUT_CODE; + } } - } } static void mED_end_edit_func(Submenu* submenu, mSM_MenuInfo_c* menu_info) { - (*submenu->overlay->move_chg_base_proc)(menu_info, mSM_MOVE_OUT_BOTTOM); // transition off the bottom of the screen - submenu->overlay->editor_ovl->command_processed = TRUE; + (*submenu->overlay->move_chg_base_proc)(menu_info, mSM_MOVE_OUT_BOTTOM); // transition off the bottom of the screen + submenu->overlay->editor_ovl->command_processed = TRUE; } static void mED_backspace_func(mED_Ovl_c* editor_ovl) { - u8* str_p; - int i; + u8* str_p; + int i; - if (editor_ovl->cursor_idx != 0) { - editor_ovl->cursor_idx--; - editor_ovl->now_str_len--; - - str_p = editor_ovl->input_str + editor_ovl->cursor_idx; + if (editor_ovl->cursor_idx != 0) { + editor_ovl->cursor_idx--; + editor_ovl->now_str_len--; - for (i = editor_ovl->cursor_idx; i < editor_ovl->now_str_len; i++) { - str_p[0] = str_p[1]; - str_p++; + str_p = editor_ovl->input_str + editor_ovl->cursor_idx; + + for (i = editor_ovl->cursor_idx; i < editor_ovl->now_str_len; i++) { + str_p[0] = str_p[1]; + str_p++; + } + + str_p[0] = CHAR_SPACE; + editor_ovl->command_processed = TRUE; } - - str_p[0] = CHAR_SPACE; - editor_ovl->command_processed = TRUE; - } } static void mED_backspace_func_pw_chk(mED_Ovl_c* editor_ovl, mPC_Ovl_c* passwordChk_ovl) { - if (editor_ovl->cursor_idx != 0) { - editor_ovl->cursor_idx--; - mem_copy(editor_ovl->input_str + editor_ovl->cursor_idx, editor_ovl->input_str + editor_ovl->cursor_idx + 1, (editor_ovl->input_length - editor_ovl->cursor_idx) - 1); - editor_ovl->input_str[editor_ovl->input_length - 1] = CHAR_SPACE; - editor_ovl->command_processed = TRUE; - } - else if (passwordChk_ovl->selected_line == 1) { - passwordChk_ovl->selected_line = 0; - editor_ovl->input_str = passwordChk_ovl->line0; - editor_ovl->cursor_idx = editor_ovl->input_length - 1; - editor_ovl->input_str[editor_ovl->cursor_idx] = CHAR_SPACE; - editor_ovl->command_processed = TRUE; - } + if (editor_ovl->cursor_idx != 0) { + editor_ovl->cursor_idx--; + mem_copy(editor_ovl->input_str + editor_ovl->cursor_idx, editor_ovl->input_str + editor_ovl->cursor_idx + 1, + (editor_ovl->input_length - editor_ovl->cursor_idx) - 1); + editor_ovl->input_str[editor_ovl->input_length - 1] = CHAR_SPACE; + editor_ovl->command_processed = TRUE; + } else if (passwordChk_ovl->selected_line == 1) { + passwordChk_ovl->selected_line = 0; + editor_ovl->input_str = passwordChk_ovl->line0; + editor_ovl->cursor_idx = editor_ovl->input_length - 1; + editor_ovl->input_str[editor_ovl->cursor_idx] = CHAR_SPACE; + editor_ovl->command_processed = TRUE; + } } static int mED_get_exchange_code(mED_Ovl_c* editor_ovl) { - int exchange_code = -1; + int exchange_code = -1; - if (editor_ovl->cursor_idx != 0) { - int ornament = mED_ornament_table[editor_ovl->input_str[editor_ovl->cursor_idx - 1]]; - int exchange = editor_ovl->input_str[editor_ovl->cursor_idx - 1]; - - if (exchange != ornament) { - exchange_code = ornament; + if (editor_ovl->cursor_idx != 0) { + int ornament = mED_ornament_table[editor_ovl->input_str[editor_ovl->cursor_idx - 1]]; + int exchange = editor_ovl->input_str[editor_ovl->cursor_idx - 1]; + + if (exchange != ornament) { + exchange_code = ornament; + } } - } - return exchange_code; + return exchange_code; } static int mED_exchange_code_func(mED_Ovl_c* editor_ovl) { - if (editor_ovl->exchange_code != -1) { - editor_ovl->command_processed = TRUE; - editor_ovl->input_str[editor_ovl->cursor_idx - 1] = editor_ovl->exchange_code; - } + if (editor_ovl->exchange_code != -1) { + editor_ovl->command_processed = TRUE; + editor_ovl->input_str[editor_ovl->cursor_idx - 1] = editor_ovl->exchange_code; + } - return editor_ovl->command_processed; + return editor_ovl->command_processed; } static void mED_clear_input_data(mED_Ovl_c* editor_ovl) { - u8* str_p = editor_ovl->input_str; - int i; + u8* str_p = editor_ovl->input_str; + int i; - for (i = 0; i < editor_ovl->input_length; i++) { - *str_p++ = CHAR_SPACE; - } + for (i = 0; i < editor_ovl->input_length; i++) { + *str_p++ = CHAR_SPACE; + } - editor_ovl->now_str_len = 0; - editor_ovl->_22 = 0; - editor_ovl->cursor_idx = 0; - editor_ovl->_26 = 0; + editor_ovl->now_str_len = 0; + editor_ovl->_22 = 0; + editor_ovl->cursor_idx = 0; + editor_ovl->_26 = 0; } static int mED_all_space_check(Submenu* submenu, mED_Ovl_c* editor_ovl, mSM_MenuInfo_c* menu_info) { - if (menu_info->data0 != mED_TYPE_LEDIT) { - return FALSE; - } - else { - u8* str_p = editor_ovl->input_str; - int res; + if (menu_info->data0 != mED_TYPE_LEDIT) { + return FALSE; + } else { + u8* str_p = editor_ovl->input_str; + int res; - if (submenu->overlay->menu_info[mSM_OVL_LEDIT].data0 == 2) { - if (mem_cmp(submenu->overlay->menu_info[mSM_OVL_LEDIT].data2, str_p, editor_ovl->input_length) == 0) { - res = FALSE; - } - else { - res = TRUE; - } - } - else { - res = FALSE; - } - - if (res == FALSE) { - u8* t_str_p = str_p; - int i; - - for (i = 0; i < editor_ovl->now_str_len; i++) { - if (*t_str_p != CHAR_SPACE) { - return FALSE; + if (submenu->overlay->menu_info[mSM_OVL_LEDIT].data0 == 2) { + if (mem_cmp(submenu->overlay->menu_info[mSM_OVL_LEDIT].data2, str_p, editor_ovl->input_length) == 0) { + res = FALSE; + } else { + res = TRUE; + } + } else { + res = FALSE; } - t_str_p++; - } - } + if (res == FALSE) { + u8* t_str_p = str_p; + int i; - mED_clear_input_data(editor_ovl); - return TRUE; - } + for (i = 0; i < editor_ovl->now_str_len; i++) { + if (*t_str_p != CHAR_SPACE) { + return FALSE; + } + + t_str_p++; + } + } + + mED_clear_input_data(editor_ovl); + return TRUE; + } } static int mED_ng_word_check(mED_Ovl_c* editor_ovl, mSM_MenuInfo_c* menu_info) { - static int ng_word_length[mED_NG_WORD_NUM] = { - 4, 4, 4, 4, - 4, 5, 5, 7, - 7, 7, 7, 7, - 9, 10 - }; + static int ng_word_length[mED_NG_WORD_NUM] = { 4, 4, 4, 4, 4, 5, 5, 7, 7, 7, 7, 7, 9, 10 }; - if (menu_info->data0 == mED_TYPE_LEDIT) { - u8 ng_word[10]; - int len; - u8* str_p; - int i; - int j; - int idx = mED_NG_WORD_START; + if (menu_info->data0 == mED_TYPE_LEDIT) { + u8 ng_word[10]; + int len; + u8* str_p; + int i; + int j; + int idx = mED_NG_WORD_START; - for (i = 0; i < mED_NG_WORD_NUM; i++) { - len = ng_word_length[i]; - mString_Load_StringFromRom(ng_word, sizeof(ng_word), idx); - str_p = editor_ovl->input_str; + for (i = 0; i < mED_NG_WORD_NUM; i++) { + len = ng_word_length[i]; + mString_Load_StringFromRom(ng_word, sizeof(ng_word), idx); + str_p = editor_ovl->input_str; - for (j = (editor_ovl->input_length - len) + 1; j >= 0; j--) { - if (mem_cmp(str_p, ng_word, len) == TRUE) { - mED_clear_input_data(editor_ovl); - return TRUE; + for (j = (editor_ovl->input_length - len) + 1; j >= 0; j--) { + if (mem_cmp(str_p, ng_word, len) == TRUE) { + mED_clear_input_data(editor_ovl); + return TRUE; + } + + str_p++; + } + + idx++; } - - str_p++; - } - - idx++; } - } - return FALSE; + return FALSE; } static void mED_edit_func_multi_line(Submenu* submenu, mSM_MenuInfo_c* menu_info) { - mED_Ovl_c* editor_ovl = submenu->overlay->editor_ovl; + mED_Ovl_c* editor_ovl = submenu->overlay->editor_ovl; - switch (editor_ovl->command) { - case mED_COMMAND_CURSOL_LEFT: - mED_move_cursol_left(editor_ovl); - break; - case mED_COMMAND_CURSOL_LOWER: - mED_move_cursol_lower(submenu, editor_ovl); - break; - case mED_COMMAND_CURSOL_UPPER: - mED_move_cursol_upper(editor_ovl); - break; - case mED_COMMAND_CURSOL_RIGHT: - mED_move_cursol_right(submenu, editor_ovl, mED_LINETYPE_MULTI); - break; - case mED_COMMAND_END_EDIT: - mED_end_edit_func(submenu, menu_info); - break; - case mED_COMMAND_BACKSPACE: - mED_backspace_func(editor_ovl); - break; - case mED_COMMAND_EXCHANGE_CODE: - mED_exchange_code_func(editor_ovl); - break; - case mED_COMMAND_OUTPUT_CODE: - mED_input_multi_line(submenu, editor_ovl); - break; - } + switch (editor_ovl->command) { + case mED_COMMAND_CURSOL_LEFT: + mED_move_cursol_left(editor_ovl); + break; + case mED_COMMAND_CURSOL_LOWER: + mED_move_cursol_lower(submenu, editor_ovl); + break; + case mED_COMMAND_CURSOL_UPPER: + mED_move_cursol_upper(editor_ovl); + break; + case mED_COMMAND_CURSOL_RIGHT: + mED_move_cursol_right(submenu, editor_ovl, mED_LINETYPE_MULTI); + break; + case mED_COMMAND_END_EDIT: + mED_end_edit_func(submenu, menu_info); + break; + case mED_COMMAND_BACKSPACE: + mED_backspace_func(editor_ovl); + break; + case mED_COMMAND_EXCHANGE_CODE: + mED_exchange_code_func(editor_ovl); + break; + case mED_COMMAND_OUTPUT_CODE: + mED_input_multi_line(submenu, editor_ovl); + break; + } } static void mED_edit_func_single_line(Submenu* submenu, mSM_MenuInfo_c* menu_info) { - mED_Ovl_c* editor_ovl = submenu->overlay->editor_ovl; + mED_Ovl_c* editor_ovl = submenu->overlay->editor_ovl; - switch (editor_ovl->command) { - case mED_COMMAND_CURSOL_LEFT: - mED_move_cursol_left(editor_ovl); - break; - case mED_COMMAND_CURSOL_LOWER: - break; - case mED_COMMAND_CURSOL_UPPER: - break; - case mED_COMMAND_CURSOL_RIGHT: - mED_move_cursol_right(submenu, editor_ovl, mED_LINETYPE_SINGLE); - break; - case mED_COMMAND_END_EDIT: - if (mED_all_space_check(submenu, editor_ovl, menu_info) != FALSE) { - sAdo_SysTrgStart(0x1003); - } - else if (mED_ng_word_check(editor_ovl, menu_info) != FALSE) { - sAdo_SysTrgStart(0x1003); - } - else { - mED_end_edit_func(submenu, menu_info); - } - break; - case mED_COMMAND_BACKSPACE: - mED_backspace_func(editor_ovl); - break; - case mED_COMMAND_EXCHANGE_CODE: - mED_exchange_code_func(editor_ovl); - break; - case mED_COMMAND_OUTPUT_CODE: - mED_input_single_line(submenu, editor_ovl); - break; - } + switch (editor_ovl->command) { + case mED_COMMAND_CURSOL_LEFT: + mED_move_cursol_left(editor_ovl); + break; + case mED_COMMAND_CURSOL_LOWER: + break; + case mED_COMMAND_CURSOL_UPPER: + break; + case mED_COMMAND_CURSOL_RIGHT: + mED_move_cursol_right(submenu, editor_ovl, mED_LINETYPE_SINGLE); + break; + case mED_COMMAND_END_EDIT: + if (mED_all_space_check(submenu, editor_ovl, menu_info) != FALSE) { + sAdo_SysTrgStart(0x1003); + } else if (mED_ng_word_check(editor_ovl, menu_info) != FALSE) { + sAdo_SysTrgStart(0x1003); + } else { + mED_end_edit_func(submenu, menu_info); + } + break; + case mED_COMMAND_BACKSPACE: + mED_backspace_func(editor_ovl); + break; + case mED_COMMAND_EXCHANGE_CODE: + mED_exchange_code_func(editor_ovl); + break; + case mED_COMMAND_OUTPUT_CODE: + mED_input_single_line(submenu, editor_ovl); + break; + } } static void mED_edit_func_letter_header_kill_space(Submenu* submenu) { - Submenu_Overlay_c* overlay = submenu->overlay; - mED_Ovl_c* editor_ovl = overlay->editor_ovl; - mBD_Ovl_c* board_ovl = overlay->board_ovl; + Submenu_Overlay_c* overlay = submenu->overlay; + mED_Ovl_c* editor_ovl = overlay->editor_ovl; + mBD_Ovl_c* board_ovl = overlay->board_ovl; - if (overlay->menu_info[mSM_OVL_BOARD].data0 == 3) { - s16 len = mMl_strlen(editor_ovl->input_str, editor_ovl->input_length, CHAR_SPACE); - s16 _22 = editor_ovl->_22; + if (overlay->menu_info[mSM_OVL_BOARD].data0 == 3) { + s16 len = mMl_strlen(editor_ovl->input_str, editor_ovl->input_length, CHAR_SPACE); + s16 _22 = editor_ovl->_22; - if (_22 > len) { - len = _22; + if (_22 > len) { + len = _22; + } + + editor_ovl->now_str_len = len; + } else { + s16 len = mMl_strlen(editor_ovl->input_str, editor_ovl->input_length, CHAR_SPACE); + int header_back_start = board_ovl->mail.content.header_back_start; + int min_len = editor_ovl->_22; + int res; + + if (len > header_back_start) { + res = len; + } else { + res = header_back_start; + } + + if (res > min_len) { + res = header_back_start; + + if (len > header_back_start) { + res = len; + } + } else { + res = min_len; + } + + editor_ovl->now_str_len = res; } - - editor_ovl->now_str_len = len; - } - else { - s16 len = mMl_strlen(editor_ovl->input_str, editor_ovl->input_length, CHAR_SPACE); - int header_back_start = board_ovl->mail.content.header_back_start; - int min_len = editor_ovl->_22; - int res; - - if (len > header_back_start) { - res = len; - } - else { - res = header_back_start; - } - - if (res > min_len) { - res = header_back_start; - - if (len > header_back_start) { - res = len; - } - } - else { - res = min_len; - } - - editor_ovl->now_str_len = res; - } } static void mED_edit_func_letter_header(Submenu* submenu, mSM_MenuInfo_c* menu_info) { - Submenu_Overlay_c* overlay = submenu->overlay; - mED_Ovl_c* editor_ovl = overlay->editor_ovl; - mBD_Ovl_c* board_ovl = overlay->board_ovl; + Submenu_Overlay_c* overlay = submenu->overlay; + mED_Ovl_c* editor_ovl = overlay->editor_ovl; + mBD_Ovl_c* board_ovl = overlay->board_ovl; - if (overlay->menu_info[mSM_OVL_BOARD].data0 == 3) { - mED_edit_func_single_line(submenu, menu_info); - } - else if (board_ovl->header_pos != mBD_HEADER_POS_ON_NAME) { - s16 len = editor_ovl->now_str_len; + if (overlay->menu_info[mSM_OVL_BOARD].data0 == 3) { + mED_edit_func_single_line(submenu, menu_info); + } else if (board_ovl->header_pos != mBD_HEADER_POS_ON_NAME) { + s16 len = editor_ovl->now_str_len; - if ( - board_ovl->mail.content.header_back_start == editor_ovl->cursor_idx && - ((board_ovl->header_pos == mBD_HEADER_POS_PRE_NAME && editor_ovl->command == mED_COMMAND_CURSOL_RIGHT) || - (board_ovl->header_pos == mBD_HEADER_POS_POST_NAME && (editor_ovl->command == mED_COMMAND_CURSOL_LEFT || editor_ovl->command == mED_COMMAND_BACKSPACE))) - ) { - board_ovl->header_pos = mBD_HEADER_POS_ON_NAME; - editor_ovl->command_processed = TRUE; - } - else { - mED_edit_func_single_line(submenu, menu_info); + if (board_ovl->mail.content.header_back_start == editor_ovl->cursor_idx && + ((board_ovl->header_pos == mBD_HEADER_POS_PRE_NAME && editor_ovl->command == mED_COMMAND_CURSOL_RIGHT) || + (board_ovl->header_pos == mBD_HEADER_POS_POST_NAME && + (editor_ovl->command == mED_COMMAND_CURSOL_LEFT || editor_ovl->command == mED_COMMAND_BACKSPACE)))) { + board_ovl->header_pos = mBD_HEADER_POS_ON_NAME; + editor_ovl->command_processed = TRUE; + } else { + mED_edit_func_single_line(submenu, menu_info); - if (board_ovl->header_pos == mBD_HEADER_POS_PRE_NAME) { - if (len > editor_ovl->now_str_len) { - board_ovl->mail.content.header_back_start --; + if (board_ovl->header_pos == mBD_HEADER_POS_PRE_NAME) { + if (len > editor_ovl->now_str_len) { + board_ovl->mail.content.header_back_start--; + } else if (len < editor_ovl->now_str_len) { + board_ovl->mail.content.header_back_start++; + } + } } - else if (len < editor_ovl->now_str_len) { - board_ovl->mail.content.header_back_start++; - } - } } - } - mED_edit_func_letter_header_kill_space(submenu); + mED_edit_func_letter_header_kill_space(submenu); } static void mED_break_space_code(u8* str) { - u8 buf[32]; + u8 buf[32]; - mem_copy(buf, str + 1, sizeof(buf) - 1); - buf[sizeof(buf) - 1] = CHAR_SPACE; - mem_copy(str, buf, sizeof(buf)); + mem_copy(buf, str + 1, sizeof(buf) - 1); + buf[sizeof(buf) - 1] = CHAR_SPACE; + mem_copy(str, buf, sizeof(buf)); } static void mED_input_footer_line_sub(Submenu* submenu, mSM_MenuInfo_c* menu_info, mED_Ovl_c* editor_ovl) { - int now_code_width = mFont_GetCodeWidth(editor_ovl->now_code, TRUE); - int str_width = mFont_GetStringWidth(editor_ovl->input_str, editor_ovl->now_str_len, TRUE); - int width = str_width + now_code_width; - - if ((editor_ovl->now_str_len + 1) <= editor_ovl->input_length) { - if (width <= editor_ovl->line_width) { - mED_output_code(editor_ovl); + int now_code_width = mFont_GetCodeWidth(editor_ovl->now_code, TRUE); + int str_width = mFont_GetStringWidth(editor_ovl->input_str, editor_ovl->now_str_len, TRUE); + int width = str_width + now_code_width; + + if ((editor_ovl->now_str_len + 1) <= editor_ovl->input_length) { + if (width <= editor_ovl->line_width) { + mED_output_code(editor_ovl); + } else if (editor_ovl->input_str[0] == CHAR_SPACE && + width - mFont_GetCodeWidth(CHAR_SPACE, TRUE) < editor_ovl->line_width) { + mED_break_space_code(editor_ovl->input_str); + editor_ovl->now_str_len--; + mED_output_code(editor_ovl); + } else { + mED_open_warning_window(submenu, menu_info, mWR_WARNING_WORD_OVER); + } + } else if (editor_ovl->input_str[0] == CHAR_SPACE && + width - mFont_GetCodeWidth(CHAR_SPACE, TRUE) < editor_ovl->line_width) { + mED_break_space_code(editor_ovl->input_str); + editor_ovl->now_str_len--; + mED_output_code(editor_ovl); + } else { + mED_open_warning_window(submenu, menu_info, mWR_WARNING_WORD_OVER); } - else if (editor_ovl->input_str[0] == CHAR_SPACE && width - mFont_GetCodeWidth(CHAR_SPACE, TRUE) < editor_ovl->line_width) { - mED_break_space_code(editor_ovl->input_str); - editor_ovl->now_str_len--; - mED_output_code(editor_ovl); - } - else { - mED_open_warning_window(submenu, menu_info, mWR_WARNING_WORD_OVER); - } - } - else if (editor_ovl->input_str[0] == CHAR_SPACE && width - mFont_GetCodeWidth(CHAR_SPACE, TRUE) < editor_ovl->line_width) { - mED_break_space_code(editor_ovl->input_str); - editor_ovl->now_str_len--; - mED_output_code(editor_ovl); - } - else { - mED_open_warning_window(submenu, menu_info, mWR_WARNING_WORD_OVER); - } } static void mED_input_footer_line(Submenu* submenu, mSM_MenuInfo_c* menu_info, mED_Ovl_c* editor_ovl) { - switch (editor_ovl->now_code) { - case CHAR_NEW_LINE: - break; - case CHAR_SPACE: - if (editor_ovl->cursor_idx != 0) { - mED_input_footer_line_sub(submenu, menu_info, editor_ovl); - } - break; - default: - mED_input_footer_line_sub(submenu, menu_info, editor_ovl); - break; - } + switch (editor_ovl->now_code) { + case CHAR_NEW_LINE: + break; + case CHAR_SPACE: + if (editor_ovl->cursor_idx != 0) { + mED_input_footer_line_sub(submenu, menu_info, editor_ovl); + } + break; + default: + mED_input_footer_line_sub(submenu, menu_info, editor_ovl); + break; + } } static void mED_move_footer_cursol_right(Submenu* submenu, mSM_MenuInfo_c* menu_info, mED_Ovl_c* editor_ovl) { - s16 str_len; - s16 cursor_idx; + s16 str_len; + s16 cursor_idx; - cursor_idx = editor_ovl->cursor_idx; - str_len = editor_ovl->now_str_len; + cursor_idx = editor_ovl->cursor_idx; + str_len = editor_ovl->now_str_len; - if (cursor_idx < str_len && str_len > 0) { - if (cursor_idx == 0 && editor_ovl->input_str[0] == CHAR_SPACE) { - u8* str_p = editor_ovl->input_str; - int i; - - editor_ovl->now_str_len = str_len - 1; - for (i = 0; i < editor_ovl->now_str_len; i++) { - str_p[0] = str_p[1]; - str_p++; - } + if (cursor_idx < str_len && str_len > 0) { + if (cursor_idx == 0 && editor_ovl->input_str[0] == CHAR_SPACE) { + u8* str_p = editor_ovl->input_str; + int i; - str_p[0] = CHAR_SPACE; - editor_ovl->command_processed = TRUE; + editor_ovl->now_str_len = str_len - 1; + for (i = 0; i < editor_ovl->now_str_len; i++) { + str_p[0] = str_p[1]; + str_p++; + } + + str_p[0] = CHAR_SPACE; + editor_ovl->command_processed = TRUE; + } else { + editor_ovl->cursor_idx++; + editor_ovl->command_processed = TRUE; + } + } else if (cursor_idx == str_len) { + editor_ovl->now_code = CHAR_SPACE; + mED_input_footer_line(submenu, menu_info, editor_ovl); + + if (editor_ovl->command_processed) { + editor_ovl->command = mED_COMMAND_OUTPUT_CODE; + } } - else { - editor_ovl->cursor_idx++; - editor_ovl->command_processed = TRUE; - } - } - else if (cursor_idx == str_len) { - editor_ovl->now_code = CHAR_SPACE; - mED_input_footer_line(submenu, menu_info, editor_ovl); - - if (editor_ovl->command_processed) { - editor_ovl->command = mED_COMMAND_OUTPUT_CODE; - } - } } static void mED_move_footer_cursol_left(Submenu* submenu, mSM_MenuInfo_c* menu_info, mED_Ovl_c* editor_ovl) { - if (editor_ovl->cursor_idx > 0) { - editor_ovl->cursor_idx--; - editor_ovl->command_processed = TRUE; - } - else if (editor_ovl->now_str_len < editor_ovl->input_length) { - editor_ovl->now_code = CHAR_SPACE; - mED_input_footer_line(submenu, menu_info, editor_ovl); - editor_ovl->cursor_idx = 0; + if (editor_ovl->cursor_idx > 0) { + editor_ovl->cursor_idx--; + editor_ovl->command_processed = TRUE; + } else if (editor_ovl->now_str_len < editor_ovl->input_length) { + editor_ovl->now_code = CHAR_SPACE; + mED_input_footer_line(submenu, menu_info, editor_ovl); + editor_ovl->cursor_idx = 0; - if (editor_ovl->command_processed) { - editor_ovl->command = mED_COMMAND_OUTPUT_CODE; + if (editor_ovl->command_processed) { + editor_ovl->command = mED_COMMAND_OUTPUT_CODE; + } } - } } static void mED_edit_func_letter_footer(Submenu* submenu, mSM_MenuInfo_c* menu_info) { - mED_Ovl_c* editor_ovl = submenu->overlay->editor_ovl; + mED_Ovl_c* editor_ovl = submenu->overlay->editor_ovl; - switch (editor_ovl->command) { - case mED_COMMAND_CURSOL_LEFT: - mED_move_footer_cursol_left(submenu, menu_info, editor_ovl); - break; - case mED_COMMAND_CURSOL_RIGHT: - mED_move_footer_cursol_right(submenu, menu_info, editor_ovl); - break; - case mED_COMMAND_END_EDIT: - if (mED_all_space_check(submenu, editor_ovl, menu_info)) { - sAdo_SysTrgStart(0x1003); - } - else if (mED_ng_word_check(editor_ovl, menu_info)) { - sAdo_SysTrgStart(0x1003); - } - else { - mED_end_edit_func(submenu, menu_info); - } - break; - case mED_COMMAND_BACKSPACE: - mED_backspace_func(editor_ovl); - break; - case mED_COMMAND_EXCHANGE_CODE: - mED_exchange_code_func(editor_ovl); - break; - case mED_COMMAND_OUTPUT_CODE: - mED_input_footer_line(submenu, menu_info, editor_ovl); - break; - } + switch (editor_ovl->command) { + case mED_COMMAND_CURSOL_LEFT: + mED_move_footer_cursol_left(submenu, menu_info, editor_ovl); + break; + case mED_COMMAND_CURSOL_RIGHT: + mED_move_footer_cursol_right(submenu, menu_info, editor_ovl); + break; + case mED_COMMAND_END_EDIT: + if (mED_all_space_check(submenu, editor_ovl, menu_info)) { + sAdo_SysTrgStart(0x1003); + } else if (mED_ng_word_check(editor_ovl, menu_info)) { + sAdo_SysTrgStart(0x1003); + } else { + mED_end_edit_func(submenu, menu_info); + } + break; + case mED_COMMAND_BACKSPACE: + mED_backspace_func(editor_ovl); + break; + case mED_COMMAND_EXCHANGE_CODE: + mED_exchange_code_func(editor_ovl); + break; + case mED_COMMAND_OUTPUT_CODE: + mED_input_footer_line(submenu, menu_info, editor_ovl); + break; + } } static void mED_move_letter_table(mED_Ovl_c* editor_ovl, mBD_Ovl_c* board_ovl, Submenu* submenu) { - static s16 letter_table_col[mBD_FIELD_NUM] = { MAIL_HEADER_LEN, MAIL_BODY_LEN / mBD_BODY_LINE_NUM, MAIL_FOOTER_LEN }; - static s16 letter_table_width[mBD_FIELD_NUM] = { 112, 192, 192 }; + static s16 letter_table_col[mBD_FIELD_NUM] = { MAIL_HEADER_LEN, MAIL_BODY_LEN / mBD_BODY_LINE_NUM, + MAIL_FOOTER_LEN }; + static s16 letter_table_width[mBD_FIELD_NUM] = { 112, 192, 192 }; - u8 field = board_ovl->field; - Submenu_Overlay_c* overlay = submenu->overlay; - mSM_MenuInfo_c* menu_info = &overlay->menu_info[mSM_OVL_EDITOR]; - int next_field; - int upper; + u8 field = board_ovl->field; + Submenu_Overlay_c* overlay = submenu->overlay; + mSM_MenuInfo_c* menu_info = &overlay->menu_info[mSM_OVL_EDITOR]; + int next_field; + int upper; - if (field == mBD_FIELD_HEADER && board_ovl->header_pos == mBD_HEADER_POS_ON_NAME) { - return; - } - - if (editor_ovl->command == mED_COMMAND_CURSOL_UPPER) { - next_field = field - 1; - upper = TRUE; - } - else if (editor_ovl->command == mED_COMMAND_CURSOL_LOWER) { - next_field = field + 1; - upper = FALSE; - } - else { - return; - } - - if (next_field < 0 || next_field >= mBD_FIELD_NUM) { - return; - } - - editor_ovl->command_processed = TRUE; - board_ovl->field = next_field; - board_ovl->header_pos = mBD_HEADER_POS_PRE_NAME; - editor_ovl->input_length = letter_table_col[next_field]; - editor_ovl->line_width = letter_table_width[next_field]; - menu_info->data3 = letter_table_width[next_field]; - - if (next_field == mBD_FIELD_BODY) { - editor_ovl->max_line_no = mBD_BODY_LINE_NUM; - editor_ovl->input_str = board_ovl->mail.content.body; - - if (upper == TRUE) { - editor_ovl->cursor_idx = -1; + if (field == mBD_FIELD_HEADER && board_ovl->header_pos == mBD_HEADER_POS_ON_NAME) { + return; } - else { - editor_ovl->cursor_idx = 0; - } - } - else { - editor_ovl->max_line_no = 1; - editor_ovl->cursor_idx = 0; - if (next_field == mBD_FIELD_HEADER) { - editor_ovl->input_str = board_ovl->mail.content.header; + if (editor_ovl->command == mED_COMMAND_CURSOL_UPPER) { + next_field = field - 1; + upper = TRUE; + } else if (editor_ovl->command == mED_COMMAND_CURSOL_LOWER) { + next_field = field + 1; + upper = FALSE; + } else { + return; } - else { - editor_ovl->input_str = board_ovl->mail.content.footer; + + if (next_field < 0 || next_field >= mBD_FIELD_NUM) { + return; } - } - editor_ovl->now_str_len = board_ovl->lengths[next_field]; + editor_ovl->command_processed = TRUE; + board_ovl->field = next_field; + board_ovl->header_pos = mBD_HEADER_POS_PRE_NAME; + editor_ovl->input_length = letter_table_col[next_field]; + editor_ovl->line_width = letter_table_width[next_field]; + menu_info->data3 = letter_table_width[next_field]; - if (editor_ovl->cursor_idx == -1) { - editor_ovl->cursor_idx = editor_ovl->now_str_len; - } + if (next_field == mBD_FIELD_BODY) { + editor_ovl->max_line_no = mBD_BODY_LINE_NUM; + editor_ovl->input_str = board_ovl->mail.content.body; + + if (upper == TRUE) { + editor_ovl->cursor_idx = -1; + } else { + editor_ovl->cursor_idx = 0; + } + } else { + editor_ovl->max_line_no = 1; + editor_ovl->cursor_idx = 0; + + if (next_field == mBD_FIELD_HEADER) { + editor_ovl->input_str = board_ovl->mail.content.header; + } else { + editor_ovl->input_str = board_ovl->mail.content.footer; + } + } + + editor_ovl->now_str_len = board_ovl->lengths[next_field]; + + if (editor_ovl->cursor_idx == -1) { + editor_ovl->cursor_idx = editor_ovl->now_str_len; + } } typedef void (*mED_BASE_FUNC)(Submenu*, mSM_MenuInfo_c*); static void mED_edit_func_letter(Submenu* submenu, mSM_MenuInfo_c* menu_info) { - static mED_BASE_FUNC letter_base_func[mBD_FIELD_NUM] = { - &mED_edit_func_letter_header, - &mED_edit_func_multi_line, - &mED_edit_func_letter_footer - }; + static mED_BASE_FUNC letter_base_func[mBD_FIELD_NUM] = { &mED_edit_func_letter_header, &mED_edit_func_multi_line, + &mED_edit_func_letter_footer }; - mBD_Ovl_c* board_ovl = submenu->overlay->board_ovl; - int field = board_ovl->field; - mED_Ovl_c* editor_ovl = submenu->overlay->editor_ovl; + mBD_Ovl_c* board_ovl = submenu->overlay->board_ovl; + int field = board_ovl->field; + mED_Ovl_c* editor_ovl = submenu->overlay->editor_ovl; - (*letter_base_func[field])(submenu, menu_info); - board_ovl->lengths[field] = editor_ovl->now_str_len; + (*letter_base_func[field])(submenu, menu_info); + board_ovl->lengths[field] = editor_ovl->now_str_len; - if (editor_ovl->command_processed == FALSE) { - mED_move_letter_table(editor_ovl, board_ovl, submenu); - } + if (editor_ovl->command_processed == FALSE) { + mED_move_letter_table(editor_ovl, board_ovl, submenu); + } } static void mED_edit_func_diary(Submenu* submenu, mSM_MenuInfo_c* menu_info) { - /* @unused */ - static mED_BASE_FUNC letter_base_func[mBD_FIELD_NUM] = { - &mED_edit_func_letter_header, - &mED_edit_func_multi_line, - &mED_edit_func_single_line - }; + /* @unused */ + static mED_BASE_FUNC letter_base_func[mBD_FIELD_NUM] = { &mED_edit_func_letter_header, &mED_edit_func_multi_line, + &mED_edit_func_single_line }; - mDI_Ovl_c* diary_ovl = submenu->overlay->diary_ovl; - int field = diary_ovl->field; - mED_Ovl_c* editor_ovl = submenu->overlay->editor_ovl; + mDI_Ovl_c* diary_ovl = submenu->overlay->diary_ovl; + int field = diary_ovl->field; + mED_Ovl_c* editor_ovl = submenu->overlay->editor_ovl; - switch (editor_ovl->command) { - case mED_COMMAND_CURSOL_LEFT: - mED_move_cursol_left(editor_ovl); - break; - case mED_COMMAND_CURSOL_LOWER: - mED_move_cursol_lower(submenu, editor_ovl); - break; - case mED_COMMAND_CURSOL_UPPER: - mED_move_cursol_upper(editor_ovl); - break; - case mED_COMMAND_CURSOL_RIGHT: - mED_move_cursol_right(submenu, editor_ovl, mED_LINETYPE_MULTI); - break; - case mED_COMMAND_END_EDIT: - mED_end_edit_func(submenu, menu_info); - break; - case mED_COMMAND_BACKSPACE: - mED_backspace_func(editor_ovl); - break; - case mED_COMMAND_EXCHANGE_CODE: - mED_exchange_code_func(editor_ovl); - break; - case mED_COMMAND_OUTPUT_CODE: - mED_input_multi_line(submenu, editor_ovl); - break; - } + switch (editor_ovl->command) { + case mED_COMMAND_CURSOL_LEFT: + mED_move_cursol_left(editor_ovl); + break; + case mED_COMMAND_CURSOL_LOWER: + mED_move_cursol_lower(submenu, editor_ovl); + break; + case mED_COMMAND_CURSOL_UPPER: + mED_move_cursol_upper(editor_ovl); + break; + case mED_COMMAND_CURSOL_RIGHT: + mED_move_cursol_right(submenu, editor_ovl, mED_LINETYPE_MULTI); + break; + case mED_COMMAND_END_EDIT: + mED_end_edit_func(submenu, menu_info); + break; + case mED_COMMAND_BACKSPACE: + mED_backspace_func(editor_ovl); + break; + case mED_COMMAND_EXCHANGE_CODE: + mED_exchange_code_func(editor_ovl); + break; + case mED_COMMAND_OUTPUT_CODE: + mED_input_multi_line(submenu, editor_ovl); + break; + } - diary_ovl->entry_len[field] = editor_ovl->now_str_len; + diary_ovl->entry_len[field] = editor_ovl->now_str_len; } static void mED_move_pw_make_table(mED_Ovl_c* editor_ovl, mPM_Ovl_c* passwordMake_ovl) { - static s16 pm_make_table_col[mPM_ENTRY_NUM] = { LAND_NAME_SIZE, PLAYER_NAME_LEN }; - int next_idx; + static s16 pm_make_table_col[mPM_ENTRY_NUM] = { LAND_NAME_SIZE, PLAYER_NAME_LEN }; + int next_idx; - switch (editor_ovl->command) { - case mED_COMMAND_CURSOL_LOWER: - { - if (passwordMake_ovl->selected_idx == mPM_ENTRY_TOWN) { - editor_ovl->now_str_len = mMl_strlen(editor_ovl->input_str, editor_ovl->input_length, CHAR_SPACE); - editor_ovl->cursor_idx = editor_ovl->now_str_len; - passwordMake_ovl->lengths[mPM_ENTRY_TOWN] = editor_ovl->now_str_len; + switch (editor_ovl->command) { + case mED_COMMAND_CURSOL_LOWER: { + if (passwordMake_ovl->selected_idx == mPM_ENTRY_TOWN) { + editor_ovl->now_str_len = mMl_strlen(editor_ovl->input_str, editor_ovl->input_length, CHAR_SPACE); + editor_ovl->cursor_idx = editor_ovl->now_str_len; + passwordMake_ovl->lengths[mPM_ENTRY_TOWN] = editor_ovl->now_str_len; - if (editor_ovl->now_str_len == 0) { - sAdo_SysTrgStart(0x1003); - return; + if (editor_ovl->now_str_len == 0) { + sAdo_SysTrgStart(0x1003); + return; + } + } + + next_idx = passwordMake_ovl->selected_idx + 1; + break; } - } - - next_idx = passwordMake_ovl->selected_idx + 1; - break; + + case mED_COMMAND_CURSOL_UPPER: + case mED_COMMAND_BACKSPACE: + next_idx = passwordMake_ovl->selected_idx - 1; + break; + + default: + return; } - case mED_COMMAND_CURSOL_UPPER: - case mED_COMMAND_BACKSPACE: - next_idx = passwordMake_ovl->selected_idx - 1; - break; + if (next_idx < 0 || next_idx >= mPM_ENTRY_NUM) { + return; + } - default: - return; - } + editor_ovl->command_processed = TRUE; + passwordMake_ovl->selected_idx = (u8)next_idx; + editor_ovl->input_length = pm_make_table_col[next_idx]; + editor_ovl->line_width = editor_ovl->input_length * 10; - if (next_idx < 0 || next_idx >= mPM_ENTRY_NUM) { - return; - } - - editor_ovl->command_processed = TRUE; - passwordMake_ovl->selected_idx = (u8)next_idx; - editor_ovl->input_length = pm_make_table_col[next_idx]; - editor_ovl->line_width = editor_ovl->input_length * 10; + switch (next_idx) { + case mPM_ENTRY_TOWN: + editor_ovl->input_str = passwordMake_ovl->town_name; + break; + case mPM_ENTRY_PLAYER: + editor_ovl->input_str = passwordMake_ovl->player_name; + break; + } - switch (next_idx) { - case mPM_ENTRY_TOWN: - editor_ovl->input_str = passwordMake_ovl->town_name; - break; - case mPM_ENTRY_PLAYER: - editor_ovl->input_str = passwordMake_ovl->player_name; - break; - } + editor_ovl->max_line_no = 1; + editor_ovl->now_str_len = passwordMake_ovl->lengths[next_idx]; - editor_ovl->max_line_no = 1; - editor_ovl->now_str_len = passwordMake_ovl->lengths[next_idx]; - - switch (editor_ovl->command) { - case mED_COMMAND_CURSOL_UPPER: - case mED_COMMAND_CURSOL_LOWER: - mED_set_idxcol_inLineWidth(editor_ovl); - break; - case mED_COMMAND_CURSOL_RIGHT: // ?? - editor_ovl->cursor_idx = 0; - break; - case mED_COMMAND_CURSOL_LEFT: // ?? - default: // ?? - editor_ovl->cursor_idx = editor_ovl->now_str_len; - break; - } + switch (editor_ovl->command) { + case mED_COMMAND_CURSOL_UPPER: + case mED_COMMAND_CURSOL_LOWER: + mED_set_idxcol_inLineWidth(editor_ovl); + break; + case mED_COMMAND_CURSOL_RIGHT: // ?? + editor_ovl->cursor_idx = 0; + break; + case mED_COMMAND_CURSOL_LEFT: // ?? + default: // ?? + editor_ovl->cursor_idx = editor_ovl->now_str_len; + break; + } } static void mED_edit_func_pw_make(Submenu* submenu, mSM_MenuInfo_c* menu_info) { - int selected_idx; - mPM_Ovl_c* passwordMake_ovl = submenu->overlay->passwordMake_ovl; - mED_Ovl_c* editor_ovl = submenu->overlay->editor_ovl; - - selected_idx = passwordMake_ovl->selected_idx; - switch (editor_ovl->command) { - case mED_COMMAND_CURSOL_LEFT: - mED_move_cursol_left(editor_ovl); - break; - case mED_COMMAND_CURSOL_RIGHT: - mED_move_cursol_right(submenu, editor_ovl, mED_LINETYPE_PW); - break; - case mED_COMMAND_END_EDIT: - if (selected_idx == mPM_ENTRY_TOWN) { - editor_ovl->command = mED_COMMAND_CURSOL_LOWER; - } - else if (mMl_strlen(editor_ovl->input_str, editor_ovl->input_length, CHAR_SPACE) == 0) { - editor_ovl->cursor_idx = 0; - editor_ovl->now_str_len = 0; - sAdo_SysTrgStart(0x1003); - } - else { - mED_end_edit_func(submenu, menu_info); - } - break; - case mED_COMMAND_BACKSPACE: - mED_backspace_func(editor_ovl); - break; - case mED_COMMAND_EXCHANGE_CODE: - mED_exchange_code_func(editor_ovl); - break; - case mED_COMMAND_OUTPUT_CODE: - mED_input_pw_make_line(submenu, editor_ovl); - break; - } + int selected_idx; + mPM_Ovl_c* passwordMake_ovl = submenu->overlay->passwordMake_ovl; + mED_Ovl_c* editor_ovl = submenu->overlay->editor_ovl; - passwordMake_ovl->lengths[selected_idx] = editor_ovl->now_str_len; + selected_idx = passwordMake_ovl->selected_idx; + switch (editor_ovl->command) { + case mED_COMMAND_CURSOL_LEFT: + mED_move_cursol_left(editor_ovl); + break; + case mED_COMMAND_CURSOL_RIGHT: + mED_move_cursol_right(submenu, editor_ovl, mED_LINETYPE_PW); + break; + case mED_COMMAND_END_EDIT: + if (selected_idx == mPM_ENTRY_TOWN) { + editor_ovl->command = mED_COMMAND_CURSOL_LOWER; + } else if (mMl_strlen(editor_ovl->input_str, editor_ovl->input_length, CHAR_SPACE) == 0) { + editor_ovl->cursor_idx = 0; + editor_ovl->now_str_len = 0; + sAdo_SysTrgStart(0x1003); + } else { + mED_end_edit_func(submenu, menu_info); + } + break; + case mED_COMMAND_BACKSPACE: + mED_backspace_func(editor_ovl); + break; + case mED_COMMAND_EXCHANGE_CODE: + mED_exchange_code_func(editor_ovl); + break; + case mED_COMMAND_OUTPUT_CODE: + mED_input_pw_make_line(submenu, editor_ovl); + break; + } - if (editor_ovl->command_processed == FALSE) { - mED_move_pw_make_table(editor_ovl, passwordMake_ovl); - } + passwordMake_ovl->lengths[selected_idx] = editor_ovl->now_str_len; + + if (editor_ovl->command_processed == FALSE) { + mED_move_pw_make_table(editor_ovl, passwordMake_ovl); + } } static void mED_move_pw_chk_table(mED_Ovl_c* editor_ovl, mPC_Ovl_c* passwordChk_ovl) { - int next_line; - - switch (editor_ovl->command) { - case mED_COMMAND_CURSOL_LOWER: - next_line = passwordChk_ovl->selected_line + 1; - break; - case mED_COMMAND_CURSOL_UPPER: - next_line = passwordChk_ovl->selected_line - 1; - break; - default: - return; - } + int next_line; - if (next_line < 0 || next_line >= mPC_LINE_COUNT) { - return; - } + switch (editor_ovl->command) { + case mED_COMMAND_CURSOL_LOWER: + next_line = passwordChk_ovl->selected_line + 1; + break; + case mED_COMMAND_CURSOL_UPPER: + next_line = passwordChk_ovl->selected_line - 1; + break; + default: + return; + } - editor_ovl->command_processed = TRUE; - passwordChk_ovl->selected_line = (u8)next_line; + if (next_line < 0 || next_line >= mPC_LINE_COUNT) { + return; + } - switch (next_line) { - case 0: - editor_ovl->input_str = passwordChk_ovl->line0; - break; - case 1: - editor_ovl->input_str = passwordChk_ovl->line1; - break; - } + editor_ovl->command_processed = TRUE; + passwordChk_ovl->selected_line = (u8)next_line; + + switch (next_line) { + case 0: + editor_ovl->input_str = passwordChk_ovl->line0; + break; + case 1: + editor_ovl->input_str = passwordChk_ovl->line1; + break; + } } static void mED_edit_func_pw_chk(Submenu* submenu, mSM_MenuInfo_c* menu_info) { - int selected_idx; - mPC_Ovl_c* passwordChk_ovl = submenu->overlay->passwordChk_ovl; - mED_Ovl_c* editor_ovl = submenu->overlay->editor_ovl; + int selected_idx; + mPC_Ovl_c* passwordChk_ovl = submenu->overlay->passwordChk_ovl; + mED_Ovl_c* editor_ovl = submenu->overlay->editor_ovl; - selected_idx = passwordChk_ovl->selected_line; - switch (editor_ovl->command) { - case mED_COMMAND_CURSOL_LEFT: - if (editor_ovl->cursor_idx > 0) { - editor_ovl->cursor_idx--; - editor_ovl->command_processed = TRUE; - } - else { - sAdo_SysTrgStart(0x1003); - } - break; - case mED_COMMAND_CURSOL_RIGHT: - if (editor_ovl->cursor_idx < editor_ovl->input_length) { - editor_ovl->cursor_idx++; - editor_ovl->command_processed = TRUE; - } - else { - sAdo_SysTrgStart(0x1003); - } - break; - case mED_COMMAND_END_EDIT: - if (passwordChk_ovl->line1[mPC_STR_SIZE - 1] != CHAR_SPACE && mED_check_pw_usable_letter(passwordChk_ovl) == FALSE) { - mED_open_warning_window(submenu, menu_info, mWR_WARNING_PW_CHK); - } - else { - mED_end_edit_func(submenu, menu_info); - } - break; - case mED_COMMAND_BACKSPACE: - mED_backspace_func_pw_chk(editor_ovl, passwordChk_ovl); - break; - case mED_COMMAND_EXCHANGE_CODE: - mED_exchange_code_func(editor_ovl); - break; - case mED_COMMAND_OUTPUT_CODE: - mED_input_pw_chk_line(submenu, editor_ovl); - break; - } + selected_idx = passwordChk_ovl->selected_line; + switch (editor_ovl->command) { + case mED_COMMAND_CURSOL_LEFT: + if (editor_ovl->cursor_idx > 0) { + editor_ovl->cursor_idx--; + editor_ovl->command_processed = TRUE; + } else { + sAdo_SysTrgStart(0x1003); + } + break; + case mED_COMMAND_CURSOL_RIGHT: + if (editor_ovl->cursor_idx < editor_ovl->input_length) { + editor_ovl->cursor_idx++; + editor_ovl->command_processed = TRUE; + } else { + sAdo_SysTrgStart(0x1003); + } + break; + case mED_COMMAND_END_EDIT: + if (passwordChk_ovl->line1[mPC_STR_SIZE - 1] != CHAR_SPACE && + mED_check_pw_usable_letter(passwordChk_ovl) == FALSE) { + mED_open_warning_window(submenu, menu_info, mWR_WARNING_PW_CHK); + } else { + mED_end_edit_func(submenu, menu_info); + } + break; + case mED_COMMAND_BACKSPACE: + mED_backspace_func_pw_chk(editor_ovl, passwordChk_ovl); + break; + case mED_COMMAND_EXCHANGE_CODE: + mED_exchange_code_func(editor_ovl); + break; + case mED_COMMAND_OUTPUT_CODE: + mED_input_pw_chk_line(submenu, editor_ovl); + break; + } - if (editor_ovl->command_processed == FALSE) { - mED_move_pw_chk_table(editor_ovl, passwordChk_ovl); - } + if (editor_ovl->command_processed == FALSE) { + mED_move_pw_chk_table(editor_ovl, passwordChk_ovl); + } } static void mED_move_Move(Submenu* submenu, mSM_MenuInfo_c* menu_info) { - (*submenu->overlay->move_Move_proc)(submenu, menu_info); + (*submenu->overlay->move_Move_proc)(submenu, menu_info); } typedef void (*mED_EDIT_FUNC)(Submenu*, mSM_MenuInfo_c*); static void mED_move_Play(Submenu* submenu, mSM_MenuInfo_c* menu_info) { - static mED_EDIT_FUNC mED_edit_func[mED_TYPE_NUM] = { - &mED_edit_func_letter, - &mED_edit_func_multi_line, - &mED_edit_func_multi_line, - &mED_edit_func_single_line, - &mED_edit_func_single_line, - &mED_edit_func_diary, - &mED_edit_func_pw_make, - &mED_edit_func_pw_chk - }; + static mED_EDIT_FUNC mED_edit_func[mED_TYPE_NUM] = { &mED_edit_func_letter, &mED_edit_func_multi_line, + &mED_edit_func_multi_line, &mED_edit_func_single_line, + &mED_edit_func_single_line, &mED_edit_func_diary, + &mED_edit_func_pw_make, &mED_edit_func_pw_chk }; - mED_Ovl_c* editor_ovl = submenu->overlay->editor_ovl; - mBD_Ovl_c* board_ovl; + mED_Ovl_c* editor_ovl = submenu->overlay->editor_ovl; + mBD_Ovl_c* board_ovl; - editor_ovl->command_processed = FALSE; - if (submenu->overlay->address_ovl != NULL && submenu->overlay->menu_info[mSM_OVL_ADDRESS].next_proc_status == mSM_OVL_PROC_WAIT) { - editor_ovl->stick_area = mED_STICK_AREA_CENTER; - editor_ovl->command = mED_COMMAND_NONE; - editor_ovl->last_buttons = (getButton() | getTrigger()) & (BUTTON_B | BUTTON_DRIGHT | BUTTON_DLEFT | BUTTON_DDOWN | BUTTON_DUP); - editor_ovl->_10 = 30; - editor_ovl->_0F = 26; - editor_ovl->_0E = 0; + editor_ovl->command_processed = FALSE; + if (submenu->overlay->address_ovl != NULL && + submenu->overlay->menu_info[mSM_OVL_ADDRESS].next_proc_status == mSM_OVL_PROC_WAIT) { + editor_ovl->stick_area = mED_STICK_AREA_CENTER; + editor_ovl->command = mED_COMMAND_NONE; + editor_ovl->last_buttons = + (getButton() | getTrigger()) & (BUTTON_B | BUTTON_DRIGHT | BUTTON_DLEFT | BUTTON_DDOWN | BUTTON_DUP); + editor_ovl->_10 = 30; + editor_ovl->_0F = 26; + editor_ovl->_0E = 0; - if (submenu->overlay->address_ovl->editor_move_down) { - board_ovl = submenu->overlay->board_ovl; + if (submenu->overlay->address_ovl->editor_move_down) { + board_ovl = submenu->overlay->board_ovl; - if (board_ovl != NULL) { - submenu->overlay->address_ovl->editor_move_down = FALSE; - editor_ovl->command = mED_COMMAND_CURSOL_LOWER; - mED_move_letter_table(editor_ovl, board_ovl, submenu); - editor_ovl->exchange_code = mED_get_exchange_code(editor_ovl); - } - } - } - else { - editor_ovl->cursol_opacity_step++; + if (board_ovl != NULL) { + submenu->overlay->address_ovl->editor_move_down = FALSE; + editor_ovl->command = mED_COMMAND_CURSOL_LOWER; + mED_move_letter_table(editor_ovl, board_ovl, submenu); + editor_ovl->exchange_code = mED_get_exchange_code(editor_ovl); + } + } + } else { + editor_ovl->cursol_opacity_step++; - if (editor_ovl->cursol_opacity_step == 35) { - editor_ovl->cursol_opacity_step = 0; + if (editor_ovl->cursol_opacity_step == 35) { + editor_ovl->cursol_opacity_step = 0; + } + + mED_set_stick_area(editor_ovl); + mED_move_keyboard_cursor(editor_ovl); + mED_set_command(editor_ovl); + (*mED_edit_func[menu_info->data0])(submenu, menu_info); + + if (editor_ovl->command_processed) { + mED_set_se(submenu); + editor_ovl->exchange_code = mED_get_exchange_code(editor_ovl); + + if (editor_ovl->command == mED_COMMAND_CURSOL_RIGHT || editor_ovl->command == mED_COMMAND_CURSOL_LEFT || + editor_ovl->command == mED_COMMAND_CURSOL_UPPER || editor_ovl->command == mED_COMMAND_CURSOL_LOWER || + editor_ovl->command == mED_COMMAND_BACKSPACE || editor_ovl->command == mED_COMMAND_OUTPUT_CODE) { + editor_ovl->cursol_opacity_step = 0; + } + } } - mED_set_stick_area(editor_ovl); - mED_move_keyboard_cursor(editor_ovl); - mED_set_command(editor_ovl); - (*mED_edit_func[menu_info->data0])(submenu, menu_info); - - if (editor_ovl->command_processed) { - mED_set_se(submenu); - editor_ovl->exchange_code = mED_get_exchange_code(editor_ovl); - - if ( - editor_ovl->command == mED_COMMAND_CURSOL_RIGHT || - editor_ovl->command == mED_COMMAND_CURSOL_LEFT || - editor_ovl->command == mED_COMMAND_CURSOL_UPPER || - editor_ovl->command == mED_COMMAND_CURSOL_LOWER || - editor_ovl->command == mED_COMMAND_BACKSPACE || - editor_ovl->command == mED_COMMAND_OUTPUT_CODE - ) { - editor_ovl->cursol_opacity_step = 0; - } - } - } - - mED_get_col_line_width(menu_info, editor_ovl, &editor_ovl->_22, &editor_ovl->_24, &editor_ovl->_26, editor_ovl->cursor_idx); - mED_check_line_over(editor_ovl); + mED_get_col_line_width(menu_info, editor_ovl, &editor_ovl->_22, &editor_ovl->_24, &editor_ovl->_26, + editor_ovl->cursor_idx); + mED_check_line_over(editor_ovl); } static void mED_move_Wait(Submenu* submenu, mSM_MenuInfo_c* menu_info) { - if (submenu->menu_type != menu_info->next_menu_type) { - menu_info->proc_status = mSM_OVL_PROC_PLAY; - } + if (submenu->menu_type != menu_info->next_menu_type) { + menu_info->proc_status = mSM_OVL_PROC_PLAY; + } } static void mED_move_End(Submenu* submenu, mSM_MenuInfo_c* menu_info) { - submenu->overlay->editor_ovl->_22 = 0; - (*submenu->overlay->move_End_proc)(submenu, menu_info); + submenu->overlay->editor_ovl->_22 = 0; + (*submenu->overlay->move_End_proc)(submenu, menu_info); } -typedef void(*mED_OVL_MOVE_PROC)(Submenu*, mSM_MenuInfo_c*); +typedef void (*mED_OVL_MOVE_PROC)(Submenu*, mSM_MenuInfo_c*); static void mED_editor_ovl_move(Submenu* submenu) { - static mED_OVL_MOVE_PROC ovl_move_proc[mSM_OVL_PROC_NUM] = { - &mED_move_Move, - &mED_move_Play, - &mED_move_Wait, - (mED_OVL_MOVE_PROC)&none_proc1, - &mED_move_End - }; + static mED_OVL_MOVE_PROC ovl_move_proc[mSM_OVL_PROC_NUM] = { &mED_move_Move, &mED_move_Play, &mED_move_Wait, + (mED_OVL_MOVE_PROC)&none_proc1, &mED_move_End }; - Submenu_Overlay_c* overlay = submenu->overlay; - mSM_MenuInfo_c* menu_info = &overlay->menu_info[mSM_OVL_EDITOR]; + Submenu_Overlay_c* overlay = submenu->overlay; + mSM_MenuInfo_c* menu_info = &overlay->menu_info[mSM_OVL_EDITOR]; - (*menu_info->pre_move_func)(submenu); - (*ovl_move_proc[menu_info->proc_status])(submenu, menu_info); + (*menu_info->pre_move_func)(submenu); + (*ovl_move_proc[menu_info->proc_status])(submenu, menu_info); } extern u8 kai_sousa_button1a_tex_rgb_ia8[]; @@ -1921,26 +1783,23 @@ extern u8 kai_sousa_button1b_tex_rgb_ia8[]; extern Gfx kai_sousa_abuttonT_model[]; static void mED_KeyDraw_A_button(GRAPH* graph) { - static u8* tex[] = { - kai_sousa_button1a_tex_rgb_ia8, - kai_sousa_button1b_tex_rgb_ia8 - }; + static u8* tex[] = { kai_sousa_button1a_tex_rgb_ia8, kai_sousa_button1b_tex_rgb_ia8 }; - int key = 0; - Gfx* gfx; + int key = 0; + Gfx* gfx; - if (chkButton(BUTTON_A)) { - key = 1; - } + if (chkButton(BUTTON_A)) { + key = 1; + } - OPEN_DISP(graph); - gfx = NOW_POLY_OPA_DISP; - - gSPSegment(gfx++, G_MWO_SEGMENT_8, tex[key]); - gSPDisplayList(gfx++, kai_sousa_abuttonT_model); + OPEN_DISP(graph); + gfx = NOW_POLY_OPA_DISP; - SET_POLY_OPA_DISP(gfx); - CLOSE_DISP(graph); + gSPSegment(gfx++, G_MWO_SEGMENT_8, tex[key]); + gSPDisplayList(gfx++, kai_sousa_abuttonT_model); + + SET_POLY_OPA_DISP(gfx); + CLOSE_DISP(graph); } extern u8 kai_sousa_button2a_tex_rgb_ia8[]; @@ -1949,27 +1808,24 @@ extern Gfx kai_sousa_bbuttonT_model[]; extern Gfx kai_sousa_cancelT_model[]; static void mED_KeyDraw_B_button(GRAPH* graph) { - static u8* tex[] = { - kai_sousa_button2a_tex_rgb_ia8, - kai_sousa_button2b_tex_rgb_ia8 - }; + static u8* tex[] = { kai_sousa_button2a_tex_rgb_ia8, kai_sousa_button2b_tex_rgb_ia8 }; - int key = 0; - Gfx* gfx; + int key = 0; + Gfx* gfx; - if (chkButton(BUTTON_B)) { - key = 1; - } + if (chkButton(BUTTON_B)) { + key = 1; + } - OPEN_DISP(graph); - gfx = NOW_POLY_OPA_DISP; - - gSPSegment(gfx++, G_MWO_SEGMENT_8, tex[key]); - gSPDisplayList(gfx++, kai_sousa_bbuttonT_model); - gSPDisplayList(gfx++, kai_sousa_cancelT_model); + OPEN_DISP(graph); + gfx = NOW_POLY_OPA_DISP; - SET_POLY_OPA_DISP(gfx); - CLOSE_DISP(graph); + gSPSegment(gfx++, G_MWO_SEGMENT_8, tex[key]); + gSPDisplayList(gfx++, kai_sousa_bbuttonT_model); + gSPDisplayList(gfx++, kai_sousa_cancelT_model); + + SET_POLY_OPA_DISP(gfx); + CLOSE_DISP(graph); } extern u8 kai_sousa_xbutton_tex_rgb_ia8[]; @@ -1979,32 +1835,29 @@ extern Gfx kai_sousa_henkan_model[]; extern Gfx kai_sousa_yajirushi_model[]; static void mED_KeyDraw_X_button(GRAPH* graph, mED_Ovl_c* editor_ovl) { - static u8* tex[] = { - kai_sousa_xbutton_tex_rgb_ia8, - kai_sousa_xbutton2_tex_rgb_ia8 - }; + static u8* tex[] = { kai_sousa_xbutton_tex_rgb_ia8, kai_sousa_xbutton2_tex_rgb_ia8 }; - int key = 0; - Gfx* gfx; + int key = 0; + Gfx* gfx; - if (chkButton(BUTTON_X)) { - key = 1; - } + if (chkButton(BUTTON_X)) { + key = 1; + } - OPEN_DISP(graph); - gfx = NOW_POLY_OPA_DISP; - - gSPSegment(gfx++, G_MWO_SEGMENT_8, tex[key]); - gSPDisplayList(gfx++, kai_sousa_henkan_model); + OPEN_DISP(graph); + gfx = NOW_POLY_OPA_DISP; - if (editor_ovl->exchange_code != -1) { - gSPDisplayList(gfx++, kai_sousa_yajirushi_model); - } + gSPSegment(gfx++, G_MWO_SEGMENT_8, tex[key]); + gSPDisplayList(gfx++, kai_sousa_henkan_model); - gSPDisplayList(gfx++, kai_sousa_xbuttonT_model); + if (editor_ovl->exchange_code != -1) { + gSPDisplayList(gfx++, kai_sousa_yajirushi_model); + } - SET_POLY_OPA_DISP(gfx); - CLOSE_DISP(graph); + gSPDisplayList(gfx++, kai_sousa_xbuttonT_model); + + SET_POLY_OPA_DISP(gfx); + CLOSE_DISP(graph); } extern u8 kai_sousa_ybutton_tex_rgb_ia8[]; @@ -2016,77 +1869,66 @@ extern Gfx kai_sousa_sign_model[]; extern Gfx kai_sousa_mark_model[]; static void mED_KeyDraw_Y_button(GRAPH* graph, mED_Ovl_c* editor_ovl) { - static u8* tex[] = { - kai_sousa_ybutton_tex_rgb_ia8, - kai_sousa_ybutton2_tex_rgb_ia8 - }; + static u8* tex[] = { kai_sousa_ybutton_tex_rgb_ia8, kai_sousa_ybutton2_tex_rgb_ia8 }; - static Gfx* dl[mED_INPUT_MODE_NUM] = { - kai_sousa_letter_model, - kai_sousa_sign_model, - kai_sousa_mark_model - }; + static Gfx* dl[mED_INPUT_MODE_NUM] = { kai_sousa_letter_model, kai_sousa_sign_model, kai_sousa_mark_model }; - /* r, g, b, a, l */ - static u8 prim[2][5] = { - { 155, 155, 160, 255, 255 }, - { 225, 255, 255, 255, 255 } - }; + /* r, g, b, a, l */ + static u8 prim[2][5] = { { 155, 155, 160, 255, 255 }, { 225, 255, 255, 255, 255 } }; - int mode = editor_ovl->input_mode; - int key = 0; - Gfx* gfx; - int i; + int mode = editor_ovl->input_mode; + int key = 0; + Gfx* gfx; + int i; - if (chkButton(BUTTON_Y)) { - key = 1; - } - - OPEN_DISP(graph); - gfx = NOW_POLY_OPA_DISP; - - gSPSegment(gfx++, G_MWO_SEGMENT_8, tex[key]); - gSPDisplayList(gfx++, kai_sousa_kirikae_model); - - for (i = 0; i < mED_INPUT_MODE_NUM; i++) { - u8* col; - - if (i == mode) { - col = prim[1]; - } - else { - col = prim[0]; + if (chkButton(BUTTON_Y)) { + key = 1; } - gDPSetPrimColor(gfx++, 0, col[4], col[0], col[1], col[2], col[3]); - gSPDisplayList(gfx++, dl[i]); - } + OPEN_DISP(graph); + gfx = NOW_POLY_OPA_DISP; - gSPDisplayList(gfx++, kai_sousa_ybuttonT_model); + gSPSegment(gfx++, G_MWO_SEGMENT_8, tex[key]); + gSPDisplayList(gfx++, kai_sousa_kirikae_model); - SET_POLY_OPA_DISP(gfx); - CLOSE_DISP(graph); + for (i = 0; i < mED_INPUT_MODE_NUM; i++) { + u8* col; + + if (i == mode) { + col = prim[1]; + } else { + col = prim[0]; + } + + gDPSetPrimColor(gfx++, 0, col[4], col[0], col[1], col[2], col[3]); + gSPDisplayList(gfx++, dl[i]); + } + + gSPDisplayList(gfx++, kai_sousa_ybuttonT_model); + + SET_POLY_OPA_DISP(gfx); + CLOSE_DISP(graph); } extern Gfx kai_sousa_startbuttonT_model[]; extern Gfx kai_sousa_endT_model[]; static void mED_KeyDraw_START_button(GRAPH* graph) { - Gfx* gfx; + Gfx* gfx; - OPEN_DISP(graph); - gfx = NOW_POLY_OPA_DISP; - - gSPDisplayList(gfx++, kai_sousa_startbuttonT_model); - gSPDisplayList(gfx++, kai_sousa_endT_model); + OPEN_DISP(graph); + gfx = NOW_POLY_OPA_DISP; - SET_POLY_OPA_DISP(gfx); - CLOSE_DISP(graph); + gSPDisplayList(gfx++, kai_sousa_startbuttonT_model); + gSPDisplayList(gfx++, kai_sousa_endT_model); + + SET_POLY_OPA_DISP(gfx); + CLOSE_DISP(graph); } typedef struct l_button_info_s { - u8* tex; - int prim; + u8* tex; + int prim; } mED_L_button_info_c; extern u8 kai_sousa_caps_tex_rgb_i4[]; @@ -2098,67 +1940,51 @@ extern Gfx kai_sousa_lmoji_model[]; extern Gfx kai_sousa_lbuttonT_model[]; static void mED_KeyDraw_L_button(GRAPH* graph, mED_Ovl_c* editor_ovl) { - static mED_L_button_info_c data[mED_INPUT_MODE_NUM][mED_SHIFT_NUM] = { - { - { kai_sousa_caps_tex_rgb_i4, 0 }, - { kai_sousa_small_tex_rgb_i4, 1 } - }, - { - { NULL, 0 }, - { NULL, 0 } - }, - { - { NULL, 0 }, - { NULL, 0 } + static mED_L_button_info_c data[mED_INPUT_MODE_NUM][mED_SHIFT_NUM] = { { { kai_sousa_caps_tex_rgb_i4, 0 }, + { kai_sousa_small_tex_rgb_i4, 1 } }, + { { NULL, 0 }, { NULL, 0 } }, + { { NULL, 0 }, { NULL, 0 } } }; + + static u8* btn_tex[] = { kai_sousa_lbutton_tex_rgb_ia8, kai_sousa_lbutton2_tex_rgb_ia8 }; + + /* r, g, b, a, l */ + static u8 prim[2][5] = { { 30, 30, 215, 255, 255 }, { 215, 30, 30, 255, 255 } }; + + int key = 0; + Gfx* gfx; + int prim_idx; + u8* col; + int i; + int mode; + int shift; + mED_L_button_info_c* button_info; + + if (chkButton(BUTTON_L)) { + key = 1; } - }; - static u8* btn_tex[] = { - kai_sousa_lbutton_tex_rgb_ia8, - kai_sousa_lbutton2_tex_rgb_ia8 - }; + mode = editor_ovl->input_mode; + shift = editor_ovl->shift_mode; - /* r, g, b, a, l */ - static u8 prim[2][5] = { - { 30, 30, 215, 255, 255 }, - { 215, 30, 30, 255, 255 } - }; + OPEN_DISP(graph); + gfx = NOW_POLY_OPA_DISP; + button_info = &data[mode][shift]; + col = prim[button_info->prim]; - int key = 0; - Gfx* gfx; - int prim_idx; - u8* col; - int i; - int mode; - int shift; - mED_L_button_info_c* button_info; + gDPPipeSync(gfx++); + gDPSetPrimColor(gfx++, 0, col[4], col[0], col[1], col[2], col[3]); + gSPDisplayList(gfx++, kai_sousa_lwaku_model); - if (chkButton(BUTTON_L)) { - key = 1; - } + if (data[mode][shift].tex != NULL) { + gSPSegment(gfx++, G_MWO_SEGMENT_8, button_info->tex); + gSPDisplayList(gfx++, kai_sousa_lmoji_model); + } - mode = editor_ovl->input_mode; - shift = editor_ovl->shift_mode; - - OPEN_DISP(graph); - gfx = NOW_POLY_OPA_DISP; - button_info = &data[mode][shift]; - col = prim[button_info->prim]; - - gDPPipeSync(gfx++); - gDPSetPrimColor(gfx++, 0, col[4], col[0], col[1], col[2], col[3]); - gSPDisplayList(gfx++, kai_sousa_lwaku_model); + gSPSegment(gfx++, G_MWO_SEGMENT_8, btn_tex[key]); + gSPDisplayList(gfx++, kai_sousa_lbuttonT_model); - if (data[mode][shift].tex != NULL) { - gSPSegment(gfx++, G_MWO_SEGMENT_8, button_info->tex); - gSPDisplayList(gfx++, kai_sousa_lmoji_model); - } - - gSPSegment(gfx++, G_MWO_SEGMENT_8, btn_tex[key]); - gSPDisplayList(gfx++, kai_sousa_lbuttonT_model); - - SET_POLY_OPA_DISP(gfx); - CLOSE_DISP(graph); + SET_POLY_OPA_DISP(gfx); + CLOSE_DISP(graph); } extern u8 kai_sousa_rbutton_tex_rgb_ia8[]; @@ -2167,112 +1993,99 @@ extern Gfx kai_sousa_rbuttonT_model[]; extern Gfx kai_sousa_spaceT_model[]; static void mED_KeyDraw_R_button(GRAPH* graph, mED_Ovl_c* editor_ovl) { - static u8* btn_tex[] = { - kai_sousa_rbutton_tex_rgb_ia8, - kai_sousa_rbutton2_tex_rgb_ia8 - }; + static u8* btn_tex[] = { kai_sousa_rbutton_tex_rgb_ia8, kai_sousa_rbutton2_tex_rgb_ia8 }; - int key = 0; - Gfx* gfx; + int key = 0; + Gfx* gfx; - if (chkButton(BUTTON_R)) { - key = 1; - } + if (chkButton(BUTTON_R)) { + key = 1; + } - OPEN_DISP(graph); - gfx = NOW_POLY_OPA_DISP; - - gSPSegment(gfx++, G_MWO_SEGMENT_8, btn_tex[key]); - gSPDisplayList(gfx++, kai_sousa_rbuttonT_model); - gSPDisplayList(gfx++, kai_sousa_spaceT_model); + OPEN_DISP(graph); + gfx = NOW_POLY_OPA_DISP; - SET_POLY_OPA_DISP(gfx); - CLOSE_DISP(graph); + gSPSegment(gfx++, G_MWO_SEGMENT_8, btn_tex[key]); + gSPDisplayList(gfx++, kai_sousa_rbuttonT_model); + gSPDisplayList(gfx++, kai_sousa_spaceT_model); + + SET_POLY_OPA_DISP(gfx); + CLOSE_DISP(graph); } extern Vtx kai_sousa2_v[]; extern u8 testbutton[]; static void mED_KeyDraw_keyboard(GRAPH* graph, mED_Ovl_c* editor_ovl) { - static u8 model_type[mED_COLUMNS * mED_ROWS] = { - 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, - 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, - 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, - 0, 0, 1, 1, 1, 1, 0, 0, 0, 0 - }; + static u8 model_type[mED_COLUMNS * mED_ROWS] = { 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, + 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0 }; - static rgba_t sel_col[2] = { - { 205, 0, 0, 255 }, - { 0, 0, 205, 255 } - }; + static rgba_t sel_col[2] = { { 205, 0, 0, 255 }, { 0, 0, 205, 255 } }; - Vtx* vert = &kai_sousa2_v[0]; - u8* mtype = &model_type[0]; - int selected_col; - int selected_row; - rgba_t* color; - int selected = TRUE; - int col_idx = 0; - int col; - int row; - Gfx* gfx; + Vtx* vert = &kai_sousa2_v[0]; + u8* mtype = &model_type[0]; + int selected_col; + int selected_row; + rgba_t* color; + int selected = TRUE; + int col_idx = 0; + int col; + int row; + Gfx* gfx; - if (editor_ovl->input_mode == mED_INPUT_MODE_LETTER && editor_ovl->shift_mode == mED_SHIFT_UPPER) { - col_idx = 1; - } - - selected_col = editor_ovl->select_col; - selected_row = editor_ovl->select_row; - color = &sel_col[col_idx]; - - OPEN_DISP(graph); - gfx = NOW_POLY_OPA_DISP; - - gSPMatrix(gfx++, _Matrix_to_Mtx_new(graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPTexture(gfx++, 0, 0, 0, G_TX_RENDERTILE, G_ON); - gDPSetCombineLERP(gfx++, 0, 0, 0, PRIMITIVE, 0, 0, 0, TEXEL0, 0, 0, 0, COMBINED, 0, 0, 0, COMBINED); - - for (row = 0; row < mED_ROWS; row++) { - for (col = 0; col < mED_COLUMNS; col++) { - if (col == selected_col && row == selected_row) { - gDPSetPrimColor(gfx++, 0, 255, color->r, color->g, color->b, 255); - selected = TRUE; - } - else if (selected == TRUE) { - gDPSetPrimColor(gfx++, 0, 255, 255, 255, 255, 255); - selected = FALSE; - } - - gDPSetTextureImage_Dolphin(gfx++, G_IM_FMT_I, G_IM_SIZ_4b, 16, 16, testbutton); - gDPSetTile_Dolphin(gfx++, G_DOLPHIN_TLUT_DEFAULT_MODE, G_TX_RENDERTILE, 15, GX_MIRROR, GX_MIRROR, GX_CLAMP, GX_CLAMP); - gSPVertex(gfx++, vert, 4, 0); - - if (*mtype != 0) { - gSPNTrianglesInit_5b( - gfx++, - 2, // tri count - 0, 1, 2, // tri0 - 3, 0, 2, // tri1 - 0, 0, 0 // tri2 - ); - } - else { - gSPNTrianglesInit_5b( - gfx++, - 2, // tri count - 0, 1, 2, // tri0 - 1, 3, 2, // tri1 - 0, 0, 0 // tri2 - ); - } - - vert += 4; - mtype++; + if (editor_ovl->input_mode == mED_INPUT_MODE_LETTER && editor_ovl->shift_mode == mED_SHIFT_UPPER) { + col_idx = 1; } - } - SET_POLY_OPA_DISP(gfx); - CLOSE_DISP(graph); + selected_col = editor_ovl->select_col; + selected_row = editor_ovl->select_row; + color = &sel_col[col_idx]; + + OPEN_DISP(graph); + gfx = NOW_POLY_OPA_DISP; + + gSPMatrix(gfx++, _Matrix_to_Mtx_new(graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPTexture(gfx++, 0, 0, 0, G_TX_RENDERTILE, G_ON); + gDPSetCombineLERP(gfx++, 0, 0, 0, PRIMITIVE, 0, 0, 0, TEXEL0, 0, 0, 0, COMBINED, 0, 0, 0, COMBINED); + + for (row = 0; row < mED_ROWS; row++) { + for (col = 0; col < mED_COLUMNS; col++) { + if (col == selected_col && row == selected_row) { + gDPSetPrimColor(gfx++, 0, 255, color->r, color->g, color->b, 255); + selected = TRUE; + } else if (selected == TRUE) { + gDPSetPrimColor(gfx++, 0, 255, 255, 255, 255, 255); + selected = FALSE; + } + + gDPSetTextureImage_Dolphin(gfx++, G_IM_FMT_I, G_IM_SIZ_4b, 16, 16, testbutton); + gDPSetTile_Dolphin(gfx++, G_DOLPHIN_TLUT_DEFAULT_MODE, G_TX_RENDERTILE, 15, GX_MIRROR, GX_MIRROR, GX_CLAMP, + GX_CLAMP); + gSPVertex(gfx++, vert, 4, 0); + + if (*mtype != 0) { + gSPNTrianglesInit_5b(gfx++, + 2, // tri count + 0, 1, 2, // tri0 + 3, 0, 2, // tri1 + 0, 0, 0 // tri2 + ); + } else { + gSPNTrianglesInit_5b(gfx++, + 2, // tri count + 0, 1, 2, // tri0 + 1, 3, 2, // tri1 + 0, 0, 0 // tri2 + ); + } + + vert += 4; + mtype++; + } + } + + SET_POLY_OPA_DISP(gfx); + CLOSE_DISP(graph); } extern u8 kai_sousa_controllpad1_tex_rgb_ia8[]; @@ -2285,39 +2098,32 @@ extern Gfx kai_sousa_controllpadT_model[]; extern Gfx kai_sousa_cursorT_model[]; static void mED_KeyDraw_J_key(GRAPH* graph) { - static u8* tex[5] = { - kai_sousa_controllpad1_tex_rgb_ia8, - kai_sousa_controllpad3_tex_rgb_ia8, - kai_sousa_controllpad4_tex_rgb_ia8, - kai_sousa_controllpad5_tex_rgb_ia8, - kai_sousa_controllpad2_tex_rgb_ia8 - }; + static u8* tex[5] = { kai_sousa_controllpad1_tex_rgb_ia8, kai_sousa_controllpad3_tex_rgb_ia8, + kai_sousa_controllpad4_tex_rgb_ia8, kai_sousa_controllpad5_tex_rgb_ia8, + kai_sousa_controllpad2_tex_rgb_ia8 }; - int tex_idx = 0; - Gfx* gfx; + int tex_idx = 0; + Gfx* gfx; - if (chkButton(BUTTON_DLEFT)) { - tex_idx = 2; - } - else if (chkButton(BUTTON_DDOWN)) { - tex_idx = 1; - } - else if (chkButton(BUTTON_DUP)) { - tex_idx = 4; - } - else if (chkButton(BUTTON_DRIGHT)) { - tex_idx = 3; - } + if (chkButton(BUTTON_DLEFT)) { + tex_idx = 2; + } else if (chkButton(BUTTON_DDOWN)) { + tex_idx = 1; + } else if (chkButton(BUTTON_DUP)) { + tex_idx = 4; + } else if (chkButton(BUTTON_DRIGHT)) { + tex_idx = 3; + } - OPEN_DISP(graph); - gfx = NOW_POLY_OPA_DISP; + OPEN_DISP(graph); + gfx = NOW_POLY_OPA_DISP; - gSPSegment(gfx++, G_MWO_SEGMENT_8, tex[tex_idx]); - gSPDisplayList(gfx++, kai_sousa_controllpadT_model); - gSPDisplayList(gfx++, kai_sousa_cursorT_model); + gSPSegment(gfx++, G_MWO_SEGMENT_8, tex[tex_idx]); + gSPDisplayList(gfx++, kai_sousa_controllpadT_model); + gSPDisplayList(gfx++, kai_sousa_cursorT_model); - SET_POLY_OPA_DISP(gfx); - CLOSE_DISP(graph); + SET_POLY_OPA_DISP(gfx); + CLOSE_DISP(graph); } extern u8 kai_sousa_3Dst_tex_rgb_ia8[]; @@ -2331,43 +2137,36 @@ extern Gfx kai_sousa_3DT_model[]; extern Gfx kai_sousa_3DstT_model[]; static void mED_KeyDraw_3D_stick(GRAPH* graph, mED_Ovl_c* editor_ovl) { - static u8* tex[mED_STICK_AREA_NUM] = { - kai_sousa_3Dst4_tex_rgb_ia8, - kai_sousa_3Dst3_tex_rgb_ia8, - kai_sousa_3Dst2_tex_rgb_ia8, - kai_sousa_3Dst3_tex_rgb_ia8, - kai_sousa_3Dst4_tex_rgb_ia8, - kai_sousa_3Dst5_tex_rgb_ia8, - kai_sousa_3Dst6_tex_rgb_ia8, - kai_sousa_3Dst5_tex_rgb_ia8, - kai_sousa_3Dst_tex_rgb_ia8 - }; + static u8* tex[mED_STICK_AREA_NUM] = { kai_sousa_3Dst4_tex_rgb_ia8, kai_sousa_3Dst3_tex_rgb_ia8, + kai_sousa_3Dst2_tex_rgb_ia8, kai_sousa_3Dst3_tex_rgb_ia8, + kai_sousa_3Dst4_tex_rgb_ia8, kai_sousa_3Dst5_tex_rgb_ia8, + kai_sousa_3Dst6_tex_rgb_ia8, kai_sousa_3Dst5_tex_rgb_ia8, + kai_sousa_3Dst_tex_rgb_ia8 }; - int stick_area = editor_ovl->stick_area; - Gfx* gfx; + int stick_area = editor_ovl->stick_area; + Gfx* gfx; - Matrix_push(); + Matrix_push(); - if (stick_area >= mED_STICK_AREA_TOP_RIGHT && stick_area <= mED_STICK_AREA_BOTTOM_RIGHT) { - Matrix_translate(-111.0f, -50.0f, 0.0f, MTX_MULT); - Matrix_RotateY(DEG2SHORT_ANGLE(-180.0f), MTX_MULT); - } - else { - Matrix_translate(-110.0f, -50.0f, 0.0f, MTX_MULT); - } - - OPEN_DISP(graph); - gfx = NOW_POLY_OPA_DISP; + if (stick_area >= mED_STICK_AREA_TOP_RIGHT && stick_area <= mED_STICK_AREA_BOTTOM_RIGHT) { + Matrix_translate(-111.0f, -50.0f, 0.0f, MTX_MULT); + Matrix_RotateY(DEG2SHORT_ANGLE(-180.0f), MTX_MULT); + } else { + Matrix_translate(-110.0f, -50.0f, 0.0f, MTX_MULT); + } - gSPDisplayList(gfx++, kai_sousa_3DT_model); - gSPMatrix(gfx++, _Matrix_to_Mtx_new(graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPSegment(gfx++, G_MWO_SEGMENT_8, tex[stick_area]); - gSPDisplayList(gfx++, kai_sousa_3DstT_model); + OPEN_DISP(graph); + gfx = NOW_POLY_OPA_DISP; - SET_POLY_OPA_DISP(gfx); - CLOSE_DISP(graph); + gSPDisplayList(gfx++, kai_sousa_3DT_model); + gSPMatrix(gfx++, _Matrix_to_Mtx_new(graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(gfx++, G_MWO_SEGMENT_8, tex[stick_area]); + gSPDisplayList(gfx++, kai_sousa_3DstT_model); - Matrix_pull(); + SET_POLY_OPA_DISP(gfx); + CLOSE_DISP(graph); + + Matrix_pull(); } extern Gfx kai_sousa_mode[]; @@ -2377,42 +2176,42 @@ extern Gfx kai_sousa_controller2T_model[]; extern Gfx kai_sousa_mojibanT_model[]; static void mED_KeyDraw(mED_Ovl_c* editor_ovl, GRAPH* graph, f32 x, f32 y) { - Gfx* gfx; - - Matrix_scale(16.0f, 16.0f, 1.0f, MTX_LOAD); - Matrix_translate(x, y, 0.0f, MTX_MULT); + Gfx* gfx; - OPEN_DISP(graph); - gfx = NOW_POLY_OPA_DISP; + Matrix_scale(16.0f, 16.0f, 1.0f, MTX_LOAD); + Matrix_translate(x, y, 0.0f, MTX_MULT); - gSPMatrix(gfx++, _Matrix_to_Mtx_new(graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(gfx++, kai_sousa_mode); + OPEN_DISP(graph); + gfx = NOW_POLY_OPA_DISP; - SET_POLY_OPA_DISP(gfx); - CLOSE_DISP(graph); + gSPMatrix(gfx++, _Matrix_to_Mtx_new(graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(gfx++, kai_sousa_mode); - mED_KeyDraw_L_button(graph, editor_ovl); - mED_KeyDraw_R_button(graph, editor_ovl); + SET_POLY_OPA_DISP(gfx); + CLOSE_DISP(graph); - OPEN_DISP(graph); - gfx = NOW_POLY_OPA_DISP; + mED_KeyDraw_L_button(graph, editor_ovl); + mED_KeyDraw_R_button(graph, editor_ovl); - gSPDisplayList(gfx++, kai_sousa_shitaT_model); - gSPDisplayList(gfx++, kai_sousa_controllerT_model); - gSPDisplayList(gfx++, kai_sousa_controller2T_model); - gSPDisplayList(gfx++, kai_sousa_mojibanT_model); + OPEN_DISP(graph); + gfx = NOW_POLY_OPA_DISP; - SET_POLY_OPA_DISP(gfx); - CLOSE_DISP(graph); + gSPDisplayList(gfx++, kai_sousa_shitaT_model); + gSPDisplayList(gfx++, kai_sousa_controllerT_model); + gSPDisplayList(gfx++, kai_sousa_controller2T_model); + gSPDisplayList(gfx++, kai_sousa_mojibanT_model); - mED_KeyDraw_A_button(graph); - mED_KeyDraw_B_button(graph); - mED_KeyDraw_X_button(graph, editor_ovl); - mED_KeyDraw_Y_button(graph, editor_ovl); - mED_KeyDraw_START_button(graph); - mED_KeyDraw_J_key(graph); - mED_KeyDraw_3D_stick(graph, editor_ovl); - mED_KeyDraw_keyboard(graph, editor_ovl); + SET_POLY_OPA_DISP(gfx); + CLOSE_DISP(graph); + + mED_KeyDraw_A_button(graph); + mED_KeyDraw_B_button(graph); + mED_KeyDraw_X_button(graph, editor_ovl); + mED_KeyDraw_Y_button(graph, editor_ovl); + mED_KeyDraw_START_button(graph); + mED_KeyDraw_J_key(graph); + mED_KeyDraw_3D_stick(graph, editor_ovl); + mED_KeyDraw_keyboard(graph, editor_ovl); } extern Gfx kai_sousa_ink_mode[]; @@ -2421,300 +2220,276 @@ extern Gfx kai_sousa_inktuboT_model[]; extern Gfx kai_sousa_inkmojiT_model[]; static void mED_InkPotDraw(Submenu* submenu, mED_Ovl_c* editor_ovl, GRAPH* graph, f32 x, f32 y) { - f32 line_y; - f32 single_line_y; - Gfx* gfx; - Gfx* scroll_gfx; + f32 line_y; + f32 single_line_y; + Gfx* gfx; + Gfx* scroll_gfx; - /* Filter out editors without the inkpot */ - switch (submenu->overlay->menu_info[mSM_OVL_EDITOR].data0) { - case mED_TYPE_BOARD: - break; - case mED_TYPE_NOTICE: - break; - case mED_TYPE_DIARY: - break; - default: - return; - } - - Matrix_scale(16.0f, 16.0f, 1.0f, MTX_LOAD); - Matrix_translate(x, y, 0.0f, MTX_MULT); - single_line_y = 0.0f; - line_y = ((f32)editor_ovl->now_str_len * 15.0f) / (f32)(editor_ovl->input_length * editor_ovl->max_line_no); - - if (line_y > 15.0f) { - line_y = 15.0f; - } - - if (editor_ovl->max_line_no == 1) { - single_line_y = ((f32)mED_get_single_line_width(editor_ovl) * 15.0f) / (f32)editor_ovl->line_width; - - if (single_line_y > 15.0f) { - single_line_y = 15.0f; + /* Filter out editors without the inkpot */ + switch (submenu->overlay->menu_info[mSM_OVL_EDITOR].data0) { + case mED_TYPE_BOARD: + break; + case mED_TYPE_NOTICE: + break; + case mED_TYPE_DIARY: + break; + default: + return; } - } - if (line_y < single_line_y) { - line_y = single_line_y; - } + Matrix_scale(16.0f, 16.0f, 1.0f, MTX_LOAD); + Matrix_translate(x, y, 0.0f, MTX_MULT); + single_line_y = 0.0f; + line_y = ((f32)editor_ovl->now_str_len * 15.0f) / (f32)(editor_ovl->input_length * editor_ovl->max_line_no); - scroll_gfx = two_tex_scroll_dolphin( - graph, - 0, - 0, 0, 32, 32, - 1, - 0, line_y * 8.0f, 32, 32 - ); + if (line_y > 15.0f) { + line_y = 15.0f; + } - OPEN_DISP(graph); - gfx = NOW_POLY_OPA_DISP; + if (editor_ovl->max_line_no == 1) { + single_line_y = ((f32)mED_get_single_line_width(editor_ovl) * 15.0f) / (f32)editor_ovl->line_width; - gSPMatrix(gfx++, _Matrix_to_Mtx_new(graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPSegment(gfx++, G_MWO_SEGMENT_8, scroll_gfx); - gSPDisplayList(gfx++, kai_sousa_ink_mode); - gSPDisplayList(gfx++, kai_sousa_ink_model); - gSPDisplayList(gfx++, kai_sousa_inktuboT_model); - gSPDisplayList(gfx++, kai_sousa_inkmojiT_model); + if (single_line_y > 15.0f) { + single_line_y = 15.0f; + } + } - SET_POLY_OPA_DISP(gfx); - CLOSE_DISP(graph); + if (line_y < single_line_y) { + line_y = single_line_y; + } + + scroll_gfx = two_tex_scroll_dolphin(graph, 0, 0, 0, 32, 32, 1, 0, line_y * 8.0f, 32, 32); + + OPEN_DISP(graph); + gfx = NOW_POLY_OPA_DISP; + + gSPMatrix(gfx++, _Matrix_to_Mtx_new(graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPSegment(gfx++, G_MWO_SEGMENT_8, scroll_gfx); + gSPDisplayList(gfx++, kai_sousa_ink_mode); + gSPDisplayList(gfx++, kai_sousa_ink_model); + gSPDisplayList(gfx++, kai_sousa_inktuboT_model); + gSPDisplayList(gfx++, kai_sousa_inkmojiT_model); + + SET_POLY_OPA_DISP(gfx); + CLOSE_DISP(graph); } extern Gfx lat_sousa_spT_model[]; static void mED_StringsDraw_spaceCode(GAME* game, rgba_t* color, f32 x, f32 y) { - GRAPH* graph = game->graph; - Gfx* gfx; + GRAPH* graph = game->graph; + Gfx* gfx; - x = 6.5f + (x - 160.0f); - y = -(8.5f + (y - 120.0f)); + x = 6.5f + (x - 160.0f); + y = -(8.5f + (y - 120.0f)); - OPEN_DISP(graph); - gfx = NOW_POLY_OPA_DISP; + OPEN_DISP(graph); + gfx = NOW_POLY_OPA_DISP; - Matrix_scale(16.0f, 16.0f, 1.0f, MTX_LOAD); - Matrix_translate(x, y, 0.0f, MTX_MULT); - Matrix_scale(0.75f, 1.0f, 1.0f, MTX_MULT); + Matrix_scale(16.0f, 16.0f, 1.0f, MTX_LOAD); + Matrix_translate(x, y, 0.0f, MTX_MULT); + Matrix_scale(0.75f, 1.0f, 1.0f, MTX_MULT); - gSPMatrix(gfx++, _Matrix_to_Mtx_new(graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gDPSetPrimColor(gfx++, 0, 255, color->r, color->g, color->b, 255); - gSPDisplayList(gfx++, lat_sousa_spT_model); - gSPMatrix(gfx++, &Mtx_clear, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(gfx++, _Matrix_to_Mtx_new(graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(gfx++, 0, 255, color->r, color->g, color->b, 255); + gSPDisplayList(gfx++, lat_sousa_spT_model); + gSPMatrix(gfx++, &Mtx_clear, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - SET_POLY_OPA_DISP(gfx); - CLOSE_DISP(gfx); + SET_POLY_OPA_DISP(gfx); + CLOSE_DISP(gfx); } static void mED_StringsDraw_keyboard(mED_Ovl_c* editor_ovl, GAME* game, f32 x, f32 y) { - static f32 offset_posX[mED_COLUMNS] = { - 60.0f, - 76.0f, - 92.0f, - 108.0f, - 124.0f, - 140.0f, - 156.0f, - 172.0f, - 188.0f, - 204.0f - }; + static f32 offset_posX[mED_COLUMNS] = { + 60.0f, 76.0f, 92.0f, 108.0f, 124.0f, 140.0f, 156.0f, 172.0f, 188.0f, 204.0f + }; - static f32 offset_posY[mED_ROWS] = { - 133.0f, - 149.0f, - 165.0f, - 181.0f - }; + static f32 offset_posY[mED_ROWS] = { 133.0f, 149.0f, 165.0f, 181.0f }; - static f32 slide_posX[mED_ROWS] = { - 0.0f, - 3.0f, - 7.0f, - 10.0f - }; + static f32 slide_posX[mED_ROWS] = { 0.0f, 3.0f, 7.0f, 10.0f }; - static rgba_t col[2] = { - { 35, 30, 55, 255 }, - { 255, 255, 255, 255 } - }; + static rgba_t col[2] = { { 35, 30, 55, 255 }, { 255, 255, 255, 255 } }; - int column; - int row; - int sel_col = editor_ovl->select_col; - int sel_row = editor_ovl->select_row; + int column; + int row; + int sel_col = editor_ovl->select_col; + int sel_row = editor_ovl->select_row; - for (row = 0; row < mED_ROWS; row++) { - for (column = 0; column < mED_COLUMNS; column++) { - u8 code = mED_get_code(editor_ovl, column, row); + for (row = 0; row < mED_ROWS; row++) { + for (column = 0; column < mED_COLUMNS; column++) { + u8 code = mED_get_code(editor_ovl, column, row); - if (code != CHAR_SPACE_3) { - rgba_t* color; - f32 text_x; - f32 text_y; - - if (column == sel_col && row == sel_row) { - color = &col[1]; + if (code != CHAR_SPACE_3) { + rgba_t* color; + f32 text_x; + f32 text_y; + + if (column == sel_col && row == sel_row) { + color = &col[1]; + } else { + color = &col[0]; + } + + text_x = x + offset_posX[column] + slide_posX[row] + 2.0f; + text_y = -y + offset_posY[row]; + + switch (code) { + case CHAR_SPACE: + mED_StringsDraw_spaceCode(game, color, text_x, text_y); + break; + default: + mFont_SetLineStrings(game, &code, 1, text_x, text_y, color->r, color->g, color->b, 255, FALSE, + FALSE, 1.0f, 1.0f, mFont_MODE_POLY); + break; + } + } } - else { - color = &col[0]; - } - - text_x = x + offset_posX[column] + slide_posX[row] + 2.0f; - text_y = -y + offset_posY[row]; - - switch (code) { - case CHAR_SPACE: - mED_StringsDraw_spaceCode(game, color, text_x, text_y); - break; - default: - mFont_SetLineStrings(game, &code, 1, text_x, text_y, color->r, color->g, color->b, 255, FALSE, FALSE, 1.0f, 1.0f, mFont_MODE_POLY); - break; - } - } } - } } static void mED_StringsDraw_select(mED_Ovl_c* editor_ovl, GAME* game, f32 x, f32 y) { - static rgba_t sp_col = { 255, 255, 255, 255 }; - u8 code = mED_get_code(editor_ovl, editor_ovl->select_col, editor_ovl->select_row); + static rgba_t sp_col = { 255, 255, 255, 255 }; + u8 code = mED_get_code(editor_ovl, editor_ovl->select_col, editor_ovl->select_row); - if (code != CHAR_SPACE_3) { - f32 text_x = (237.0f + x) + 5.0f; - f32 text_y = (177.0f - y) + 3.0f; + if (code != CHAR_SPACE_3) { + f32 text_x = (237.0f + x) + 5.0f; + f32 text_y = (177.0f - y) + 3.0f; - if (chkButton(BUTTON_A)) { - text_y += 1.0f; + if (chkButton(BUTTON_A)) { + text_y += 1.0f; + } + + switch (code) { + case CHAR_SPACE: + mED_StringsDraw_spaceCode(game, &sp_col, text_x, text_y); + break; + default: + mFont_SetLineStrings(game, &code, 1, text_x, text_y, 255, 255, 255, 255, FALSE, FALSE, 1.0f, 1.0f, + mFont_MODE_POLY); + break; + } } - - switch (code) { - case CHAR_SPACE: - mED_StringsDraw_spaceCode(game, &sp_col, text_x, text_y); - break; - default: - mFont_SetLineStrings(game, &code, 1, text_x, text_y, 255, 255, 255, 255, FALSE, FALSE, 1.0f, 1.0f, mFont_MODE_POLY); - break; - } - } } static void mED_StringsDraw_ornament(mED_Ovl_c* editor_ovl, GAME* game, f32 x, f32 y) { - if (editor_ovl->exchange_code != -1) { - u8 code = editor_ovl->exchange_code; - f32 text_x = 259.0f + x; - f32 text_y = 190.0f - y; - int cursor_idx = editor_ovl->cursor_idx; - u8* str_p = &editor_ovl->input_str[cursor_idx]; + if (editor_ovl->exchange_code != -1) { + u8 code = editor_ovl->exchange_code; + f32 text_x = 259.0f + x; + f32 text_y = 190.0f - y; + int cursor_idx = editor_ovl->cursor_idx; + u8* str_p = &editor_ovl->input_str[cursor_idx]; - mFont_SetLineStrings(game, &str_p[-1], 1, text_x + 2.0f, text_y, 225, 195, 195, 255, FALSE, FALSE, 1.0f, 1.0f, mFont_MODE_POLY); - text_x = 281.0f + x; - mFont_SetLineStrings(game, &code, 1, text_x + 2.0f, text_y, 255, 255, 255, 255, FALSE, FALSE, 1.0f, 1.0f, mFont_MODE_POLY); - } + mFont_SetLineStrings(game, &str_p[-1], 1, text_x + 2.0f, text_y, 225, 195, 195, 255, FALSE, FALSE, 1.0f, 1.0f, + mFont_MODE_POLY); + text_x = 281.0f + x; + mFont_SetLineStrings(game, &code, 1, text_x + 2.0f, text_y, 255, 255, 255, 255, FALSE, FALSE, 1.0f, 1.0f, + mFont_MODE_POLY); + } } static void mED_StringsDraw(Submenu* submenu, mED_Ovl_c* editor_ovl, GAME* game, f32 x, f32 y) { - (*submenu->overlay->set_char_matrix_proc)(game->graph); - mED_StringsDraw_keyboard(editor_ovl, game, x, y); - mED_StringsDraw_select(editor_ovl, game, x, y); - mED_StringsDraw_ornament(editor_ovl, game, x, y); + (*submenu->overlay->set_char_matrix_proc)(game->graph); + mED_StringsDraw_keyboard(editor_ovl, game, x, y); + mED_StringsDraw_select(editor_ovl, game, x, y); + mED_StringsDraw_ornament(editor_ovl, game, x, y); } static void mED_set_dl(Submenu* submenu, mSM_MenuInfo_c* menu_info, GAME* game) { - mED_Ovl_c* editor_ovl = submenu->overlay->editor_ovl; - GRAPH* graph = game->graph; + mED_Ovl_c* editor_ovl = submenu->overlay->editor_ovl; + GRAPH* graph = game->graph; - mED_KeyDraw(editor_ovl, graph, menu_info->position[0], menu_info->position[1]); - mED_InkPotDraw(submenu, editor_ovl, graph, menu_info->position[0], menu_info->position[1]); - mED_StringsDraw(submenu, editor_ovl, game, menu_info->position[0], menu_info->position[1]); + mED_KeyDraw(editor_ovl, graph, menu_info->position[0], menu_info->position[1]); + mED_InkPotDraw(submenu, editor_ovl, graph, menu_info->position[0], menu_info->position[1]); + mED_StringsDraw(submenu, editor_ovl, game, menu_info->position[0], menu_info->position[1]); } extern Gfx lat_end_cordT_model[]; static void mED_endCode_draw(Submenu* submenu, GAME* game, f32 x, f32 y) { - GRAPH* graph = game->graph; - Gfx* gfx; + GRAPH* graph = game->graph; + Gfx* gfx; - Matrix_scale(16.0f, 16.0f, 1.0f, MTX_LOAD); - Matrix_translate(x, y, 140.0f, MTX_MULT); + Matrix_scale(16.0f, 16.0f, 1.0f, MTX_LOAD); + Matrix_translate(x, y, 140.0f, MTX_MULT); - OPEN_DISP(graph); - gfx = NOW_POLY_OPA_DISP; + OPEN_DISP(graph); + gfx = NOW_POLY_OPA_DISP; - gSPMatrix(gfx++, _Matrix_to_Mtx_new(graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(gfx++, lat_end_cordT_model); + gSPMatrix(gfx++, _Matrix_to_Mtx_new(graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(gfx++, lat_end_cordT_model); - SET_POLY_OPA_DISP(gfx); - CLOSE_DISP(graph); + SET_POLY_OPA_DISP(gfx); + CLOSE_DISP(graph); } static void mED_cursol_draw(Submenu* submenu, GAME* game, f32 x, f32 y) { - mED_Ovl_c* editor_ovl = submenu->overlay->editor_ovl; - int cursol_opacity_step = editor_ovl->cursol_opacity_step; - int a; + mED_Ovl_c* editor_ovl = submenu->overlay->editor_ovl; + int cursol_opacity_step = editor_ovl->cursol_opacity_step; + int a; - if (cursol_opacity_step > 17) { - cursol_opacity_step = 35 - cursol_opacity_step; - } + if (cursol_opacity_step > 17) { + cursol_opacity_step = 35 - cursol_opacity_step; + } - a = ((17 - cursol_opacity_step) * 255) / 17; - mFont_SetMarkChar(game, mFont_MARKTYPE_CURSOR, x, y, 195, 80, 80, a, FALSE, 1.0f, 1.0f, mFont_MODE_POLY); + a = ((17 - cursol_opacity_step) * 255) / 17; + mFont_SetMarkChar(game, mFont_MARKTYPE_CURSOR, x, y, 195, 80, 80, a, FALSE, 1.0f, 1.0f, mFont_MODE_POLY); } static void mED_editor_ovl_draw(Submenu* submenu, GAME* game) { - Submenu_Overlay_c* overlay = submenu->overlay; - mSM_MenuInfo_c* menu_info = &overlay->menu_info[mSM_OVL_EDITOR]; + Submenu_Overlay_c* overlay = submenu->overlay; + mSM_MenuInfo_c* menu_info = &overlay->menu_info[mSM_OVL_EDITOR]; - (*menu_info->pre_draw_func)(submenu, game); - mED_set_dl(submenu, menu_info, game); + (*menu_info->pre_draw_func)(submenu, game); + mED_set_dl(submenu, menu_info, game); - if (menu_info->pre_menu_type == mSM_OVL_ADDRESS && submenu->overlay->address_ovl->display_list != NULL) { - OPEN_DISP(game->graph); + if (menu_info->pre_menu_type == mSM_OVL_ADDRESS && submenu->overlay->address_ovl->display_list != NULL) { + OPEN_DISP(game->graph); - gSPDisplayList(NOW_POLY_OPA_DISP++, submenu->overlay->address_ovl->display_list); + gSPDisplayList(NOW_POLY_OPA_DISP++, submenu->overlay->address_ovl->display_list); - CLOSE_DISP(game->graph); - } + CLOSE_DISP(game->graph); + } } extern void mED_editor_ovl_set_proc(Submenu* submenu) { - Submenu_Overlay_c* overlay = submenu->overlay; + Submenu_Overlay_c* overlay = submenu->overlay; - overlay->menu_control.menu_move_func = &mED_editor_ovl_move; - overlay->menu_control.menu_draw_func = &mED_editor_ovl_draw; + overlay->menu_control.menu_move_func = &mED_editor_ovl_move; + overlay->menu_control.menu_draw_func = &mED_editor_ovl_draw; } static void mED_editor_ovl_init(Submenu* submenu) { - Submenu_Overlay_c* overlay = submenu->overlay; - mSM_MenuInfo_c* menu_info = &overlay->menu_info[mSM_OVL_EDITOR]; + Submenu_Overlay_c* overlay = submenu->overlay; + mSM_MenuInfo_c* menu_info = &overlay->menu_info[mSM_OVL_EDITOR]; - (*overlay->move_chg_base_proc)(menu_info, mSM_MOVE_IN_BOTTOM); + (*overlay->move_chg_base_proc)(menu_info, mSM_MOVE_IN_BOTTOM); - if (menu_info->data0 == mED_TYPE_CP_TITLE || menu_info->data0 == mED_TYPE_LEDIT || menu_info->data0 == mED_TYPE_HBOARD) { - sAdo_SysTrgStart(0x59); - } + if (menu_info->data0 == mED_TYPE_CP_TITLE || menu_info->data0 == mED_TYPE_LEDIT || + menu_info->data0 == mED_TYPE_HBOARD) { + sAdo_SysTrgStart(0x59); + } } static mED_Ovl_c edit_ovl_data; extern void mED_editor_ovl_construct(Submenu* submenu) { - Submenu_Overlay_c* overlay = submenu->overlay; - mSM_MenuInfo_c* menu_info = &overlay->menu_info[mSM_OVL_EDITOR]; + Submenu_Overlay_c* overlay = submenu->overlay; + mSM_MenuInfo_c* menu_info = &overlay->menu_info[mSM_OVL_EDITOR]; - if (overlay->editor_ovl == NULL) { - mem_clear((u8*)&edit_ovl_data, sizeof(mED_Ovl_c), 0); - overlay->editor_ovl = &edit_ovl_data; - } + if (overlay->editor_ovl == NULL) { + mem_clear((u8*)&edit_ovl_data, sizeof(mED_Ovl_c), 0); + overlay->editor_ovl = &edit_ovl_data; + } - mED_init(submenu, menu_info); - mED_editor_ovl_init(submenu); - mED_editor_ovl_set_proc(submenu); - submenu->overlay->editor_ovl->end_code_draw = &mED_endCode_draw; - submenu->overlay->editor_ovl->cursol_draw = &mED_cursol_draw; + mED_init(submenu, menu_info); + mED_editor_ovl_init(submenu); + mED_editor_ovl_set_proc(submenu); + submenu->overlay->editor_ovl->end_code_draw = &mED_endCode_draw; + submenu->overlay->editor_ovl->cursol_draw = &mED_cursol_draw; } extern void mED_editor_ovl_destruct(Submenu* submenu) { - Submenu_Overlay_c* overlay = submenu->overlay; + Submenu_Overlay_c* overlay = submenu->overlay; - overlay->editor_ovl = NULL; + overlay->editor_ovl = NULL; } diff --git a/src/game/m_event.c b/src/game/m_event.c index 0afe6406..e6f028c1 100644 --- a/src/game/m_event.c +++ b/src/game/m_event.c @@ -364,41 +364,41 @@ static int last_day_of_month(lbRTC_month_t month) { static void init_weekday1st() { lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); - lbRTC_month_t month; lbRTC_month_t temp; lbRTC_month_t i; - int weekday; + lbRTC_month_t j; + lbRTC_month_t month; + int t; month = rtc_time->month & 0xF; weekday1st_year = rtc_time->year; - weekday = (rtc_time->weekday + (1 - rtc_time->day)) % lbRTC_WEEK; - if (weekday < 0) { - weekday += lbRTC_WEEK; + t = (rtc_time->weekday + (1 - rtc_time->day)) % lbRTC_WEEK; + if (t < 0) { + t += lbRTC_WEEK; } - weekday1st[month] = weekday; + weekday1st[month] = t; - for (i = month, temp = month + 1; temp <= lbRTC_MONTHS_MAX; i++, temp++) { - int last = last_day_of_month(i); - int t = (weekday1st[i] + (u8)last) % lbRTC_WEEK; + for (i = month, j = month + 1; j <= lbRTC_MONTHS_MAX; i++, j++) { + temp = last_day_of_month(i); + t = (weekday1st[i] + temp) % lbRTC_WEEK; if (t < 0) { t += lbRTC_WEEK; } - weekday1st[temp] = t; + weekday1st[j] = t; } - for (temp = month - 1, i = month; temp >= lbRTC_JANUARY; i--, temp--) { - lbRTC_day_t last_day = last_day_of_month(temp); - - weekday = (weekday1st[i] - last_day) % lbRTC_WEEK; - if (weekday < 0) { - weekday += lbRTC_WEEK; + for (j = month - 1, i = month; j >= lbRTC_JANUARY; i--, j--) { + temp = last_day_of_month(j); + t = (weekday1st[i] - temp) % lbRTC_WEEK; + if (t < 0) { + t += lbRTC_WEEK; } - weekday1st[temp] = weekday; + weekday1st[j] = t; } } @@ -574,24 +574,21 @@ extern int mEv_weekday2day(lbRTC_month_t month, int week, int weekday) { } static int get_end_time(u32 active_hours) { - int hour; int i; if ((active_hours & ((1 << 24) - 1)) == 0) { return -1; /* no active hours */ } - hour = 23; - for (i = 0; i < 24; i++) { + for (i = 23; i >= 0; i--) { if ((active_hours & (1 << 23)) != 0) { break; } active_hours <<= 1; /* move hours left by one bit, MSB is latest hour */ - hour--; } - return hour; + return i; } extern int mEv_get_end_time(int event_type) { @@ -856,6 +853,7 @@ static int init_special_event(int new_event) { mEv_save_common_data_c* ev_save_common; u16* dates_p; s16 event_year; + int t; switch (Common_Get(last_scene_no)) { case SCENE_BUGGY: @@ -899,6 +897,20 @@ static int init_special_event(int new_event) { special_ymdh.raw = (dates_p[mEv_SAVE_DATE_SPECIAL0] << 8) & 0x000FFFF00; special_ymdh.year = event_year % 100; + + +#if VERSION >= VER_GAFU01_00 + rtc_ymdh.raw = (rtc_sched.md) << 8; + rtc_ymdh.year = rtc_time->year % 100; + rtc_ymdh.hour = rtc_time->hour; + special_end_ymdh.raw = (dates_p[mEv_SAVE_DATE_SPECIAL2] << 8) & 0x000FFFF00; + t = event_year % 100; + if (dates_p[mEv_SAVE_DATE_SPECIAL0] > dates_p[mEv_SAVE_DATE_SPECIAL2]) { + t++; + } + + special_end_ymdh.year = t; +#else rtc_ymdh.raw = (rtc_sched.md) << 8; rtc_ymdh.year = rtc_time->year % 100; rtc_ymdh.hour = rtc_time->hour; @@ -907,6 +919,7 @@ static int init_special_event(int new_event) { dates_p[mEv_SAVE_DATE_SPECIAL0] > rtc_sched.md) ? 1 : 0); +#endif special_end_ymdh.hour = get_special_event_end_time(type); @@ -945,6 +958,12 @@ static int init_special_event(int new_event) { } special_monthday[0].raw = after_n_day(rtc_sched.md, next_event_day_gap); +// Aus version prevents special events from happening on the last day of the year +#if VERSION >= VER_GAFU01_00 + if (special_monthday[0].raw == mEv_MonthDay(lbRTC_DECEMBER, 31)) { + special_monthday[0].raw = after_n_day(special_monthday[0].raw, 1); + } +#endif if (rtc_sched.md <= sale_day && sale_day <= special_monthday[0].raw) { /* Force the next special event to be Crazy Redd since Sale Day falls between now and the rolled * event date */ @@ -1668,21 +1687,21 @@ static int effective_scene() { } static void update_schedule_today(Event_c* event) { - int month; + lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); + // int month; u8 equinox_day = 0; mEv_schedule_date_u today_date; mEv_MonthDay_u birthday_date; mEv_schedule_c sched; - lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); mEv_schedule_c* sched_p = &sched; Private_c* priv = &Save_Get(private_data[Common_Get(player_no)]); int i; int type; if (mEv_ArbeitPlayer_kari(Common_Get(player_no)) == FALSE) { - month = rtc_time->month; + // month = rtc_time->month; - today_date.d.month = month; + today_date.d.month = rtc_time->month; today_date.d.day = rtc_time->day; today_date.d.hour = rtc_time->hour; today_date.d._2 = 0; @@ -1708,7 +1727,7 @@ static void update_schedule_today(Event_c* event) { if (sched.type == mEv_EVENT_SUMMER_CAMPER) { mEv_MonthDay_u camper_date; - switch (month) { + switch (today_date.d.month) { case lbRTC_JUNE: case lbRTC_JULY: case lbRTC_AUGUST: @@ -1912,6 +1931,23 @@ extern void mEv_init_force(Event_c* event) { init_event(event, renewal_flag); } +// Aus checks if the save weather is set to rain, not the current weather. +// This would prevent a bug where Morning Aerobics could be scheduled +// in the rain because the previous weather was clear. +#if VERSION >= VER_GAFU01_00 +extern void mEv_2nd_init(Event_c* event) { + /* Disable morning aerobics if it is scheduled and the weather is rain */ + u8 index = index_today[mEv_EVENT_MORNING_AEROBICS]; + + if (index != 0xFF && mEnv_SAVE_GET_WEATHER_TYPE(Save_Get(weather)) == mEnv_WEATHER_RAIN) { + mEv_event_today_c* ev_today = &event_today[index]; + + mEv_clear_status(mEv_EVENT_MORNING_AEROBICS, mEv_STATUS_ACTIVE); + ev_today->type = -1; + index_today[mEv_EVENT_MORNING_AEROBICS] = 0xFF; + } +} +#else extern void mEv_2nd_init(Event_c* event) { /* Disable morning aerobics if it is scheduled and the weather is rain */ if (Common_Get(weather) == mEnv_WEATHER_RAIN) { @@ -1926,6 +1962,7 @@ extern void mEv_2nd_init(Event_c* event) { } } } +#endif extern int mEv_PlayerOK() { int res = FALSE; @@ -2499,8 +2536,8 @@ extern int mEv_get_rumor() { extern void mEv_actor_dying_message(int type, ACTOR* actor) { xyz_t pos = actor->world.position; - mEv_common_data_c* ev_common = Common_GetPointer(event_common); mActor_name_t actor_name = actor->npc_id; + mEv_common_data_c* ev_common = Common_GetPointer(event_common); int i; for (i = 0; i < mEv_PLACE_NUM; i++) { @@ -2621,22 +2658,22 @@ extern int mEv_GetHour(Event_c* event) { } extern void mEv_debug_print4f(gfxprint_t* gfxprint) { - // int x = 0; int i; int event_idx = 0; for (i = 0; i < mEv_TODAY_EVENT_NUM; i++) { - if (event_today[i].type != -1 && mEv_check_status(event_today[i].type, mEv_STATUS_ACTIVE)) { + mEv_event_today_c* ev = &event_today[i]; + + if (ev->type != -1 && mEv_check_status(ev->type, mEv_STATUS_ACTIVE)) { gfxprint_color(gfxprint, 245, 200, 170, 255); gfxprint_locate8x8(gfxprint, 3 + event_idx * 3, 5); - gfxprint_printf(gfxprint, "%3d", event_today[i].type); + gfxprint_printf(gfxprint, "%3d", ev->type); event_idx++; - // x += 3; if (event_idx >= 9) { - if (mEv_check_status(event_today[i].type, mEv_STATUS_ERROR) == FALSE) { + if (mEv_check_status(ev->type, mEv_STATUS_ERROR) == FALSE) { gfxprint_color(gfxprint, 245, 150, 120, 255); - } else if (mEv_check_status(event_today[i].type, mEv_STATUS_RUN)) { + } else if (mEv_check_status(ev->type, mEv_STATUS_RUN)) { gfxprint_color(gfxprint, 180, 150, 160, 255); } else { gfxprint_color(gfxprint, 140, 120, 120, 255); @@ -2770,7 +2807,7 @@ extern int mEv_someone_died() { extern void mEv_special_event_soldout(int type) { GAME_PLAY* play = (GAME_PLAY*)gamePT; - mEv_event_today_c* ev_today; + mEv_event_today_c* ev_today = event_today; int i; for (i = 0; i < mEv_TODAY_EVENT_NUM; i++) { diff --git a/src/game/m_event_map_npc.c b/src/game/m_event_map_npc.c index 0fa75da4..a80e3bf7 100644 --- a/src/game/m_event_map_npc.c +++ b/src/game/m_event_map_npc.c @@ -353,11 +353,11 @@ static void mEvMN_SetNpcJointEvRandom(u8* animal_idx, int max) { animal_idx -= max; if (animal_count > 0 && mLd_PlayerManKindCheck() == FALSE) { - animal = Save_Get(animals); + Animal_c* sec_animal = animal; for (i = 0; i < ANIMAL_NUM_MAX; i++) { if (((animal_bitfield >> i) & 1) == 1 && - mEvMN_CheckCanJointEvent(animal[i].memories, &Now_Private->player_ID) == FALSE) { + mEvMN_CheckCanJointEvent(sec_animal[i].memories, &Now_Private->player_ID) == FALSE) { animal_count--; animal_bitfield &= ~(1 << i); diff --git a/src/game/m_field_assessment.c b/src/game/m_field_assessment.c index d64d7e52..279e37fa 100644 --- a/src/game/m_field_assessment.c +++ b/src/game/m_field_assessment.c @@ -211,8 +211,8 @@ static int mFAs_GetFieldGoodBlockNum_common(int* condition_num, int* block_x, in int condition_result; int flower_num; int block_dust_num; - int i; int dust_num; + int i; int selected_block_x; int selected_block_z; int tree_num; diff --git a/src/game/m_field_info.c b/src/game/m_field_info.c index b123f794..a3966f46 100644 --- a/src/game/m_field_info.c +++ b/src/game/m_field_info.c @@ -16,9 +16,10 @@ typedef struct collision_keep_s { int unk_C; } mFI_col_keep_c; -static mFI_col_keep_c l_keepcld[mFI_NUM_COL_KEEP] = { { 0xFF, 0xFF, 0 }, { 0xFF, 0xFF, 0 }, { 0xFF, 0xFF, 0 }, - { 0xFF, 0xFF, 0 }, { 0xFF, 0xFF, 0 }, { 0xFF, 0xFF, 0 }, - { 0xFF, 0xFF, 0 }, { 0xFF, 0xFF, 0 }, { 0xFF, 0xFF, 0 } }; +static mFI_col_keep_c l_keepcld[mFI_NUM_COL_KEEP] = { + { 0xFF, 0xFF, 0 }, { 0xFF, 0xFF, 0 }, { 0xFF, 0xFF, 0 }, { 0xFF, 0xFF, 0 }, { 0xFF, 0xFF, 0 }, + { 0xFF, 0xFF, 0 }, { 0xFF, 0xFF, 0 }, { 0xFF, 0xFF, 0 }, { 0xFF, 0xFF, 0 }, +}; extern void mFI_ClearFieldData() { g_fdinfo = NULL; @@ -1284,10 +1285,20 @@ extern int mFI_GetBlockUtNum2FG(mActor_name_t* item, int bx, int bz, int ut_x, i int num = mFI_GetBlockNum(bx, bz); int ut_num = mFI_GetUtNum(ut_x, ut_z); + // Aus version added a NULL check on the acre item data pointer +#if VERSION >= VER_GAFU01_00 + if (g_fdinfo->block_info[num].fg_info.items_p != NULL) { + res = TRUE; + *item = g_fdinfo->block_info[num].fg_info.items_p[ut_num]; + } else { + *item = RSV_NO; + } +#else res = TRUE; - item[0] = g_fdinfo->block_info[num].fg_info.items_p[ut_num]; + *item = g_fdinfo->block_info[num].fg_info.items_p[ut_num]; +#endif } else { - item[0] = RSV_NO; + *item = RSV_NO; } return res; @@ -1330,8 +1341,16 @@ extern int mFI_UtNumtoFGSet_common(mActor_name_t item, int ut_x, int ut_z, int u mFI_GetUtNumInBK(&b_ut_x, &b_ut_z, ut_x, ut_z); ut_num = mFI_GetUtNum(b_ut_x, b_ut_z); - g_fdinfo->block_info[block_num].fg_info.items_p[ut_num] = item; + // Aus version added a NULL check on the acre item data pointer +#if VERSION >= VER_GAFU01_00 + if (g_fdinfo->block_info[block_num].fg_info.items_p == NULL) { + return FALSE; + } +#endif + + g_fdinfo->block_info[block_num].fg_info.items_p[ut_num] = item; + if (update) { mFI_SetFGUpData(); } @@ -2118,9 +2137,22 @@ static int mFI_LineDepositOFF(u16* deposit, int ut_x) { return FALSE; } +// Aus added NULL check +#if VERSION >= VER_GAFU01_00 +extern int mFI_GetLineDeposit(u16* deposit, int ut_x) { + int ret = FALSE; + + if (deposit != NULL) { + ret = ((*deposit) >> ut_x) & 1; + } + + return ret; +} +#else extern int mFI_GetLineDeposit(u16* deposit, int ut_x) { return (deposit[0] >> ut_x) & 1; } +#endif typedef int (*mFI_SET_DEPOSIT_PROC)(u16*, int); @@ -2369,7 +2401,11 @@ extern int mFI_GetDigStatus(mActor_name_t* item, xyz_t wpos, int golden_shovel) break; } } - } else if (mCoBG_CheckSkySwing(wpos) == TRUE) { +#if VERSION >= VER_GAFU01_00 + } else if (mCoBG_CheckAirSwing(wpos) == TRUE) { +#else + } else if (mCoBG_CheckAirSwing(wpos) == TRUE) { +#endif status = mFI_DIGSTATUS_MISS; } } @@ -2417,9 +2453,13 @@ extern void mFI_ClearBeecomb(int bx, int bz) { static void mFI_SetFGStructureKeep(mActor_name_t* item_p, mActor_name_t replace_item, int destroy_item) { if (destroy_item == FALSE) { mPB_keep_item(*item_p); +// Aus version cleans up any snowmen here +#if VERSION >= VER_GAFU01_00 + mSN_ClearSnowman(item_p); +#endif } - item_p[0] = replace_item; + *item_p = replace_item; } static mActor_name_t l_set_fg_table[3 * 3]; @@ -3189,16 +3229,16 @@ static void mFI_SetShellBlock(mActor_name_t* fg_p, mCoBG_Collision_u* col_p, int } } +// TODO: I think this is fakematch static void mFI_SetShellSandyBeachBlock(u8* can_set_ut_num, u8* shell_num_inblock) { - int bz; int shell_num; int bx; int i; + u8 bz; for (i = 0; i < 7; i++) { if (can_set_ut_num[0] != 0) { - shell_num = shell_num_inblock[0]; - + shell_num = *shell_num_inblock; if (shell_num > 0) { bx = l_sandy_beach_bx[i]; bz = l_sandy_beach_bz[i]; @@ -3355,19 +3395,23 @@ static int mFI_CheckBlockSetTreasure(int* block, int bx, int bz) { } extern int mFI_SetTreasure(int* selected_bx, int* selected_bz, mActor_name_t item) { - static int no_check_block_table[2 * 4] = { + static int no_check_block_table[4][2] = { 3, 1, /* train station */ 3, 2, /* player house */ 0, 0, /* wishing well/shrine (dynamic) */ 0, 0 /* lake (dynamic) */ }; - u8 depositable_num_block[FG_BLOCK_TOTAL_NUM]; mFM_fg_c* fg_block; mFM_fg_c* fg_block_p; + mCoBG_Collision_u* col_p; + u8 depositable_num_block[FG_BLOCK_TOTAL_NUM]; u8* depositable_num_p2; u8* depositable_num_p; u8 depositable_blocks; + int selected_block; + int i; + int j; int res; fg_block = Save_Get(fg[0]); @@ -3377,18 +3421,15 @@ extern int mFI_SetTreasure(int* selected_bx, int* selected_bz, mActor_name_t ite res = FALSE; if (Save_Get(scene_no) == SCENE_FG) { - int bz; bzero(depositable_num_p, FG_BLOCK_TOTAL_NUM); - mFI_BlockKind2BkNum(&no_check_block_table[4], &no_check_block_table[5], mRF_BLOCKKIND_SHRINE); - mFI_BlockKind2BkNum(&no_check_block_table[6], &no_check_block_table[7], mRF_BLOCKKIND_POOL); + mFI_BlockKind2BkNum(&no_check_block_table[2][0], &no_check_block_table[2][1], mRF_BLOCKKIND_SHRINE); + mFI_BlockKind2BkNum(&no_check_block_table[3][0], &no_check_block_table[3][1], mRF_BLOCKKIND_POOL); - for (bz = 0; bz < FG_BLOCK_Z_NUM; bz++) { - int bx; - - for (bx = 0; bx < FG_BLOCK_X_NUM; bx++) { - if (mFI_CheckBlockSetTreasure(no_check_block_table, bx + 1, bz + 1) == TRUE) { - mCoBG_Collision_u* col_p = mFI_GetBkNum2ColTop(bx + 1, bz + 1); + for (i = 0; i < FG_BLOCK_Z_NUM; i++) { + for (j = 0; j < FG_BLOCK_X_NUM; j++) { + if (mFI_CheckBlockSetTreasure((int*)no_check_block_table, j + 1, i + 1) == TRUE) { + col_p = mFI_GetBkNum2ColTop(j + 1, i + 1); depositable_num_p[0] = mMsm_GetDepositAbleNum(fg_block_p->items[0], col_p); @@ -3403,10 +3444,6 @@ extern int mFI_SetTreasure(int* selected_bx, int* selected_bz, mActor_name_t ite } if (depositable_blocks != 0) { - u8* depositable_num_p; // removing this line fixes regalloc but causes regswaps - int selected_block; - int i; - depositable_num_p2 = depositable_num_block; selected_block = RANDOM(depositable_blocks); for (i = 0; i < FG_BLOCK_TOTAL_NUM; i++) { diff --git a/src/game/m_field_make.c b/src/game/m_field_make.c index f587ae99..f67064e9 100644 --- a/src/game/m_field_make.c +++ b/src/game/m_field_make.c @@ -14,41 +14,45 @@ #include "m_house.h" #include "m_bgm.h" +// clang-format off static mActor_name_t l_fg_outer_fill[UT_Z_NUM * UT_X_NUM] = { - RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, - RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, - RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, - RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, - RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, - RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, - RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, - RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, - RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, - RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, - RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, - RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, - RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, - RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, - RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, - RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO + RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, + RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, + RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, + RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, + RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, + RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, + RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, + RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, + RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, + RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, + RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, + RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, + RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, + RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, + RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, + RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, RSV_NO, }; +// clang-format on +// clang-format off static mActor_name_t l_title_demo_fg[(BLOCK_Z_NUM - 2) * BLOCK_X_NUM] = { - 0x00CB, 0x00CB, 0x00CB, 0x00CB, 0x00CB, 0x00CB, 0x00CB, - 0x00CB, 0x00DD, 0x00AB, 0x00CC, 0x00E5, 0x002E, 0x00CB, - 0x00CB, 0x0174, 0x0030, 0x0069, 0x0088, 0x017C, 0x00CB, - 0x00CB, 0x0055, 0x0176, 0x0046, 0x0179, 0x0045, 0x00CB, - 0x00CB, 0x0175, 0x003F, 0x0029, 0x017A, 0x017D, 0x00CB, - 0x00CB, 0x006A, 0x00AC, 0x0178, 0x0068, 0x017E, 0x00CB, - 0x00CB, 0x0061, 0x0177, 0x0062, 0x017B, 0x0064, 0x00CB, - 0x00CB, 0x00CB, 0x00CB, 0x00CB, 0x00CB, 0x00CB, 0x00CB + 0x00CB, 0x00CB, 0x00CB, 0x00CB, 0x00CB, 0x00CB, 0x00CB, + 0x00CB, 0x00DD, 0x00AB, 0x00CC, 0x00E5, 0x002E, 0x00CB, + 0x00CB, 0x0174, 0x0030, 0x0069, 0x0088, 0x017C, 0x00CB, + 0x00CB, 0x0055, 0x0176, 0x0046, 0x0179, 0x0045, 0x00CB, + 0x00CB, 0x0175, 0x003F, 0x0029, 0x017A, 0x017D, 0x00CB, + 0x00CB, 0x006A, 0x00AC, 0x0178, 0x0068, 0x017E, 0x00CB, + 0x00CB, 0x0061, 0x0177, 0x0062, 0x017B, 0x0064, 0x00CB, + 0x00CB, 0x00CB, 0x00CB, 0x00CB, 0x00CB, 0x00CB, 0x00CB, }; +// clang-format on typedef struct police_pos_s { - int bx; - int bz; - int ut_x; - int ut_z; + int bx; + int bz; + int ut_x; + int ut_z; } mFM_police_pos_c; static mFM_police_pos_c l_mfm_police_pos = { 0, 0, 0, 0 }; @@ -60,518 +64,516 @@ mFM_fdinfo_c* g_fdinfo; static u8 l_block_type[BLOCK_TOTAL_NUM]; static int l_block_kind[BLOCK_TOTAL_NUM]; - static void mFM_SortBGData(mFM_bg_data_c** sorted_data_p, mFM_bg_data_c* data, int count) { - mFM_bg_data_c** sorted_data_p_copy = sorted_data_p; - int i; + int i; + mFM_bg_data_c** sorted_data_p_copy = sorted_data_p; - for (i = 0; i < mFM_BG_ID_MAX; i++) { - sorted_data_p_copy[0] = NULL; - sorted_data_p_copy++; - } - - for (i = 0; i < count; i++) { - if (data->bg_id <= mFM_BG_ID_MAX) { - sorted_data_p[data->bg_id] = data; + for (i = 0; i < mFM_BG_ID_MAX; i++) { + sorted_data_p_copy[0] = NULL; + sorted_data_p_copy++; + } + + for (i = 0; i < count; i++) { + if (data->bg_id <= mFM_BG_ID_MAX) { + sorted_data_p[data->bg_id] = data; + } + data++; } - data++; - } } -static void mFM_SortFGData(mFM_fg_data_c** sorted_data_p, mFM_fg_data_c* data, int count, int list_size, int name_start) { - mFM_fg_data_c** sorted_data_p_copy = sorted_data_p; - int i; +static void mFM_SortFGData(mFM_fg_data_c** sorted_data_p, mFM_fg_data_c* data, int count, int list_size, + int name_start) { + int i; + mFM_fg_data_c** sorted_data_p_copy = sorted_data_p; - for (i = 0; i < count; i++) { - sorted_data_p_copy[0] = NULL; - sorted_data_p_copy++; - } - - for (i = 0; i < list_size; i++) { - int fg_idx = data->fg_id - name_start; - - if (fg_idx < 0) { - fg_idx = 0; + for (i = 0; i < count; i++) { + sorted_data_p_copy[0] = NULL; + sorted_data_p_copy++; } - sorted_data_p[fg_idx] = data; - data++; - } + for (i = 0; i < list_size; i++) { + int fg_idx = data->fg_id - name_start; + + if (fg_idx < 0) { + fg_idx = 0; + } + + sorted_data_p[fg_idx] = data; + data++; + } } static void mFM_BgUtDataSet(mCoBG_Collision_u* collision, u8* keep, mCoBG_Collision_u* data) { - int ut_x; - int ut_z; + int ut_x; + int ut_z; - for (ut_z = 0; ut_z < UT_Z_NUM; ut_z++) { - for (ut_x = 0; ut_x < UT_X_NUM; ut_x++) { - collision[0] = data[0]; - keep[0] = data[0].data.center; + for (ut_z = 0; ut_z < UT_Z_NUM; ut_z++) { + for (ut_x = 0; ut_x < UT_X_NUM; ut_x++) { + collision[0] = data[0]; + keep[0] = data[0].data.center; - collision++; - data++; - keep++; + collision++; + data++; + keep++; + } } - } } static void mFM_FgUtDataSet(mActor_name_t* fg, mActor_name_t* data) { - int ut_x; - int ut_z; + int ut_x; + int ut_z; - for (ut_z = 0; ut_z < UT_Z_NUM; ut_z++) { - for (ut_x = 0; ut_x < UT_X_NUM; ut_x++) { - fg[0] = data[0]; - fg++; - data++; +// Aus version added NULL checks +#if VERSION >= VER_GAFU01_00 + if (fg == NULL) { + return; + } + + if (data == NULL) { + return; + } +#endif + + for (ut_z = 0; ut_z < UT_Z_NUM; ut_z++) { + for (ut_x = 0; ut_x < UT_X_NUM; ut_x++) { + fg[0] = data[0]; + fg++; + data++; + } } - } } static void mFM_SetFgUtPtoSaveData(mFM_block_info_c* block_info, u8 bx_max, u8 bz_max, int* island_block_x) { - int bz; - int bx; + int bz; + int bx; - for (bz = 0; bz < bz_max; bz++) { - for (bx = 0; bx < bx_max; bx++) { - if (bz > 0 && bz < (bz_max - 1) && bx > 0 && bx < (bx_max - 1)) { - if (bx == island_block_x[0] && bz == mISL_BLOCK_Z) { - block_info->fg_info.items_p = Save_Get(island.fgblock[0][0]).items[0]; - } - else if (bx == island_block_x[1] && bz == mISL_BLOCK_Z) { - block_info->fg_info.items_p = Save_Get(island.fgblock[0][1]).items[0]; - } - else if (bz >= (bz_max - 3)) { - block_info->fg_info.items_p = l_fg_outer_fill; - } - else { - block_info->fg_info.items_p = Save_Get(fg[bz - 1][bx - 1]).items[0]; - } - } - else { - block_info->fg_info.items_p = l_fg_outer_fill; - } + for (bz = 0; bz < bz_max; bz++) { + for (bx = 0; bx < bx_max; bx++) { + if (bz > 0 && bz < (bz_max - 1) && bx > 0 && bx < (bx_max - 1)) { + if (bx == island_block_x[0] && bz == mISL_BLOCK_Z) { + block_info->fg_info.items_p = Save_Get(island.fgblock[0][0]).items[0]; + } else if (bx == island_block_x[1] && bz == mISL_BLOCK_Z) { + block_info->fg_info.items_p = Save_Get(island.fgblock[0][1]).items[0]; + } else if (bz >= (bz_max - 3)) { + block_info->fg_info.items_p = l_fg_outer_fill; + } else { + block_info->fg_info.items_p = Save_Get(fg[bz - 1][bx - 1]).items[0]; + } + } else { + block_info->fg_info.items_p = l_fg_outer_fill; + } - block_info++; + block_info++; + } } - } } -static void mFM_SetFgUtPtoHomeInfo(mFM_block_info_c* block_info, u8 bx_max, u8 bz_max, mActor_name_t house_no, int floor) { - int bx; - int bz; +static void mFM_SetFgUtPtoHomeInfo(mFM_block_info_c* block_info, u8 bx_max, u8 bz_max, mActor_name_t house_no, + int floor) { + int bz; + int bx; - for (bz = 0; bz < bz_max; bz++) { - for (bx = 0; bx < bx_max; bx++) { - block_info->fg_info.items_p = Save_Get(homes[house_no]).floors[floor].layer_main.items[0]; - block_info++; + for (bz = 0; bz < bz_max; bz++) { + for (bx = 0; bx < bx_max; bx++) { + block_info->fg_info.items_p = Save_Get(homes[house_no]).floors[floor].layer_main.items[0]; + block_info++; + } } - } } static void mFM_SetFgUtPtoCottageInfo(mFM_block_info_c* block_info, u8 bx_max, u8 bz_max) { - int bx; - int bz; + int bz; + int bx; - for (bz = 0; bz < bz_max; bz++) { - for (bx = 0; bx < bx_max; bx++) { - block_info->fg_info.items_p = Save_Get(island).cottage.room.layer_main.items[0]; - block_info++; + for (bz = 0; bz < bz_max; bz++) { + for (bx = 0; bx < bx_max; bx++) { + block_info->fg_info.items_p = Save_Get(island).cottage.room.layer_main.items[0]; + block_info++; + } } - } } static void mFM_ChangeFGName(mActor_name_t* fg_name_p, mActor_name_t fg_name, mActor_name_t field_name, int block) { - mActor_name_t house_owner_name = Common_Get(house_owner_name); + mActor_name_t house_owner_name = Common_Get(house_owner_name); - if (Save_Get(scene_no) == SCENE_COTTAGE_NPC) { - fg_name_p[0] = Common_Get(island_npclist[0]).house_data.main_layer_id; - } - else if (field_name == mFI_FIELD_NPCROOM0 && ITEM_NAME_GET_TYPE(house_owner_name) == NAME_TYPE_NPC) { - int npc_idx = mNpc_SearchAnimalinfo(Save_Get(animals), house_owner_name, ANIMAL_NUM_MAX); - mNpc_NpcList_c* list = Common_GetPointer(npclist[npc_idx]); - - fg_name_p[0] = list->house_data.main_layer_id; - } - else if (mFI_CheckShopFieldName(field_name)) { - fg_name_p[0] = mSP_GetNowShopFgNum(); - } - else if (Save_Get(scene_no) == SCENE_FIELD_TOOL || Save_Get(scene_no) == SCENE_TITLE_DEMO) { - fg_name_p[0] = l_title_demo_fg[block]; - } - else { - fg_name_p[0] = fg_name; - } + if (Save_Get(scene_no) == SCENE_COTTAGE_NPC) { + fg_name_p[0] = Common_Get(island_npclist[0]).house_data.main_layer_id; + } else if (field_name == mFI_FIELD_NPCROOM0 && ITEM_NAME_GET_TYPE(house_owner_name) == NAME_TYPE_NPC) { + int npc_idx = mNpc_SearchAnimalinfo(Save_Get(animals), house_owner_name, ANIMAL_NUM_MAX); + mNpc_NpcList_c* list = Common_GetPointer(npclist[npc_idx]); + + fg_name_p[0] = list->house_data.main_layer_id; + } else if (mFI_CheckShopFieldName(field_name)) { + fg_name_p[0] = mSP_GetNowShopFgNum(); + } else if (Save_Get(scene_no) == SCENE_FIELD_TOOL || Save_Get(scene_no) == SCENE_TITLE_DEMO) { + fg_name_p[0] = l_title_demo_fg[block]; + } else { + fg_name_p[0] = fg_name; + } } static void mFM_ChangeBGName(mActor_name_t* bg_name_p, mActor_name_t bg_name, mActor_name_t field_name) { - if (mFI_CheckShopFieldName(field_name)) { - bg_name_p[0] = mSP_GetNowShopBgNum(); - } - else if (mFI_GET_TYPE(field_name) == mFI_FIELD_PLAYER0_ROOM) { - bg_name_p[0] = mRmTp_GetPlayerRoomCollisionIdx(field_name, bg_name); - } - else { - bg_name_p[0] = bg_name; - } + if (mFI_CheckShopFieldName(field_name)) { + bg_name_p[0] = mSP_GetNowShopBgNum(); + } else if (mFI_GET_TYPE(field_name) == mFI_FIELD_PLAYER0_ROOM) { + bg_name_p[0] = mRmTp_GetPlayerRoomCollisionIdx(field_name, bg_name); + } else { + bg_name_p[0] = bg_name; + } } -static void mFM_SetSoundSource(mFM_bg_sound_source_c* sound_source, mFM_bg_sound_source_data_c* data, int count, int bx, int bz) { - int i; +static void mFM_SetSoundSource(mFM_bg_sound_source_c* sound_source, mFM_bg_sound_source_data_c* data, int count, int bx, + int bz) { + int i; - for (i = 0; i != count; i++) { - sound_source->kind = data->kind; - sound_source->pos.x = data->ut_x * mFI_UT_WORLDSIZE_X_F; - sound_source->pos.x += bx * mFI_BK_WORLDSIZE_X_F + mFI_UT_WORLDSIZE_HALF_X_F; - sound_source->pos.y = 0.0f; - sound_source->pos.z = data->ut_z * mFI_UT_WORLDSIZE_Z_F; - sound_source->pos.z += bz * mFI_BK_WORLDSIZE_Z_F + mFI_UT_WORLDSIZE_HALF_Z_F; + for (i = 0; i != count; i++) { + sound_source->kind = data->kind; + sound_source->pos.x = data->ut_x * mFI_UT_WORLDSIZE_X_F; + sound_source->pos.x += bx * mFI_BK_WORLDSIZE_X_F + mFI_UT_WORLDSIZE_HALF_X_F; + sound_source->pos.y = 0.0f; + sound_source->pos.z = data->ut_z * mFI_UT_WORLDSIZE_Z_F; + sound_source->pos.z += bz * mFI_BK_WORLDSIZE_Z_F + mFI_UT_WORLDSIZE_HALF_Z_F; - data++; - sound_source++; - } + data++; + sound_source++; + } } -static void mFM_SetBG(mFM_bg_info_c* bg_info, mFM_bg_data_c* bg_data, u16 height, u8 type, mActor_name_t bg_name, int block_x, int block_z) { - bg_info->bg_id.height = height; - bg_info->bg_id.combination_type = bg_name; - bg_info->opaque_gfx = bg_data->opaque_gfx; - bg_info->translucent_gfx = bg_data->translucent_gfx; - bg_info->animation = bg_data->animation; - bg_info->animation_count = bg_data->animation_count; - bg_info->rom_start_addr = bg_data->rom_start_addr; - bg_info->rom_size = bg_data->rom_end_addr - bg_data->rom_start_addr; - bg_info->block_type = type; - bg_info->block_kind = mRF_Type2BlockInfo(type); +static void mFM_SetBG(mFM_bg_info_c* bg_info, mFM_bg_data_c* bg_data, u16 height, u8 type, mActor_name_t bg_name, + int block_x, int block_z) { + bg_info->bg_id.height = height; + bg_info->bg_id.combination_type = bg_name; + bg_info->opaque_gfx = bg_data->opaque_gfx; + bg_info->translucent_gfx = bg_data->translucent_gfx; + bg_info->animation = bg_data->animation; + bg_info->animation_count = bg_data->animation_count; + bg_info->rom_start_addr = bg_data->rom_start_addr; + bg_info->rom_size = bg_data->rom_end_addr - bg_data->rom_start_addr; + bg_info->block_type = type; + bg_info->block_kind = mRF_Type2BlockInfo(type); - mFM_SetSoundSource(bg_info->sound_source, bg_data->sound_source, mFM_SOUND_SOURCE_NUM, block_x, block_z); - mFM_BgUtDataSet(bg_info->collision[0], bg_info->keep_h[0], bg_data->collision[0]); + mFM_SetSoundSource(bg_info->sound_source, bg_data->sound_source, mFM_SOUND_SOURCE_NUM, block_x, block_z); + mFM_BgUtDataSet(bg_info->collision[0], bg_info->keep_h[0], bg_data->collision[0]); } static void mFM_SetFG(mFM_fg_info_c* fg_info, mFM_fg_data_c* data, mActor_name_t fg_name) { - int scene; - int i; + int scene; + int i; - fg_info->fg_id = fg_name; - fg_info->move_actor_bit_data = 0; + fg_info->fg_id = fg_name; + fg_info->move_actor_bit_data = 0; - scene = Save_Get(scene_no); + scene = Save_Get(scene_no); - if ( - scene != SCENE_FG && - scene != SCENE_MY_ROOM_S && scene != SCENE_MY_ROOM_M && scene != SCENE_MY_ROOM_L && - scene != SCENE_MY_ROOM_LL1 && scene != SCENE_MY_ROOM_LL2 && - scene != SCENE_MY_ROOM_BASEMENT_S && scene != SCENE_MY_ROOM_BASEMENT_M && scene != SCENE_MY_ROOM_BASEMENT_L && scene != SCENE_MY_ROOM_BASEMENT_LL1 && - scene != SCENE_COTTAGE_MY - ) { - if (scene == SCENE_COTTAGE_NPC) { - if (mNpc_GetIslandRoomFtrNum() > 0) { - mFM_FgUtDataSet(fg_info->items_p, mNpc_GetIslandRoomP(Save_Get(island).animal.id.npc_id)); - mNpc_ChangeIslandRoom(fg_info->items_p); - } - else { - mFM_FgUtDataSet(fg_info->items_p, data->items[0]); - } + if (scene != SCENE_FG && scene != SCENE_MY_ROOM_S && scene != SCENE_MY_ROOM_M && scene != SCENE_MY_ROOM_L && + scene != SCENE_MY_ROOM_LL1 && scene != SCENE_MY_ROOM_LL2 && scene != SCENE_MY_ROOM_BASEMENT_S && + scene != SCENE_MY_ROOM_BASEMENT_M && scene != SCENE_MY_ROOM_BASEMENT_L && scene != SCENE_MY_ROOM_BASEMENT_LL1 && + scene != SCENE_COTTAGE_MY) { + if (scene == SCENE_COTTAGE_NPC) { + if (mNpc_GetIslandRoomFtrNum() > 0) { + mFM_FgUtDataSet(fg_info->items_p, mNpc_GetIslandRoomP(Save_Get(island).animal.id.npc_id)); + mNpc_ChangeIslandRoom(fg_info->items_p); + } else { + mFM_FgUtDataSet(fg_info->items_p, data->items[0]); + } - if (fg_info != NULL && fg_info->items_p != NULL) { - mActor_name_t* items_p = fg_info->items_p; - - items_p[(8 << 4) | 3] = EXIT_DOOR; - items_p[(8 << 4) | 4] = EXIT_DOOR; - } + if (fg_info != NULL && fg_info->items_p != NULL) { + mActor_name_t* items_p = fg_info->items_p; + + items_p[(8 << 4) | 3] = EXIT_DOOR; + items_p[(8 << 4) | 4] = EXIT_DOOR; + } + } else { + mFM_FgUtDataSet(fg_info->items_p, data->items[0]); + } } - else { - mFM_FgUtDataSet(fg_info->items_p, data->items[0]); - } - } - for (i = 0; i < mFM_HANIWA_STEP_NUM; i++) { - fg_info->haniwa_step[i] = data->haniwa_step[i]; - } + for (i = 0; i < mFM_HANIWA_STEP_NUM; i++) { + fg_info->haniwa_step[i] = data->haniwa_step[i]; + } } static void mFM_SetFG2(mActor_name_t* items_p, mFM_fg_data_c** data, mActor_name_t field_name, int name_start) { - mActor_name_t house_owner_name = Common_Get(house_owner_name); + mActor_name_t house_owner_name = Common_Get(house_owner_name); - if (items_p != NULL && Save_Get(scene_no) == SCENE_COTTAGE_NPC) { - int idx = mFM_FG2_ID_MAX; - - idx -= name_start; - if (idx < 0) { - idx = 0; + if (items_p != NULL && Save_Get(scene_no) == SCENE_COTTAGE_NPC) { + int idx = mFM_FG2_ID_MAX; + + idx -= name_start; + if (idx < 0) { + idx = 0; + } + + if (data[idx] != NULL) { + mFM_FgUtDataSet(items_p, data[idx]->items[0]); + } + } else { + if (items_p != NULL && field_name == mFI_FIELD_NPCROOM0 && + ITEM_NAME_GET_TYPE(house_owner_name) == NAME_TYPE_NPC) { + int anm_idx = mNpc_SearchAnimalinfo(Save_Get(animals), house_owner_name, ANIMAL_NUM_MAX); + mNpc_NpcList_c* npc_list = Common_GetPointer(npclist[anm_idx]); + int secondary_idx = npc_list->house_data.secondary_layer_id - name_start; + + if (secondary_idx < 0) { + secondary_idx = 0; + } + + if (data[secondary_idx] != NULL) { + mFM_FgUtDataSet(items_p, data[secondary_idx]->items[0]); + } + } } - - if (data[idx] != NULL) { - mFM_FgUtDataSet(items_p, data[idx]->items[0]); - } - } - else { - if (items_p != NULL && field_name == mFI_FIELD_NPCROOM0 && ITEM_NAME_GET_TYPE(house_owner_name) == NAME_TYPE_NPC) { - int anm_idx = mNpc_SearchAnimalinfo(Save_Get(animals), house_owner_name, ANIMAL_NUM_MAX); - mNpc_NpcList_c* npc_list = Common_GetPointer(npclist[anm_idx]); - int secondary_idx = npc_list->house_data.secondary_layer_id - name_start; - - if (secondary_idx < 0) { - secondary_idx = 0; - } - - if (data[secondary_idx] != NULL) { - mFM_FgUtDataSet(items_p, data[secondary_idx]->items[0]); - } - } - } } -static void mFM_BlockDataSet( - mActor_name_t field_name, - mFM_block_info_c* block_info, - mFM_combination_c* save_combi_table, - mFM_bg_data_c** bg_data_list, - mFM_fg_data_c** fg_data_list, - mFM_combo_info_c* data_combi_table, - int bx_max, - int bz_max, - int name_start -) { - mFM_combo_info_c* combi; - mActor_name_t bg_name; - mActor_name_t fg_name; - int fg_idx; - int i; - int bx = 0; - int bz = 0; - int max = bz_max * bx_max; +static void mFM_BlockDataSet(mActor_name_t field_name, mFM_block_info_c* block_info, + mFM_combination_c* save_combi_table, mFM_bg_data_c** bg_data_list, + mFM_fg_data_c** fg_data_list, mFM_combo_info_c* data_combi_table, int bx_max, int bz_max, + int name_start) { + mFM_combo_info_c* combi; + mActor_name_t bg_name; + mActor_name_t fg_name; + int fg_idx; + int i; + int bx = 0; + int bz = 0; + int max = bz_max * bx_max; - for (i = 0; i < max; i++) { - combi = &data_combi_table[save_combi_table[0].combination_type]; + for (i = 0; i < max; i++) { + combi = &data_combi_table[save_combi_table[0].combination_type]; - mFM_ChangeFGName(&fg_name, combi->fg_id, field_name, i); - mFM_ChangeBGName(&bg_name, combi->bg_id, field_name); + mFM_ChangeFGName(&fg_name, combi->fg_id, field_name, i); + mFM_ChangeBGName(&bg_name, combi->bg_id, field_name); - if (bg_name > mFM_BG_ID_MAX) { - bg_name = 0; + if (bg_name > mFM_BG_ID_MAX) { + bg_name = 0; + } + + if (fg_name > mFM_FG_ID_MAX) { + fg_name = 0; + } + + fg_idx = fg_name - name_start; + if (fg_idx < 0) { + fg_idx = 0; + } + + if (bg_data_list[bg_name] != NULL && fg_data_list[fg_idx]) { + mFM_SetBG(&block_info->bg_info, bg_data_list[bg_name], save_combi_table[0].height, combi->type, bg_name, bx, + bz); + mFM_SetFG(&block_info->fg_info, fg_data_list[fg_idx], fg_name); + } + + bx++; + + if (bx >= bx_max) { + bx = 0; + bz++; + } + + block_info++; + save_combi_table++; } - - if (fg_name > mFM_FG_ID_MAX) { - fg_name = 0; - } - - fg_idx = fg_name - name_start; - if (fg_idx < 0) { - fg_idx = 0; - } - - if (bg_data_list[bg_name] != NULL && fg_data_list[fg_idx]) { - mFM_SetBG(&block_info->bg_info, bg_data_list[bg_name], save_combi_table[0].height, combi->type, bg_name, bx, bz); - mFM_SetFG(&block_info->fg_info, fg_data_list[fg_idx], fg_name); - } - - bx++; - - if (bx >= bx_max) { - bx = 0; - bz++; - } - - block_info++; - save_combi_table++; - } } static void mFM_KeepPolicePos(int bx, int bz, int ut_x, int ut_z) { - l_mfm_police_pos.bx = bx; - l_mfm_police_pos.bz = bz; - l_mfm_police_pos.ut_x = ut_x; - l_mfm_police_pos.ut_z = ut_z; + l_mfm_police_pos.bx = bx; + l_mfm_police_pos.bz = bz; + l_mfm_police_pos.ut_x = ut_x; + l_mfm_police_pos.ut_z = ut_z; } extern void mFM_GetPolicePos(int* bx, int* bz, int* ut_x, int* ut_z) { - *bx = l_mfm_police_pos.bx; - *bz = l_mfm_police_pos.bz; - *ut_x = l_mfm_police_pos.ut_x; - *ut_z = l_mfm_police_pos.ut_z; + *bx = l_mfm_police_pos.bx; + *bz = l_mfm_police_pos.bz; + *ut_x = l_mfm_police_pos.ut_x; + *ut_z = l_mfm_police_pos.ut_z; } -static void mFM_SetMoveActorInfo(mFM_block_info_c* block_info, int bx_max, int bz_max, mFM_move_actor_data_c* move_actor_data, u32 param_5, u32 param_6) { - mFM_move_actor_data_c* move_ac_data_p = move_actor_data; +static void mFM_SetMoveActorInfo(mFM_block_info_c* block_info, int bx_max, int bz_max, + mFM_move_actor_data_c* move_actor_data, u32 param_5, u32 param_6) { + mFM_move_actor_data_c* move_ac_data_p = move_actor_data; - if (block_info != NULL) { - for (move_ac_data_p; move_ac_data_p != NULL && move_ac_data_p->name_id != RSV_NO; move_ac_data_p++) { - int block = -1; - int ut_x; - int ut_z; + if (block_info != NULL) { + for (move_ac_data_p; move_ac_data_p != NULL && move_ac_data_p->name_id != RSV_NO; move_ac_data_p++) { + int block = -1; + int ut_x; + int ut_z; - ut_x = move_ac_data_p->ut_x; - ut_z = move_ac_data_p->ut_z; + ut_x = move_ac_data_p->ut_x; + ut_z = move_ac_data_p->ut_z; - if (move_ac_data_p->desired_block_kind == mRF_BLOCKKIND_NONE) { - block = move_ac_data_p->block_x + move_ac_data_p->block_z * bx_max; - } - else { - int bx; - int bz; + if (move_ac_data_p->desired_block_kind == mRF_BLOCKKIND_NONE) { + block = move_ac_data_p->block_x + move_ac_data_p->block_z * bx_max; + } else { + int bx; + int bz; - if (mFI_BlockKind2BkNum(&bx, &bz, move_ac_data_p->desired_block_kind) == TRUE) { - block = bx + bz * bx_max; + if (mFI_BlockKind2BkNum(&bx, &bz, move_ac_data_p->desired_block_kind) == TRUE) { + block = bx + bz * bx_max; - switch (move_ac_data_p->name_id) { - case SP_NPC_POLICE: - { - mActor_name_t* items = block_info[block].fg_info.items_p; - int i; + switch (move_ac_data_p->name_id) { + case SP_NPC_POLICE: { + mActor_name_t* items = block_info[block].fg_info.items_p; + int i; - for (i = 0; i < UT_TOTAL_NUM; i++) { - if (items[0] == POLICE_STATION) { - ut_x = i % UT_X_NUM; - ut_z = i / UT_Z_NUM; - ut_x += 2; - mFM_KeepPolicePos(bx, bz, ut_x, ut_z); + for (i = 0; i < UT_TOTAL_NUM; i++) { + if (items[0] == POLICE_STATION) { + ut_x = i % UT_X_NUM; + ut_z = i / UT_Z_NUM; + ut_x += 2; + mFM_KeepPolicePos(bx, bz, ut_x, ut_z); - break; + break; + } + + items++; + } + + break; + } + + case SP_NPC_SONCHO: { + if (mEv_CheckFirstJob() == FALSE || + (mSC_check_ArbeitPlayer() && mSC_LightHouse_travel_check())) { + block = -1; + } + + break; + } + } } - - items++; - } - - break; } - case SP_NPC_SONCHO: - { - if (mEv_CheckFirstJob() == FALSE || (mSC_check_ArbeitPlayer() && mSC_LightHouse_travel_check())) { - block = -1; - } + if (block != -1) { + mFM_move_actor_c* move_actor = block_info[block].fg_info.move_actors; + int free_idx = mFI_GetMoveActorListIdx(move_actor, mFM_MOVE_ACTOR_NUM, EMPTY_NO); - break; + if (free_idx != -1) { + move_actor[free_idx].name_id = move_ac_data_p->name_id; + move_actor[free_idx].ut_x = ut_x; + move_actor[free_idx].ut_z = ut_z; + move_actor[free_idx].npc_info_idx = move_ac_data_p->npc_info_idx; + move_actor[free_idx].arg = move_ac_data_p->arg; + } } - } } - } - - if (block != -1) { - mFM_move_actor_c* move_actor = block_info[block].fg_info.move_actors; - int free_idx = mFI_GetMoveActorListIdx(move_actor, mFM_MOVE_ACTOR_NUM, EMPTY_NO); - - if (free_idx != -1) { - move_actor[free_idx].name_id = move_ac_data_p->name_id; - move_actor[free_idx].ut_x = ut_x; - move_actor[free_idx].ut_z = ut_z; - move_actor[free_idx].npc_info_idx = move_ac_data_p->npc_info_idx; - move_actor[free_idx].arg = move_ac_data_p->arg; - } - } } - } } static void mFM_SetCombiTable(mFM_combination_c* combi_table, mFM_combination_c* combi_id, u8 bx_max, u8 bz_max) { - u8 bz; - u8 bx; - - for (bz = 0; bz < bz_max; bz++) { - for (bx = 0; bx < bx_max; bx++) { - combi_table->combination_type = combi_id->combination_type; - combi_table->height = combi_id->height; + u8 bz; + u8 bx; - combi_table++; - combi_id++; + for (bz = 0; bz < bz_max; bz++) { + for (bx = 0; bx < bx_max; bx++) { + combi_table->combination_type = combi_id->combination_type; + combi_table->height = combi_id->height; + + combi_table++; + combi_id++; + } } - } } static int mFM_SetBlockInfo(mFM_fdinfo_c* field_info, mFM_combination_c* combi_table) { - mFM_bg_data_c** sorted_bg_data; - mFM_fg_data_c** sorted_fg_data; - mFM_combo_info_c* combi_info_p; - mFM_bg_data_c* bg_data_p = data_bgd; - mFM_fg_data_c* fg_data; - size_t malloc_size; - u32 aram_addr; - int fg_count; - int name_start; - int fg_data_entries; - int file_id; - u32 size; - u32 align_size; - - if (mFI_GET_TYPE(field_info->field_id) == mFI_FIELD_NPCROOM0) { - malloc_size = mFM_FG_NPC_NUM * sizeof(mFM_fg_data_c*); - fg_count = mFM_FG_NPC_NUM; - name_start = mFM_FG_NPC_START; - file_id = RESOURCE_FGNPCDATA; - } - else { - malloc_size = mFM_FG_NUM * sizeof(mFM_fg_data_c*); - fg_count = mFM_FG_NUM; - name_start = mFM_FG_START; - file_id = RESOURCE_FGDATA; - } - - { - size = JW_GetResSizeFileNo(file_id); - align_size = ALIGN_NEXT(size, 32); - fg_data = (mFM_fg_data_c*)zelda_malloc_align(align_size, 32); - fg_data_entries = size / sizeof(mFM_fg_data_c); - - _JW_GetResourceAram(JW_GetAramAddress(file_id), (u8*)fg_data, align_size); - combi_info_p = data_combi_table; - sorted_bg_data = (mFM_bg_data_c**)zelda_malloc(mFM_BG_ID_MAX * sizeof(mFM_bg_data_c**)); - - if (sorted_bg_data == NULL) { - return FALSE; - } - - mFM_SortBGData(sorted_bg_data, bg_data_p, data_bgd_number); - sorted_fg_data = (mFM_fg_data_c**)zelda_malloc(malloc_size); - - if (sorted_fg_data == NULL) { - return FALSE; /* @BUG - possible memory leak from the sorted_bg_data malloc */ - } - - mFM_SortFGData(sorted_fg_data, fg_data, fg_count, fg_data_entries, name_start); - - mFM_BlockDataSet( - field_info->field_id, - field_info->block_info, - combi_table, - sorted_bg_data, - sorted_fg_data, - combi_info_p, - field_info->block_x_max, - field_info->block_z_max, - name_start - ); - - mFM_SetFG2(field_info->fg2_p[0], sorted_fg_data, field_info->field_id, name_start); + mFM_bg_data_c** sorted_bg_data; + mFM_fg_data_c** sorted_fg_data; + mFM_combo_info_c* combi_info_p; + mFM_bg_data_c* bg_data_p = data_bgd; + mFM_fg_data_c* fg_data; + size_t malloc_size; + u32 aram_addr; + int fg_count; + int name_start; + int file_id; + u32 align_size; + int fg_data_entries; + u32 size; if (mFI_GET_TYPE(field_info->field_id) == mFI_FIELD_NPCROOM0) { - mNpc_SetNpcFurnitureRandom(sorted_fg_data, name_start); // select a random furniture item from NPC base furniture layer + malloc_size = mFM_FG_NPC_NUM * sizeof(mFM_fg_data_c*); + fg_count = mFM_FG_NPC_NUM; + name_start = mFM_FG_NPC_START; + file_id = RESOURCE_FGNPCDATA; + } else { + malloc_size = mFM_FG_NUM * sizeof(mFM_fg_data_c*); + fg_count = mFM_FG_NUM; + name_start = mFM_FG_START; + file_id = RESOURCE_FGDATA; } - - zelda_free(sorted_bg_data); - zelda_free(sorted_fg_data); - zelda_free(fg_data); - } - return 0; + { + size = JW_GetResSizeFileNo(file_id); + align_size = ALIGN_NEXT(size, 32); + fg_data = (mFM_fg_data_c*)zelda_malloc_align(align_size, 32); + fg_data_entries = size / sizeof(mFM_fg_data_c); + + _JW_GetResourceAram(JW_GetAramAddress(file_id), (u8*)fg_data, align_size); + combi_info_p = data_combi_table; + sorted_bg_data = (mFM_bg_data_c**)zelda_malloc(mFM_BG_ID_MAX * sizeof(mFM_bg_data_c**)); + + if (sorted_bg_data == NULL) { + return FALSE; + } + + mFM_SortBGData(sorted_bg_data, bg_data_p, data_bgd_number); + sorted_fg_data = (mFM_fg_data_c**)zelda_malloc(malloc_size); + + if (sorted_fg_data == NULL) { + return FALSE; /* @BUG - possible memory leak from the sorted_bg_data malloc */ + } + + mFM_SortFGData(sorted_fg_data, fg_data, fg_count, fg_data_entries, name_start); + + mFM_BlockDataSet(field_info->field_id, field_info->block_info, combi_table, sorted_bg_data, sorted_fg_data, + combi_info_p, field_info->block_x_max, field_info->block_z_max, name_start); + + mFM_SetFG2(field_info->fg2_p[0], sorted_fg_data, field_info->field_id, name_start); + + if (mFI_GET_TYPE(field_info->field_id) == mFI_FIELD_NPCROOM0) { + mNpc_SetNpcFurnitureRandom(sorted_fg_data, + name_start); // select a random furniture item from NPC base furniture layer + } + +// Aus version added NULL checks +#if VERSION >= VER_GAFU01_00 + if (sorted_bg_data != NULL) { + zelda_free(sorted_bg_data); + } + + if (sorted_fg_data != NULL) { + zelda_free(sorted_fg_data); + } + + if (fg_data != NULL) { + zelda_free(fg_data); + } +#else + zelda_free(sorted_bg_data); + zelda_free(sorted_fg_data); + zelda_free(fg_data); +#endif + } + + return 0; } static void mFM_set_pal_p(mFM_field_pal_c* pal) { - if (pal != NULL) { - bzero(mFM_pal_area, sizeof(mFM_pal_area)); + if (pal != NULL) { + bzero(mFM_pal_area, sizeof(mFM_pal_area)); - pal->earth_pal = mFM_pal_area[0]; - pal->cliff_pal = mFM_pal_area[1]; - pal->bush_pal = mFM_pal_area[2]; - pal->flower0_pal = mFM_pal_area[3]; - pal->flower1_pal = mFM_pal_area[4]; - pal->flower2_pal = mFM_pal_area[5]; - pal->grass_pal = mFM_pal_area[6]; - pal->tree_pal = mFM_pal_area[7]; - pal->cedar_tree_pal = mFM_pal_area[8]; - pal->palm_tree_pal = mFM_pal_area[9]; - pal->golden_tree_pal = mFM_pal_area[10]; - } + pal->earth_pal = mFM_pal_area[0]; + pal->cliff_pal = mFM_pal_area[1]; + pal->bush_pal = mFM_pal_area[2]; + pal->flower0_pal = mFM_pal_area[3]; + pal->flower1_pal = mFM_pal_area[4]; + pal->flower2_pal = mFM_pal_area[5]; + pal->grass_pal = mFM_pal_area[6]; + pal->tree_pal = mFM_pal_area[7]; + pal->cedar_tree_pal = mFM_pal_area[8]; + pal->palm_tree_pal = mFM_pal_area[9]; + pal->golden_tree_pal = mFM_pal_area[10]; + } } extern u16 mFM_obj_a_01_flower_pal[3 * 9][16]; @@ -582,32 +584,20 @@ extern u16 mFM_obj_palm_01_pal[14][16]; extern u16 mFM_obj_gold_01_pal_dol[14][16]; static void mFM_SetFGPal(mFM_field_pal_c* pal, int term) { - static int tree_pal_idx_table[mTM_TERM_NUM] = { - 10, 12, 13, 0, - 1, 2, 2, 3, - 3, 4, 5, 6, - 7, 8, 9, 10, - 11, 10 - }; + static int tree_pal_idx_table[mTM_TERM_NUM] = { 10, 12, 13, 0, 1, 2, 2, 3, 3, 4, 5, 6, 7, 8, 9, 10, 11, 10 }; - static int flower_pal_idx_table[mTM_TERM_NUM] = { - 8, 8, 8, 0, - 1, 1, 1, 2, - 2, 3, 4, 5, - 6, 7, 8, 8, - 8, 8 - }; + static int flower_pal_idx_table[mTM_TERM_NUM] = { 8, 8, 8, 0, 1, 1, 1, 2, 2, 3, 4, 5, 6, 7, 8, 8, 8, 8 }; - int idx = flower_pal_idx_table[term]; + int idx = flower_pal_idx_table[term]; - bcopy(mFM_obj_a_01_flower_pal[0 * 9 + idx], pal->flower0_pal, 16 * sizeof(u16)); - bcopy(mFM_obj_a_01_flower_pal[1 * 9 + idx], pal->flower1_pal, 16 * sizeof(u16)); - bcopy(mFM_obj_a_01_flower_pal[2 * 9 + idx], pal->flower2_pal, 16 * sizeof(u16)); - bcopy(mFM_obj_01_zassou_pal[idx], pal->grass_pal, 16 * sizeof(u16)); - bcopy(mFM_obj_tree_01_pal[tree_pal_idx_table[term]], pal->tree_pal, 16 * sizeof(u16)); - bcopy(mFM_obj_tree_01_pal_dol[tree_pal_idx_table[term]], pal->cedar_tree_pal, 16 * sizeof(u16)); - bcopy(mFM_obj_palm_01_pal[tree_pal_idx_table[term]], pal->palm_tree_pal, 16 * sizeof(u16)); - bcopy(mFM_obj_gold_01_pal_dol[tree_pal_idx_table[term]], pal->golden_tree_pal, 16 * sizeof(u16)); + bcopy(mFM_obj_a_01_flower_pal[0 * 9 + idx], pal->flower0_pal, 16 * sizeof(u16)); + bcopy(mFM_obj_a_01_flower_pal[1 * 9 + idx], pal->flower1_pal, 16 * sizeof(u16)); + bcopy(mFM_obj_a_01_flower_pal[2 * 9 + idx], pal->flower2_pal, 16 * sizeof(u16)); + bcopy(mFM_obj_01_zassou_pal[idx], pal->grass_pal, 16 * sizeof(u16)); + bcopy(mFM_obj_tree_01_pal[tree_pal_idx_table[term]], pal->tree_pal, 16 * sizeof(u16)); + bcopy(mFM_obj_tree_01_pal_dol[tree_pal_idx_table[term]], pal->cedar_tree_pal, 16 * sizeof(u16)); + bcopy(mFM_obj_palm_01_pal[tree_pal_idx_table[term]], pal->palm_tree_pal, 16 * sizeof(u16)); + bcopy(mFM_obj_gold_01_pal_dol[tree_pal_idx_table[term]], pal->golden_tree_pal, 16 * sizeof(u16)); } extern u16 mFM_earth_pal[mFM_FIELD_PAL_NUM][16]; @@ -617,302 +607,275 @@ extern u16 mFM_rail_pal[mFM_FIELD_PAL_NUM][16]; extern u16 mFM_beach_pal[mFM_FIELD_PAL_NUM][16]; static void mFM_SetFieldPal(mFM_field_pal_c* pal) { - static int field_pal_idx_table[mTM_TERM_NUM] = { - 9, 10, 11, 0, - 1, 1, 1, 2, - 2, 3, 4, 5, - 6, 7, 8, 9, - 9, 9 - }; + static int field_pal_idx_table[mTM_TERM_NUM] = { 9, 10, 11, 0, 1, 1, 1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 9, 9 }; - u32 term = Common_Get(time.term_idx); - int field_pal_idx; - int i; - u16* pal_src; + u32 term = Common_Get(time.term_idx); + int field_pal_idx; + int i; + u16* pal_src; - if (term >= mTM_TERM_NUM) { - term = mTM_TERM_0; - } + if (term >= mTM_TERM_NUM) { + term = mTM_TERM_0; + } - if (Save_Get(scene_no) == SCENE_MUSEUM_ROOM_INSECT) { - term = mTM_TERM_4; - } + if (Save_Get(scene_no) == SCENE_MUSEUM_ROOM_INSECT) { + term = mTM_TERM_4; + } - field_pal_idx = field_pal_idx_table[term]; + field_pal_idx = field_pal_idx_table[term]; - pal_src = mFM_earth_pal[field_pal_idx]; - for (i = 0; i < 16; i++) { - pal->earth_pal[i] = pal_src[i]; - } + pal_src = mFM_earth_pal[field_pal_idx]; + for (i = 0; i < 16; i++) { + pal->earth_pal[i] = pal_src[i]; + } - pal_src = mFM_cliff_pal[field_pal_idx]; - for (i = 0; i < 16; i++) { - pal->cliff_pal[i] = pal_src[i]; - } + pal_src = mFM_cliff_pal[field_pal_idx]; + for (i = 0; i < 16; i++) { + pal->cliff_pal[i] = pal_src[i]; + } - pal_src = mFM_bush_pal[field_pal_idx]; - for (i = 0; i < 16; i++) { - pal->bush_pal[i] = pal_src[i]; - } + pal_src = mFM_bush_pal[field_pal_idx]; + for (i = 0; i < 16; i++) { + pal->bush_pal[i] = pal_src[i]; + } - mFM_SetFGPal(pal, term); + mFM_SetFGPal(pal, term); } -static void mFM_SetFgDepositP(mFM_block_info_c* block_info, mActor_name_t field_id, int bx_max, int bz_max, int* island_x_blocks) { - mFM_block_info_c* block_info_p; - int total_block; - int scene; - u16* deposit_p; - int bz; - int bx; - int fg_blocks; +static void mFM_SetFgDepositP(mFM_block_info_c* block_info, mActor_name_t field_id, int bx_max, int bz_max, + int* island_x_blocks) { + mFM_block_info_c* block_info_p; + int total_block; + int scene; + u16* deposit_p; + int bz; + int bx; + int fg_blocks; - scene = Save_Get(scene_no); - total_block = bx_max * bz_max; - block_info_p = block_info; + scene = Save_Get(scene_no); + total_block = bx_max * bz_max; + block_info_p = block_info; - for (bz = 0; bz < total_block; bz++) { - block_info[bz].fg_info.deposit_p = NULL; - } - - if ((mFI_GET_TYPE(field_id) == mFI_FIELD_FG)) { - fg_blocks = 0; - - if (scene == SCENE_FG) { - for (bz = 0; bz < bz_max; bz++) { - for (bx = 0; bx < bx_max; bx++) { - if (fg_blocks >= FG_BLOCK_TOTAL_NUM) { - break; - } - - if (bx > 0 && bx < bx_max - 1 && bz > 0 && bz < bz_max - 3) { - block_info->fg_info.deposit_p = Save_GetPointer(deposit[fg_blocks++][0]); - } - - block_info++; - } - } - - block_info = block_info_p + island_x_blocks[0] + bx_max * mISL_BLOCK_Z; - - /* @BUG - they used the island Z acre location define here on accident lol */ - #ifndef BUGFIXES - for (bz = 0; bz < mISL_BLOCK_Z; bz++) { - #else - for (bz = 0; bz < mISL_FG_BLOCK_X_NUM; bz++) { - #endif - block_info->fg_info.deposit_p = Save_Get(island).deposit[bz]; - block_info++; - } + for (bz = 0; bz < total_block; bz++) { + block_info[bz].fg_info.deposit_p = NULL; } - else { - for (bz = 0; bz < bz_max; bz++) { - for (bx = 0; bx < bx_max; bx++) { - if (fg_blocks >= FG_BLOCK_TOTAL_NUM) { - break; - } - block_info->fg_info.deposit_p = Save_GetPointer(deposit[fg_blocks++][0]); - block_info++; + if ((mFI_GET_TYPE(field_id) == mFI_FIELD_FG)) { + fg_blocks = 0; + + if (scene == SCENE_FG) { + for (bz = 0; bz < bz_max; bz++) { + for (bx = 0; bx < bx_max; bx++) { + if (fg_blocks >= FG_BLOCK_TOTAL_NUM) { + break; + } + + if (bx > 0 && bx < bx_max - 1 && bz > 0 && bz < bz_max - 3) { + block_info->fg_info.deposit_p = Save_GetPointer(deposit[fg_blocks++][0]); + } + + block_info++; + } + } + + block_info = block_info_p + island_x_blocks[0] + bx_max * mISL_BLOCK_Z; + +/* @BUG - they used the island Z acre location define here on accident lol */ +#ifndef BUGFIXES + for (bz = 0; bz < mISL_BLOCK_Z; bz++) { +#else + for (bz = 0; bz < mISL_FG_BLOCK_X_NUM; bz++) { +#endif + block_info->fg_info.deposit_p = Save_Get(island).deposit[bz]; + block_info++; + } + } else { + for (bz = 0; bz < bz_max; bz++) { + for (bx = 0; bx < bx_max; bx++) { + if (fg_blocks >= FG_BLOCK_TOTAL_NUM) { + break; + } + + block_info->fg_info.deposit_p = Save_GetPointer(deposit[fg_blocks++][0]); + block_info++; + } + } } - } } - } } extern mFM_field_data_c data_fdd[SCENE_NUM]; static mFM_fdinfo_c* mFM_MakeField(u16 scene, u16 bg_max, u8 bg_num) { - mFM_field_data_c* field_data; - int island_x_blocks[2]; - int total_block; - mFM_block_info_c* block_info; - mFM_combination_c* combi; - mFM_fdinfo_c* field_info = (mFM_fdinfo_c*)zelda_malloc(sizeof(mFM_fdinfo_c)); - int i; - int j; - mActor_name_t house_owner_id; - int floor_no; + mFM_field_data_c* field_data; + int island_x_blocks[2]; + int total_block; + mFM_block_info_c* block_info; + mFM_combination_c* combi; + mFM_fdinfo_c* field_info = (mFM_fdinfo_c*)zelda_malloc(sizeof(mFM_fdinfo_c)); + int i; + int j; + mActor_name_t house_owner_id; + int floor_no; - if (field_info == NULL) { - return NULL; - } - - bzero(field_info, sizeof(mFM_fdinfo_c)); - field_data = &data_fdd[scene]; - field_info->block_x_max = field_data->block_x_max; - field_info->block_z_max = field_data->block_z_max; - field_info->bg_num = bg_num; - field_info->bg_max = bg_max; - field_info->fg2_p = (mActor_name_t**)zelda_malloc((mHm_LAYER_NUM - 1) * sizeof(mActor_name_t*)); - - for (i = 0; i < 3; i++) { - field_info->fg2_p[i] = NULL; - } - - i = sizeof(mFM_block_info_c) * field_data->block_x_max * field_data->block_z_max; - block_info = (mFM_block_info_c*)zelda_malloc(i); - - if (block_info == NULL) { - /* @BUG - field_info was not freed */ - #ifdef BUGFIXES - zelda_free(field_info); - #endif - return NULL; - } - - bzero(block_info, i); - field_info->block_info = block_info; - field_info->field_id = field_data->field_name; - field_info->_04 = field_data->_94; - field_info->update_fg = FALSE; - field_info->born_item = FALSE; - field_info->born_actor = FALSE; - - for (j = 0; j < mFM_VISIBLE_BLOCK_NUM; j++) { - field_info->bg_draw_info[j].block_x = 0xFF; - field_info->bg_draw_info[j].block_z = 0xFF; - field_info->bg_draw_info[j].dma_loaded = FALSE; - field_info->last_bg_idx[j] = -1; - } - - if (Save_Get(scene_no) == SCENE_FG) { - mFI_GetIslandBlockNumX(island_x_blocks); - } - - if (Save_Get(scene_no) == SCENE_FG) { - combi = Save_Get(combi_table[0]); - mFM_SetFgUtPtoSaveData(field_info->block_info, field_info->block_x_max, field_info->block_z_max, island_x_blocks); - } - else if (mSc_IS_SCENE_PLAYER_ROOM(Save_Get(scene_no))) { - house_owner_id = Common_Get(house_owner_name); - floor_no = mFI_GetNowPlayerHouseFloorNo(); - - if (floor_no == -1) { - floor_no = 0; + if (field_info == NULL) { + return NULL; } - if (house_owner_id == RSV_NO) { - house_owner_id = EMPTY_NO; - Common_Set(house_owner_name, house_owner_id); + bzero(field_info, sizeof(mFM_fdinfo_c)); + field_data = &data_fdd[scene]; + field_info->block_x_max = field_data->block_x_max; + field_info->block_z_max = field_data->block_z_max; + field_info->bg_num = bg_num; + field_info->bg_max = bg_max; + field_info->fg2_p = (mActor_name_t**)zelda_malloc((mHm_LAYER_NUM - 1) * sizeof(mActor_name_t*)); + + for (i = 0; i < 3; i++) { + field_info->fg2_p[i] = NULL; } - combi = field_data->combi; - field_info->field_id = mFI_FIELD_PLAYER0_ROOM + house_owner_id; + i = sizeof(mFM_block_info_c) * field_data->block_x_max * field_data->block_z_max; + block_info = (mFM_block_info_c*)zelda_malloc(i); - if (Save_Get(scene_no) == SCENE_COTTAGE_MY) { - mFM_SetFgUtPtoCottageInfo(field_info->block_info, field_info->block_x_max, field_info->block_z_max); - } - else { - mFM_SetFgUtPtoHomeInfo(field_info->block_info, field_info->block_x_max, field_info->block_z_max, house_owner_id, floor_no); - } - } - else { - mFM_block_info_c* block_info = field_info->block_info; - int total_block = field_info->block_x_max * field_info->block_z_max; - int k; - combi = field_data->combi; - - for (k = total_block; k != 0; k--) { - mActor_name_t* fg_p = (mActor_name_t*)zelda_malloc(UT_TOTAL_NUM * sizeof(mActor_name_t)); - - // There could be a memory leak here due to previous allocated blocks, perhaps investigate later - if (fg_p == NULL) { - break; - } - - bzero(fg_p, UT_TOTAL_NUM * sizeof(mActor_name_t)); - block_info->fg_info.items_p = fg_p; - block_info++; - } - } - - if (mSc_IS_SCENE_PLAYER_ROOM(Save_Get(scene_no))) { - mHm_lyr_c* layer; - - if (Save_Get(scene_no) == SCENE_COTTAGE_MY) { - layer = &Save_Get(island).cottage.room.layer_main; - } - else { - mActor_name_t house_owner_id = Common_Get(house_owner_name); - floor_no = mFI_GetNowPlayerHouseFloorNo(); - - if (floor_no == -1) { - floor_no = 0; - } - - layer = &Save_Get(homes[house_owner_id]).floors[floor_no].layer_main; + if (block_info == NULL) { +/* @BUG - field_info was not freed */ +#ifdef BUGFIXES + zelda_free(field_info); +#endif + return NULL; } - for (i = 1; i < mHm_LAYER_NUM; i++) { - field_info->fg2_p[i - 1] = layer[i].items[0]; + bzero(block_info, i); + field_info->block_info = block_info; + field_info->field_id = field_data->field_name; + field_info->_04 = field_data->_94; + field_info->update_fg = FALSE; + field_info->born_item = FALSE; + field_info->born_actor = FALSE; + + for (j = 0; j < mFM_VISIBLE_BLOCK_NUM; j++) { + field_info->bg_draw_info[j].block_x = 0xFF; + field_info->bg_draw_info[j].block_z = 0xFF; + field_info->bg_draw_info[j].dma_loaded = FALSE; + field_info->last_bg_idx[j] = -1; } - } - else if (Save_Get(scene_no) == SCENE_NPC_HOUSE || Save_Get(scene_no) == SCENE_FIELD_TOOL_INSIDE) { - field_info->fg2_p[0] = (mActor_name_t*)zelda_malloc(UT_TOTAL_NUM * sizeof(mActor_name_t)); - if (field_info->fg2_p[0] != NULL) { - bzero(field_info->fg2_p[0], UT_TOTAL_NUM * sizeof(mActor_name_t)); + if (Save_Get(scene_no) == SCENE_FG) { + mFI_GetIslandBlockNumX(island_x_blocks); } - } - mFM_SetBlockInfo(field_info, combi); - mFM_SetMoveActorInfo(field_info->block_info, field_info->block_x_max, field_info->block_z_max, field_data->move_actor_data, field_data->_94, field_data->_98); + if (Save_Get(scene_no) == SCENE_FG) { + combi = Save_Get(combi_table[0]); + mFM_SetFgUtPtoSaveData(field_info->block_info, field_info->block_x_max, field_info->block_z_max, + island_x_blocks); + } else if (mSc_IS_SCENE_PLAYER_ROOM(Save_Get(scene_no))) { + house_owner_id = Common_Get(house_owner_name); + floor_no = mFI_GetNowPlayerHouseFloorNo(); - for (i = 0; i < mFM_VISIBLE_BLOCK_NUM; i++) { - field_info->bg_display_list_p[i] = NULL; - } + if (floor_no == -1) { + floor_no = 0; + } - for (i = 0; i < field_info->bg_num; i++) { - field_info->bg_display_list_p[i] = (u8*)zelda_malloc(field_info->bg_max); - field_info->bg_display_list_p[i] = (u8*)((u32)(field_info->bg_display_list_p[i]) + (16-1)); - field_info->bg_display_list_p[i] = (u8*)((u32)(field_info->bg_display_list_p[i]) & (~(16-1))); - } + if (house_owner_id == RSV_NO) { + house_owner_id = EMPTY_NO; + Common_Set(house_owner_name, house_owner_id); + } - mFM_set_pal_p(&field_info->field_palette); - mFM_SetFieldPal(&field_info->field_palette); - mFM_SetFgDepositP(field_info->block_info, field_info->field_id, field_info->block_x_max, field_info->block_z_max, island_x_blocks); + combi = field_data->combi; + field_info->field_id = mFI_FIELD_PLAYER0_ROOM + house_owner_id; - return field_info; + if (Save_Get(scene_no) == SCENE_COTTAGE_MY) { + mFM_SetFgUtPtoCottageInfo(field_info->block_info, field_info->block_x_max, field_info->block_z_max); + } else { + mFM_SetFgUtPtoHomeInfo(field_info->block_info, field_info->block_x_max, field_info->block_z_max, + house_owner_id, floor_no); + } + } else { + mFM_block_info_c* block_info = field_info->block_info; + int total_block = field_info->block_x_max * field_info->block_z_max; + int k; + combi = field_data->combi; + + for (k = total_block; k != 0; k--) { + mActor_name_t* fg_p = (mActor_name_t*)zelda_malloc(UT_TOTAL_NUM * sizeof(mActor_name_t)); + + // There could be a memory leak here due to previous allocated blocks, perhaps investigate later + if (fg_p == NULL) { + break; + } + + bzero(fg_p, UT_TOTAL_NUM * sizeof(mActor_name_t)); + block_info->fg_info.items_p = fg_p; + block_info++; + } + } + + if (mSc_IS_SCENE_PLAYER_ROOM(Save_Get(scene_no))) { + mHm_lyr_c* layer; + + if (Save_Get(scene_no) == SCENE_COTTAGE_MY) { + layer = &Save_Get(island).cottage.room.layer_main; + } else { + mActor_name_t house_owner_id = Common_Get(house_owner_name); + floor_no = mFI_GetNowPlayerHouseFloorNo(); + + if (floor_no == -1) { + floor_no = 0; + } + + layer = &Save_Get(homes[house_owner_id]).floors[floor_no].layer_main; + } + + for (i = 1; i < mHm_LAYER_NUM; i++) { + field_info->fg2_p[i - 1] = layer[i].items[0]; + } + } else if (Save_Get(scene_no) == SCENE_NPC_HOUSE || Save_Get(scene_no) == SCENE_FIELD_TOOL_INSIDE) { + field_info->fg2_p[0] = (mActor_name_t*)zelda_malloc(UT_TOTAL_NUM * sizeof(mActor_name_t)); + + if (field_info->fg2_p[0] != NULL) { + bzero(field_info->fg2_p[0], UT_TOTAL_NUM * sizeof(mActor_name_t)); + } + } + + mFM_SetBlockInfo(field_info, combi); + mFM_SetMoveActorInfo(field_info->block_info, field_info->block_x_max, field_info->block_z_max, + field_data->move_actor_data, field_data->_94, field_data->_98); + + for (i = 0; i < mFM_VISIBLE_BLOCK_NUM; i++) { + field_info->bg_display_list_p[i] = NULL; + } + + for (i = 0; i < field_info->bg_num; i++) { + field_info->bg_display_list_p[i] = (u8*)zelda_malloc(field_info->bg_max); + field_info->bg_display_list_p[i] = (u8*)((u32)(field_info->bg_display_list_p[i]) + (16 - 1)); + field_info->bg_display_list_p[i] = (u8*)((u32)(field_info->bg_display_list_p[i]) & (~(16 - 1))); + } + + mFM_set_pal_p(&field_info->field_palette); + mFM_SetFieldPal(&field_info->field_palette); + mFM_SetFgDepositP(field_info->block_info, field_info->field_id, field_info->block_x_max, field_info->block_z_max, + island_x_blocks); + + return field_info; } static mBGTex_obj_c l_bg_tex_common_dummy[27] = { - { earth_tex_dummy, 0x800 }, - { cliff_tex_dummy, 0x800 }, - { bush_a_tex_dummy, 0x800 }, - { bush_b_tex_dummy, 0x400 }, - { grass_tex_dummy, 0x200 }, - { rail_tex_dummy, 0x800 }, - { station_tex_dummy, 0x800 }, - { stone_tex_dummy, 0x800 }, - { river_tex_dummy, 0x400 }, - { water_1_tex_dummy, 0x200 }, - { water_2_tex_dummy, 0x200 }, - { bridge_1_tex_dummy, 0x800 }, - { bridge_2_tex_dummy, 0x800 }, - { tekkyo_tex_dummy, 0x800 }, - { tunnel_tex_dummy, 0x800 }, - { beach_tex_dummy, 0x800 }, - { bridge_1_pal_dummy, 0x20 }, - { bridge_2_pal_dummy, 0x20 }, - { station_pal_dummy, 0x20 }, - { beach1_tex_dummy2, 0x400 }, - { beach2_tex_dummy2, 0x100 }, - { sand_tex_dummy, 0x400 }, - { wave1_tex_dummy, 0x400 }, - { wave2_tex_dummy, 0x800 }, - { wave3_tex_dummy, 0x400 }, - { sprashA_tex_dummy, 0x200 }, - { sprashC_tex_dummy, 0x200 }, + { earth_tex_dummy, 0x800 }, { cliff_tex_dummy, 0x800 }, { bush_a_tex_dummy, 0x800 }, + { bush_b_tex_dummy, 0x400 }, { grass_tex_dummy, 0x200 }, { rail_tex_dummy, 0x800 }, + { station_tex_dummy, 0x800 }, { stone_tex_dummy, 0x800 }, { river_tex_dummy, 0x400 }, + { water_1_tex_dummy, 0x200 }, { water_2_tex_dummy, 0x200 }, { bridge_1_tex_dummy, 0x800 }, + { bridge_2_tex_dummy, 0x800 }, { tekkyo_tex_dummy, 0x800 }, { tunnel_tex_dummy, 0x800 }, + { beach_tex_dummy, 0x800 }, { bridge_1_pal_dummy, 0x20 }, { bridge_2_pal_dummy, 0x20 }, + { station_pal_dummy, 0x20 }, { beach1_tex_dummy2, 0x400 }, { beach2_tex_dummy2, 0x100 }, + { sand_tex_dummy, 0x400 }, { wave1_tex_dummy, 0x400 }, { wave2_tex_dummy, 0x800 }, + { wave3_tex_dummy, 0x400 }, { sprashA_tex_dummy, 0x200 }, { sprashC_tex_dummy, 0x200 }, }; -static mBGTex_obj_c l_bg_pal_common_dummy[5] = { - { earth_pal_dummy, 16 * sizeof(u16) }, - { cliff_pal_dummy, 16 * sizeof(u16) }, - { bush_pal_dummy, 16 * sizeof(u16) }, - { rail_pal_dummy, 16 * sizeof(u16) }, - { beach_pal_dummy2, 16 * sizeof(u16) } -}; +static mBGTex_obj_c l_bg_pal_common_dummy[5] = { { earth_pal_dummy, 16 * sizeof(u16) }, + { cliff_pal_dummy, 16 * sizeof(u16) }, + { bush_pal_dummy, 16 * sizeof(u16) }, + { rail_pal_dummy, 16 * sizeof(u16) }, + { beach_pal_dummy2, 16 * sizeof(u16) } }; extern u8 mFM_grd_s_earth_tex[]; extern u8 mFM_grd_s_cliff_tex[]; @@ -943,33 +906,12 @@ extern u8 mFM_grd_sprashA_tex[]; extern u8 mFM_grd_sprashC_tex[]; static void* l_bg_tex_segment_rom_start_s_0[mFM_FIELD_TEX_NUM] = { - mFM_grd_s_earth_tex, - mFM_grd_s_cliff_tex, - mFM_grd_s_bushA_tex, - mFM_grd_s_bushB_tex, - mFM_grd_s_grass_tex, - mFM_grd_s_rail_tex, - mFM_grd_s_station_tex, - mFM_grd_s_stone_tex, - mFM_grd_s_river_tex, - mFM_grd_water1_tex, - mFM_grd_water2_tex, - mFM_grd_s_bridge1_tex, - mFM_grd_s_bridge2_tex, - mFM_grd_s_tekkyo_tex, - mFM_grd_s_tunnel_tex, - mFM_grd_s_beach_tex, - mFM_grd_s_bridge1_pal, - mFM_grd_s_bridge2_pal, - mFM_grd_s_station1_pal, - mFM_grd_beachA_tex, - mFM_grd_beachB_tex, - mFM_grd_s_sand_tex, - mFM_grd_wave1_tex, - mFM_grd_wave2_tex, - mFM_grd_wave3_tex, - mFM_grd_sprashA_tex, - mFM_grd_sprashC_tex + mFM_grd_s_earth_tex, mFM_grd_s_cliff_tex, mFM_grd_s_bushA_tex, mFM_grd_s_bushB_tex, mFM_grd_s_grass_tex, + mFM_grd_s_rail_tex, mFM_grd_s_station_tex, mFM_grd_s_stone_tex, mFM_grd_s_river_tex, mFM_grd_water1_tex, + mFM_grd_water2_tex, mFM_grd_s_bridge1_tex, mFM_grd_s_bridge2_tex, mFM_grd_s_tekkyo_tex, mFM_grd_s_tunnel_tex, + mFM_grd_s_beach_tex, mFM_grd_s_bridge1_pal, mFM_grd_s_bridge2_pal, mFM_grd_s_station1_pal, mFM_grd_beachA_tex, + mFM_grd_beachB_tex, mFM_grd_s_sand_tex, mFM_grd_wave1_tex, mFM_grd_wave2_tex, mFM_grd_wave3_tex, + mFM_grd_sprashA_tex, mFM_grd_sprashC_tex }; extern u8 mFM_grd_s_earth_2_tex[]; @@ -988,33 +930,13 @@ extern u8 mFM_grd_s_tunnel_2_tex[]; extern u8 mFM_grd_s_sand_2_tex[]; static void* l_bg_tex_segment_rom_start_s_1[mFM_FIELD_TEX_NUM] = { - mFM_grd_s_earth_2_tex, - mFM_grd_s_cliff_2_tex, - mFM_grd_s_bushA_2_tex, - mFM_grd_s_bushB_2_tex, - mFM_grd_s_grass_2_tex, - mFM_grd_s_rail_2_tex, - mFM_grd_s_station_2_tex, - mFM_grd_s_stone_2_tex, - mFM_grd_s_river_2_tex, - mFM_grd_water1_tex, - mFM_grd_water2_tex, - mFM_grd_s_bridge1_2_tex, - mFM_grd_s_bridge2_2_tex, - mFM_grd_s_tekkyo_2_tex, - mFM_grd_s_tunnel_2_tex, - mFM_grd_s_beach_tex, - mFM_grd_s_bridge1_pal, - mFM_grd_s_bridge2_pal, - mFM_grd_s_station1_pal, - mFM_grd_beachA_tex, - mFM_grd_beachB_tex, - mFM_grd_s_sand_2_tex, - mFM_grd_wave1_tex, - mFM_grd_wave2_tex, - mFM_grd_wave3_tex, - mFM_grd_sprashA_tex, - mFM_grd_sprashC_tex + mFM_grd_s_earth_2_tex, mFM_grd_s_cliff_2_tex, mFM_grd_s_bushA_2_tex, mFM_grd_s_bushB_2_tex, + mFM_grd_s_grass_2_tex, mFM_grd_s_rail_2_tex, mFM_grd_s_station_2_tex, mFM_grd_s_stone_2_tex, + mFM_grd_s_river_2_tex, mFM_grd_water1_tex, mFM_grd_water2_tex, mFM_grd_s_bridge1_2_tex, + mFM_grd_s_bridge2_2_tex, mFM_grd_s_tekkyo_2_tex, mFM_grd_s_tunnel_2_tex, mFM_grd_s_beach_tex, + mFM_grd_s_bridge1_pal, mFM_grd_s_bridge2_pal, mFM_grd_s_station1_pal, mFM_grd_beachA_tex, + mFM_grd_beachB_tex, mFM_grd_s_sand_2_tex, mFM_grd_wave1_tex, mFM_grd_wave2_tex, + mFM_grd_wave3_tex, mFM_grd_sprashA_tex, mFM_grd_sprashC_tex }; extern u8 mFM_grd_s_earth_3_tex[]; @@ -1033,40 +955,17 @@ extern u8 mFM_grd_s_tunnel_3_tex[]; extern u8 mFM_grd_s_sand_3_tex[]; static void* l_bg_tex_segment_rom_start_s_2[mFM_FIELD_TEX_NUM] = { - mFM_grd_s_earth_3_tex, - mFM_grd_s_cliff_3_tex, - mFM_grd_s_bushA_3_tex, - mFM_grd_s_bushB_3_tex, - mFM_grd_s_grass_3_tex, - mFM_grd_s_rail_3_tex, - mFM_grd_s_station_3_tex, - mFM_grd_s_stone_3_tex, - mFM_grd_s_river_3_tex, - mFM_grd_water1_tex, - mFM_grd_water2_tex, - mFM_grd_s_bridge1_3_tex, - mFM_grd_s_bridge2_3_tex, - mFM_grd_s_tekkyo_3_tex, - mFM_grd_s_tunnel_3_tex, - mFM_grd_s_beach_tex, - mFM_grd_s_bridge1_pal, - mFM_grd_s_bridge2_pal, - mFM_grd_s_station1_pal, - mFM_grd_beachA_tex, - mFM_grd_beachB_tex, - mFM_grd_s_sand_3_tex, - mFM_grd_wave1_tex, - mFM_grd_wave2_tex, - mFM_grd_wave3_tex, - mFM_grd_sprashA_tex, - mFM_grd_sprashC_tex + mFM_grd_s_earth_3_tex, mFM_grd_s_cliff_3_tex, mFM_grd_s_bushA_3_tex, mFM_grd_s_bushB_3_tex, + mFM_grd_s_grass_3_tex, mFM_grd_s_rail_3_tex, mFM_grd_s_station_3_tex, mFM_grd_s_stone_3_tex, + mFM_grd_s_river_3_tex, mFM_grd_water1_tex, mFM_grd_water2_tex, mFM_grd_s_bridge1_3_tex, + mFM_grd_s_bridge2_3_tex, mFM_grd_s_tekkyo_3_tex, mFM_grd_s_tunnel_3_tex, mFM_grd_s_beach_tex, + mFM_grd_s_bridge1_pal, mFM_grd_s_bridge2_pal, mFM_grd_s_station1_pal, mFM_grd_beachA_tex, + mFM_grd_beachB_tex, mFM_grd_s_sand_3_tex, mFM_grd_wave1_tex, mFM_grd_wave2_tex, + mFM_grd_wave3_tex, mFM_grd_sprashA_tex, mFM_grd_sprashC_tex }; -static void** l_bg_tex_segment_table[mFM_BG_TEX_NUM] = { - l_bg_tex_segment_rom_start_s_0, - l_bg_tex_segment_rom_start_s_1, - l_bg_tex_segment_rom_start_s_2 -}; +static void** l_bg_tex_segment_table[mFM_BG_TEX_NUM] = { l_bg_tex_segment_rom_start_s_0, l_bg_tex_segment_rom_start_s_1, + l_bg_tex_segment_rom_start_s_2 }; extern u8 mFM_grd_w_earth_tex[]; extern u8 mFM_grd_w_cliff_tex[]; @@ -1083,33 +982,12 @@ extern u8 mFM_grd_w_tekkyo_tex[]; extern u8 mFM_grd_w_sand_tex[]; static void* l_bg_tex_segment_rom_start_w_0[mFM_FIELD_TEX_NUM] = { - mFM_grd_w_earth_tex, - mFM_grd_w_cliff_tex, - mFM_grd_w_bushA_tex, - mFM_grd_w_bushB_tex, - mFM_grd_w_grass_tex, - mFM_grd_w_rail_tex, - mFM_grd_w_station_tex, - mFM_grd_w_stone_tex, - mFM_grd_w_river_tex, - mFM_grd_water1_tex, - mFM_grd_water2_tex, - mFM_grd_w_bridge1_tex, - mFM_grd_w_bridge2_tex, - mFM_grd_w_tekkyo_tex, - mFM_grd_s_tunnel_tex, - mFM_grd_s_beach_tex, - mFM_grd_s_bridge1_pal, - mFM_grd_s_bridge2_pal, - mFM_grd_s_station1_pal, - mFM_grd_beachA_tex, - mFM_grd_beachB_tex, - mFM_grd_w_sand_tex, - mFM_grd_wave1_tex, - mFM_grd_wave2_tex, - mFM_grd_wave3_tex, - mFM_grd_sprashA_tex, - mFM_grd_sprashC_tex + mFM_grd_w_earth_tex, mFM_grd_w_cliff_tex, mFM_grd_w_bushA_tex, mFM_grd_w_bushB_tex, mFM_grd_w_grass_tex, + mFM_grd_w_rail_tex, mFM_grd_w_station_tex, mFM_grd_w_stone_tex, mFM_grd_w_river_tex, mFM_grd_water1_tex, + mFM_grd_water2_tex, mFM_grd_w_bridge1_tex, mFM_grd_w_bridge2_tex, mFM_grd_w_tekkyo_tex, mFM_grd_s_tunnel_tex, + mFM_grd_s_beach_tex, mFM_grd_s_bridge1_pal, mFM_grd_s_bridge2_pal, mFM_grd_s_station1_pal, mFM_grd_beachA_tex, + mFM_grd_beachB_tex, mFM_grd_w_sand_tex, mFM_grd_wave1_tex, mFM_grd_wave2_tex, mFM_grd_wave3_tex, + mFM_grd_sprashA_tex, mFM_grd_sprashC_tex }; extern u8 mFM_grd_w_earth_2_tex[]; @@ -1128,33 +1006,13 @@ extern u8 mFM_grd_w_tunnel_2_tex[]; extern u8 mFM_grd_w_sand_2_tex[]; static void* l_bg_tex_segment_rom_start_w_1[mFM_FIELD_TEX_NUM] = { - mFM_grd_w_earth_2_tex, - mFM_grd_w_cliff_2_tex, - mFM_grd_w_bushA_2_tex, - mFM_grd_w_bushB_2_tex, - mFM_grd_w_grass_2_tex, - mFM_grd_w_rail_2_tex, - mFM_grd_w_station_2_tex, - mFM_grd_w_stone_2_tex, - mFM_grd_w_river_2_tex, - mFM_grd_water1_tex, - mFM_grd_water2_tex, - mFM_grd_w_bridge1_2_tex, - mFM_grd_w_bridge2_2_tex, - mFM_grd_w_tekkyo_2_tex, - mFM_grd_w_tunnel_2_tex, - mFM_grd_s_beach_tex, - mFM_grd_s_bridge1_pal, - mFM_grd_s_bridge2_pal, - mFM_grd_s_station1_pal, - mFM_grd_beachA_tex, - mFM_grd_beachB_tex, - mFM_grd_w_sand_2_tex, - mFM_grd_wave1_tex, - mFM_grd_wave2_tex, - mFM_grd_wave3_tex, - mFM_grd_sprashA_tex, - mFM_grd_sprashC_tex + mFM_grd_w_earth_2_tex, mFM_grd_w_cliff_2_tex, mFM_grd_w_bushA_2_tex, mFM_grd_w_bushB_2_tex, + mFM_grd_w_grass_2_tex, mFM_grd_w_rail_2_tex, mFM_grd_w_station_2_tex, mFM_grd_w_stone_2_tex, + mFM_grd_w_river_2_tex, mFM_grd_water1_tex, mFM_grd_water2_tex, mFM_grd_w_bridge1_2_tex, + mFM_grd_w_bridge2_2_tex, mFM_grd_w_tekkyo_2_tex, mFM_grd_w_tunnel_2_tex, mFM_grd_s_beach_tex, + mFM_grd_s_bridge1_pal, mFM_grd_s_bridge2_pal, mFM_grd_s_station1_pal, mFM_grd_beachA_tex, + mFM_grd_beachB_tex, mFM_grd_w_sand_2_tex, mFM_grd_wave1_tex, mFM_grd_wave2_tex, + mFM_grd_wave3_tex, mFM_grd_sprashA_tex, mFM_grd_sprashC_tex }; extern u8 mFM_grd_w_earth_3_tex[]; @@ -1173,808 +1031,823 @@ extern u8 mFM_grd_w_tunnel_3_tex[]; extern u8 mFM_grd_w_sand_3_tex[]; static void* l_bg_tex_segment_rom_start_w_2[mFM_FIELD_TEX_NUM] = { - mFM_grd_w_earth_3_tex, - mFM_grd_w_cliff_3_tex, - mFM_grd_w_bushA_3_tex, - mFM_grd_w_bushB_3_tex, - mFM_grd_w_grass_3_tex, - mFM_grd_w_rail_3_tex, - mFM_grd_w_station_3_tex, - mFM_grd_w_stone_3_tex, - mFM_grd_w_river_3_tex, - mFM_grd_water1_tex, - mFM_grd_water2_tex, - mFM_grd_w_bridge1_3_tex, - mFM_grd_w_bridge2_3_tex, - mFM_grd_w_tekkyo_3_tex, - mFM_grd_w_tunnel_3_tex, - mFM_grd_s_beach_tex, - mFM_grd_s_bridge1_pal, - mFM_grd_s_bridge2_pal, - mFM_grd_s_station1_pal, - mFM_grd_beachA_tex, - mFM_grd_beachB_tex, - mFM_grd_w_sand_3_tex, - mFM_grd_wave1_tex, - mFM_grd_wave2_tex, - mFM_grd_wave3_tex, - mFM_grd_sprashA_tex, - mFM_grd_sprashC_tex + mFM_grd_w_earth_3_tex, mFM_grd_w_cliff_3_tex, mFM_grd_w_bushA_3_tex, mFM_grd_w_bushB_3_tex, + mFM_grd_w_grass_3_tex, mFM_grd_w_rail_3_tex, mFM_grd_w_station_3_tex, mFM_grd_w_stone_3_tex, + mFM_grd_w_river_3_tex, mFM_grd_water1_tex, mFM_grd_water2_tex, mFM_grd_w_bridge1_3_tex, + mFM_grd_w_bridge2_3_tex, mFM_grd_w_tekkyo_3_tex, mFM_grd_w_tunnel_3_tex, mFM_grd_s_beach_tex, + mFM_grd_s_bridge1_pal, mFM_grd_s_bridge2_pal, mFM_grd_s_station1_pal, mFM_grd_beachA_tex, + mFM_grd_beachB_tex, mFM_grd_w_sand_3_tex, mFM_grd_wave1_tex, mFM_grd_wave2_tex, + mFM_grd_wave3_tex, mFM_grd_sprashA_tex, mFM_grd_sprashC_tex }; -static void** l_bg_w_tex_segment_table[mFM_BG_TEX_NUM] = { - l_bg_tex_segment_rom_start_w_0, - l_bg_tex_segment_rom_start_w_1, - l_bg_tex_segment_rom_start_w_2 -}; +static void** l_bg_w_tex_segment_table[mFM_BG_TEX_NUM] = { l_bg_tex_segment_rom_start_w_0, + l_bg_tex_segment_rom_start_w_1, + l_bg_tex_segment_rom_start_w_2 }; -static u8* l_bg_pal_segment_rom_start[5] = { - (u8*)mFM_earth_pal, - (u8*)mFM_cliff_pal, - (u8*)mFM_bush_pal, - (u8*)mFM_rail_pal, - (u8*)mFM_beach_pal -}; +static u8* l_bg_pal_segment_rom_start[5] = { (u8*)mFM_earth_pal, (u8*)mFM_cliff_pal, (u8*)mFM_bush_pal, + (u8*)mFM_rail_pal, (u8*)mFM_beach_pal }; -static u8 l_water_permission[mFM_FIELD_TEX_NUM] = { - TRUE, TRUE, TRUE, TRUE, - TRUE, TRUE, TRUE, TRUE, - FALSE, FALSE, FALSE, TRUE, - TRUE, TRUE, TRUE, TRUE, - TRUE, TRUE, TRUE, TRUE, - TRUE, TRUE, FALSE, FALSE, - FALSE, TRUE, TRUE -}; +static u8 l_water_permission[mFM_FIELD_TEX_NUM] = { TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, + FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, + TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, TRUE }; static void mFM_LoadBGCommonMonthlyPal() { - static int field_pal_idx_table[mTM_TERM_NUM] = { - 9, 10, 11, 0, - 1, 1, 1, 2, - 2, 3, 4, 5, - 6, 7, 8, 9, - 9, 9 - }; + static int field_pal_idx_table[mTM_TERM_NUM] = { 9, 10, 11, 0, 1, 1, 1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 9, 9 }; - u32 term = Common_Get(time.term_idx); - int idx; - int i; + u32 term = Common_Get(time.term_idx); + int idx; + int i; - if (term >= mTM_TERM_NUM) { - term = mTM_TERM_0; - } + if (term >= mTM_TERM_NUM) { + term = mTM_TERM_0; + } - if (Save_Get(scene_no) == SCENE_MUSEUM_ROOM_INSECT) { - term = mTM_TERM_4; - } + if (Save_Get(scene_no) == SCENE_MUSEUM_ROOM_INSECT) { + term = mTM_TERM_4; + } - idx = field_pal_idx_table[term]; + idx = field_pal_idx_table[term]; - for (i = 0; i < 5; i++) { - bcopy(l_bg_pal_segment_rom_start[i] + ((l_bg_pal_common_dummy[i].size * idx) & ~1), l_bg_pal_common_dummy[i].data, l_bg_pal_common_dummy[i].size); - } + for (i = 0; i < 5; i++) { + bcopy(l_bg_pal_segment_rom_start[i] + ((l_bg_pal_common_dummy[i].size * idx) & ~1), + l_bg_pal_common_dummy[i].data, l_bg_pal_common_dummy[i].size); + } } extern void mFM_DecideBgTexIdx(u8* bg_tex_idx) { - *bg_tex_idx = RANDOM(mFM_BG_TEX_NUM); + *bg_tex_idx = RANDOM(mFM_BG_TEX_NUM); } static void mFM_LoadBGCommonTex(int update_tex, u8 tex_idx) { - void** bg_tex_tbl; - u32 season = Common_Get(time.season); - int i; + void** bg_tex_tbl; + u32 season = Common_Get(time.season); + int i; - if (season >= mTM_SEASON_NUM) { - season = mTM_SEASON_SPRING; - } - - if (Save_Get(scene_no) == SCENE_TITLE_DEMO) { - mFM_DecideBgTexIdx(&tex_idx); - } - - if (tex_idx >= mFM_BG_TEX_NUM) { - tex_idx = mFM_BG_TEX_TRIANGLE; - } - - if (Save_Get(scene_no) == SCENE_MUSEUM_ROOM_INSECT) { - bg_tex_tbl = l_bg_tex_segment_table[tex_idx]; - } - else if (season == mTM_SEASON_WINTER) { - bg_tex_tbl = l_bg_w_tex_segment_table[tex_idx]; - } - else { - bg_tex_tbl = l_bg_tex_segment_table[tex_idx]; - } - - for (i = 0; i < mFM_FIELD_TEX_NUM; i++) { - if (update_tex == TRUE || l_water_permission[i] == TRUE) { - bcopy(bg_tex_tbl[i], l_bg_tex_common_dummy[i].data, l_bg_tex_common_dummy[i].size); + if (season >= mTM_SEASON_NUM) { + season = mTM_SEASON_SPRING; } - } - mFM_LoadBGCommonMonthlyPal(); + if (Save_Get(scene_no) == SCENE_TITLE_DEMO) { + mFM_DecideBgTexIdx(&tex_idx); + } + + if (tex_idx >= mFM_BG_TEX_NUM) { + tex_idx = mFM_BG_TEX_TRIANGLE; + } + + if (Save_Get(scene_no) == SCENE_MUSEUM_ROOM_INSECT) { + bg_tex_tbl = l_bg_tex_segment_table[tex_idx]; + } else if (season == mTM_SEASON_WINTER) { + bg_tex_tbl = l_bg_w_tex_segment_table[tex_idx]; + } else { + bg_tex_tbl = l_bg_tex_segment_table[tex_idx]; + } + + for (i = 0; i < mFM_FIELD_TEX_NUM; i++) { + if (update_tex == TRUE || l_water_permission[i] == TRUE) { + bcopy(bg_tex_tbl[i], l_bg_tex_common_dummy[i].data, l_bg_tex_common_dummy[i].size); + } + } + + mFM_LoadBGCommonMonthlyPal(); } static void set_field_type() { - int field_id = mFI_GetFieldId(); - int house_owner_id; - u8 field_type; + int field_id = mFI_GetFieldId(); + int house_owner_id; + u8 field_type; - if (mLd_PlayerManKindCheck() == FALSE) { - house_owner_id = mFI_FIELD_PLAYER0_ROOM + mHS_get_arrange_idx(Common_Get(player_no)); - } - else { - house_owner_id = RSV_NO; - } + if (mLd_PlayerManKindCheck() == FALSE) { + house_owner_id = mFI_FIELD_PLAYER0_ROOM + mHS_get_arrange_idx(Common_Get(player_no)); + } else { + house_owner_id = RSV_NO; + } - if (field_id == mFI_FIELD_FG) { - field_type = mFI_FIELDTYPE2_FG; - } - else if ((field_id == house_owner_id && mEv_CheckFirstIntro() == FALSE) || Save_Get(scene_no) == SCENE_COTTAGE_MY) { - field_type = mFI_FIELDTYPE2_PLAYER_ROOM; - } - else if (field_id == mFI_FIELD_NPCROOM0) { - field_type = mFI_FIELDTYPE2_NPC_ROOM; - } - else { - field_type = mFI_FIELDTYPE2_ROOM; - } + if (field_id == mFI_FIELD_FG) { + field_type = mFI_FIELDTYPE2_FG; + } else if ((field_id == house_owner_id && mEv_CheckFirstIntro() == FALSE) || + Save_Get(scene_no) == SCENE_COTTAGE_MY) { + field_type = mFI_FIELDTYPE2_PLAYER_ROOM; + } else if (field_id == mFI_FIELD_NPCROOM0) { + field_type = mFI_FIELDTYPE2_NPC_ROOM; + } else { + field_type = mFI_FIELDTYPE2_ROOM; + } - Common_Set(field_type, field_type); + Common_Set(field_type, field_type); } static void mFM_PoorTreeBlock(mFM_block_info_c* block, int ut) { - mCoBG_Collision_u* col = (mCoBG_Collision_u*)block->bg_info.collision; - int i; + mCoBG_Collision_u* col = (mCoBG_Collision_u*)block->bg_info.collision; + int i; - for (i = ut; i < UT_TOTAL_NUM; i += UT_X_NUM) { - mCoBG_Change2PoorAttr(col + i); - } + for (i = ut; i < UT_TOTAL_NUM; i += UT_X_NUM) { + mCoBG_Change2PoorAttr(col + i); + } } static void mFM_PoorTree() { - mFM_fdinfo_c* field_info = g_fdinfo; - mFM_block_info_c* first_block = field_info->block_info; - mFM_block_info_c* last_block = field_info->block_info; - int block_total; - u8 bx_max; - int i; + mFM_block_info_c* block = g_fdinfo->block_info; + int bx_max; + int bz_max; + int block_total; + int i; - bx_max = field_info->block_x_max; - block_total = field_info->block_x_max * (field_info->block_z_max - 3); + bx_max = g_fdinfo->block_x_max; + bz_max = g_fdinfo->block_z_max - 3; + block_total = bx_max * bz_max; - if (mFI_GET_TYPE(field_info->field_id) == mFI_FIELD_FG && Save_Get(scene_no) == SCENE_FG) { - for (i = field_info->block_x_max; i < block_total; i += bx_max) { - mFM_PoorTreeBlock(first_block + (i + 1), 0); - mFM_PoorTreeBlock(last_block + (i + (bx_max - 2)), UT_X_NUM - 1); + if (mFI_GET_TYPE(g_fdinfo->field_id) == mFI_FIELD_FG && Save_Get(scene_no) == SCENE_FG) { + for (i = bx_max; i < block_total; i += bx_max) { + mFM_PoorTreeBlock(&block[i + 1], 0); + mFM_PoorTreeBlock(&block[i + bx_max - 2], UT_X_NUM - 1); + } } - } } static void mFM_PoorTreeUnderPlayerBlock() { - mFM_fdinfo_c* field_info = g_fdinfo; - mFM_block_info_c* block_info = field_info->block_info; - int bx_max = field_info->block_x_max; + mFM_fdinfo_c* field_info = g_fdinfo; + mFM_block_info_c* block_info = field_info->block_info; + int bx_max = field_info->block_x_max; - if (field_info != NULL && mFI_GET_TYPE(field_info->field_id) == mFI_FIELD_FG && Save_Get(scene_no) == SCENE_FG) { - mCoBG_Collision_u* col = &block_info[bx_max * 3 + 3].bg_info.collision[0][0]; + if (field_info != NULL && mFI_GET_TYPE(field_info->field_id) == mFI_FIELD_FG && Save_Get(scene_no) == SCENE_FG) { + mCoBG_Collision_u* col = &block_info[bx_max * 3 + 3].bg_info.collision[0][0]; - if (col != NULL) { - mCoBG_Change2PoorAttr(col + 7); - mCoBG_Change2PoorAttr(col + 8); - mCoBG_Change2PoorAttr(col + (UT_X_NUM + 7)); - mCoBG_Change2PoorAttr(col + (UT_X_NUM + 8)); + if (col != NULL) { + mCoBG_Change2PoorAttr(col + 7); + mCoBG_Change2PoorAttr(col + 8); + mCoBG_Change2PoorAttr(col + (UT_X_NUM + 7)); + mCoBG_Change2PoorAttr(col + (UT_X_NUM + 8)); + } } - } } static void mFM_SetFruit_title_demo(int scene) { - if (scene == SCENE_FIELD_TOOL || scene == SCENE_TITLE_DEMO) { - mFI_BlockUtNumtoFGSet(TREE_APPLE_FRUIT, 5, 5, 14, 8); - } + if (scene == SCENE_FIELD_TOOL || scene == SCENE_TITLE_DEMO) { + mFI_BlockUtNumtoFGSet(TREE_APPLE_FRUIT, 5, 5, 14, 8); + } } extern void mFM_SetFieldInitData(int bg_disp_num, int bg_disp_size) { - l_bg_disp_num = bg_disp_num; - l_bg_disp_size = bg_disp_size; + l_bg_disp_num = bg_disp_num; + l_bg_disp_size = bg_disp_size; } extern void mFM_FieldInit(GAME_PLAY* play) { - int bg_disp_num = l_bg_disp_num; - int bg_disp_size = l_bg_disp_size; - int scene = Save_Get(scene_no); + int bg_disp_num = l_bg_disp_num; + int bg_disp_size = l_bg_disp_size; + int scene = Save_Get(scene_no); - mFM_LoadBGCommonTex(TRUE, Save_Get(bg_tex_idx)); - if (bg_disp_num > mFM_VISIBLE_BLOCK_NUM) { - bg_disp_num = mFM_VISIBLE_BLOCK_NUM; - } + mFM_LoadBGCommonTex(TRUE, Save_Get(bg_tex_idx)); + if (bg_disp_num > mFM_VISIBLE_BLOCK_NUM) { + bg_disp_num = mFM_VISIBLE_BLOCK_NUM; + } - g_fdinfo = mFM_MakeField(scene, bg_disp_size, bg_disp_num); - mFI_InitMoveActorBitData(); - mFI_ClearColKeep(); - mFI_InitAreaInfo(); - mFI_InitRegisterBgInfo(); - set_field_type(); - mFM_PoorTree(); + g_fdinfo = mFM_MakeField(scene, bg_disp_size, bg_disp_num); + mFI_InitMoveActorBitData(); + mFI_ClearColKeep(); + mFI_InitAreaInfo(); + mFI_InitRegisterBgInfo(); + set_field_type(); + mFM_PoorTree(); - if (Common_Get(field_type) == mFI_FIELDTYPE2_FG) { - mRF_CheckBeastRoad(); - } + if (Common_Get(field_type) == mFI_FIELDTYPE2_FG) { + mRF_CheckBeastRoad(); + } - mFM_PoorTreeUnderPlayerBlock(); - mAGrw_ChangeCedar2Tree(); - mAGrw_RenewalFgItem(Common_GetPointer(time.rtc_time)); - mAGrw_SetXmasTree(); - mFM_SetFruit_title_demo(Save_Get(scene_no)); + mFM_PoorTreeUnderPlayerBlock(); + mAGrw_ChangeCedar2Tree(); + mAGrw_RenewalFgItem(Common_GetPointer(time.rtc_time)); + mAGrw_SetXmasTree(); + mFM_SetFruit_title_demo(Save_Get(scene_no)); - if (scene == SCENE_FG) { - mNpc_SetNpcHomeYpos(); - } + if (scene == SCENE_FG) { + mNpc_SetNpcHomeYpos(); + } - mNpc_SendRegisteredGoodbyMail(); - Common_Set(floor_idx, mRmTp_GetFloorIdx()); - Common_Set(make_npc2_actor, FALSE); + mNpc_SendRegisteredGoodbyMail(); + Common_Set(floor_idx, mRmTp_GetFloorIdx()); + Common_Set(make_npc2_actor, FALSE); - if (play->fb_wipe_type == WIPE_TYPE_EVENT) { - if (scene == SCENE_MUSEUM_ENTRANCE) { - mBGMPsComp_museum_status(1); + if (play->fb_wipe_type == WIPE_TYPE_EVENT) { + if (scene == SCENE_MUSEUM_ENTRANCE) { + mBGMPsComp_museum_status(1); + } else if (scene == SCENE_MUSEUM_ROOM_PAINTING) { + mBGMPsComp_museum_status(2); + } else if (scene == SCENE_MUSEUM_ROOM_FISH) { + mBGMPsComp_museum_status(3); + } else if (scene == SCENE_MUSEUM_ROOM_INSECT) { + mBGMPsComp_museum_status(4); + } else if (scene == SCENE_MUSEUM_ROOM_FOSSIL) { + mBGMPsComp_museum_status(5); + } + } else if (mFI_GET_TYPE(g_fdinfo->field_id) == mFI_FIELD_PLAYER0_ROOM || + mFI_GET_TYPE(g_fdinfo->field_id) == mFI_FIELD_ROOM0 || + mFI_GET_TYPE(g_fdinfo->field_id) == mFI_FIELD_NPCROOM0) { + if (scene == SCENE_MUSEUM_ENTRANCE) { + mBGMPsComp_scene_mode(15); + mBGMPsComp_museum_status(1); + } else if (scene == SCENE_MUSEUM_ROOM_PAINTING) { + mBGMPsComp_scene_mode(15); + mBGMPsComp_museum_status(2); + } else if (scene == SCENE_MUSEUM_ROOM_FISH) { + mBGMPsComp_scene_mode(15); + mBGMPsComp_museum_status(3); + } else if (scene == SCENE_MUSEUM_ROOM_INSECT) { + mBGMPsComp_scene_mode(15); + mBGMPsComp_museum_status(4); + } else if (scene == SCENE_MUSEUM_ROOM_FOSSIL) { + mBGMPsComp_scene_mode(15); + mBGMPsComp_museum_status(5); + } else if (scene == SCENE_LIGHTHOUSE) { + mBGMPsComp_scene_mode(16); + } else { + if (mEv_CheckFirstIntro() == TRUE) { + mBGMPsComp_scene_mode(10); + } else { + mBGMPsComp_scene_mode(2); + } + } + } else if (mFI_GET_TYPE(g_fdinfo->field_id) == mFI_FIELD_FG) { + if (scene != SCENE_TITLE_DEMO) { + if (mEv_CheckFirstIntro() == TRUE) { + mBGMPsComp_scene_mode(9); + } else if (mEv_CheckGateway() == TRUE) { + mBGMPsComp_scene_mode(8); + } else { + mBGMPsComp_scene_mode(1); + } + } + } else if (scene == SCENE_PLAYERSELECT || scene == SCENE_PLAYERSELECT_2 || scene == SCENE_PLAYERSELECT_3 || + scene == SCENE_PLAYERSELECT_SAVE) { + mBGMPsComp_scene_mode(3); + } else if (scene == SCENE_START_DEMO || scene == SCENE_START_DEMO2 || scene == SCENE_START_DEMO3) { + mBGMPsComp_scene_mode(4); + } else { + mBGMPsComp_scene_mode(0); } - else if (scene == SCENE_MUSEUM_ROOM_PAINTING) { - mBGMPsComp_museum_status(2); - } - else if (scene == SCENE_MUSEUM_ROOM_FISH) { - mBGMPsComp_museum_status(3); - } - else if (scene == SCENE_MUSEUM_ROOM_INSECT) { - mBGMPsComp_museum_status(4); - } - else if (scene == SCENE_MUSEUM_ROOM_FOSSIL) { - mBGMPsComp_museum_status(5); - } - } - else if ( - mFI_GET_TYPE(g_fdinfo->field_id) == mFI_FIELD_PLAYER0_ROOM || - mFI_GET_TYPE(g_fdinfo->field_id) == mFI_FIELD_ROOM0 || - mFI_GET_TYPE(g_fdinfo->field_id) == mFI_FIELD_NPCROOM0 - ) { - if (scene == SCENE_MUSEUM_ENTRANCE) { - mBGMPsComp_scene_mode(15); - mBGMPsComp_museum_status(1); - } - else if (scene == SCENE_MUSEUM_ROOM_PAINTING) { - mBGMPsComp_scene_mode(15); - mBGMPsComp_museum_status(2); - } - else if (scene == SCENE_MUSEUM_ROOM_FISH) { - mBGMPsComp_scene_mode(15); - mBGMPsComp_museum_status(3); - } - else if (scene == SCENE_MUSEUM_ROOM_INSECT) { - mBGMPsComp_scene_mode(15); - mBGMPsComp_museum_status(4); - } - else if (scene == SCENE_MUSEUM_ROOM_FOSSIL) { - mBGMPsComp_scene_mode(15); - mBGMPsComp_museum_status(5); - } - else if (scene == SCENE_LIGHTHOUSE) { - mBGMPsComp_scene_mode(16); - } - else { - if (mEv_CheckFirstIntro() == TRUE) { - mBGMPsComp_scene_mode(10); - } - else { - mBGMPsComp_scene_mode(2); - } - } - } - else if (mFI_GET_TYPE(g_fdinfo->field_id) == mFI_FIELD_FG) { - if (scene != SCENE_TITLE_DEMO) { - if (mEv_CheckFirstIntro() == TRUE) { - mBGMPsComp_scene_mode(9); - } - else if (mEv_CheckGateway() == TRUE) { - mBGMPsComp_scene_mode(8); - } - else { - mBGMPsComp_scene_mode(1); - } - } - } - else if (scene == SCENE_PLAYERSELECT || scene == SCENE_PLAYERSELECT_2 || scene == SCENE_PLAYERSELECT_3 || scene == SCENE_PLAYERSELECT_SAVE) { - mBGMPsComp_scene_mode(3); - } - else if (scene == SCENE_START_DEMO || scene == SCENE_START_DEMO2 || scene == SCENE_START_DEMO3) { - mBGMPsComp_scene_mode(4); - } - else { - mBGMPsComp_scene_mode(0); - } } extern void mFM_Field_dt() { - mFM_fdinfo_c* field_info = g_fdinfo; - mFM_block_info_c* block_info; - int max; - int i; + mFM_fdinfo_c* field_info = g_fdinfo; + mFM_block_info_c* block_info; + int max; + int i; - Common_Set(last_field_id, field_info->field_id); + Common_Set(last_field_id, field_info->field_id); - if (mFI_GET_TYPE(field_info->field_id) == mFI_FIELD_ROOM0 && mSc_IS_SCENE_MUSEUM_ROOM(Common_Get(last_scene_no)) && !mSc_IS_SCENE_MUSEUM_ROOM(Save_Get(scene_no))) { - mBGMPsComp_museum_status(0); - } - - if (field_info->field_id != mFI_FIELD_FG && mFI_GET_TYPE(field_info->field_id) != mFI_FIELD_PLAYER0_ROOM) { - if (mFI_GET_TYPE(field_info->field_id) == mFI_FIELD_NPCROOM0) { - if (field_info->fg2_p[0] != NULL) { - zelda_free(field_info->fg2_p[0]); - } + if (mFI_GET_TYPE(field_info->field_id) == mFI_FIELD_ROOM0 && mSc_IS_SCENE_MUSEUM_ROOM(Common_Get(last_scene_no)) && + !mSc_IS_SCENE_MUSEUM_ROOM(Save_Get(scene_no))) { + mBGMPsComp_museum_status(0); } - else { - block_info = field_info->block_info; - max = field_info->block_x_max * field_info->block_z_max; - for (i = max; i != 0; i--) { - zelda_free(block_info->fg_info.items_p); - block_info++; - } + if (field_info->field_id != mFI_FIELD_FG && mFI_GET_TYPE(field_info->field_id) != mFI_FIELD_PLAYER0_ROOM) { + if (mFI_GET_TYPE(field_info->field_id) == mFI_FIELD_NPCROOM0) { + if (field_info->fg2_p[0] != NULL) { + zelda_free(field_info->fg2_p[0]); + } + } else { + block_info = field_info->block_info; + max = field_info->block_x_max * field_info->block_z_max; + + for (i = max; i != 0; i--) { +// Aus version added NULL check +#if VERSION >= VER_GAFU01_00 + if (block_info->fg_info.items_p != NULL) { + zelda_free(block_info->fg_info.items_p); + } +#else + zelda_free(block_info->fg_info.items_p); +#endif + block_info++; + } + } } - } - zelda_free(field_info->fg2_p); - zelda_free(field_info->block_info); + // Aus version added NULL checks +#if VERSION >= VER_GAFU01_00 + if (field_info->fg2_p != NULL) { + zelda_free(field_info->fg2_p); + } + if (field_info->block_info != NULL) { + zelda_free(field_info->block_info); + } - for (i = 0; i < mFM_VISIBLE_BLOCK_NUM; i++) { - zelda_free(field_info->bg_display_list_p[i]); - } + for (i = 0; i < mFM_VISIBLE_BLOCK_NUM; i++) { + if (field_info->bg_display_list_p[i] != NULL) { + zelda_free(field_info->bg_display_list_p[i]); + } + } - zelda_free(field_info); - g_fdinfo = NULL; - mFI_InitRegisterBgInfo(); + if (field_info != NULL) { + zelda_free(field_info); + } +#else + zelda_free(field_info->fg2_p); + zelda_free(field_info->block_info); + + for (i = 0; i < mFM_VISIBLE_BLOCK_NUM; i++) { + zelda_free(field_info->bg_display_list_p[i]); + } + + zelda_free(field_info); +#endif + + + g_fdinfo = NULL; + mFI_InitRegisterBgInfo(); } -static void mFM_SetBlockKind(u8* type_p, int* kind_p, mFM_combination_c* combi_p, mFM_combo_info_c* combi_info_p, int count) { - for (count; count != 0; count--) { - int combi_type = combi_p[0].combination_type; - - type_p[0] = combi_info_p[combi_type].type; - kind_p[0] = mRF_Type2BlockInfo(combi_info_p[combi_type].type); +static void mFM_SetBlockKind(u8* type_p, int* kind_p, mFM_combination_c* combi_p, mFM_combo_info_c* combi_info_p, + int count) { + for (count; count != 0; count--) { + int combi_type = combi_p[0].combination_type; - type_p++; - kind_p++; - combi_p++; - } + type_p[0] = combi_info_p[combi_type].type; + kind_p[0] = mRF_Type2BlockInfo(combi_info_p[combi_type].type); + + type_p++; + kind_p++; + combi_p++; + } } extern void mFM_SetBlockKindLoadCombi() { - mFM_SetBlockKind(g_block_type_p, g_block_kind_p, Save_Get(combi_table[0]), data_combi_table, BLOCK_TOTAL_NUM); + mFM_SetBlockKind(g_block_type_p, g_block_kind_p, Save_Get(combi_table[0]), data_combi_table, BLOCK_TOTAL_NUM); } static void mFM_SetIslandFg(mFM_combo_info_c* combi_info_p, mFM_fg_data_c** sorted_fg_data, int* island_x_blocks) { - int i; + int i; - for (i = 0; i < mISL_FG_BLOCK_X_NUM; i++) { - int fg_id = combi_info_p[Save_Get(combi_table[mISL_BLOCK_Z][island_x_blocks[0]]).combination_type].fg_id; - if (sorted_fg_data[fg_id] == NULL) { - break; - } + for (i = 0; i < mISL_FG_BLOCK_X_NUM; i++) { + int fg_id = combi_info_p[Save_Get(combi_table[mISL_BLOCK_Z][island_x_blocks[0]]).combination_type].fg_id; + if (sorted_fg_data[fg_id] == NULL) { + break; + } - if (fg_id >= 0 && fg_id < mFM_FG_NUM) { - mFM_FgUtDataSet(Save_Get(island).fgblock[0][i].items[0], sorted_fg_data[fg_id]->items[0]); + if (fg_id >= 0 && fg_id < mFM_FG_NUM) { + mFM_FgUtDataSet(Save_Get(island).fgblock[0][i].items[0], sorted_fg_data[fg_id]->items[0]); + } + + island_x_blocks++; } - - island_x_blocks++; - } } -static mFM_combination_c l_combiID[BLOCK_TOTAL_NUM] = { - { 209, 1 }, { 201, 1 }, { 201, 1 }, { 201, 1 }, { 202, 1 }, { 201, 1 }, { 210, 1 }, - { 205, 1 }, { 172, 1 }, { 222, 1 }, { 189, 1 }, { 176, 1 }, { 225, 1 }, { 208, 1 }, - { 203, 1 }, { 159, 1 }, { 5, 1 }, { 215, 1 }, { 93, 1 }, { 37, 1 }, { 206, 1 }, - { 203, 1 }, { 45, 0 }, { 101, 0 }, { 96, 1 }, { 152, 1 }, { 108, 0 }, { 207, 0 }, - { 204, 0 }, { 42, 0 }, { 163, 0 }, { 64, 0 }, { 164, 0 }, { 213, 0 }, { 206, 0 }, - { 203, 0 }, { 157, 0 }, { 217, 0 }, { 127, 0 }, { 38, 0 }, { 160, 0 }, { 206, 0 }, - { 196, 0 }, { 196, 0 }, { 196, 0 }, { 196, 0 }, { 196, 0 }, { 196, 0 }, { 196, 0 }, - { 196, 0 }, { 196, 0 }, { 196, 0 }, { 196, 0 }, { 196, 0 }, { 196, 0 }, { 196, 0 }, - { 196, 0 }, { 196, 0 }, { 196, 0 }, { 196, 0 }, { 196, 0 }, { 196, 0 }, { 196, 0 }, - { 196, 0 }, { 196, 0 }, { 196, 0 }, { 196, 0 }, { 196, 0 }, { 196, 0 }, { 196, 0 } +static mFM_combination_c l_combiID[BLOCK_TOTAL_NUM] = { + { 209, 1 }, { 201, 1 }, { 201, 1 }, { 201, 1 }, { 202, 1 }, { 201, 1 }, { 210, 1 }, { 205, 1 }, { 172, 1 }, + { 222, 1 }, { 189, 1 }, { 176, 1 }, { 225, 1 }, { 208, 1 }, { 203, 1 }, { 159, 1 }, { 5, 1 }, { 215, 1 }, + { 93, 1 }, { 37, 1 }, { 206, 1 }, { 203, 1 }, { 45, 0 }, { 101, 0 }, { 96, 1 }, { 152, 1 }, { 108, 0 }, + { 207, 0 }, { 204, 0 }, { 42, 0 }, { 163, 0 }, { 64, 0 }, { 164, 0 }, { 213, 0 }, { 206, 0 }, { 203, 0 }, + { 157, 0 }, { 217, 0 }, { 127, 0 }, { 38, 0 }, { 160, 0 }, { 206, 0 }, { 196, 0 }, { 196, 0 }, { 196, 0 }, + { 196, 0 }, { 196, 0 }, { 196, 0 }, { 196, 0 }, { 196, 0 }, { 196, 0 }, { 196, 0 }, { 196, 0 }, { 196, 0 }, + { 196, 0 }, { 196, 0 }, { 196, 0 }, { 196, 0 }, { 196, 0 }, { 196, 0 }, { 196, 0 }, { 196, 0 }, { 196, 0 }, + { 196, 0 }, { 196, 0 }, { 196, 0 }, { 196, 0 }, { 196, 0 }, { 196, 0 }, { 196, 0 }, }; u8* g_block_type_p = l_block_type; int* g_block_kind_p = l_block_kind; extern void mFM_InitFgCombiSaveData(GAME* game) { - GameAlloc* game_alloc_p = NULL; - void* gamealloc_data_p; - mFM_fg_data_c* fg_data_p; - mFM_combo_info_c* combo_info_p; - mFM_combination_c* combi_table; - mFM_fg_data_c** sorted_fg_data_list; - size_t fg_datasize; - size_t fg_datasize_align; - mFM_fg_c* fg_block; - int fg_id; - mFM_fg_c* fg_block_p; - int fg_data_num; - mFM_fg_data_c* src_data; - int bz; - int bx; - int total_fg_block; + GameAlloc* game_alloc_p = NULL; + void* gamealloc_data_p; + mFM_fg_data_c* fg_data_p; + mFM_combo_info_c* combo_info_p; + mFM_combination_c* combi_table; + mFM_fg_data_c** sorted_fg_data_list; + size_t fg_datasize; + size_t fg_datasize_align; + mFM_fg_c* fg_block; + int fg_id; + mFM_fg_c* fg_block_p; + int fg_data_num; + mFM_fg_data_c* src_data; + int bz; + int bx; + int total_fg_block; - combi_table = Save_Get(combi_table[0]); - fg_block = Save_Get(fg[0]); - total_fg_block = 0; + combi_table = Save_Get(combi_table[0]); + fg_block = Save_Get(fg[0]); - if (game != NULL) { - game_alloc_p = &game->gamealloc; - } +// Aus version initializes pointers to NULL for NULL checks +#if VERSION >= VER_GAFU01_00 + gamealloc_data_p = NULL; + fg_data_p = NULL; + total_fg_block = 0; +#else + total_fg_block = 0; +#endif - combo_info_p = data_combi_table; - mRF_MakeRandomField(l_combiID, combo_info_p, data_combi_table_number, game); - mFM_SetBlockKind(g_block_type_p, g_block_kind_p, l_combiID, combo_info_p, BLOCK_TOTAL_NUM); - mFM_SetCombiTable(combi_table, l_combiID, BLOCK_X_NUM, BLOCK_Z_NUM); - fg_datasize = JW_GetResSizeFileNo(RESOURCE_FGDATA); - fg_datasize_align = ALIGN_NEXT(fg_datasize, 32); - - if (game != NULL) { - gamealloc_data_p = gamealloc_malloc(game_alloc_p, fg_datasize_align + 32); - fg_data_p = (mFM_fg_data_c*)(ALIGN_NEXT((u32)gamealloc_data_p, 32)); - } - else { - fg_data_p = (mFM_fg_data_c*)zelda_malloc_align(fg_datasize_align, 32); - } - - fg_data_num = fg_datasize / sizeof(mFM_fg_data_c); - _JW_GetResourceAram(JW_GetAramAddress(RESOURCE_FGDATA), (u8*)fg_data_p, fg_datasize_align); - - if (game != NULL) { - sorted_fg_data_list = (mFM_fg_data_c**)gamealloc_malloc(game_alloc_p, mFM_FG_NUM * sizeof(mFM_fg_data_c*)); - } - else { - sorted_fg_data_list = (mFM_fg_data_c**)zelda_malloc(mFM_FG_NUM * sizeof(mFM_fg_data_c*)); - } - - mFM_SortFGData(sorted_fg_data_list, fg_data_p, mFM_FG_NUM, fg_data_num, 0); - - fg_block_p = fg_block; - for (bz = 0; bz < mISL_BLOCK_Z; bz++) { - for (bx = 0; bx < BLOCK_X_NUM; bx++, combi_table++) { - if (bz > 0 && bz < (BLOCK_Z_NUM - 3) && bx > 0 && bx < (BLOCK_X_NUM - 1)) { - if (total_fg_block >= FG_BLOCK_TOTAL_NUM) { - break; - } - - fg_id = combo_info_p[combi_table[0].combination_type].fg_id; - if (fg_block_p == NULL) { - break; - } - - src_data = sorted_fg_data_list[fg_id]; - if (src_data == NULL) { - break; - } - - if (fg_id >= 0 && fg_id < mFM_FG_NUM) { - mFM_FgUtDataSet(fg_block_p->items[0], src_data->items[0]); - } - - total_fg_block++; - fg_block_p++; - - if (total_fg_block >= FG_BLOCK_TOTAL_NUM) { - break; - } - } + if (game != NULL) { + game_alloc_p = &game->gamealloc; } - } - { - int island_x_blocks[2]; + combo_info_p = data_combi_table; + mRF_MakeRandomField(l_combiID, combo_info_p, data_combi_table_number, game); + mFM_SetBlockKind(g_block_type_p, g_block_kind_p, l_combiID, combo_info_p, BLOCK_TOTAL_NUM); + mFM_SetCombiTable(combi_table, l_combiID, BLOCK_X_NUM, BLOCK_Z_NUM); + fg_datasize = JW_GetResSizeFileNo(RESOURCE_FGDATA); + fg_datasize_align = ALIGN_NEXT(fg_datasize, 32); - mFI_GetIslandBlockNumX(island_x_blocks); - mFM_SetIslandFg(combo_info_p, sorted_fg_data_list, island_x_blocks); - } + if (game != NULL) { + gamealloc_data_p = gamealloc_malloc(game_alloc_p, fg_datasize_align + 32); +// Aus version added NULL check +#if VERSION >= VER_GAFU01_00 + if (gamealloc_data_p != NULL) { + fg_data_p = (mFM_fg_data_c*)(ALIGN_NEXT((u32)gamealloc_data_p, 32)); + } +#else + fg_data_p = (mFM_fg_data_c*)(ALIGN_NEXT((u32)gamealloc_data_p, 32)); +#endif + } else { + fg_data_p = (mFM_fg_data_c*)zelda_malloc_align(fg_datasize_align, 32); + } - if (game != NULL) { - gamealloc_free(game_alloc_p, sorted_fg_data_list); - gamealloc_free(game_alloc_p, gamealloc_data_p); - } - else { - zelda_free(sorted_fg_data_list); - zelda_free(fg_data_p); - } + fg_data_num = fg_datasize / sizeof(mFM_fg_data_c); + _JW_GetResourceAram(JW_GetAramAddress(RESOURCE_FGDATA), (u8*)fg_data_p, fg_datasize_align); + + if (game != NULL) { + sorted_fg_data_list = (mFM_fg_data_c**)gamealloc_malloc(game_alloc_p, mFM_FG_NUM * sizeof(mFM_fg_data_c*)); + } else { + sorted_fg_data_list = (mFM_fg_data_c**)zelda_malloc(mFM_FG_NUM * sizeof(mFM_fg_data_c*)); + } + + mFM_SortFGData(sorted_fg_data_list, fg_data_p, mFM_FG_NUM, fg_data_num, 0); + + fg_block_p = fg_block; + for (bz = 0; bz < mISL_BLOCK_Z; bz++) { + for (bx = 0; bx < BLOCK_X_NUM; bx++, combi_table++) { + if (bz > 0 && bz < (BLOCK_Z_NUM - 3) && bx > 0 && bx < (BLOCK_X_NUM - 1)) { + if (total_fg_block >= FG_BLOCK_TOTAL_NUM) { + break; + } + + fg_id = combo_info_p[combi_table[0].combination_type].fg_id; + if (fg_block_p == NULL) { + break; + } + + src_data = sorted_fg_data_list[fg_id]; + if (src_data == NULL) { + break; + } + + if (fg_id >= 0 && fg_id < mFM_FG_NUM) { + mFM_FgUtDataSet(fg_block_p->items[0], src_data->items[0]); + } + + total_fg_block++; + fg_block_p++; + + if (total_fg_block >= FG_BLOCK_TOTAL_NUM) { + break; + } + } + } + } + + { + int island_x_blocks[2]; + + mFI_GetIslandBlockNumX(island_x_blocks); + mFM_SetIslandFg(combo_info_p, sorted_fg_data_list, island_x_blocks); + } + +// Aus version added NULL checks +#if VERSION >= VER_GAFU01_00 + if (game != NULL) { + if (sorted_fg_data_list != NULL) { + gamealloc_free(game_alloc_p, sorted_fg_data_list); + } + + if (gamealloc_data_p != NULL) { + gamealloc_free(game_alloc_p, gamealloc_data_p); + } + } else { + if (sorted_fg_data_list != NULL) { + zelda_free(sorted_fg_data_list); + } + + if (fg_data_p != NULL) { + zelda_free(fg_data_p); + } + } +#else + if (game != NULL) { + gamealloc_free(game_alloc_p, sorted_fg_data_list); + gamealloc_free(game_alloc_p, gamealloc_data_p); + } else { + zelda_free(sorted_fg_data_list); + zelda_free(fg_data_p); + } +#endif } static int mFM_AddIdx(int* idx, int min, int max) { - int res = FALSE; + int res = FALSE; - (*idx)++; + (*idx)++; - if (*idx >= max) { - *idx = min; - res = TRUE; - } + if (*idx >= max) { + *idx = min; + res = TRUE; + } - return res; + return res; } static mActor_name_t mFM_GetNextReseve(int set, int set_idx, int river_idx, u32 block_kind, int force) { - mActor_name_t reserve; + int group = set; + int idx = set_idx; + mActor_name_t reserve = SIGN00; - if (force == FALSE && ((block_kind & mRF_BLOCKKIND_RIVER) == mRF_BLOCKKIND_RIVER)) { - set = 0; - set_idx = river_idx; - } + if (force == FALSE && ((block_kind & mRF_BLOCKKIND_RIVER) == mRF_BLOCKKIND_RIVER)) { + group = 0; + idx = river_idx; + } - reserve = set * 3 + set_idx; - reserve += SIGN00; - return reserve; + + reserve += (mActor_name_t)(group * 3 + idx); + return reserve; } static void mFM_RenewalReserveBlock(mActor_name_t* items, int* set, int* set_idx, int* river_idx, u32 block_kind) { - int force = FALSE; - int i; + int force = FALSE; + int i; - for (i = 0; i < UT_TOTAL_NUM; i++) { - if (items[0] == SIGN00) { - items[0] = mFM_GetNextReseve(*set, *set_idx, *river_idx, block_kind, force); + for (i = 0; i < UT_TOTAL_NUM; i++) { + if (*items == SIGN00) { + *items = mFM_GetNextReseve(*set, *set_idx, *river_idx, block_kind, force); - if (force == FALSE && (block_kind & mRF_BLOCKKIND_RIVER) == mRF_BLOCKKIND_RIVER) { - mFM_AddIdx(river_idx, 0, 3); - force = TRUE; - } - else { - if (mFM_AddIdx(set, 1, 7) == TRUE) { - mFM_AddIdx(set_idx, 0, 3); + if (force == FALSE && (block_kind & mRF_BLOCKKIND_RIVER) == mRF_BLOCKKIND_RIVER) { + mFM_AddIdx(river_idx, 0, 3); + force = TRUE; + } else { + if (mFM_AddIdx(set, 1, 7) == TRUE) { + mFM_AddIdx(set_idx, 0, 3); + } + } } - } - } - items++; - } + items++; + } } extern void mFM_RenewalReserve() { - int set = 1; - int set_idx = 0; - int river_idx = 0; - mFM_fg_c* fg_block = Save_Get(fg[1]); - - int bx; - int bz; - - for (bz = 1; bz < FG_BLOCK_Z_NUM; bz++) { - for (bx = 0; bx < FG_BLOCK_X_NUM; bx++) { - mFM_RenewalReserveBlock(fg_block->items[0], &set, &set_idx, &river_idx, g_block_kind_p[(bz + 1) * BLOCK_X_NUM + (bx + 1)]); - fg_block++; + mFM_fg_c* fg_block = Save_Get(fg[1]); + int set = 1; + int set_idx = 0; + int river_idx = 0; + u32 block_kind; + int block; + + int bx; + int bz; + + for (bz = 1; bz < FG_BLOCK_Z_NUM; bz++) { + for (bx = 0; bx < FG_BLOCK_X_NUM; bx++, fg_block++) { + block_kind = g_block_kind_p[(bz + 1) * BLOCK_X_NUM + (bx + 1)]; +// Aus adds NULL check on fg_block +#if VERSION >= VER_GAFU01_00 + if (fg_block == NULL) { + continue; + } +#endif + mFM_RenewalReserveBlock(fg_block->items[0], &set, &set_idx, &river_idx, block_kind); + } } - } } extern mActor_name_t mFM_GetReseveName(int bx, int bz) { - mActor_name_t reserve_name = SIGN03; - int reserve_bit_field = 0; - u8 reserve_complete_sets_bit_field = 0; - int free_signs; - int set = 0; - int reserve_noncomplete_sets = 0; - int set_idx = 0; - int i; + mActor_name_t* items; + mActor_name_t reserve_name = SIGN03; + u32 block_kind; + int reserve_bit_field = 0; + u8 reserve_complete_sets_bit_field = 0; + int free_signs; + int set = 0; + int reserve_noncomplete_sets = 0; + int set_idx = 0; + int i; - if (bx > 0 && bx < (BLOCK_X_NUM - 1) && bz > 0 && bz < (BLOCK_Z_NUM - 3)) { - u32 block_kind = g_block_kind_p[(bz * BLOCK_X_NUM) + bx]; - mActor_name_t* items = Save_Get(fg[bz - 1][bx - 1]).items[0]; - - for (i = 0; i < UT_TOTAL_NUM; i++) { - if (mNT_IS_RESERVE(items[0])) { - reserve_bit_field |= (1 << (items[0] - SIGN00)); - } + if (bx > 0 && bx < (BLOCK_X_NUM - 1) && bz > 0 && bz < (BLOCK_Z_NUM - 3)) { + block_kind = g_block_kind_p[(bz * BLOCK_X_NUM) + bx]; + items = Save_Get(fg[bz - 1][bx - 1]).items[0]; - items++; - } + for (i = 0; i < UT_TOTAL_NUM; i++) { + if (mNT_IS_RESERVE(items[0])) { + reserve_bit_field |= (1 << (items[0] - SIGN00)); + } - for (i = 0; i < 7; i++) { - u32 shift = i * 3; - if (((reserve_bit_field >> shift) & 0b111) == 0b111) { - reserve_complete_sets_bit_field |= (1 << i); - } - - if (((reserve_bit_field >> (i * 3)) & 0b111) != 0b111) { - reserve_noncomplete_sets++; - } - } - - /* Mark river set as unavailable */ - if ( - (block_kind & mRF_BLOCKKIND_RIVER) != mRF_BLOCKKIND_RIVER && - ((reserve_complete_sets_bit_field & 1) == 0) - ) { - reserve_complete_sets_bit_field |= 1; - reserve_noncomplete_sets--; - } - - /* Select one of the 7 sets of signs */ - { - int selected_set = RANDOM(reserve_noncomplete_sets); - - for (i = 0; i < 7; i++) { - if (((reserve_complete_sets_bit_field >> i) & 1) == 0) { - if (selected_set <= 0) { - set = i; - break; - } - else { - selected_set--; - } + items++; + } + + for (i = 0; i < 7; i++) { + u32 shift = i * 3; + if (((reserve_bit_field >> shift) & 0b111) == 0b111) { + reserve_complete_sets_bit_field |= (1 << i); + } + + if (((reserve_bit_field >> (i * 3)) & 0b111) != 0b111) { + reserve_noncomplete_sets++; + } + } + + /* Mark river set as unavailable */ + if ((block_kind & mRF_BLOCKKIND_RIVER) != mRF_BLOCKKIND_RIVER && ((reserve_complete_sets_bit_field & 1) == 0)) { + reserve_complete_sets_bit_field |= 1; + reserve_noncomplete_sets--; + } + + /* Select one of the 7 sets of signs */ + { + int selected_set = RANDOM(reserve_noncomplete_sets); + + for (i = 0; i < 7; i++) { + if (((reserve_complete_sets_bit_field >> i) & 1) == 0) { + if (selected_set <= 0) { + set = i; + break; + } else { + selected_set--; + } + } + } + } + + /* Count used signs in selected set */ + { + int subset_start = set * 3; + int idx; + int j; + int selected_idx; + free_signs = 0; + + for (i = subset_start; i < subset_start + 3; i++) { + if (((reserve_bit_field >> i) & 1) == 0) { + free_signs++; + } + } + + /* Select random free sign in set */ + selected_idx = RANDOM(free_signs); + idx = 0; + + for (j = subset_start; j < subset_start + 3; j++) { + if (((reserve_bit_field >> j) & 1) == 0) { + if (selected_idx <= 0) { + idx = j; + break; + } else { + selected_idx--; + } + } + } + + reserve_name = SIGN00 + idx; } - } } - /* Count used signs in selected set */ - { - int subset_start = set * 3; - int idx; - int j; - int selected_idx; - free_signs = 0; - - for (i = subset_start; i < subset_start + 3; i++) { - if (((reserve_bit_field >> i) & 1) == 0) { - free_signs++; - } - } - - /* Select random free sign in set */ - selected_idx = RANDOM(free_signs); - idx = 0; - - for (j = subset_start; j < subset_start + 3; j++) { - if (((reserve_bit_field >> j) & 1) == 0) { - if (selected_idx <= 0) { - idx = j; - break; - } - else { - selected_idx--; - } - } - } - - reserve_name = SIGN00 + idx; - } - } - - return reserve_name; + return reserve_name; } extern void mFM_toSummer() { - mTM_set_season_com(7); + mTM_set_season_com(7); - if (g_fdinfo != NULL) { - mFM_LoadBGCommonTex(FALSE, Save_Get(island).grass_tex_type); - mFM_SetFieldPal(&g_fdinfo->field_palette); - } + if (g_fdinfo != NULL) { + mFM_LoadBGCommonTex(FALSE, Save_Get(island).grass_tex_type); + mFM_SetFieldPal(&g_fdinfo->field_palette); + } } extern void mFM_returnSeason() { - mTM_set_season(); + mTM_set_season(); - if (g_fdinfo != NULL) { - mFM_LoadBGCommonTex(FALSE, Save_Get(bg_tex_idx)); - mFM_SetFieldPal(&g_fdinfo->field_palette); - } + if (g_fdinfo != NULL) { + mFM_LoadBGCommonTex(FALSE, Save_Get(bg_tex_idx)); + mFM_SetFieldPal(&g_fdinfo->field_palette); + } } extern void mFM_RestoreIslandBG(int* island_x_blocks, int bx_num) { - mFM_combination_c* combi_p; - - mFM_block_info_c* block_info; - mFM_bg_data_c** sorted_bg_data; - mFM_bg_data_c* bg_data_p = data_bgd; - mFM_combo_info_c* combo_info_p = data_combi_table; + mFM_combination_c* combi_p; - if (mFI_CheckFieldData() && Save_Get(scene_no) == SCENE_FG) { - block_info = mFI_GetBlockTopP(); + mFM_block_info_c* block_info; + mFM_bg_data_c** sorted_bg_data; + mFM_bg_data_c* bg_data_p = data_bgd; + mFM_combo_info_c* combo_info_p = data_combi_table; - if (block_info != NULL) { - int i; - sorted_bg_data = (mFM_bg_data_c**)zelda_malloc(mFM_BG_ID_MAX * sizeof(mFM_bg_data_c*)); + if (mFI_CheckFieldData() && Save_Get(scene_no) == SCENE_FG) { + block_info = mFI_GetBlockTopP(); - if (sorted_bg_data != NULL) { - mFM_SortBGData(sorted_bg_data, bg_data_p, data_bgd_number); - combi_p = Save_Get(combi_table[mISL_BLOCK_Z] + island_x_blocks[0]); - block_info += mFI_GetBlockNum(island_x_blocks[0], mISL_BLOCK_Z); + if (block_info != NULL) { + int i; + sorted_bg_data = (mFM_bg_data_c**)zelda_malloc(mFM_BG_ID_MAX * sizeof(mFM_bg_data_c*)); - for (i = 0; i < bx_num; i++) { - int bg_id = combo_info_p[combi_p[0].combination_type].bg_id; + if (sorted_bg_data != NULL) { + mFM_SortBGData(sorted_bg_data, bg_data_p, data_bgd_number); + combi_p = Save_Get(combi_table[mISL_BLOCK_Z] + island_x_blocks[0]); + block_info += mFI_GetBlockNum(island_x_blocks[0], mISL_BLOCK_Z); - if (bg_id <= mFM_BG_ID_MAX && sorted_bg_data[bg_id] != NULL) { - mFM_SetBG(&block_info->bg_info, sorted_bg_data[bg_id], combi_p->height, block_info->bg_info.block_type, bg_id, island_x_blocks[i], mISL_BLOCK_Z); - } + for (i = 0; i < bx_num; i++) { + int bg_id = combo_info_p[combi_p[0].combination_type].bg_id; - block_info++; - combi_p++; + if (bg_id <= mFM_BG_ID_MAX && sorted_bg_data[bg_id] != NULL) { + mFM_SetBG(&block_info->bg_info, sorted_bg_data[bg_id], combi_p->height, + block_info->bg_info.block_type, bg_id, island_x_blocks[i], mISL_BLOCK_Z); + } + + block_info++; + combi_p++; + } + + if (sorted_bg_data != NULL) { + zelda_free(sorted_bg_data); + } + } } - - if (sorted_bg_data != NULL) { - zelda_free(sorted_bg_data); - } - } } - } } extern void mFM_SetIslandNpcRoomData(GAME* game, int malloc_flag) { - GameAlloc* gamealloc = NULL; - mFM_fg_data_c** sorted_fgnpc_data_list; - void* gamealloc_data_p; - mFM_fg_data_c* fgnpc_data_p; - size_t fgnpc_size = JW_GetResSizeFileNo(RESOURCE_FGNPCDATA); - size_t fgnpc_size_align = ALIGN_NEXT(fgnpc_size, 32); - int fgnpc_data_num; + GameAlloc* gamealloc = NULL; + mFM_fg_data_c** sorted_fgnpc_data_list; - if (game != NULL) { - gamealloc = &game->gamealloc; - } +#if VERSION >= VER_GAFU01_00 + void* gamealloc_data_p = NULL; +#else + void* gamealloc_data_p; +#endif + mFM_fg_data_c* fgnpc_data_p; + size_t fgnpc_size = JW_GetResSizeFileNo(RESOURCE_FGNPCDATA); + size_t fgnpc_size_align = ALIGN_NEXT(fgnpc_size, 32); + int fgnpc_data_num; - if (malloc_flag == TRUE) { - fgnpc_data_p = (mFM_fg_data_c*)zelda_malloc_align(fgnpc_size_align, 32); - } - else if (game != NULL) { - gamealloc_data_p = gamealloc_malloc(gamealloc, fgnpc_size_align + 32); - fgnpc_data_p = (mFM_fg_data_c*)(ALIGN_NEXT((u32)gamealloc_data_p, 32)); - } - else { - fgnpc_data_p = (mFM_fg_data_c*)zelda_malloc_align(fgnpc_size_align, 32); - } - - - if (fgnpc_data_p != NULL) { - fgnpc_data_num = fgnpc_size / sizeof(mFM_fg_data_c); - _JW_GetResourceAram(JW_GetAramAddress(RESOURCE_FGNPCDATA), (u8*)fgnpc_data_p, fgnpc_size_align); + if (game != NULL) { + gamealloc = &game->gamealloc; + } if (malloc_flag == TRUE) { - sorted_fgnpc_data_list = (mFM_fg_data_c**)zelda_malloc(mFM_FG_NPC_NUM * sizeof(mFM_fg_data_c*)); - } - else if (game != NULL) { - sorted_fgnpc_data_list = (mFM_fg_data_c**)gamealloc_malloc(gamealloc, mFM_FG_NPC_NUM * sizeof(mFM_fg_data_c*)); - } - else { - sorted_fgnpc_data_list = (mFM_fg_data_c**)zelda_malloc(mFM_FG_NPC_NUM * sizeof(mFM_fg_data_c*)); + fgnpc_data_p = (mFM_fg_data_c*)zelda_malloc_align(fgnpc_size_align, 32); + } else if (game != NULL) { + gamealloc_data_p = gamealloc_malloc(gamealloc, fgnpc_size_align + 32); + fgnpc_data_p = (mFM_fg_data_c*)(ALIGN_NEXT((u32)gamealloc_data_p, 32)); + } else { + fgnpc_data_p = (mFM_fg_data_c*)zelda_malloc_align(fgnpc_size_align, 32); } - if (sorted_fgnpc_data_list != NULL) { - mFM_SortFGData(sorted_fgnpc_data_list, fgnpc_data_p, mFM_FG_NPC_NUM, fgnpc_data_num, mFM_FG_NPC_START); - mNpc_IslandNpcRoomDataSet(sorted_fgnpc_data_list, mFM_FG_NPC_START); + if (fgnpc_data_p != NULL) { + fgnpc_data_num = fgnpc_size / sizeof(mFM_fg_data_c); + _JW_GetResourceAram(JW_GetAramAddress(RESOURCE_FGNPCDATA), (u8*)fgnpc_data_p, fgnpc_size_align); - if (sorted_fgnpc_data_list != NULL) { if (malloc_flag == TRUE) { - zelda_free(sorted_fgnpc_data_list); + sorted_fgnpc_data_list = (mFM_fg_data_c**)zelda_malloc(mFM_FG_NPC_NUM * sizeof(mFM_fg_data_c*)); + } else if (game != NULL) { + sorted_fgnpc_data_list = + (mFM_fg_data_c**)gamealloc_malloc(gamealloc, mFM_FG_NPC_NUM * sizeof(mFM_fg_data_c*)); + } else { + sorted_fgnpc_data_list = (mFM_fg_data_c**)zelda_malloc(mFM_FG_NPC_NUM * sizeof(mFM_fg_data_c*)); } - else if (game != NULL) { - gamealloc_free(gamealloc, sorted_fgnpc_data_list); - } - else { - zelda_free(sorted_fgnpc_data_list); - } - } - } - /* @BUG - memory leak if gamealloc malloc path is not taken above */ - #ifndef BUGFIXES - if (gamealloc_data_p != NULL) { - #else - if (fgnpc_data_p != NULL) { // this is guaranteed to exist in all malloc paths - #endif - if (malloc_flag == TRUE) { - zelda_free(fgnpc_data_p); - } - else if (game != NULL) { - gamealloc_free(gamealloc, gamealloc_data_p); - } - else { - zelda_free(fgnpc_data_p); - } + if (sorted_fgnpc_data_list != NULL) { + mFM_SortFGData(sorted_fgnpc_data_list, fgnpc_data_p, mFM_FG_NPC_NUM, fgnpc_data_num, mFM_FG_NPC_START); + mNpc_IslandNpcRoomDataSet(sorted_fgnpc_data_list, mFM_FG_NPC_START); + + if (sorted_fgnpc_data_list != NULL) { + if (malloc_flag == TRUE) { + zelda_free(sorted_fgnpc_data_list); + } else if (game != NULL) { + gamealloc_free(gamealloc, sorted_fgnpc_data_list); + } else { + zelda_free(sorted_fgnpc_data_list); + } + } + } + +#if VERSION >= VER_GAFU01_00 + if (fgnpc_data_p != NULL) { + if (malloc_flag == TRUE || game == NULL) { + zelda_free(fgnpc_data_p); + } + } + + if (gamealloc_data_p != NULL) { + gamealloc_free(gamealloc, gamealloc_data_p); + } +#else + /* @BUG - memory leak if gamealloc malloc path is not taken above */ +#ifndef BUGFIXES + if (gamealloc_data_p != NULL) { +#else + if (fgnpc_data_p != NULL) { // this is guaranteed to exist in all malloc paths +#endif + if (malloc_flag == TRUE) { + zelda_free(fgnpc_data_p); + } else if (game != NULL) { + gamealloc_free(gamealloc, gamealloc_data_p); + } else { + zelda_free(fgnpc_data_p); + } + } +#endif } - } } diff --git a/src/game/m_fishrecord.c b/src/game/m_fishrecord.c index 0691465c..280d0801 100644 --- a/src/game/m_fishrecord.c +++ b/src/game/m_fishrecord.c @@ -11,521 +11,490 @@ #include "m_common_data.h" static void mFR_delete_record(mFR_record_c* record) { - mem_clear((u8*)record, sizeof(mFR_record_c), 0); + mem_clear((u8*)record, sizeof(mFR_record_c), 0); } static void mFR_delete_after_record(lbRTC_ymd_c* after) { - int i; + int i; - for (i = 0; i < mFR_RECORD_NUM; i++) { - mFR_record_c* record = Save_Get(fishRecord) + i; + for (i = 0; i < mFR_RECORD_NUM; i++) { + mFR_record_c* record = Save_Get(fishRecord) + i; - int equal = lbRTC_IsEqualDate( - after->year, after->month, after->day, - record->time.year, record->time.month, record->time.day - ); + int equal = lbRTC_IsEqualDate(after->year, after->month, after->day, record->time.year, record->time.month, + record->time.day); - if (equal == lbRTC_LESS) { - mFR_delete_record(record); + if (equal == lbRTC_LESS) { + mFR_delete_record(record); + } } - } } static void mFR_delete_npc_record(lbRTC_ymd_c* date) { - int i; + int i; - for (i = 0; i < mFR_RECORD_NUM; i++) { - mFR_record_c* record = Save_Get(fishRecord) + i; - - if ( - record->size != 0 && - ( - date == NULL || - lbRTC_IsEqualDate( date->year, date->month, date->day, record->time.year, record->time.month, record->time.day) != lbRTC_EQUAL - ) && - mPr_GetPrivateIdx(&record->pid) == -1 - ) { - mFR_delete_record(record); + for (i = 0; i < mFR_RECORD_NUM; i++) { + mFR_record_c* record = Save_Get(fishRecord) + i; + + if (record->size != 0 && + (date == NULL || lbRTC_IsEqualDate(date->year, date->month, date->day, record->time.year, + record->time.month, record->time.day) != lbRTC_EQUAL) && + mPr_GetPrivateIdx(&record->pid) == -1) { + mFR_delete_record(record); + } } - } } static mFR_record_c* mFR_get_record(lbRTC_ymd_c date) { - int i; + int i; - for (i = 0; i < mFR_RECORD_NUM; i++) { - mFR_record_c* record = Save_Get(fishRecord) + i; + for (i = 0; i < mFR_RECORD_NUM; i++) { + mFR_record_c* record = Save_Get(fishRecord) + i; - int equal = lbRTC_IsEqualDate( - date.year, date.month, date.day, - record->time.year, record->time.month, record->time.day - ); + int equal = + lbRTC_IsEqualDate(date.year, date.month, date.day, record->time.year, record->time.month, record->time.day); - if (equal == lbRTC_EQUAL) { - return record; + if (equal == lbRTC_EQUAL) { + return record; + } } - } - return NULL; + return NULL; } static mFR_record_c* mFR_get_free_record() { - int i; + int i; - for (i = 0; i < mFR_RECORD_NUM; i++) { - mFR_record_c* record = Save_Get(fishRecord) + i; + for (i = 0; i < mFR_RECORD_NUM; i++) { + mFR_record_c* record = Save_Get(fishRecord) + i; - if (record->size == 0) { - return record; + if (record->size == 0) { + return record; + } } - } - return NULL; + return NULL; } static mFR_record_c* mFR_recycle_record() { - int i; - mFR_record_c* record; - mFR_record_c* recycle = Save_GetPointer(fishRecord[0]); + int i; + mFR_record_c* record; + mFR_record_c* recycle = Save_GetPointer(fishRecord[0]); - for (i = 1; i < mFR_RECORD_NUM; i++) { - int equal; - - record = Save_Get(fishRecord) + i; - equal = lbRTC_IsEqualDate( - recycle->time.year, recycle->time.month, recycle->time.day, - record->time.year, record->time.month, record->time.day - ); + for (i = 1; i < mFR_RECORD_NUM; i++) { + int equal; - if (equal == lbRTC_OVER) { - recycle = record; + record = Save_Get(fishRecord) + i; + equal = lbRTC_IsEqualDate(recycle->time.year, recycle->time.month, recycle->time.day, record->time.year, + record->time.month, record->time.day); + + if (equal == lbRTC_OVER) { + recycle = record; + } } - } - mFR_delete_record(recycle); - return recycle; + mFR_delete_record(recycle); + return recycle; } static mFR_record_c* mFR_new_record(lbRTC_ymd_c date) { - mFR_record_c* new_record; - - mFR_delete_after_record(&date); - mFR_delete_npc_record(&date); - - new_record = mFR_get_free_record(); - if (new_record != NULL) { - return new_record; - } - else { - return mFR_recycle_record(); - } + mFR_record_c* new_record; + + mFR_delete_after_record(&date); + mFR_delete_npc_record(&date); + + new_record = mFR_get_free_record(); + if (new_record != NULL) { + return new_record; + } else { + return mFR_recycle_record(); + } } extern void mEv_fishRecord_set(PersonalID_c* pid, int size) { - lbRTC_ymd_c date; - lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); - mFR_record_c* record; + lbRTC_ymd_c date; + lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); + mFR_record_c* record; - mTM_set_renew_time(&date, rtc_time); - record = mFR_get_record(date); + mTM_set_renew_time(&date, rtc_time); + record = mFR_get_record(date); - if (record == NULL) { - record = mFR_new_record(date); - } + if (record == NULL) { + record = mFR_new_record(date); + } - mPr_CopyPersonalID(&record->pid, pid); - record->size = size; - lbRTC_TimeCopy(&record->time, rtc_time); + mPr_CopyPersonalID(&record->pid, pid); + record->size = size; + lbRTC_TimeCopy(&record->time, rtc_time); } extern int mFR_fish_rndsize(int fish_size) { - f32 rng = fqrand(); + f32 rng = fqrand(); - switch(fish_size) { - case mFR_SIZE_LARGE: - return (50.0f + 20.0f * rng * rng) / 2.54f; - case mFR_SIZE_MEDIUM: - return (30.0f + 20.0f * rng) / 2.54f; - default: /* mFR_SIZE_SMALL */ - return (30.0f - 20.0f * rng * rng) / 2.54f; - } + switch (fish_size) { + case mFR_SIZE_LARGE: + return (50.0f + 20.0f * rng * rng) / 2.54f; + case mFR_SIZE_MEDIUM: + return (30.0f + 20.0f * rng) / 2.54f; + default: /* mFR_SIZE_SMALL */ + return (30.0f - 20.0f * rng * rng) / 2.54f; + } } extern int mFR_make_NpcRecord(lbRTC_hour_t hour) { - int rand; - if (hour < 9) { - return (int)mFR_fish_rndsize(mFR_SIZE_SMALL); - } - else if (hour < 15) { - rand = RANDOM(2); - return (int)mFR_fish_rndsize(rand); /* 50/50 mFR_SIZE_SMALL, mFR_SIZE_MEDIUM */ - } - else { - rand = RANDOM(3); - return (int)mFR_fish_rndsize(rand); /* equal chance for all sizes */ - } + int rand; + if (hour < 9) { + return (int)mFR_fish_rndsize(mFR_SIZE_SMALL); + } else if (hour < 15) { + rand = RANDOM(2); + return (int)mFR_fish_rndsize(rand); /* 50/50 mFR_SIZE_SMALL, mFR_SIZE_MEDIUM */ + } else { + rand = RANDOM(3); + return (int)mFR_fish_rndsize(rand); /* equal chance for all sizes */ + } } -static int mEv_fishRecord_local(PersonalID_c* pid, int* record_size, lbRTC_time_c* record_set_time, int player_record_size) { - static u8 l_name[] = { 0x98, 0xA6, 0x8F, 0xA1, 0x20 }; /* Untranslated JP, クニッチ */ +static int mEv_fishRecord_local(PersonalID_c* pid, int* record_size, lbRTC_time_c* record_set_time, + int player_record_size) { + static u8 l_name[] = { 0x98, 0xA6, 0x8F, 0xA1, 0x20 }; /* Untranslated JP, クニッチ */ - u8 name[ANIMAL_NAME_LEN]; - mActor_name_t selected_npc; - lbRTC_time_c l_record_time; - - fqrand(); /* unused call to fqrand..? */ - lbRTC_TimeCopy(&l_record_time, record_set_time); + u8 name[ANIMAL_NAME_LEN]; + mActor_name_t selected_npc; + lbRTC_time_c l_record_time; - /* Adjust time to 5:50 PM */ - l_record_time.hour = 17; - l_record_time.min = 50; - l_record_time.sec = 0; + fqrand(); /* unused call to fqrand..? */ + lbRTC_TimeCopy(&l_record_time, record_set_time); - *record_size = 0; + /* Adjust time to 5:50 PM */ + l_record_time.hour = 17; + l_record_time.min = 50; + l_record_time.sec = 0; - /* Roll potential new record size for every 30 minutes between the last record set time and 5:50PM */ - while (lbRTC_IsOverTime(&l_record_time, record_set_time) == lbRTC_LESS) { - /* Roll a potential new record size set by an NPC */ - int npc_record = mFR_make_NpcRecord(record_set_time->hour); + *record_size = 0; - if (npc_record > *record_size) { - *record_size = npc_record; + /* Roll potential new record size for every 30 minutes between the last record set time and 5:50PM */ + while (lbRTC_IsOverTime(&l_record_time, record_set_time) == lbRTC_LESS) { + /* Roll a potential new record size set by an NPC */ + int npc_record = mFR_make_NpcRecord(record_set_time->hour); + + if (npc_record > *record_size) { + *record_size = npc_record; + } + + lbRTC_Add_mm(record_set_time, 30); // add 30 minutes } - lbRTC_Add_mm(record_set_time, 30); // add 30 minutes - } + /* Adjust set time to 6:00PM */ + record_set_time->hour = 18; + record_set_time->min = 0; + record_set_time->sec = 0; - /* Adjust set time to 6:00PM */ - record_set_time->hour = 18; - record_set_time->min = 0; - record_set_time->sec = 0; + if (*record_size <= player_record_size) { + return FALSE; + } else { + mPr_ClearPersonalID(pid); + if (mEvMN_GetJointEventRandomNpc(&selected_npc) == TRUE) { + mNpc_GetNpcWorldNameTableNo(name, selected_npc); + } else { + mNpc_GetRandomAnimalName(name); + } - if (*record_size <= player_record_size) { - return FALSE; - } - else { - mPr_ClearPersonalID(pid); - if (mEvMN_GetJointEventRandomNpc(&selected_npc) == TRUE) { - mNpc_GetNpcWorldNameTableNo(name, selected_npc); + mem_copy(pid->player_name, name, ANIMAL_NAME_LEN); + mLd_ClearLandName(pid->land_name); + mem_copy(pid->land_name, l_name, sizeof(l_name)); + + return TRUE; } - else { - mNpc_GetRandomAnimalName(name); - } - - mem_copy(pid->player_name, name, ANIMAL_NAME_LEN); - mLd_ClearLandName(pid->land_name); - mem_copy(pid->land_name, l_name, sizeof(l_name)); - - return TRUE; - } } static void mEv_fishRecord_holder1(PersonalID_c* pid, int* size, mFR_record_c* record) { - PersonalID_c record_id; - int record_size; + PersonalID_c record_id; + int record_size; - - if (mEv_fishRecord_local(&record_id, &record_size, &record->time, record->size) == FALSE) { - /* Player wins */ - mPr_CopyPersonalID(pid, &Save_GetPointer(fishRecord[0])->pid); - *size = Save_GetPointer(fishRecord[0])->size; - } - else { - /* NPC wins */ - record->size = record_size; - mPr_CopyPersonalID(&record->pid, &record_id); - *size = record_size; - mPr_CopyPersonalID(pid, &record_id); - } + if (mEv_fishRecord_local(&record_id, &record_size, &record->time, record->size) == FALSE) { + /* Player wins */ + mPr_CopyPersonalID(pid, &Save_GetPointer(fishRecord[0])->pid); + *size = Save_GetPointer(fishRecord[0])->size; + } else { + /* NPC wins */ + record->size = record_size; + mPr_CopyPersonalID(&record->pid, &record_id); + *size = record_size; + mPr_CopyPersonalID(pid, &record_id); + } } static void mEv_fishRecord_holder2(PersonalID_c* pid, int* size) { - /* NPC only win */ - lbRTC_time_c time; + /* NPC only win */ + lbRTC_time_c time; - lbRTC_TimeCopy(&time, Common_GetPointer(time.rtc_time)); - time.hour = 6; - time.min = 0; - time.sec = 0; + lbRTC_TimeCopy(&time, Common_GetPointer(time.rtc_time)); + time.hour = 6; + time.min = 0; + time.sec = 0; - mEv_fishRecord_local(pid, size, &time, 0); + mEv_fishRecord_local(pid, size, &time, 0); } -extern void mEv_fishRecord_holder(PersonalID_c* winning_pid, u32* winning_size, lbRTC_ymd_c* contest_date) { - int i; +extern void mEv_fishRecord_holder(PersonalID_c* winning_pid, u32* winning_size, const lbRTC_ymd_c* contest_date) { + int i; - for (i = 0; i < mFR_RECORD_NUM; i++) { - mFR_record_c* record = Save_Get(fishRecord) + i; + for (i = 0; i < mFR_RECORD_NUM; i++) { + mFR_record_c* record = Save_Get(fishRecord) + i; - if ( - record->time.year == contest_date->year && - record->time.month == contest_date->month && - record->time.day == contest_date->day - ) { - mEv_fishRecord_holder1(winning_pid, (int*)winning_size, record); /* found an existing record for this fishing contest */ - return; + if (record->time.year == contest_date->year && record->time.month == contest_date->month && + record->time.day == contest_date->day) { + mEv_fishRecord_holder1(winning_pid, (int*)winning_size, + record); /* found an existing record for this fishing contest */ + return; + } } - } - /* No record found for this fishing contest so generate a fake one */ - mEv_fishRecord_holder2(winning_pid, (int*)winning_size); + /* No record found for this fishing contest so generate a fake one */ + mEv_fishRecord_holder2(winning_pid, (int*)winning_size); } static lbRTC_ymd_c* mEv_fishday_day(lbRTC_year_t year, lbRTC_month_t month, int week) { - static lbRTC_ymd_c ymd; + static lbRTC_ymd_c ymd; - int weekday; - int day; + int weekday; + int day; - weekday = lbRTC_Week(year, month, lbRTC_WEEK); - ymd.year = year; - ymd.month = month; - day = (week * lbRTC_WEEK) + lbRTC_WEEK - weekday; + weekday = lbRTC_Week(year, month, lbRTC_WEEK); + ymd.year = year; + ymd.month = month; + day = (week * lbRTC_WEEK) + lbRTC_WEEK - weekday; - if (day > lbRTC_GetDaysByMonth(ymd.year, ymd.month)) { - return NULL; - } - else { - ymd.day = day; - return &ymd; - } + if (day > lbRTC_GetDaysByMonth(ymd.year, ymd.month)) { + return NULL; + } else { + ymd.day = day; + return &ymd; + } } extern int mEv_fishday(lbRTC_ymd_c* dates, lbRTC_time_c* time) { - lbRTC_time_c l_time; - lbRTC_ymd_c ymd; - int free_dates; - int i; - lbRTC_ymd_c* fishing_day_ymd_p; + lbRTC_time_c l_time; + lbRTC_ymd_c ymd; + int free_dates; + int i; + lbRTC_ymd_c* fishing_day_ymd_p; - lbRTC_TimeCopy(&l_time, time); - lbRTC_Add_hh(&l_time, 6); - ymd.year = l_time.year; - ymd.month = l_time.month; - ymd.day = l_time.day; - free_dates = 4; + lbRTC_TimeCopy(&l_time, time); + lbRTC_Add_hh(&l_time, 6); + ymd.year = l_time.year; + ymd.month = l_time.month; + ymd.day = l_time.day; + free_dates = 4; - if (ymd.month >= lbRTC_NOVEMBER) { - for (i = 4; i >= 0; i--) { - fishing_day_ymd_p = mEv_fishday_day(ymd.year, lbRTC_NOVEMBER, i); + if (ymd.month >= lbRTC_NOVEMBER) { + for (i = 4; i >= 0; i--) { + fishing_day_ymd_p = mEv_fishday_day(ymd.year, lbRTC_NOVEMBER, i); - if (fishing_day_ymd_p != NULL && (ymd.month > lbRTC_NOVEMBER || ymd.day > fishing_day_ymd_p->day)) { - lbRTC_ymd_c* week_date = dates + free_dates; + if (fishing_day_ymd_p != NULL && (ymd.month > lbRTC_NOVEMBER || ymd.day > fishing_day_ymd_p->day)) { + lbRTC_ymd_c* week_date = dates + free_dates; - week_date->year = fishing_day_ymd_p->year; - week_date->month = fishing_day_ymd_p->month; - week_date->day = fishing_day_ymd_p->day; + week_date->year = fishing_day_ymd_p->year; + week_date->month = fishing_day_ymd_p->month; + week_date->day = fishing_day_ymd_p->day; - if (free_dates <= 0) { - return TRUE; + if (free_dates <= 0) { + return TRUE; + } + + free_dates--; + } } - - free_dates--; - } } - } - if (ymd.month >= lbRTC_JUNE) { - for (i = 4; i >= 0; i--) { - fishing_day_ymd_p = mEv_fishday_day(ymd.year, lbRTC_JUNE, i); + if (ymd.month >= lbRTC_JUNE) { + for (i = 4; i >= 0; i--) { + fishing_day_ymd_p = mEv_fishday_day(ymd.year, lbRTC_JUNE, i); - if (fishing_day_ymd_p != NULL && (ymd.month > lbRTC_JUNE || ymd.day > fishing_day_ymd_p->day)) { - lbRTC_ymd_c* week_date = dates + free_dates; + if (fishing_day_ymd_p != NULL && (ymd.month > lbRTC_JUNE || ymd.day > fishing_day_ymd_p->day)) { + lbRTC_ymd_c* week_date = dates + free_dates; - week_date->year = fishing_day_ymd_p->year; - week_date->month = fishing_day_ymd_p->month; - week_date->day = fishing_day_ymd_p->day; + week_date->year = fishing_day_ymd_p->year; + week_date->month = fishing_day_ymd_p->month; + week_date->day = fishing_day_ymd_p->day; - if (free_dates <= 0) { - return TRUE; + if (free_dates <= 0) { + return TRUE; + } + + free_dates--; + } } - - free_dates--; - } } - } - /* Go through previous year */ - lbRTC_Sub_YY(&l_time, 1); - ymd.year = l_time.year; + /* Go through previous year */ + lbRTC_Sub_YY(&l_time, 1); + ymd.year = l_time.year; - for (i = 4; i >= 0; i--) { - fishing_day_ymd_p = mEv_fishday_day(ymd.year, lbRTC_NOVEMBER, i); + for (i = 4; i >= 0; i--) { + fishing_day_ymd_p = mEv_fishday_day(ymd.year, lbRTC_NOVEMBER, i); - if (fishing_day_ymd_p != NULL) { - lbRTC_ymd_c* week_date = dates + free_dates; + if (fishing_day_ymd_p != NULL) { + lbRTC_ymd_c* week_date = dates + free_dates; - week_date->year = fishing_day_ymd_p->year; - week_date->month = fishing_day_ymd_p->month; - week_date->day = fishing_day_ymd_p->day; + week_date->year = fishing_day_ymd_p->year; + week_date->month = fishing_day_ymd_p->month; + week_date->day = fishing_day_ymd_p->day; - if (free_dates <= 0) { - return TRUE; - } + if (free_dates <= 0) { + return TRUE; + } - free_dates--; + free_dates--; + } } - } - for (i = 4; i >= 0; i--) { - fishing_day_ymd_p = mEv_fishday_day(ymd.year, lbRTC_JUNE, i); + for (i = 4; i >= 0; i--) { + fishing_day_ymd_p = mEv_fishday_day(ymd.year, lbRTC_JUNE, i); - if (fishing_day_ymd_p != NULL) { - lbRTC_ymd_c* week_date = dates + free_dates; + if (fishing_day_ymd_p != NULL) { + lbRTC_ymd_c* week_date = dates + free_dates; - week_date->year = fishing_day_ymd_p->year; - week_date->month = fishing_day_ymd_p->month; - week_date->day = fishing_day_ymd_p->day; + week_date->year = fishing_day_ymd_p->year; + week_date->month = fishing_day_ymd_p->month; + week_date->day = fishing_day_ymd_p->day; - if (free_dates <= 0) { - return TRUE; - } + if (free_dates <= 0) { + return TRUE; + } - free_dates--; + free_dates--; + } } - } - return FALSE; + return FALSE; } static void mFR_swap_record(mFR_record_c* r0, mFR_record_c* r1) { - mFR_record_c temp; + mFR_record_c temp; - bcopy(r0, &temp, sizeof(mFR_record_c)); - bcopy(r1, r0, sizeof(mFR_record_c)); - bcopy(&temp, r1, sizeof(mFR_record_c)); + bcopy(r0, &temp, sizeof(mFR_record_c)); + bcopy(r1, r0, sizeof(mFR_record_c)); + bcopy(&temp, r1, sizeof(mFR_record_c)); } static void mFR_sort_record() { - int i; - int j; - mFR_record_c* records = Save_Get(fishRecord); + int i; + int j; + mFR_record_c* records = Save_Get(fishRecord); - for (i = 0; i < mFR_RECORD_NUM - 1; i++) { - for (j = i + 1; j < mFR_RECORD_NUM; j++) { - if ( - records[j].size != 0 && - (records[j].size == 0 || lbRTC_IsEqualDate( - records[i].time.year, records[i].time.month, records[i].time.day, - records[j].time.year, records[j].time.month, records[j].time.day - ) == lbRTC_OVER) - ) { - mFR_swap_record(&records[i], &records[j]); - } + for (i = 0; i < mFR_RECORD_NUM - 1; i++) { + for (j = i + 1; j < mFR_RECORD_NUM; j++) { + if (records[j].size != 0 && + (records[j].size == 0 || + lbRTC_IsEqualDate(records[i].time.year, records[i].time.month, records[i].time.day, + records[j].time.year, records[j].time.month, records[j].time.day) == lbRTC_OVER)) { + mFR_swap_record(&records[i], &records[j]); + } + } } - } } static int mFR_Fishmail_send_post(PersonalID_c* pid, Mail_c* mail) { - int arrange_idx = mHS_get_arrange_idx(mPr_GetPrivateIdx(pid)) & 3; - int free_mail_idx = mMl_chk_mail_free_space(Save_Get(homes[arrange_idx]).mailbox, HOME_MAILBOX_SIZE); + int arrange_idx = mHS_get_arrange_idx(mPr_GetPrivateIdx(pid)) & 3; + int free_mail_idx = mMl_chk_mail_free_space(Save_Get(homes[arrange_idx]).mailbox, HOME_MAILBOX_SIZE); - if (free_mail_idx >= 0) { - mMl_copy_mail(Save_Get(homes[arrange_idx]).mailbox + free_mail_idx, mail); - return TRUE; - } + if (free_mail_idx >= 0) { + mMl_copy_mail(Save_Get(homes[arrange_idx]).mailbox + free_mail_idx, mail); + return TRUE; + } - return FALSE; + return FALSE; } static int mFR_Fishmail_send_postoffice(PersonalID_c* pid, Mail_c* mail) { - if (mPO_get_keep_mail_sum() < mPO_MAIL_STORAGE_SIZE) { - mPO_receipt_proc(mail, mPO_SENDTYPE_MAIL); - return TRUE; - } + if (mPO_get_keep_mail_sum() < mPO_MAIL_STORAGE_SIZE) { + mPO_receipt_proc(mail, mPO_SENDTYPE_MAIL); + return TRUE; + } - return FALSE; + return FALSE; } static void mFR_GetFishPresentMail(mFR_record_c* record, Mail_c* mail) { - mActor_name_t present; - u8 present_name[mIN_ITEM_NAME_LEN]; - int header_back_start; + mActor_name_t present; + u8 present_name[mIN_ITEM_NAME_LEN]; + int header_back_start; - mMl_clear_mail(mail); - present = mSP_SelectFishginPresent(mPr_GetPrivateIdx(&record->pid)); - mIN_copy_name_str(present_name, present); - mHandbill_Set_free_str(mHandbill_FREE_STR0, present_name, mIN_ITEM_NAME_LEN); - mHandbill_Load_HandbillFromRom( - mail->content.header, &header_back_start, - mail->content.footer, - mail->content.body, - 0x23E + (((record->time.day - 1) / 7) & 3) - ); + mMl_clear_mail(mail); + present = mSP_SelectFishginPresent(mPr_GetPrivateIdx(&record->pid)); + mIN_copy_name_str(present_name, present); + mHandbill_Set_free_str(mHandbill_FREE_STR0, present_name, mIN_ITEM_NAME_LEN); + mHandbill_Load_HandbillFromRom(mail->content.header, &header_back_start, mail->content.footer, mail->content.body, + 0x23E + (((record->time.day - 1) / 7) & 3)); - mail->content.header_back_start = header_back_start; - mail->content.font = mMl_FONT_RECV; - mail->content.mail_type = mMl_TYPE_FISHING_CONTENST; - mail->present = present; - mail->content.paper_type = 15; // deep sea paper - mPr_CopyPersonalID(&mail->header.recipient.personalID, &record->pid); - mail->header.recipient.type = mMl_NAME_TYPE_PLAYER; + mail->content.header_back_start = header_back_start; + mail->content.font = mMl_FONT_RECV; + mail->content.mail_type = mMl_TYPE_FISHING_CONTENST; + mail->present = present; + mail->content.paper_type = 15; // deep sea paper + mPr_CopyPersonalID(&mail->header.recipient.personalID, &record->pid); + mail->header.recipient.type = mMl_NAME_TYPE_PLAYER; } static void mFR_Fishmail_send() { - int i; - mFR_record_c* record; - lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); - Mail_c* mail; + int i; + mFR_record_c* record; + lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); + Mail_c* mail; - mail = (Mail_c*)zelda_malloc(sizeof(Mail_c)); + mail = (Mail_c*)zelda_malloc(sizeof(Mail_c)); - if (mail != NULL) { - for (i = 0; i < mFR_RECORD_NUM; i++) { - record = Save_Get(fishRecord) + i; + if (mail != NULL) { + for (i = 0; i < mFR_RECORD_NUM; i++) { + record = Save_Get(fishRecord) + i; - if ( - record->size > 0 && /* used record */ - mPr_GetPrivateIdx(&record->pid) != -1 && /* record holder isn't an NPC or from out of town */ - lbRTC_IsOverTime(&record->time, rtc_time) == lbRTC_OVER /* record happened in the past */ - ) { - mFR_GetFishPresentMail(record, mail); - - /* Try sending the mail to both the recipient's mailbox and the post office */ - if (mFR_Fishmail_send_post(&record->pid, mail) != FALSE) { - mFR_delete_record(record); + if (record->size > 0 && /* used record */ + mPr_GetPrivateIdx(&record->pid) != -1 && /* record holder isn't an NPC or from out of town */ + lbRTC_IsOverTime(&record->time, rtc_time) == lbRTC_OVER /* record happened in the past */ + ) { + mFR_GetFishPresentMail(record, mail); + + /* Try sending the mail to both the recipient's mailbox and the post office */ + if (mFR_Fishmail_send_post(&record->pid, mail) != FALSE) { + mFR_delete_record(record); + } else if (mFR_Fishmail_send_postoffice(&record->pid, mail) != FALSE) { + mFR_delete_record(record); + } + } } - else if (mFR_Fishmail_send_postoffice(&record->pid, mail) != FALSE) { - mFR_delete_record(record); - } - } + + zelda_free(mail); } - - zelda_free(mail); - } } static void mFR_fishRecord_last_holder() { - mFR_record_c* record; - int i; - lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); - PersonalID_c record_holder; - int record_size; + mFR_record_c* record; + int i; + lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); + PersonalID_c record_holder; + int record_size; - for (i = 0; i < mFR_RECORD_NUM; i++) { - record = Save_Get(fishRecord) + i; + for (i = 0; i < mFR_RECORD_NUM; i++) { + record = Save_Get(fishRecord) + i; - if ( - record->size > 0 && - lbRTC_IsOverTime(&record->time, rtc_time) == lbRTC_OVER - ) { - int new_record = mEv_fishRecord_local(&record_holder, &record_size, &record->time, record->size); + if (record->size > 0 && lbRTC_IsOverTime(&record->time, rtc_time) == lbRTC_OVER) { + int new_record = mEv_fishRecord_local(&record_holder, &record_size, &record->time, record->size); - if (new_record) { - record->size = record_size; - mPr_CopyPersonalID(&record->pid, &record_holder); - } + if (new_record) { + record->size = record_size; + mPr_CopyPersonalID(&record->pid, &record_holder); + } + } } - } } extern void mFR_fishmail() { - lbRTC_ymd_c now; + lbRTC_ymd_c now; - mTM_set_renew_time(&now, Common_GetPointer(time.rtc_time)); - mFR_delete_after_record(&now); - mFR_fishRecord_last_holder(); - mFR_delete_npc_record(&now); - mFR_sort_record(); - mFR_Fishmail_send(); + mTM_set_renew_time(&now, Common_GetPointer(time.rtc_time)); + mFR_delete_after_record(&now); + mFR_fishRecord_last_holder(); + mFR_delete_npc_record(&now); + mFR_sort_record(); + mFR_Fishmail_send(); } diff --git a/src/game/m_font.c b/src/game/m_font.c index a5039b73..8936ac73 100644 --- a/src/game/m_font.c +++ b/src/game/m_font.c @@ -60,14 +60,13 @@ static int mMsg_CutLeftSpace(u8* str, int str_len) { return str_len - i; } -static u8 mFont_suji_data[] = "0123456789"; +static u8 mFont_suji_data[10] = "0123456789"; static int mFont_suji_check(u8 c) { - u8* suji = mFont_suji_data; int i; for (i = 0; i < 10; i++) { - if (c == suji[i]) { + if (c == mFont_suji_data[i]) { return TRUE; } } @@ -201,13 +200,11 @@ extern u8 mFont_small_to_capital(u8 small) { u8* t = (u8*)tbl; int i; - for (i = 0; i < 56; i++) { + for (i = 0; i < 56; i++, t += 2) { if (t[0] == small) { res = t[1]; break; } - - t += 2; } return res; diff --git a/src/game/m_hand_ovl.c b/src/game/m_hand_ovl.c index cf7402d7..50b858e5 100644 --- a/src/game/m_hand_ovl.c +++ b/src/game/m_hand_ovl.c @@ -126,12 +126,13 @@ static void mHD_hand_position_move(Submenu* submenu) { dY = pos[1] - hand_ovl->info.pos[1]; if (fabsf(dX) > 0.01f || fabsf(dY) > 0.01f) { - f32 dist = sqrtf(dX * dX + dY * dY); - f32 dist2 = dist; - f32 rate_speed = sqrtf(1.0f - rate); - s16 p0 = (GETREG(UREG, 19)); - s16 p1 = (GETREG(UREG, 20)); - f32 calc = add_calc(&dist2, 0.0f, 1.0f - rate_speed, (12.0f + p0 * 0.1f) * 0.5f, (1.0f + p1 * 0.1f) * 0.5f); + f32 dist; + f32 dist2; + f32 calc; + + dist = dist2 = sqrtf(SQ(dX) + SQ(dY)); + dist = dist2; // this second set is necessary for Aus version, seems sus + calc = add_calc(&dist2, 0.0f, CALC_EASE(rate), (12.0f + GETREG(UREG, 19) * 0.1f) * 0.5f, (1.0f + GETREG(UREG, 20) * 0.1f) * 0.5f); if (fabsf(calc) < 0.1f) { if (hand_ovl->info.move_flag == mHD_MOVE_SWITCH_LEFT) { diff --git a/src/game/m_handbill.c b/src/game/m_handbill.c index e5f54df3..a4c0a311 100644 --- a/src/game/m_handbill.c +++ b/src/game/m_handbill.c @@ -94,21 +94,19 @@ extern void mHandbill_Set_free_str_art(int str_num, u8* str, int str_len, int ar } static void mHandbill_CopyString(u8* dst, u8* src, int len) { - for (len; len > 0; len--) { + int i; + + for (i = 0; i < len; i++) { *dst++ = *src++; } } extern int mHandbill_MoveDataCut(u8* data, int buf_size, int dst_idx, int src_idx, int data_len, int fill_type) { int new_len = data_len; - int i; if (dst_idx < src_idx) { - u8* dst = data + dst_idx; - u8* src = data + src_idx; - - for (i = src_idx; i < data_len; i++) { - data[dst_idx] = data[src_idx++]; + for (src_idx; src_idx < data_len; src_idx++) { + data[dst_idx] = data[src_idx]; dst_idx++; } @@ -129,6 +127,7 @@ extern int mHandbill_MoveDataCut(u8* data, int buf_size, int dst_idx, int src_id } } else if (dst_idx > src_idx) { int move_size = data_len - src_idx; + int i; u8* dst; u8* src; @@ -531,10 +530,10 @@ static void mHandbill_Load_SuperStringFromRom(u8* buf, int buf_size, int* header u32 aligned_addr = ALIGN_PREV(super_address, 32); // align to 32 bytes for ARAM DMA u32 data_ofs = super_address - aligned_addr; // calculate offset for desired data u32 size = ALIGN_NEXT(data_ofs + super_size, 32); + int i; int move_size; u8* dst; u8* src; - int i; bzero(buff, 90); _JW_GetResourceAram(aligned_addr, buff, size); @@ -572,18 +571,20 @@ static void mHandbill_Load_PsStringFromRom(u8* buf, int buf_size, int ps_no) { u32 aligned_addr = ALIGN_PREV(ps_address, 32); // align to 32 bytes for ARAM DMA u32 data_ofs = ps_address - aligned_addr; // calculate offset for desired data u32 size = ALIGN_NEXT(data_ofs + ps_size, 32); - int sz; int i; + int sz; u8* dst; + u8* src; _JW_GetResourceAram(aligned_addr, buff, size); /* Move desired data to output buffer */ sz = (int)ps_size < buf_size ? ps_size : buf_size; dst = buf; + src = buff + data_ofs; for (i = 0; i < sz; i++) { - *dst = buff[data_ofs + i]; - dst++; + // *dst = src[data_ofs + i]; + *dst++ = *src++; } /* Initialize remaining buffer to spaces */ @@ -622,8 +623,8 @@ static void mHandbill_Load_MailFromRom(u8* buf, int mail_no) { { int i; int j; - u8* src = &mHandbill_mail_buff[data_ofs]; u8* dst = buf; + u8* src = &mHandbill_mail_buff[data_ofs]; int sz = mHandbill_BODY_LEN; if (mail_size < mHandbill_BODY_LEN) { @@ -726,20 +727,15 @@ static int mHandbillzDMA_body_load(mHandbillzDMA_c* dma_info) { _JW_GetResourceAram(aligned_addr, dma_info->ram_buf, size); if (data_ofs != 0) { + int i; + const int size = dma_info->dma_size; u8* src; u8* dst; - int size; - int i; dst = dma_info->ram_buf; src = dst + data_ofs; - size = dma_info->dma_size; - - for (i = 0; i < size; i++) { - u8 b = *src; - src++; - *dst = b; - dst++; + for (i = 0; i < size; i++, dst++, src++) { + *dst = *src; } } } diff --git a/src/game/m_home.c b/src/game/m_home.c index a67a3395..cf3c6a7a 100644 --- a/src/game/m_home.c +++ b/src/game/m_home.c @@ -482,8 +482,7 @@ extern void mHm_CheckRehouseOrder() { } for (i = 0; i < PLAYER_NUM; i++) { - u32* state_flags = Save_GetPointer(private_data[i].state_flags); - *state_flags &= (~0x200); /* TODO: these need an enum/defines */ + Save_Get(private_data[i].state_flags) &= (~0x200); /* TODO: these need an enum/defines */ } } diff --git a/src/game/m_huusui_room_ovl.c b/src/game/m_huusui_room_ovl.c index 1952c776..ee9bd18a 100644 --- a/src/game/m_huusui_room_ovl.c +++ b/src/game/m_huusui_room_ovl.c @@ -20,10 +20,9 @@ #define mHsRm_MONEY_BAD_PTS 10 #define mHsRm_GOODS_BAD_PTS 5 - typedef struct huusui_room_ftr_info_s { - u8 huusui_type; - u8 has_face; + u8 huusui_type; + u8 has_face; } mHsRm_ftr_info_c; /* table of feng shui data for every item, clearly copy-pasted... should be mHsRm_ftr_info */ @@ -33,277 +32,279 @@ static mHsRm_ftr_info_c mMkRm_ftr_info[FTR_NUM] = { /* maximum unit position for each main floor size */ static int mHsRm_unit_max[mHm_HOMESIZE_NUM - 1] = { - mHsRm_UNIT_MAX_S, /* mHm_HOMESIZE_SMALL */ - mHsRm_UNIT_MAX_M, /* mHm_HOMESIZE_MEDIUM */ - mHsRm_UNIT_MAX_L, /* mHm_HOMESIZE_LARGE */ - mHsRm_UNIT_MAX_L /* mHm_HOMESIZE_UPPER */ + mHsRm_UNIT_MAX_S, /* mHm_HOMESIZE_SMALL */ + mHsRm_UNIT_MAX_M, /* mHm_HOMESIZE_MEDIUM */ + mHsRm_UNIT_MAX_L, /* mHm_HOMESIZE_LARGE */ + mHsRm_UNIT_MAX_L, /* mHm_HOMESIZE_UPPER */ }; /* number of units taken up by each furniture size */ static int mHsRm_unit_value[mRmTp_FTRSIZE_NUM] = { - 1, /* mRmTp_FTRSIZE_1x1 */ - 2, /* mRmTp_FTRSIZE_1x2 */ - 4 /* mRmTp_FTRSIZE_2x2 */ + 1, /* mRmTp_FTRSIZE_1x1 */ + 2, /* mRmTp_FTRSIZE_1x2 */ + 4, /* mRmTp_FTRSIZE_2x2 */ }; /* table indices below are [directions][points] */ -#define mHsRm_WALL_NON (0) /* No wall */ -#define mHsRm_WALL_STH (1 << mHsRm_DIRECTION_SOUTH) /* South wall */ -#define mHsRm_WALL_EST (1 << mHsRm_DIRECTION_EAST) /* East wall */ -#define mHsRm_WALL_NTH (1 << mHsRm_DIRECTION_NORTH) /* North wall */ -#define mHsRm_WALL_WST (1 << mHsRm_DIRECTION_WEST) /* West wall */ -#define mHsRm_WALL_ALL \ - (mHsRm_WALL_STH | mHsRm_WALL_EST | mHsRm_WALL_NTH | mHsRm_WALL_WST) /* any wall */ +#define mHsRm_WALL_NON (0) /* No wall */ +#define mHsRm_WALL_STH (1 << mHsRm_DIRECTION_SOUTH) /* South wall */ +#define mHsRm_WALL_EST (1 << mHsRm_DIRECTION_EAST) /* East wall */ +#define mHsRm_WALL_NTH (1 << mHsRm_DIRECTION_NORTH) /* North wall */ +#define mHsRm_WALL_WST (1 << mHsRm_DIRECTION_WEST) /* West wall */ +#define mHsRm_WALL_ALL (mHsRm_WALL_STH | mHsRm_WALL_EST | mHsRm_WALL_NTH | mHsRm_WALL_WST) /* any wall */ /* money power info table */ static const int money_power_tbl[mHsRm_HUUSUI_NUM][2] = { - { mHsRm_WALL_NON, 0 }, /* mHsRm_HUUSUI_NONE */ - { mHsRm_WALL_WST, 4 }, /* mHsRm_HUUSUI_YELLOW */ - { mHsRm_WALL_NON, 0 }, /* mHsRm_HUUSUI_RED */ - { mHsRm_WALL_NTH, 2 }, /* mHsRm_HUUSUI_ORANGE */ - { mHsRm_WALL_STH, 2 }, /* mHsRm_HUUSUI_GREEN */ - { mHsRm_WALL_ALL, 4 } /* mHsRm_HUUSUI_LUCKY */ + { mHsRm_WALL_NON, 0 }, /* mHsRm_HUUSUI_NONE */ + { mHsRm_WALL_WST, 4 }, /* mHsRm_HUUSUI_YELLOW */ + { mHsRm_WALL_NON, 0 }, /* mHsRm_HUUSUI_RED */ + { mHsRm_WALL_NTH, 2 }, /* mHsRm_HUUSUI_ORANGE */ + { mHsRm_WALL_STH, 2 }, /* mHsRm_HUUSUI_GREEN */ + { mHsRm_WALL_ALL, 4 }, /* mHsRm_HUUSUI_LUCKY */ }; /* goods power info table */ static const int goods_power_tbl[mHsRm_HUUSUI_NUM][2] = { - { mHsRm_WALL_NON, 0 }, /* mHsRm_HUUSUI_NONE */ - { mHsRm_WALL_NON, 0 }, /* mHsRm_HUUSUI_YELLOW */ - { mHsRm_WALL_EST, 8 }, /* mHsRm_HUUSUI_RED */ - { mHsRm_WALL_NTH, 4 }, /* mHsRm_HUUSUI_ORANGE */ - { mHsRm_WALL_STH, 4 }, /* mHsRm_HUUSUI_GREEN */ - { mHsRm_WALL_ALL, 8 } /* mHsRm_HUUSUI_LUCKY */ + { mHsRm_WALL_NON, 0 }, /* mHsRm_HUUSUI_NONE */ + { mHsRm_WALL_NON, 0 }, /* mHsRm_HUUSUI_YELLOW */ + { mHsRm_WALL_EST, 8 }, /* mHsRm_HUUSUI_RED */ + { mHsRm_WALL_NTH, 4 }, /* mHsRm_HUUSUI_ORANGE */ + { mHsRm_WALL_STH, 4 }, /* mHsRm_HUUSUI_GREEN */ + { mHsRm_WALL_ALL, 8 }, /* mHsRm_HUUSUI_LUCKY */ }; /** * @brief Feng Shui scoring algorithm for a single furniture. - * + * * This function checks which side of the room the furniture is on, * along with its orientation. It returns the point score for both * money power and goods power into 'money_power' and 'goods_power'. * The result can be negative if a 'doll'/'item with a face' is facing * the wall. - * + * * @param ftr The actor furniture number * @param ut_x Unit x position * @param ut_z Unit z position * @param money_power Calculated money power for the furniture position * @param goods_power Calculated goods power for the furniture position **/ -static void mHsRm_EvaluateHuusuiPoint_Single(mActor_name_t ftr, int ut_x, int ut_z, int ut_max, int* money_power, int* goods_power) { - int i; - int ftr_idx; - int room_side_bits; - int ut_value; - int rotation_bits; - int huusui_type; - int room_side_tbl[mHsRm_DIRECTION_NUM]; - int rotation_tbl[mHsRm_DIRECTION_NUM]; - mRmTp_FtrPlaceInfoOne_t place_info[mRmTp_FTR_UNIT_MAX]; - int ftr_rot; - int has_face; - int start_ut; +static void mHsRm_EvaluateHuusuiPoint_Single(mActor_name_t ftr, int ut_x, int ut_z, int ut_max, int* money_power, + int* goods_power) { + int i; + int ftr_idx; + int room_side_bits; + int ut_value; + int rotation_bits; + int huusui_type; + int room_side_tbl[mHsRm_DIRECTION_NUM]; + int rotation_tbl[mHsRm_DIRECTION_NUM]; + mRmTp_FtrPlaceInfoOne_t place_info[mRmTp_FTR_UNIT_MAX]; + int ftr_rot; + int has_face; + int start_ut; - *money_power = 0; - *goods_power = 0; + *money_power = 0; + *goods_power = 0; - ftr_idx = mRmTp_FtrItemNo2FtrIdx(ftr); - ftr_rot = FTR_GET_ROTATION(ftr); - huusui_type = mMkRm_ftr_info[ftr_idx].huusui_type; - has_face = mMkRm_ftr_info[ftr_idx].has_face; - ut_value = mHsRm_unit_value[mRmTp_GetFurnitureData(ftr, ut_x, ut_z, place_info)]; /* number of units occupied by this furniture */ + ftr_idx = mRmTp_FtrItemNo2FtrIdx(ftr); + ftr_rot = FTR_GET_ROTATION(ftr); + huusui_type = mMkRm_ftr_info[ftr_idx].huusui_type; + has_face = mMkRm_ftr_info[ftr_idx].has_face; + ut_value = mHsRm_unit_value[mRmTp_GetFurnitureData(ftr, ut_x, ut_z, + place_info)]; /* number of units occupied by this furniture */ - /* maximum top/left position for feng shui */ - if (ut_max == mHsRm_UNIT_MAX_S && ut_value == 1) { - start_ut = 1; - } - else { - start_ut = 2; - } - - for (i = 0; i < mHsRm_DIRECTION_NUM; i++) { - room_side_tbl[i] = 0; - rotation_tbl[i] = 0; - } - - /* loop through all units occupied by the furniture and check feng shui parameters on each unit */ - for (i = 0; i < ut_value; i++) { - if (place_info[i].ut_z <= start_ut) { - room_side_tbl[mHsRm_DIRECTION_NORTH]++; - - if (place_info[i].ut_z <= 1) { - rotation_tbl[mHsRm_DIRECTION_NORTH]++; - } - } - else if (place_info[i].ut_z >= ((ut_max - start_ut) - 1)) { - room_side_tbl[mHsRm_DIRECTION_SOUTH]++; - - if (place_info[i].ut_z >= ut_max - 2) { - rotation_tbl[mHsRm_DIRECTION_SOUTH]++; - } + /* maximum top/left position for feng shui */ + if (ut_max == mHsRm_UNIT_MAX_S && ut_value == 1) { + start_ut = 1; + } else { + start_ut = 2; } - if (place_info[i].ut_x <= start_ut) { - room_side_tbl[mHsRm_DIRECTION_WEST]++; - - if (place_info[i].ut_x <= 1) { - rotation_tbl[mHsRm_DIRECTION_WEST]++; - } - } - else if (place_info[i].ut_x >= ((ut_max - start_ut) - 1)) { - room_side_tbl[mHsRm_DIRECTION_EAST]++; - - if (place_info[i].ut_x >= ut_max - 2) { - rotation_tbl[mHsRm_DIRECTION_EAST]++; - } - } - } - - room_side_bits = 0; - rotation_bits = 0; - - /* log positioning & rotation */ - for (i = 0; i < mHsRm_DIRECTION_NUM; i++) { - /* if all units belonging to this furniture are in the same feng shui room side, add feng shui type */ - if (ut_value == room_side_tbl[i]) { - room_side_bits |= (1 << i); - } - - /* if any of the furnitures units are directly adjecent to a wall, mark it for rotation check */ - if ((ut_value >= 2 && rotation_tbl[i] >= 2) || (ut_value == 1 && rotation_tbl[i] >= 1)) { - rotation_bits |= (1 << i); - } - } - - if (huusui_type == mHsRm_HUUSUI_LUCKY) { - *money_power += mHsRm_MONEY_LUCKY_PTS; - *goods_power += mHsRm_GOODS_LUCKY_PTS; - } - - if (room_side_bits != 0) { for (i = 0; i < mHsRm_DIRECTION_NUM; i++) { - if (huusui_type != mHsRm_HUUSUI_LUCKY) { - /* if the furniture was properly placed entirely in the feng shui area, check points & add */ - if (room_side_bits & (1 << i)) { - if (money_power_tbl[huusui_type][0] & (1 << i)) { - *money_power += money_power_tbl[huusui_type][1]; - } - - if (goods_power_tbl[huusui_type][0] & (1 << i)) { - *goods_power += goods_power_tbl[huusui_type][1]; - } - } - } + room_side_tbl[i] = 0; + rotation_tbl[i] = 0; } - /* If the furniture has a "face" (front side), deduct points if that side is facing the wall */ - if (has_face != 0) { - for (i = 0; i < mHsRm_DIRECTION_NUM; i++) { - /* check is for furniture is directly adjacent to the given wall and the rotation is the same direction as the wall */ - if ((rotation_bits & (1 << i)) && (ftr_rot == i)) { - *money_power -= mHsRm_MONEY_BAD_PTS; - *goods_power -= mHsRm_GOODS_BAD_PTS; + /* loop through all units occupied by the furniture and check feng shui parameters on each unit */ + for (i = 0; i < ut_value; i++) { + if (place_info[i].ut_z <= start_ut) { + room_side_tbl[mHsRm_DIRECTION_NORTH]++; + + if (place_info[i].ut_z <= 1) { + rotation_tbl[mHsRm_DIRECTION_NORTH]++; + } + } else if (place_info[i].ut_z >= ((ut_max - start_ut) - 1)) { + room_side_tbl[mHsRm_DIRECTION_SOUTH]++; + + if (place_info[i].ut_z >= ut_max - 2) { + rotation_tbl[mHsRm_DIRECTION_SOUTH]++; + } + } + + if (place_info[i].ut_x <= start_ut) { + room_side_tbl[mHsRm_DIRECTION_WEST]++; + + if (place_info[i].ut_x <= 1) { + rotation_tbl[mHsRm_DIRECTION_WEST]++; + } + } else if (place_info[i].ut_x >= ((ut_max - start_ut) - 1)) { + room_side_tbl[mHsRm_DIRECTION_EAST]++; + + if (place_info[i].ut_x >= ut_max - 2) { + rotation_tbl[mHsRm_DIRECTION_EAST]++; + } + } + } + + room_side_bits = 0; + rotation_bits = 0; + + /* log positioning & rotation */ + for (i = 0; i < mHsRm_DIRECTION_NUM; i++) { + /* if all units belonging to this furniture are in the same feng shui room side, add feng shui type */ + if (ut_value == room_side_tbl[i]) { + room_side_bits |= (1 << i); + } + + /* if any of the furnitures units are directly adjecent to a wall, mark it for rotation check */ + if ((ut_value >= 2 && rotation_tbl[i] >= 2) || (ut_value == 1 && rotation_tbl[i] >= 1)) { + rotation_bits |= (1 << i); + } + } + + if (huusui_type == mHsRm_HUUSUI_LUCKY) { + *money_power += mHsRm_MONEY_LUCKY_PTS; + *goods_power += mHsRm_GOODS_LUCKY_PTS; + } + + if (room_side_bits != 0) { + for (i = 0; i < mHsRm_DIRECTION_NUM; i++) { + if (huusui_type != mHsRm_HUUSUI_LUCKY) { + /* if the furniture was properly placed entirely in the feng shui area, check points & add */ + if (room_side_bits & (1 << i)) { + if (money_power_tbl[huusui_type][0] & (1 << i)) { + *money_power += money_power_tbl[huusui_type][1]; + } + + if (goods_power_tbl[huusui_type][0] & (1 << i)) { + *goods_power += goods_power_tbl[huusui_type][1]; + } + } + } + } + + /* If the furniture has a "face" (front side), deduct points if that side is facing the wall */ + if (has_face != 0) { + for (i = 0; i < mHsRm_DIRECTION_NUM; i++) { + /* check is for furniture is directly adjacent to the given wall and the rotation is the same direction + * as the wall */ + if ((rotation_bits & (1 << i)) && (ftr_rot == i)) { + *money_power -= mHsRm_MONEY_BAD_PTS; + *goods_power -= mHsRm_GOODS_BAD_PTS; + } + } } - } } - } } /** * @brief Scores an entire room's Feng Shui. - * + * * @param layers Pointer to array of mHm_lyr_c room layers to score (main & secondary) * @param ut_max The maximum unit position (both x & z) for the room's size * @param money_power Calculated room money power * @param goods_power Calculated room goods power **/ static void mHsRm_EvaluateHuusuiPoint(mHm_lyr_c** layers, int ut_max, int* money_power, int* goods_power) { - int room_money_power; - int room_goods_power; + mActor_name_t item_no; + int room_money_power; + int room_goods_power; + int lyr; + int ut_x; + int ut_z; + int item_money_power; + int item_goods_power; + mActor_name_t* fg_p_top; + int z; + + room_money_power = 0; + room_goods_power = 0; - int lyr; - int ut_x; - int ut_z; + /* loop through each unit on both main & secondary layers and score each ftr */ + for (lyr = 0; lyr < 2; lyr++) { + fg_p_top = (mActor_name_t*)layers[lyr]; + for (ut_z = 0; ut_z < ut_max; ut_z++) { + int z = ut_z * UT_X_NUM; - room_money_power = 0; - room_goods_power = 0; - - /* loop through each unit on both main & secondary layers and score each ftr */ - for (lyr = 0; lyr < 2; lyr++) { - mHm_lyr_c* layer = layers[lyr]; - for (ut_z = 0; ut_z < ut_max; ut_z++) { - for (ut_x = 0; ut_x < ut_max; ut_x++) { - mActor_name_t item_no = layer->items[ut_z][ut_x]; - if (ITEM_IS_FTR(item_no)) { - int item_money_power; - int item_goods_power; - - mHsRm_EvaluateHuusuiPoint_Single(item_no, ut_x, ut_z, ut_max, &item_money_power, &item_goods_power); - room_money_power += item_money_power; - room_goods_power += item_goods_power; + for (ut_x = 0; ut_x < ut_max; ut_x++) { + item_no = *((fg_p_top + z + ut_x)); + if (ITEM_IS_FTR(item_no)) { + mHsRm_EvaluateHuusuiPoint_Single(item_no, ut_x, ut_z, ut_max, &item_money_power, &item_goods_power); + room_money_power += item_money_power; + room_goods_power += item_goods_power; + } + } } - } } - } - *money_power += room_money_power; - *goods_power += room_goods_power; + *money_power += room_money_power; + *goods_power += room_goods_power; } /** * @brief Main Feng Shui scoring function. Will score all three rooms in house * depending on house size. - * + * * @param player_no The index of the player whose house will be scored for Feng Shui **/ extern void mHsRm_HuusuiRoomOvl(int player_no) { - int ut_max; - mHm_hs_c* home; - int money_power; - int goods_power; - mHm_lyr_c* layers[2]; - f32 real_goods_power; + int ut_max; + mHm_hs_c* home; + int money_power; + int goods_power; + mHm_lyr_c* layers[2]; + f32 real_goods_power; - home = Save_Get(homes + mHS_get_arrange_idx(player_no)); - money_power = 0; - goods_power = 0; + home = Save_Get(homes + mHS_get_arrange_idx(player_no)); + money_power = 0; + goods_power = 0; - /* Evaluate the main room first */ - ut_max = mHsRm_unit_max[home->size_info.size]; - layers[0] = &home->floors[mHm_ROOM_MAIN].layer_main; - layers[1] = &home->floors[mHm_ROOM_MAIN].layer_secondary; - mHsRm_EvaluateHuusuiPoint(layers, ut_max, &money_power, &goods_power); + /* Evaluate the main room first */ + ut_max = mHsRm_unit_max[home->size_info.size]; + layers[0] = &home->floors[mHm_ROOM_MAIN].layer_main; + layers[1] = &home->floors[mHm_ROOM_MAIN].layer_secondary; + mHsRm_EvaluateHuusuiPoint(layers, ut_max, &money_power, &goods_power); - /* Evaluate the second floor next if it exists */ - if (home->size_info.size == mHm_HOMESIZE_UPPER) { - layers[0] = &home->floors[mHm_ROOM_UPPER].layer_main; - layers[1] = &home->floors[mHm_ROOM_UPPER].layer_secondary; - mHsRm_EvaluateHuusuiPoint(layers, mHsRm_UNIT_MAX_UPPER, &money_power, &goods_power); - } + /* Evaluate the second floor next if it exists */ + if (home->size_info.size == mHm_HOMESIZE_UPPER) { + layers[0] = &home->floors[mHm_ROOM_UPPER].layer_main; + layers[1] = &home->floors[mHm_ROOM_UPPER].layer_secondary; + mHsRm_EvaluateHuusuiPoint(layers, mHsRm_UNIT_MAX_UPPER, &money_power, &goods_power); + } - /* Finally, evaluate the basement if it exists */ - if (home->flags.has_basement == TRUE) { - layers[0] = &home->floors[mHm_ROOM_BASEMENT].layer_main; - layers[1] = &home->floors[mHm_ROOM_BASEMENT].layer_secondary; - mHsRm_EvaluateHuusuiPoint(layers, mHsRm_UNIT_MAX_BASEMENT, &money_power, &goods_power); - } + /* Finally, evaluate the basement if it exists */ + if (home->flags.has_basement == TRUE) { + layers[0] = &home->floors[mHm_ROOM_BASEMENT].layer_main; + layers[1] = &home->floors[mHm_ROOM_BASEMENT].layer_secondary; + mHsRm_EvaluateHuusuiPoint(layers, mHsRm_UNIT_MAX_BASEMENT, &money_power, &goods_power); + } - /* Goods power is clamed to its upper bound of 40 */ - if (goods_power > mHsRm_GOODS_POWER_MAX) { - goods_power = mHsRm_GOODS_POWER_MAX; - } + /* Goods power is clamed to its upper bound of 40 */ + if (goods_power > mHsRm_GOODS_POWER_MAX) { + goods_power = mHsRm_GOODS_POWER_MAX; + } - /* Adjust goods power by dividing it in half and rounding up */ - real_goods_power = (f32)goods_power * 0.5f; - goods_power = real_goods_power; + /* Adjust goods power by dividing it in half and rounding up */ + real_goods_power = (f32)goods_power * 0.5f; + goods_power = real_goods_power; - /* Always round up if there's any fractional part to goods_power */ - real_goods_power -= goods_power; - if (real_goods_power > 0.0f) { - goods_power++; - } + /* Always round up if there's any fractional part to goods_power */ + real_goods_power -= goods_power; + if (real_goods_power > 0.0f) { + goods_power++; + } - Common_Set(money_power, money_power); - Common_Set(goods_power, goods_power); + Common_Set(money_power, money_power); + Common_Set(goods_power, goods_power); } diff --git a/src/game/m_inventory_ovl.c b/src/game/m_inventory_ovl.c index 63cc66d6..9e59ec05 100644 --- a/src/game/m_inventory_ovl.c +++ b/src/game/m_inventory_ovl.c @@ -1604,17 +1604,16 @@ static int mIV_is_mark_check(mIV_Ovl_c* inv_ovl, int idx) { extern Gfx inv_item_mode[]; static void mIV_set_item(Submenu* submenu, mSM_MenuInfo_c* menu_info, GRAPH* graph, f32 pos_x, f32 pos_y) { - mTG_Ovl_c* tag_ovl; - mTG_tag_c* tag; mIV_Ovl_c* inv_ovl; mActor_name_t* item; u8* scale_type; + mTG_tag_c* tag; int i; int anim_frame; f32 hand_pos[2]; f32 scale; int no_wc_flag; - + tag = &submenu->overlay->tag_ovl->tags[0]; inv_ovl = submenu->overlay->inventory_ovl; item = Now_Private->inventory.pockets; @@ -1653,8 +1652,8 @@ static void mIV_set_item(Submenu* submenu, mSM_MenuInfo_c* menu_info, GRAPH* gra } case mIV_ITEM_SCALE_TYPE_SHRINK: { - anim_frame = 70 - inv_ovl->remove_timer; scale = (f32)inv_ovl->remove_timer * (1.0f / 12.0f); + anim_frame = 70 - inv_ovl->remove_timer; if (anim_frame >= 6) { anim_frame = 5; @@ -1663,10 +1662,10 @@ static void mIV_set_item(Submenu* submenu, mSM_MenuInfo_c* menu_info, GRAPH* gra } default: { - anim_frame = 0; scale = 1.0f - (f32)(inv_ovl->remove_timer - 14 - (*scale_type - mIV_ITEM_SCALE_TYPE_GROW) * 14) * (1.0f / 12.0f); + anim_frame = 0; break; } } @@ -1677,8 +1676,8 @@ static void mIV_set_item(Submenu* submenu, mSM_MenuInfo_c* menu_info, GRAPH* gra scale = 0.0f; } } else { - anim_frame = 0; scale = 1.0f; + anim_frame = 0; } /* @BUG - they compare int (anim_frame) to float (0.0f) here instead of just 0 */ @@ -1689,7 +1688,7 @@ static void mIV_set_item(Submenu* submenu, mSM_MenuInfo_c* menu_info, GRAPH* gra submenu->overlay->draw_item_proc( graph, pos_x + hand_pos[0], pos_y + hand_pos[1], scale, *item, - ((Now_Private->inventory.item_conditions >> (i * 2)) & mPr_ITEM_COND_PRESENT) != 0, + (NowPrivate_GetItemCond(i) & mPr_ITEM_COND_PRESENT) != 0, !no_wc_flag && (inv_ovl->selectable_item_bitfield & (1 << i)), anim_frame, FALSE, mIV_is_mark_check(inv_ovl, i)); } diff --git a/src/game/m_kankyo.c b/src/game/m_kankyo.c index fd9c79e6..94bf5ff4 100644 --- a/src/game/m_kankyo.c +++ b/src/game/m_kankyo.c @@ -1504,8 +1504,9 @@ static void mEnv_ChangeRGBLight(u8* dst, u8* src_nxt_w0, u8* src_nxt_w1, u8* src int i; for (i = 0; i < 3; i++) { - dst[0] = weather_change_bias * (f1 * (src_nxt_w0[0] + f0 * ((f32)src_nxt_w1[0] - (f32)src_nxt_w0[0]))) + - inverse_weather_change_bias * (f1 * (src_now_w0[0] + f0 * ((f32)src_now_w1[0] - (f32)src_now_w0[0]))); + *dst = + weather_change_bias * (f1 * (*src_nxt_w0 + f0 * ((f32)*src_nxt_w1 - (f32)*src_nxt_w0))) + + inverse_weather_change_bias * (f1 * (*src_now_w0 + f0 * ((f32)*src_now_w1 - (f32)*src_now_w0))); dst++; src_nxt_w0++; @@ -2113,7 +2114,7 @@ extern void mEnv_ManagePointLight(GAME_PLAY* play, Kankyo* kankyo, Global_light* static void mEnv_ManageChangeWeatherEnvRate() { if (l_mEnv_electric_light.now_weather != l_mEnv_electric_light.next_weather) { - l_mEnv_electric_light.change_weather_env_rate += (1.0f / 600.0f); + l_mEnv_electric_light.change_weather_env_rate += mEnv_CHANGE_WEATHER_ENV_RATE; if (l_mEnv_electric_light.change_weather_env_rate >= 1.0f) { l_mEnv_electric_light.change_weather_env_rate = 1.0f; @@ -2203,7 +2204,11 @@ static int mEnv_CheckNpcRoomPointLightNiceStatus() { schedule = Common_GetPointer(npc_schedule[ANIMAL_NUM_MAX]); if (schedule != NULL) { - if (schedule->current_type == mNPS_SCHED_IN_HOUSE && animal->is_home == TRUE && + if ( +#if VERSION < VER_GAFU01_00 + schedule->current_type == mNPS_SCHED_IN_HOUSE && +#endif + animal->is_home == TRUE && (Common_Get(time).now_sec < mEnv_NPC_LIGHTS_OFF_TIME || Common_Get(time).now_sec >= mEnv_NPC_LIGHTS_ON_TIME)) { return TRUE; @@ -2216,7 +2221,11 @@ static int mEnv_CheckNpcRoomPointLightNiceStatus() { schedule = mNPS_get_schedule_area(&animal->id); if (schedule != NULL) { - if (schedule->current_type == mNPS_SCHED_IN_HOUSE && animal->is_home == TRUE && + if ( +#if VERSION < VER_GAFU01_00 + schedule->current_type == mNPS_SCHED_IN_HOUSE && +#endif + animal->is_home == TRUE && (Common_Get(time).now_sec < mEnv_NPC_LIGHTS_OFF_TIME || Common_Get(time).now_sec >= mEnv_NPC_LIGHTS_ON_TIME)) { return TRUE; @@ -2394,8 +2403,8 @@ extern int mEnv_ReservePointLight(GAME_PLAY* play, xyz_t* pos, u8 r, u8 g, u8 b, if (l_mEnv_electric_light.point_light_list_buf[i] == NULL) { point_light = &l_mEnv_electric_light.point_lights[i]; - Light_point_ct(point_light, pos->x, pos->y, pos->z, r, g, b, power); - list = Global_light_list_new((GAME*)play, &play->global_light, point_light); + Light_point_ct(&l_mEnv_electric_light.point_lights[i], pos->x, pos->y, pos->z, r, g, b, power); + list = Global_light_list_new((GAME*)play, &play->global_light, &l_mEnv_electric_light.point_lights[i]); if (list != NULL) { l_mEnv_electric_light.point_light_list_buf[i] = list; diff --git a/src/game/m_land.c b/src/game/m_land.c index e846c2bc..319482c6 100644 --- a/src/game/m_land.c +++ b/src/game/m_land.c @@ -2,10 +2,10 @@ * @file m_land.c * @brief Functions and definitions for handling town name, town ID, and * determining if a player is a foreigner or not. - * + * * This file contains functions for manipulating town names and IDs, checking * if a player is a foreigner, and initializing land and home data. - * + * * Note: "Mura" (むら/村) is the Japanese word for village. Functions which contain that * word were used to concatenate the town name with it. Since this does not happen * in inernational releases, these functions essentially do nothing. @@ -49,7 +49,7 @@ static int l_mld_start_flag = FALSE; * @brief Turns on the start flag. */ extern void mLd_StartFlagOn() { - l_mld_start_flag = TRUE; + l_mld_start_flag = TRUE; } /** @@ -57,7 +57,7 @@ extern void mLd_StartFlagOn() { * @return The value of l_mld_start_flag. */ extern int mLd_CheckStartFlag() { - return l_mld_start_flag; + return l_mld_start_flag; } /** @@ -65,21 +65,21 @@ extern int mLd_CheckStartFlag() { * @param land_name Pointer to the town name. * @return TRUE if the town name is empty, FALSE otherwise. */ -extern int mLd_NullCheckLandName(const u8* land_name) { - int null_name = FALSE; - int i; - - for (i = 0; i < LAND_NAME_SIZE; i++) { - if (*land_name != CHAR_SPACE) { - break; - } - land_name++; - } +extern int mLd_NullCheckLandName(u8* land_name) { + int null_name = FALSE; + int i; - if (i == LAND_NAME_SIZE) { - null_name = TRUE; - } - return null_name; + for (i = 0; i < LAND_NAME_SIZE; i++) { + if (*land_name != CHAR_SPACE) { + break; + } + land_name++; + } + + if (i == LAND_NAME_SIZE) { + null_name = TRUE; + } + return null_name; } /** @@ -88,12 +88,12 @@ extern int mLd_NullCheckLandName(const u8* land_name) { * @return TRUE if the land ID has the correct bitmask, FALSE otherwise. */ extern int mLd_CheckId(u16 land_id) { - int res = FALSE; - if (mLd_CHECK_ID(land_id)) { - res = TRUE; - } + int res = FALSE; + if (mLd_CHECK_ID(land_id)) { + res = TRUE; + } - return res; + return res; } /** @@ -103,13 +103,13 @@ extern int mLd_CheckId(u16 land_id) { * @return TRUE if both town names are equal, FALSE otherwise. */ extern int mLd_CheckCmpLandName(u8* name_a, u8* name_b) { - int equal = FALSE; + int equal = FALSE; - if (mLd_NullCheckLandName(name_a) == FALSE && mLd_NullCheckLandName(name_b) == FALSE) { - equal = mem_cmp(name_a, name_b, LAND_NAME_SIZE); - } + if (mLd_NullCheckLandName(name_a) == FALSE && mLd_NullCheckLandName(name_b) == FALSE) { + equal = mem_cmp(name_a, name_b, LAND_NAME_SIZE); + } - return equal; + return equal; } /** @@ -121,13 +121,13 @@ extern int mLd_CheckCmpLandName(u8* name_a, u8* name_b) { * @return TRUE if both town names and IDs are equal, FALSE otherwise. */ extern int mLd_CheckCmpLand(u8* name_a, u16 id_a, u8* name_b, u16 id_b) { - int equal = FALSE; + int equal = FALSE; - if (id_a == id_b && mLd_CheckCmpLandName(name_a, name_b) == TRUE) { - equal = TRUE; - } + if (id_a == id_b && mLd_CheckCmpLandName(name_a, name_b) == TRUE) { + equal = TRUE; + } - return equal; + return equal; } /** @@ -135,7 +135,7 @@ extern int mLd_CheckCmpLand(u8* name_a, u16 id_a, u8* name_b, u16 id_b) { * @param name Pointer to the town name. */ extern void mLd_ClearLandName(u8* name) { - mem_clear(name, LAND_NAME_SIZE, CHAR_SPACE); + mem_clear(name, LAND_NAME_SIZE, CHAR_SPACE); } /** @@ -144,7 +144,7 @@ extern void mLd_ClearLandName(u8* name) { * @param src Pointer to the source town name. */ extern void mLd_CopyLandName(u8* dst, u8* src) { - mem_copy(dst, src, LAND_NAME_SIZE); + mem_copy(dst, src, LAND_NAME_SIZE); } /** @@ -154,14 +154,14 @@ extern void mLd_CopyLandName(u8* dst, u8* src) { * @return The length of the new town name with "Mura" (むら/村) added. */ extern int mLd_AddMuraString(u8* name, int name_len) { - u8 buf[16]; - int size; + u8 buf[16]; + int size; - mString_Load_StringFromRom(buf, 16, 484); /* TODO: str_no should probably be enum or something */ - size = mMsg_Get_Length_String(buf, 16); - mem_copy(name + name_len, buf, size); + mString_Load_StringFromRom(buf, 16, 484); /* TODO: str_no should probably be enum or something */ + size = mMsg_Get_Length_String(buf, 16); + mem_copy(name + name_len, buf, size); - return size + name_len; + return size + name_len; } /** @@ -169,19 +169,19 @@ extern int mLd_AddMuraString(u8* name, int name_len) { * @param buf Buffer to store the town name with "Mura" (むら/村) added. */ extern int mLd_GetLandNameStringAddMura(u8* buf) { - int mura_size; - int i; - - u8* name = mLd_GetLandName(); - int size = mMsg_Get_Length_String(name, LAND_NAME_SIZE); - mem_copy(buf, name, size); - mura_size = mLd_AddMuraString(buf, size); + int mura_size; + int i; - for (i = mura_size; i < LAND_NAME_MURA_SIZE; i++) { - buf[i] = CHAR_SPACE; - } + u8* name = mLd_GetLandName(); + int size = mMsg_Get_Length_String(name, LAND_NAME_SIZE); + mem_copy(buf, name, size); + mura_size = mLd_AddMuraString(buf, size); - return mura_size; + for (i = mura_size; i < LAND_NAME_MURA_SIZE; i++) { + buf[i] = CHAR_SPACE; + } + + return mura_size; } /** @@ -190,19 +190,19 @@ extern int mLd_GetLandNameStringAddMura(u8* buf) { * @param free_str_no The number of the free string. */ extern void mLd_SetFreeStrLandMuraName(u8* name, int free_str_no) { - u8 str[16]; - int name_len; - int mura_len; - int i; + u8 str[16]; + int name_len; + int mura_len; + int i; - for (i = 0; i < LAND_NAME_MURA_SIZE; i++) { - str[i] = CHAR_SPACE; - } + for (i = 0; i < LAND_NAME_MURA_SIZE; i++) { + str[i] = CHAR_SPACE; + } - name_len = mMsg_Get_Length_String(name, LAND_NAME_SIZE); - mem_copy(str, name, name_len); - mura_len = mLd_AddMuraString(str, name_len); - mMsg_Set_free_str(mMsg_Get_base_window_p(), free_str_no, str, mura_len); + name_len = mMsg_Get_Length_String(name, LAND_NAME_SIZE); + mem_copy(str, name, name_len); + mura_len = mLd_AddMuraString(str, name_len); + mMsg_Set_free_str(mMsg_Get_base_window_p(), free_str_no, str, mura_len); } /** @@ -210,7 +210,7 @@ extern void mLd_SetFreeStrLandMuraName(u8* name, int free_str_no) { * @return Pointer to the town name. */ extern u8* mLd_GetLandName() { - return Save_Get(land_info.name); + return Save_Get(land_info.name); } /** @@ -218,7 +218,7 @@ extern u8* mLd_GetLandName() { * @return The newly generated land ID. */ extern u16 mLd_MakeLandId() { - return (int)(fqrand() * 256.0f) | mLd_BITMASK; + return (int)(fqrand() * 256.0f) | mLd_BITMASK; } /** @@ -227,12 +227,12 @@ extern u16 mLd_MakeLandId() { * @return TRUE if the player is a foreigner, FALSE otherwise. */ extern int mLd_PlayerManKindCheckNo(u8 player_no) { - int foreigner = TRUE; - if (player_no < PLAYER_NUM) { - foreigner = FALSE; - } + int foreigner = TRUE; + if (player_no < PLAYER_NUM) { + foreigner = FALSE; + } - return foreigner; + return foreigner; } /** @@ -240,7 +240,7 @@ extern int mLd_PlayerManKindCheckNo(u8 player_no) { * @return TRUE if the current player is a foreigner, FALSE otherwise. */ extern int mLd_PlayerManKindCheck() { - return mLd_PlayerManKindCheckNo(Common_Get(player_no)); + return mLd_PlayerManKindCheckNo(Common_Get(player_no)); } /* @@ -250,23 +250,23 @@ extern int mLd_PlayerManKindCheck() { * @return TRUE if the town name and ID match the current town, FALSE otherwise. */ extern int mLd_CheckThisLand(u8* other_name, u16 other_id) { - return mLd_CheckCmpLand(other_name, other_id, Save_Get(land_info.name), Save_Get(land_info.id)); + return mLd_CheckCmpLand(other_name, other_id, Save_Get(land_info.name), Save_Get(land_info.id)); } /** * @brief Initializes the land information in the save data. */ extern void mLd_LandInfoInit() { - mLd_land_info_c* land_info = Save_GetPointer(land_info); + mLd_land_info_c* land_info = Save_GetPointer(land_info); - land_info->id = mLd_MakeLandId(); - land_info->exists = TRUE; + land_info->id = mLd_MakeLandId(); + land_info->exists = TRUE; } /** * @brief Initializes the land data and clears all home information. */ extern void mLd_LandDataInit() { - mLd_LandInfoInit(); - mHm_ClearAllHomeInfo(); + mLd_LandInfoInit(); + mHm_ClearAllHomeInfo(); } diff --git a/src/game/m_mail_password_check.c b/src/game/m_mail_password_check.c index 612f542a..cf9bdcd6 100644 --- a/src/game/m_mail_password_check.c +++ b/src/game/m_mail_password_check.c @@ -321,17 +321,19 @@ static void mMpswd_adjust_letter(u8* pswd_str) { int i; for (i = 0; i < mMpswd_PASSWORD_STR_LEN; i++) { - switch (pswd_str[i]) { + switch (*pswd_str) { case CHAR_ZERO: { - pswd_str[i] = CHAR_O; // 0 -> O + *pswd_str = CHAR_O; // 0 -> O break; } case CHAR_ONE: { - pswd_str[i] = CHAR_l; // 1 -> l + *pswd_str = CHAR_l; // 1 -> l break; } } + + pswd_str++; } } @@ -474,7 +476,7 @@ static void mMpswd_chg_8bits_code(u8* eightbits, u8* sixbits) { } while (TRUE); } -static void mMpswd_get_RSA_key_code(int* p, int* q, int* r, int** select_table, const u8* pswd) { +static void mMpswd_get_RSA_key_code(int* p, int* q, int* r, int** select_table, u8* pswd) { u32 rsa_info = pswd[mMpswd_RSA_INFO_IDX]; int p_idx = rsa_info & 3; int q_idx = (rsa_info >> 2) & 3; @@ -563,15 +565,22 @@ static void mMpswd_decode_RSA_cipher(u8* pswd) { pow = 1; /* Calculate exponent d for decryption */ - do { + for (pow = 1; ; pow++) { n = pow * pq_1 + 1; if (n % r == 0) { r = n / r; break; } + } + // do { + // n = pow * pq_1 + 1; + // if (n % r == 0) { + // r = n / r; + // break; + // } - pow++; - } while (TRUE); + // pow++; + // } while (TRUE); rsa_keysave = pswd[mMpswd_RSA_KEYSAVE_IDX]; for (i = 0; i < 8; i++) { @@ -920,6 +929,7 @@ extern int mMpswd_password_zuru_check(mMpswd_password_c* password) { int cheated = TRUE; if (password->type < mMpswd_CODETYPE_NUM) { + u8* str_p; int checksum = 0; int i; diff --git a/src/game/m_map_ovl.c b/src/game/m_map_ovl.c index 78338712..31e8151f 100644 --- a/src/game/m_map_ovl.c +++ b/src/game/m_map_ovl.c @@ -404,36 +404,42 @@ static mActor_name_t mMP_GetFgBlockName(mMP_Ovl_c* map_ovl, int block_x, int blo } static void mMP_set_house_data(mMP_Ovl_c* map_ovl, mSM_MenuInfo_c* menu) { - static u8 akiya_str[PLAYER_NAME_LEN] = { CHAR_f, CHAR_r, CHAR_e, CHAR_e, - CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE }; + static u8 akiya_str[PLAYER_NAME_LEN] = "free "; - mMP_ResidentInfo_c* resident_p = &map_ovl->player_info[0]; - mMP_LabelInfo_c* player_block_label = &map_ovl->label_info[1][2]; - Private_c* priv = Save_Get(private_data); - mMP_HousePos_c* house_pos2; - Animal_c* animal = Save_Get(animals); - int residents; + mMP_ResidentInfo_c* resident_p; + mMP_LabelInfo_c* block_label; + mMP_HousePos_c* house_pos; + mMP_HousePos_c* house_pos_top; + mMP_HousePos_Entry_c* pos_info; + Private_c* priv; + Animal_c* animal; + Anmhome_c* home; int i; + int j; + int residents; + mActor_name_t fgblock_name; + + priv = Save_Get(private_data); + animal = Save_Get(animals); + resident_p = &map_ovl->player_info[0]; + block_label = &map_ovl->label_info[1][2]; /* Process player resident info first */ - - player_block_label->label_cnt = PLAYER_NUM; - player_block_label->label_no = mMP_LABEL_PLAYER; + block_label->label_cnt = PLAYER_NUM; + block_label->label_no = mMP_LABEL_PLAYER; residents = 0; - for (i = 0; i < PLAYER_NUM; i++) { + for (i = 0; i < PLAYER_NUM; i++, priv++) { if (mPr_CheckPrivate(priv) == TRUE && (Common_Get(now_private) != priv || mEv_CheckFirstIntro() == FALSE)) { mPr_CopyPlayerName(resident_p->name, priv->player_ID.player_name); resident_p->sex = priv->gender; resident_p->house_layer = 0; resident_p->house_idx = 0; - player_block_label->residents[residents] = resident_p; + block_label->residents[residents] = resident_p; residents++; resident_p++; } - - priv++; } for (residents; residents < PLAYER_NUM; residents++, resident_p++) { @@ -441,83 +447,64 @@ static void mMP_set_house_data(mMP_Ovl_c* map_ovl, mSM_MenuInfo_c* menu) { resident_p->sex = -1; resident_p->house_layer = 0; - player_block_label->residents[residents] = resident_p; + block_label->residents[residents] = resident_p; } - house_pos2 = mMP_house_pos_list; + house_pos_top = mMP_house_pos_list; /* Process animal resident info next */ resident_p = &map_ovl->animal_info[0]; residents = 0; for (i = 0; i < ANIMAL_NUM_MAX; i++, animal++, resident_p++) { if (mNpc_CheckFreeAnimalInfo(animal) == FALSE) { - Anmhome_c* home = &animal->home_info; + home = &animal->home_info; mNpc_GetNpcWorldNameAnm(resident_p->name, &animal->id); resident_p->sex = mNpc_GetLooks2Sex(animal->id.looks); resident_p->house_layer = mMP_check_layer(Common_Get(npclist[i].house_position.y)); - { - mActor_name_t fgblock_name = mMP_GetFgBlockName(map_ovl, home->block_x, home->block_z); - mMP_HousePos_c* house_pos = house_pos2; - mMP_HousePos_Entry_c* pos_info = house_pos[0].entries; + fgblock_name = mMP_GetFgBlockName(map_ovl, home->block_x, home->block_z); + house_pos = house_pos_top; + pos_info = house_pos[0].entries; - for (house_pos; house_pos->fgblock_name != 0x03B8; house_pos++) { - if (fgblock_name == house_pos->fgblock_name) { - int j; - pos_info = house_pos->entries; + for (house_pos; house_pos->fgblock_name != 0x03B8; house_pos++) { + if (fgblock_name == house_pos->fgblock_name) { + pos_info = house_pos->entries; - for (j = 0; j < 3; j++, pos_info++) { - if (pos_info->ut_x == home->ut_x && pos_info->ut_z == home->ut_z - 1) { - break; - } + for (j = 0; j < 3; j++, pos_info++) { + if (pos_info->ut_x == home->ut_x && pos_info->ut_z == home->ut_z - 1) { + break; } - - if (j == 3) { - pos_info = &house_pos->entries[0]; // default - } - - break; } + + if (j == 3) { + pos_info = &house_pos->entries[0]; // default + } + + break; } - - resident_p->house_idx = pos_info->idx; } - { - int bx = home->block_x - 1; - int bz = home->block_z - 1; - mMP_LabelInfo_c* label_info = &map_ovl->label_info[bz][bx]; + resident_p->house_idx = pos_info->idx; - label_info->residents[label_info->label_cnt] = resident_p; - label_info->label_cnt++; - label_info->label_no = mMP_LABEL_NPC; - } + block_label = &map_ovl->label_info[home->block_z - 1][home->block_x - 1]; + block_label->residents[block_label->label_cnt] = resident_p; + block_label->label_cnt++; + block_label->label_no = mMP_LABEL_NPC; } } /* Sort villager houses by layer, with lower layers coming first */ - { - mMP_ResidentInfo_c* resident; - mMP_ResidentInfo_c* next_resident; - mMP_LabelInfo_c* label_info = (mMP_LabelInfo_c*)map_ovl->label_info; - for (i = 0; i < FG_BLOCK_TOTAL_NUM; i++) { - if (label_info->label_no == mMP_LABEL_NPC && label_info->label_cnt > 1) { - - int j; - for (j = 0; j < label_info->label_cnt - 1; j++) { - - resident = label_info->residents[j]; - next_resident = label_info->residents[j + 1]; - - if (resident->house_layer > next_resident->house_layer) { - label_info->residents[j] = next_resident; - label_info->residents[j + 1] = resident; - j = -1; - } + block_label = (mMP_LabelInfo_c*)map_ovl->label_info; + for (i = 0; i < FG_BLOCK_TOTAL_NUM; i++, block_label++) { + if (block_label->label_no == mMP_LABEL_NPC && block_label->label_cnt > 1) { + for (j = 0; j < block_label->label_cnt - 1; j++) { + if (block_label->residents[j]->house_layer > block_label->residents[j + 1]->house_layer) { + resident_p = block_label->residents[j]; + block_label->residents[j] = block_label->residents[j + 1]; + block_label->residents[j + 1] = resident_p; + j = -1; } } - - label_info++; } } } @@ -603,9 +590,8 @@ static void mMP_set_init_data(mMP_Ovl_c* map_ovl, mSM_MenuInfo_c* menu_info) { mMP_set_map_texture_pal(map_ovl); - for (i = 0; i < FG_BLOCK_TOTAL_NUM; i++) { + for (i = 0; i < FG_BLOCK_TOTAL_NUM; i++, label_info++) { label_info->label_cnt = 0; - label_info++; } mMP_set_house_data(map_ovl, menu_info); diff --git a/src/game/m_mark_room_ovl.c b/src/game/m_mark_room_ovl.c index 91ef9abd..3d9ddfbb 100644 --- a/src/game/m_mark_room_ovl.c +++ b/src/game/m_mark_room_ovl.c @@ -3034,7 +3034,8 @@ static void mMkRm_EvaluateCompleteObstacle(int* points, mActor_name_t** layer_ut mActor_name_t item = ut_info[(ut_z * UT_Z_NUM) + ut_x]; if (ITEM_IS_FTR(item)) { - int series = mMkRm_ftr_info[mRmTp_FtrItemNo2FtrIdx(item)].series; + int ftr_no = mRmTp_FtrItemNo2FtrIdx(item); + int series = mMkRm_ftr_info[ftr_no].series; if (series != theme_idx) { obstacles++; @@ -3236,8 +3237,8 @@ static int mMkRm_EvaluateThemeSeriesComplete(int* points, int* complete_theme, m if (ftr_in_theme != 0) { u32 perfect_bit; int j; - int wall_floor_idx = mMkRm_series_info[i].wall_floor_idx; u32 complete_bit = mMkRm_search_table[i]; + int wall_floor_idx = mMkRm_series_info[i].wall_floor_idx; #ifndef IMPROVEMENTS perfect_bit = 0; @@ -3464,16 +3465,15 @@ static void mMkRm_InitSearchTable() { u32* search_table_p = mMkRm_search_table; int series; - for (series = 0; series < mMkRm_SERIES_NUM; series++) { + for (series = 0; series < mMkRm_SERIES_NUM; series++, search_table_p++) { search_table_p[0] = 0; - search_table_p++; } } static void mMkRm_AssignIdxInGroup_BaseSeries(int series) { + int i; int group_idx = mMkRm_NOT_NECESSITY; int num_ftr = 0; - int i; for (i = 0; i < FTR_NUM; i++) { if (series == mMkRm_ftr_info[i].series) { @@ -3490,9 +3490,9 @@ static void mMkRm_AssignIdxInGroup_BaseSeries(int series) { } static void mMkRm_AssignIdxInGroup_ThemeSeries(int series) { + int i; int group_idx = 0; int num_ftr = 0; - int i; for (i = 0; i < FTR_NUM; i++) { if (series == mMkRm_ftr_info[i].series) { @@ -3506,9 +3506,9 @@ static void mMkRm_AssignIdxInGroup_ThemeSeries(int series) { } static void mMkRm_AssignIdxInGroup_SetSeries(int series) { + int i; int group_idx = 0; int num_ftr = 0; - int i; for (i = 0; i < FTR_NUM; i++) { if (series == mMkRm_ftr_info[i].series) { @@ -3522,9 +3522,9 @@ static void mMkRm_AssignIdxInGroup_SetSeries(int series) { } static void mMkRm_AssignIdxInGroup_OneSeries(int series) { + int i; int group_idx = 0; int num_ftr = 0; - int i; for (i = 0; i < FTR_NUM; i++) { if (series == mMkRm_ftr_info[i].series) { diff --git a/src/game/m_msg_main.c_inc b/src/game/m_msg_main.c_inc index ea2dab46..011b469a 100644 --- a/src/game/m_msg_main.c_inc +++ b/src/game/m_msg_main.c_inc @@ -1,543 +1,512 @@ static int mMsg_Set_SizeCode(mMsg_Window_c* msg_p, int idx) { - return mFont_CodeSize_idx_get(msg_p->msg_data->text_buf.data, idx); + return mFont_CodeSize_idx_get(msg_p->msg_data->text_buf.data, idx); } static int mMsg_Count_SameCode(u8* data, int start, int length, u8 code) { - int res = 0; - int i = start; - u8* now_p; - u8 now_code; + int res = 0; + int i = start; + u8* now_p; + u8 now_code; - while (i < length) { - now_p = &data[i]; - now_code = *now_p; + while (i < length) { + now_p = &data[i]; + now_code = *now_p; - if (now_code == CHAR_CONTROL_CODE) { - i += mFont_CodeSize_get(now_p); + if (now_code == CHAR_CONTROL_CODE) { + i += mFont_CodeSize_get(now_p); + } else if (now_code == code) { + res++; + i++; + } else { + break; + } } - else if (now_code == code) { - res++; - i++; - } - else { - break; - } - } - return res; + return res; } static int mMsg_Check_LastCode_forData(u8* data, int idx) { - u8 code = data[idx]; + u8 code = data[idx]; - if (code == CHAR_CONTROL_CODE) { - code = data[idx + 1]; + if (code == CHAR_CONTROL_CODE) { + code = data[idx + 1]; - if (code == mFont_CONT_CODE_LAST) { - return TRUE; + if (code == mFont_CONT_CODE_LAST) { + return TRUE; + } } - } - return FALSE; + return FALSE; } static int mMsg_Check_LastCode(mMsg_Window_c* msg_p, int idx) { - return mMsg_Check_LastCode_forData(msg_p->msg_data->text_buf.data, idx); + return mMsg_Check_LastCode_forData(msg_p->msg_data->text_buf.data, idx); } static int mMsg_Check_ContinueCode_forData(u8* data, int idx) { - u8 code = data[idx]; + u8 code = data[idx]; - if (code == CHAR_CONTROL_CODE) { - code = data[idx + 1]; + if (code == CHAR_CONTROL_CODE) { + code = data[idx + 1]; - if (code == mFont_CONT_CODE_CONTINUE) { - return TRUE; + if (code == mFont_CONT_CODE_CONTINUE) { + return TRUE; + } } - } - return FALSE; + return FALSE; } static int mMsg_Check_ContinueCode(mMsg_Window_c* msg_p, int idx) { - return mMsg_Check_ContinueCode_forData(msg_p->msg_data->text_buf.data, idx); + return mMsg_Check_ContinueCode_forData(msg_p->msg_data->text_buf.data, idx); } static int mMsg_Check_NextIndex_ContinueCode(mMsg_Window_c* msg_p) { - if (mMsg_Check_ContinueCode(msg_p, msg_p->end_text_cursor_idx)) { - return TRUE; - } + if (mMsg_Check_ContinueCode(msg_p, msg_p->end_text_cursor_idx)) { + return TRUE; + } - return FALSE; + return FALSE; } static int mMsg_Check_NextIndex_LastCode(mMsg_Window_c* msg_p) { - if (mMsg_Check_LastCode(msg_p, msg_p->end_text_cursor_idx)) { - return TRUE; - } + if (mMsg_Check_LastCode(msg_p, msg_p->end_text_cursor_idx)) { + return TRUE; + } - return FALSE; + return FALSE; } static int mMsg_Check_NextIndex_SetSelectWindowCode(mMsg_Window_c* msg_p) { - u8* data = msg_p->msg_data->text_buf.data; - int idx = msg_p->end_text_cursor_idx; - u8 code = data[idx]; + u8* data = msg_p->msg_data->text_buf.data; + int idx = msg_p->end_text_cursor_idx; + u8 code = data[idx]; - if (code == CHAR_CONTROL_CODE) { - code = data[idx + 1]; + if (code == CHAR_CONTROL_CODE) { + code = data[idx + 1]; - if (code == mFont_CONT_CODE_SET_SELECT_WINDOW) { - return TRUE; + if (code == mFont_CONT_CODE_SET_SELECT_WINDOW) { + return TRUE; + } } - } - return FALSE; + return FALSE; } static f32 mMsg_Get_CursolSetTimeCode_forData(u8* data, int idx) { - u8 code = data[idx]; + u8 code = data[idx]; - if (code == CHAR_CONTROL_CODE) { - code = data[idx + 1]; + if (code == CHAR_CONTROL_CODE) { + code = data[idx + 1]; - if (code == mFont_CONT_CODE_CURSOR_SET_TIME) { - code = data[idx + 2]; + if (code == mFont_CONT_CODE_CURSOR_SET_TIME) { + code = data[idx + 2]; - return (f32)(int)code * 2.0f; /* Multiply by two due to AC running at 60fps over 30fps */ + return (f32)(int)code * 2.0f; /* Multiply by two due to AC running at 60fps over 30fps */ + } } - } - return 0.0f; + return 0.0f; } static f32 mMsg_Get_CursolSetTimeCode(mMsg_Window_c* msg_p, int idx) { - return mMsg_Get_CursolSetTimeCode_forData(msg_p->msg_data->text_buf.data, idx); + return mMsg_Get_CursolSetTimeCode_forData(msg_p->msg_data->text_buf.data, idx); } static int mMsg_Get_ColorCode_forData(u8* data, int idx, u8* r, u8* g, u8* b) { - u8 code = data[idx]; + u8 code = data[idx]; - if (code == CHAR_CONTROL_CODE) { - code = data[idx + 1]; + if (code == CHAR_CONTROL_CODE) { + code = data[idx + 1]; - if (code == mFont_CONT_CODE_COLOR) { - *r = data[idx + 2]; - *g = data[idx + 3]; - *b = data[idx + 4]; - return TRUE; + if (code == mFont_CONT_CODE_COLOR) { + *r = data[idx + 2]; + *g = data[idx + 3]; + *b = data[idx + 4]; + return TRUE; + } } - } - return FALSE; + return FALSE; } static int mMsg_Get_ColorCode(mMsg_Window_c* msg_p, int idx, u8* r, u8* g, u8* b) { - return mMsg_Get_ColorCode_forData(msg_p->msg_data->text_buf.data, idx, r, g, b); + return mMsg_Get_ColorCode_forData(msg_p->msg_data->text_buf.data, idx, r, g, b); } static int mMsg_Get_OrderCode_forData(u8* data, int idx, int* order_idx, u16* order_val) { - u8 code = data[idx]; + u8 code = data[idx]; - if (code == CHAR_CONTROL_CODE) { - code = data[idx + 1]; + if (code == CHAR_CONTROL_CODE) { + code = data[idx + 1]; - if ( - code == mFont_CONT_CODE_SET_DEMO_ORDER_PLAYER || - code == mFont_CONT_CODE_SET_DEMO_ORDER_NPC0 || - code == mFont_CONT_CODE_SET_DEMO_ORDER_NPC1 || - code == mFont_CONT_CODE_SET_DEMO_ORDER_NPC2 || - code == mFont_CONT_CODE_SET_DEMO_ORDER_QUEST - ) { - u16 val; - - *order_idx = data[idx + 2]; - val = (u16)(data[idx + 3]) << 8; - *order_val = val | ((data[idx + 4]) & 0xFF); - return TRUE; + if (code == mFont_CONT_CODE_SET_DEMO_ORDER_PLAYER || code == mFont_CONT_CODE_SET_DEMO_ORDER_NPC0 || + code == mFont_CONT_CODE_SET_DEMO_ORDER_NPC1 || code == mFont_CONT_CODE_SET_DEMO_ORDER_NPC2 || + code == mFont_CONT_CODE_SET_DEMO_ORDER_QUEST) { + u16 val; + + *order_idx = data[idx + 2]; + val = (u16)(data[idx + 3]) << 8; + *order_val = val | ((data[idx + 4]) & 0xFF); + return TRUE; + } } - } - return FALSE; + return FALSE; } static int mMsg_Get_OrderCode(mMsg_Window_c* msg_p, int idx, int* order_idx, u16* order_val) { - return mMsg_Get_OrderCode_forData(msg_p->msg_data->text_buf.data, idx, order_idx, order_val); + return mMsg_Get_OrderCode_forData(msg_p->msg_data->text_buf.data, idx, order_idx, order_val); } static int mMsg_Get_SoundCutCode_forData(u8* data, int idx) { - if (data[idx] == CHAR_CONTROL_CODE && data[idx + 1] == mFont_CONT_CODE_SOUND_CUT) { - return data[idx + 2]; - } + if (data[idx] == CHAR_CONTROL_CODE && data[idx + 1] == mFont_CONT_CODE_SOUND_CUT) { + return data[idx + 2]; + } - return FALSE; + return FALSE; } static int mMsg_Get_SoundCutCode(mMsg_Window_c* msg_p, int idx) { - return mMsg_Get_SoundCutCode_forData(msg_p->msg_data->text_buf.data, idx); + return mMsg_Get_SoundCutCode_forData(msg_p->msg_data->text_buf.data, idx); } static void mMsg_Get_bgm_make_forData(u8* data, int idx, int* bgm_type, int* stop_type) { - u8* code_p = &data[idx]; + u8* code_p = &data[idx]; - if ( - code_p[0] == CHAR_CONTROL_CODE && - code_p[1] == mFont_CONT_CODE_BGM_MAKE && - code_p[2] < mFont_BGM_NUM && - code_p[3] < mFont_BGM_STOP_TYPE_NUM - ) { - *bgm_type = code_p[2]; - *stop_type = code_p[3]; - } - else { - *bgm_type = mFont_BGM_NUM; - *stop_type = mFont_BGM_STOP_TYPE_NUM; - } + if (code_p[0] == CHAR_CONTROL_CODE && code_p[1] == mFont_CONT_CODE_BGM_MAKE && code_p[2] < mFont_BGM_NUM && + code_p[3] < mFont_BGM_STOP_TYPE_NUM) { + *bgm_type = code_p[2]; + *stop_type = code_p[3]; + } else { + *bgm_type = mFont_BGM_NUM; + *stop_type = mFont_BGM_STOP_TYPE_NUM; + } } static void mMsg_Get_bgm_make(mMsg_Window_c* msg_p, int idx, int* bgm_type, int* stop_type) { - mMsg_Get_bgm_make_forData(msg_p->msg_data->text_buf.data, idx, bgm_type, stop_type); + mMsg_Get_bgm_make_forData(msg_p->msg_data->text_buf.data, idx, bgm_type, stop_type); } static void mMsg_Get_bgm_delete_forData(u8* data, int idx, int* bgm_type, int* stop_type) { - u8* code_p = &data[idx]; + u8* code_p = &data[idx]; - if ( - code_p[0] == CHAR_CONTROL_CODE && - code_p[1] == mFont_CONT_CODE_BGM_DELETE && - code_p[2] < mFont_BGM_NUM && - code_p[3] < mFont_BGM_STOP_TYPE_NUM - ) { - *bgm_type = code_p[2]; - *stop_type = code_p[3]; - } - else { - *bgm_type = mFont_BGM_NUM; - *stop_type = mFont_BGM_STOP_TYPE_NUM; - } + if (code_p[0] == CHAR_CONTROL_CODE && code_p[1] == mFont_CONT_CODE_BGM_DELETE && code_p[2] < mFont_BGM_NUM && + code_p[3] < mFont_BGM_STOP_TYPE_NUM) { + *bgm_type = code_p[2]; + *stop_type = code_p[3]; + } else { + *bgm_type = mFont_BGM_NUM; + *stop_type = mFont_BGM_STOP_TYPE_NUM; + } } static void mMsg_Get_bgm_delete(mMsg_Window_c* msg_p, int idx, int* bgm_type, int* stop_type) { - mMsg_Get_bgm_delete_forData(msg_p->msg_data->text_buf.data, idx, bgm_type, stop_type); + mMsg_Get_bgm_delete_forData(msg_p->msg_data->text_buf.data, idx, bgm_type, stop_type); } static int mMsg_Get_MsgTimeEnd_time_forData(u8* data, int idx) { - u8* code_p = &data[idx]; + u8* code_p = &data[idx]; - if (code_p[0] == CHAR_CONTROL_CODE && code_p[1] == mFont_CONT_CODE_MSG_TIME_END) { - return code_p[2]; - } + if (code_p[0] == CHAR_CONTROL_CODE && code_p[1] == mFont_CONT_CODE_MSG_TIME_END) { + return code_p[2]; + } - return 0; + return 0; } static int mMsg_Get_MsgTimeEnd_time(mMsg_Window_c* msg_p, int idx) { - return mMsg_Get_MsgTimeEnd_time_forData(msg_p->msg_data->text_buf.data, idx); + return mMsg_Get_MsgTimeEnd_time_forData(msg_p->msg_data->text_buf.data, idx); } static int mMsg_Check_MsgTimeEndCode_forData(u8* data, int idx) { - u8* code_p = &data[idx]; + u8* code_p = &data[idx]; - return (code_p[0] == CHAR_CONTROL_CODE && code_p[1] == mFont_CONT_CODE_MSG_TIME_END); + return (code_p[0] == CHAR_CONTROL_CODE && code_p[1] == mFont_CONT_CODE_MSG_TIME_END); } static int mMsg_Check_MsgTimeEndCode(mMsg_Window_c* msg_p, int idx) { - return mMsg_Check_MsgTimeEndCode_forData(msg_p->msg_data->text_buf.data, idx); + return mMsg_Check_MsgTimeEndCode_forData(msg_p->msg_data->text_buf.data, idx); } static int mMsg_Check_NextIndex_MsgTimeEndCode(mMsg_Window_c* msg_p) { - return mMsg_Check_MsgTimeEndCode(msg_p, msg_p->end_text_cursor_idx); + return mMsg_Check_MsgTimeEndCode(msg_p, msg_p->end_text_cursor_idx); } static void mMsg_Get_sound_trg_sys_forData(u8* data, int idx, int* se_no) { - u8* code_p = &data[idx]; + u8* code_p = &data[idx]; - if ( - code_p[0] == CHAR_CONTROL_CODE && - code_p[1] == mFont_CONT_CODE_SOUND_TRG_SYS && - code_p[2] < mFont_SE_NUM - ) { - *se_no = code_p[2]; - } - else { - *se_no = mFont_SE_NUM; - } + if (code_p[0] == CHAR_CONTROL_CODE && code_p[1] == mFont_CONT_CODE_SOUND_TRG_SYS && code_p[2] < mFont_SE_NUM) { + *se_no = code_p[2]; + } else { + *se_no = mFont_SE_NUM; + } } static void mMsg_Get_sound_trg_sys(mMsg_Window_c* msg_p, int idx, int* se_no) { - mMsg_Get_sound_trg_sys_forData(msg_p->msg_data->text_buf.data, idx, se_no); + mMsg_Get_sound_trg_sys_forData(msg_p->msg_data->text_buf.data, idx, se_no); } static void mMsg_Set_LineFontColor(mMsg_Window_c* msg_p, int line_no, u8 r, u8 g, u8 b, u8 a) { - if (line_no >= 0 && line_no < mMsg_MAX_LINE) { - rgba_t* color = &msg_p->font_color[line_no]; + if (line_no >= 0 && line_no < mMsg_MAX_LINE) { + rgba_t* color = &msg_p->font_color[line_no]; - color->r = r; - color->g = g; - color->b = b; - color->a = a; - } + color->r = r; + color->g = g; + color->b = b; + color->a = a; + } } static void mMsg_init_FontColor(mMsg_Window_c* msg_p) { - int i; + int i; - for (i = 0; i < mMsg_MAX_LINE; i++) { - mMsg_Set_LineFontColor(msg_p, i, 50, 60, 50, 255); - } + for (i = 0; i < mMsg_MAX_LINE; i++) { + mMsg_Set_LineFontColor(msg_p, i, 50, 60, 50, 255); + } } static void mMsg_init_NowDisplayLIne(mMsg_Window_c* msg_p) { - msg_p->now_display_line = 0; + msg_p->now_display_line = 0; } static void mMsg_Clear_CursolIndex(mMsg_Window_c* msg_p) { - msg_p->start_text_cursor_idx = msg_p->end_text_cursor_idx; - mMsg_init_FontColor(msg_p); - mMsg_init_NowDisplayLIne(msg_p); + msg_p->start_text_cursor_idx = msg_p->end_text_cursor_idx; + mMsg_init_FontColor(msg_p); + mMsg_init_NowDisplayLIne(msg_p); } static void mMsg_SetTimer(mMsg_Window_c* msg_p, f32 timer) { - msg_p->cursor_timer = timer; + msg_p->cursor_timer = timer; } extern void mMsg_Get_BodyParam(u32 table_addr, u32 data_addr, int index, u32* addr, u32* size) { - static u32 tmp_buff[16] ATTRIBUTE_ALIGN(32); - int first_entry = index == 0; - u32 aligned_ofs = first_entry ? 0 : ALIGN_PREV((index - 1) * sizeof(u32), 32); - int ofs = first_entry ? 0 : (index - 1) & 7; + static u32 tmp_buff[16] ATTRIBUTE_ALIGN(32); + int first_entry = index == 0; + u32 aligned_ofs = first_entry ? 0 : ALIGN_PREV((index - 1) * sizeof(u32), 32); + int ofs = first_entry ? 0 : (index - 1) & 7; - _JW_GetResourceAram(table_addr + aligned_ofs, (u8*)tmp_buff, sizeof(tmp_buff)); + _JW_GetResourceAram(table_addr + aligned_ofs, (u8*)tmp_buff, sizeof(tmp_buff)); - if (first_entry) { - *addr = data_addr; - *size = tmp_buff[ofs]; - } - else { - *addr = data_addr + tmp_buff[ofs]; - *size = tmp_buff[ofs + 1] - tmp_buff[ofs]; - } + if (first_entry) { + *addr = data_addr; + *size = tmp_buff[ofs]; + } else { + *addr = data_addr + tmp_buff[ofs]; + *size = tmp_buff[ofs + 1] - tmp_buff[ofs]; + } } static void mMsg_Get_MsgDataAddressAndSize(int idx, u32* addr, u32* size) { - mMsg_Get_BodyParam(Msg_table_rom_start, Msg_rom_start, idx, addr, size); + mMsg_Get_BodyParam(Msg_table_rom_start, Msg_rom_start, idx, addr, size); } static int mMsg_Count_MsgData(u8* data) { - int i = 0; + int i = 0; - while (i < mMsg_MSG_BUF_MAX) { - if ( - mMsg_Check_LastCode_forData(data, i) || - mMsg_Check_ContinueCode_forData(data, i) || - mMsg_Check_MsgTimeEndCode_forData(data, i) - ) { - i += mFont_CodeSize_idx_get(data, i); - break; + while (i < mMsg_MSG_BUF_MAX) { + if (mMsg_Check_LastCode_forData(data, i) || mMsg_Check_ContinueCode_forData(data, i) || + mMsg_Check_MsgTimeEndCode_forData(data, i)) { + i += mFont_CodeSize_idx_get(data, i); + break; + } + + i += mFont_CodeSize_idx_get(data, i); } - i += mFont_CodeSize_idx_get(data, i); - } - - return i; + return i; } static int mMsg_LoadMsgData(mMsg_Data_c* msg_data, int index, int cut) { - if (msg_data != NULL) { - u32 addr; - u32 size; - - mFRm_set_msg_idx(index); - mMsg_Get_MsgDataAddressAndSize(index, &addr, &size); + if (msg_data != NULL) { + u32 addr; + u32 size; - if (addr != 0 && size != 0) { - u32 aligned_addr = ALIGN_PREV(addr, 32); - int ofs = addr - aligned_addr; - u8* dst_p; - u8* src_p; - int len; - int i; + mFRm_set_msg_idx(index); + mMsg_Get_MsgDataAddressAndSize(index, &addr, &size); - /* DMA copy from ARAM */ - _JW_GetResourceAram(aligned_addr, msg_data->text_buf.data, ALIGN_NEXT(ofs + size, 32)); - - /* Move text to beginning of buffer since we copied aligned to 32 bytes */ - len = size; - dst_p = msg_data->text_buf.data; - src_p = msg_data->text_buf.data + ofs; + if (addr != 0 && size != 0) { + u32 aligned_addr = ALIGN_PREV(addr, 32); + int ofs = addr - aligned_addr; + int i; + int len; + u8* dst_p; + u8* src_p; - for (i = 0; i < len; i++) { - *dst_p++ = *src_p++; - } + /* DMA copy from ARAM */ + _JW_GetResourceAram(aligned_addr, msg_data->text_buf.data, ALIGN_NEXT(ofs + size, 32)); - msg_data->msg_no = index; - msg_data->data_loaded = TRUE; - msg_data->msg_len = mMsg_Count_MsgData(msg_data->text_buf.data); - msg_data->cut = cut; - return TRUE; + /* Move text to beginning of buffer since we copied aligned to 32 bytes */ + len = size; + dst_p = msg_data->text_buf.data; + src_p = msg_data->text_buf.data + ofs; + + for (i = 0; i < len; i++) { + *dst_p++ = *src_p++; + } + + msg_data->msg_no = index; + msg_data->data_loaded = TRUE; + msg_data->msg_len = mMsg_Count_MsgData(msg_data->text_buf.data); + msg_data->cut = cut; + return TRUE; + } } - } - msg_data->data_loaded = FALSE; - return FALSE; + msg_data->data_loaded = FALSE; + return FALSE; } extern int mMsg_ChangeMsgData(mMsg_Window_c* msg_p, int index) { - if (index >= 0 && index < MSG_MAX && mMsg_LoadMsgData(msg_p->msg_data, index, FALSE)) { - msg_p->end_text_cursor_idx = 0; - mMsg_Clear_CursolIndex(msg_p); - mMsg_SetTimer(msg_p, 20.0f); - return TRUE; - } + if (index >= 0 && index < MSG_MAX && mMsg_LoadMsgData(msg_p->msg_data, index, FALSE)) { + msg_p->end_text_cursor_idx = 0; + mMsg_Clear_CursolIndex(msg_p); + mMsg_SetTimer(msg_p, 20.0f); + return TRUE; + } - return FALSE; + return FALSE; } static void mMsg_Unset_NowUtter(mMsg_Window_c* msg_p) { - msg_p->now_utter = FALSE; + msg_p->now_utter = FALSE; } static void mMsg_Set_NowUtter(mMsg_Window_c* msg_p) { - msg_p->now_utter = TRUE; + msg_p->now_utter = TRUE; } extern int mMsg_Check_NowUtter() { - return mMsg_Get_base_window_p()->now_utter; + return mMsg_Get_base_window_p()->now_utter; } static void mMsg_init(GAME* game) { - mMsg_data.data_loaded = FALSE; - mMsg_window.data_loaded = FALSE; - mMsg_window.msg_no = 0; - mMsg_window._008 = 0; - mMsg_window.msg_data = &mMsg_data; - mMsg_window.center_x = 160.0; - mMsg_window.center_y = 185.4; - mMsg_window.width = 245.0; - mMsg_window.height = 96.0; - mMsg_window.client_actor_p = NULL; - mMsg_window.client_name_len = 0; - mMsg_window.nameplate_x = 61.0; - mMsg_window.nameplate_y = 64.0; - mMsg_window.show_continue_button = FALSE; - mMsg_window.name_text_color.r = 0x32; - mMsg_window.name_text_color.g = 0x5a; - mMsg_window.name_text_color.b = 0; - mMsg_window.name_text_color.a = 0xff; - mMsg_window.name_background_color.r = 0xa0; - mMsg_window.name_background_color.g = 0xd7; - mMsg_window.name_background_color.b = 0x1e; - mMsg_window.name_background_color.a = 0xff; - mMsg_window.window_background_color.r = 0xeb; - mMsg_window.window_background_color.g = 0xff; - mMsg_window.window_background_color.b = 0xeb; - mMsg_window.window_background_color.a = 0xff; - mMsg_init_FontColor(&mMsg_window); - mMsg_init_NowDisplayLIne(&mMsg_window); - mMsg_window.continue_button_color.r = 0; - mMsg_window.continue_button_color.g = 0; - mMsg_window.continue_button_color.b = 0xff; - mMsg_window.continue_button_color.a = 0; - mMsg_window.font_scale_x = 1.0; - mMsg_window.font_scale_y = 1.0; - mMsg_window._2D8 = 196; - mMsg_window._2DC = 66; - mMsg_window.text_lines = mMsg_MAX_LINE; - mMsg_window.now_display_line = 0; - mMsg_window.timer = 0.0; - mMsg_SetTimer(&mMsg_window, 0.0); - mMsg_window.continue_button_timer = 0.0; - mMsg_window.start_text_cursor_idx = 0; - mMsg_window.end_text_cursor_idx = 0; - mMsg_window.window_scale = 0.0; - mMsg_window.text_scale = 1.0; - mMsg_window.requested_main_index = -1; - mMsg_window.requested_priority = 0; - mMsg_window.main_index = mMsg_INDEX_HIDE; - mMsg_window.draw_flag = 0; - mMsg_window.cancel_flag = 0; - mMsg_window.cancelable_flag = 0; - mMsg_window.continue_msg_no = 0xFFFF; - mMsg_Unset_CancelNormalContinue(&mMsg_window); - mMsg_Unset_ForceNext(&mMsg_window); - mMsg_Unset_LockContinue(&mMsg_window); - mMsg_sound_MessageSpeedForce(0.0f); - mMsg_sound_MessageStatus(0); - mMsg_window.status_flags &= ~( - mMsg_STATUS_FLAG_SOUND_CUT | - mMsg_STATUS_FLAG_IDLING_REQ | - mMsg_STATUS_FLAG_IDLING_NOW | - mMsg_STATUS_FLAG_NOT_PAUSE_FRAME | - mMsg_STATUS_FLAG_NO_ZOOMDOWN | - mMsg_STATUS_FLAG_VOICE_CLICK | - mMsg_STATUS_FLAG_VOICE_SILENT | - mMsg_STATUS_FLAG_CURSOL_JUST - ); // ~7AC1 - mMsg_window.free_str_color_idx[0] = 0; - mMsg_window.free_str_color_idx[1] = 0; - mMsg_window.free_str_color_idx[2] = 0; + mMsg_data.data_loaded = FALSE; + mMsg_window.data_loaded = FALSE; + mMsg_window.msg_no = 0; + mMsg_window._008 = 0; + mMsg_window.msg_data = &mMsg_data; + mMsg_window.center_x = 160.0; + mMsg_window.center_y = 185.4; + mMsg_window.width = 245.0; + mMsg_window.height = 96.0; + mMsg_window.client_actor_p = NULL; + mMsg_window.client_name_len = 0; + mMsg_window.nameplate_x = 61.0; + mMsg_window.nameplate_y = 64.0; + mMsg_window.show_continue_button = FALSE; + mMsg_window.name_text_color.r = 0x32; + mMsg_window.name_text_color.g = 0x5a; + mMsg_window.name_text_color.b = 0; + mMsg_window.name_text_color.a = 0xff; + mMsg_window.name_background_color.r = 0xa0; + mMsg_window.name_background_color.g = 0xd7; + mMsg_window.name_background_color.b = 0x1e; + mMsg_window.name_background_color.a = 0xff; + mMsg_window.window_background_color.r = 0xeb; + mMsg_window.window_background_color.g = 0xff; + mMsg_window.window_background_color.b = 0xeb; + mMsg_window.window_background_color.a = 0xff; + mMsg_init_FontColor(&mMsg_window); + mMsg_init_NowDisplayLIne(&mMsg_window); + mMsg_window.continue_button_color.r = 0; + mMsg_window.continue_button_color.g = 0; + mMsg_window.continue_button_color.b = 0xff; + mMsg_window.continue_button_color.a = 0; + mMsg_window.font_scale_x = 1.0; + mMsg_window.font_scale_y = 1.0; + mMsg_window._2D8 = 196; + mMsg_window._2DC = 66; + mMsg_window.text_lines = mMsg_MAX_LINE; + mMsg_window.now_display_line = 0; + mMsg_window.timer = 0.0; + mMsg_SetTimer(&mMsg_window, 0.0); + mMsg_window.continue_button_timer = 0.0; + mMsg_window.start_text_cursor_idx = 0; + mMsg_window.end_text_cursor_idx = 0; + mMsg_window.window_scale = 0.0; + mMsg_window.text_scale = 1.0; + mMsg_window.requested_main_index = -1; + mMsg_window.requested_priority = 0; + mMsg_window.main_index = mMsg_INDEX_HIDE; + mMsg_window.draw_flag = 0; + mMsg_window.cancel_flag = 0; + mMsg_window.cancelable_flag = 0; + mMsg_window.continue_msg_no = 0xFFFF; + mMsg_Unset_CancelNormalContinue(&mMsg_window); + mMsg_Unset_ForceNext(&mMsg_window); + mMsg_Unset_LockContinue(&mMsg_window); + mMsg_sound_MessageSpeedForce(0.0f); + mMsg_sound_MessageStatus(0); + mMsg_window.status_flags &= + ~(mMsg_STATUS_FLAG_SOUND_CUT | mMsg_STATUS_FLAG_IDLING_REQ | mMsg_STATUS_FLAG_IDLING_NOW | + mMsg_STATUS_FLAG_NOT_PAUSE_FRAME | mMsg_STATUS_FLAG_NO_ZOOMDOWN | mMsg_STATUS_FLAG_VOICE_CLICK | + mMsg_STATUS_FLAG_VOICE_SILENT | mMsg_STATUS_FLAG_CURSOL_JUST); // ~7AC1 + mMsg_window.free_str_color_idx[0] = 0; + mMsg_window.free_str_color_idx[1] = 0; + mMsg_window.free_str_color_idx[2] = 0; } extern int mMsg_Get_Length_String(u8* str, int str_len) { - int i; + int i; - for (i = str_len - 1; i >= 0; i--) { - if (str[i] != CHAR_SPACE) { - break; + for (i = str_len - 1; i >= 0; i--) { + if (str[i] != CHAR_SPACE) { + break; + } } - } - return i + 1; + return i + 1; } extern int mMsg_Check_MainNormalContinue(mMsg_Window_c* msg_p) { - if (msg_p->main_index == mMsg_INDEX_NORMAL) { - if (mMsg_Check_NextIndex_ContinueCode(msg_p)) { - return TRUE; + if (msg_p->main_index == mMsg_INDEX_NORMAL) { + if (mMsg_Check_NextIndex_ContinueCode(msg_p)) { + return TRUE; + } } - } - return FALSE; + return FALSE; } extern int mMsg_Check_MainNormal(mMsg_Window_c* msg_p) { - if (msg_p->main_index == mMsg_INDEX_NORMAL) { - return TRUE; - } + if (msg_p->main_index == mMsg_INDEX_NORMAL) { + return TRUE; + } - return FALSE; + return FALSE; } extern int mMsg_Check_MainHide(mMsg_Window_c* msg_p) { - if (msg_p->main_index == mMsg_INDEX_HIDE) { - return TRUE; - } + if (msg_p->main_index == mMsg_INDEX_HIDE) { + return TRUE; + } - return FALSE; + return FALSE; } extern int mMsg_Check_MainDisappear(mMsg_Window_c* msg_p) { - if (msg_p->main_index == mMsg_INDEX_DISAPPEAR) { - return TRUE; - } + if (msg_p->main_index == mMsg_INDEX_DISAPPEAR) { + return TRUE; + } - return FALSE; + return FALSE; } extern void mMsg_Set_CancelNormalContinue(mMsg_Window_c* msg_p) { - msg_p->continue_cancel_flag = TRUE; + msg_p->continue_cancel_flag = TRUE; } extern void mMsg_Unset_CancelNormalContinue(mMsg_Window_c* msg_p) { - msg_p->continue_cancel_flag = FALSE; + msg_p->continue_cancel_flag = FALSE; } extern void mMsg_Set_ForceNext(mMsg_Window_c* msg_p) { - msg_p->force_next = TRUE; + msg_p->force_next = TRUE; } extern void mMsg_Unset_ForceNext(mMsg_Window_c* msg_p) { - msg_p->force_next = FALSE; + msg_p->force_next = FALSE; } /* @unused @fabricated */ @@ -546,438 +515,423 @@ extern void mMsg_Unset_ForceNext(mMsg_Window_c* msg_p) { // } extern void mMsg_Set_LockContinue(mMsg_Window_c* msg_p) { - msg_p->lock_continue = TRUE; + msg_p->lock_continue = TRUE; } extern void mMsg_Unset_LockContinue(mMsg_Window_c* msg_p) { - msg_p->lock_continue = FALSE; + msg_p->lock_continue = FALSE; } extern void mMsg_Set_idling_req(mMsg_Window_c* msg_p) { - msg_p->status_flags |= mMsg_STATUS_FLAG_IDLING_REQ; + msg_p->status_flags |= mMsg_STATUS_FLAG_IDLING_REQ; } extern int mMsg_Check_idling_now(mMsg_Window_c* msg_p) { - return (msg_p->status_flags & mMsg_STATUS_FLAG_IDLING_NOW) != 0; + return (msg_p->status_flags & mMsg_STATUS_FLAG_IDLING_NOW) != 0; } extern int mMsg_MoveDataCut(u8* data, int dst_idx, int src_idx, int len, int space_flag) { - int new_len = len; + int new_len = len; - if (dst_idx < src_idx) { - while (src_idx < len) { - data[dst_idx] = data[src_idx]; - dst_idx++; - src_idx++; + if (dst_idx < src_idx) { + while (src_idx < len) { + data[dst_idx] = data[src_idx]; + dst_idx++; + src_idx++; + } + + new_len -= src_idx - dst_idx; + + if (space_flag) { + while (dst_idx < len) { + data[dst_idx] = CHAR_SPACE; + dst_idx++; + } + } + } else if (dst_idx > src_idx) { + int move_size = len - src_idx; + + new_len += dst_idx - src_idx; + if (new_len <= mMsg_MSG_BUF_MAX) { + int i; + u8* dst_p = data + new_len - 1; + u8* src_p = data + len - 1; + + for (i = 0; i < move_size; i++) { + *dst_p-- = *src_p--; + } + } } - new_len -= src_idx - dst_idx; - - if (space_flag) { - while (dst_idx < len) { - data[dst_idx] = CHAR_SPACE; - dst_idx++; - } - } - } - else if (dst_idx > src_idx) { - int move_size = len - src_idx; - - new_len += dst_idx - src_idx; - if (new_len <= mMsg_MSG_BUF_MAX) { - int i; - u8* dst_p = data + new_len - 1; - u8* src_p = data + len - 1; - - for (i = 0; i < move_size; i++) { - *dst_p-- = *src_p--; - } - } - } - - return new_len; + return new_len; } -static void mMsg_CopyString(u8* dst, u8* src, int len) { - int i; +static void mMsg_CopyString(u8* dst, const u8* src, int len) { + int i; - for (i = 0; i < len; i++) { - *dst++ = *src++; - } + for (i = 0; i < len; i++) { + *dst++ = *src++; + } } static int mMsg_Set_PlayerNameColor(u8* data, int* start_idx, int len) { - static u8 add_string[] = { - CHAR_CONTROL_CODE, - mFont_CONT_CODE_SET_COLOR_CHAR, - 75, - 95, - 155, - 0 - }; + static u8 add_string[] = { CHAR_CONTROL_CODE, mFont_CONT_CODE_SET_COLOR_CHAR, 75, 95, 155, 0 }; - u8* name = Common_Get(now_private)->player_ID.player_name; - int name_len = mMsg_Get_Length_String(name, PLAYER_NAME_LEN); - int hypen_count; - int new_len; - int initial_start_idx = *start_idx; - int command_len = mFont_CodeSize_idx_get(data, *start_idx); + u8* name = Common_Get(now_private)->player_ID.player_name; + int name_len = mMsg_Get_Length_String(name, PLAYER_NAME_LEN); + int hypen_count; + int new_len; + int initial_start_idx = *start_idx; + int command_len = mFont_CodeSize_idx_get(data, *start_idx); - if (name_len > 0) { - hypen_count = mMsg_Count_SameCode(data, (*start_idx) + command_len, len, CHAR_HYPHEN); - add_string[5] = name_len + hypen_count; - new_len = mMsg_MoveDataCut(data, initial_start_idx + sizeof(add_string), initial_start_idx, len, FALSE); - mMsg_CopyString(data + initial_start_idx, add_string, sizeof(add_string)); - *start_idx += sizeof(add_string); - } - else { - new_len = len; - } + if (name_len > 0) { + hypen_count = mMsg_Count_SameCode(data, (*start_idx) + command_len, len, CHAR_HYPHEN); + add_string[5] = name_len + hypen_count; + new_len = mMsg_MoveDataCut(data, initial_start_idx + sizeof(add_string), initial_start_idx, len, FALSE); + mMsg_CopyString(data + initial_start_idx, add_string, sizeof(add_string)); + *start_idx += sizeof(add_string); + } else { + new_len = len; + } - return new_len; + return new_len; } extern int mMsg_CopyPlayerName(u8* data, int start_idx, int len, u32 capitalize) { - int command_len = mFont_CodeSize_idx_get(data, start_idx); - u8* name = Common_Get(now_private)->player_ID.player_name; - int name_len = mMsg_Get_Length_String(name, PLAYER_NAME_LEN); - int new_len = mMsg_MoveDataCut(data, start_idx + name_len, start_idx + command_len, len, FALSE); + int command_len = mFont_CodeSize_idx_get(data, start_idx); + u8* name = Common_Get(now_private)->player_ID.player_name; + int name_len = mMsg_Get_Length_String(name, PLAYER_NAME_LEN); + int new_len = mMsg_MoveDataCut(data, start_idx + name_len, start_idx + command_len, len, FALSE); - mMsg_CopyString(&data[start_idx], name, name_len); + mMsg_CopyString(&data[start_idx], name, name_len); - if (capitalize) { - data[start_idx] = mFont_small_to_capital(data[start_idx]); - } + if (capitalize) { + data[start_idx] = mFont_small_to_capital(data[start_idx]); + } - return new_len; + return new_len; } extern int mMsg_CopyTalkName(ACTOR* actor_p, u8* data, int start_idx, int len, u32 capitalize) { - int command_len = mFont_CodeSize_idx_get(data, start_idx); - u8 name[ANIMAL_NAME_LEN]; - int name_len; - int new_len; + int command_len = mFont_CodeSize_idx_get(data, start_idx); + u8 name[ANIMAL_NAME_LEN]; + int name_len; + int new_len; - if (actor_p != NULL) { - mNpc_GetNpcWorldName(name, actor_p); - name_len = mMsg_Get_Length_String(name, sizeof(name)); - } - else { - name_len = 0; - } + if (actor_p != NULL) { + mNpc_GetNpcWorldName(name, actor_p); + name_len = mMsg_Get_Length_String(name, sizeof(name)); + } else { + name_len = 0; + } - new_len = mMsg_MoveDataCut(data, start_idx + name_len, start_idx + command_len, len, FALSE); - mMsg_CopyString(&data[start_idx], name, name_len); + new_len = mMsg_MoveDataCut(data, start_idx + name_len, start_idx + command_len, len, FALSE); + mMsg_CopyString(&data[start_idx], name, name_len); - if (capitalize) { - data[start_idx] = mFont_small_to_capital(data[start_idx]); - } + if (capitalize) { + data[start_idx] = mFont_small_to_capital(data[start_idx]); + } - return new_len; + return new_len; } extern int mMsg_CopyTail(ACTOR* actor_p, u8* data, int start_idx, int len, u32 capitalize) { - int command_len = mFont_CodeSize_idx_get(data, start_idx); - u8* tail_p = actor_p != NULL ? mNpc_GetWordEnding(actor_p) : NULL; - int tail_len = actor_p != NULL ? mMsg_Get_Length_String(tail_p, ANIMAL_CATCHPHRASE_LEN) : 0; - int new_len; + int command_len = mFont_CodeSize_idx_get(data, start_idx); + u8* tail_p = actor_p != NULL ? mNpc_GetWordEnding(actor_p) : NULL; + int tail_len = actor_p != NULL ? mMsg_Get_Length_String(tail_p, ANIMAL_CATCHPHRASE_LEN) : 0; + int new_len; - new_len = mMsg_MoveDataCut(data, start_idx + tail_len, start_idx + command_len, len, FALSE); - mMsg_CopyString(&data[start_idx], tail_p, tail_len); + new_len = mMsg_MoveDataCut(data, start_idx + tail_len, start_idx + command_len, len, FALSE); + mMsg_CopyString(&data[start_idx], tail_p, tail_len); - if (capitalize) { - data[start_idx] = mFont_small_to_capital(data[start_idx]); - } + if (capitalize) { + data[start_idx] = mFont_small_to_capital(data[start_idx]); + } - return new_len; + return new_len; } extern int mMsg_CopyYear(u8* data, int start_idx, int len) { - int command_len = mFont_CodeSize_idx_get(data, start_idx); - u16 year = Common_Get(time.rtc_time.year); - u8 year_str[6]; - int year_len = mString_Load_YearStringFromRom(year_str, year); - int new_len = mMsg_MoveDataCut(data, start_idx + year_len, start_idx + command_len, len, FALSE); + int command_len = mFont_CodeSize_idx_get(data, start_idx); + u16 year = Common_Get(time.rtc_time.year); + u8 year_str[6]; + int year_len = mString_Load_YearStringFromRom(year_str, year); + int new_len = mMsg_MoveDataCut(data, start_idx + year_len, start_idx + command_len, len, FALSE); - mMsg_CopyString(&data[start_idx], year_str, year_len); - return new_len; + mMsg_CopyString(&data[start_idx], year_str, year_len); + return new_len; } extern int mMsg_CopyMonth(u8* data, int start_idx, int len) { - int command_len = mFont_CodeSize_idx_get(data, start_idx); - u8 month = Common_Get(time.rtc_time.month); - u8 month_str[9]; - int month_len = mString_Load_MonthStringFromRom(month_str, month); - int new_len = mMsg_MoveDataCut(data, start_idx + month_len, start_idx + command_len, len, FALSE); + int command_len = mFont_CodeSize_idx_get(data, start_idx); + u8 month = Common_Get(time.rtc_time.month); + u8 month_str[9]; + int month_len = mString_Load_MonthStringFromRom(month_str, month); + int new_len = mMsg_MoveDataCut(data, start_idx + month_len, start_idx + command_len, len, FALSE); - mMsg_CopyString(&data[start_idx], month_str, month_len); - return new_len; + mMsg_CopyString(&data[start_idx], month_str, month_len); + return new_len; } extern int mMsg_CopyWeek(u8* data, int start_idx, int len) { - int command_len = mFont_CodeSize_idx_get(data, start_idx); - u8 week = Common_Get(time.rtc_time.weekday); - u8 week_str[9]; - int week_len = mString_Load_WeekStringFromRom(week_str, week); - int new_len = mMsg_MoveDataCut(data, start_idx + week_len, start_idx + command_len, len, FALSE); + int command_len = mFont_CodeSize_idx_get(data, start_idx); + u8 week = Common_Get(time.rtc_time.weekday); + u8 week_str[9]; + int week_len = mString_Load_WeekStringFromRom(week_str, week); + int new_len = mMsg_MoveDataCut(data, start_idx + week_len, start_idx + command_len, len, FALSE); - mMsg_CopyString(&data[start_idx], week_str, week_len); - return new_len; + mMsg_CopyString(&data[start_idx], week_str, week_len); + return new_len; } extern int mMsg_CopyDay(u8* data, int start_idx, int len) { - int command_len = mFont_CodeSize_idx_get(data, start_idx); - u8 day = Common_Get(time.rtc_time.day); - u8 day_str[4]; - int day_len = mString_Load_DayStringFromRom(day_str, day); - int new_len = mMsg_MoveDataCut(data, start_idx + day_len, start_idx + command_len, len, FALSE); + int command_len = mFont_CodeSize_idx_get(data, start_idx); + u8 day = Common_Get(time.rtc_time.day); + u8 day_str[4]; + int day_len = mString_Load_DayStringFromRom(day_str, day); + int new_len = mMsg_MoveDataCut(data, start_idx + day_len, start_idx + command_len, len, FALSE); - mMsg_CopyString(&data[start_idx], day_str, day_len); - return new_len; + mMsg_CopyString(&data[start_idx], day_str, day_len); + return new_len; } extern int mMsg_CopyHour(u8* data, int start_idx, int len) { - int command_len = mFont_CodeSize_idx_get(data, start_idx); - u8 hour = Common_Get(time.rtc_time.hour); - u8 hour_str[2]; - int hour_len = mString_Load_HourStringFromRom2(hour_str, hour); - int new_len = mMsg_MoveDataCut(data, start_idx + hour_len, start_idx + command_len, len, FALSE); + int command_len = mFont_CodeSize_idx_get(data, start_idx); + u8 hour = Common_Get(time.rtc_time.hour); + u8 hour_str[2]; + int hour_len = mString_Load_HourStringFromRom2(hour_str, hour); + int new_len = mMsg_MoveDataCut(data, start_idx + hour_len, start_idx + command_len, len, FALSE); - mMsg_CopyString(&data[start_idx], hour_str, hour_len); - return new_len; + mMsg_CopyString(&data[start_idx], hour_str, hour_len); + return new_len; } extern int mMsg_CopyMin(u8* data, int start_idx, int len) { - int command_len = mFont_CodeSize_idx_get(data, start_idx); - u8 min = Common_Get(time.rtc_time.min); - u8 min_str[2]; - int min_len = mString_Load_MinStringFromRom(min_str, min); - int new_len = mMsg_MoveDataCut(data, start_idx + min_len, start_idx + command_len, len, FALSE); + int command_len = mFont_CodeSize_idx_get(data, start_idx); + u8 min = Common_Get(time.rtc_time.min); + u8 min_str[2]; + int min_len = mString_Load_MinStringFromRom(min_str, min); + int new_len = mMsg_MoveDataCut(data, start_idx + min_len, start_idx + command_len, len, FALSE); - mMsg_CopyString(&data[start_idx], min_str, min_len); - return new_len; + mMsg_CopyString(&data[start_idx], min_str, min_len); + return new_len; } extern int mMsg_CopySec(u8* data, int start_idx, int len) { - int command_len = mFont_CodeSize_idx_get(data, start_idx); - u8 sec = Common_Get(time.rtc_time.sec); - u8 sec_str[2]; - int sec_len = mString_Load_SecStringFromRom(sec_str, sec); - int new_len = mMsg_MoveDataCut(data, start_idx + sec_len, start_idx + command_len, len, FALSE); - - mMsg_CopyString(&data[start_idx], sec_str, sec_len); - return new_len; -} - -extern int mMsg_CopyFree(mMsg_Window_c* msg_p, int str_no, u8* data, int start_idx, int len, int article, u32 capitalize) { - if (str_no < 0 || str_no >= mMsg_FREE_STR_NUM) { - str_no = mMsg_FREE_STR0; - } - - { - int new_len; int command_len = mFont_CodeSize_idx_get(data, start_idx); - u8* free_str_p = msg_p->free_str[str_no]; - int free_str_len = mMsg_Get_Length_String(free_str_p, mMsg_FREE_STRING_LEN); - - new_len = mMsg_MoveDataCut(data, start_idx + free_str_len, start_idx + command_len, len, FALSE); - mMsg_CopyString(&data[start_idx], free_str_p, free_str_len); - - article = article != mIN_ARTICLE_NUM ? article : msg_p->free_str_article[str_no]; - if (article != mIN_ARTICLE_NONE) { - u8 article_str[mIN_ITEM_NAME_LEN + 1]; - int article_len; - - mString_Load_StringFromRom(article_str, mIN_ITEM_NAME_LEN, mString_ARTICLE_START + article); - article_len = mMsg_Get_Length_String(article_str, mIN_ITEM_NAME_LEN); - article_str[article_len] = CHAR_SPACE; - new_len = mMsg_MoveDataCut(data, start_idx + article_len + 1, start_idx, new_len, FALSE); - mMsg_CopyString(&data[start_idx], article_str, article_len + 1); - } - - if (capitalize) { - data[start_idx] = mFont_small_to_capital(data[start_idx]); - } + u8 sec = Common_Get(time.rtc_time.sec); + u8 sec_str[2]; + int sec_len = mString_Load_SecStringFromRom(sec_str, sec); + int new_len = mMsg_MoveDataCut(data, start_idx + sec_len, start_idx + command_len, len, FALSE); + mMsg_CopyString(&data[start_idx], sec_str, sec_len); return new_len; - } } -static u8 MMSG_pf_cl[6][3] = { - { 0, 0, 0 }, - { 145, 60, 145 }, - { 50, 130, 70 }, - { 75, 95, 155 }, - { 160, 50, 75 }, - { 50, 75, 225 } -}; +extern int mMsg_CopyFree(mMsg_Window_c* msg_p, int str_no, u8* data, int start_idx, int len, int article, + u32 capitalize) { + if (str_no < 0 || str_no >= mMsg_FREE_STR_NUM) { + str_no = mMsg_FREE_STR0; + } + + { + int new_len; + int command_len = mFont_CodeSize_idx_get(data, start_idx); + u8* free_str_p = msg_p->free_str[str_no]; + int free_str_len = mMsg_Get_Length_String(free_str_p, mMsg_FREE_STRING_LEN); + + new_len = mMsg_MoveDataCut(data, start_idx + free_str_len, start_idx + command_len, len, FALSE); + mMsg_CopyString(&data[start_idx], free_str_p, free_str_len); + + article = article != mIN_ARTICLE_NUM ? article : msg_p->free_str_article[str_no]; + if (article != mIN_ARTICLE_NONE) { + u8 article_str[mIN_ITEM_NAME_LEN + 1]; + int article_len; + + mString_Load_StringFromRom(article_str, mIN_ITEM_NAME_LEN, mString_ARTICLE_START + article); + article_len = mMsg_Get_Length_String(article_str, mIN_ITEM_NAME_LEN); + article_str[article_len] = CHAR_SPACE; + new_len = mMsg_MoveDataCut(data, start_idx + article_len + 1, start_idx, new_len, FALSE); + mMsg_CopyString(&data[start_idx], article_str, article_len + 1); + } + + if (capitalize) { + data[start_idx] = mFont_small_to_capital(data[start_idx]); + } + + return new_len; + } +} + +static u8 MMSG_pf_cl[6][3] = { { 0, 0, 0 }, { 145, 60, 145 }, { 50, 130, 70 }, + { 75, 95, 155 }, { 160, 50, 75 }, { 50, 75, 225 } }; static int mMsg_Set_PfColor(u8* data, int* start_idx, int len, u8* free_str, int pf_color_id, int article) { - static u8 add_string[] = { CHAR_CONTROL_CODE, mFont_CONT_CODE_SET_COLOR_CHAR, 0, 0, 0, 0 }; + static u8 add_string[] = { CHAR_CONTROL_CODE, mFont_CONT_CODE_SET_COLOR_CHAR, 0, 0, 0, 0 }; - int free_str_len = mMsg_Get_Length_String(free_str, mMsg_FREE_STRING_LEN); - int article_len; - int src_idx = *start_idx; - int new_len; - u8* color_data = MMSG_pf_cl[pf_color_id]; + int free_str_len = mMsg_Get_Length_String(free_str, mMsg_FREE_STRING_LEN); + int article_len; + int src_idx = *start_idx; + int new_len; + u8* color_data = MMSG_pf_cl[pf_color_id]; - add_string[2] = color_data[0]; - add_string[3] = color_data[1]; - add_string[4] = color_data[2]; + add_string[2] = color_data[0]; + add_string[3] = color_data[1]; + add_string[4] = color_data[2]; - if (article == mIN_ARTICLE_NONE) { - article_len = 0; - } - else { - u8 article_str[mIN_ITEM_NAME_LEN]; + if (article == mIN_ARTICLE_NONE) { + article_len = 0; + } else { + u8 article_str[mIN_ITEM_NAME_LEN]; - mString_Load_StringFromRom(article_str, mIN_ITEM_NAME_LEN, mString_ARTICLE_START + article); - article_len = mMsg_Get_Length_String(article_str, mIN_ITEM_NAME_LEN) + 1; - } + mString_Load_StringFromRom(article_str, mIN_ITEM_NAME_LEN, mString_ARTICLE_START + article); + article_len = mMsg_Get_Length_String(article_str, mIN_ITEM_NAME_LEN) + 1; + } - add_string[5] = free_str_len + article_len; - new_len = mMsg_MoveDataCut(data, src_idx + sizeof(add_string), src_idx, len, FALSE); - mMsg_CopyString(data + src_idx, add_string, sizeof(add_string)); - (*start_idx) += sizeof(add_string); - return new_len; + add_string[5] = free_str_len + article_len; + new_len = mMsg_MoveDataCut(data, src_idx + sizeof(add_string), src_idx, len, FALSE); + mMsg_CopyString(data + src_idx, add_string, sizeof(add_string)); + (*start_idx) += sizeof(add_string); + return new_len; } extern int mMsg_CopyDetermination(mMsg_Window_c* msg_p, u8* data, int start_idx, int len) { - int command_len = mFont_CodeSize_idx_get(data, start_idx); - u8* str = msg_p->choice_window.data.determination_string; - int str_len = msg_p->choice_window.data.determination_len; - int new_len = mMsg_MoveDataCut(data, start_idx + str_len, start_idx + command_len, len, FALSE); + int command_len = mFont_CodeSize_idx_get(data, start_idx); + u8* str = msg_p->choice_window.data.determination_string; + int str_len = msg_p->choice_window.data.determination_len; + int new_len = mMsg_MoveDataCut(data, start_idx + str_len, start_idx + command_len, len, FALSE); - mMsg_CopyString(&data[start_idx], str, str_len); - return new_len; + mMsg_CopyString(&data[start_idx], str, str_len); + return new_len; } -extern int mMsg_CopyCountryName(u8 *data, int start_idx, int len, u32 capitalize) { - int new_len; - int new_start_idx; - int command_len = mFont_CodeSize_idx_get(data, start_idx); - u8* land_name = mLd_GetLandName(); - int land_name_len = mMsg_Get_Length_String(land_name, LAND_NAME_SIZE); +extern int mMsg_CopyCountryName(u8* data, int start_idx, int len, u32 capitalize) { + int new_len; + int new_start_idx; + int command_len = mFont_CodeSize_idx_get(data, start_idx); + u8* land_name = mLd_GetLandName(); + int land_name_len = mMsg_Get_Length_String(land_name, LAND_NAME_SIZE); - new_start_idx = start_idx + land_name_len; - new_len = mMsg_MoveDataCut(data, start_idx + land_name_len, start_idx + command_len, len, FALSE); + new_start_idx = start_idx + land_name_len; + new_len = mMsg_MoveDataCut(data, start_idx + land_name_len, start_idx + command_len, len, FALSE); - mMsg_CopyString(&data[start_idx], land_name, land_name_len); + mMsg_CopyString(&data[start_idx], land_name, land_name_len); - // This entire block can be removed in the English version - #ifndef IMPROVEMENTS - /* Leftover from JP to add 'むら' (mura) to the town name */ - { - u8 mura_str[mMsg_FREE_STRING_LEN]; - u8* mura_str_p = mura_str; - int mura_size; +// This entire block can be removed in the English version +#ifndef IMPROVEMENTS + /* Leftover from JP to add 'むら' (mura) to the town name */ + { + u8 mura_str[mMsg_FREE_STRING_LEN]; + u8* mura_str_p = mura_str; + int mura_size; - mString_Load_StringFromRom(mura_str_p, sizeof(mura_str), 0x1E4); - mura_size = mMsg_Get_Length_String(mura_str_p, sizeof(mura_str)); - new_len = mMsg_MoveDataCut(data, new_start_idx + mura_size, new_start_idx, new_len, FALSE); - mMsg_CopyString(&data[new_start_idx], mura_str_p, mura_size); - } - #endif + mString_Load_StringFromRom(mura_str_p, sizeof(mura_str), 0x1E4); + mura_size = mMsg_Get_Length_String(mura_str_p, sizeof(mura_str)); + new_len = mMsg_MoveDataCut(data, new_start_idx + mura_size, new_start_idx, new_len, FALSE); + mMsg_CopyString(&data[new_start_idx], mura_str_p, mura_size); + } +#endif - if (capitalize) { - data[start_idx] = mFont_small_to_capital(data[start_idx]); - } + if (capitalize) { + data[start_idx] = mFont_small_to_capital(data[start_idx]); + } - return new_len; + return new_len; } extern int mMsg_CopyIslandName(u8* data, int start_idx, int len, u32 capitalize) { - int new_len; - int command_len = mFont_CodeSize_idx_get(data, start_idx); - u8* str = Save_Get(island).name; - int str_len = mMsg_Get_Length_String(str, mISL_ISLAND_NAME_LEN); - - new_len = mMsg_MoveDataCut(data, start_idx + str_len, start_idx + command_len, len, FALSE); - mMsg_CopyString(&data[start_idx], str, str_len); + int new_len; + int command_len = mFont_CodeSize_idx_get(data, start_idx); + u8* str = Save_Get(island).name; + int str_len = mMsg_Get_Length_String(str, mISL_ISLAND_NAME_LEN); - if (capitalize) { - data[start_idx] = mFont_small_to_capital(data[start_idx]); - } + new_len = mMsg_MoveDataCut(data, start_idx + str_len, start_idx + command_len, len, FALSE); + mMsg_CopyString(&data[start_idx], str, str_len); - return new_len; + if (capitalize) { + data[start_idx] = mFont_small_to_capital(data[start_idx]); + } + + return new_len; } extern int mMsg_CopyAmPm(mMsg_Window_c* msg_p, u8* data, int start_idx, int len) { - int new_len; - int command_len = mFont_CodeSize_idx_get(data, start_idx); - u8 str[15]; - int str_len; + int new_len; + int command_len = mFont_CodeSize_idx_get(data, start_idx); + u8 str[15]; + int str_len; - mString_Load_StringFromRom(str, sizeof(str), (msg_p->status_flags & mMsg_STATUS_FLAG_USE_AM) ? 1 : 2); - str_len = mMsg_Get_Length_String(str, sizeof(str)); - new_len = mMsg_MoveDataCut(data, start_idx + str_len, start_idx + command_len, len, FALSE); + mString_Load_StringFromRom(str, sizeof(str), (msg_p->status_flags & mMsg_STATUS_FLAG_USE_AM) ? 1 : 2); + str_len = mMsg_Get_Length_String(str, sizeof(str)); + new_len = mMsg_MoveDataCut(data, start_idx + str_len, start_idx + command_len, len, FALSE); - mMsg_CopyString(&data[start_idx], str, str_len); - return new_len; + mMsg_CopyString(&data[start_idx], str, str_len); + return new_len; } extern int mMsg_CopyRamdomNumber2(u8* data, int start_idx, int len) { - int command_len = mFont_CodeSize_idx_get(data, start_idx); - u16 rng = get_random_timer(0, 100) % 100; - u8 str[2]; - u8* str_p = str; - int str_len = mFont_UnintToString(str_p, 2, rng, 2, TRUE, FALSE, TRUE); - int new_len = mMsg_MoveDataCut(data, start_idx + str_len, start_idx + command_len, len, FALSE); + int command_len = mFont_CodeSize_idx_get(data, start_idx); + u16 rng = get_random_timer(0, 100) % 100; + u8 str[2]; + u8* str_p = str; + int str_len = mFont_UnintToString(str_p, 2, rng, 2, TRUE, FALSE, TRUE); + int new_len = mMsg_MoveDataCut(data, start_idx + str_len, start_idx + command_len, len, FALSE); - mMsg_CopyString(&data[start_idx], str_p, str_len); - return new_len; + mMsg_CopyString(&data[start_idx], str_p, str_len); + return new_len; } -extern int mMsg_CopyItem(mMsg_Window_c* msg_p, int str_no, u8* data, int start_idx, int len, int article, u32 capitalize) { - if (str_no < 0 || str_no >= mMsg_ITEM_STR_NUM) { - str_no = mMsg_ITEM_STR0; - } - - { - int new_len; - int command_len = mFont_CodeSize_idx_get(data, start_idx); - u8* free_str_p = msg_p->item_str[str_no]; - int free_str_len = mMsg_Get_Length_String(free_str_p, mMsg_FREE_STRING_LEN); - - new_len = mMsg_MoveDataCut(data, start_idx + free_str_len, start_idx + command_len, len, FALSE); - mMsg_CopyString(&data[start_idx], free_str_p, free_str_len); - - article = article != mIN_ARTICLE_NUM ? article : msg_p->item_str_article[str_no]; - if (article != mIN_ARTICLE_NONE) { - u8 article_str[mIN_ITEM_NAME_LEN + 1]; - - mString_Load_StringFromRom(article_str, mIN_ITEM_NAME_LEN, mString_ARTICLE_START + article); - command_len = mMsg_Get_Length_String(article_str, mIN_ITEM_NAME_LEN); - article_str[command_len] = CHAR_SPACE; - new_len = mMsg_MoveDataCut(data, start_idx + command_len + 1, start_idx, new_len, FALSE); - mMsg_CopyString(&data[start_idx], article_str, command_len + 1); +extern int mMsg_CopyItem(mMsg_Window_c* msg_p, int str_no, u8* data, int start_idx, int len, int article, + u32 capitalize) { + if (str_no < 0 || str_no >= mMsg_ITEM_STR_NUM) { + str_no = mMsg_ITEM_STR0; } - if (capitalize) { - data[start_idx] = mFont_small_to_capital(data[start_idx]); - } + { + int new_len; + int command_len = mFont_CodeSize_idx_get(data, start_idx); + u8* free_str_p = msg_p->item_str[str_no]; + int free_str_len = mMsg_Get_Length_String(free_str_p, mMsg_FREE_STRING_LEN); - return new_len; - } + new_len = mMsg_MoveDataCut(data, start_idx + free_str_len, start_idx + command_len, len, FALSE); + mMsg_CopyString(&data[start_idx], free_str_p, free_str_len); + + article = article != mIN_ARTICLE_NUM ? article : msg_p->item_str_article[str_no]; + if (article != mIN_ARTICLE_NONE) { + u8 article_str[mIN_ITEM_NAME_LEN + 1]; + + mString_Load_StringFromRom(article_str, mIN_ITEM_NAME_LEN, mString_ARTICLE_START + article); + command_len = mMsg_Get_Length_String(article_str, mIN_ITEM_NAME_LEN); + article_str[command_len] = CHAR_SPACE; + new_len = mMsg_MoveDataCut(data, start_idx + command_len + 1, start_idx, new_len, FALSE); + mMsg_CopyString(&data[start_idx], article_str, command_len + 1); + } + + if (capitalize) { + data[start_idx] = mFont_small_to_capital(data[start_idx]); + } + + return new_len; + } } extern int mMsg_CopyMail(mMsg_Window_c* msg_p, int str_no, u8* data, int start_idx, int len, u32 capitalize) { - if (str_no < 0 || str_no >= mMsg_MAIL_STR_NUM) { - str_no = mMsg_MAIL_STR0; - } - - { - int command_len = mFont_CodeSize_idx_get(data, start_idx); - u8* free_str_p = msg_p->mail_str[str_no]; - int free_str_len = mMsg_Get_Length_String(free_str_p, mMsg_MAIL_STRING_LEN); - int new_len = mMsg_MoveDataCut(data, start_idx + free_str_len, start_idx + command_len, len, TRUE); - - mMsg_CopyString(&data[start_idx], free_str_p, free_str_len); - - if (capitalize) { - data[start_idx] = mFont_small_to_capital(data[start_idx]); + if (str_no < 0 || str_no >= mMsg_MAIL_STR_NUM) { + str_no = mMsg_MAIL_STR0; } - return new_len; - } + { + int command_len = mFont_CodeSize_idx_get(data, start_idx); + u8* free_str_p = msg_p->mail_str[str_no]; + int free_str_len = mMsg_Get_Length_String(free_str_p, mMsg_MAIL_STRING_LEN); + int new_len = mMsg_MoveDataCut(data, start_idx + free_str_len, start_idx + command_len, len, TRUE); + + mMsg_CopyString(&data[start_idx], free_str_p, free_str_len); + + if (capitalize) { + data[start_idx] = mFont_small_to_capital(data[start_idx]); + } + + return new_len; + } } diff --git a/src/game/m_mushroom.c b/src/game/m_mushroom.c index a80ddb06..5b15746a 100644 --- a/src/game/m_mushroom.c +++ b/src/game/m_mushroom.c @@ -16,688 +16,690 @@ static lbRTC_time_c l_mmsr_zeto_time = { 0, 0, 0, 0, 0, 0, 0 }; /** * @brief Converts a saved time in mMsr_time_c format into its lbRTC_time_c representation. - * + * * @param dst The destination lbRTC_time_c * @param src The source mMsr_time_c **/ -static void mMsr_Mushtime2Rtc(lbRTC_time_c* dst, const mMsr_time_c* src) { - dst->year = src->year; - dst->month = src->month; - dst->day = src->day; - dst->hour = src->hour; - dst->min = src->hour_quarter * 15; - dst->sec = 0; - dst->weekday = lbRTC_Week(dst->year, dst->month, dst->day); +static void mMsr_Mushtime2Rtc(lbRTC_time_c* dst, mMsr_time_c* src) { + dst->year = src->year; + dst->month = src->month; + dst->day = src->day; + dst->hour = src->hour; + dst->min = src->hour_quarter * 15; + dst->sec = 0; + dst->weekday = lbRTC_Week(dst->year, dst->month, dst->day); } /** * @brief Converts time in lbRTC_time_c format into its mMsr_time_c representation. - * + * * @param dst The destination mMsr_time_c * @param src The source lbRTC_time_c **/ -static void mMsr_Rtc2MushTime(mMsr_time_c* dst, const lbRTC_time_c* src) { - dst->year = src->year; - dst->month = src->month; - dst->day = src->day; - dst->hour = src->hour; - dst->hour_quarter = src->min / 15; +static void mMsr_Rtc2MushTime(mMsr_time_c* dst, lbRTC_time_c* src) { + dst->year = src->year; + dst->month = src->month; + dst->day = src->day; + dst->hour = src->hour; + dst->hour_quarter = src->min / 15; } /** * @brief Gets whether or not the mushroom season event is currently active. - * + * * @return TRUE when event is active, FALSE otherwise **/ static int mMsr_CheckMushroomDay() { - return mEv_check_status(mEv_EVENT_MUSHROOM_SEASON, mEv_STATUS_ACTIVE) == TRUE; + return mEv_check_status(mEv_EVENT_MUSHROOM_SEASON, mEv_STATUS_ACTIVE) == TRUE; } /** * @brief Transforms a source lbRTC_time_c's minute member to the closest 15 minute margin in the future - * + * * @param dst The destination 15-minute demarcated lbRTC_time_c * @param src The source lbRTC_time_c **/ -static void mMsr_Set15Minites(lbRTC_time_c* dst, const lbRTC_time_c* src) { - static u8 min_15_table[4] = { 45, 30, 15, 0 }; - int i; +static void mMsr_Set15Minites(lbRTC_time_c* dst, lbRTC_time_c* src) { + static u8 min_15_table[4] = { 45, 30, 15, 0 }; + int i; - lbRTC_TimeCopy(dst, src); - for (i = 0; i < 4; i++) { - if (dst->min >= min_15_table[i]) { - dst->min = min_15_table[i]; - break; + lbRTC_TimeCopy(dst, src); + for (i = 0; i < 4; i++) { + if (dst->min >= min_15_table[i]) { + dst->min = min_15_table[i]; + break; + } } - } } /** * @brief Gets the initial amount of mushrooms which should be removed. - * + * * The amount removed is determined by how many 15-minute intervals * have passed since 8 AM. - * + * * @param rtc_time The current rtc time * @param mush_time The current mushroom 15-minute demarcated time - * + * * @return Number of mushrooms to initially remove **/ -static u32 mMsr_GetFirstClearMushroomNum(const lbRTC_time_c* rtc_time, const lbRTC_time_c* mush_time) { - u32 mushroom_num = 0; - lbRTC_time_c rtc_15_min; - lbRTC_time_c mush_15_min; +static u32 mMsr_GetFirstClearMushroomNum(lbRTC_time_c* rtc_time, lbRTC_time_c* mush_time) { + u32 mushroom_num = 0; + lbRTC_time_c rtc_15_min; + lbRTC_time_c mush_15_min; - if (mTM_AreTimesEqual(rtc_time, mush_time) != TRUE) { - mMsr_Set15Minites(&rtc_15_min, rtc_time); - mMsr_Set15Minites(&mush_15_min, mush_time); + if (mTM_AreTimesEqual(rtc_time, mush_time) != TRUE) { + mMsr_Set15Minites(&rtc_15_min, rtc_time); + mMsr_Set15Minites(&mush_15_min, mush_time); - if (lbRTC_IsOverTime(&mush_15_min, &rtc_15_min) == lbRTC_OVER) { - mushroom_num = lbRTC_IntervalTime(&rtc_15_min, &mush_15_min); - } - else { - mushroom_num = lbRTC_IntervalTime(&mush_15_min, &rtc_15_min); + if (lbRTC_IsOverTime(&mush_15_min, &rtc_15_min) == lbRTC_OVER) { + mushroom_num = lbRTC_IntervalTime(&rtc_15_min, &mush_15_min); + } else { + mushroom_num = lbRTC_IntervalTime(&mush_15_min, &rtc_15_min); + } + + mushroom_num /= 15; } - mushroom_num /= 15; - } - - return mushroom_num; + return mushroom_num; } /** * @brief Gets the number of removeable mushrooms in an acre and tracks which locations they are at. - * + * * Clearable mushrooms are mushrooms which are not buried. - * - * @param fg_block_items Pointer to the acre's item data + * + * @param fg_block_items Pointer to the acre's item data * @param save_deposit Pointer to the acre's buried item flags * @param block_candidates Pointer to the table of saved mushroom locations - * + * * @return Number of removeable mushrooms in the acre **/ static int mMsr_GetBlockClearAbleMushroomNum(mActor_name_t* fg_block_items, u16* save_deposit, u16* block_candidates) { - int clearable = 0; - if (fg_block_items != NULL && save_deposit != NULL && block_candidates != NULL) { - int ut_z; - for (ut_z = 0; ut_z < UT_Z_NUM; ut_z++) { - int ut_x; - for (ut_x = 0; ut_x < UT_X_NUM; ut_x++) { - if (*fg_block_items == ITM_FOOD_MUSHROOM && mFI_GetLineDeposit(save_deposit, ut_x) == FALSE) { - clearable++; - *block_candidates |= 1 << ut_x; + int clearable = 0; + if (fg_block_items != NULL && save_deposit != NULL && block_candidates != NULL) { + int ut_z; + for (ut_z = 0; ut_z < UT_Z_NUM; ut_z++) { + int ut_x; + for (ut_x = 0; ut_x < UT_X_NUM; ut_x++) { + if (*fg_block_items == ITM_FOOD_MUSHROOM && mFI_GetLineDeposit(save_deposit, ut_x) == FALSE) { + clearable++; + *block_candidates |= 1 << ut_x; + } + + fg_block_items++; + } + + save_deposit++; + block_candidates++; } - - fg_block_items++; - } - - save_deposit++; - block_candidates++; } - } - return clearable; + return clearable; } /** * @brief Splits up an amount of cleared mushrooms between all acres in town. - * + * * @param share_num Pointer to the list of mushrooms to remove for each acre * @param candidate_num Pointer to the list of mushrooms present for removal in each acre * @param candidate_block_num Total number of acres with clearable mushroom candidates * @param total_clearable Total number of clearable mushrooms in town * @param clear_num Amount of mushrooms to clear **/ -static void mMsr_SetShareNum(u8* share_num, u8* candidate_num, int candidate_block_num, int total_clearable, int clear_num) { - u8* share_num_p = share_num; - u8* candidate_num_p = candidate_num; - int clearable; - int i; +static void mMsr_SetShareNum(u8* share_num, u8* candidate_num, int candidate_block_num, int total_clearable, + int clear_num) { + u8* share_num_p = share_num; + u8* candidate_num_p = candidate_num; + int clearable; + int i; - /* count clearable mushrooms and log which acres */ - while(total_clearable != 0 && candidate_block_num != 0 && clear_num > candidate_block_num) { - share_num = share_num_p; - candidate_num = candidate_num_p; - clearable = 0; - for (i = 0; i < FG_BLOCK_TOTAL_NUM; i++) { - if (*candidate_num - *share_num > 0) { - clearable++; - (*share_num)++; - if (*candidate_num <= *share_num) { - candidate_block_num--; // acre doesn't have enough mushrooms in it, so remove it from the count + /* count clearable mushrooms and log which acres */ + while (total_clearable != 0 && candidate_block_num != 0 && clear_num > candidate_block_num) { + share_num = share_num_p; + candidate_num = candidate_num_p; + clearable = 0; + for (i = 0; i < FG_BLOCK_TOTAL_NUM; i++) { + if (*candidate_num - *share_num > 0) { + clearable++; + (*share_num)++; + if (*candidate_num <= *share_num) { + candidate_block_num--; // acre doesn't have enough mushrooms in it, so remove it from the count + } + } + + share_num++; + candidate_num++; } - } - share_num++; - candidate_num++; - } - - if (clearable == 0) { - break; // no clearable mushrooms left - } - - clear_num -= clearable; - total_clearable -= clearable; - } - - /* try to assign share for any cleared mushrooms left */ - while (clear_num != 0 && candidate_block_num != 0 && total_clearable != 0) { - int selected_block; - - share_num = share_num_p; - candidate_num = candidate_num_p; - selected_block = (int)(fqrand() * candidate_block_num); // randomly selected acre - - for (i = 0; i < FG_BLOCK_TOTAL_NUM; i++) { - if (*candidate_num - *share_num > 0) { - if (selected_block == 0) { - clear_num--; - (*share_num)++; - total_clearable--; - if (*candidate_num <= *share_num) { - candidate_block_num--; - } - break; + if (clearable == 0) { + break; // no clearable mushrooms left } - - selected_block--; - } - share_num++; - candidate_num++; + clear_num -= clearable; + total_clearable -= clearable; + } + + /* try to assign share for any cleared mushrooms left */ + while (clear_num != 0 && candidate_block_num != 0 && total_clearable != 0) { + int selected_block; + + share_num = share_num_p; + candidate_num = candidate_num_p; + selected_block = (int)(fqrand() * candidate_block_num); // randomly selected acre + + for (i = 0; i < FG_BLOCK_TOTAL_NUM; i++) { + if (*candidate_num - *share_num > 0) { + if (selected_block == 0) { + clear_num--; + (*share_num)++; + total_clearable--; + if (*candidate_num <= *share_num) { + candidate_block_num--; + } + break; + } + + selected_block--; + } + + share_num++; + candidate_num++; + } } - } } /** * @brief Removes candidate mushrooms in an acre. - * + * * @param fg_items Pointer to acre items * @param candidates Pointer to mushroom removal candidate location bitfield for the acre **/ static void mMsr_ClearBlockCandidateMushroom(mActor_name_t* fg_items, u16* candidates) { - int ut_z; - for (ut_z = 0; ut_z < UT_Z_NUM; ut_z++) { - int ut_x; - for (ut_x = 0; ut_x < UT_X_NUM; ut_x++) { - /* check if the 'candidate' bit is set for our x unit */ - if ((((*candidates) >> ut_x) & 1) == 1) { - *fg_items = EMPTY_NO; // clear item - mFI_SetFGUpData(); - } + int ut_z; + for (ut_z = 0; ut_z < UT_Z_NUM; ut_z++) { + int ut_x; + for (ut_x = 0; ut_x < UT_X_NUM; ut_x++) { + /* check if the 'candidate' bit is set for our x unit */ + if ((((*candidates) >> ut_x) & 1) == 1) { + *fg_items = EMPTY_NO; // clear item + mFI_SetFGUpData(); + } - fg_items++; + fg_items++; + } + + candidates++; } - - candidates++; - } } /** * @brief Removes all candidate mushrooms from all acres - * + * * @param fg Pointer to all acres' item data * @param candidates Pointer to mushroom removal candidate location bitfields * @param candidate_num Pointer to mushroom candidate number list **/ static void mMsr_ClearCandidateMushroom(mFM_fg_c* fg, u16* candidates, u8* candidate_num) { - int i; + int i; - for (i = 0; i < FG_BLOCK_TOTAL_NUM; i++) { - if (*candidate_num != 0) { - mMsr_ClearBlockCandidateMushroom((mActor_name_t*)fg->items, candidates); + for (i = 0; i < FG_BLOCK_TOTAL_NUM; i++) { + if (*candidate_num != 0) { + mMsr_ClearBlockCandidateMushroom((mActor_name_t*)fg->items, candidates); + } + + fg++; + candidates += UT_Z_NUM; + candidate_num++; } - - fg++; - candidates += UT_Z_NUM; - candidate_num++; - } } /** * @brief Clears a set number of mushrooms around town while ignoring the acre the player is in. - * + * * @param clear_num Number of mushrooms to clear * @param block_x The X-acre the player is currently in * @param block_z The Z-acre the player is currently in **/ static void mMsr_ClearMushrooms(int clear_num, int block_x, int block_z) { - static u16 candidate[FG_BLOCK_TOTAL_NUM][UT_Z_NUM]; - static u8 candidate_num[FG_BLOCK_TOTAL_NUM]; - static u8 share_num[FG_BLOCK_TOTAL_NUM]; + static u16 candidate[FG_BLOCK_TOTAL_NUM][UT_Z_NUM]; + static u8 candidate_num[FG_BLOCK_TOTAL_NUM]; + static u8 share_num[FG_BLOCK_TOTAL_NUM]; - mFM_fg_c* fg_block; - int candidate_blocks = 0; - int total_candidate_num = 0; - int i; + mFM_fg_c* fg_block; + int candidate_blocks = 0; + int total_candidate_num = 0; + int i; - fg_block = (mFM_fg_c*)Save_Get(fg); - bzero(candidate, FG_BLOCK_TOTAL_NUM * UT_Z_NUM * sizeof(u16)); - bzero(candidate_num, FG_BLOCK_TOTAL_NUM * sizeof(u8)); - bzero(share_num, FG_BLOCK_TOTAL_NUM * sizeof(u8)); - - for (i = 0; i < FG_BLOCK_TOTAL_NUM; i++) { - int clearable_num = mMsr_GetBlockClearAbleMushroomNum((mActor_name_t*)fg_block->items, Save_Get(deposit[i]), candidate[i]); - candidate_num[i] = clearable_num; - if (candidate_num[i] != 0) { - total_candidate_num += candidate_num[i]; - candidate_blocks++; - } - fg_block++; - } + fg_block = (mFM_fg_c*)Save_Get(fg); + bzero(candidate, FG_BLOCK_TOTAL_NUM * UT_Z_NUM * sizeof(u16)); + bzero(candidate_num, FG_BLOCK_TOTAL_NUM * sizeof(u8)); + bzero(share_num, FG_BLOCK_TOTAL_NUM * sizeof(u8)); - if ((block_x - 1) >= 0 && (block_x - 1) < FG_BLOCK_X_NUM && (block_z - 1) >= 0 && (block_z - 1) < FG_BLOCK_Z_NUM) { - u8 candidate_amt; - - int bx = (block_z - 1) * FG_BLOCK_X_NUM + (block_x - 1); - candidate_amt = candidate_num[bx]; - if (candidate_num[bx] != 0) { - candidate_num[bx] = 0; - total_candidate_num -= candidate_amt; - candidate_blocks--; - bzero(candidate[bx], UT_Z_NUM * sizeof(u16)); - } - } - - if (total_candidate_num > 0) { - if (total_candidate_num < clear_num) { - fg_block = (mFM_fg_c*)Save_Get(fg); - mMsr_ClearCandidateMushroom(fg_block, (u16*)candidate, candidate_num); - } - else { - mMsr_SetShareNum(share_num, candidate_num, candidate_blocks, total_candidate_num, clear_num); - fg_block = (mFM_fg_c*)Save_Get(fg); - for (i = 0; i < FG_BLOCK_TOTAL_NUM; i++) { - if (share_num[i] != 0) { - int cleared = mFI_ClearBlockItemRandom_common(ITM_FOOD_MUSHROOM, share_num[i], (mActor_name_t*)fg_block->items, Save_Get(deposit[i]), FALSE); - if (cleared > 0) { - mFI_SetFGUpData(); - } + for (i = 0; i < FG_BLOCK_TOTAL_NUM; i++) { + int clearable_num = + mMsr_GetBlockClearAbleMushroomNum((mActor_name_t*)fg_block->items, Save_Get(deposit[i]), candidate[i]); + candidate_num[i] = clearable_num; + if (candidate_num[i] != 0) { + total_candidate_num += candidate_num[i]; + candidate_blocks++; } - fg_block++; - } } - } + + if ((block_x - 1) >= 0 && (block_x - 1) < FG_BLOCK_X_NUM && (block_z - 1) >= 0 && (block_z - 1) < FG_BLOCK_Z_NUM) { + u8 candidate_amt; + + int bx = (block_z - 1) * FG_BLOCK_X_NUM + (block_x - 1); + candidate_amt = candidate_num[bx]; + if (candidate_num[bx] != 0) { + candidate_num[bx] = 0; + total_candidate_num -= candidate_amt; + candidate_blocks--; + bzero(candidate[bx], UT_Z_NUM * sizeof(u16)); + } + } + + if (total_candidate_num > 0) { + if (total_candidate_num < clear_num) { + fg_block = (mFM_fg_c*)Save_Get(fg); + mMsr_ClearCandidateMushroom(fg_block, (u16*)candidate, candidate_num); + } else { + mMsr_SetShareNum(share_num, candidate_num, candidate_blocks, total_candidate_num, clear_num); + fg_block = (mFM_fg_c*)Save_Get(fg); + for (i = 0; i < FG_BLOCK_TOTAL_NUM; i++) { + if (share_num[i] != 0) { + int cleared = mFI_ClearBlockItemRandom_common( + ITM_FOOD_MUSHROOM, share_num[i], (mActor_name_t*)fg_block->items, Save_Get(deposit[i]), FALSE); + if (cleared > 0) { + mFI_SetFGUpData(); + } + } + + fg_block++; + } + } + } } /** * @brief Clears mushrooms upon first load. - * + * * This funciton is necessary to remove the already missed mushrooms * if there are any. **/ extern void mMsr_FirstClearMushroom() { - int first_clear_num; - lbRTC_time_c mush_rtc_time; - mMsr_time_c* mush_time = Save_GetPointer(mushroom_time); - const lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); - - mMsr_Mushtime2Rtc(&mush_rtc_time, mush_time); - if (mTM_AreTimesEqual(&mush_rtc_time, &l_mmsr_zeto_time) == TRUE) { - lbRTC_TimeCopy(&mush_rtc_time, rtc_time); - } - - first_clear_num = mMsr_GetFirstClearMushroomNum(rtc_time, &mush_rtc_time); - if (first_clear_num > 0) { - mMsr_ClearMushrooms(first_clear_num, 0, 0); - } + int first_clear_num; + lbRTC_time_c mush_rtc_time; + mMsr_time_c* mush_time = Save_GetPointer(mushroom_time); + lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); - if (lbRTC_IsEqualTime(&mush_rtc_time, rtc_time, lbRTC_CHECK_DAYS | lbRTC_CHECK_MONTHS | lbRTC_CHECK_YEARS) == FALSE) { - mush_time->active = TRUE; - } + mMsr_Mushtime2Rtc(&mush_rtc_time, mush_time); + if (mTM_AreTimesEqual(&mush_rtc_time, &l_mmsr_zeto_time) == TRUE) { + lbRTC_TimeCopy(&mush_rtc_time, rtc_time); + } - mMsr_Rtc2MushTime(mush_time, rtc_time); + first_clear_num = mMsr_GetFirstClearMushroomNum(rtc_time, &mush_rtc_time); + if (first_clear_num > 0) { + mMsr_ClearMushrooms(first_clear_num, 0, 0); + } + + if (lbRTC_IsEqualTime(&mush_rtc_time, rtc_time, lbRTC_CHECK_DAYS | lbRTC_CHECK_MONTHS | lbRTC_CHECK_YEARS) == + FALSE) { + mush_time->active = TRUE; + } + + mMsr_Rtc2MushTime(mush_time, rtc_time); } /** * @brief Gets number of mushrooms that should be placed - * + * * @param mush_time Pointer to the next mushroom update time * @param rtc_time Pointer to the current RTC time * @param active Flag that force-controls whether mushrooms should be placed or not - * + * **/ static int mMsr_GetMushroomNum(const lbRTC_time_c* mush_time, const lbRTC_time_c* rtc_time, u8 active) { - int mushroom_num = 0; - if (active == TRUE || lbRTC_IsEqualTime(rtc_time, mush_time, lbRTC_CHECK_DAYS | lbRTC_CHECK_MONTHS | lbRTC_CHECK_YEARS) == FALSE) { - if (rtc_time->hour == mMsr_ACTIVE_HOUR) { - mushroom_num = mMsr_NUM_MUSHROOMS - rtc_time->min / 15; + int mushroom_num = 0; + if (active == TRUE || + lbRTC_IsEqualTime(rtc_time, mush_time, lbRTC_CHECK_DAYS | lbRTC_CHECK_MONTHS | lbRTC_CHECK_YEARS) == FALSE) { + if (rtc_time->hour == mMsr_ACTIVE_HOUR) { + mushroom_num = mMsr_NUM_MUSHROOMS - rtc_time->min / 15; + } else if (rtc_time->hour == (mMsr_ACTIVE_HOUR + 1) && rtc_time->min < 15) { + mushroom_num = mMsr_NUM_MUSHROOMS - 4; // 1 mushroom until 9:15 am + } } - else if (rtc_time->hour == (mMsr_ACTIVE_HOUR + 1) && rtc_time->min < 15) { - mushroom_num = mMsr_NUM_MUSHROOMS - 4; // 1 mushroom until 9:15 am - } - } - return mushroom_num; + return mushroom_num; } /** * @brief Gets whether an item is a valid tree and if that tree has space for a mushroom around it. - * + * * Valid trees are: * - Trees (not ones with hidden objects) * - Cedar trees (not ones with hidden objects) * - Fruit trees that currently have fruit * - Golden trees (including with golden shovel on them) * - Player-grown money trees (all denominations) - * + * * Spot check map (x = valid spot, T = tree): * xTx * xxx - * + * * @param item Pointer to the item to check * @param ut_x The X unit of the item * @param ut_z The Z unit of the item - * + * * @return TRUE when item is a valid tree with a valid spot, FALSE otherwise **/ static int mMsr_CheckAroundTree(mActor_name_t* item, u8 ut_x, u8 ut_z) { - static int area_table[5] = { - -1, /* xT- 1 left of tree */ + static int area_table[5] = { + -1, /* xT- 1 left of tree */ + /* --- */ + 1, /* -Tx 1 right of tree */ /* --- */ - 1, /* -Tx 1 right of tree */ - /* --- */ - 15, /* -T- 1 below, 1 left of tree */ + 15, /* -T- 1 below, 1 left of tree */ /* x-- */ - 16, /* -T- 1 below of tree */ + 16, /* -T- 1 below of tree */ /* -x- */ - 17 /* -T- 1 below, 1 right of tree */ - /* --x */ - }; + 17 /* -T- 1 below, 1 right of tree */ + /* --x */ + }; - int* area_p = area_table; - int res = FALSE; - if (ut_x < (UT_X_NUM - 1) && ut_z < (UT_Z_NUM - 1)) { - mActor_name_t item_no = *item; - if (item_no == TREE || item_no == TREE_APPLE_FRUIT || item_no == TREE_ORANGE_FRUIT || - item_no == TREE_PEACH_FRUIT || item_no == TREE_PEAR_FRUIT || - item_no == TREE_CHERRY_FRUIT || item_no == TREE_1000BELLS || - item_no == TREE_10000BELLS || item_no == TREE_30000BELLS || - item_no == TREE_100BELLS || item_no == TREE_PALM_FRUIT || - item_no == CEDAR_TREE || item_no == GOLD_TREE || item_no == GOLD_TREE_SHOVEL - ) { - int i; + int* area_p = area_table; + int res = FALSE; + if (ut_x < (UT_X_NUM - 1) && ut_z < (UT_Z_NUM - 1)) { + mActor_name_t item_no = *item; + if (item_no == TREE || item_no == TREE_APPLE_FRUIT || item_no == TREE_ORANGE_FRUIT || + item_no == TREE_PEACH_FRUIT || item_no == TREE_PEAR_FRUIT || item_no == TREE_CHERRY_FRUIT || + item_no == TREE_1000BELLS || item_no == TREE_10000BELLS || item_no == TREE_30000BELLS || + item_no == TREE_100BELLS || item_no == TREE_PALM_FRUIT || item_no == CEDAR_TREE || item_no == GOLD_TREE || + item_no == GOLD_TREE_SHOVEL) { + int i; - for (i = 0; i < 5; i++) { - if (*(item + *area_p) == EMPTY_NO) { - res = TRUE; - break; + for (i = 0; i < 5; i++) { + if (*(item + *area_p) == EMPTY_NO) { + res = TRUE; + break; + } + area_p++; + } } - area_p++; - } } - } - return res; + return res; } /** * @brief Counts all the valid mushroom trees in an acre. - * + * * @param item_p Pointer to the acre items - * + * * @return Number of valid mushroom trees in the acre **/ static u8 mMsr_GetBlockSetAbleMushroomTreeNum(mActor_name_t* item_p) { - u8 num = 0; - u8 ut_z; + u8 num = 0; + u8 ut_z; - for (ut_z = 0; ut_z < UT_Z_NUM; ut_z++) { - u8 ut_x; - for (ut_x = 0; ut_x < UT_X_NUM; ut_x++) { - if (mMsr_CheckAroundTree(item_p, ut_x, ut_z) == TRUE) { - num++; - } - item_p++; + for (ut_z = 0; ut_z < UT_Z_NUM; ut_z++) { + u8 ut_x; + for (ut_x = 0; ut_x < UT_X_NUM; ut_x++) { + if (mMsr_CheckAroundTree(item_p, ut_x, ut_z) == TRUE) { + num++; + } + item_p++; + } } - } - return num; + return num; } /** * @brief Sets a mushroom at a random valid spot under a tree. - * + * * @param item_p Pointer to the tree item **/ static void mMsr_SetMushroomAroundTree(mActor_name_t* item_p) { static int area_table[5] = { - -1, /* xT- 1 left of tree */ + -1, /* xT- 1 left of tree */ + /* --- */ + 1, /* -Tx 1 right of tree */ /* --- */ - 1, /* -Tx 1 right of tree */ - /* --- */ - 15, /* -T- 1 below, 1 left of tree */ + 15, /* -T- 1 below, 1 left of tree */ /* x-- */ - 16, /* -T- 1 below of tree */ + 16, /* -T- 1 below of tree */ /* -x- */ - 17 /* -T- 1 below, 1 right of tree */ - /* --x */ - }; + 17 /* -T- 1 below, 1 right of tree */ + /* --x */ + }; - int empty_space_num = 0; - int i; - - for (i = 0; i < 5; i++) { - if (*(item_p + area_table[i]) == EMPTY_NO) { - empty_space_num++; - } - } - - if (empty_space_num > 0) { - int selected = (int)(fqrand() * empty_space_num); + int empty_space_num = 0; + int i; for (i = 0; i < 5; i++) { - if (*(item_p + area_table[i]) == EMPTY_NO) { - if (selected <= 0) { - *(item_p + area_table[i]) = ITM_FOOD_MUSHROOM; - return; + if (*(item_p + area_table[i]) == EMPTY_NO) { + empty_space_num++; + } + } + + if (empty_space_num > 0) { + int selected = (int)(fqrand() * empty_space_num); + + for (i = 0; i < 5; i++) { + if (*(item_p + area_table[i]) == EMPTY_NO) { + if (selected <= 0) { + *(item_p + area_table[i]) = ITM_FOOD_MUSHROOM; + return; + } + selected--; + } } - selected--; - } } - } } /** * @brief Sets a mushroom randomly under N trees in an acre. - * + * * @param fg_items Pointer to the acre items * @param block_x Number of candidate trees in the acre **/ static void mMsr_SetBlockMashroom(mActor_name_t* fg_items, u8 candidate_num) { - int selected_num = (int)(fqrand() * candidate_num); - u8 ut_z; + int selected_num = (int)(fqrand() * candidate_num); + u8 ut_z; - for (ut_z = 0; ut_z < UT_Z_NUM; ut_z++) { - u8 ut_x; - for (ut_x = 0; ut_x < UT_X_NUM; ut_x++) { - if (mMsr_CheckAroundTree(fg_items, ut_x, ut_z) == TRUE) { - if (selected_num <= 0) { - mMsr_SetMushroomAroundTree(fg_items); - ut_z = UT_Z_NUM; /* break out by exceeding first loop case... bruh */ - break; + for (ut_z = 0; ut_z < UT_Z_NUM; ut_z++) { + u8 ut_x; + for (ut_x = 0; ut_x < UT_X_NUM; ut_x++) { + if (mMsr_CheckAroundTree(fg_items, ut_x, ut_z) == TRUE) { + if (selected_num <= 0) { + mMsr_SetMushroomAroundTree(fg_items); + ut_z = UT_Z_NUM; /* break out by exceeding first loop case... bruh */ + break; + } + + selected_num--; + } + + fg_items++; } - - selected_num--; - } - - fg_items++; } - } } /** * @brief Places all requested mushrooms in an acre column (A->F) - * + * * @param fg_block_col Pointer to the town mFM_fg_c data * @param candidate_num Pointer to the list containing number of candidate trees per acre **/ static void mMsr_SetLineMushroom(mFM_fg_c* fg_block_col, u8* candidate_num) { - u8* t_cand_num = candidate_num; - int candidate_rows = 0; - int bz; + u8* t_cand_num = candidate_num; + int candidate_rows = 0; + int bz; - for (bz = 0; bz < FG_BLOCK_Z_NUM; bz++) { - if (*candidate_num != 0) { - candidate_rows++; - } - - candidate_num += FG_BLOCK_X_NUM; - } - - if (candidate_rows > 0) { - int selected_z = (int)(fqrand() * candidate_rows); - candidate_num = t_cand_num; for (bz = 0; bz < FG_BLOCK_Z_NUM; bz++) { - if (*candidate_num != 0) { - if (selected_z <= 0) { - mMsr_SetBlockMashroom((mActor_name_t*)fg_block_col->items, *candidate_num); - break; + if (*candidate_num != 0) { + candidate_rows++; } - selected_z--; - } - /* Check next Z row */ - candidate_num += FG_BLOCK_X_NUM; - fg_block_col += FG_BLOCK_X_NUM; + candidate_num += FG_BLOCK_X_NUM; + } + + if (candidate_rows > 0) { + int selected_z = (int)(fqrand() * candidate_rows); + candidate_num = t_cand_num; + for (bz = 0; bz < FG_BLOCK_Z_NUM; bz++) { + if (*candidate_num != 0) { + if (selected_z <= 0) { + mMsr_SetBlockMashroom((mActor_name_t*)fg_block_col->items, *candidate_num); + break; + } + selected_z--; + } + + /* Check next Z row */ + candidate_num += FG_BLOCK_X_NUM; + fg_block_col += FG_BLOCK_X_NUM; + } } - } } /** * @brief Places N mushrooms around town, ignoring the acre the player is currently in. - * + * * @param mushroom_num Number of mushrooms to place * @param player_bx The X-acre the player is currently in * @param player_bz The Z-acre the player is currently in **/ static void mMsr_SetMushroomNum(int mushroom_num, int player_bx, int player_bz) { - static u8 candidate_num[FG_BLOCK_TOTAL_NUM]; + static u8 candidate_num[FG_BLOCK_TOTAL_NUM]; - mFM_fg_c* fg_block = (mFM_fg_c*)Save_Get(fg); - u8* candidate_p = candidate_num; - u8 possible_col_bitfield = 0; - int possible_cols = 0; - int bz; - int bx; + mFM_fg_c* fg_block = (mFM_fg_c*)Save_Get(fg); + u8* candidate_p = candidate_num; + u8 possible_col_bitfield = 0; + int possible_cols = 0; + int bz; + int bx; - bzero(candidate_num, FG_BLOCK_TOTAL_NUM * sizeof(u8)); + bzero(candidate_num, FG_BLOCK_TOTAL_NUM * sizeof(u8)); - /* Check all acres for candidate mushroom locations */ - for (bz = 0; bz < FG_BLOCK_Z_NUM; bz++) { - for (bx = 0; bx < FG_BLOCK_X_NUM; bx++) { - /* ensure we do not spawn a mushroom in the acre the player is currently in */ - if (bx != player_bx - 1 && bz != player_bz - 1) { - *candidate_p = mMsr_GetBlockSetAbleMushroomTreeNum((mActor_name_t*)fg_block->items); - if (*candidate_p != 0 && ((possible_col_bitfield >> bx) & 1) == 0) { - possible_cols++; - possible_col_bitfield |= 1 << bx; - } - } - - fg_block++; - candidate_p++; - } - } - - if (possible_cols > 0) { - for (mushroom_num; mushroom_num != 0; mushroom_num--) { - int selected; - fg_block = (mFM_fg_c*)Save_Get(fg); - candidate_p = candidate_num; - - /* if we've run out of X cols to place mushrooms in, look again */ - if (possible_cols == 0) { - possible_col_bitfield = 0; - possible_cols = 0; + /* Check all acres for candidate mushroom locations */ + for (bz = 0; bz < FG_BLOCK_Z_NUM; bz++) { for (bx = 0; bx < FG_BLOCK_X_NUM; bx++) { - candidate_p = candidate_num + bx; - for (bz = 0; bz < FG_BLOCK_Z_NUM; bz++) { - if (*candidate_p != 0) { - possible_cols++; - possible_col_bitfield |= 1 << bx; - break; + /* ensure we do not spawn a mushroom in the acre the player is currently in */ + if (bx != player_bx - 1 && bz != player_bz - 1) { + *candidate_p = mMsr_GetBlockSetAbleMushroomTreeNum((mActor_name_t*)fg_block->items); + if (*candidate_p != 0 && ((possible_col_bitfield >> bx) & 1) == 0) { + possible_cols++; + possible_col_bitfield |= 1 << bx; + } + } + + fg_block++; + candidate_p++; + } + } + + if (possible_cols > 0) { + for (mushroom_num; mushroom_num != 0; mushroom_num--) { + int selected; + fg_block = (mFM_fg_c*)Save_Get(fg); + candidate_p = candidate_num; + + /* if we've run out of X cols to place mushrooms in, look again */ + if (possible_cols == 0) { + possible_col_bitfield = 0; + possible_cols = 0; + for (bx = 0; bx < FG_BLOCK_X_NUM; bx++) { + candidate_p = candidate_num + bx; + for (bz = 0; bz < FG_BLOCK_Z_NUM; bz++) { + if (*candidate_p != 0) { + possible_cols++; + possible_col_bitfield |= 1 << bx; + break; + } + candidate_p += FG_BLOCK_X_NUM; /* move onto next Z row */ + } + } + + candidate_p = candidate_num; + if (possible_cols == 0) { + break; /* no possible locations left */ + } + } + + /* randomly select one of the possible X columns */ + selected = (int)(fqrand() * possible_cols); + + for (bx = 0; bx < FG_BLOCK_X_NUM; bx++) { + u8 bit = possible_col_bitfield >> bx; + if ((bit & 1) == 1) { + if (selected <= 0) { + mMsr_SetLineMushroom(fg_block, candidate_p); /* set mushroom on our X column */ + break; + } + + selected--; + } + + /* move onto next X column */ + fg_block++; + candidate_p++; } - candidate_p += FG_BLOCK_X_NUM; /* move onto next Z row */ - } } - - candidate_p = candidate_num; - if (possible_cols == 0) { - break; /* no possible locations left */ - } - } - - /* randomly select one of the possible X columns */ - selected = (int)(fqrand() * possible_cols); - - for (bx = 0; bx < FG_BLOCK_X_NUM; bx++) { - u8 bit = possible_col_bitfield >> bx; - if ((bit & 1) == 1) { - if (selected <= 0) { - mMsr_SetLineMushroom(fg_block, candidate_p); /* set mushroom on our X column */ - break; - } - - selected--; - } - - /* move onto next X column */ - fg_block++; - candidate_p++; - } } - } } /** * @brief Places or removes mushrooms around town based on game state. - * + * * For mushrooms to be placed/cleared: * - Field data must be ready. * - Scene must be outside in town. * - Field type must be FG (outside). * - 'MushroomDay' must be an active event. * - Mushrooms are placed if mMsr_GetMushroomNum is non-zero, otherwise they're cleared. - * + * * @param mushroom_num player_pos Current world position of the player **/ extern void mMsr_SetMushroom(xyz_t player_pos) { - int player_bx, player_bz; - lbRTC_time_c mush_rtc; - mMsr_time_c* mush_time = Save_GetPointer(mushroom_time); - const lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); + int player_bx, player_bz; + lbRTC_time_c mush_rtc; + mMsr_time_c* mush_time = Save_GetPointer(mushroom_time); + lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); - mMsr_Mushtime2Rtc(&mush_rtc, mush_time); - if (mTM_AreTimesEqual(&mush_rtc, &l_mmsr_zeto_time) == TRUE) { - /* mushroom time is not initialized, so initialize it to yesterday */ - lbRTC_TimeCopy(&mush_rtc, rtc_time); - lbRTC_Sub_DD(&mush_rtc, 1); - } - - mFI_Wpos2BlockNum(&player_bx, &player_bz, player_pos); - if (mFI_CheckFieldData() == TRUE) { - mActor_name_t field_id = mFI_GetFieldId(); - - if (Save_Get(scene_no) == SCENE_FG && mFI_GET_TYPE(field_id) == mFI_FIELDTYPE_FG && mMsr_CheckMushroomDay() == TRUE) { - int mushroom_num = mMsr_GetMushroomNum(&mush_rtc, rtc_time, mush_time->active); - if (mushroom_num > 0 && mushroom_num <= mMsr_NUM_MUSHROOMS) { - mMsr_SetMushroomNum(mushroom_num, player_bx, player_bz); - mMsr_Rtc2MushTime(mush_time, rtc_time); - mush_time->active = FALSE; - } - else { - int clear_num = mMsr_GetFirstClearMushroomNum(rtc_time, &mush_rtc); - if (clear_num > 0) { - mMsr_ClearMushrooms(clear_num, player_bx, player_bz); - if (mush_time->active != TRUE && lbRTC_IsEqualTime(&mush_rtc, rtc_time, lbRTC_CHECK_DAYS | lbRTC_CHECK_MONTHS | lbRTC_CHECK_YEARS) == FALSE) { - mush_time->active = TRUE; - } - - mMsr_Rtc2MushTime(mush_time, rtc_time); - } - } + mMsr_Mushtime2Rtc(&mush_rtc, mush_time); + if (mTM_AreTimesEqual(&mush_rtc, &l_mmsr_zeto_time) == TRUE) { + /* mushroom time is not initialized, so initialize it to yesterday */ + lbRTC_TimeCopy(&mush_rtc, rtc_time); + lbRTC_Sub_DD(&mush_rtc, 1); + } + + mFI_Wpos2BlockNum(&player_bx, &player_bz, player_pos); + if (mFI_CheckFieldData() == TRUE) { + mActor_name_t field_id = mFI_GetFieldId(); + + if (Save_Get(scene_no) == SCENE_FG && mFI_GET_TYPE(field_id) == mFI_FIELDTYPE_FG && + mMsr_CheckMushroomDay() == TRUE) { + int mushroom_num = mMsr_GetMushroomNum(&mush_rtc, rtc_time, mush_time->active); + if (mushroom_num > 0 && mushroom_num <= mMsr_NUM_MUSHROOMS) { + mMsr_SetMushroomNum(mushroom_num, player_bx, player_bz); + mMsr_Rtc2MushTime(mush_time, rtc_time); + mush_time->active = FALSE; + } else { + int clear_num = mMsr_GetFirstClearMushroomNum(rtc_time, &mush_rtc); + if (clear_num > 0) { + mMsr_ClearMushrooms(clear_num, player_bx, player_bz); + if (mush_time->active != TRUE && + lbRTC_IsEqualTime(&mush_rtc, rtc_time, + lbRTC_CHECK_DAYS | lbRTC_CHECK_MONTHS | lbRTC_CHECK_YEARS) == FALSE) { + mush_time->active = TRUE; + } + + mMsr_Rtc2MushTime(mush_time, rtc_time); + } + } + } } - } } diff --git a/src/game/m_needlework.c b/src/game/m_needlework.c index e3721607..93aad0f3 100644 --- a/src/game/m_needlework.c +++ b/src/game/m_needlework.c @@ -148,7 +148,7 @@ extern void mNW_AGB_to_GC_texture(u8* agb, u8* gc) { for (i = 0; i < mNW_DESIGN_TEX_SIZE; i++) { u8 src = *agb++; - *gc++ = (((src >> 4) & 0xF) | ((src & 0xF) << 4)); + *gc++ = (((src & 0xF0) >> 4) | ((src & 0xF) << 4)); } } diff --git a/src/game/m_needlework_ovl.c b/src/game/m_needlework_ovl.c index 44919650..2eef59bc 100644 --- a/src/game/m_needlework_ovl.c +++ b/src/game/m_needlework_ovl.c @@ -338,12 +338,11 @@ static void mNW_set_frame_dl(Submenu* submenu, GAME* game, mSM_MenuInfo_c* menu_ extern Gfx sav_mark_winT_before_model[]; extern void mNW_draw_sav_mark_before(GAME* game) { - GRAPH* graph = game->graph; int g; int prim_g; int env_g; - OPEN_POLY_OPA_DISP(graph); + OPEN_POLY_OPA_DISP(game->graph); gSPDisplayList(POLY_OPA_DISP++, sav_mark_winT_before_model); g = game->frame_counter % 40; @@ -356,7 +355,7 @@ extern void mNW_draw_sav_mark_before(GAME* game) { env_g = g * 3; gDPSetEnvColor(POLY_OPA_DISP++, env_g, 210 + g * 2, env_g, 255); - CLOSE_POLY_OPA_DISP(graph); + CLOSE_POLY_OPA_DISP(game->graph); } extern Gfx sav_mark_winT_model[]; @@ -456,6 +455,22 @@ static void mNW_set_frame_dl_cpo(Submenu* submenu, GAME* game, mSM_MenuInfo_c* m CLOSE_POLY_OPA_DISP(graph); mNW_draw_sav_mark_before(game); + +// TODO: I don't like this devation. It's probably fake. +#if VERSION >= VER_GAFU01_00 + { + s16* y_p = mark_table_y; + s16* x_p = mark_table_x; + int j; + for (j = 0; j < mNW_DESIGN_COUNT; j++, y_p++, x_p++) { + if (mNW_check_mark_flg(submenu, j)) { + Matrix_push(); + mNW_draw_sav_mark(game, *x_p, *y_p); + Matrix_pull(); + } + } + } +#else for (j = 0; j < mNW_DESIGN_COUNT; j++) { if (mNW_check_mark_flg(submenu, j)) { Matrix_push(); @@ -463,6 +478,7 @@ static void mNW_set_frame_dl_cpo(Submenu* submenu, GAME* game, mSM_MenuInfo_c* m Matrix_pull(); } } +#endif } static void mNW_needlework_ovl_draw(Submenu* submenu, GAME* game) { diff --git a/src/game/m_notice.c b/src/game/m_notice.c index 86c63134..926255c0 100644 --- a/src/game/m_notice.c +++ b/src/game/m_notice.c @@ -141,14 +141,12 @@ static void mNtc_operate_data_list() { static void mNtc_sort_data_list() { mNtc_date_data_c replace_data; - mNtc_date_data_c now_data; int replace_idx; int i, j; /* sort from earliest to latest dates */ for (i = 0; i < mNtc_DATA_LIST_NUM; i++) { - now_data = mNtc_auto_nwrite_data[i]; - replace_data = now_data; + replace_data = mNtc_auto_nwrite_data[i]; replace_idx = i; /* search through all entries ahead and find the next closest date */ @@ -160,7 +158,7 @@ static void mNtc_sort_data_list() { } /* swap the entries */ - mNtc_auto_nwrite_data[replace_idx] = now_data; + mNtc_auto_nwrite_data[replace_idx] = mNtc_auto_nwrite_data[i]; mNtc_auto_nwrite_data[i] = replace_data; } } @@ -283,6 +281,8 @@ static void mNtc_set_treasure_string(AnmPersonalID_c* sender_id, mActor_name_t i mHandbill_Set_free_str(5, land_name, land_name_len); } +// TODO: deviation implies fakematch +#if VERSION != VER_GAFE01_00 static void mNtc_check_treasure() { lbRTC_time_c* treasure_buried_time; lbRTC_time_c* treasure_checked_time; @@ -292,6 +292,104 @@ static void mNtc_check_treasure() { u32 comp_time_buried; lbRTC_time_c rtc_time; int valid_animal_ids[ANIMAL_NUM_MAX]; + int* valid_id_p; + Animal_c* selected_animal; + int valid_animal_num; + int i; + u8 header[mHandbill_FOOTER_LEN]; + u8 footer[mHandbill_FOOTER_LEN]; + int mem; + int interval_days; + int header_back_pos; + mNtc_board_post_c post; + mActor_name_t item; + int b_x; + int b_z; + f32 rng; + int list_type; + + treasure_buried_time = Save_GetPointer(treasure_buried_time); + treasure_checked_time = Save_GetPointer(treasure_checked_time); + animal = Save_Get(animals); + land_info = Save_GetPointer(land_info); + valid_animal_num = 0; + rtc_time = Common_Get(time.rtc_time); + + if (rtc_time.hour >= mTM_FIELD_RENEW_HOUR) { + comp_time_rtc = lbRTC_TIME_TO_U32(&rtc_time); + comp_time_buried = lbRTC_TIME_TO_U32(treasure_buried_time); + if (comp_time_rtc > comp_time_buried) { + interval_days = lbRTC_GetIntervalDays(treasure_buried_time, &rtc_time); + } else if (comp_time_rtc < comp_time_buried) { + interval_days = lbRTC_GetIntervalDays(&rtc_time, treasure_buried_time); + } else { + interval_days = 0; + } + + if (lbRTC_IsEqualTime(treasure_buried_time, &mTM_rtcTime_clear_code, lbRTC_CHECK_ALL) || + interval_days >= mNtc_MIN_DAYS_BETWEEN_TREASURE) { + if (lbRTC_IsEqualTime(treasure_checked_time, &mTM_rtcTime_clear_code, lbRTC_CHECK_ALL) || + treasure_checked_time->year != rtc_time.year || treasure_checked_time->month != rtc_time.month || + treasure_checked_time->day != rtc_time.day) { + for (i = 0, valid_id_p = valid_animal_ids; i < ANIMAL_NUM_MAX; i++, animal++) { + if (mNpc_CheckFreeAnimalPersonalID(&animal->id) == FALSE) { + for (mem = 0; mem < ANIMAL_MEMORY_NUM; mem++) { + if (animal->memories[mem].memory_player_id.land_id == land_info->id && + mLd_CheckCmpLandName(animal->memories[mem].memory_player_id.land_name, + land_info->name)) { + if (valid_animal_num == ANIMAL_NUM_MAX) { + return; + } + + valid_animal_num++; + *valid_id_p++ = i; + break; + } + } + } + } + + if (valid_animal_num != 0 && fqrand() < mNtc_TREASURE_CHANCE) { + b_x = 0; + b_z = 0; + + /* 1/3rd chance of pitfall, 2/3rds chance of rare furniture */ + rng = fqrand(); + if (rng < (1.0f / 3.0f)) { + item = ITM_PITFALL; + } else { + list_type = rng < (2.0f / 3.0f) + ? mSP_LISTTYPE_LOTTERY + : mSP_LISTTYPE_EVENT; /* 50/50 to roll redd or lottery furniture*/ + mSP_SelectRandomItem_New(NULL, &item, 1, NULL, 0, mSP_KIND_FURNITURE, list_type, FALSE); + } + + if (mFI_SetTreasure(&b_x, &b_z, item)) { + selected_animal = + Save_GetPointer(animals[valid_animal_ids[RANDOM(valid_animal_num) % valid_animal_num]]); + mNtc_set_treasure_string(&selected_animal->id, item, b_x, b_z); + lbRTC_TimeCopy(&post.post_time, &rtc_time); + mHandbill_Load_HandbillFromRom(header, &header_back_pos, footer, post.message, + 0x1F0 + selected_animal->id.looks * 3 + (RANDOM(3) % 3)); + mNtc_notice_write(&post); + lbRTC_TimeCopy(treasure_buried_time, &rtc_time); + } + } + } + } + } +} +#else +static void mNtc_check_treasure() { + lbRTC_time_c* treasure_buried_time; + lbRTC_time_c* treasure_checked_time; + Animal_c* animal; + mLd_land_info_c* land_info; + u32 comp_time_rtc; + u32 comp_time_buried; + lbRTC_time_c rtc_time; + int valid_animal_ids[ANIMAL_NUM_MAX]; + Animal_c* selected_animal; int valid_animal_num; int i; u8 header[mHandbill_FOOTER_LEN]; @@ -362,12 +460,12 @@ static void mNtc_check_treasure() { } if (mFI_SetTreasure(&b_x, &b_z, item)) { - animal = + selected_animal = Save_GetPointer(animals[valid_animal_ids[RANDOM(valid_animal_num) % valid_animal_num]]); - mNtc_set_treasure_string(&animal->id, item, b_x, b_z); + mNtc_set_treasure_string(&selected_animal->id, item, b_x, b_z); lbRTC_TimeCopy(&post.post_time, &rtc_time); mHandbill_Load_HandbillFromRom(header, &header_back_pos, footer, post.message, - 0x1F0 + animal->id.looks * 3 + (RANDOM(3) % 3)); + 0x1F0 + selected_animal->id.looks * 3 + (RANDOM(3) % 3)); mNtc_notice_write(&post); lbRTC_TimeCopy(treasure_buried_time, &rtc_time); } @@ -376,6 +474,7 @@ static void mNtc_check_treasure() { } } } +#endif static void mNtc_set_near_old_nwrite_data(lbRTC_time_c* nwrite_time, lbRTC_year_t* nwrite_year, u8* nwrite_num) { mNtc_date_data_c* auto_nwrite_p; diff --git a/src/game/m_notice_ovl.c b/src/game/m_notice_ovl.c index 1acc6fc2..1ed2853a 100644 --- a/src/game/m_notice_ovl.c +++ b/src/game/m_notice_ovl.c @@ -403,6 +403,11 @@ static void mNT_notice_ovl_move(Submenu* submenu) { (*ovl_move_proc[menu_info->proc_status])(submenu, menu_info); } +#if VERSION >= VER_GAFU01_00 +static void mNT_notice_draw_init(mSM_MenuInfo_c* menu_info) { + // stubbed +} +#else static u8** mNT_notice_draw_init(mSM_MenuInfo_c* menu_info) { u8** tex_p = kei_win_st_tex_tbl; int i; @@ -413,6 +418,7 @@ static u8** mNT_notice_draw_init(mSM_MenuInfo_c* menu_info) { return tex_p; } +#endif extern Gfx kei_win_model[]; diff --git a/src/game/m_npc.c b/src/game/m_npc.c index bc00e398..ebf2f731 100644 --- a/src/game/m_npc.c +++ b/src/game/m_npc.c @@ -2723,14 +2723,15 @@ static void mNpc_SetNpcHome(Animal_c* animal, Anmhome_c* reserved, u8 reserved_n idx = fake_table_p[n]; if (idx >= reserved_num) { - /* I don't like this */ - while ((idx = fake_table_p[n], idx >= reserved_num) && n < reserved_num) { + while ((fake_table_p[n] >= reserved_num) && n < reserved_num) { n++; } if (n >= reserved_num) { return; } + + idx = fake_table_p[n]; } if (idx < reserved_num) { @@ -4330,6 +4331,7 @@ static int mNpc_GrowLooksNpcIdx(u8 looks) { } if (candidates > 0) { + looks_table = npc_looks_table; selected = RANDOM(candidates); npc_idx = 0; @@ -4338,7 +4340,7 @@ static int mNpc_GrowLooksNpcIdx(u8 looks) { break; } - for (j = 0; j < 8; j++) { + for (j = 0; j < 8; looks_table++, npc_idx++, j++) { if (npc_idx >= NPC_NUM) { break; } @@ -4351,8 +4353,6 @@ static int mNpc_GrowLooksNpcIdx(u8 looks) { selected--; } } - - npc_idx++; } if (res != -1) { @@ -4617,7 +4617,6 @@ extern int mNpc_GetMakeUtNuminBlock_hard_area(int* ut_x, int* ut_z, int bx, int int now_ut_x; int now_ut_z; mCoBG_Collision_u* col; - mCoBG_Collision_u* col_p; mActor_name_t* items; int min_ut_x; int min_ut_z; @@ -4639,14 +4638,10 @@ extern int mNpc_GetMakeUtNuminBlock_hard_area(int* ut_x, int* ut_z, int bx, int if (items != NULL && col != NULL) { for (i = restrict_area; i < UT_Z_NUM - restrict_area; i++) { for (j = restrict_area; j < UT_X_NUM - restrict_area; j++) { - col_p = &col[i * UT_X_NUM + j]; - - if (mNpc_CheckNpcSet_fgcol_hard(items[i * UT_X_NUM + j], col_p->data.unit_attribute) == TRUE) { - center = col_p->data.center; - + if (mNpc_CheckNpcSet_fgcol_hard(items[i * UT_X_NUM + j], col[i * UT_X_NUM + j].data.unit_attribute) == TRUE) { /* Check that the height of each point on the unit is equal*/ - if ((int)center == col_p->data.top_left && center == col_p->data.bot_left && - center == col_p->data.bot_right && (int)center == col_p->data.top_right) { + if (col[i * UT_X_NUM + j].data.center == col[i * UT_X_NUM + j].data.top_left && col[i * UT_X_NUM + j].data.center == col[i * UT_X_NUM + j].data.bot_left && + col[i * UT_X_NUM + j].data.center == col[i * UT_X_NUM + j].data.bot_right && col[i * UT_X_NUM + j].data.center == col[i * UT_X_NUM + j].data.top_right) { now_ut_x = 8 - j; now_ut_z = 8 - i; @@ -4801,10 +4796,7 @@ extern int mNpc_GetMakeUtNuminBlock_hide_hard_area(int* ut_x, int* ut_z, int bx, int now_ut_z; int now_ut_x; mCoBG_Collision_u* col_top; - mCoBG_Collision_u* col_p; mActor_name_t* fg_top; - mActor_name_t* item_p; - u32 center; int min_ut_x; int min_ut_z; int res; @@ -4827,15 +4819,10 @@ extern int mNpc_GetMakeUtNuminBlock_hide_hard_area(int* ut_x, int* ut_z, int bx, for (i = restrict_area; i < UT_Z_NUM - restrict_area; i++) { for (j = restrict_area; j < UT_X_NUM - restrict_area; j++) { - item_p = &fg_top[i * UT_X_NUM + j]; - col_p = &col_top[i * UT_X_NUM + j]; - - if (mNpc_CheckNpcSet_fgcol_hard(item_p[0], col_p->data.unit_attribute) == TRUE) { - center = col_p->data.center; - + if (mNpc_CheckNpcSet_fgcol_hard(fg_top[i * UT_X_NUM + j], col_top[i * UT_X_NUM + j].data.unit_attribute) == TRUE) { /* Check that the height of each point on the unit is equal*/ - if ((int)center == col_p->data.top_left && center == col_p->data.bot_left && - center == col_p->data.bot_right && (int)center == col_p->data.top_right && + if (col_top[i * UT_X_NUM + j].data.center == col_top[i * UT_X_NUM + j].data.top_left && col_top[i * UT_X_NUM + j].data.center == col_top[i * UT_X_NUM + j].data.bot_left && + col_top[i * UT_X_NUM + j].data.center == col_top[i * UT_X_NUM + j].data.bot_right && col_top[i * UT_X_NUM + j].data.center == col_top[i * UT_X_NUM + j].data.top_right && ((hide_ut_bit[i] >> j) & 1) == 1) { now_ut_x = 8 - j; @@ -5753,6 +5740,113 @@ extern int mNpc_CheckFtrIsIslandNormalFtr(mActor_name_t ftr) { return res; } +// TODO: The deviation here is likely fakematch +#if VERSION != VER_GAFE01_00 +extern int mNpc_SetIslandFtr(PersonalID_c* pid, mActor_name_t ftr) { + int n; + Anmmem_c* memory; + mActor_name_t* island_room; + mActor_name_t rsv_item; + int variant; + int set; + int direct; + int i; + int j; + int slot; + int mem_idx; + + memory = Save_Get(island).animal.memories; + island_room = mNpc_GetIslandRoomP(Save_Get(island).animal.id.npc_id); + n = 0; + rsv_item = EMPTY_NO; + set = FALSE; + slot = 0; + direct = 0; + + if (ITEM_IS_FTR(ftr) && island_room != NULL && pid != NULL && mPr_NullCheckPersonalID(pid) == FALSE) { + mem_idx = mNpc_GetAnimalMemoryIdx(pid, memory, ANIMAL_MEMORY_NUM); + + if (mem_idx == -1) { + memory = &memory[mNpc_ForceGetFreeAnimalMemoryIdx(&Save_Get(island).animal, memory, ANIMAL_MEMORY_NUM)]; + mNpc_SetAnimalMemory(pid, &Save_Get(island).animal.id, memory); + } else { + memory = &memory[mem_idx]; + } + + /* Unnecessary NULL check, memory is guaranteed to exist */ + if (memory != NULL) { + if (mNpc_CheckFtrIsIslandBestFtr(ftr) == TRUE) { + int idx = mNpc_GetIslandFtrIdx(ftr); + + if (idx != -1 && mNpc_CheckIslandNpcRoomFtrIdx(idx) == -1) { + memory->memuni.island.have_bitfield |= (1 << idx); + set = TRUE; + } + } else { + mActor_name_t ftr_variant0; + mActor_name_t ftr_variant1; + int ftr_unit = aMR_GetFurnitureUnit(ftr); + + if (ftr_unit == mRmTp_FTRSIZE_1x1) { + ftr_variant0 = RSV_ISLAND_FTR0; + ftr_variant1 = RSV_ISLAND_FTR4; + } else { + ftr_variant0 = RSV_ISLAND_FTR0 + (ftr_unit + 1) * 4; + ftr_variant1 = EMPTY_NO; + } + + for (i = 0; i < UT_TOTAL_NUM; i++) { + if (ITEM_IS_FTR(*island_room)) { + n++; + } else if (*island_room >= RSV_ISLAND_FTR0 && *island_room <= RSV_ISLAND_FTR15) { + variant = -1; + + for (j = 0; j < mRmTp_DIRECT_NUM; j++) { + if (*island_room == (mActor_name_t)(ftr_variant0 + j)) { + direct = j; + variant = 0; + break; + } else if (*island_room == (mActor_name_t)(ftr_variant1 + j)) { + direct = j; + variant = 1; + break; + } + } + + if (variant != -1 && mNpc_CheckIslandNpcRoomFtrIdx(n) == -1) { + memory->memuni.island.have_bitfield |= (1 << n); + + if (variant == 0) { + slot = (ftr_variant0 - RSV_ISLAND_FTR0) / mNpc_ISLAND_FTR_SAVE_NUM; + } else { + slot = (ftr_variant1 - RSV_ISLAND_FTR0) / mNpc_ISLAND_FTR_SAVE_NUM; + } + + if (slot < mNpc_ISLAND_FTR_SAVE_NUM) { + Save_Get(island).animal.anmuni.island_ftr[slot] = + aMR_FurnitureFg_to_FurnitureFgWithDirect(ftr, direct); + set = TRUE; + } + + break; + } + + n++; + } + + if (n == mNpc_ISLAND_FTR_NUM) { + break; + } + + island_room++; + } + } + } + } + + return set; +} +#else extern int mNpc_SetIslandFtr(PersonalID_c* pid, mActor_name_t ftr) { int n; Anmmem_c* memory; @@ -5858,6 +5952,7 @@ extern int mNpc_SetIslandFtr(PersonalID_c* pid, mActor_name_t ftr) { return set; } +#endif extern int mNpc_EraseIslandFtr(mActor_name_t ftr) { int n; diff --git a/src/game/m_player.c b/src/game/m_player.c index 07f3a28c..7e30669b 100644 --- a/src/game/m_player.c +++ b/src/game/m_player.c @@ -31,13 +31,13 @@ /* Static function declarations, add as needed for intellisense */ static void Player_actor_Item_Setup_main(ACTOR* actor, int now, int last); static mActor_name_t Player_actor_Get_ItemNoSubmenu(void); -static int Player_actor_request_main_broken_axe_type_swing(GAME* game, const xyz_t* pos, mActor_name_t hit_item, +static int Player_actor_request_main_broken_axe_type_swing(GAME* game, xyz_t* pos, mActor_name_t hit_item, int hit_ut_x, int hit_ut_z, int priority); -static int Player_actor_request_main_swing_axe_all(GAME* game, const xyz_t* pos, mActor_name_t hit_item, u16 damage_no, +static int Player_actor_request_main_swing_axe_all(GAME* game, xyz_t* pos, mActor_name_t hit_item, u16 damage_no, int hit_ut_x, int hit_ut_z, int priority); -static int Player_actor_request_main_broken_axe_type_reflect(GAME* game, const xyz_t* pos, mActor_name_t hit_item, +static int Player_actor_request_main_broken_axe_type_reflect(GAME* game, xyz_t* pos, mActor_name_t hit_item, ACTOR* hit_actor, int priority); -static int Player_actor_request_main_reflect_axe_all(GAME* game, const xyz_t* pos, mActor_name_t hit_item, +static int Player_actor_request_main_reflect_axe_all(GAME* game, xyz_t* pos, mActor_name_t hit_item, u16 damage_no, ACTOR* hit_actor, int priority); static int Player_actor_request_main_air_axe_all(GAME* game, int priority); static int Player_actor_request_main_rotate_umbrella_all(GAME* game, int prio); @@ -306,8 +306,8 @@ static int Player_actor_request_main_release_creature_all(GAME* game, int type, ACTOR* release_actor_p, int prio); static int Player_actor_request_main_complete_payment(GAME* game, int prio); static int Player_actor_request_main_push(GAME* game, int ftr_no, s16 angle_y, xyz_t* pos, int priority); -static int Player_actor_request_main_pull(GAME* game, int ftr_no, s16 angle, xyz_t* start_pos, xyz_t* end_pos, - xyz_t* ofs, int priority); +static int Player_actor_request_main_pull(GAME* game, int ftr_no, s16 angle, const xyz_t* start_pos, const xyz_t* end_pos, + const xyz_t* ofs, int priority); static int Player_actor_request_main_rotate_furniture(GAME* game, int ftr_no, s16 angle, xyz_t* pos, int type, int priority); static int Player_actor_request_main_open_furniture(GAME* game, s16 angle, xyz_t* pos, int anim_idx, int priority); @@ -505,18 +505,13 @@ static int Player_actor_request_main_demo_getoff_boat_all(GAME* game, const xyz_ static void Player_actor_init_value(ACTOR* actorx, GAME* game) { PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; - GAME_PLAY* play = (GAME_PLAY*)game; - int* shake_tree_table_ut_x_p; - int* shake_tree_table_ut_z_p; - s8* radio_exercise_command_ring_buffer_p; - int i; player->actor_class.gravity = -1.0f; player->actor_class.max_velocity_y = -8.0f; player->actor_class.scale.x = 0.01f; player->actor_class.scale.y = 0.01f; player->actor_class.scale.z = 0.01f; - player->balloon_actor = Actor_info_make_actor(&play->actor_info, game, mAc_PROFILE_BALLOON, + player->balloon_actor = Actor_info_make_actor(&((GAME_PLAY*)game)->actor_info, game, mAc_PROFILE_BALLOON, actorx->world.position.x, actorx->world.position.y, actorx->world.position.z, 0, 0, 0, -1, -1, -1, EMPTY_NO, -1, -1, -1); player->animation0_idx = -1; @@ -603,17 +598,36 @@ static void Player_actor_init_value(ACTOR* actorx, GAME* game) { player->Check_able_force_speak_label_proc = &Player_actor_Check_able_force_speak_label; player->Check_stung_mosquito_proc = &Player_actor_Check_stung_mosquito; - shake_tree_table_ut_x_p = player->shake_tree_ut_x; - shake_tree_table_ut_z_p = player->shake_tree_ut_z; - for (i = 0; i < 3; i++) { - *shake_tree_table_ut_x_p++ = -1; - *shake_tree_table_ut_z_p++ = -1; + { + int* shake_tree_table_ut_x_p = player->shake_tree_ut_x; + int* shake_tree_table_ut_z_p = player->shake_tree_ut_z; + int i; + + for (i = 0; i < 3; i++) { + *shake_tree_table_ut_x_p++ = -1; + *shake_tree_table_ut_z_p++ = -1; + } } - radio_exercise_command_ring_buffer_p = player->radio_exercise_command_ring_buffer; - for (i = 0; i < 8; i++) { - *radio_exercise_command_ring_buffer_p++ = -1; +// TODO: I don't like this deviation between 1.3.2/US AC and 2.0/Aus AC +#if VERSION >= VER_GAFU01_00 + { + int i; + + for (i = 0; i < 8; i++) { + player->radio_exercise_command_ring_buffer[i] = -1; + } } +#else + { + s8* radio_exercise_command_ring_buffer_p = player->radio_exercise_command_ring_buffer; + int i; + + for (i = 0; i < 8; i++) { + *radio_exercise_command_ring_buffer_p++ = -1; + } + } +#endif Player_actor_Set_old_sound_frame_counter(actorx); } diff --git a/src/game/m_player_common.c_inc b/src/game/m_player_common.c_inc index 9a36b551..44376ded 100644 --- a/src/game/m_player_common.c_inc +++ b/src/game/m_player_common.c_inc @@ -3250,11 +3250,19 @@ static int Player_actor_Check_axe_after(ACTOR* actorx, xyz_t* target_pos_p, mAct } for (i = 0; i < unit_count; i++) { +// TODO: this feels fake, unlikely to have been changed between US and Aus +#if VERSION == VER_GAFE01_00 unit_center_p = &unit_center_pos[i]; unit_exist_table[i] = mFI_Wpos2UtCenterWpos(unit_center_p, unit_pos[i]); if (unit_exist_table[i] != FALSE) { f32 dx = unit_center_p->x - player_move_pos.x; f32 dz = unit_center_p->z - player_move_pos.z; +#else + unit_exist_table[i] = mFI_Wpos2UtCenterWpos(&unit_center_pos[i], unit_pos[i]); + if (unit_exist_table[i] != FALSE) { + f32 dx = unit_center_pos[i].x - player_move_pos.x; + f32 dz = unit_center_pos[i].z - player_move_pos.z; +#endif f32 dist_center = Math3DVecLength2D(dx, dz); int angle_center = atans_table(dz, dx) - player_angle_y; int abs_angle_center = ABS(angle_center); @@ -3684,7 +3692,7 @@ static int Player_actor_Set_ScrollDemo_forDemo_wade(ACTOR* actorx) { return FALSE; } -static int Player_actor_Set_ScrollDemo_forDemo_geton_boat_wade(ACTOR* actorx, s16 angle_y, f32 border_start) { +static int Player_actor_Set_ScrollDemo_forDemo_geton_boat_wade(ACTOR* actorx, f32 border_start, s16 angle_y) { int dir = Player_actor_CheckAbleMoveDemoWadeBoatBlock(actorx, angle_y, border_start); if (dir != mFI_MOVEDIR_NONE) { @@ -4245,8 +4253,14 @@ static int Player_actor_able_request_main_index_for_reset(int request_main_index return FALSE; } +#if VERSION >= VER_GAFU01_00 +#define Player_actor_RESET_COUNT_FOR_RESET 4 +#else +#define Player_actor_RESET_COUNT_FOR_RESET 2 +#endif + static int Player_actor_check_able_request_main_index_for_reset(int request_main_index) { - if (Common_Get(reset_flag) && Now_Private->reset_count == 2 && + if (Common_Get(reset_flag) && Now_Private->reset_count == Player_actor_RESET_COUNT_FOR_RESET && Player_actor_able_request_main_index_for_reset(request_main_index) != FALSE) { if (Common_Get(reset_type) != 3) { Common_Set(reset_type, 3); @@ -7154,7 +7168,7 @@ static void Player_actor_Get_PickupHandPosition(ACTOR* actorx, xyz_t* pos_p, f32 pos_p->z += z; } -static void Player_actor_Get_ItemDisplayPos(xyz_t* item_pos_p, xyz_t* center_pos_p) { +static void Player_actor_Get_ItemDisplayPos(xyz_t* item_pos_p, const xyz_t* center_pos_p) { if (Common_Get(clip).bg_item_clip != NULL && Common_Get(clip).bg_item_clip->rand_pos_get_proc != NULL) { const xyz_t pos = *center_pos_p; @@ -8088,7 +8102,10 @@ static void Player_actor_Check_player_change_color_for_main(ACTOR* actorx) { } } +#if VERSION == VER_GAFE01_00 static int Player_actor_Check_InBlockRadioExercise(ACTOR* actorx) { + // @BUG - the logic in this prevents radio exercise from working + // indoors when an aerobics event is active if (mEv_check_status(mEv_EVENT_MORNING_AEROBICS, mEv_STATUS_RUN) || mEv_check_status(mEv_EVENT_SPORTS_FAIR_AEROBICS, mEv_STATUS_RUN)) { int bx; @@ -8115,6 +8132,33 @@ static int Player_actor_Check_InBlockRadioExercise(ACTOR* actorx) { return FALSE; } +#else +static int Player_actor_Check_InBlockRadioExercise(ACTOR* actorx) { + int field_type = Common_Get(field_type); + if (field_type == mFI_FIELDTYPE2_FG) { + if (mEv_check_status(mEv_EVENT_MORNING_AEROBICS, mEv_STATUS_RUN) || + mEv_check_status(mEv_EVENT_SPORTS_FAIR_AEROBICS, mEv_STATUS_RUN)) { + int bx; + int bz; + + if (mFI_BlockKind2BkNum(&bx, &bz, mRF_BLOCKKIND_SHRINE)) { + int player_bx; + int player_bz; + + if (mFI_Wpos2BlockNum(&player_bx, &player_bz, actorx->world.position)) { + if (player_bx == bx && player_bz == bz) { + return TRUE; + } + } + } + } + } else if (aMR_RadioBgmNow()) { + return TRUE; + } + + return FALSE; +} +#endif static int Player_actor_Check_AbleRadioExercise(ACTOR* actorx) { /* Player must be in the same block as aerobics radio, or in a house room with one playing */ @@ -8547,3 +8591,11 @@ static void Player_actor_Set_Indoor_Camera_Index(ACTOR* actorx, GAME* game) { } } } + +#if VERSION >= VER_GAFU01_00 +static void Player_actor_Reset_item_net_catch_correct_pos(ACTOR* actorx) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actorx; + + player->item_net_catch_correct_pos_set = FALSE; +} +#endif diff --git a/src/game/m_player_draw.c_inc b/src/game/m_player_draw.c_inc index ae94d31f..62ed9bb2 100644 --- a/src/game/m_player_draw.c_inc +++ b/src/game/m_player_draw.c_inc @@ -374,4 +374,18 @@ static void Player_actor_draw_Normal(ACTOR* actorx, GAME* game) { if (moving_in_boat) { Matrix_pull(); } + +#if VERSION >= VER_GAFU01_00 + if (player->item_net_catch_correct_pos_set) { + TOOLS_ACTOR* label = (TOOLS_ACTOR*)player->item_net_catch_label; + + if (label != NULL && player->item_net_catch_type == mPlayer_NET_CATCH_TYPE_INSECT) { + Matrix_push(); + Matrix_translate(player->item_net_catch_correct_pos.x, player->item_net_catch_correct_pos.y, player->item_net_catch_correct_pos.z, MTX_LOAD); + Matrix_get(&label->matrix_work); + Matrix_pull(); + label->init_matrix = TRUE; + } + } +#endif } diff --git a/src/game/m_player_item_common.c_inc b/src/game/m_player_item_common.c_inc index 9fb53b52..ac6f857a 100644 --- a/src/game/m_player_item_common.c_inc +++ b/src/game/m_player_item_common.c_inc @@ -47,7 +47,7 @@ static s8 Player_actor_Get_ItemKind(ACTOR* actor, int kind) { static int Player_actor_Get_BasicItemMainIndex_fromItemKind(int kind) { // clang-format off - static const s8 data[] = { + static const s8 data[mPlayer_ITEM_KIND_NUM+1] = { mPlayer_ITEM_MAIN_AXE_NORMAL, mPlayer_ITEM_MAIN_AXE_NORMAL, mPlayer_ITEM_MAIN_AXE_NORMAL, @@ -384,7 +384,18 @@ static void Player_actor_LoadOrDestruct_Item(ACTOR* actor, int kind, int anim_id } } -static void Player_actor_CorrectSomething_net(ACTOR* actor, xyz_t* pos) { +#if VERSION >= VER_GAFU01_00 +static void Player_actor_CorrectSomething_net(ACTOR* actor, const xyz_t* pos) { + PLAYER_ACTOR* player = (PLAYER_ACTOR*)actor; + TOOLS_ACTOR* label = (TOOLS_ACTOR*)player->item_net_catch_label; + + if (label != NULL && player->item_net_catch_type == mPlayer_NET_CATCH_TYPE_INSECT && !player->item_net_catch_correct_pos_set) { + player->item_net_catch_correct_pos = *pos; + player->item_net_catch_correct_pos_set = TRUE; + } +} +#else +static void Player_actor_CorrectSomething_net(ACTOR* actor, const xyz_t* pos) { PLAYER_ACTOR* player = (PLAYER_ACTOR*)actor; TOOLS_ACTOR* label = (TOOLS_ACTOR*)player->item_net_catch_label; @@ -396,6 +407,7 @@ static void Player_actor_CorrectSomething_net(ACTOR* actor, xyz_t* pos) { label->init_matrix = TRUE; } } +#endif static int Player_actor_Check_ItemAnimationToItemKind(int kind, int anim) { int res; diff --git a/src/game/m_player_lib.c b/src/game/m_player_lib.c index df55c2c6..63710890 100644 --- a/src/game/m_player_lib.c +++ b/src/game/m_player_lib.c @@ -2176,8 +2176,11 @@ extern int mPlib_request_main_groundhog_type1(GAME* game) { } extern int mPlib_request_main_door_type1(GAME* game, const xyz_t* pos_p, s16 angle_y, int door_type, void* door_label) { - return GET_PLAYER_ACTOR_GAME(game)->request_main_door_all_proc(game, pos_p, angle_y, door_type, door_label, - mPlayer_REQUEST_PRIORITY_7) != FALSE; + if (GET_PLAYER_ACTOR_GAME(game)->request_main_door_all_proc(game, pos_p, angle_y, door_type, door_label, + mPlayer_REQUEST_PRIORITY_7)) { + return TRUE; + } + return FALSE; } extern int mPlib_request_main_door_type2(GAME* game, const xyz_t* pos_p, s16 angle_y, int door_type, void* door_label) { @@ -3181,6 +3184,13 @@ extern int mPlib_Check_scoop_after(GAME* game, xyz_t* pos_p, mActor_name_t* item /* Don't let the player hit NPCs with the shovel */ hit_actor_p = mPlib_Search_exist_npc_inCircle_forScoop(game, pos_p, SQ(39.0f)); if (hit_actor_p != NULL) { +#if VERSION >= VER_GAFU01_00 + if (is_stone_tencoin) { + *item_p = scoop_fg; + return mPlayer_INDEX_REFLECT_SCOOP; + } +#endif + return mPlayer_INDEX_AIR_SCOOP; } diff --git a/src/game/m_player_main_broken_axe.c_inc b/src/game/m_player_main_broken_axe.c_inc index c126ae1e..b484acfa 100644 --- a/src/game/m_player_main_broken_axe.c_inc +++ b/src/game/m_player_main_broken_axe.c_inc @@ -1,4 +1,4 @@ -static int Player_actor_request_main_broken_axe_type_reflect(GAME* game, const xyz_t* pos, mActor_name_t hit_item, +static int Player_actor_request_main_broken_axe_type_reflect(GAME* game, xyz_t* pos, mActor_name_t hit_item, ACTOR* hit_actor, int priority) { if (Player_actor_check_request_main_able(game, mPlayer_INDEX_BROKEN_AXE, priority)) { PLAYER_ACTOR* player = GET_PLAYER_ACTOR_GAME(game); @@ -13,7 +13,7 @@ static int Player_actor_request_main_broken_axe_type_reflect(GAME* game, const x return FALSE; } -static int Player_actor_request_main_broken_axe_type_swing(GAME* game, const xyz_t* pos, mActor_name_t hit_item, +static int Player_actor_request_main_broken_axe_type_swing(GAME* game, xyz_t* pos, mActor_name_t hit_item, int hit_ut_x, int hit_ut_z, int priority) { if (Player_actor_check_request_main_able(game, mPlayer_INDEX_BROKEN_AXE, priority)) { PLAYER_ACTOR* player = GET_PLAYER_ACTOR_GAME(game); diff --git a/src/game/m_player_main_complete_payment.c_inc b/src/game/m_player_main_complete_payment.c_inc index 939382c6..0b158743 100644 --- a/src/game/m_player_main_complete_payment.c_inc +++ b/src/game/m_player_main_complete_payment.c_inc @@ -15,8 +15,13 @@ static void Player_actor_setup_main_Complete_payment(ACTOR* actorx, GAME* game) complete_payment_p->timer = 0.0f; complete_payment_p->msg_mode = 0; +#if VERSION >= VER_GAFU01_00 + Player_actor_InitAnimation_Base2(actorx, game, mPlayer_ANIM_YATTA1, mPlayer_ANIM_YATTA1, 1.0f, 1.0f, 0.6f, 0.0f, + cKF_FRAMECONTROL_STOP, mPlayer_PART_TABLE_NORMAL); +#else Player_actor_InitAnimation_Base2(actorx, game, mPlayer_ANIM_YATTA1, mPlayer_ANIM_YATTA1, 1.0f, 1.0f, 0.5f, 0.0f, cKF_FRAMECONTROL_STOP, mPlayer_PART_TABLE_NORMAL); +#endif Player_actor_setup_main_Base(actorx, game); bgm_num = Player_actor_sound_Get_bgm_num_forCompletePayment(); mBGMPsComp_make_ps_fanfare(bgm_num, 0x168); diff --git a/src/game/m_player_main_dash.c_inc b/src/game/m_player_main_dash.c_inc index 4539076a..a957cfd6 100644 --- a/src/game/m_player_main_dash.c_inc +++ b/src/game/m_player_main_dash.c_inc @@ -109,22 +109,24 @@ static void Player_actor_BGcheck_Dash(ACTOR* actor) { } static int Player_actor_Check_FlatPlace(ACTOR* actor) { - static const xy_t offset[] = { + static const float offset[][2] = { { 0.0f, 0.0f }, { 20.0f, 0.0f }, { -20.0f, 0.0f }, { 0.0f, 28.284271f }, { 20.0f, 28.284271f }, { -20.0f, 28.284271f }, { 0.0f, 56.568542f }, { 20.0f, 56.568542f }, { -20, 56.568542f }, { 0.0f, 84.85281f }, { 20.0f, 84.85281f }, { -20.0f, 84.85281f }, }; xyz_t norm; - s16 angle = actor->shape_info.rotation.y; xyz_t pos = actor->world.position; + s16 angle = actor->shape_info.rotation.y; f32 sin = sin_s(angle); f32 cos = cos_s(angle); int i; - + for (i = 0; i < 12; i++) { - f32 x = offset[i].x; - f32 y = offset[i].y; + f32 x; + f32 y; + x = offset[i][0]; + y = offset[i][1]; pos.x = actor->world.position.x + (y * sin) + (x * cos); pos.z = actor->world.position.z + (y * cos) - (x * sin); @@ -133,6 +135,11 @@ static int Player_actor_Check_FlatPlace(ACTOR* actor) { if (norm.x != 0.0f || norm.z != 0.0f) { return 0; } + + // TODO: this doesn't match 1.3.2 (AC) and I feel like it's gotta be a hack. +#if VERSION >= VER_GAFU01_00 + pos.y = pos.y; +#endif } return 1; diff --git a/src/game/m_player_main_demo_geton_boat_wait.c_inc b/src/game/m_player_main_demo_geton_boat_wait.c_inc index ff05d449..61959d0b 100644 --- a/src/game/m_player_main_demo_geton_boat_wait.c_inc +++ b/src/game/m_player_main_demo_geton_boat_wait.c_inc @@ -41,7 +41,12 @@ static void Player_actor_request_proc_index_fromDemo_geton_boat_wait(ACTOR* acto } angle_y += DEG2SHORT_ANGLE2(180.0f); - Player_actor_Set_ScrollDemo_forDemo_geton_boat_wade(actorx, angle_y, ((speed * 0.5f) * 36.0f) * 0.05f); +// TODO: I don't like that this deviates between versions for something very simple. +#if VERSION >= VER_GAFU01_00 + Player_actor_Set_ScrollDemo_forDemo_geton_boat_wade(actorx, ((speed * 0.5f) * 36.0f) * 0.05f, (s16)angle_y); +#else + Player_actor_Set_ScrollDemo_forDemo_geton_boat_wade(actorx, ((speed * 0.5f) * 36.0f) * 0.05f, angle_y); +#endif } static void Player_actor_main_Demo_geton_boat_wait(ACTOR* actorx, GAME* game) { diff --git a/src/game/m_player_main_demo_walk.c_inc b/src/game/m_player_main_demo_walk.c_inc index beb88035..c5fd4fa2 100644 --- a/src/game/m_player_main_demo_walk.c_inc +++ b/src/game/m_player_main_demo_walk.c_inc @@ -94,8 +94,7 @@ static int Player_actor_Movement_Demo_walk(ACTOR* actorx, f32* over_speed_normal speed_mod = 0.01f + (speed_mod - 0.05f) * 0.5157895f; } - speed_mod = sqrtf(1.0f - speed_mod); - add_calc_short_angle2(&actorx->world.angle.y, goal_angle_y, 1.0f - speed_mod, 2500, 50); + add_calc_short_angle2(&actorx->world.angle.y, goal_angle_y, CALC_EASE(speed_mod), 2500, 50); if (player->animation0_idx != mPlayer_ANIM_WAIT1) { actorx->shape_info.rotation.y = actorx->world.angle.y; } diff --git a/src/game/m_player_main_hold.c_inc b/src/game/m_player_main_hold.c_inc index b9b33daf..18518901 100644 --- a/src/game/m_player_main_hold.c_inc +++ b/src/game/m_player_main_hold.c_inc @@ -70,9 +70,9 @@ static int Player_actor_CulcAnimation_Hold(ACTOR* actor) { static void Player_actor_Movement_Hold(ACTOR* actor) { PLAYER_ACTOR* player = (PLAYER_ACTOR*)actor; + s16 angle = player->main_data.hold.angle_y; f32 x = player->main_data.hold.player_pos.x; f32 z = player->main_data.hold.player_pos.z; - s16 angle = player->main_data.hold.angle_y; add_calc_short_angle2(&actor->shape_info.rotation.y, angle, 1.0f - sqrtf(0.5), 8192, 50); actor->world.angle.y = actor->shape_info.rotation.y; diff --git a/src/game/m_player_main_notice_net.c_inc b/src/game/m_player_main_notice_net.c_inc index af220f0f..bfc0cf5b 100644 --- a/src/game/m_player_main_notice_net.c_inc +++ b/src/game/m_player_main_notice_net.c_inc @@ -185,8 +185,13 @@ static int Player_actor_MessageControl_Notice_net(ACTOR* actor, GAME* game, int if (!mMsg_Check_MainNormal(win)) { Player_actor_SetupItem_Base2(actor, Player_actor_Get_ItemKind_from_submenu(), mPlayer_ANIM_GET_PUTAWAY1, mPlayer_INDEX_RUN, -5.0f, -1.0f, 0); +#if VERSION >= VER_GAFU01_00 + Player_actor_InitAnimation_Base2(actor, game, mPlayer_ANIM_YATTA2, mPlayer_ANIM_YATTA2, 1.0f, 1.0f, + 0.6f, -5.0f, 0, 0); +#else Player_actor_InitAnimation_Base2(actor, game, mPlayer_ANIM_YATTA2, mPlayer_ANIM_YATTA2, 1.0f, 1.0f, 0.5f, -5.0f, 0, 0); +#endif mBGMPsComp_delete_ps_fanfare(0x28, 0x168); mBGMPsComp_make_ps_fanfare(0x4B, 0x168); mMsg_Set_LockContinue(win); diff --git a/src/game/m_player_main_notice_rod.c_inc b/src/game/m_player_main_notice_rod.c_inc index 8c7cf95f..653f0424 100644 --- a/src/game/m_player_main_notice_rod.c_inc +++ b/src/game/m_player_main_notice_rod.c_inc @@ -234,8 +234,13 @@ static int Player_actor_MessageControl_Notice_rod(ACTOR* actor, GAME* game, int case 2: if (!mMsg_Check_MainNormal(win)) { +#if VERSION >= VER_GAFU01_00 + Player_actor_InitAnimation_Base2(actor, game, mPlayer_ANIM_YATTA2, mPlayer_ANIM_YATTA2, 1.0f, 1.0f, + 0.6f, -5.0f, 0, 0); +#else Player_actor_InitAnimation_Base2(actor, game, mPlayer_ANIM_YATTA2, mPlayer_ANIM_YATTA2, 1.0f, 1.0f, 0.5f, -5.0f, 0, 0); +#endif mBGMPsComp_delete_ps_fanfare(0x28, 0x168); mBGMPsComp_make_ps_fanfare(0x4C, 0x168); mMsg_Set_LockContinue(win); diff --git a/src/game/m_player_main_pickup_furniture.c_inc b/src/game/m_player_main_pickup_furniture.c_inc index 1a0f2299..35206e5e 100644 --- a/src/game/m_player_main_pickup_furniture.c_inc +++ b/src/game/m_player_main_pickup_furniture.c_inc @@ -54,7 +54,7 @@ static void Player_actor_settle_main_Pickup_furniture(ACTOR* actorx, GAME* game) } } -static void Player_actor_Movement_Pickup_furniture_common(ACTOR* actorx, xyz_t* target_pos_p) { +static void Player_actor_Movement_Pickup_furniture_common(ACTOR* actorx, const xyz_t* target_pos_p) { xyz_t* player_pos_p = &actorx->world.position; f32 dx = target_pos_p->x - player_pos_p->x; f32 dz = target_pos_p->z - player_pos_p->z; diff --git a/src/game/m_player_main_pickup_jump.c_inc b/src/game/m_player_main_pickup_jump.c_inc index 004d508c..83374fe7 100644 --- a/src/game/m_player_main_pickup_jump.c_inc +++ b/src/game/m_player_main_pickup_jump.c_inc @@ -77,7 +77,7 @@ static void Player_actor_settle_main_Pickup_jump(ACTOR* actorx, GAME* game) { } } -static void Player_actor_Movement_Pickup_jump_common(ACTOR* actorx, xyz_t* target_pos_p) { +static void Player_actor_Movement_Pickup_jump_common(ACTOR* actorx, const xyz_t* target_pos_p) { xyz_t* player_pos_p = &actorx->world.position; f32 dx = target_pos_p->x - player_pos_p->x; f32 dz = target_pos_p->z - player_pos_p->z; diff --git a/src/game/m_player_main_pull.c_inc b/src/game/m_player_main_pull.c_inc index 62cc6531..855016a3 100644 --- a/src/game/m_player_main_pull.c_inc +++ b/src/game/m_player_main_pull.c_inc @@ -1,14 +1,15 @@ -static int Player_actor_request_main_pull(GAME* game, int ftr_no, s16 angle, xyz_t* start_pos, xyz_t* end_pos, - xyz_t* ofs, int priority) { +static int Player_actor_request_main_pull(GAME* game, int ftr_no, s16 angle, const xyz_t* start_pos, const xyz_t* end_pos, + const xyz_t* ofs, int priority) { if (mPlib_get_player_actor_main_index(game) == mPlayer_INDEX_HOLD && Player_actor_check_request_main_able(game, mPlayer_INDEX_PULL, priority)) { PLAYER_ACTOR* player = GET_PLAYER_ACTOR_GAME(game); + mPlayer_request_pull_c* req_pull_p = &player->requested_main_index_data.pull; - player->requested_main_index_data.pull.ftrNo = ftr_no; - player->requested_main_index_data.pull.angle_y = angle; - player->requested_main_index_data.pull.start_pos = *start_pos; - player->requested_main_index_data.pull.end_pos = *end_pos; - player->requested_main_index_data.pull.ofs = *ofs; + req_pull_p->ftrNo = ftr_no; + req_pull_p->angle_y = angle; + req_pull_p->start_pos = *start_pos; + req_pull_p->end_pos = *end_pos; + req_pull_p->ofs = *ofs; Player_actor_request_main_index(game, mPlayer_INDEX_PULL, priority); diff --git a/src/game/m_player_main_reflect_axe.c_inc b/src/game/m_player_main_reflect_axe.c_inc index e438220f..d0f7f860 100644 --- a/src/game/m_player_main_reflect_axe.c_inc +++ b/src/game/m_player_main_reflect_axe.c_inc @@ -1,4 +1,4 @@ -static void Player_actor_request_main_reflect_axe_common(mPlayer_request_reflect_axe_c* req_axe, const xyz_t* pos, +static void Player_actor_request_main_reflect_axe_common(mPlayer_request_reflect_axe_c* req_axe, xyz_t* pos, mActor_name_t hit_item, u16 damage_no, ACTOR* hit_actor) { req_axe->goal_pos = *pos; req_axe->hit_item = hit_item; @@ -6,7 +6,7 @@ static void Player_actor_request_main_reflect_axe_common(mPlayer_request_reflect req_axe->axe_damage_no = damage_no; } -static int Player_actor_request_main_reflect_axe_all(GAME* game, const xyz_t* pos, mActor_name_t hit_item, +static int Player_actor_request_main_reflect_axe_all(GAME* game, xyz_t* pos, mActor_name_t hit_item, u16 damage_no, ACTOR* hit_actor, int priority) { if (Player_actor_check_request_main_able(game, mPlayer_INDEX_REFLECT_AXE, priority)) { PLAYER_ACTOR* player = GET_PLAYER_ACTOR_GAME(game); diff --git a/src/game/m_player_main_swing_axe.c_inc b/src/game/m_player_main_swing_axe.c_inc index 1955aacb..ac52838e 100644 --- a/src/game/m_player_main_swing_axe.c_inc +++ b/src/game/m_player_main_swing_axe.c_inc @@ -1,4 +1,4 @@ -static void Player_actor_request_main_swing_axe_common(mPlayer_request_swing_axe_c* req_axe, const xyz_t* pos, +static void Player_actor_request_main_swing_axe_common(mPlayer_request_swing_axe_c* req_axe, xyz_t* pos, mActor_name_t hit_item, u16 damage_no, int hit_ut_x, int hit_ut_z) { req_axe->goal_pos = *pos; @@ -8,7 +8,7 @@ static void Player_actor_request_main_swing_axe_common(mPlayer_request_swing_axe req_axe->axe_damage_no = damage_no; } -static int Player_actor_request_main_swing_axe_all(GAME* game, const xyz_t* pos, mActor_name_t hit_item, u16 damage_no, +static int Player_actor_request_main_swing_axe_all(GAME* game, xyz_t* pos, mActor_name_t hit_item, u16 damage_no, int hit_ut_x, int hit_ut_z, int priority) { if (Player_actor_check_request_main_able(game, mPlayer_INDEX_SWING_AXE, priority)) { PLAYER_ACTOR* player = GET_PLAYER_ACTOR_GAME(game); @@ -47,7 +47,7 @@ static void Player_actor_setup_main_Swing_axe(ACTOR* actor, GAME* game) { Player_actor_setup_main_Base(actor, game); } -static void Player_actor_Movement_axe_common(ACTOR* actor, xyz_t* axe_pos) { +static void Player_actor_Movement_axe_common(ACTOR* actor, const xyz_t* axe_pos) { PLAYER_ACTOR* player = (PLAYER_ACTOR*)actor; f32 z; f32 x; diff --git a/src/game/m_player_main_tumble.c_inc b/src/game/m_player_main_tumble.c_inc index 2d7f03a7..e72cefe3 100644 --- a/src/game/m_player_main_tumble.c_inc +++ b/src/game/m_player_main_tumble.c_inc @@ -30,7 +30,7 @@ static void Player_actor_setup_Item_Tumble(ACTOR* actor, GAME* game, int kind, f } static int Player_actor_Get_PlayerAnimeIndex_fromItemKind_Tumble(int kind) { - static const u8 data[] = { + static const u8 data[mPlayer_ITEM_KIND_NUM+1] = { mPlayer_ANIM_KOKERU_A1, mPlayer_ANIM_KOKERU_A1, mPlayer_ANIM_KOKERU_A1, mPlayer_ANIM_KOKERU_A1, mPlayer_ANIM_KOKERU_A1, mPlayer_ANIM_KOKERU_A1, mPlayer_ANIM_KOKERU_A1, mPlayer_ANIM_KOKERU_A1, mPlayer_ANIM_KOKERU_A1, mPlayer_ANIM_KOKERU_N1, mPlayer_ANIM_KOKERU_N1, mPlayer_ANIM_KOKERU_N1, diff --git a/src/game/m_player_main_tumble_getup.c_inc b/src/game/m_player_main_tumble_getup.c_inc index b44295f8..dd3b076c 100644 --- a/src/game/m_player_main_tumble_getup.c_inc +++ b/src/game/m_player_main_tumble_getup.c_inc @@ -56,7 +56,7 @@ static void Player_actor_setup_Item_Tumble_getup(ACTOR* actor, GAME* game, int k } static int Player_actor_Get_PlayerAnimeIndex_fromItemKind_Tumble_getup(int kind) { - static const u8 data[] = { + static const u8 data[mPlayer_ITEM_KIND_NUM+1] = { mPlayer_ANIM_KOKERU_GETUP_A1, mPlayer_ANIM_KOKERU_GETUP_A1, mPlayer_ANIM_KOKERU_GETUP_A1, mPlayer_ANIM_KOKERU_GETUP_A1, mPlayer_ANIM_KOKERU_GETUP_A1, mPlayer_ANIM_KOKERU_GETUP_A1, mPlayer_ANIM_KOKERU_GETUP_A1, mPlayer_ANIM_KOKERU_GETUP_A1, mPlayer_ANIM_KOKERU_GETUP_A1, diff --git a/src/game/m_player_other_func.c_inc b/src/game/m_player_other_func.c_inc index 0a373d43..3d9ff5e4 100644 --- a/src/game/m_player_other_func.c_inc +++ b/src/game/m_player_other_func.c_inc @@ -248,6 +248,9 @@ static void Player_actor_move_other_func1(ACTOR* actor, GAME* game) { Player_actor_Check_player_sunburn_ChangeDay(); Player_actor_Check_player_sunburn_for_main(actor); Player_actor_Check_player_change_color_for_main(actor); +#if VERSION >= VER_GAFU01_00 + Player_actor_Reset_item_net_catch_correct_pos(actor); +#endif } static void Player_actor_move_other_func2(ACTOR* actor, GAME* game) { diff --git a/src/game/m_police_box.c b/src/game/m_police_box.c index df72e1a9..5954931a 100644 --- a/src/game/m_police_box.c +++ b/src/game/m_police_box.c @@ -13,157 +13,157 @@ /** * @brief Copies an array of items to the lost and found. - * + * * item_buf must have a length of at least mPB_POLICE_BOX_ITEM_STORAGE_COUNT. - * + * * @param item_buf The array of items to copy **/ extern void mPB_copy_itemBuf(mActor_name_t* item_buf) { - mActor_name_t* keep_item; - int count; - int i; + mActor_name_t* keep_item; + int count; + int i; - keep_item = Save_Get(police_box.keep_items); - count = 0; + keep_item = Save_Get(police_box.keep_items); + count = 0; - /* copy over the items */ - for (i = 0; i < mPB_POLICE_BOX_ITEM_STORAGE_COUNT; i++) { - if (*item_buf != EMPTY_NO) { - *keep_item = *item_buf; - count++; - keep_item++; + /* copy over the items */ + for (i = 0; i < mPB_POLICE_BOX_ITEM_STORAGE_COUNT; i++) { + if (*item_buf != EMPTY_NO) { + *keep_item = *item_buf; + count++; + keep_item++; + } + + item_buf++; } - item_buf++; - } - - /* clear out any unset items if necessary */ - for (i = count; i < mPB_POLICE_BOX_ITEM_STORAGE_COUNT; i++) { - *keep_item++ = EMPTY_NO; - } + /* clear out any unset items if necessary */ + for (i = count; i < mPB_POLICE_BOX_ITEM_STORAGE_COUNT; i++) { + *keep_item++ = EMPTY_NO; + } } /** * @brief Gets the number of used slots in the lost and found. - * + * * @return count of used slots **/ extern int mPB_get_keep_item_sum() { - int i; - mActor_name_t* keep_item = Save_Get(police_box.keep_items); - int sum = 0; + mActor_name_t* keep_item = Save_Get(police_box.keep_items); + int sum = 0; + int i; - for (i = 0; i < mPB_POLICE_BOX_ITEM_STORAGE_COUNT; i++) { - if (*keep_item != EMPTY_NO) { - sum++; + for (i = 0; i < mPB_POLICE_BOX_ITEM_STORAGE_COUNT; i++) { + if (*keep_item != EMPTY_NO) { + sum++; + } + keep_item++; } - keep_item++; - } - return sum; + return sum; } /** * @brief Adds an item to the lost and found. - * + * * The item must be of type 'ITEM1' or 'FTR0/FTR1'. * If the lost and found is full, the first item in it * will be deleted and all subsequent items will be shifted * over by one. - * + * * @param item_no The item to add **/ extern void mPB_keep_item(mActor_name_t item_no) { - if (ITEM_IS_ITEM1(item_no) || ITEM_IS_FTR(item_no)) { - int keep_item_sum = mPB_get_keep_item_sum(); - if (keep_item_sum >= mPB_POLICE_BOX_ITEM_STORAGE_COUNT) { - /* delete the first item and move the rest down one slot */ - mActor_name_t* keep_item = Save_Get(police_box.keep_items); - int i; + if (ITEM_IS_ITEM1(item_no) || ITEM_IS_FTR(item_no)) { + int keep_item_sum = mPB_get_keep_item_sum(); + if (keep_item_sum >= mPB_POLICE_BOX_ITEM_STORAGE_COUNT) { + /* delete the first item and move the rest down one slot */ + mActor_name_t* keep_item = Save_Get(police_box.keep_items); + int i; - for (i = 0; i < mPB_POLICE_BOX_ITEM_STORAGE_COUNT - 1; i++) { - keep_item[0] = keep_item[1]; - keep_item++; - } + for (i = 1; i < mPB_POLICE_BOX_ITEM_STORAGE_COUNT; i++) { + keep_item[0] = keep_item[1]; + keep_item++; + } - keep_item_sum = mPB_POLICE_BOX_ITEM_STORAGE_COUNT - 1; + keep_item_sum = mPB_POLICE_BOX_ITEM_STORAGE_COUNT - 1; + } + + Save_Set(police_box.keep_items[keep_item_sum], item_no); } - - Save_Set(police_box.keep_items[keep_item_sum], item_no); - } } /** * @brief Transfers all items of type 'ITEM1' and 'FTR0/FTR1' to the lost and found. - * + * * If the number of items to add exceeds the size of the lost and found, * the items kept will be randomly selected by using rng to overwrite * previously saved items from the acre. - * + * * Additionally, items already in the lost in found will be deleted to * make space for the new items if necessary. - * + * * @param blk_x The x acre (column) * @param blk_z The z acre (row) **/ extern void mPB_keep_all_item_in_block(int blk_x, int blk_z) { - int count; - mActor_name_t new_items[mPB_POLICE_BOX_ITEM_STORAGE_COUNT]; - int keep_item_sum; - mActor_name_t item; - mActor_name_t* block_items; - int i; - - keep_item_sum = mPB_get_keep_item_sum(); - block_items = mFI_BkNumtoUtFGTop(blk_x, blk_z); - count = 0; - - bzero(new_items, mPB_POLICE_BOX_ITEM_STORAGE_COUNT * sizeof(mActor_name_t)); - - for (i = 0; i < UT_X_NUM * UT_Z_NUM; i++) { + int count; + mActor_name_t new_items[mPB_POLICE_BOX_ITEM_STORAGE_COUNT]; + int keep_item_sum; + mActor_name_t item; + mActor_name_t* block_items; int item_type; - item = *block_items; + int i; - /* only accept items in the 0x1XXX, 2XXX, and 3XXX range */ - item_type = ITEM_NAME_GET_TYPE(item); - if (item_type == NAME_TYPE_FTR0 || item_type == NAME_TYPE_ITEM1 || item_type == NAME_TYPE_FTR1) { - if (count < mPB_POLICE_BOX_ITEM_STORAGE_COUNT) { - /* space is still available, so directly add it */ - new_items[count++] = item; - } - else { - /* randomly overwrite one of the items in the lost and found */ - new_items[(int)(fqrand() * mPB_POLICE_BOX_ITEM_STORAGE_COUNT)] = item; - } + keep_item_sum = mPB_get_keep_item_sum(); + block_items = mFI_BkNumtoUtFGTop(blk_x, blk_z); + count = 0; - *block_items = EMPTY_NO; + bzero(new_items, mPB_POLICE_BOX_ITEM_STORAGE_COUNT * sizeof(mActor_name_t)); + + for (i = 0; i < UT_TOTAL_NUM; i++) { + item = *block_items; + + /* only accept items in the 0x1XXX, 2XXX, and 3XXX range */ + item_type = ITEM_NAME_GET_TYPE(item); + if (item_type == NAME_TYPE_FTR0 || item_type == NAME_TYPE_ITEM1 || item_type == NAME_TYPE_FTR1) { + if (count < mPB_POLICE_BOX_ITEM_STORAGE_COUNT) { + /* space is still available, so directly add it */ + new_items[count] = item; + count++; + } else { + /* randomly overwrite one of the items in the lost and found */ + new_items[RANDOM(mPB_POLICE_BOX_ITEM_STORAGE_COUNT)] = item; + } + + *block_items = EMPTY_NO; + } + block_items++; } - block_items++; - } - if (count > 0) { - int total_sum = count + keep_item_sum; + if (count > 0) { + int total_sum = count + keep_item_sum; - if (total_sum <= mPB_POLICE_BOX_ITEM_STORAGE_COUNT) { - mem_copy((u8*)(Save_Get(police_box.keep_items) + keep_item_sum), (u8*)new_items, count * sizeof(mActor_name_t)); + if (total_sum <= mPB_POLICE_BOX_ITEM_STORAGE_COUNT) { + mem_copy((u8*)(Save_Get(police_box.keep_items) + keep_item_sum), (u8*)new_items, + count * sizeof(mActor_name_t)); + } else { + mActor_name_t* dst = Save_Get(police_box.keep_items); + int save_count = total_sum - mPB_POLICE_BOX_ITEM_STORAGE_COUNT; + int keep_sum = keep_item_sum - save_count; + + /* move over saved items already in lost and found */ + for (i = 0; i < keep_sum; i++) { + dst[i] = dst[i + save_count]; + } + + /* copy newly added items */ + mem_copy((u8*)(Save_Get(police_box.keep_items) + keep_sum), (u8*)new_items, count * sizeof(mActor_name_t)); + } } - else { - mActor_name_t* dst = Save_Get(police_box.keep_items); - int save_count = total_sum - mPB_POLICE_BOX_ITEM_STORAGE_COUNT; - int keep_sum = keep_item_sum - save_count; - /* move over saved items already in lost and found */ - for (i = 0; i < keep_sum; i++) { - dst[i] = dst[i + save_count]; - } - - /* copy newly added items */ - mem_copy((u8*)(Save_Get(police_box.keep_items) + keep_sum), (u8*)new_items, count * sizeof(mActor_name_t)); - } - } - - /* clear buried item flags in the cleared acre */ - mFI_ClearDeposit(blk_x, blk_z); + /* clear buried item flags in the cleared acre */ + mFI_ClearDeposit(blk_x, blk_z); } /* select random item function definition */ @@ -171,141 +171,134 @@ typedef mActor_name_t (*mPB_get_force_set_proc)(); /** * @brief Selects a random 'goods' item to add to the lost and found/ - * + * * @return The randomly selected item **/ static mActor_name_t mPB_get_force_set_item_goods() { - static int category_table[mSP_KIND_MAX] = { - mSP_KIND_FURNITURE, - mSP_KIND_PAPER, - mSP_KIND_CLOTH, - mSP_KIND_CARPET, - mSP_KIND_WALLPAPER - }; + static int category_table[mSP_KIND_MAX] = { + mSP_KIND_FURNITURE, mSP_KIND_PAPER, mSP_KIND_CLOTH, mSP_KIND_CARPET, mSP_KIND_WALLPAPER, + }; - static int prob_table[mSP_KIND_MAX] = { - 35, /* furniture 0-35 (36%) */ - 58, /* stationery 36-58 (23%) */ - 88, /* clothing 59-88 (30%) */ - 94, /* carpets 89-94 (6%) */ - 100 /* wallpaper 95-99 (5%) (fqrand is [min, max) so 100 is not possible) */ - }; + static int prob_table[mSP_KIND_MAX] = { + 35, /* furniture 0-35 (36%) */ + 58, /* stationery 36-58 (23%) */ + 88, /* clothing 59-88 (30%) */ + 94, /* carpets 89-94 (6%) */ + 100 /* wallpaper 95-99 (5%) (fqrand is [min, max) so 100 is not possible) */ + }; + int category = mSP_KIND_MAX; + mActor_name_t item = EMPTY_NO; + int roll = (int)(fqrand() * 100.0f); + int i; - int category = mSP_KIND_MAX; - mActor_name_t item = EMPTY_NO; - int roll = (int)(fqrand() * 100.0f); - int i; - - for (i = 0; i < mSP_KIND_MAX; i++) { - if (roll <= prob_table[i]) { - category = i; - break; + for (i = 0; i < mSP_KIND_MAX; i++) { + if (roll <= prob_table[i]) { + category = i; + break; + } } - } - mSP_SelectRandomItem_New(NULL, &item, 1, NULL, 0, category_table[category], mSP_LISTTYPE_COMMON, FALSE); - return item; + mSP_SelectRandomItem_New(NULL, &item, 1, NULL, 0, category_table[category], mSP_LISTTYPE_COMMON, FALSE); + return item; } /** * @brief Selects a random tool or sapling to add to the lost and found. - * + * * @return The randomly selected item **/ static mActor_name_t mPB_get_force_set_item_item() { - static mActor_name_t category_table[6] = { - ITM_NET, ITM_AXE, ITM_SHOVEL, ITM_ROD, ITM_SAPLING, ITM_CEDAR_SAPLING - }; + static mActor_name_t category_table[6] = { ITM_NET, ITM_AXE, ITM_SHOVEL, ITM_ROD, ITM_SAPLING, ITM_CEDAR_SAPLING }; - return category_table[(int)(fqrand() * 6.0f)]; + return category_table[(int)(fqrand() * 6.0f)]; } /** * @brief Selects a random flower bag to add to the lost and found. - * + * * @return The randomly selected flower bag **/ static mActor_name_t mPB_get_force_set_item_flower() { - return ITM_WHITE_PANSY_BAG + (int)(fqrand() * 8.0f); + return ITM_WHITE_PANSY_BAG + (int)(fqrand() * 8.0f); } /** * @brief Selects a random umbrella to add to the lost and found. - * + * * @return The randomly selected umbrella **/ static mActor_name_t mPB_get_force_set_item_umbrella() { - mActor_name_t umbrella; - mSP_RandomUmbSelect(&umbrella, 1); + mActor_name_t umbrella; + mSP_RandomUmbSelect(&umbrella, 1); - return umbrella; + return umbrella; } /** * @brief Selects a random item from a random category to add to the lost and found. - * + * * @return The randomly selected item **/ static mActor_name_t mPB_get_force_set_item() { - static mPB_get_force_set_proc force_proc[mPB_CATEGORY_NUM] = { - &mPB_get_force_set_item_goods, - &mPB_get_force_set_item_item, - &mPB_get_force_set_item_flower, - &mPB_get_force_set_item_umbrella - }; + static mPB_get_force_set_proc force_proc[mPB_CATEGORY_NUM] = { + &mPB_get_force_set_item_goods, + &mPB_get_force_set_item_item, + &mPB_get_force_set_item_flower, + &mPB_get_force_set_item_umbrella, + }; - static int prob_table[mPB_CATEGORY_NUM] = { - 85, /* 0-85 (86%) 'goods' */ - 90, /* 86-90 (5%) 'item' */ - 95, /* 91-95 (5%) 'flower' */ - 100 /* 96-100 (4%) 'umbrella' (again, fqrand is [min, max) therefore 100 is never possible) */ - }; + static int prob_table[mPB_CATEGORY_NUM] = { + 85, /* 0-85 (86%) 'goods' */ + 90, /* 86-90 (5%) 'item' */ + 95, /* 91-95 (5%) 'flower' */ + 100 /* 96-100 (4%) 'umbrella' (again, fqrand is [min, max) therefore 100 is never possible) */ + }; - int proc = mPB_CATEGORY_NUM; - int roll = (int)(fqrand() * 100.0f); - int i; + int proc = mPB_CATEGORY_NUM; + int roll = (int)(fqrand() * 100.0f); + int i; - for (i = 0; i < mPB_CATEGORY_NUM; i++) { - if (roll <= prob_table[i]) { - proc = i; - break; + for (i = 0; i < mPB_CATEGORY_NUM; i++) { + if (roll <= prob_table[i]) { + proc = i; + break; + } } - } - return (*force_proc[proc])(); + return (*force_proc[proc])(); } /** * @brief Adds a random item to the lost and found if grow space is available. **/ extern void mPB_force_set_keep_item() { - /* if lost and found item count is less-than-equal-to max grow size & 50-50 roll */ - if (mPB_get_keep_item_sum() <= mPB_MAX_GROW_SIZE && (int)qrand() >= 0) { - mPB_keep_item(mPB_get_force_set_item()); - } + /* if lost and found item count is less-than-equal-to max grow size & 50-50 roll */ + if (mPB_get_keep_item_sum() <= mPB_MAX_GROW_SIZE && (int)qrand() >= 0) { + mPB_keep_item(mPB_get_force_set_item()); + } } /** * @brief Initializes the police station lost and found. - * + * * The lost and found will always start with one random common * priority list furniture and two random common priority list * shirts. - * + * * @param game The GAME pointer to pass to mSP_SelectRandomItem_New, goes unused **/ extern void mPB_police_box_init(GAME* game) { - mActor_name_t* keep_items = Save_Get(police_box.keep_items); - int i; + mActor_name_t* keep_items = Save_Get(police_box.keep_items); + int i; - /* generate one random ABC prio furniture and two random ABC prio shirts */ - mSP_SelectRandomItem_New(game, keep_items + 0, 1, NULL, 0, mSP_KIND_FURNITURE, mSP_LISTTYPE_ABC, FALSE); - mSP_SelectRandomItem_New(game, keep_items + 1, 2, NULL, 0, mSP_KIND_CLOTH, mSP_LISTTYPE_ABC, FALSE); + /* generate one random ABC prio furniture and two random ABC prio shirts */ + mSP_SelectRandomItem_New(game, keep_items + 0, 1, NULL, 0, mSP_KIND_FURNITURE, mSP_LISTTYPE_ABC, FALSE); + mSP_SelectRandomItem_New(game, keep_items + 1, 2, NULL, 0, mSP_KIND_CLOTH, mSP_LISTTYPE_ABC, FALSE); - /* clear the rest of the lost and found */ - keep_items += 3; - for (i = 0; i < mPB_POLICE_BOX_ITEM_STORAGE_COUNT - 3; i++) { - *keep_items++ = EMPTY_NO; - } + /* clear the rest of the lost and found */ + keep_items += 3; + for (i = 3; i < mPB_POLICE_BOX_ITEM_STORAGE_COUNT; i++) { + *keep_items++ = EMPTY_NO; + } } diff --git a/src/game/m_quest.c b/src/game/m_quest.c index da0e29e5..fbf1e34c 100644 --- a/src/game/m_quest.c +++ b/src/game/m_quest.c @@ -127,8 +127,8 @@ extern void mQst_CopyErrand(mQst_errand_c* dst, mQst_errand_c* src) { dst->errand_type = src->errand_type; // dst->info = src->info; - /* what the fuck guys */ - for (i = 0; i < sizeof(mQst_errand_info_u); i++) { + /* why are we copying it like this? */ + for (i = 0; i < (int)sizeof(mQst_errand_info_u); i++) { *info_dst_p = *info_src_p; info_dst_p++; info_src_p++; diff --git a/src/game/m_random_field_ovl.c b/src/game/m_random_field_ovl.c index 3d9dc8a7..c444aa28 100644 --- a/src/game/m_random_field_ovl.c +++ b/src/game/m_random_field_ovl.c @@ -580,7 +580,11 @@ static int mRF_DecideBaseCliff(u8* block_data) { mRF_TraceCliffBlock(block_data, 1, bz); mRF_SetEndCliffBlock(block_data); - return mRF_LastCheckCliff(block_data, 1, bz) != FALSE; + if (mRF_LastCheckCliff(block_data, 1, bz)) { + return TRUE; + } + + return FALSE; } static u8 mRF_RiverAlbuminCliff(u8 cliff_type, u8 river_type) { @@ -1256,7 +1260,7 @@ static void mRF_CopyBlockBaseHeightData(mFM_combination_c* combi_table, u8* base int i; for (i = 0; i < BLOCK_TOTAL_NUM; i++) { - combi_table->height = *base_height; + combi_table->height = (u8)*base_height; combi_table++; base_height++; } diff --git a/src/game/m_roll_lib.c b/src/game/m_roll_lib.c index 8ad5a4c0..9f32f306 100644 --- a/src/game/m_roll_lib.c +++ b/src/game/m_roll_lib.c @@ -12,347 +12,333 @@ #include "sys_matrix.h" extern void mRlib_spdXZ_to_spdF_Angle(xyz_t* speed_vec, f32* speedf, s16* angle_y_s) { - f32 x = speed_vec->x; - f32 z = speed_vec->z; + f32 x = speed_vec->x; + f32 z = speed_vec->z; - speedf[0] = sqrtf(x * x + z * z); - angle_y_s[0] = atans_table(z, x); + speedf[0] = sqrtf(x * x + z * z); + angle_y_s[0] = atans_table(z, x); } extern void mRlib_spdF_Angle_to_spdXZ(xyz_t* speed_vec, f32* speedf, s16* angle_y_s) { - speed_vec->x = sin_s(angle_y_s[0]) * speedf[0]; - speed_vec->z = cos_s(angle_y_s[0]) * speedf[0]; + speed_vec->x = sin_s(angle_y_s[0]) * speedf[0]; + speed_vec->z = cos_s(angle_y_s[0]) * speedf[0]; } extern int mRlib_position_move_for_sloop(ACTOR* actor, s_xyz* slope_angle) { - if (actor->bg_collision_check.result.on_ground && (slope_angle->x != 0 || slope_angle->z != 0)) { - f32 x = (actor->position_speed.x * ABS(cos_s(slope_angle->z))); // duplicates cos_s call (3x) - f32 y = actor->position_speed.y; - f32 z = (actor->position_speed.z * ABS(cos_s(slope_angle->x))); // duplicates cos_s call (3x) - - actor->world.position.x += x * 0.5f + actor->status_data.collision_vec.x; - actor->world.position.y += y * 0.5f + actor->status_data.collision_vec.y; - actor->world.position.z += z * 0.5f + actor->status_data.collision_vec.z; + if (actor->bg_collision_check.result.on_ground && (slope_angle->x != 0 || slope_angle->z != 0)) { + f32 x = (actor->position_speed.x * ABS(cos_s(slope_angle->z))); // duplicates cos_s call (3x) + f32 y = actor->position_speed.y; + f32 z = (actor->position_speed.z * ABS(cos_s(slope_angle->x))); // duplicates cos_s call (3x) - return TRUE; - } - else { - Actor_position_move(actor); - return FALSE; - } + actor->world.position.x += x * 0.5f + actor->status_data.collision_vec.x; + actor->world.position.y += y * 0.5f + actor->status_data.collision_vec.y; + actor->world.position.z += z * 0.5f + actor->status_data.collision_vec.z; + + return TRUE; + } else { + Actor_position_move(actor); + return FALSE; + } } extern int mRlib_Get_norm_Clif(ACTOR* actor, xyz_t* normal_vec) { - s16 angles[2]; + s16 angles[2]; - if (mCoBG_CheckAttribute_BallRolling(angles, &actor->world.position)) { - int i; + if (mCoBG_CheckAttribute_BallRolling(angles, &actor->world.position)) { + int i; - for (i = 0; i < 2; i++) { - f32 percent = mCoBG_CheckBallRollingArea(angles[i], &actor->world.position); + for (i = 0; i < 2; i++) { + f32 percent = mCoBG_CheckBallRollingArea(angles[i], &actor->world.position); - if (percent > 0.0f && percent < 0.5f) { - xyz_t rot; - s16 angle = angles[i] + DEG2SHORT_ANGLE(90.0f); - xyz_t pos = *normal_vec; + if (percent > 0.0f && percent < 0.5f) { + xyz_t rot; + s16 angle = angles[i] + DEG2SHORT_ANGLE(90.0f); + xyz_t pos = *normal_vec; - rot.x = sin_s(angle); - rot.y = 0.0f; - rot.z = cos_s(angle); + rot.x = sin_s(angle); + rot.y = 0.0f; + rot.z = cos_s(angle); - Matrix_RotateVector((int)DEG2SHORT_ANGLE((0.5f - percent) * 80.0f), &rot, MTX_LOAD); - Matrix_Position(&pos, normal_vec); + Matrix_RotateVector((int)DEG2SHORT_ANGLE((0.5f - percent) * 80.0f), &rot, MTX_LOAD); + Matrix_Position(&pos, normal_vec); - return TRUE; - } + return TRUE; + } + } } - } - return FALSE; + return FALSE; } extern void mRlib_Roll_Matrix_to_s_xyz(ACTOR* actor, s_xyz* rot, s16 angle) { - MtxF matrix; - xyz_t axis; + MtxF matrix; + xyz_t axis; - axis.x = cos_s(actor->world.angle.y); - axis.z = -sin_s(actor->world.angle.y); - axis.y = 0.0f; + axis.x = cos_s(actor->world.angle.y); + axis.z = -sin_s(actor->world.angle.y); + axis.y = 0.0f; - Matrix_RotateVector(angle, &axis, MTX_LOAD); - Matrix_rotateXYZ(rot->x, rot->y, rot->z, MTX_MULT); - Matrix_get(&matrix); - Matrix_to_rotate2_new(&matrix, rot, MTX_LOAD); + Matrix_RotateVector(angle, &axis, MTX_LOAD); + Matrix_rotateXYZ(rot->x, rot->y, rot->z, MTX_MULT); + Matrix_get(&matrix); + Matrix_to_rotate2_new(&matrix, rot, MTX_LOAD); } extern s16 mRlib_Get_HitWallAngleY(ACTOR* actor) { - u16 angle = actor->bg_collision_check.wall_info[0].angleY; - u16 angle2; - s16 median; + u16 angle = actor->bg_collision_check.wall_info[0].angleY; + u16 angle2; + s16 median; - /* check if only hit one wall */ - if (actor->bg_collision_check.result.hit_wall_count != 1) { - angle2 = actor->bg_collision_check.wall_info[1].angleY; - median = (angle + angle2) >> 1; + /* check if only hit one wall */ + if (actor->bg_collision_check.result.hit_wall_count != 1) { + angle2 = actor->bg_collision_check.wall_info[1].angleY; + median = (angle + angle2) >> 1; - if (ABS(angle - angle2) <= 0x8000) { - return median; + if (ABS(angle - angle2) > DEG2SHORT_ANGLE2(180.0f)) { + median -= (s16)DEG2SHORT_ANGLE2(180.0f); /* add 180 degrees */ + } + return median; } - else { - median += 0x8000; - - return median; /* add 180 degrees */ - } - } - return angle; + return angle; } extern void mRlib_Station_step_modify_to_wall(ACTOR* actor) { - s_xyz angle; - mCoBG_GetBgY_AngleS_FromWpos(&angle, actor->world.position, 0.0f); + s_xyz angle; + mCoBG_GetBgY_AngleS_FromWpos(&angle, actor->world.position, 0.0f); - if (angle.x >= DEG2SHORT_ANGLE(45.0f)) { - f32 z; - - actor->bg_collision_check.result.hit_wall |= mCoBG_HIT_WALL | mCoBG_HIT_WALL_FRONT; /* force 'collision' with a wall in front of the actor */ - z = mFI_UT_WORLDSIZE_Z_F + (f32)((int)(actor->world.position.z / mFI_UT_WORLDSIZE_Z_F) * mFI_UT_WORLDSIZE_Z); /* move to exactly one Z unit backwards (positive Z) */ - actor->bg_collision_check.wall_info[0].angleY = DEG2SHORT_ANGLE(0.0f); - actor->bg_collision_check.result.hit_wall_count = 1; - actor->world.position.z = z; - } + if (angle.x >= DEG2SHORT_ANGLE(45.0f)) { + f32 z; + + actor->bg_collision_check.result.hit_wall |= + mCoBG_HIT_WALL | mCoBG_HIT_WALL_FRONT; /* force 'collision' with a wall in front of the actor */ + z = mFI_UT_WORLDSIZE_Z_F + (f32)((int)(actor->world.position.z / mFI_UT_WORLDSIZE_Z_F) * + mFI_UT_WORLDSIZE_Z); /* move to exactly one Z unit backwards (positive Z) */ + actor->bg_collision_check.wall_info[0].angleY = DEG2SHORT_ANGLE(0.0f); + actor->bg_collision_check.result.hit_wall_count = 1; + actor->world.position.z = z; + } } extern int mRlib_Set_Position_Check(ACTOR* actor) { - int set; - int bx; - int bz; - int ut_x; - int ut_z; + int set; + int bx; + int bz; + int ut_x; + int ut_z; - mFI_Wpos2BkandUtNuminBlock(&bx, &bz, &ut_x, &ut_z, actor->world.position); + mFI_Wpos2BkandUtNuminBlock(&bx, &bz, &ut_x, &ut_z, actor->world.position); - /* check if the current unit is accessible by NPCs */ - set = mNpc_CheckNpcSet(bx, bz, ut_x, ut_z); - if (set == FALSE) { - /* Since it isn't, try searching the 3x3 grid around the center unit for available spots */ - int x_ofs; + /* check if the current unit is accessible by NPCs */ + set = mNpc_CheckNpcSet(bx, bz, ut_x, ut_z); + if (set == FALSE) { + /* Since it isn't, try searching the 3x3 grid around the center unit for available spots */ + int x_ofs; - for (x_ofs = -1; x_ofs < 2; x_ofs++) { - int z_ofs; + for (x_ofs = -1; x_ofs < 2; x_ofs++) { + int z_ofs; - for (z_ofs = -1; z_ofs < 2; z_ofs++) { - if ( - (x_ofs != 0 || z_ofs != 0) && - (ut_x + x_ofs) < UT_X_NUM && (ut_x + x_ofs) > 0 && - (ut_z + z_ofs) < UT_Z_NUM && (ut_z + z_ofs) > 0 - ) { - set = mNpc_CheckNpcSet(bx, bz, ut_x + x_ofs, ut_z + z_ofs); + for (z_ofs = -1; z_ofs < 2; z_ofs++) { + if ((x_ofs != 0 || z_ofs != 0) && (ut_x + x_ofs) < UT_X_NUM && (ut_x + x_ofs) > 0 && + (ut_z + z_ofs) < UT_Z_NUM && (ut_z + z_ofs) > 0) { + set = mNpc_CheckNpcSet(bx, bz, ut_x + x_ofs, ut_z + z_ofs); + } + + if (set == TRUE) { + /* found an accessible spot for an NPC/ACTOR, so use that */ + f32 y_save = actor->world.position.y; + + mFI_BkandUtNum2CenterWpos(&actor->world.position, bx, bz, ut_x + x_ofs, ut_z + z_ofs); + actor->world.position.y = y_save; + + return set; + } + } } - - if (set == TRUE) { - /* found an accessible spot for an NPC/ACTOR, so use that */ - f32 y_save = actor->world.position.y; - - mFI_BkandUtNum2CenterWpos(&actor->world.position, bx, bz, ut_x + x_ofs, ut_z + z_ofs); - actor->world.position.y = y_save; - - return set; - } - } } - } - return set; + return set; } extern int mRlib_HeightGapCheck_And_ReversePos(ACTOR* actor) { - if (mFI_GetPlayerWade() == mFI_WADE_INPROGRESS && mCoBG_ExistHeightGap_KeepAndNow_Detail(actor->world.position)) { - if (mRlib_Set_Position_Check(actor) != FALSE) { - actor->position_speed.y = 0.0f; + if (mFI_GetPlayerWade() == mFI_WADE_INPROGRESS && mCoBG_ExistHeightGap_KeepAndNow_Detail(actor->world.position)) { + if (mRlib_Set_Position_Check(actor) != FALSE) { + actor->position_speed.y = 0.0f; + } else { + /* We couldn't find a valid unit in the 3x3 grid around the ACTOR's current unit */ + + int bx; + int bz; + int ut_x; + int ut_z; + + mFI_Wpos2BkandUtNuminBlock(&bx, &bz, &ut_x, &ut_z, actor->world.position); + + /* Check all units in the current block for any valid spot to move our ACTOR to, and move there if found */ + if (mNpc_GetMakeUtNuminBlock_hard_area(&ut_x, &ut_z, bx, bz, 0)) { + f32 y_save = actor->world.position.y; + + mFI_BkandUtNum2CenterWpos(&actor->world.position, bx, bz, ut_x, ut_z); + actor->world.position.y = y_save; + actor->position_speed.y = 0.0f; + + return TRUE; + } + + return FALSE; /* no accessible unit in the entire block was found */ + } } - else { - /* We couldn't find a valid unit in the 3x3 grid around the ACTOR's current unit */ - int bx; - int bz; - int ut_x; - int ut_z; - - mFI_Wpos2BkandUtNuminBlock(&bx, &bz, &ut_x, &ut_z, actor->world.position); - - /* Check all units in the current block for any valid spot to move our ACTOR to, and move there if found */ - if (mNpc_GetMakeUtNuminBlock_hard_area(&ut_x, &ut_z, bx, bz, 0)) { - f32 y_save = actor->world.position.y; - - mFI_BkandUtNum2CenterWpos(&actor->world.position, bx, bz, ut_x, ut_z); - actor->world.position.y = y_save; - actor->position_speed.y = 0.0f; - - return TRUE; - } - - return FALSE; /* no accessible unit in the entire block was found */ - } - } - - return TRUE; /* ACTOR was in a good location or was moved to one in the 3x3 unit grid around them */ + return TRUE; /* ACTOR was in a good location or was moved to one in the 3x3 unit grid around them */ } extern int mRlib_Hole_check(ACTOR* actor) { - mActor_name_t* ut_fg_p = mFI_GetUnitFG(actor->world.position); // item underneath where the actor is + mActor_name_t* ut_fg_p = mFI_GetUnitFG(actor->world.position); // item underneath where the actor is - if (ut_fg_p != NULL && ((ut_fg_p[0] >= HOLE_START && ut_fg_p[0] <= HOLE_END) || ut_fg_p[0] == HOLE_SHINE)) { - return TRUE; // a hole item is under the actor - } - - return FALSE; // item under the actor isn't a hole + if (ut_fg_p != NULL && ((ut_fg_p[0] >= HOLE_START && ut_fg_p[0] <= HOLE_END) || ut_fg_p[0] == HOLE_SHINE)) { + return TRUE; // a hole item is under the actor + } + + return FALSE; // item under the actor isn't a hole } -extern int mRlib_Get_ground_norm_inHole(ACTOR* actor, xyz_t* normal, f32* dist, s16* angle_y, s16* angle_rate, f32 rate_mod) { - if (mRlib_Hole_check(actor) != FALSE) { - xyz_t center_pos; +extern int mRlib_Get_ground_norm_inHole(ACTOR* actor, xyz_t* normal, f32* dist, s16* angle_y, s16* angle_rate, + f32 rate_mod) { + if (mRlib_Hole_check(actor) != FALSE) { + xyz_t center_pos; - mFI_Wpos2UtCenterWpos(¢er_pos, actor->world.position); - dist[0] = search_position_distance(&actor->world.position, ¢er_pos); // distance to center of hole - angle_rate[0] = DEG2SHORT_ANGLE((dist[0] * 90.0f) * 0.0325f); - angle_rate[0] = (int)(angle_rate[0] * rate_mod); - angle_y[0] = atans_table(actor->world.position.z - center_pos.z, actor->world.position.x - center_pos.x); - - normal->x = (-cos_s(angle_rate[0])) * sin_s(angle_y[0]); - normal->y = -sin_s(angle_rate[0]); - normal->z = (-cos_s(angle_rate[0])) * cos_s(angle_y[0]); - - return TRUE; - } - else { - dist[0] = 0.0f; + mFI_Wpos2UtCenterWpos(¢er_pos, actor->world.position); + dist[0] = search_position_distance(&actor->world.position, ¢er_pos); // distance to center of hole + angle_rate[0] = DEG2SHORT_ANGLE((dist[0] * 90.0f) * 0.0325f); + angle_rate[0] = (int)(angle_rate[0] * rate_mod); + angle_y[0] = atans_table(actor->world.position.z - center_pos.z, actor->world.position.x - center_pos.x); - return FALSE; - } + normal->x = (-cos_s(angle_rate[0])) * sin_s(angle_y[0]); + normal->y = -sin_s(angle_rate[0]); + normal->z = (-cos_s(angle_rate[0])) * cos_s(angle_y[0]); + + return TRUE; + } else { + dist[0] = 0.0f; + + return FALSE; + } } static int mRlib_PSnowmanTouchCheck(const xyz_t* wpos) { - if ( - ABS(wpos->x) < mFI_UT_WORLDSIZE_X_F && - ABS(wpos->z) < mFI_UT_WORLDSIZE_Z_F && - ABS(wpos->y) < mFI_UNIT_BASE_SIZE_F - ) { - return TRUE; - } + if (ABS(wpos->x) < mFI_UT_WORLDSIZE_X_F && ABS(wpos->z) < mFI_UT_WORLDSIZE_Z_F && + ABS(wpos->y) < mFI_UNIT_BASE_SIZE_F) { + return TRUE; + } - return FALSE; + return FALSE; } extern int mRlib_PSnowmanBreakCheck(ACTOR* actor, GAME_PLAY* play, f32* speed) { - PLAYER_ACTOR* player = get_player_actor_withoutCheck(play); - f32 actor_y_pos_save = actor->world.position.y; - xyz_t pos_diff; - - /* Move actor to ground level for calc */ - actor->world.position.y = mCoBG_GetBgY_OnlyCenter_FromWpos2(actor->world.position, 0.0f); - xyz_t_sub(&actor->world.position, &player->actor_class.world.position, &pos_diff); - actor->world.position.y = actor_y_pos_save; // restore y position after calculation + PLAYER_ACTOR* player = get_player_actor_withoutCheck(play); + f32 actor_y_pos_save = actor->world.position.y; + xyz_t pos_diff; - if (mRlib_PSnowmanTouchCheck(&pos_diff)) { - if (Math3d_normalizeXyz_t(&pos_diff)) { - xyz_t player_speed = player->actor_class.position_speed; - f32 sq_dist = pos_diff.x * player_speed.x + pos_diff.z * player_speed.z; + /* Move actor to ground level for calc */ + actor->world.position.y = mCoBG_GetBgY_OnlyCenter_FromWpos2(actor->world.position, 0.0f); + xyz_t_sub(&actor->world.position, &player->actor_class.world.position, &pos_diff); + actor->world.position.y = actor_y_pos_save; // restore y position after calculation - if (sq_dist > 0.0f) { - speed[0] += sq_dist * 0.5f; - } - else { + if (mRlib_PSnowmanTouchCheck(&pos_diff)) { + if (Math3d_normalizeXyz_t(&pos_diff)) { + xyz_t player_speed = player->actor_class.position_speed; + f32 sq_dist = pos_diff.x * player_speed.x + pos_diff.z * player_speed.z; + + if (sq_dist > 0.0f) { + speed[0] += sq_dist * 0.5f; + } else { + add_calc0(speed, 1.0f - sqrtf(0.7), 10.0f); + } + + if (speed[0] > 200.0f) { + return TRUE; + } + } else { + add_calc0(speed, 1.0f - sqrtf(0.7), 10.0f); + } + } else { add_calc0(speed, 1.0f - sqrtf(0.7), 10.0f); - } - - if (speed[0] > 200.0f) { - return TRUE; - } } - else { - add_calc0(speed, 1.0f - sqrtf(0.7), 10.0f); - } - } - else { - add_calc0(speed, 1.0f - sqrtf(0.7), 10.0f); - } - return FALSE; + return FALSE; } extern int mRlib_PSnowmanBreakNeckSwing(s16* head_angle_y, f32 f0, f32 scale) { - if (f0 > 20.0f) { - s16 rot_x; - s16 rot_z; - s16 angle; + if (f0 > 20.0f) { + s16 rot_x; + s16 rot_z; + s16 angle; - head_angle_y[0] += (s16)((f0 * 40.0f) * 0.5f); - angle = head_angle_y[0] & 0x7000; - rot_x = (f0 * 4.5f) * sin_s(angle); - rot_z = (f0 * 4.5f) * cos_s(angle); + head_angle_y[0] += (s16)((f0 * 40.0f) * 0.5f); + angle = head_angle_y[0] & 0x7000; + rot_x = (f0 * 4.5f) * sin_s(angle); + rot_z = (f0 * 4.5f) * cos_s(angle); - Matrix_translate(0.0f, scale * -1400.0f, 0.0f, MTX_MULT); // move to neck location? - Matrix_rotateXYZ(rot_x, 0, rot_z, MTX_MULT); // rotate at location - Matrix_translate(0.0f, scale * 1400.0f, 0.0f, MTX_MULT); // restore original location - } + Matrix_translate(0.0f, scale * -1400.0f, 0.0f, MTX_MULT); // move to neck location? + Matrix_rotateXYZ(rot_x, 0, rot_z, MTX_MULT); // rotate at location + Matrix_translate(0.0f, scale * 1400.0f, 0.0f, MTX_MULT); // restore original location + } } extern int mRlib_PSnowman_NormalTalk(ACTOR* actor, GAME_PLAY* play, f32* speed, mDemo_REQUEST_PROC demo_req_proc) { - if (mDemo_Check(mDemo_TYPE_TALK, actor) == FALSE) { - f32 actor_y_save; + if (mDemo_Check(mDemo_TYPE_TALK, actor) == FALSE) { + f32 actor_y_save; - /* Don't talk if the snowman broke */ - if (mRlib_PSnowmanBreakCheck(actor, play, speed) != FALSE) { - return FALSE; + /* Don't talk if the snowman broke */ + if (mRlib_PSnowmanBreakCheck(actor, play, speed) != FALSE) { + return FALSE; + } + + /* Update actor position temporarily */ + actor_y_save = actor->world.position.y; + actor->world.position.y = mCoBG_GetBgY_AngleS_FromWpos(NULL, actor->world.position, 0.0f); + mDemo_Request(mDemo_TYPE_TALK, actor, demo_req_proc); + actor->world.position.y = actor_y_save; // restore original Y position + } else { + add_calc0(speed, 1.0f - sqrtf(0.7), 10.0f); } - /* Update actor position temporarily */ - actor_y_save = actor->world.position.y; - actor->world.position.y = mCoBG_GetBgY_AngleS_FromWpos(NULL, actor->world.position, 0.0f); - mDemo_Request(mDemo_TYPE_TALK, actor, demo_req_proc); - actor->world.position.y = actor_y_save; // restore original Y position - } - else { - add_calc0(speed, 1.0f - sqrtf(0.7), 10.0f); - } - - return TRUE; + return TRUE; } extern int mRlib_snowman_ball_unit_check_from_pos(GAME_PLAY* play, const xyz_t* wpos) { - ACTOR* actor; + ACTOR* actor; - /* Search out snowman actor & check distance to any found */ - for (actor = play->actor_info.list[ACTOR_PART_BG].actor; actor != NULL; actor = actor->next_actor) { - if (actor->id == mAc_PROFILE_SNOWMAN) { - xyz_t diff; - SNOWMAN_ACTOR* snowman = (SNOWMAN_ACTOR*)actor; - xyz_t* snowman_pos = &snowman->actor_class.world.position; - f32 max_dist = MIN(snowman->normalized_scale * 20.0f + 10.0f, 19.0f); + /* Search out snowman actor & check distance to any found */ + for (actor = play->actor_info.list[ACTOR_PART_BG].actor; actor != NULL; actor = actor->next_actor) { + if (actor->id == mAc_PROFILE_SNOWMAN) { + xyz_t diff; + SNOWMAN_ACTOR* snowman = (SNOWMAN_ACTOR*)actor; + xyz_t* snowman_pos = &snowman->actor_class.world.position; + f32 max_dist = MIN(snowman->normalized_scale * 20.0f + 10.0f, 19.0f); - xyz_t_sub(snowman_pos, wpos, &diff); + xyz_t_sub(snowman_pos, wpos, &diff); - max_dist += 19.0f; + max_dist += 19.0f; - if (Math3DVecLengthSquare2D(diff.x, diff.z) < max_dist * max_dist) { - return TRUE; - } + if (Math3DVecLengthSquare2D(diff.x, diff.z) < max_dist * max_dist) { + return TRUE; + } + } } - } - /* If a snowman actor doesn't exist, try using the ball position */ - if (Common_Get(ball_pos).x != 0.0f || Common_Get(ball_pos).y != 0.0f || Common_Get(ball_pos).z != 0.0f) { - xyz_t diff; - f32 max_dist = 20.0f; + /* If a snowman actor doesn't exist, try using the ball position */ + if (Common_Get(ball_pos).x != 0.0f || Common_Get(ball_pos).y != 0.0f || Common_Get(ball_pos).z != 0.0f) { + xyz_t diff; + f32 max_dist = 20.0f; - xyz_t_sub(Common_GetPointer(ball_pos), wpos, &diff); - max_dist += 19.0f; + xyz_t_sub(Common_GetPointer(ball_pos), wpos, &diff); + max_dist += 19.0f; - if (Math3DVecLengthSquare2D(diff.x, diff.z) < max_dist * max_dist) { - return TRUE; + if (Math3DVecLengthSquare2D(diff.x, diff.z) < max_dist * max_dist) { + return TRUE; + } } - } - return FALSE; + return FALSE; } diff --git a/src/game/m_room_type.c b/src/game/m_room_type.c index cae476a1..c5048812 100644 --- a/src/game/m_room_type.c +++ b/src/game/m_room_type.c @@ -433,12 +433,9 @@ extern int mRmTp_GetFurnitureData(mActor_name_t ftr, int ut_x, int ut_z, mRmTp_F int i; for (i = 0; i < mRmTp_FTR_UNIT_MAX; i++) { - mRmTp_FtrPlaceData_c* ut_data = &unit_data[i]; - mRmTp_FtrPlaceInfoOne_t* ut_info = &place_info[i]; - - ut_info->exists = ut_data->exist; - ut_info->ut_x = ut_x + ut_data->ofs_x; - ut_info->ut_z = ut_z + ut_data->ofs_z; + place_info[i].exists = unit_data[i].exist; + place_info[i].ut_x = ut_x + unit_data[i].ofs_x; + place_info[i].ut_z = ut_z + unit_data[i].ofs_z; } return aMR_GetFurnitureUnit(ftr); @@ -450,9 +447,10 @@ extern int mRmTp_GetFurnitureData(mActor_name_t ftr, int ut_x, int ut_z, mRmTp_F extern void mRmTp_MakeFtrNoTable(mActor_name_t* dst, mActor_name_t* src) { int i; int j; + int k; - for (i = 0; i < UT_TOTAL_NUM; i++) { - dst[i] = EMPTY_NO; + for (k = 0; k < UT_TOTAL_NUM; k++) { + dst[k] = EMPTY_NO; } for (i = 0; i < UT_Z_NUM; i++) { @@ -462,8 +460,6 @@ extern void mRmTp_MakeFtrNoTable(mActor_name_t* dst, mActor_name_t* src) { if (ITEM_IS_FTR(item) && mRmTp_GetFurnitureData(item, j, i, place_data) != mRmTp_FTRSIZE_NUM) { mRmTp_FtrPlaceInfoOne_t* data_p = place_data; - int k; - for (k = 0; k < mRmTp_FTR_UNIT_MAX; k++) { if (data_p->exists) { dst[data_p->ut_z * UT_X_NUM + data_p->ut_x] = item; @@ -518,1272 +514,1274 @@ extern int mRmTp_GetFtrActionSE(int ftr_idx, int mode) { return -1; } -static u8 mRmTp_birth_type[FTR_NUM] = { mRmTp_BIRTH_TYPE_HALLOWEEN, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_SANTA, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_SANTA, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_HALLOWEEN, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_LOTTERY, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_LOTTERY, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_LOTTERY, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_LOTTERY, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_LOTTERY, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_LOTTERY, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_BIRTHDAY, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_LOTTERY, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_LOTTERY, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_LOTTERY, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_LOTTERY, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_LOTTERY, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_LOTTERY, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_LOTTERY, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_LOTTERY, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_HALLOWEEN_TRICK, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_HALLOWEEN, - mRmTp_BIRTH_TYPE_HALLOWEEN_TRICK, - mRmTp_BIRTH_TYPE_HALLOWEEN, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_HALLOWEEN, - mRmTp_BIRTH_TYPE_HALLOWEEN, - mRmTp_BIRTH_TYPE_HALLOWEEN, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_LOTTERY, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_HALLOWEEN, - mRmTp_BIRTH_TYPE_HALLOWEEN, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_LOTTERY, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_HALLOWEEN, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_LOTTERY, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_HANIWA, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_FTR_CLOTH, - mRmTp_BIRTH_TYPE_MY_ORIGINAL, - mRmTp_BIRTH_TYPE_MY_ORIGINAL, - mRmTp_BIRTH_TYPE_MY_ORIGINAL, - mRmTp_BIRTH_TYPE_MY_ORIGINAL, - mRmTp_BIRTH_TYPE_MY_ORIGINAL, - mRmTp_BIRTH_TYPE_MY_ORIGINAL, - mRmTp_BIRTH_TYPE_MY_ORIGINAL, - mRmTp_BIRTH_TYPE_MY_ORIGINAL, - mRmTp_BIRTH_TYPE_FTR_INSECT, - mRmTp_BIRTH_TYPE_FTR_INSECT, - mRmTp_BIRTH_TYPE_FTR_INSECT, - mRmTp_BIRTH_TYPE_FTR_INSECT, - mRmTp_BIRTH_TYPE_FTR_INSECT, - mRmTp_BIRTH_TYPE_FTR_INSECT, - mRmTp_BIRTH_TYPE_FTR_INSECT, - mRmTp_BIRTH_TYPE_FTR_INSECT, - mRmTp_BIRTH_TYPE_FTR_INSECT, - mRmTp_BIRTH_TYPE_FTR_INSECT, - mRmTp_BIRTH_TYPE_FTR_INSECT, - mRmTp_BIRTH_TYPE_FTR_INSECT, - mRmTp_BIRTH_TYPE_FTR_INSECT, - mRmTp_BIRTH_TYPE_FTR_INSECT, - mRmTp_BIRTH_TYPE_FTR_INSECT, - mRmTp_BIRTH_TYPE_FTR_INSECT, - mRmTp_BIRTH_TYPE_FTR_INSECT, - mRmTp_BIRTH_TYPE_FTR_INSECT, - mRmTp_BIRTH_TYPE_FTR_INSECT, - mRmTp_BIRTH_TYPE_FTR_INSECT, - mRmTp_BIRTH_TYPE_FTR_INSECT, - mRmTp_BIRTH_TYPE_FTR_INSECT, - mRmTp_BIRTH_TYPE_FTR_INSECT, - mRmTp_BIRTH_TYPE_FTR_INSECT, - mRmTp_BIRTH_TYPE_FTR_INSECT, - mRmTp_BIRTH_TYPE_FTR_INSECT, - mRmTp_BIRTH_TYPE_FTR_INSECT, - mRmTp_BIRTH_TYPE_FTR_INSECT, - mRmTp_BIRTH_TYPE_FTR_INSECT, - mRmTp_BIRTH_TYPE_FTR_INSECT, - mRmTp_BIRTH_TYPE_FTR_INSECT, - mRmTp_BIRTH_TYPE_FTR_INSECT, - mRmTp_BIRTH_TYPE_FTR_INSECT, - mRmTp_BIRTH_TYPE_FTR_INSECT, - mRmTp_BIRTH_TYPE_FTR_INSECT, - mRmTp_BIRTH_TYPE_FTR_INSECT, - mRmTp_BIRTH_TYPE_FTR_INSECT, - mRmTp_BIRTH_TYPE_FTR_INSECT, - mRmTp_BIRTH_TYPE_FTR_INSECT, - mRmTp_BIRTH_TYPE_FTR_INSECT, - mRmTp_BIRTH_TYPE_FTR_FISH, - mRmTp_BIRTH_TYPE_FTR_FISH, - mRmTp_BIRTH_TYPE_FTR_FISH, - mRmTp_BIRTH_TYPE_FTR_FISH, - mRmTp_BIRTH_TYPE_FTR_FISH, - mRmTp_BIRTH_TYPE_FTR_FISH, - mRmTp_BIRTH_TYPE_FTR_FISH, - mRmTp_BIRTH_TYPE_FTR_FISH, - mRmTp_BIRTH_TYPE_FTR_FISH, - mRmTp_BIRTH_TYPE_FTR_FISH, - mRmTp_BIRTH_TYPE_FTR_FISH, - mRmTp_BIRTH_TYPE_FTR_FISH, - mRmTp_BIRTH_TYPE_FTR_FISH, - mRmTp_BIRTH_TYPE_FTR_FISH, - mRmTp_BIRTH_TYPE_FTR_FISH, - mRmTp_BIRTH_TYPE_FTR_FISH, - mRmTp_BIRTH_TYPE_FTR_FISH, - mRmTp_BIRTH_TYPE_FTR_FISH, - mRmTp_BIRTH_TYPE_FTR_FISH, - mRmTp_BIRTH_TYPE_FTR_FISH, - mRmTp_BIRTH_TYPE_FTR_FISH, - mRmTp_BIRTH_TYPE_FTR_FISH, - mRmTp_BIRTH_TYPE_FTR_FISH, - mRmTp_BIRTH_TYPE_FTR_FISH, - mRmTp_BIRTH_TYPE_FTR_FISH, - mRmTp_BIRTH_TYPE_FTR_FISH, - mRmTp_BIRTH_TYPE_FTR_FISH, - mRmTp_BIRTH_TYPE_FTR_FISH, - mRmTp_BIRTH_TYPE_FTR_FISH, - mRmTp_BIRTH_TYPE_FTR_FISH, - mRmTp_BIRTH_TYPE_FTR_FISH, - mRmTp_BIRTH_TYPE_FTR_FISH, - mRmTp_BIRTH_TYPE_FTR_FISH, - mRmTp_BIRTH_TYPE_FTR_FISH, - mRmTp_BIRTH_TYPE_FTR_FISH, - mRmTp_BIRTH_TYPE_FTR_FISH, - mRmTp_BIRTH_TYPE_FTR_FISH, - mRmTp_BIRTH_TYPE_FTR_FISH, - mRmTp_BIRTH_TYPE_FTR_FISH, - mRmTp_BIRTH_TYPE_FTR_FISH, - mRmTp_BIRTH_TYPE_FTR_UMBRELLA, - mRmTp_BIRTH_TYPE_FTR_UMBRELLA, - mRmTp_BIRTH_TYPE_FTR_UMBRELLA, - mRmTp_BIRTH_TYPE_FTR_UMBRELLA, - mRmTp_BIRTH_TYPE_FTR_UMBRELLA, - mRmTp_BIRTH_TYPE_FTR_UMBRELLA, - mRmTp_BIRTH_TYPE_FTR_UMBRELLA, - mRmTp_BIRTH_TYPE_FTR_UMBRELLA, - mRmTp_BIRTH_TYPE_FTR_UMBRELLA, - mRmTp_BIRTH_TYPE_FTR_UMBRELLA, - mRmTp_BIRTH_TYPE_FTR_UMBRELLA, - mRmTp_BIRTH_TYPE_FTR_UMBRELLA, - mRmTp_BIRTH_TYPE_FTR_UMBRELLA, - mRmTp_BIRTH_TYPE_FTR_UMBRELLA, - mRmTp_BIRTH_TYPE_FTR_UMBRELLA, - mRmTp_BIRTH_TYPE_FTR_UMBRELLA, - mRmTp_BIRTH_TYPE_FTR_UMBRELLA, - mRmTp_BIRTH_TYPE_FTR_UMBRELLA, - mRmTp_BIRTH_TYPE_FTR_UMBRELLA, - mRmTp_BIRTH_TYPE_FTR_UMBRELLA, - mRmTp_BIRTH_TYPE_FTR_UMBRELLA, - mRmTp_BIRTH_TYPE_FTR_UMBRELLA, - mRmTp_BIRTH_TYPE_FTR_UMBRELLA, - mRmTp_BIRTH_TYPE_FTR_UMBRELLA, - mRmTp_BIRTH_TYPE_FTR_UMBRELLA, - mRmTp_BIRTH_TYPE_FTR_UMBRELLA, - mRmTp_BIRTH_TYPE_FTR_UMBRELLA, - mRmTp_BIRTH_TYPE_FTR_UMBRELLA, - mRmTp_BIRTH_TYPE_FTR_UMBRELLA, - mRmTp_BIRTH_TYPE_FTR_UMBRELLA, - mRmTp_BIRTH_TYPE_FTR_UMBRELLA, - mRmTp_BIRTH_TYPE_FTR_UMBRELLA, - mRmTp_BIRTH_TYPE_MY_ORIGINAL, - mRmTp_BIRTH_TYPE_MY_ORIGINAL, - mRmTp_BIRTH_TYPE_MY_ORIGINAL, - mRmTp_BIRTH_TYPE_MY_ORIGINAL, - mRmTp_BIRTH_TYPE_MY_ORIGINAL, - mRmTp_BIRTH_TYPE_MY_ORIGINAL, - mRmTp_BIRTH_TYPE_MY_ORIGINAL, - mRmTp_BIRTH_TYPE_MY_ORIGINAL, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_LOTTERY, - mRmTp_BIRTH_TYPE_LOTTERY, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_LOTTERY, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_FAMICOM_CODE, - mRmTp_BIRTH_TYPE_FAMICOM_ISLAND, - mRmTp_BIRTH_TYPE_FAMICOM_CODE, - mRmTp_BIRTH_TYPE_FAMICOM_CODE, - mRmTp_BIRTH_TYPE_FAMICOM_CODE, - mRmTp_BIRTH_TYPE_FAMICOM_CODE, - mRmTp_BIRTH_TYPE_LOTTERY, - mRmTp_BIRTH_TYPE_FAMICOM_ISLAND, - mRmTp_BIRTH_TYPE_FAMICOM_EREADER, - mRmTp_BIRTH_TYPE_FAMICOM_EREADER, - mRmTp_BIRTH_TYPE_FAMICOM_EREADER, - mRmTp_BIRTH_TYPE_FAMICOM_EREADER, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_LOTTERY, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_LOTTERY, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_SANTA, - mRmTp_BIRTH_TYPE_SANTA, - mRmTp_BIRTH_TYPE_SANTA, - mRmTp_BIRTH_TYPE_SANTA, - mRmTp_BIRTH_TYPE_SANTA, - mRmTp_BIRTH_TYPE_SANTA, - mRmTp_BIRTH_TYPE_SANTA, - mRmTp_BIRTH_TYPE_SANTA, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_LOTTERY, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_LOTTERY, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_XMAS, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_LOTTERY, - mRmTp_BIRTH_TYPE_LOTTERY, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_LOTTERY, - mRmTp_BIRTH_TYPE_LOTTERY, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_XMAS, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_LOTTERY, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_MULTI_FOSSIL, - mRmTp_BIRTH_TYPE_MULTI_FOSSIL, - mRmTp_BIRTH_TYPE_MULTI_FOSSIL, - mRmTp_BIRTH_TYPE_MULTI_FOSSIL, - mRmTp_BIRTH_TYPE_MULTI_FOSSIL, - mRmTp_BIRTH_TYPE_MULTI_FOSSIL, - mRmTp_BIRTH_TYPE_MULTI_FOSSIL, - mRmTp_BIRTH_TYPE_MULTI_FOSSIL, - mRmTp_BIRTH_TYPE_MULTI_FOSSIL, - mRmTp_BIRTH_TYPE_MULTI_FOSSIL, - mRmTp_BIRTH_TYPE_MULTI_FOSSIL, - mRmTp_BIRTH_TYPE_MULTI_FOSSIL, - mRmTp_BIRTH_TYPE_MULTI_FOSSIL, - mRmTp_BIRTH_TYPE_MULTI_FOSSIL, - mRmTp_BIRTH_TYPE_MULTI_FOSSIL, - mRmTp_BIRTH_TYPE_MULTI_FOSSIL, - mRmTp_BIRTH_TYPE_MULTI_FOSSIL, - mRmTp_BIRTH_TYPE_MULTI_FOSSIL, - mRmTp_BIRTH_TYPE_MULTI_FOSSIL, - mRmTp_BIRTH_TYPE_MULTI_FOSSIL, - mRmTp_BIRTH_TYPE_SINGLE_FOSSIL, - mRmTp_BIRTH_TYPE_SINGLE_FOSSIL, - mRmTp_BIRTH_TYPE_SINGLE_FOSSIL, - mRmTp_BIRTH_TYPE_SINGLE_FOSSIL, - mRmTp_BIRTH_TYPE_SINGLE_FOSSIL, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_SNOWMAN, - mRmTp_BIRTH_TYPE_SNOWMAN, - mRmTp_BIRTH_TYPE_SNOWMAN, - mRmTp_BIRTH_TYPE_SNOWMAN, - mRmTp_BIRTH_TYPE_SNOWMAN, - mRmTp_BIRTH_TYPE_SNOWMAN, - mRmTp_BIRTH_TYPE_SNOWMAN, - mRmTp_BIRTH_TYPE_SNOWMAN, - mRmTp_BIRTH_TYPE_SNOWMAN, - mRmTp_BIRTH_TYPE_SNOWMAN, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_JONASON, - mRmTp_BIRTH_TYPE_SONCHO_LIGHTHOUSE_QUEST, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_POST_OFFICE, - mRmTp_BIRTH_TYPE_POST_OFFICE, - mRmTp_BIRTH_TYPE_JONASON, - mRmTp_BIRTH_TYPE_JONASON, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_SONCHO, - mRmTp_BIRTH_TYPE_JONASON, - mRmTp_BIRTH_TYPE_JONASON, - mRmTp_BIRTH_TYPE_SONCHO, - mRmTp_BIRTH_TYPE_JONASON, - mRmTp_BIRTH_TYPE_JONASON, - mRmTp_BIRTH_TYPE_JONASON, - mRmTp_BIRTH_TYPE_JONASON, - mRmTp_BIRTH_TYPE_JONASON, - mRmTp_BIRTH_TYPE_JONASON, - mRmTp_BIRTH_TYPE_JONASON, - mRmTp_BIRTH_TYPE_JONASON, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_JONASON, - mRmTp_BIRTH_TYPE_JONASON, - mRmTp_BIRTH_TYPE_JONASON, - mRmTp_BIRTH_TYPE_JONASON, - mRmTp_BIRTH_TYPE_POST_OFFICE, - mRmTp_BIRTH_TYPE_MARK_ROOM, - mRmTp_BIRTH_TYPE_MARK_ROOM, - mRmTp_BIRTH_TYPE_SONCHO, - mRmTp_BIRTH_TYPE_MUSEUM, - mRmTp_BIRTH_TYPE_JONASON, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_SONCHO, - mRmTp_BIRTH_TYPE_SONCHO, - mRmTp_BIRTH_TYPE_SONCHO, - mRmTp_BIRTH_TYPE_JONASON, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_SONCHO, - mRmTp_BIRTH_TYPE_JONASON, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_SONCHO_LIGHTHOUSE_QUEST, - mRmTp_BIRTH_TYPE_ISLAND, - mRmTp_BIRTH_TYPE_GROUNDHOG, - mRmTp_BIRTH_TYPE_GROUNDHOG, - mRmTp_BIRTH_TYPE_GROUNDHOG, - mRmTp_BIRTH_TYPE_SONCHO, - mRmTp_BIRTH_TYPE_SONCHO, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_SONCHO, - mRmTp_BIRTH_TYPE_SONCHO, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_SONCHO, - mRmTp_BIRTH_TYPE_SONCHO, - mRmTp_BIRTH_TYPE_SONCHO, - mRmTp_BIRTH_TYPE_SONCHO, - mRmTp_BIRTH_TYPE_SONCHO, - mRmTp_BIRTH_TYPE_SONCHO, - mRmTp_BIRTH_TYPE_SONCHO, - mRmTp_BIRTH_TYPE_SONCHO, - mRmTp_BIRTH_TYPE_SONCHO, - mRmTp_BIRTH_TYPE_SONCHO, - mRmTp_BIRTH_TYPE_SONCHO, - mRmTp_BIRTH_TYPE_SONCHO, - mRmTp_BIRTH_TYPE_SONCHO, - mRmTp_BIRTH_TYPE_SONCHO, - mRmTp_BIRTH_TYPE_SONCHO, - mRmTp_BIRTH_TYPE_SONCHO, - mRmTp_BIRTH_TYPE_SONCHO, - mRmTp_BIRTH_TYPE_SONCHO, - mRmTp_BIRTH_TYPE_SONCHO, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_FTR_DIARY, - mRmTp_BIRTH_TYPE_FTR_DIARY, - mRmTp_BIRTH_TYPE_FTR_DIARY, - mRmTp_BIRTH_TYPE_FTR_DIARY, - mRmTp_BIRTH_TYPE_FTR_DIARY, - mRmTp_BIRTH_TYPE_FTR_DIARY, - mRmTp_BIRTH_TYPE_FTR_DIARY, - mRmTp_BIRTH_TYPE_FTR_DIARY, - mRmTp_BIRTH_TYPE_FTR_DIARY, - mRmTp_BIRTH_TYPE_FTR_DIARY, - mRmTp_BIRTH_TYPE_FTR_DIARY, - mRmTp_BIRTH_TYPE_FTR_DIARY, - mRmTp_BIRTH_TYPE_FTR_DIARY, - mRmTp_BIRTH_TYPE_FTR_DIARY, - mRmTp_BIRTH_TYPE_FTR_DIARY, - mRmTp_BIRTH_TYPE_FTR_DIARY, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_KAMAKURA, - mRmTp_BIRTH_TYPE_KAMAKURA, - mRmTp_BIRTH_TYPE_KAMAKURA, - mRmTp_BIRTH_TYPE_KAMAKURA, - mRmTp_BIRTH_TYPE_ISLAND, - mRmTp_BIRTH_TYPE_ISLAND, - mRmTp_BIRTH_TYPE_ISLAND, - mRmTp_BIRTH_TYPE_ISLAND, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_ISLAND, - mRmTp_BIRTH_TYPE_KAMAKURA, - mRmTp_BIRTH_TYPE_ISLAND, - mRmTp_BIRTH_TYPE_ISLAND, - mRmTp_BIRTH_TYPE_ISLAND, - mRmTp_BIRTH_TYPE_KAMAKURA, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_KAMAKURA, - mRmTp_BIRTH_TYPE_NINTENDO_CODE, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_SONCHO, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_SONCHO, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_UNOBTAINABLE, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_SONCHO, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_LOTTERY, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_LOTTERY, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_XMAS, - mRmTp_BIRTH_TYPE_SONCHO, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_POST_OFFICE, - mRmTp_BIRTH_TYPE_XMAS, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_LOTTERY, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_SONCHO, - mRmTp_BIRTH_TYPE_SONCHO, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_LOTTERY, - mRmTp_BIRTH_TYPE_HARVEST_FESTIVAL, - mRmTp_BIRTH_TYPE_LOTTERY, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_HARVEST_FESTIVAL, - mRmTp_BIRTH_TYPE_HARVEST_FESTIVAL, - mRmTp_BIRTH_TYPE_HARVEST_FESTIVAL, - mRmTp_BIRTH_TYPE_HARVEST_FESTIVAL, - mRmTp_BIRTH_TYPE_HARVEST_FESTIVAL, - mRmTp_BIRTH_TYPE_HARVEST_FESTIVAL, - mRmTp_BIRTH_TYPE_NINTENDO_CODE, - mRmTp_BIRTH_TYPE_NINTENDO_CODE, - mRmTp_BIRTH_TYPE_HARVEST_FESTIVAL, - mRmTp_BIRTH_TYPE_NINTENDO_CODE, - mRmTp_BIRTH_TYPE_HARVEST_FESTIVAL, - mRmTp_BIRTH_TYPE_NINTENDO_CODE, - mRmTp_BIRTH_TYPE_HARVEST_FESTIVAL, - mRmTp_BIRTH_TYPE_NINTENDO_CODE, - mRmTp_BIRTH_TYPE_NINTENDO_CODE, - mRmTp_BIRTH_TYPE_NINTENDO_CODE, - mRmTp_BIRTH_TYPE_NINTENDO_CODE, - mRmTp_BIRTH_TYPE_NINTENDO_CODE, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_NINTENDO_CODE, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_LOTTERY, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_A, - mRmTp_BIRTH_TYPE_GRP_B, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_SUMMER_CAMPER, - mRmTp_BIRTH_TYPE_SUMMER_CAMPER, - mRmTp_BIRTH_TYPE_SUMMER_CAMPER, - mRmTp_BIRTH_TYPE_GRP_C, - mRmTp_BIRTH_TYPE_SUMMER_CAMPER, - mRmTp_BIRTH_TYPE_SUMMER_CAMPER, - mRmTp_BIRTH_TYPE_SONCHO, - mRmTp_BIRTH_TYPE_GROUNDHOG, - mRmTp_BIRTH_TYPE_GROUNDHOG, - mRmTp_BIRTH_TYPE_GROUNDHOG, - mRmTp_BIRTH_TYPE_GROUNDHOG, - mRmTp_BIRTH_TYPE_GROUNDHOG, - mRmTp_BIRTH_TYPE_GROUNDHOG, - mRmTp_BIRTH_TYPE_GROUNDHOG, - mRmTp_BIRTH_TYPE_GROUNDHOG, - mRmTp_BIRTH_TYPE_GROUNDHOG, - mRmTp_BIRTH_TYPE_SUMMER_CAMPER, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_SUMMER_CAMPER, - mRmTp_BIRTH_TYPE_SUMMER_CAMPER, - mRmTp_BIRTH_TYPE_SUMMER_CAMPER, - mRmTp_BIRTH_TYPE_SUMMER_CAMPER, - mRmTp_BIRTH_TYPE_SONCHO, - mRmTp_BIRTH_TYPE_EVENT, - mRmTp_BIRTH_TYPE_SONCHO, - mRmTp_BIRTH_TYPE_KAMAKURA, - mRmTp_BIRTH_TYPE_UNOBTAINABLE }; +static u8 mRmTp_birth_type[FTR_NUM] = { + mRmTp_BIRTH_TYPE_HALLOWEEN, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_SANTA, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_SANTA, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_HALLOWEEN, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_LOTTERY, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_LOTTERY, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_LOTTERY, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_LOTTERY, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_LOTTERY, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_LOTTERY, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_BIRTHDAY, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_LOTTERY, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_LOTTERY, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_LOTTERY, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_LOTTERY, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_LOTTERY, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_LOTTERY, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_LOTTERY, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_LOTTERY, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_HALLOWEEN_TRICK, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_HALLOWEEN, + mRmTp_BIRTH_TYPE_HALLOWEEN_TRICK, + mRmTp_BIRTH_TYPE_HALLOWEEN, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_HALLOWEEN, + mRmTp_BIRTH_TYPE_HALLOWEEN, + mRmTp_BIRTH_TYPE_HALLOWEEN, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_LOTTERY, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_HALLOWEEN, + mRmTp_BIRTH_TYPE_HALLOWEEN, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_LOTTERY, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_HALLOWEEN, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_LOTTERY, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_HANIWA, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_FTR_CLOTH, + mRmTp_BIRTH_TYPE_MY_ORIGINAL, + mRmTp_BIRTH_TYPE_MY_ORIGINAL, + mRmTp_BIRTH_TYPE_MY_ORIGINAL, + mRmTp_BIRTH_TYPE_MY_ORIGINAL, + mRmTp_BIRTH_TYPE_MY_ORIGINAL, + mRmTp_BIRTH_TYPE_MY_ORIGINAL, + mRmTp_BIRTH_TYPE_MY_ORIGINAL, + mRmTp_BIRTH_TYPE_MY_ORIGINAL, + mRmTp_BIRTH_TYPE_FTR_INSECT, + mRmTp_BIRTH_TYPE_FTR_INSECT, + mRmTp_BIRTH_TYPE_FTR_INSECT, + mRmTp_BIRTH_TYPE_FTR_INSECT, + mRmTp_BIRTH_TYPE_FTR_INSECT, + mRmTp_BIRTH_TYPE_FTR_INSECT, + mRmTp_BIRTH_TYPE_FTR_INSECT, + mRmTp_BIRTH_TYPE_FTR_INSECT, + mRmTp_BIRTH_TYPE_FTR_INSECT, + mRmTp_BIRTH_TYPE_FTR_INSECT, + mRmTp_BIRTH_TYPE_FTR_INSECT, + mRmTp_BIRTH_TYPE_FTR_INSECT, + mRmTp_BIRTH_TYPE_FTR_INSECT, + mRmTp_BIRTH_TYPE_FTR_INSECT, + mRmTp_BIRTH_TYPE_FTR_INSECT, + mRmTp_BIRTH_TYPE_FTR_INSECT, + mRmTp_BIRTH_TYPE_FTR_INSECT, + mRmTp_BIRTH_TYPE_FTR_INSECT, + mRmTp_BIRTH_TYPE_FTR_INSECT, + mRmTp_BIRTH_TYPE_FTR_INSECT, + mRmTp_BIRTH_TYPE_FTR_INSECT, + mRmTp_BIRTH_TYPE_FTR_INSECT, + mRmTp_BIRTH_TYPE_FTR_INSECT, + mRmTp_BIRTH_TYPE_FTR_INSECT, + mRmTp_BIRTH_TYPE_FTR_INSECT, + mRmTp_BIRTH_TYPE_FTR_INSECT, + mRmTp_BIRTH_TYPE_FTR_INSECT, + mRmTp_BIRTH_TYPE_FTR_INSECT, + mRmTp_BIRTH_TYPE_FTR_INSECT, + mRmTp_BIRTH_TYPE_FTR_INSECT, + mRmTp_BIRTH_TYPE_FTR_INSECT, + mRmTp_BIRTH_TYPE_FTR_INSECT, + mRmTp_BIRTH_TYPE_FTR_INSECT, + mRmTp_BIRTH_TYPE_FTR_INSECT, + mRmTp_BIRTH_TYPE_FTR_INSECT, + mRmTp_BIRTH_TYPE_FTR_INSECT, + mRmTp_BIRTH_TYPE_FTR_INSECT, + mRmTp_BIRTH_TYPE_FTR_INSECT, + mRmTp_BIRTH_TYPE_FTR_INSECT, + mRmTp_BIRTH_TYPE_FTR_INSECT, + mRmTp_BIRTH_TYPE_FTR_FISH, + mRmTp_BIRTH_TYPE_FTR_FISH, + mRmTp_BIRTH_TYPE_FTR_FISH, + mRmTp_BIRTH_TYPE_FTR_FISH, + mRmTp_BIRTH_TYPE_FTR_FISH, + mRmTp_BIRTH_TYPE_FTR_FISH, + mRmTp_BIRTH_TYPE_FTR_FISH, + mRmTp_BIRTH_TYPE_FTR_FISH, + mRmTp_BIRTH_TYPE_FTR_FISH, + mRmTp_BIRTH_TYPE_FTR_FISH, + mRmTp_BIRTH_TYPE_FTR_FISH, + mRmTp_BIRTH_TYPE_FTR_FISH, + mRmTp_BIRTH_TYPE_FTR_FISH, + mRmTp_BIRTH_TYPE_FTR_FISH, + mRmTp_BIRTH_TYPE_FTR_FISH, + mRmTp_BIRTH_TYPE_FTR_FISH, + mRmTp_BIRTH_TYPE_FTR_FISH, + mRmTp_BIRTH_TYPE_FTR_FISH, + mRmTp_BIRTH_TYPE_FTR_FISH, + mRmTp_BIRTH_TYPE_FTR_FISH, + mRmTp_BIRTH_TYPE_FTR_FISH, + mRmTp_BIRTH_TYPE_FTR_FISH, + mRmTp_BIRTH_TYPE_FTR_FISH, + mRmTp_BIRTH_TYPE_FTR_FISH, + mRmTp_BIRTH_TYPE_FTR_FISH, + mRmTp_BIRTH_TYPE_FTR_FISH, + mRmTp_BIRTH_TYPE_FTR_FISH, + mRmTp_BIRTH_TYPE_FTR_FISH, + mRmTp_BIRTH_TYPE_FTR_FISH, + mRmTp_BIRTH_TYPE_FTR_FISH, + mRmTp_BIRTH_TYPE_FTR_FISH, + mRmTp_BIRTH_TYPE_FTR_FISH, + mRmTp_BIRTH_TYPE_FTR_FISH, + mRmTp_BIRTH_TYPE_FTR_FISH, + mRmTp_BIRTH_TYPE_FTR_FISH, + mRmTp_BIRTH_TYPE_FTR_FISH, + mRmTp_BIRTH_TYPE_FTR_FISH, + mRmTp_BIRTH_TYPE_FTR_FISH, + mRmTp_BIRTH_TYPE_FTR_FISH, + mRmTp_BIRTH_TYPE_FTR_FISH, + mRmTp_BIRTH_TYPE_FTR_UMBRELLA, + mRmTp_BIRTH_TYPE_FTR_UMBRELLA, + mRmTp_BIRTH_TYPE_FTR_UMBRELLA, + mRmTp_BIRTH_TYPE_FTR_UMBRELLA, + mRmTp_BIRTH_TYPE_FTR_UMBRELLA, + mRmTp_BIRTH_TYPE_FTR_UMBRELLA, + mRmTp_BIRTH_TYPE_FTR_UMBRELLA, + mRmTp_BIRTH_TYPE_FTR_UMBRELLA, + mRmTp_BIRTH_TYPE_FTR_UMBRELLA, + mRmTp_BIRTH_TYPE_FTR_UMBRELLA, + mRmTp_BIRTH_TYPE_FTR_UMBRELLA, + mRmTp_BIRTH_TYPE_FTR_UMBRELLA, + mRmTp_BIRTH_TYPE_FTR_UMBRELLA, + mRmTp_BIRTH_TYPE_FTR_UMBRELLA, + mRmTp_BIRTH_TYPE_FTR_UMBRELLA, + mRmTp_BIRTH_TYPE_FTR_UMBRELLA, + mRmTp_BIRTH_TYPE_FTR_UMBRELLA, + mRmTp_BIRTH_TYPE_FTR_UMBRELLA, + mRmTp_BIRTH_TYPE_FTR_UMBRELLA, + mRmTp_BIRTH_TYPE_FTR_UMBRELLA, + mRmTp_BIRTH_TYPE_FTR_UMBRELLA, + mRmTp_BIRTH_TYPE_FTR_UMBRELLA, + mRmTp_BIRTH_TYPE_FTR_UMBRELLA, + mRmTp_BIRTH_TYPE_FTR_UMBRELLA, + mRmTp_BIRTH_TYPE_FTR_UMBRELLA, + mRmTp_BIRTH_TYPE_FTR_UMBRELLA, + mRmTp_BIRTH_TYPE_FTR_UMBRELLA, + mRmTp_BIRTH_TYPE_FTR_UMBRELLA, + mRmTp_BIRTH_TYPE_FTR_UMBRELLA, + mRmTp_BIRTH_TYPE_FTR_UMBRELLA, + mRmTp_BIRTH_TYPE_FTR_UMBRELLA, + mRmTp_BIRTH_TYPE_FTR_UMBRELLA, + mRmTp_BIRTH_TYPE_MY_ORIGINAL, + mRmTp_BIRTH_TYPE_MY_ORIGINAL, + mRmTp_BIRTH_TYPE_MY_ORIGINAL, + mRmTp_BIRTH_TYPE_MY_ORIGINAL, + mRmTp_BIRTH_TYPE_MY_ORIGINAL, + mRmTp_BIRTH_TYPE_MY_ORIGINAL, + mRmTp_BIRTH_TYPE_MY_ORIGINAL, + mRmTp_BIRTH_TYPE_MY_ORIGINAL, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_LOTTERY, + mRmTp_BIRTH_TYPE_LOTTERY, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_LOTTERY, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_FAMICOM_CODE, + mRmTp_BIRTH_TYPE_FAMICOM_ISLAND, + mRmTp_BIRTH_TYPE_FAMICOM_CODE, + mRmTp_BIRTH_TYPE_FAMICOM_CODE, + mRmTp_BIRTH_TYPE_FAMICOM_CODE, + mRmTp_BIRTH_TYPE_FAMICOM_CODE, + mRmTp_BIRTH_TYPE_LOTTERY, + mRmTp_BIRTH_TYPE_FAMICOM_ISLAND, + mRmTp_BIRTH_TYPE_FAMICOM_EREADER, + mRmTp_BIRTH_TYPE_FAMICOM_EREADER, + mRmTp_BIRTH_TYPE_FAMICOM_EREADER, + mRmTp_BIRTH_TYPE_FAMICOM_EREADER, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_LOTTERY, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_LOTTERY, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_SANTA, + mRmTp_BIRTH_TYPE_SANTA, + mRmTp_BIRTH_TYPE_SANTA, + mRmTp_BIRTH_TYPE_SANTA, + mRmTp_BIRTH_TYPE_SANTA, + mRmTp_BIRTH_TYPE_SANTA, + mRmTp_BIRTH_TYPE_SANTA, + mRmTp_BIRTH_TYPE_SANTA, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_LOTTERY, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_LOTTERY, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_XMAS, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_LOTTERY, + mRmTp_BIRTH_TYPE_LOTTERY, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_LOTTERY, + mRmTp_BIRTH_TYPE_LOTTERY, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_XMAS, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_LOTTERY, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_MULTI_FOSSIL, + mRmTp_BIRTH_TYPE_MULTI_FOSSIL, + mRmTp_BIRTH_TYPE_MULTI_FOSSIL, + mRmTp_BIRTH_TYPE_MULTI_FOSSIL, + mRmTp_BIRTH_TYPE_MULTI_FOSSIL, + mRmTp_BIRTH_TYPE_MULTI_FOSSIL, + mRmTp_BIRTH_TYPE_MULTI_FOSSIL, + mRmTp_BIRTH_TYPE_MULTI_FOSSIL, + mRmTp_BIRTH_TYPE_MULTI_FOSSIL, + mRmTp_BIRTH_TYPE_MULTI_FOSSIL, + mRmTp_BIRTH_TYPE_MULTI_FOSSIL, + mRmTp_BIRTH_TYPE_MULTI_FOSSIL, + mRmTp_BIRTH_TYPE_MULTI_FOSSIL, + mRmTp_BIRTH_TYPE_MULTI_FOSSIL, + mRmTp_BIRTH_TYPE_MULTI_FOSSIL, + mRmTp_BIRTH_TYPE_MULTI_FOSSIL, + mRmTp_BIRTH_TYPE_MULTI_FOSSIL, + mRmTp_BIRTH_TYPE_MULTI_FOSSIL, + mRmTp_BIRTH_TYPE_MULTI_FOSSIL, + mRmTp_BIRTH_TYPE_MULTI_FOSSIL, + mRmTp_BIRTH_TYPE_SINGLE_FOSSIL, + mRmTp_BIRTH_TYPE_SINGLE_FOSSIL, + mRmTp_BIRTH_TYPE_SINGLE_FOSSIL, + mRmTp_BIRTH_TYPE_SINGLE_FOSSIL, + mRmTp_BIRTH_TYPE_SINGLE_FOSSIL, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_SNOWMAN, + mRmTp_BIRTH_TYPE_SNOWMAN, + mRmTp_BIRTH_TYPE_SNOWMAN, + mRmTp_BIRTH_TYPE_SNOWMAN, + mRmTp_BIRTH_TYPE_SNOWMAN, + mRmTp_BIRTH_TYPE_SNOWMAN, + mRmTp_BIRTH_TYPE_SNOWMAN, + mRmTp_BIRTH_TYPE_SNOWMAN, + mRmTp_BIRTH_TYPE_SNOWMAN, + mRmTp_BIRTH_TYPE_SNOWMAN, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_JONASON, + mRmTp_BIRTH_TYPE_SONCHO_LIGHTHOUSE_QUEST, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_POST_OFFICE, + mRmTp_BIRTH_TYPE_POST_OFFICE, + mRmTp_BIRTH_TYPE_JONASON, + mRmTp_BIRTH_TYPE_JONASON, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_SONCHO, + mRmTp_BIRTH_TYPE_JONASON, + mRmTp_BIRTH_TYPE_JONASON, + mRmTp_BIRTH_TYPE_SONCHO, + mRmTp_BIRTH_TYPE_JONASON, + mRmTp_BIRTH_TYPE_JONASON, + mRmTp_BIRTH_TYPE_JONASON, + mRmTp_BIRTH_TYPE_JONASON, + mRmTp_BIRTH_TYPE_JONASON, + mRmTp_BIRTH_TYPE_JONASON, + mRmTp_BIRTH_TYPE_JONASON, + mRmTp_BIRTH_TYPE_JONASON, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_JONASON, + mRmTp_BIRTH_TYPE_JONASON, + mRmTp_BIRTH_TYPE_JONASON, + mRmTp_BIRTH_TYPE_JONASON, + mRmTp_BIRTH_TYPE_POST_OFFICE, + mRmTp_BIRTH_TYPE_MARK_ROOM, + mRmTp_BIRTH_TYPE_MARK_ROOM, + mRmTp_BIRTH_TYPE_SONCHO, + mRmTp_BIRTH_TYPE_MUSEUM, + mRmTp_BIRTH_TYPE_JONASON, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_SONCHO, + mRmTp_BIRTH_TYPE_SONCHO, + mRmTp_BIRTH_TYPE_SONCHO, + mRmTp_BIRTH_TYPE_JONASON, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_SONCHO, + mRmTp_BIRTH_TYPE_JONASON, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_SONCHO_LIGHTHOUSE_QUEST, + mRmTp_BIRTH_TYPE_ISLAND, + mRmTp_BIRTH_TYPE_GROUNDHOG, + mRmTp_BIRTH_TYPE_GROUNDHOG, + mRmTp_BIRTH_TYPE_GROUNDHOG, + mRmTp_BIRTH_TYPE_SONCHO, + mRmTp_BIRTH_TYPE_SONCHO, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_SONCHO, + mRmTp_BIRTH_TYPE_SONCHO, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_SONCHO, + mRmTp_BIRTH_TYPE_SONCHO, + mRmTp_BIRTH_TYPE_SONCHO, + mRmTp_BIRTH_TYPE_SONCHO, + mRmTp_BIRTH_TYPE_SONCHO, + mRmTp_BIRTH_TYPE_SONCHO, + mRmTp_BIRTH_TYPE_SONCHO, + mRmTp_BIRTH_TYPE_SONCHO, + mRmTp_BIRTH_TYPE_SONCHO, + mRmTp_BIRTH_TYPE_SONCHO, + mRmTp_BIRTH_TYPE_SONCHO, + mRmTp_BIRTH_TYPE_SONCHO, + mRmTp_BIRTH_TYPE_SONCHO, + mRmTp_BIRTH_TYPE_SONCHO, + mRmTp_BIRTH_TYPE_SONCHO, + mRmTp_BIRTH_TYPE_SONCHO, + mRmTp_BIRTH_TYPE_SONCHO, + mRmTp_BIRTH_TYPE_SONCHO, + mRmTp_BIRTH_TYPE_SONCHO, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_FTR_DIARY, + mRmTp_BIRTH_TYPE_FTR_DIARY, + mRmTp_BIRTH_TYPE_FTR_DIARY, + mRmTp_BIRTH_TYPE_FTR_DIARY, + mRmTp_BIRTH_TYPE_FTR_DIARY, + mRmTp_BIRTH_TYPE_FTR_DIARY, + mRmTp_BIRTH_TYPE_FTR_DIARY, + mRmTp_BIRTH_TYPE_FTR_DIARY, + mRmTp_BIRTH_TYPE_FTR_DIARY, + mRmTp_BIRTH_TYPE_FTR_DIARY, + mRmTp_BIRTH_TYPE_FTR_DIARY, + mRmTp_BIRTH_TYPE_FTR_DIARY, + mRmTp_BIRTH_TYPE_FTR_DIARY, + mRmTp_BIRTH_TYPE_FTR_DIARY, + mRmTp_BIRTH_TYPE_FTR_DIARY, + mRmTp_BIRTH_TYPE_FTR_DIARY, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_KAMAKURA, + mRmTp_BIRTH_TYPE_KAMAKURA, + mRmTp_BIRTH_TYPE_KAMAKURA, + mRmTp_BIRTH_TYPE_KAMAKURA, + mRmTp_BIRTH_TYPE_ISLAND, + mRmTp_BIRTH_TYPE_ISLAND, + mRmTp_BIRTH_TYPE_ISLAND, + mRmTp_BIRTH_TYPE_ISLAND, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_ISLAND, + mRmTp_BIRTH_TYPE_KAMAKURA, + mRmTp_BIRTH_TYPE_ISLAND, + mRmTp_BIRTH_TYPE_ISLAND, + mRmTp_BIRTH_TYPE_ISLAND, + mRmTp_BIRTH_TYPE_KAMAKURA, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_KAMAKURA, + mRmTp_BIRTH_TYPE_NINTENDO_CODE, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_SONCHO, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_SONCHO, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_SONCHO, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_LOTTERY, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_LOTTERY, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_XMAS, + mRmTp_BIRTH_TYPE_SONCHO, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_POST_OFFICE, + mRmTp_BIRTH_TYPE_XMAS, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_LOTTERY, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_SONCHO, + mRmTp_BIRTH_TYPE_SONCHO, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_LOTTERY, + mRmTp_BIRTH_TYPE_HARVEST_FESTIVAL, + mRmTp_BIRTH_TYPE_LOTTERY, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_HARVEST_FESTIVAL, + mRmTp_BIRTH_TYPE_HARVEST_FESTIVAL, + mRmTp_BIRTH_TYPE_HARVEST_FESTIVAL, + mRmTp_BIRTH_TYPE_HARVEST_FESTIVAL, + mRmTp_BIRTH_TYPE_HARVEST_FESTIVAL, + mRmTp_BIRTH_TYPE_HARVEST_FESTIVAL, + mRmTp_BIRTH_TYPE_NINTENDO_CODE, + mRmTp_BIRTH_TYPE_NINTENDO_CODE, + mRmTp_BIRTH_TYPE_HARVEST_FESTIVAL, + mRmTp_BIRTH_TYPE_NINTENDO_CODE, + mRmTp_BIRTH_TYPE_HARVEST_FESTIVAL, + mRmTp_BIRTH_TYPE_NINTENDO_CODE, + mRmTp_BIRTH_TYPE_HARVEST_FESTIVAL, + mRmTp_BIRTH_TYPE_NINTENDO_CODE, + mRmTp_BIRTH_TYPE_NINTENDO_CODE, + mRmTp_BIRTH_TYPE_NINTENDO_CODE, + mRmTp_BIRTH_TYPE_NINTENDO_CODE, + mRmTp_BIRTH_TYPE_NINTENDO_CODE, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_NINTENDO_CODE, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_LOTTERY, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_A, + mRmTp_BIRTH_TYPE_GRP_B, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_SUMMER_CAMPER, + mRmTp_BIRTH_TYPE_SUMMER_CAMPER, + mRmTp_BIRTH_TYPE_SUMMER_CAMPER, + mRmTp_BIRTH_TYPE_GRP_C, + mRmTp_BIRTH_TYPE_SUMMER_CAMPER, + mRmTp_BIRTH_TYPE_SUMMER_CAMPER, + mRmTp_BIRTH_TYPE_SONCHO, + mRmTp_BIRTH_TYPE_GROUNDHOG, + mRmTp_BIRTH_TYPE_GROUNDHOG, + mRmTp_BIRTH_TYPE_GROUNDHOG, + mRmTp_BIRTH_TYPE_GROUNDHOG, + mRmTp_BIRTH_TYPE_GROUNDHOG, + mRmTp_BIRTH_TYPE_GROUNDHOG, + mRmTp_BIRTH_TYPE_GROUNDHOG, + mRmTp_BIRTH_TYPE_GROUNDHOG, + mRmTp_BIRTH_TYPE_GROUNDHOG, + mRmTp_BIRTH_TYPE_SUMMER_CAMPER, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_SUMMER_CAMPER, + mRmTp_BIRTH_TYPE_SUMMER_CAMPER, + mRmTp_BIRTH_TYPE_SUMMER_CAMPER, + mRmTp_BIRTH_TYPE_SUMMER_CAMPER, + mRmTp_BIRTH_TYPE_SONCHO, + mRmTp_BIRTH_TYPE_EVENT, + mRmTp_BIRTH_TYPE_SONCHO, + mRmTp_BIRTH_TYPE_KAMAKURA, + mRmTp_BIRTH_TYPE_UNOBTAINABLE, +}; extern u8* mRmTp_CheckFtrBirthInfoTop() { return mRmTp_birth_type; @@ -1929,7 +1927,8 @@ extern mActor_name_t mRmTp_Item1ItemNo2FtrItemNo_AtPlayerRoom(mActor_name_t item return FTR_UMBRELLA_START + (is_valid ? item1_no - ITM_UMBRELLA_START : 0) * mRmTp_DIRECT_NUM; } else if (item1_no >= ITM_BALLOON_START && item1_no <= ITM_BUNNY_O_BALLOON) { - return mRmTp_FtrIdx2FtrItemNo(FTR_NOG_BALLOON_COMMON0 + ((item1_no - ITM_BALLOON_START) & 7), mRmTp_DIRECT_SOUTH); + return mRmTp_FtrIdx2FtrItemNo(FTR_NOG_BALLOON_COMMON0 + ((item1_no - ITM_BALLOON_START) & 7), + mRmTp_DIRECT_SOUTH); } if (no_convert_tools == FALSE) { diff --git a/src/game/m_select.c b/src/game/m_select.c index 2333a593..1dfc9a86 100644 --- a/src/game/m_select.c +++ b/src/game/m_select.c @@ -20,1252 +20,988 @@ #include "m_common_data.h" static void game_next_play(GAME* game, int scene_no) { - Save_Set(scene_no, scene_no); + Save_Set(scene_no, scene_no); - GAME_GOTO_NEXT(game, play, PLAY); - mHm_SetNowHome(); - Common_Set(door_data.next_scene_id, 0); - Kabu_decide_price_schedule(); - Common_Set(map_flag, TRUE); + GAME_GOTO_NEXT(game, play, PLAY); + mHm_SetNowHome(); + Common_Set(door_data.next_scene_id, 0); + Kabu_decide_price_schedule(); + Common_Set(map_flag, TRUE); } typedef struct namefunc_s { - const char* name; - GAME_PROC next_play_proc; - int scene_no; + const char* name; + GAME_PROC next_play_proc; + int scene_no; } namefunc_t; #define nf_str(s0, s1) (s0 GFXPRINT_KATAKANA_MODE_CHAR s1) static namefunc_t nf_tbl[SCENE_NUM] = { - { - nf_str(" 1:", "フィールド コース1"), - &game_next_play, - SCENE_TEST1 - }, - { - nf_str(" 2:", "フィールド コース2"), - &game_next_play, - SCENE_TEST2 - }, - { - nf_str(" 3:", "フィールデ コース3"), - &game_next_play, - SCENE_TEST3 - }, - { - nf_str(" 4:", "オミズテスト コース"), - &game_next_play, - SCENE_WATER_TEST - }, - { - nf_str(" 5:", "アシアトテストコース"), - &game_next_play, - SCENE_FOOTPRINT_TEST - }, - { - nf_str(" 6:", "npc テストコース"), - &game_next_play, - SCENE_NPC_TEST - }, - { - nf_str(" 7:", "NPCアレンジルーム"), - &game_next_play, - SCENE_NPC_HOUSE - }, - { - nf_str(" 8:", "NPCランダムコース"), - &game_next_play, - SCENE_FG - }, - { - nf_str(" 9:", "FGツール フィールドヨウ"), - &game_next_play, - SCENE_RANDOM_NPC_TEST - }, - { - nf_str("10:", "オミセ"), - &game_next_play, - SCENE_SHOP0 - }, - { - nf_str("11:", "BGプレビュー カワナシ"), - &game_next_play, - SCENE_BG_TEST_NO_RIVER - }, - { - nf_str("12:", "BGプレビュー カワアリ"), - &game_next_play, - SCENE_BG_TEST_RIVER - }, - { - nf_str("13:", "ヤミブローカーノ オミセ"), - &game_next_play, - SCENE_BROKER_SHOP - }, - { - nf_str("14:", "FGツール ヘヤノナカヨウ"), - &game_next_play, - SCENE_FIELD_TOOL_INSIDE - }, - { - nf_str("15:", "ユウビンキョク"), - &game_next_play, - SCENE_POST_OFFICE - }, - { - nf_str("16:", "start demo 1"), - &game_next_play, - SCENE_START_DEMO - }, - { - nf_str("17:", "start demo 2"), - &game_next_play, - SCENE_START_DEMO2 - }, - { - nf_str("18:", "コウバン"), - &game_next_play, - SCENE_POLICE_BOX - }, - { - nf_str("19:", "ホロバシャ"), - &game_next_play, - SCENE_BUGGY - }, - { - nf_str("20:", "プレーヤー セレクト"), - &game_next_play, - SCENE_PLAYERSELECT - }, - { - nf_str("21:", "マイルーム size S"), - &game_next_play, - SCENE_MY_ROOM_S - }, - { - nf_str("22:", "マイルーム size M"), - &game_next_play, - SCENE_MY_ROOM_M - }, - { - nf_str("23:", "マイルーム size L"), - &game_next_play, - SCENE_MY_ROOM_L - }, - { - nf_str("24:", "コンビニ"), - &game_next_play, - SCENE_CONVENI - }, - { - nf_str("25:", "スーパー"), - &game_next_play, - SCENE_SUPER - }, - { - nf_str("26:", "デパート1F"), - &game_next_play, - SCENE_DEPART - }, - { - nf_str("27:", "テストコース 5"), - &game_next_play, - SCENE_TEST5 - }, - { - nf_str("28:", "プレーヤー セレクト 2"), - &game_next_play, - SCENE_PLAYERSELECT_2 - }, - { - nf_str("29:", "プレーヤー セレクト 3"), - &game_next_play, - SCENE_PLAYERSELECT_3 - }, - { - nf_str("30:", "デパート2F"), - &game_next_play, - SCENE_DEPART_2 - }, - { - nf_str("31:", "イベント コクチ"), - &game_next_play, - SCENE_EVENT_ANNOUNCEMENT - }, - { - nf_str("32:", "カマクラ"), - &game_next_play, - SCENE_KAMAKURA - }, - { - nf_str("33:", "for field tool"), - &game_next_play, - SCENE_FIELD_TOOL - }, - { - nf_str("34:", "キャクマチ デモ"), - &game_next_play, - SCENE_TITLE_DEMO - }, - { - nf_str("35:", "プレーヤー セレクト 4"), - &game_next_play, - SCENE_PLAYERSELECT_SAVE - }, - { - nf_str("36:", "museum-エントランス"), - &game_next_play, - SCENE_MUSEUM_ENTRANCE - }, - { - nf_str("37:", "museum-カイガ"), - &game_next_play, - SCENE_MUSEUM_ROOM_PAINTING - }, - { - nf_str("38:", "museum-カセキ"), - &game_next_play, - SCENE_MUSEUM_ROOM_FOSSIL - }, - { - nf_str("39:", "museum-インセクト"), - &game_next_play, - SCENE_MUSEUM_ROOM_INSECT - }, - { - nf_str("40:", "museum-フィッシュ"), - &game_next_play, - SCENE_MUSEUM_ROOM_FISH - }, - { - nf_str("41:", "マイルーム size LL1"), - &game_next_play, - SCENE_MY_ROOM_LL1 - }, - { - nf_str("42:", "マイルーム size LL2"), - &game_next_play, - SCENE_MY_ROOM_LL2 - }, - { - nf_str("43:", "マイルーム チカ -> S"), - &game_next_play, - SCENE_MY_ROOM_BASEMENT_S - }, - { - nf_str("44:", "マイルーム チカ -> M"), - &game_next_play, - SCENE_MY_ROOM_BASEMENT_M - }, - { - nf_str("45:", "マイルーム チカ -> L"), - &game_next_play, - SCENE_MY_ROOM_BASEMENT_L - }, - { - nf_str("46:", "マイルーム チカ -> LL1"), - &game_next_play, - SCENE_MY_ROOM_BASEMENT_LL1 - }, - { - nf_str("47:", "シタテヤ"), - &game_next_play, - SCENE_NEEDLEWORK - }, - { - nf_str("48:", "シマノプレイヤノイエ"), - &game_next_play, - SCENE_COTTAGE_MY - }, - { - nf_str("49:", "シマノNPCノイエ"), - &game_next_play, - SCENE_COTTAGE_NPC - }, - { - nf_str("50:", "start demo 3"), - &game_next_play, - SCENE_START_DEMO3 - }, - { - nf_str("51:", "LIGHTHOUSE"), - &game_next_play, - SCENE_LIGHTHOUSE - }, - { - nf_str("52:", "In Tent"), - &game_next_play, - SCENE_TENT - } + { nf_str(" 1:", "フィールド コース1"), &game_next_play, SCENE_TEST1 }, + { nf_str(" 2:", "フィールド コース2"), &game_next_play, SCENE_TEST2 }, + { nf_str(" 3:", "フィールデ コース3"), &game_next_play, SCENE_TEST3 }, + { nf_str(" 4:", "オミズテスト コース"), &game_next_play, SCENE_WATER_TEST }, + { nf_str(" 5:", "アシアトテストコース"), &game_next_play, SCENE_FOOTPRINT_TEST }, + { nf_str(" 6:", "npc テストコース"), &game_next_play, SCENE_NPC_TEST }, + { nf_str(" 7:", "NPCアレンジルーム"), &game_next_play, SCENE_NPC_HOUSE }, + { nf_str(" 8:", "NPCランダムコース"), &game_next_play, SCENE_FG }, + { nf_str(" 9:", "FGツール フィールドヨウ"), &game_next_play, SCENE_RANDOM_NPC_TEST }, + { nf_str("10:", "オミセ"), &game_next_play, SCENE_SHOP0 }, + { nf_str("11:", "BGプレビュー カワナシ"), &game_next_play, SCENE_BG_TEST_NO_RIVER }, + { nf_str("12:", "BGプレビュー カワアリ"), &game_next_play, SCENE_BG_TEST_RIVER }, + { nf_str("13:", "ヤミブローカーノ オミセ"), &game_next_play, SCENE_BROKER_SHOP }, + { nf_str("14:", "FGツール ヘヤノナカヨウ"), &game_next_play, SCENE_FIELD_TOOL_INSIDE }, + { nf_str("15:", "ユウビンキョク"), &game_next_play, SCENE_POST_OFFICE }, + { nf_str("16:", "start demo 1"), &game_next_play, SCENE_START_DEMO }, + { nf_str("17:", "start demo 2"), &game_next_play, SCENE_START_DEMO2 }, + { nf_str("18:", "コウバン"), &game_next_play, SCENE_POLICE_BOX }, + { nf_str("19:", "ホロバシャ"), &game_next_play, SCENE_BUGGY }, + { nf_str("20:", "プレーヤー セレクト"), &game_next_play, SCENE_PLAYERSELECT }, + { nf_str("21:", "マイルーム size S"), &game_next_play, SCENE_MY_ROOM_S }, + { nf_str("22:", "マイルーム size M"), &game_next_play, SCENE_MY_ROOM_M }, + { nf_str("23:", "マイルーム size L"), &game_next_play, SCENE_MY_ROOM_L }, + { nf_str("24:", "コンビニ"), &game_next_play, SCENE_CONVENI }, + { nf_str("25:", "スーパー"), &game_next_play, SCENE_SUPER }, + { nf_str("26:", "デパート1F"), &game_next_play, SCENE_DEPART }, + { nf_str("27:", "テストコース 5"), &game_next_play, SCENE_TEST5 }, + { nf_str("28:", "プレーヤー セレクト 2"), &game_next_play, SCENE_PLAYERSELECT_2 }, + { nf_str("29:", "プレーヤー セレクト 3"), &game_next_play, SCENE_PLAYERSELECT_3 }, + { nf_str("30:", "デパート2F"), &game_next_play, SCENE_DEPART_2 }, + { nf_str("31:", "イベント コクチ"), &game_next_play, SCENE_EVENT_ANNOUNCEMENT }, + { nf_str("32:", "カマクラ"), &game_next_play, SCENE_KAMAKURA }, + { nf_str("33:", "for field tool"), &game_next_play, SCENE_FIELD_TOOL }, + { nf_str("34:", "キャクマチ デモ"), &game_next_play, SCENE_TITLE_DEMO }, + { nf_str("35:", "プレーヤー セレクト 4"), &game_next_play, SCENE_PLAYERSELECT_SAVE }, + { nf_str("36:", "museum-エントランス"), &game_next_play, SCENE_MUSEUM_ENTRANCE }, + { nf_str("37:", "museum-カイガ"), &game_next_play, SCENE_MUSEUM_ROOM_PAINTING }, + { nf_str("38:", "museum-カセキ"), &game_next_play, SCENE_MUSEUM_ROOM_FOSSIL }, + { nf_str("39:", "museum-インセクト"), &game_next_play, SCENE_MUSEUM_ROOM_INSECT }, + { nf_str("40:", "museum-フィッシュ"), &game_next_play, SCENE_MUSEUM_ROOM_FISH }, + { nf_str("41:", "マイルーム size LL1"), &game_next_play, SCENE_MY_ROOM_LL1 }, + { nf_str("42:", "マイルーム size LL2"), &game_next_play, SCENE_MY_ROOM_LL2 }, + { nf_str("43:", "マイルーム チカ -> S"), &game_next_play, SCENE_MY_ROOM_BASEMENT_S }, + { nf_str("44:", "マイルーム チカ -> M"), &game_next_play, SCENE_MY_ROOM_BASEMENT_M }, + { nf_str("45:", "マイルーム チカ -> L"), &game_next_play, SCENE_MY_ROOM_BASEMENT_L }, + { nf_str("46:", "マイルーム チカ -> LL1"), &game_next_play, SCENE_MY_ROOM_BASEMENT_LL1 }, + { nf_str("47:", "シタテヤ"), &game_next_play, SCENE_NEEDLEWORK }, + { nf_str("48:", "シマノプレイヤノイエ"), &game_next_play, SCENE_COTTAGE_MY }, + { nf_str("49:", "シマノNPCノイエ"), &game_next_play, SCENE_COTTAGE_NPC }, + { nf_str("50:", "start demo 3"), &game_next_play, SCENE_START_DEMO3 }, + { nf_str("51:", "LIGHTHOUSE"), &game_next_play, SCENE_LIGHTHOUSE }, + { nf_str("52:", "In Tent"), &game_next_play, SCENE_TENT }, }; static u8 data2fcode(u8 data) { - u8 fcode = CHAR_SPACE; + u8 fcode = CHAR_SPACE; - if (data != 0) { - fcode = data + 0x90; - } + if (data != 0) { + fcode = data + 0x90; + } - return fcode; + return fcode; } static u8 fcode2data(u8 fcode) { - u8 data = 0; - if (fcode != CHAR_SPACE) { - data = fcode - 0x90; - } + u8 data = 0; + if (fcode != CHAR_SPACE) { + data = fcode - 0x90; + } - return data; + return data; } static void select_pass(GAME_SELECT* select) { - lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); - namefunc_t* nf_p; - int field_scene = Common_Get(scene_from_title_demo); - int sec = rtc_time->sec; - int min_sec = rtc_time->min * mTM_SECONDS_IN_MINUTE; - int hour_sec = rtc_time->hour * mTM_SECONDS_IN_HOUR; + lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); + namefunc_t* nf_p; + int field_scene = Common_Get(scene_from_title_demo); + int sec = rtc_time->sec; + int min_sec = rtc_time->min * mTM_SECONDS_IN_MINUTE; + int hour_sec = rtc_time->hour * mTM_SECONDS_IN_HOUR; - Common_Set(time.now_sec, hour_sec + min_sec + sec); - nf_p = nf_tbl + field_scene; - if (nf_p->next_play_proc != NULL) { - (*nf_p->next_play_proc)((GAME*)select, nf_p->scene_no); - } + Common_Set(time.now_sec, hour_sec + min_sec + sec); + nf_p = nf_tbl + field_scene; + if (nf_p->next_play_proc != NULL) { + (*nf_p->next_play_proc)((GAME*)select, nf_p->scene_no); + } - Common_Set(scene_from_title_demo, -1); + Common_Set(scene_from_title_demo, -1); } static int select_start_proc(GAME_SELECT* select) { - lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); - int sec = rtc_time->sec; - int min_sec = rtc_time->min * mTM_SECONDS_IN_MINUTE; - int hour_sec = rtc_time->hour * mTM_SECONDS_IN_HOUR; + lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); + int sec = rtc_time->sec; + int min_sec = rtc_time->min * mTM_SECONDS_IN_MINUTE; + int hour_sec = rtc_time->hour * mTM_SECONDS_IN_HOUR; - Common_Set(time.now_sec, hour_sec + min_sec + sec); + Common_Set(time.now_sec, hour_sec + min_sec + sec); - { - namefunc_t* nf_p = nf_tbl + select->selected_course; - if (nf_p->next_play_proc != NULL) { - (*nf_p->next_play_proc)((GAME*)select, nf_p->scene_no); + { + namefunc_t* nf_p = nf_tbl + select->selected_course; + if (nf_p->next_play_proc != NULL) { + (*nf_p->next_play_proc)((GAME*)select, nf_p->scene_no); + } } - } - Common_Set(select_last_select_no, select->selected_course); - Common_Set(select_last_top_no, select->top_course); + Common_Set(select_last_select_no, select->selected_course); + Common_Set(select_last_top_no, select->top_course); - if (rtc_time->min == 0) { - Common_Set(time.time_signal, TRUE); - } - - { - int i; - - for (i = 0; i < PLAYER_NAME_LEN; i++) { - Common_Get(now_private)->player_ID.player_name[i] = data2fcode(select->name[i]); + if (rtc_time->min == 0) { + Common_Set(time.time_signal, TRUE); } - } - return TRUE; + { + int i; + + for (i = 0; i < PLAYER_NAME_LEN; i++) { + Common_Get(now_private)->player_ID.player_name[i] = data2fcode(select->name[i]); + } + } + + return TRUE; } static int select_check_start(GAME_SELECT* select) { - if (select->status == 0) { - if (chkTrigger(BUTTON_START) || chkTrigger(BUTTON_A)) { - return select_start_proc(select); + if (select->status == 0) { + if (chkTrigger(BUTTON_START) || chkTrigger(BUTTON_A)) { + return select_start_proc(select); + } + } else if (chkTrigger(BUTTON_START)) { + return select_start_proc(select); } - } - else if (chkTrigger(BUTTON_START)) { - return select_start_proc(select); - } - return FALSE; + return FALSE; } typedef int (*SELECT_CHECK_A_BUTTON_PROC)(GAME_SELECT*); static int select_check_A_button_rtc(GAME_SELECT* select) { - return FALSE; + return FALSE; } static int select_check_A_button_time(GAME_SELECT* select) { - return FALSE; + return FALSE; } static int select_check_A_button_step(GAME_SELECT* select) { - return FALSE; + return FALSE; } static int select_check_A_button_weather(GAME_SELECT* select) { - u8 save_weather; - int weather = Common_Get(weather); - weather++; - if (weather > mEnv_WEATHER_LEAVES || weather < mEnv_WEATHER_CLEAR) { - weather = mEnv_WEATHER_CLEAR; - } + u8 save_weather; + int weather = Common_Get(weather); + weather++; + if (weather > mEnv_WEATHER_LEAVES || weather < mEnv_WEATHER_CLEAR) { + weather = mEnv_WEATHER_CLEAR; + } - Common_Set(weather, weather); - Common_Set(weather_intensity, mEnv_WEATHER_INTENSITY_HEAVY); + Common_Set(weather, weather); + Common_Set(weather_intensity, mEnv_WEATHER_INTENSITY_HEAVY); - save_weather = mEnv_WEATHER_INTENSITY_HEAVY; - save_weather |= (u8)weather << 4; - Save_Set(weather, save_weather); + save_weather = mEnv_WEATHER_INTENSITY_HEAVY; + save_weather |= (u8)weather << 4; + Save_Set(weather, save_weather); - return FALSE; + return FALSE; } static int select_check_A_button_sex(GAME_SELECT* select) { - int sex = Common_Get(now_private)->gender; - sex++; - Common_Get(now_private)->gender = sex % mPr_SEX_NUM; + int sex = Common_Get(now_private)->gender; + sex++; + Common_Get(now_private)->gender = sex % mPr_SEX_NUM; - return FALSE; + return FALSE; } static int select_check_A_button_face_type(GAME_SELECT* select) { - int face_type = Common_Get(now_private)->face; - face_type++; - Common_Get(now_private)->face = face_type % mPr_FACE_TYPE_NUM; + int face_type = Common_Get(now_private)->face; + face_type++; + Common_Get(now_private)->face = face_type % mPr_FACE_TYPE_NUM; - return FALSE; + return FALSE; } static int select_check_A_button_swell(GAME_SELECT* select) { - int swell = Common_Get(player_bee_swell_flag); - Common_Set(player_bee_swell_flag, !swell); + int swell = Common_Get(player_bee_swell_flag); + Common_Set(player_bee_swell_flag, !swell); - return FALSE; + return FALSE; } static int select_check_A_button_sunburn(GAME_SELECT* select) { - lbRTC_ymd_c renew_time; - mPr_sunburn_c sunburn = Common_Get(now_private)->sunburn; - - mTM_set_renew_time(&renew_time, Common_GetPointer(time.rtc_time)); - sunburn.last_changed_date = renew_time; + lbRTC_ymd_c renew_time; + mPr_sunburn_c sunburn = Common_Get(now_private)->sunburn; - sunburn.rank++; - if (sunburn.rank >= mPr_SUNBURN_RANK_NUM) { - sunburn.rank = mPr_SUNBURN_RANK0; - } + mTM_set_renew_time(&renew_time, Common_GetPointer(time.rtc_time)); + sunburn.last_changed_date = renew_time; - sunburn.rankdown_days = 2; - Common_Get(now_private)->sunburn = sunburn; + sunburn.rank++; + if (sunburn.rank >= mPr_SUNBURN_RANK_NUM) { + sunburn.rank = mPr_SUNBURN_RANK0; + } - return FALSE; + sunburn.rankdown_days = 2; + Common_Get(now_private)->sunburn = sunburn; + + return FALSE; } static int select_check_A_button_decoy(GAME_SELECT* select) { - Common_Set(player_decoy_flag, !Common_Get(player_decoy_flag)); + Common_Set(player_decoy_flag, !Common_Get(player_decoy_flag)); - return FALSE; + return FALSE; } static int select_check_A_button_cloth(GAME_SELECT* select) { - return FALSE; + return FALSE; } static int select_check_A_button_event(GAME_SELECT* select) { - return FALSE; + return FALSE; } static int select_check_A_button(GAME_SELECT* select) { - static SELECT_CHECK_A_BUTTON_PROC process[SELECT_CHECK_A_BUTTON_NUM] = { - &select_check_A_button_rtc, - &select_check_A_button_time, - &select_check_A_button_step, - &select_check_A_button_weather, - &select_check_A_button_sex, - &select_check_A_button_face_type, - &select_check_A_button_swell, - &select_check_A_button_decoy, - &select_check_A_button_cloth, - &select_check_A_button_sunburn, - &select_check_A_button_event - }; + static SELECT_CHECK_A_BUTTON_PROC process[SELECT_CHECK_A_BUTTON_NUM] = { + &select_check_A_button_rtc, &select_check_A_button_time, &select_check_A_button_step, + &select_check_A_button_weather, &select_check_A_button_sex, &select_check_A_button_face_type, + &select_check_A_button_swell, &select_check_A_button_decoy, &select_check_A_button_cloth, + &select_check_A_button_sunburn, &select_check_A_button_event, + }; - if (chkTrigger(BUTTON_A)) { - return (*process[select->cursor_y])(select); - } - else { - return FALSE; - } + if (chkTrigger(BUTTON_A)) { + return (*process[select->cursor_y])(select); + } else { + return FALSE; + } } static int select_move_cursol(GAME_SELECT* select) { - if (chkTrigger(BUTTON_DLEFT)) { - select->status = 0; - return TRUE; - } - else if (chkTrigger(BUTTON_DUP)) { - if (select->cursor_y == 0) { - select->cursor_y = SELECT_CHECK_A_BUTTON_NUM - 1; + if (chkTrigger(BUTTON_DLEFT)) { + select->status = 0; + return TRUE; + } else if (chkTrigger(BUTTON_DUP)) { + if (select->cursor_y == 0) { + select->cursor_y = SELECT_CHECK_A_BUTTON_NUM - 1; + } else { + select->cursor_y--; + } + } else if (chkTrigger(BUTTON_DDOWN)) { + select->cursor_y = (select->cursor_y + 1) % SELECT_CHECK_A_BUTTON_NUM; } - else { - select->cursor_y--; - } - } - else if (chkTrigger(BUTTON_DDOWN)) { - select->cursor_y = (select->cursor_y + 1) % SELECT_CHECK_A_BUTTON_NUM; - } - return FALSE; + return FALSE; } static int select_course_step_sub(int course) { - if (course < 0) { - return course + SCENE_NUM; - } - else if (course >= SCENE_NUM) { - return course - SCENE_NUM; - } + if (course < 0) { + return course + SCENE_NUM; + } else if (course >= SCENE_NUM) { + return course - SCENE_NUM; + } - return course; + return course; } static int select_adjust_top_no(GAME_SELECT* select, int course, int adjust) { - int top = select->top_course; - int new_top = (top + SELECT_COURSE_NUM_VISIBLE) % SCENE_NUM; + int top = select->top_course; + int new_top = (select->top_course + SELECT_COURSE_NUM_VISIBLE) % SCENE_NUM; - if (top < new_top) { - if (course <= top || course >= new_top) { - top = select_course_step_sub(top + adjust); + if (top < new_top) { + if (course <= top || course >= new_top) { + top = select_course_step_sub(top + adjust); + } + } else if (course <= top && course >= new_top) { + top = select_course_step_sub(top + adjust); } - } - else if (course <= top && course >= new_top) { - top = select_course_step_sub(top + adjust); - } - select->top_course = top; - return top; + select->top_course = top; + return top; } static void select_course_step(GAME_SELECT* select, int step_add) { - int new_step = select->step + step_add; + int new_step = select->step + step_add; - if (ABS(new_step) >= 32) { - int course = select->selected_course; - sAdo_SysTrgStart(NA_SE_CURSOL); + if (ABS(new_step) >= 32) { + int course = select->selected_course; + sAdo_SysTrgStart(NA_SE_CURSOL); - if (new_step > 0) { - new_step = 0; - course = select_course_step_sub(course + 1); - select_adjust_top_no(select, course, 1); - } - else { - new_step = 0; - course = select_course_step_sub(course - 1); - select_adjust_top_no(select, course, -1); + if (new_step > 0) { + new_step = 0; + course = select_course_step_sub(course + 1); + select_adjust_top_no(select, course, 1); + } else { + new_step = 0; + course = select_course_step_sub(course - 1); + select_adjust_top_no(select, course, -1); + } + + select->step_add = 6; + select->selected_course = course; } - select->step_add = 6; - select->selected_course = course; - } - - select->step = new_step; + select->step = new_step; } static void select_course(GAME_SELECT* select) { - int step_add; - int joystick_y; - if (chkTrigger(BUTTON_DUP)) { - if (select->step > 0) { - select->step = 0; - } - - select_course_step(select, -32); - select->step_add = 1; - } - else if (chkButton(BUTTON_DUP)) { - select_course_step(select, -select->step_add); - } - else if (chkTrigger(BUTTON_DDOWN)) { - if (select->step < 0) { - select->step = 0; - } - - select_course_step(select, 32); - select->step_add = 1; - } - else if (chkButton(BUTTON_DDOWN)) { - select_course_step(select, select->step_add); - } - else { - joystick_y = -getJoystick_Y(); - step_add = select->step_add; - - if (step_add == 0) { - if (joystick_y < 0) { + int step_add; + int joystick_y; + if (chkTrigger(BUTTON_DUP)) { if (select->step > 0) { - select->step = 0; + select->step = 0; } select_course_step(select, -32); select->step_add = 1; - } - else if (joystick_y > 0) { + } else if (chkButton(BUTTON_DUP)) { + select_course_step(select, -select->step_add); + } else if (chkTrigger(BUTTON_DDOWN)) { if (select->step < 0) { - select->step = 0; + select->step = 0; } select_course_step(select, 32); select->step_add = 1; - } + } else if (chkButton(BUTTON_DDOWN)) { + select_course_step(select, select->step_add); + } else { + joystick_y = -getJoystick_Y(); + step_add = select->step_add; + + if (step_add == 0) { + if (joystick_y < 0) { + if (select->step > 0) { + select->step = 0; + } + + select_course_step(select, -32); + select->step_add = 1; + } else if (joystick_y > 0) { + if (select->step < 0) { + select->step = 0; + } + + select_course_step(select, 32); + select->step_add = 1; + } + } else { + if (joystick_y == 0) { + select->step_add = 0; + } else if (joystick_y < 0) { + select_course_step(select, -step_add * 2); + } else if (joystick_y > 0) { + select_course_step(select, step_add * 2); + } + } } - else { - if (joystick_y == 0) { - select->step_add = 0; - } - else if (joystick_y < 0) { - select_course_step(select, -step_add * 2); - } - else if (joystick_y > 0) { - select_course_step(select, step_add * 2); - } - } - } } typedef void (*SELECT_MOVE_PROC)(GAME_SELECT*); static void select_move_main(GAME_SELECT* select) { - if (select_check_start(select) != TRUE) { - if (chkTrigger(BUTTON_DRIGHT)) { - select->status = 1; + if (select_check_start(select) != TRUE) { + if (chkTrigger(BUTTON_DRIGHT)) { + select->status = 1; + } else { + select_course(select); + } } - else { - select_course(select); - } - } } static void select_move_setup(GAME_SELECT* select) { - if (select_check_start(select) != TRUE && select_move_cursol(select) != TRUE) { - if (select_check_A_button(select) == TRUE) { - return; /* stubbed code */ + if (select_check_start(select) != TRUE && select_move_cursol(select) != TRUE) { + if (select_check_A_button(select) == TRUE) { + return; /* stubbed code */ + } } - } } typedef void (*SELECT_MOVE_TIME_PROC)(int); static void select_move_time_year_set(int adjust) { - int year = Common_Get(time.rtc_time.year); - year += adjust; + int year = Common_Get(time.rtc_time.year); + year += adjust; - if (year > lbRTC_YEAR_MAX) { - year -= ((lbRTC_YEAR_MAX - lbRTC_YEAR_MIN) + 1); - } - else if (year < lbRTC_YEAR_MIN) { - year = lbRTC_YEAR_MAX - ((lbRTC_YEAR_MIN - 1) - year); - } + if (year > lbRTC_YEAR_MAX) { + year -= ((lbRTC_YEAR_MAX - lbRTC_YEAR_MIN) + 1); + } else if (year < lbRTC_YEAR_MIN) { + year = lbRTC_YEAR_MAX - ((lbRTC_YEAR_MIN - 1) - year); + } - Common_Set(time.rtc_time.year, year); + Common_Set(time.rtc_time.year, year); } static void select_move_time_month_set(int adjust) { - static int season_table[lbRTC_MONTHS_MAX] = { - mTM_SEASON_WINTER, mTM_SEASON_WINTER, mTM_SEASON_SPRING, mTM_SEASON_SPRING, - mTM_SEASON_SPRING, mTM_SEASON_SUMMER, mTM_SEASON_SUMMER, mTM_SEASON_SUMMER, - mTM_SEASON_AUTUMN, mTM_SEASON_AUTUMN, mTM_SEASON_AUTUMN, mTM_SEASON_WINTER - }; + static int season_table[lbRTC_MONTHS_MAX] = { + mTM_SEASON_WINTER, mTM_SEASON_WINTER, mTM_SEASON_SPRING, mTM_SEASON_SPRING, + mTM_SEASON_SPRING, mTM_SEASON_SUMMER, mTM_SEASON_SUMMER, mTM_SEASON_SUMMER, + mTM_SEASON_AUTUMN, mTM_SEASON_AUTUMN, mTM_SEASON_AUTUMN, mTM_SEASON_WINTER, + }; - int month = Common_Get(time.rtc_time.month) - 1; - u8 day; - month = (month + adjust) % lbRTC_MONTHS_MAX; - Common_Set(time.rtc_time.month, month + 1); + int month = Common_Get(time.rtc_time.month) - 1; + u8 day; + month = (month + adjust) % lbRTC_MONTHS_MAX; + Common_Set(time.rtc_time.month, month + 1); - day = lbRTC_GetDaysByMonth(Common_Get(time.rtc_time.year), month + 1); - if (Common_Get(time.rtc_time.day) > day) { - Common_Set(time.rtc_time.day, day); - } + day = lbRTC_GetDaysByMonth(Common_Get(time.rtc_time.year), month + 1); + if (Common_Get(time.rtc_time.day) > day) { + Common_Set(time.rtc_time.day, day); + } - Common_Set(time.season, season_table[month]); + Common_Set(time.season, season_table[month]); } static void select_move_time_day_set(int adjust) { - int max_day = lbRTC_GetDaysByMonth(Common_Get(time.rtc_time.year), Common_Get(time.rtc_time.month)); - int day = (Common_Get(time.rtc_time.day) + adjust) % (max_day + 1); + int max_day = lbRTC_GetDaysByMonth(Common_Get(time.rtc_time.year), Common_Get(time.rtc_time.month)); + int day = (Common_Get(time.rtc_time.day) + adjust) % (max_day + 1); - if (day == 0) { - if (adjust > 0) { - day = 1; + if (day == 0) { + if (adjust > 0) { + day = 1; + } else { + day = max_day; + } } - else { - day = max_day; - } - } - Common_Set(time.rtc_time.day, day); + Common_Set(time.rtc_time.day, day); } static void select_move_time_hour_set(int adjust) { - int hour = Common_Get(time.rtc_time.hour); - if (hour == 0 && adjust < 0) { - hour = lbRTC_HOURS_PER_DAY - 1; - } - else { - hour = (hour + adjust) % lbRTC_HOURS_PER_DAY; - } + int hour = Common_Get(time.rtc_time.hour); + if (hour == 0 && adjust < 0) { + hour = lbRTC_HOURS_PER_DAY - 1; + } else { + hour = (hour + adjust) % lbRTC_HOURS_PER_DAY; + } - Common_Set(time.rtc_time.hour, hour); + Common_Set(time.rtc_time.hour, hour); } static void select_move_time_min_set(int adjust) { - int min = Common_Get(time.rtc_time.min); - - if (min == 0 && adjust < 0) { - min = lbRTC_MINUTES_PER_HOUR - 1; - } - else { - min = (min + adjust) % lbRTC_MINUTES_PER_HOUR; - } + int min = Common_Get(time.rtc_time.min); - Common_Set(time.rtc_time.min, min); + if (min == 0 && adjust < 0) { + min = lbRTC_MINUTES_PER_HOUR - 1; + } else { + min = (min + adjust) % lbRTC_MINUTES_PER_HOUR; + } + + Common_Set(time.rtc_time.min, min); } static void select_move_time_week_set(int adjust) { - static lbRTC_time_c base = { - 0, 0, 0, // 00:00:00 - 1, lbRTC_SATURDAY, lbRTC_JANUARY, // Sunday Jan 1st - 2000 - }; + static lbRTC_time_c base = { + 0, + 0, + 0, // 00:00:00 + 1, + lbRTC_SATURDAY, + lbRTC_JANUARY, // Sunday Jan 1st + 2000, + }; - if (adjust != 0) { - u32 interval = lbRTC_IntervalTime(Common_GetPointer(time.rtc_time), &base); - /* minutes -> days */ - interval = interval / (lbRTC_HOURS_PER_DAY * lbRTC_MINUTES_PER_HOUR) + (lbRTC_WEEK - 1); - Common_Set(time.rtc_time.weekday, interval % lbRTC_WEEK); - } + if (adjust != 0) { + u32 interval = lbRTC_IntervalTime(Common_GetPointer(time.rtc_time), &base); + /* minutes -> days */ + interval = interval / (lbRTC_HOURS_PER_DAY * lbRTC_MINUTES_PER_HOUR) + (lbRTC_WEEK - 1); + Common_Set(time.rtc_time.weekday, interval % lbRTC_WEEK); + } } static void select_move_time_set(GAME_SELECT* select) { - if (chkTrigger(BUTTON_A) || chkTrigger(BUTTON_START)) { - select->status = 1; - if (Common_Get(time.rtc_enabled) == TRUE) { - lbRTC_SetTime(Common_GetPointer(time.rtc_time)); - } - } - else if (chkTrigger(BUTTON_DLEFT)) { - if (select->cursor_x == 0) { - select->cursor_x = 4; - } - else { - select->cursor_x--; - } - } - else if (chkTrigger(BUTTON_DRIGHT)) { - select->cursor_x = (select->cursor_x + 1) % 5; - } - else { - int adjust = 0; - - if (chkButton(BUTTON_DDOWN)) { - if (chkTrigger(BUTTON_DDOWN)) { - adjust = -1; - select->button_step = -16; - } - - select->button_step++; - if (select->button_step == 6) { - adjust = -1; - select->button_step = 0; - } - } - - if (chkButton(BUTTON_DUP)) { - if (chkTrigger(BUTTON_DUP)) { - adjust = 1; - select->button_step = 16; - } - - select->button_step--; - if (select->button_step == -6) { - adjust = 1; - select->button_step = 0; - } - } - - if (chkButton(BUTTON_B)) { - adjust *= 10; - } - - { - static SELECT_MOVE_TIME_PROC process[5] = { - &select_move_time_year_set, - &select_move_time_month_set, - &select_move_time_day_set, - &select_move_time_hour_set, - &select_move_time_min_set - }; - - int i; - - for (i = 0; i < 5; i++) { - if (i == select->cursor_x) { - (*process[i])(adjust); - select_move_time_week_set(adjust); + if (chkTrigger(BUTTON_A) || chkTrigger(BUTTON_START)) { + select->status = 1; + if (Common_Get(time.rtc_enabled) == TRUE) { + lbRTC_SetTime(Common_GetPointer(time.rtc_time)); } - } + } else if (chkTrigger(BUTTON_DLEFT)) { + if (select->cursor_x == 0) { + select->cursor_x = 4; + } else { + select->cursor_x--; + } + } else if (chkTrigger(BUTTON_DRIGHT)) { + select->cursor_x = (select->cursor_x + 1) % 5; + } else { + int adjust = 0; - if (adjust != 0 && Common_Get(time.rtc_enabled) == TRUE) { - lbRTC_SetTime(Common_GetPointer(time.rtc_time)); - } + if (chkButton(BUTTON_DDOWN)) { + if (chkTrigger(BUTTON_DDOWN)) { + adjust = -1; + select->button_step = -16; + } + + select->button_step++; + if (select->button_step == 6) { + adjust = -1; + select->button_step = 0; + } + } + + if (chkButton(BUTTON_DUP)) { + if (chkTrigger(BUTTON_DUP)) { + adjust = 1; + select->button_step = 16; + } + + select->button_step--; + if (select->button_step == -6) { + adjust = 1; + select->button_step = 0; + } + } + + if (chkButton(BUTTON_B)) { + adjust *= 10; + } + + { + static SELECT_MOVE_TIME_PROC process[5] = { + &select_move_time_year_set, &select_move_time_month_set, &select_move_time_day_set, + &select_move_time_hour_set, &select_move_time_min_set, + }; + + int i; + + for (i = 0; i < 5; i++) { + if (i == select->cursor_x) { + (*process[i])(adjust); + select_move_time_week_set(adjust); + } + } + + if (adjust != 0 && Common_Get(time.rtc_enabled) == TRUE) { + lbRTC_SetTime(Common_GetPointer(time.rtc_time)); + } + } } - } } static void select_move_cloth_sel(GAME_SELECT* select) { - if (chkTrigger(BUTTON_A) || chkTrigger(BUTTON_START)) { - select->status = 1; - } - else { - int cloth = Common_Get(now_private)->cloth.item - ITM_CLOTH001; // shouldn't this be CLOTH000? - int adjust = (chkButton(BUTTON_B)) ? 10 : 1; + if (chkTrigger(BUTTON_A) || chkTrigger(BUTTON_START)) { + select->status = 1; + } else { + int cloth = Common_Get(now_private)->cloth.item - ITM_CLOTH001; // shouldn't this be CLOTH000? + int adjust = (chkButton(BUTTON_B)) ? 10 : 1; - if (chkButton(BUTTON_DDOWN)) { - if (chkTrigger(BUTTON_DDOWN)) { - cloth += adjust; - select->button_step = -16; - } + if (chkButton(BUTTON_DDOWN)) { + if (chkTrigger(BUTTON_DDOWN)) { + cloth += adjust; + select->button_step = -16; + } - select->button_step++; - if (select->button_step == 6) { - cloth += adjust; - select->button_step = 0; - } + select->button_step++; + if (select->button_step == 6) { + cloth += adjust; + select->button_step = 0; + } + } + + if (chkButton(BUTTON_DUP)) { + if (chkTrigger(BUTTON_DUP)) { + cloth -= adjust; + select->button_step = 16; + } + + select->button_step--; + if (select->button_step == -6) { + cloth -= adjust; + select->button_step = 0; + } + } + + while (cloth < 0) { + cloth += CLOTH_NUM; + } + + while (cloth > CLOTH_NUM - 1) { + cloth -= CLOTH_NUM; + } + + Common_Get(now_private)->cloth.item = ITM_CLOTH001 + cloth; } - - if (chkButton(BUTTON_DUP)) { - if (chkTrigger(BUTTON_DUP)) { - cloth -= adjust; - select->button_step = 16; - } - - select->button_step--; - if (select->button_step == -6) { - cloth -= adjust; - select->button_step = 0; - } - } - - while (cloth < 0) { - cloth += CLOTH_NUM; - } - - while (cloth > CLOTH_NUM - 1) { - cloth -= CLOTH_NUM; - } - - Common_Get(now_private)->cloth.item = ITM_CLOTH001 + cloth; - } } static void select_move(GAME_SELECT* select) { - static SELECT_MOVE_PROC process[SELECT_STATUS_NUM] = { - &select_move_main, - &select_move_setup, - &select_move_time_set, - &select_move_cloth_sel - }; + static SELECT_MOVE_PROC process[SELECT_STATUS_NUM] = { + &select_move_main, + &select_move_setup, + &select_move_time_set, + &select_move_cloth_sel, + }; - if (Common_Get(scene_from_title_demo) >= 0) { - select_pass(select); - } - else { - (*process[select->status])(select); - } + if (Common_Get(scene_from_title_demo) >= 0) { + select_pass(select); + } else { + (*process[select->status])(select); + } } typedef void (*SELECT_PRINT_PROC)(gfxprint_t*, GAME_SELECT*); static void select_print_wait(gfxprint_t* gfxprint) { - static const char* msgs[12] = { - GFXPRINT_HIRAGANA_MODE_CHAR "シバラクオマチクダサイ", /* (しばらくお待ち下さい) "Please wait for a bit" */ - GFXPRINT_HIRAGANA_MODE_CHAR "チョット マッテネ", /* (ちょっと 待ってね) "Wait a minute" */ - GFXPRINT_KATAKANA_MODE_CHAR "ウェイト ア モーメント", /* "Wait a moment" */ - GFXPRINT_KATAKANA_MODE_CHAR "ロード" GFXPRINT_HIRAGANA_MODE_CHAR "チュウ", /* (ロード中) "Loading" */ - GFXPRINT_HIRAGANA_MODE_CHAR "ナウ ワーキング", /* "Now working" */ - GFXPRINT_HIRAGANA_MODE_CHAR "イマ ツクッテマス", /* (今つくってます) "Now making" */ - GFXPRINT_HIRAGANA_MODE_CHAR "コショウジャナイヨ", /* (故障じゃないよ) "It's not faulty" */ - GFXPRINT_KATAKANA_MODE_CHAR "コーヒー ブレイク", /* "coffee break" */ - GFXPRINT_KATAKANA_MODE_CHAR "Bメンヲセットシテクダサイ", /* (Bメンヲ セットしてください) "Please set the B menu" */ - GFXPRINT_HIRAGANA_MODE_CHAR "ジット" GFXPRINT_KATAKANA_MODE_CHAR "ガマン" GFXPRINT_HIRAGANA_MODE_CHAR "ノ" GFXPRINT_KATAKANA_MODE_CHAR "コ" GFXPRINT_HIRAGANA_MODE_CHAR "デアッタ", /* (ジっと我慢のこであった) "I am patient" */ - GFXPRINT_HIRAGANA_MODE_CHAR "イマシバラクオマチクダサイ", /* (今しばらくお待ちください) "Please wait a moment now" */ - GFXPRINT_HIRAGANA_MODE_CHAR "アワテナイアワテナイ。ヒトヤスミヒトヤスミ。" /* (あわてないあわてない。 ひとやすみひとやすみ。) "Don't rush, don't rush. Take a break, take a break." */ - }; + static const char* msgs[12] = { + GFXPRINT_HIRAGANA_MODE_CHAR "シバラクオマチクダサイ", /* (しばらくお待ち下さい) "Please wait for a bit" */ + GFXPRINT_HIRAGANA_MODE_CHAR "チョット マッテネ", /* (ちょっと 待ってね) "Wait a minute" */ + GFXPRINT_KATAKANA_MODE_CHAR "ウェイト ア モーメント", /* "Wait a moment" */ + GFXPRINT_KATAKANA_MODE_CHAR "ロード" GFXPRINT_HIRAGANA_MODE_CHAR "チュウ", /* (ロード中) "Loading" */ + GFXPRINT_HIRAGANA_MODE_CHAR "ナウ ワーキング", /* "Now working" */ + GFXPRINT_HIRAGANA_MODE_CHAR "イマ ツクッテマス", /* (今つくってます) "Now making" */ + GFXPRINT_HIRAGANA_MODE_CHAR "コショウジャナイヨ", /* (故障じゃないよ) "It's not faulty" */ + GFXPRINT_KATAKANA_MODE_CHAR "コーヒー ブレイク", /* "coffee break" */ + GFXPRINT_KATAKANA_MODE_CHAR "Bメンヲセットシテクダサイ", /* (Bメンヲ セットしてください) "Please set the B menu" */ + GFXPRINT_HIRAGANA_MODE_CHAR "ジット" GFXPRINT_KATAKANA_MODE_CHAR "ガマン" GFXPRINT_HIRAGANA_MODE_CHAR + "ノ" GFXPRINT_KATAKANA_MODE_CHAR "コ" GFXPRINT_HIRAGANA_MODE_CHAR + "デアッタ", /* (ジっと我慢のこであった) "I am patient" */ + GFXPRINT_HIRAGANA_MODE_CHAR "イマシバラクオマチクダサイ", /* (今しばらくお待ちください) "Please wait a moment now" */ + GFXPRINT_HIRAGANA_MODE_CHAR "アワテナイアワテナイ。ヒトヤスミヒトヤスミ。", /* (あわてないあわてない。 ひとやすみひとやすみ。) "Don't + rush, don't rush. Take a break, take a break." */ + }; - int msg_no; + int msg_no; - gfxprint_locate8x8(gfxprint, 10, 15); - gfxprint_color(gfxprint, 255, 255, 255, 255); + gfxprint_locate8x8(gfxprint, 10, 15); + gfxprint_color(gfxprint, 255, 255, 255, 255); - msg_no = fqrand() * 12.0f; - gfxprint_printf(gfxprint, "%s", msgs[msg_no]); + msg_no = fqrand() * 12.0f; + gfxprint_printf(gfxprint, "%s", msgs[msg_no]); } static void select_print_course_name(GAME_SELECT* select, gfxprint_t* gfxprint) { - const char* name; - int i; + const char* name; + int i; - gfxprint_color(gfxprint, 255, 155, 150, 255); - gfxprint_locate8x8(gfxprint, 12, 2); - gfxprint_printf(gfxprint, "FOREST MAP SELECT"); + gfxprint_color(gfxprint, 255, 155, 150, 255); + gfxprint_locate8x8(gfxprint, 12, 2); + gfxprint_printf(gfxprint, "FOREST MAP SELECT"); - - gfxprint_color(gfxprint, 255, 255, 255, 255); - for (i = 0; i < 15; i++) { - int course; + gfxprint_color(gfxprint, 255, 255, 255, 255); + for (i = 0; i < 15; i++) { + int course; - gfxprint_locate8x8(gfxprint, 5, i + 4); - course = (select->top_course + i + SCENE_NUM) % SCENE_NUM; - if (course == select->selected_course) { - if (select->status != 0) { - gfxprint_color(gfxprint, 255, 120, 120, 255); - - } - else { - gfxprint_color(gfxprint, 255, 20, 20, 255); - } + gfxprint_locate8x8(gfxprint, 5, i + 4); + course = (select->top_course + i + SCENE_NUM) % SCENE_NUM; + if (course == select->selected_course) { + if (select->status != 0) { + gfxprint_color(gfxprint, 255, 120, 120, 255); + + } else { + gfxprint_color(gfxprint, 255, 20, 20, 255); + } + } else { + gfxprint_color(gfxprint, 200, 200, 55, 255); + } + + name = nf_tbl[course].name; + if (name == NULL) { + name = "**Null**"; + } + + gfxprint_printf(gfxprint, "%s", name); } - else { - gfxprint_color(gfxprint, 200, 200, 55, 255); - } - - name = nf_tbl[course].name; - if (name == NULL) { - name = "**Null**"; - } - - gfxprint_printf(gfxprint, "%s", name); - } } static void select_print_rtc(gfxprint_t* gfxprint, GAME_SELECT* select) { - gfxprint_locate8x8(gfxprint, 23, 6); - gfxprint_printf(gfxprint, "RTC Z:USE"); + gfxprint_locate8x8(gfxprint, 23, 6); + gfxprint_printf(gfxprint, "RTC Z:USE"); } static void select_print_time_sub(gfxprint_t* gfxprint, GAME_SELECT* select, lbRTC_time_c* time) { - const char* weekday_name; + const char* weekday_name; - gfxprint_locate8x8(gfxprint, 23, 7); - gfxprint_printf(gfxprint, "%04d/%02d/%02d", time->year, time->month, time->day); + gfxprint_locate8x8(gfxprint, 23, 7); + gfxprint_printf(gfxprint, "%04d/%02d/%02d", time->year, time->month, time->day); - gfxprint_locate8x8(gfxprint, 33, 7); - switch(time->weekday) { - case lbRTC_SUNDAY: - weekday_name = "SUN"; - break; + gfxprint_locate8x8(gfxprint, 33, 7); + switch (time->weekday) { + case lbRTC_SUNDAY: + weekday_name = "SUN"; + break; - case lbRTC_MONDAY: - weekday_name = "MON"; - break; + case lbRTC_MONDAY: + weekday_name = "MON"; + break; - case lbRTC_TUESDAY: - weekday_name = "TUE"; - break; + case lbRTC_TUESDAY: + weekday_name = "TUE"; + break; - case lbRTC_WEDNESDAY: - weekday_name = "WED"; - break; + case lbRTC_WEDNESDAY: + weekday_name = "WED"; + break; - case lbRTC_THURSDAY: - weekday_name = "THU"; - break; + case lbRTC_THURSDAY: + weekday_name = "THU"; + break; - case lbRTC_FRIDAY: - weekday_name = "FRI"; - break; + case lbRTC_FRIDAY: + weekday_name = "FRI"; + break; - case lbRTC_SATURDAY: - weekday_name = "SAT"; - break; + case lbRTC_SATURDAY: + weekday_name = "SAT"; + break; - default: - weekday_name = "---"; - break; - } - - gfxprint_printf(gfxprint, "<%s>", weekday_name); - - gfxprint_locate8x8(gfxprint, 28, 8); - gfxprint_printf(gfxprint, "%02d:%02d", time->hour, time->min); - - if (select->status == SELECT_STATUS_TIME_SET) { - gfxprint_color(gfxprint, 255, 180, 180, 255); - - switch (select->cursor_x) { - case 0: - { - gfxprint_locate8x8(gfxprint, 23, 7); - gfxprint_printf(gfxprint, "%04d", time->year); - break; - } - - case 1: - { - gfxprint_locate8x8(gfxprint, 28, 7); - gfxprint_printf(gfxprint, "%02d", time->month); - break; - } - - case 2: - { - gfxprint_locate8x8(gfxprint, 31, 7); - gfxprint_printf(gfxprint, "%02d", time->day); - break; - } - - case 3: - { - gfxprint_locate8x8(gfxprint, 28, 8); - gfxprint_printf(gfxprint, "%02d", time->hour); - break; - } - - case 4: - { - gfxprint_locate8x8(gfxprint, 31, 8); - gfxprint_printf(gfxprint, "%02d", time->min); - break; - } + default: + weekday_name = "---"; + break; + } + + gfxprint_printf(gfxprint, "<%s>", weekday_name); + + gfxprint_locate8x8(gfxprint, 28, 8); + gfxprint_printf(gfxprint, "%02d:%02d", time->hour, time->min); + + if (select->status == SELECT_STATUS_TIME_SET) { + gfxprint_color(gfxprint, 255, 180, 180, 255); + + switch (select->cursor_x) { + case 0: { + gfxprint_locate8x8(gfxprint, 23, 7); + gfxprint_printf(gfxprint, "%04d", time->year); + break; + } + + case 1: { + gfxprint_locate8x8(gfxprint, 28, 7); + gfxprint_printf(gfxprint, "%02d", time->month); + break; + } + + case 2: { + gfxprint_locate8x8(gfxprint, 31, 7); + gfxprint_printf(gfxprint, "%02d", time->day); + break; + } + + case 3: { + gfxprint_locate8x8(gfxprint, 28, 8); + gfxprint_printf(gfxprint, "%02d", time->hour); + break; + } + + case 4: { + gfxprint_locate8x8(gfxprint, 31, 8); + gfxprint_printf(gfxprint, "%02d", time->min); + break; + } + } } - } } static void select_print_time(gfxprint_t* gfxprint, GAME_SELECT* select) { - lbRTC_time_c time; - - lbRTC_GetTime(&time); - select_print_time_sub(gfxprint, select, &time); + lbRTC_time_c time; + + lbRTC_GetTime(&time); + select_print_time_sub(gfxprint, select, &time); } static void select_print_step_sub2(gfxprint_t* gfxprint) { - gfxprint_locate8x8(gfxprint, 23, 9); - gfxprint_printf(gfxprint, GFXPRINT_KATAKANA_MODE_CHAR "ステップ :**m**s"); + gfxprint_locate8x8(gfxprint, 23, 9); + gfxprint_printf(gfxprint, GFXPRINT_KATAKANA_MODE_CHAR "ステップ :**m**s"); } static void select_print_step(gfxprint_t* gfxprint, GAME_SELECT* select) { - select_print_step_sub2(gfxprint); + select_print_step_sub2(gfxprint); } static void select_print_weather(gfxprint_t* gfxprint, GAME_SELECT* select) { - static const char* Weather_type[mEnv_WEATHER_NUM] = { - GFXPRINT_HIRAGANA_MODE_CHAR "ハレ", // 晴れ (clear/fine) - GFXPRINT_HIRAGANA_MODE_CHAR "アメ", // 雨 (rain) - GFXPRINT_HIRAGANA_MODE_CHAR "ユキ", // 雪 (snow) - GFXPRINT_HIRAGANA_MODE_CHAR "サクラ", // 桜 (cherry blossoms) - GFXPRINT_HIRAGANA_MODE_CHAR "ランダム" // "random" (should be leaves seen in K.K. Slider demo) - }; + static const char* Weather_type[mEnv_WEATHER_NUM] = { + GFXPRINT_HIRAGANA_MODE_CHAR "ハレ", // 晴れ (clear/fine) + GFXPRINT_HIRAGANA_MODE_CHAR "アメ", // 雨 (rain) + GFXPRINT_HIRAGANA_MODE_CHAR "ユキ", // 雪 (snow) + GFXPRINT_HIRAGANA_MODE_CHAR "サクラ", // 桜 (cherry blossoms) + GFXPRINT_HIRAGANA_MODE_CHAR "ランダム", // "random" (should be leaves seen in K.K. Slider demo) + }; - gfxprint_locate8x8(gfxprint, 23, 10); - gfxprint_printf(gfxprint, GFXPRINT_HIRAGANA_MODE_CHAR "テンキ :%s", Weather_type[Common_Get(weather)]); + gfxprint_locate8x8(gfxprint, 23, 10); + gfxprint_printf(gfxprint, GFXPRINT_HIRAGANA_MODE_CHAR "テンキ :%s", Weather_type[Common_Get(weather)]); } static void select_print_sex(gfxprint_t* gfxprint, GAME_SELECT* select) { - static const char* Distinction[mPr_SEX_NUM] = { - GFXPRINT_HIRAGANA_MODE_CHAR "オトコノコ", // 男の子 (boy) - GFXPRINT_HIRAGANA_MODE_CHAR "オンナノコ" // 女の子 (girl) - }; + static const char* Distinction[mPr_SEX_NUM] = { + GFXPRINT_HIRAGANA_MODE_CHAR "オトコノコ", // 男の子 (boy) + GFXPRINT_HIRAGANA_MODE_CHAR "オンナノコ" // 女の子 (girl) + }; - gfxprint_locate8x8(gfxprint, 23, 11); - gfxprint_printf(gfxprint, "セイベツ :%s", Distinction[Common_Get(now_private)->gender]); + gfxprint_locate8x8(gfxprint, 23, 11); + gfxprint_printf(gfxprint, "セイベツ :%s", Distinction[Common_Get(now_private)->gender]); } static void select_print_cloth(gfxprint_t* gfxprint, GAME_SELECT* select) { - gfxprint_locate8x8(gfxprint, 23, 15); - if (select->status == SELECT_STATUS_CLOTH_SEL) { - gfxprint_color(gfxprint, 255, 180, 180, 255); - } + gfxprint_locate8x8(gfxprint, 23, 15); + if (select->status == SELECT_STATUS_CLOTH_SEL) { + gfxprint_color(gfxprint, 255, 180, 180, 255); + } - gfxprint_printf(gfxprint, "フク :%03d", Common_Get(now_private)->cloth.item - ITM_CLOTH_START); + gfxprint_printf(gfxprint, "フク :%03d", Common_Get(now_private)->cloth.item - ITM_CLOTH_START); } static void select_print_swell(gfxprint_t* gfxprint, GAME_SELECT* select) { - int swell = Common_Get(player_bee_swell_flag); - gfxprint_locate8x8(gfxprint, 23, 13); + int swell = Common_Get(player_bee_swell_flag); + gfxprint_locate8x8(gfxprint, 23, 13); - if (swell == FALSE) { - gfxprint_printf(gfxprint, "ムシササレ :イタクナイ"); // 虫刺され: 痛くない (sting: painless) - } - else { - gfxprint_printf(gfxprint, "ムシササレ :イタソウ"); // 虫刺され: 痛そう (sting: painful) - } + if (swell == FALSE) { + gfxprint_printf(gfxprint, "ムシササレ :イタクナイ"); // 虫刺され: 痛くない (sting: painless) + } else { + gfxprint_printf(gfxprint, "ムシササレ :イタソウ"); // 虫刺され: 痛そう (sting: painful) + } } static void select_print_decoy(gfxprint_t* gfxprint, GAME_SELECT* select) { - int decoy = Common_Get(player_decoy_flag); - gfxprint_locate8x8(gfxprint, 23, 14); + int decoy = Common_Get(player_decoy_flag); + gfxprint_locate8x8(gfxprint, 23, 14); - if (decoy == FALSE) { - gfxprint_printf(gfxprint, "データ :モノホン"); // (data: genuine) - } - else { - gfxprint_printf(gfxprint, "データ :カゲムシャ"); // (data: double) [double meaning body double/puppet master] - } + if (decoy == FALSE) { + gfxprint_printf(gfxprint, "データ :モノホン"); // (data: genuine) + } else { + gfxprint_printf(gfxprint, "データ :カゲムシャ"); // (data: double) [double meaning body double/puppet master] + } } static void select_print_face_type(gfxprint_t* gfxprint, GAME_SELECT* select) { - static const char* Distinction[mPr_FACE_TYPE_NUM] = { - GFXPRINT_HIRAGANA_MODE_CHAR "タイプ1", - GFXPRINT_HIRAGANA_MODE_CHAR "タイプ2", - GFXPRINT_HIRAGANA_MODE_CHAR "タイプ3", - GFXPRINT_HIRAGANA_MODE_CHAR "タイプ4", - GFXPRINT_HIRAGANA_MODE_CHAR "タイプ5", - GFXPRINT_HIRAGANA_MODE_CHAR "タイプ6", - GFXPRINT_HIRAGANA_MODE_CHAR "タイプ7", - GFXPRINT_HIRAGANA_MODE_CHAR "タイプ8" - }; + static const char* Distinction[mPr_FACE_TYPE_NUM] = { + GFXPRINT_HIRAGANA_MODE_CHAR "タイプ1", GFXPRINT_HIRAGANA_MODE_CHAR "タイプ2", GFXPRINT_HIRAGANA_MODE_CHAR "タイプ3", + GFXPRINT_HIRAGANA_MODE_CHAR "タイプ4", GFXPRINT_HIRAGANA_MODE_CHAR "タイプ5", GFXPRINT_HIRAGANA_MODE_CHAR "タイプ6", + GFXPRINT_HIRAGANA_MODE_CHAR "タイプ7", GFXPRINT_HIRAGANA_MODE_CHAR "タイプ8", + }; - gfxprint_locate8x8(gfxprint, 23, 12); - gfxprint_printf(gfxprint, "カオ :%s", Distinction[Common_Get(now_private)->face]); + gfxprint_locate8x8(gfxprint, 23, 12); + gfxprint_printf(gfxprint, "カオ :%s", Distinction[Common_Get(now_private)->face]); } static void select_print_sunburn(gfxprint_t* gfxprint, GAME_SELECT* select) { - mPr_sunburn_c* sunburn = &Common_Get(now_private)->sunburn; - int rank = sunburn->rank; + mPr_sunburn_c* sunburn = &Common_Get(now_private)->sunburn; + int rank = sunburn->rank; - gfxprint_locate8x8(gfxprint, 23, 16); - gfxprint_printf(gfxprint, "ヒヤケ :%d %d/%d", rank, sunburn->last_changed_date.month, sunburn->last_changed_date.day); + gfxprint_locate8x8(gfxprint, 23, 16); + gfxprint_printf(gfxprint, "ヒヤケ :%d %d/%d", rank, sunburn->last_changed_date.month, + sunburn->last_changed_date.day); } static void select_print_event(gfxprint_t* gfxprint, GAME_SELECT* select) { - static const char* event_kind[] = { - GFXPRINT_KATAKANA_MODE_CHAR "---", - GFXPRINT_KATAKANA_MODE_CHAR "ザッカヤ", // (雑貨屋) (general store/shop) - GFXPRINT_KATAKANA_MODE_CHAR "デザイナ-", // designer - GFXPRINT_KATAKANA_MODE_CHAR "ブロ-カ-", // broker - GFXPRINT_KATAKANA_MODE_CHAR "ガハク", // (画伯) artist - GFXPRINT_KATAKANA_MODE_CHAR "ジュウタン", // (絨毯) carpet - GFXPRINT_KATAKANA_MODE_CHAR "クロヒョウ" // (黒豹) black panther - }; + static const char* event_kind[] = { + GFXPRINT_KATAKANA_MODE_CHAR "---", + GFXPRINT_KATAKANA_MODE_CHAR "ザッカヤ", // (雑貨屋) (general store/shop) + GFXPRINT_KATAKANA_MODE_CHAR "デザイナ-", // designer + GFXPRINT_KATAKANA_MODE_CHAR "ブロ-カ-", // broker + GFXPRINT_KATAKANA_MODE_CHAR "ガハク", // (画伯) artist + GFXPRINT_KATAKANA_MODE_CHAR "ジュウタン", // (絨毯) carpet + GFXPRINT_KATAKANA_MODE_CHAR "クロヒョウ", // (黒豹) black panther + }; - gfxprint_locate8x8(gfxprint, 23, 17); - gfxprint_printf(gfxprint, GFXPRINT_KATAKANA_MODE_CHAR "イベント :%s", event_kind[0]); + gfxprint_locate8x8(gfxprint, 23, 17); + gfxprint_printf(gfxprint, GFXPRINT_KATAKANA_MODE_CHAR "イベント :%s", event_kind[0]); } static void select_draw_main(GAME_SELECT* select) { static SELECT_PRINT_PROC print_process[11] = { - &select_print_rtc, - &select_print_time, - &select_print_step, - &select_print_weather, - &select_print_sex, - &select_print_face_type, - &select_print_swell, - &select_print_decoy, - &select_print_cloth, - &select_print_sunburn, - &select_print_event + &select_print_rtc, &select_print_time, &select_print_step, &select_print_weather, + &select_print_sex, &select_print_face_type, &select_print_swell, &select_print_decoy, + &select_print_cloth, &select_print_sunburn, &select_print_event, }; - rect screen; - GRAPH* g = select->game.graph; + rect screen; + GRAPH* g = select->game.graph; - OPEN_DISP(g); + OPEN_DISP(g); - gSPSegment(NOW_BG_OPA_DISP++, G_MWO_SEGMENT_0, 0); - gSPSegment(NOW_POLY_OPA_DISP++, G_MWO_SEGMENT_0, 0); + gSPSegment(NOW_BG_OPA_DISP++, G_MWO_SEGMENT_0, 0); + gSPSegment(NOW_POLY_OPA_DISP++, G_MWO_SEGMENT_0, 0); - DisplayList_initialize(g, 0, 0, 0, NULL); + DisplayList_initialize(g, 0, 0, 0, NULL); - { - screen.top = 0; - screen.bottom = SCREEN_HEIGHT; - screen.l = 0; - screen.r = SCREEN_WIDTH; + { + screen.top = 0; + screen.bottom = SCREEN_HEIGHT; + screen.l = 0; + screen.r = SCREEN_WIDTH; - setScissorView(&select->view, &screen); - showView(&select->view, VIEW_UPDATE_ALL); - } - - rect_moji(g); - - { - gfxprint_t* gfxprint_p = __alloca(sizeof(gfxprint_t)); - int i; - gfxprint_init(gfxprint_p); - gfxprint_open(gfxprint_p, NOW_POLY_OPA_DISP); - - select_print_course_name(select, gfxprint_p); - - gfxprint_color(gfxprint_p, 200, 200, 55, 255); - gfxprint_locate8x8(gfxprint_p, 26, 4); - gfxprint_printf(gfxprint_p, GFXPRINT_HIRAGANA_MODE_CHAR "-セッテイ-"); // -settings- - - for (i = 0; i < 11; i++) { - if (select->cursor_y == i) { - if (select->status == SELECT_STATUS_MAIN) { - gfxprint_color(gfxprint_p, 180, 180, 255, 255); - } - else { - gfxprint_color(gfxprint_p, 120, 120, 255, 255); - } - } - else { - gfxprint_color(gfxprint_p, 255, 255, 55, 255); - } - - (*print_process[i])(gfxprint_p, select); + setScissorView(&select->view, &screen); + showView(&select->view, VIEW_UPDATE_ALL); } - SET_POLY_OPA_DISP(gfxprint_close(gfxprint_p)); + rect_moji(g); + { + gfxprint_t* gfxprint_p = __alloca(sizeof(gfxprint_t)); + int i; + gfxprint_init(gfxprint_p); + gfxprint_open(gfxprint_p, NOW_POLY_OPA_DISP); - gfxprint_cleanup(gfxprint_p); - } - CLOSE_DISP(g); + select_print_course_name(select, gfxprint_p); + + gfxprint_color(gfxprint_p, 200, 200, 55, 255); + gfxprint_locate8x8(gfxprint_p, 26, 4); + gfxprint_printf(gfxprint_p, GFXPRINT_HIRAGANA_MODE_CHAR "-セッテイ-"); // -settings- + + for (i = 0; i < 11; i++) { + if (select->cursor_y == i) { + if (select->status == SELECT_STATUS_MAIN) { + gfxprint_color(gfxprint_p, 180, 180, 255, 255); + } else { + gfxprint_color(gfxprint_p, 120, 120, 255, 255); + } + } else { + gfxprint_color(gfxprint_p, 255, 255, 55, 255); + } + + (*print_process[i])(gfxprint_p, select); + } + + SET_POLY_OPA_DISP(gfxprint_close(gfxprint_p)); + + gfxprint_cleanup(gfxprint_p); + } + CLOSE_DISP(g); } static void select_draw_wait(GAME_SELECT* select) { - GRAPH* g = select->game.graph; + GRAPH* g = select->game.graph; - OPEN_DISP(g); + OPEN_DISP(g); - gSPSegment(NOW_BG_OPA_DISP++, G_MWO_SEGMENT_0, 0); - gSPSegment(NOW_POLY_OPA_DISP++, G_MWO_SEGMENT_0, 0); + gSPSegment(NOW_BG_OPA_DISP++, G_MWO_SEGMENT_0, 0); + gSPSegment(NOW_POLY_OPA_DISP++, G_MWO_SEGMENT_0, 0); - DisplayList_initialize(g, 0, 0, 0, NULL); + DisplayList_initialize(g, 0, 0, 0, NULL); - { - rect screen; + { + rect screen; - screen.top = 0; - screen.bottom = SCREEN_HEIGHT; - screen.l = 0; - screen.r = SCREEN_WIDTH; + screen.top = 0; + screen.bottom = SCREEN_HEIGHT; + screen.l = 0; + screen.r = SCREEN_WIDTH; - setScissorView(&select->view, &screen); - showView(&select->view, VIEW_UPDATE_ALL); - } + setScissorView(&select->view, &screen); + showView(&select->view, VIEW_UPDATE_ALL); + } - rect_moji(g); - { - gfxprint_t* gfxprint_p = __alloca(sizeof(gfxprint_t)); + rect_moji(g); + { + gfxprint_t* gfxprint_p = __alloca(sizeof(gfxprint_t)); - gfxprint_init(gfxprint_p); - gfxprint_open(gfxprint_p, NOW_POLY_OPA_DISP); + gfxprint_init(gfxprint_p); + gfxprint_open(gfxprint_p, NOW_POLY_OPA_DISP); - select_print_wait(gfxprint_p); + select_print_wait(gfxprint_p); - SET_POLY_OPA_DISP(gfxprint_close(gfxprint_p)); + SET_POLY_OPA_DISP(gfxprint_close(gfxprint_p)); - - gfxprint_cleanup(gfxprint_p); - } - CLOSE_DISP(g); + gfxprint_cleanup(gfxprint_p); + } + CLOSE_DISP(g); } static void select_draw(GAME_SELECT* select) { - GRAPH* g = select->game.graph; - rect screen; + GRAPH* g = select->game.graph; + rect screen; - OPEN_DISP(g); + OPEN_DISP(g); - gSPSegment(NOW_BG_OPA_DISP++, G_MWO_SEGMENT_0, 0); - gSPSegment(NOW_POLY_OPA_DISP++, G_MWO_SEGMENT_0, 0); + gSPSegment(NOW_BG_OPA_DISP++, G_MWO_SEGMENT_0, 0); + gSPSegment(NOW_POLY_OPA_DISP++, G_MWO_SEGMENT_0, 0); - DisplayList_initialize(g, 0, 0, 0, NULL); + DisplayList_initialize(g, 0, 0, 0, NULL); screen.top = 0; screen.bottom = SCREEN_HEIGHT; @@ -1275,62 +1011,62 @@ static void select_draw(GAME_SELECT* select) { setScissorView(&select->view, &screen); showView(&select->view, VIEW_UPDATE_ALL); - if (select->game.doing == FALSE) { - select_draw_wait(select); - } - else { - select_draw_main(select); - } + if (select->game.doing == FALSE) { + select_draw_wait(select); + } else { + select_draw_main(select); + } - CLOSE_DISP(g); + CLOSE_DISP(g); } static void select_main(GAME* game) { - GAME_SELECT* select = (GAME_SELECT*)game; + GAME_SELECT* select = (GAME_SELECT*)game; - select_move(select); - select_draw(select); + select_move(select); + select_draw(select); - { - GRAPH* g = game->graph; - game_debug_draw_last(game, g); - game_draw_last(g); - } + { + GRAPH* g = game->graph; + game_debug_draw_last(game, g); + game_draw_last(g); + } } -extern void select_cleanup(GAME* game) { } +extern void select_cleanup(GAME* game) { +} extern void select_init(GAME* game) { - GAME_SELECT* select = (GAME_SELECT*)game; - int i; + GAME_SELECT* select = (GAME_SELECT*)game; + int i; - game->exec = &select_main; - game->cleanup = &select_cleanup; + game->exec = &select_main; + game->cleanup = &select_cleanup; - select->status = SELECT_STATUS_MAIN; - select->cursor_y = 10; - select->step = 0; - select->step_add = 0; + select->status = SELECT_STATUS_MAIN; + select->cursor_y = 10; + select->step = 0; + select->step_add = 0; - initView(&select->view, game->graph); - select->view.flag = VIEW_UPDATE_SCISSOR | VIEW_UPDATE_ORTHOGRAPHIC; + initView(&select->view, game->graph); + select->view.flag = VIEW_UPDATE_SCISSOR | VIEW_UPDATE_ORTHOGRAPHIC; - select->unk_228[0] = 0; - select->unk_228[1] = 0; - select->unk_228[2] = 0; - for (i = 0; i < PLAYER_NAME_LEN; i++) { - select->name[i] = fcode2data(Common_Get(now_private)->player_ID.player_name[i]); - } + select->unk_228[0] = 0; + select->unk_228[1] = 0; + select->unk_228[2] = 0; + for (i = 0; i < PLAYER_NAME_LEN; i++) { + select->name[i] = fcode2data(Common_Get(now_private)->player_ID.player_name[i]); + } - select->selected_course = Common_Get(select_last_select_no); - select->top_course = Common_Get(select_last_top_no); + select->selected_course = Common_Get(select_last_select_no); + select->top_course = Common_Get(select_last_top_no); - SetGameFrame(1); - Common_Set(last_scene_no, Save_Get(scene_no)); - Common_Set(submenu_disabled, 0); - Common_Set(now_private->inventory.loan, 1000); - mNpc_ClearEventNpc(); - mNpc_ClearMaskNpc(); - mFI_SetClimate(mFI_CLIMATE_0); - Common_Set(last_scene_no, 0); + SetGameFrame(1); + Common_Set(last_scene_no, Save_Get(scene_no)); + Common_Set(submenu_disabled, 0); + Common_Set(now_private->inventory.loan, 1000); + mNpc_ClearEventNpc(); + mNpc_ClearMaskNpc(); + mFI_SetClimate(mFI_CLIMATE_0); + Common_Set(last_scene_no, 0); } diff --git a/src/game/m_shop.c b/src/game/m_shop.c index 2ec366f0..538c7b57 100644 --- a/src/game/m_shop.c +++ b/src/game/m_shop.c @@ -949,13 +949,17 @@ static void mSP_SelectTool(mActor_name_t* goods_list, int* count, int tool_num, /* Add paint & signboard if shop is Nookway or greater */ if (shop_level >= mSP_SHOP_TYPE_SUPER) { - if (paint_idx >= PAINT_NUM) { + if ((u16)paint_idx >= PAINT_NUM) { paint_idx = 0; /* wrap over to beginning */ } goods_list[count[0]] = ITM_RED_PAINT + paint_idx; paint_idx++; +#if VERSION == VER_GAFU01_00 + Save_Get(shop).shop_info.paint_color = (u16)paint_idx; +#else Save_Get(shop).shop_info.paint_color = paint_idx; +#endif count[0]++; goods_list[count[0]] = ITM_SIGNBOARD; count[0]++; @@ -967,7 +971,7 @@ static void mSP_SelectTool(mActor_name_t* goods_list, int* count, int tool_num, } static void mSP_SelectPlant(mActor_name_t* goods_list, int* count, int flower_count, int sapling_count, - int shop_level) { + const int shop_level) { u8 flower_use[FLOWER_NUM]; int i; @@ -983,7 +987,7 @@ static void mSP_SelectPlant(mActor_name_t* goods_list, int* count, int flower_co count[0] += 1; } - for (i = 0; i < sapling_count; i++) { + for (i = sapling_count; i > 0; i--) { goods_list[count[0]] = ITM_SAPLING; count[0] += 1; } @@ -2369,6 +2373,7 @@ static void mSP_SelectRandomItemToAGB_Unit(mActor_name_t* item, xyz_t* wpos, int } } +#if VERSION == VER_GAFE01_00 // @fakematch // @HACK - we shouldn't have to force propagation off, nor access the Save_t* struct directly #pragma opt_propagation off @@ -2448,6 +2453,79 @@ extern void mSP_SelectRandomItemToAGB() { wpos.z = wpos.z; } #pragma opt_propagation reset +#else +extern void mSP_SelectRandomItemToAGB() { + int i; + int ut_x; + int ut_z; + xyz_t* wpos_p; + mActor_name_t* start_p; + mActor_name_t* item_p; + xyz_t tpos; + + xyz_t wpos = { 0.0f, 0.0f, 0.0f }; + int bx = 0; + int bz = 0; + + mFI_BlockKind2BkNum(&bx, &bz, mRF_BLOCKKIND_ISLAND_LEFT); + + /* convert all unit island items to valid items */ + for (i = 0; i < mISL_FG_BLOCK_X_NUM; i++) { + item_p = &Save_Get(island).fgblock[0][i].items[0][0]; + + mFI_BkNum2WposXZ(&wpos.x, &wpos.z, bx + i, bz); + wpos.x += mFI_UT_WORLDSIZE_HALF_X_F; + wpos.z += mFI_UT_WORLDSIZE_HALF_Z_F; + tpos.x = wpos.x; + + for (ut_z = 0; ut_z < UT_Z_NUM; ut_z++) { + wpos.x = tpos.x; + + for (ut_x = 0; ut_x < UT_X_NUM; ut_x++) { + mSP_SelectRandomItemToAGB_Unit(item_p, &wpos, ut_x, ut_z); + wpos.x += mFI_UT_WORLDSIZE_X_F; + item_p++; + } + + wpos.z += mFI_UT_WORLDSIZE_Z_F; + } + } + + /* add correctly placed signboard actor */ + for (i = 0; i < mISL_FG_BLOCK_X_NUM; i++) { + item_p = &Save_Get(island).fgblock[0][i].items[0][0]; + + for (ut_z = 0; ut_z < UT_Z_NUM; ut_z++) { + for (ut_x = 0; ut_x < UT_X_NUM; ut_x++) { + start_p = &Save_Get(island).fgblock[0][i].items[0][0]; + if (item_p[0] == COTTAGE_NPC) { + start_p[(((ut_x - 1) & 15) + (((ut_z + 1) & 0xF) << 4))] = ACTOR_PROP_VILLAGER_SIGNBOARD; + } + + item_p++; + } + } + } + + /* remove incorrectly placed signboard actors */ + for (i = 0; i < mISL_FG_BLOCK_X_NUM; i++) { + item_p = &Save_Get(island).fgblock[0][i].items[0][0]; + start_p = &Save_Get(island).fgblock[0][i].items[0][0]; + + for (ut_z = 0; ut_z < UT_Z_NUM; ut_z++) { + for (ut_x = 0; ut_x < UT_X_NUM; ut_x++) { + if (item_p[0] == ACTOR_PROP_VILLAGER_SIGNBOARD && + start_p[((ut_x + 1) & 15) + (((ut_z - 1) & 0xF) << 4)] != COTTAGE_NPC) { + item_p[0] = EMPTY_NO; + } + + item_p++; + } + } + } + wpos.z = wpos.z; +} +#endif extern const char* mSP_ShopStatus2String(int status) { static char dummy[] = "hahaha"; diff --git a/src/game/m_start_data_init.c b/src/game/m_start_data_init.c index 08e5c31c..2ae9c117 100644 --- a/src/game/m_start_data_init.c +++ b/src/game/m_start_data_init.c @@ -44,6 +44,9 @@ static void title_game_haniwa_data_init() { int line_len; int haniwa_msg_len; int i; + int j; + Haniwa_c* haniwa; + mHm_hs_c* house; u8* dst; /* Load message line-by-line */ @@ -62,9 +65,8 @@ static void title_game_haniwa_data_init() { } for (i = 0; i < mHS_HOUSE_NUM; i++) { - Haniwa_c* haniwa = &Save_Get(homes + i)->haniwa; - mHm_hs_c* house = Save_Get(homes + i); - int j; + haniwa = &Save_Get(homes + i)->haniwa; + house = Save_Get(homes + i); /* Copy default message */ mem_copy(house->haniwa.message, haniwa_buf, HANIWA_MESSAGE_LEN); @@ -169,6 +171,118 @@ static void mSDI_PullTreeUnderPlayerBlock() { } } +// TODO: I don't like this deviation +#if VERSION != VER_GAFE01_00 +static int mSDI_StartInitNew(GAME* game, int player_no, int malloc_flag) { + Private_c* priv; + Animal_c* animals = Save_Get(animals); + mActor_name_t* fruit_p = Save_GetPointer(fruit); + int town_day; + GAME* g = NULL; + int i; + int ret = TRUE; + GAME_PLAY* play = (GAME_PLAY*)game; + + Common_Set(scene_from_title_demo, SCENE_START_DEMO); + lbRTC_GetTime(Common_GetPointer(time.rtc_time)); + osSyncPrintf("player no -- %d\n", player_no); + Common_Set(player_no, player_no); + + priv = Save_GetPointer(private_data[player_no]); + Common_Set(now_private, priv); + priv->gender = mPr_SEX_MALE; + decide_fruit(fruit_p); + mFM_DecideBgTexIdx(Save_GetPointer(bg_tex_idx)); + mFAs_ClearGoodField(); + + if (malloc_flag == FALSE) { + g = game; + } + + bzero(Save_Get(deposit), sizeof(Save_Get(deposit))); + Save_Set(dust_flag, FALSE); + bzero(Save_GetPointer(island), sizeof(Island_c)); + mFM_InitFgCombiSaveData(g); + + /* Remove trees */ + mSDI_PullTree(); + mSDI_PullTreeUnderPlayerBlock(); + + mFM_SetBlockKindLoadCombi(g); + + /* Tree -> Fruit Tree */ + mAGrw_ChangeTree2FruitTree(); + + /* Tree -> Cedar Tree */ + mAGrw_ChangeTree2Cedar(); + + + priv = Save_Get(private_data); + mMld_SetDefaultMelody(); + mLd_LandDataInit(); + mEv_ClearEventSaveInfo(Save_GetPointer(event_save_data)); + mEv_init(&play->event); + mNpc_InitNpcAllInfo(malloc_flag); + + for (i = 0; i < PLAYER_NUM; i++) { + mPr_ClearPrivateInfo(priv); + + Save_Get(homes[i]).outlook_pal = i; + Save_Get(homes[i]).next_outlook_pal = i; + bzero(&Save_Get(homes[i]).size_info, sizeof(mHm_rmsz_c)); + + mPr_ClearMotherMailInfo(&Save_Get(mother_mail[i])); + priv++; + } + + mPr_InitPrivateInfo(priv - PLAYER_NUM + player_no); + mNpc_SetRemoveAnimalNo(Save_GetPointer(remove_animal_idx), animals, -1); + title_game_haniwa_data_init(); + mPB_police_box_init(g); + mSN_snowman_init(); + mHS_house_init(); + mGH_animal_return_init(); + mMC_mask_cat_init(); + mDE_maskcat_init(Save_GetPointer(mask_cat)); + + lbRTC_TimeCopy(Save_GetPointer(last_grow_time), &mTM_rtcTime_clear_code); + lbRTC_TimeCopy(Save_GetPointer(treasure_buried_time), &mTM_rtcTime_clear_code); + lbRTC_TimeCopy(Save_GetPointer(treasure_checked_time), &mTM_rtcTime_clear_code); + lbRTC_TimeCopy(Save_GetPointer(saved_auto_nwrite_time), &mTM_rtcTime_clear_code); + + Save_Set(station_type, RANDOM(15)); + Save_Set(island.last_song_to_island, -1); + Save_Set(island.last_song_from_island, -1); + + mPr_SetPossessionItem(Common_Get(now_private), 0, ITM_MONEY_1000, mPr_ITEM_COND_QUEST); + + town_day = RANDOM(30) + 1; /* Initial spread is [1, 30] */ + if (town_day >= 4) { + town_day++; /* Add an extra day so that 4th of July is never chosen, so [1, 3] U [5, 31] */ + } + + Save_Set(town_day, town_day); + + mCkRh_InitGokiSaveData_AllRoom(); + + mNW_InitMyOriginal(); + mNW_InitNeedleworkData(); + + mEv_2nd_init(&play->event); + + mISL_init(Save_GetPointer(island)); + + famicom_emu_initial_common_data(); + + mRmTp_SetDefaultLightSwitchData(1); // TODO: lightswitch enum + + mFI_PullTanukiPathTrees(); + + Common_Set(_2dbe1, 0); + + return ret; +} +#else static int mSDI_StartInitNew(GAME* game, int player_no, int malloc_flag) { int town_day; Private_c* priv; @@ -277,6 +391,7 @@ static int mSDI_StartInitNew(GAME* game, int player_no, int malloc_flag) { return TRUE; } +#endif static int mSDI_StartInitFrom(GAME* game, int player_no, int malloc_flag) { GAME_PLAY* play = (GAME_PLAY*)game; diff --git a/src/game/m_string.c b/src/game/m_string.c index 474b923a..bc1c1ab4 100644 --- a/src/game/m_string.c +++ b/src/game/m_string.c @@ -11,167 +11,166 @@ static u32 String_rom_start; static u32 String_table_rom_start; extern void mString_aram_init() { - String_table_rom_start = JW_GetAramAddress(RESOURCE_STRING_TABLE); - String_rom_start = JW_GetAramAddress(RESOURCE_STRING); + String_table_rom_start = JW_GetAramAddress(RESOURCE_STRING_TABLE); + String_rom_start = JW_GetAramAddress(RESOURCE_STRING); } static void mString_Get_StringDataAddressAndSize(int string_no, u32* string_addr, u32* string_size) { - mMsg_Get_BodyParam(String_table_rom_start, String_rom_start, string_no, string_addr, string_size); + mMsg_Get_BodyParam(String_table_rom_start, String_rom_start, string_no, string_addr, string_size); } extern void mString_Load_StringFromRom(u8* dst, int dst_len, int str_no) { - //static u8 buff[MAIL_BODY_LEN - 1] ATTRIBUTE_ALIGN(32); // TODO: proper bss ordering + // static u8 buff[MAIL_BODY_LEN - 1] ATTRIBUTE_ALIGN(32); // TODO: proper bss ordering - u32 string_data_addr; - u32 string_size; + u32 string_data_addr; + u32 string_size; - if (str_no >= 0 && str_no < mString_MAX_STR) { - mString_Get_StringDataAddressAndSize(str_no, &string_data_addr, &string_size); + if (str_no >= 0 && str_no < mString_MAX_STR) { + mString_Get_StringDataAddressAndSize(str_no, &string_data_addr, &string_size); - if (string_size == 0) { - mem_clear(dst, dst_len, CHAR_SPACE); + if (string_size == 0) { + mem_clear(dst, dst_len, CHAR_SPACE); + } else if (string_data_addr != 0) { + u32 base_addr = ALIGN_PREV(string_data_addr, 32); + u32 ofs = string_data_addr - base_addr; + u32 dma_size = ALIGN_NEXT(ofs + string_size, 32); + int i; + int copy_size; + u8* s_dst; + u8* s_src; + + _JW_GetResourceAram(base_addr, buff, dma_size); + if (dst_len < (int)string_size) { + string_size = dst_len; + } + + s_src = buff + ofs; + s_dst = dst; + copy_size = string_size; + for (i = 0; i < copy_size; i++) { + *s_dst++ = *s_src++; + } + + for (i; i < dst_len; i++) { + *s_dst++ = CHAR_SPACE; + } + } } - else if (string_data_addr != 0) { - u32 base_addr = ALIGN_PREV(string_data_addr, 32); - u32 ofs = string_data_addr - base_addr; - u32 dma_size = ALIGN_NEXT(ofs + string_size, 32); - int i; - u8* s_src; - int copy_size; - u8* s_dst; - - _JW_GetResourceAram(base_addr, buff, dma_size); - if (dst_len < (int)string_size) { - string_size = dst_len; - } - - s_src = buff + ofs; - s_dst = dst; - copy_size = string_size; - for (i = 0; i < copy_size; i++) { - *s_dst++ = *s_src++; - } - - for (i; i < dst_len; i++) { - *s_dst++ = CHAR_SPACE; - } - } - } } extern int mString_Load_YearStringFromRom(u8* dst, lbRTC_year_t year) { - if (year < lbRTC_YEAR_MIN || year > lbRTC_YEAR_MAX) { - year = GAME_YEAR_MIN; - } + if (year < lbRTC_YEAR_MIN || year > lbRTC_YEAR_MAX) { + year = GAME_YEAR_MIN; + } - return mFont_UnintToString(dst, 6, year, 6, TRUE, FALSE, FALSE); + return mFont_UnintToString(dst, 6, year, 6, TRUE, FALSE, FALSE); } extern int mString_Load_MonthStringFromRom(u8* dst, lbRTC_month_t month) { - if (month < lbRTC_JANUARY || month > lbRTC_DECEMBER) { - month = lbRTC_JANUARY; - } + if (month < lbRTC_JANUARY || month > lbRTC_DECEMBER) { + month = lbRTC_JANUARY; + } - mString_Load_StringFromRom(dst, 9, mString_MONTH_START + month - 1); - return mMsg_Get_Length_String(dst, 9); + mString_Load_StringFromRom(dst, 9, mString_MONTH_START + month - 1); + return mMsg_Get_Length_String(dst, 9); } extern int mString_Load_WeekStringFromRom(u8* dst, lbRTC_weekday_t weekday) { - if (weekday > lbRTC_SATURDAY) { - weekday = lbRTC_SUNDAY; - } + if (weekday > lbRTC_SATURDAY) { + weekday = lbRTC_SUNDAY; + } - mString_Load_StringFromRom(dst, 9, mString_WEEKDAY_START + weekday); - return mMsg_Get_Length_String(dst, 9); + mString_Load_StringFromRom(dst, 9, mString_WEEKDAY_START + weekday); + return mMsg_Get_Length_String(dst, 9); } extern int mString_Load_DayStringFromRom(u8* dst, lbRTC_day_t day) { - if (day < 1 || day > 31) { - day = 1; - } + if (day < 1 || day > 31) { + day = 1; + } - mString_Load_StringFromRom(dst, 4, mString_DAY_START + day - 1); - return mMsg_Get_Length_String(dst, 4); + mString_Load_StringFromRom(dst, 4, mString_DAY_START + day - 1); + return mMsg_Get_Length_String(dst, 4); } extern int mString_Load_HourStringFromRom(u8* dst, lbRTC_hour_t hour) { - int hour_num_len; - int clamped_hour; - int specifier; + int hour_num_len; + int clamped_hour; + int specifier; - if (hour > 23) { - hour = 0; - } + if (hour > 23) { + hour = 0; + } - clamped_hour = hour; - switch (clamped_hour) { - case 0: - clamped_hour = 12; - break; - case 12: - clamped_hour = 12; - break; + clamped_hour = hour; + switch (clamped_hour) { + case 0: + clamped_hour = 12; + break; + case 12: + clamped_hour = 12; + break; - default: - clamped_hour %= 12; - break; - } + default: + clamped_hour %= 12; + break; + } - specifier = hour < 12 ? mString_AM : mString_PM; - hour_num_len = mFont_UnintToString(dst, 15, clamped_hour, 15, TRUE, FALSE, FALSE); - dst[hour_num_len] = CHAR_SPACE; - hour_num_len++; + specifier = hour < 12 ? mString_AM : mString_PM; + hour_num_len = mFont_UnintToString(dst, 15, clamped_hour, 15, TRUE, FALSE, FALSE); + dst[hour_num_len] = CHAR_SPACE; + hour_num_len++; - /* Load AM/PM string */ - mString_Load_StringFromRom(dst + hour_num_len, 15 - hour_num_len, specifier); - return mMsg_Get_Length_String(dst, 15); + /* Load AM/PM string */ + mString_Load_StringFromRom(dst + hour_num_len, 15 - hour_num_len, specifier); + return mMsg_Get_Length_String(dst, 15); } extern int mString_Load_HourStringFromRom2(u8* dst, lbRTC_hour_t hour) { - int clamped_hour; + int clamped_hour; - if (hour > 23) { - hour = 0; - } + if (hour > 23) { + hour = 0; + } - clamped_hour = hour; - switch (clamped_hour) { - case 0: - case 12: - clamped_hour = 12; - break; + clamped_hour = hour; + switch (clamped_hour) { + case 0: + case 12: + clamped_hour = 12; + break; - default: - clamped_hour %= 12; - break; - } + default: + clamped_hour %= 12; + break; + } - return mFont_UnintToString(dst, 15, clamped_hour, 2, TRUE, FALSE, FALSE); + return mFont_UnintToString(dst, 15, clamped_hour, 2, TRUE, FALSE, FALSE); } extern int mString_Load_MinStringFromRom(u8* dst, lbRTC_min_t min) { - if (min > 59) { - min = 0; - } + if (min > 59) { + min = 0; + } - return mFont_UnintToString(dst, 4, min, 2, TRUE, TRUE, TRUE); + return mFont_UnintToString(dst, 4, min, 2, TRUE, TRUE, TRUE); } extern int mString_Load_SecStringFromRom(u8* dst, lbRTC_sec_t sec) { - if (sec > 59) { - sec = 0; - } + if (sec > 59) { + sec = 0; + } - return mFont_UnintToString(dst, 5, sec, 2, TRUE, TRUE, TRUE); + return mFont_UnintToString(dst, 5, sec, 2, TRUE, TRUE, TRUE); } extern int mString_Load_NumberStringAddUnitFromRom(u8* dst, u16 num, int str_no) { - int num_len = mFont_UnintToString(dst, mMsg_FREE_STRING_LEN, num, mMsg_FREE_STRING_LEN, TRUE, FALSE, TRUE); - u8* n_dst = dst + num_len; - dst[num_len] = CHAR_SPACE; - num_len++; + int num_len = mFont_UnintToString(dst, mMsg_FREE_STRING_LEN, num, mMsg_FREE_STRING_LEN, TRUE, FALSE, TRUE); + u8* n_dst = dst + num_len; + dst[num_len] = CHAR_SPACE; + num_len++; - /* Add the unit */ - mString_Load_StringFromRom(dst + num_len, mMsg_FREE_STRING_LEN - num_len, str_no); - return mMsg_Get_Length_String(dst, mMsg_FREE_STRING_LEN); + /* Add the unit */ + mString_Load_StringFromRom(dst + num_len, mMsg_FREE_STRING_LEN - num_len, str_no); + return mMsg_Get_Length_String(dst, mMsg_FREE_STRING_LEN); } diff --git a/src/game/m_tag_ovl.c b/src/game/m_tag_ovl.c index 21506627..6e71e146 100644 --- a/src/game/m_tag_ovl.c +++ b/src/game/m_tag_ovl.c @@ -27,7 +27,7 @@ #include "m_roll_lib.h" #include "m_house.h" -static void mTG_mark_main_CLR(Submenu* submenu, mSM_MenuInfo_c* menu_info); +static void mTG_mark_main_CLR(Submenu* submenu, const mSM_MenuInfo_c* menu_info); enum { mTG_QSTR_TYPE_NONE, @@ -1606,7 +1606,7 @@ static int mTG_strcpy(u8* dst, u8* src, int dst_max, int src_max) { return dst_max; } -static int mTG_strcat_color(u8* str, u8* src, int str_max, int src_max, rgba_t* color) { +static int mTG_strcat_color(u8* str, u8* src, int str_max, int src_max, const rgba_t* color) { /* 0x7F 0x05 0x00 0x00 0x00 0x00 */ static u8 font_color_base[] = { CHAR_CONTROL_CODE, mFont_CONT_CODE_SET_COLOR_CHAR, 0, 0, 0, 0 }; int str_len = mMl_strlen(str, str_max, CHAR_SPACE); @@ -1618,7 +1618,7 @@ static int mTG_strcat_color(u8* str, u8* src, int str_max, int src_max, rgba_t* if ((col_len + src_len) > str_max) { src_len -= (col_len + src_len) - str_max; } - + str[col_len - 4] = color->r; str[col_len - 3] = color->g; str[col_len - 2] = color->b; @@ -3210,10 +3210,9 @@ static void mTG_sell_all_proc(Submenu* submenu, mSM_MenuInfo_c* menu_info) { item_p = submenu->item_p; count = 0; - for (i = 0; i < mPr_POCKETS_SLOT_COUNT; i++) { + for (i = 0; i < mPr_POCKETS_SLOT_COUNT; i++, item_p++) { item_p->item = EMPTY_NO; item_p->slot_no = 0; - item_p++; } item_p = submenu->item_p; @@ -3339,6 +3338,8 @@ static void mTG_dump_mail_mark_exe_proc(Submenu* submenu, mSM_MenuInfo_c* menu_i int i; if (menu_info->menu_type == mSM_OVL_MAILBOX) { + int i; + mailbox_ovl->mark_flag = FALSE; for (i = 0; i < HOME_MAILBOX_SIZE; i++) { Mail_c* mail = &Common_Get(now_home)->mailbox[i]; @@ -3355,6 +3356,7 @@ static void mTG_dump_mail_mark_exe_proc(Submenu* submenu, mSM_MenuInfo_c* menu_i } } else if (menu_info->menu_type == mSM_OVL_CPMAIL) { int page = cpmail_ovl->page_order[0]; + int i; for (i = 0; i < mCD_KEEP_MAIL_COUNT; i++) { Mail_c* mail = &cpmail_ovl->card_mail->mail[page][i]; @@ -4512,8 +4514,8 @@ static int mTG_bit_chk(u8* flags, u8* masks, int count) { int res = 0; int i; - for (i = 0; i < count; i++) { - res |= *flags++ & *masks++; + for (i = 0; i < count; i++, flags++, masks++) { + res |= *flags & *masks; } return res; @@ -4522,32 +4524,32 @@ static int mTG_bit_chk(u8* flags, u8* masks, int count) { static void mTG_bit_on(u8* flags, u8* bits, int count) { int i; - for (i = 0; i < count; i++) { - *flags++ |= *bits++; + for (i = 0; i < count; i++, flags++, bits++) { + *flags |= *bits; } } static void mTG_bit_off(u8* flags, u8* bits, int count) { int i; - for (i = 0; i < count; i++) { - *flags++ &= ~*bits++; + for (i = 0; i < count; i++, flags++, bits++) { + *flags &= ~*bits; } } static void mTG_bit_rvs(u8* flags, u8* bits, int count) { int i; - for (i = 0; i < count; i++) { - *flags++ ^= *bits++; + for (i = 0; i < count; i++, flags++, bits++) { + *flags ^= *bits; } } static void mTG_bit_clr(u8* flags, u8* bits, int count) { int i; - for (i = 0; i < count; i++) { - *flags++ = 0; + for (i = 0; i < count; i++, flags++) { + *flags = 0; } } @@ -4555,20 +4557,21 @@ static int mTG_bit_chk_all0(u8* flags, u8* bits, int count) { int res = 0; int i; - for (i = 0; i < count; i++) { - res |= *flags++ == 0; + for (i = 0; i < count; i++, flags++) { + res |= *flags == 0; } return res; } -extern int mTG_mark_mainX(Submenu* submenu, mSM_MenuInfo_c* menu_info, int table, int table_idx, int mode, +extern int mTG_mark_mainX(Submenu* submenu, const mSM_MenuInfo_c* menu_info, int table, int table_idx, int mode, int* chk_result) { - int mark_res; - Mail_c* mail; + int mark_res = FALSE; mTG_mark_field_u set_flags; mTG_mark_field_u* current_flags_p; int max_flag_count; + int menu_type; + int param; int chk_res = FALSE; int i; @@ -4576,8 +4579,7 @@ extern int mTG_mark_mainX(Submenu* submenu, mSM_MenuInfo_c* menu_info, int table set_flags.u8array[i] = 0; } - mail = mTG_get_mail_pointer(submenu, NULL); - mark_res = mTG_mark_main_sub(submenu, menu_info->menu_type, menu_info->data0, table, table_idx, mail, mode, + mark_res = mTG_mark_main_sub(submenu, menu_info->menu_type, menu_info->data0, table, table_idx, mTG_get_mail_pointer(submenu, NULL), mode, ¤t_flags_p, &max_flag_count, &set_flags); if (mark_res) { int byte_count = ((max_flag_count + 15) / 16) * 2; @@ -4615,7 +4617,7 @@ extern int mTG_mark_mainX(Submenu* submenu, mSM_MenuInfo_c* menu_info, int table return mark_res; } -static void mTG_mark_main_CLR(Submenu* submenu, mSM_MenuInfo_c* menu_info) { +static void mTG_mark_main_CLR(Submenu* submenu, const mSM_MenuInfo_c* menu_info) { switch (menu_info->menu_type) { case mSM_OVL_INVENTORY: mTG_mark_mainX(submenu, menu_info, mTG_TABLE_ITEM, 0, mTG_MARK_CLR, NULL); @@ -5050,7 +5052,6 @@ static void mTG_hukubukuro_open_proc(Submenu* submenu, mSM_MenuInfo_c* menu_info int free_idx[3]; mActor_name_t items[3]; int idx; - int t_idx; int i; int j; int count; @@ -5067,7 +5068,8 @@ static void mTG_hukubukuro_open_proc(Submenu* submenu, mSM_MenuInfo_c* menu_info idx = mTG_get_table_idx(&submenu->overlay->tag_ovl->tags[0]); for (i = 0; i < mPr_POCKETS_SLOT_COUNT; i++, item_p++) { if (*item_p == EMPTY_NO) { - free_idx[count++] = i; + free_idx[count] = i; + count++; if (count == 3) { break; } @@ -5131,9 +5133,8 @@ static void mTG_hukubukuro_open_proc(Submenu* submenu, mSM_MenuInfo_c* menu_info /* Give items */ for (j = 0; j < 3; j++) { - t_idx = free_idx[j]; - mPr_SetPossessionItem(Now_Private, t_idx, items[j], mPr_ITEM_COND_NORMAL); - inv_ovl->item_scale_type[t_idx] = mIV_ITEM_SCALE_TYPE_GROW + j; + mPr_SetPossessionItem(Now_Private, free_idx[j], items[j], mPr_ITEM_COND_NORMAL); + inv_ovl->item_scale_type[free_idx[j]] = mIV_ITEM_SCALE_TYPE_GROW + j; } mTG_return_tag_init(submenu, mTG_TYPE_NONE, mTG_RETURN_CLOSE); @@ -5629,11 +5630,11 @@ static void mTG_cpack_change_mail_mark_decide(Submenu* submenu, mIV_Ovl_c* inv_o cpmail_mark->idx_tbl[1] = inv_free_idx; cpmail_mark->idx_tbl[2] = cpmail_move_idx; cpmail_mark->idx_tbl[3] = cpmail_free_idx; - + tag_ovl->_370 = 0.0f; cpmail_mark->_4A = 0b11; // 3 cpmail_mark->mode = mTG_CHANGE_MAIL_MARK_MOVE; - + inv_menu = &submenu->overlay->menu_info[mSM_OVL_INVENTORY]; cpmail_menu = &submenu->overlay->menu_info[mSM_OVL_CPMAIL]; @@ -7732,8 +7733,8 @@ static void mTG_change_original_mark_decide(Submenu* submenu, mNW_Ovl_c* nw_ovl, mTG_cporiginal_mark_c* mark_p = &tag_ovl->original_mark.mark[mark_idx]; for (i = 0; i < mTG_ORG_TYPE_NUM; i++) { - mark_max = original_mark_p->mark_max[i]; idx1[i] = -1; + mark_max = original_mark_p->mark_max[i]; for (j = 0; j < mark_max; j++) { if ((original_mark_p->mark_flg[i] & (1 << j)) != 0) { mark_p->idx[i] = j; @@ -7825,8 +7826,8 @@ static void mTG_move_delete(Submenu* submenu, mTG_tag_c* tag) { int i; mPr_SetPossessionItem(Now_Private, (u32)idx, EMPTY_NO, mPr_ITEM_COND_NORMAL); - for (i = 0; i < mPr_POCKETS_SLOT_COUNT; i++) { - *scale_p++ = mIV_ITEM_SCALE_TYPE_NONE; + for (i = 0; i < mPr_POCKETS_SLOT_COUNT; i++, scale_p++) { + *scale_p = mIV_ITEM_SCALE_TYPE_NONE; } } } @@ -8586,11 +8587,12 @@ static void mTG_set_select(GAME* game, mSM_MenuInfo_c* menu_info, mTG_tag_c* tag static void mTG_set_character(Submenu* submenu, mSM_MenuInfo_c* menu_info, GAME* game, GRAPH* graph, mTG_tag_c* tag, f32 base_x, f32 base_y) { - f32 scale_rate = tag->scale * 0.875f; + f32 scale = tag->scale; + f32 scale_rate = scale * 0.875f; if (!F32_IS_ZERO(tag->scale)) { - f32 pos_x = 160.0f + (tag->base_pos[0] + base_x + tag->scale * (tag->body_ofs[0] + tag->text_ofs[0])); - f32 pos_y = 120.0f - (tag->base_pos[1] + base_y + tag->scale * (tag->body_ofs[1] + tag->text_ofs[1])); + f32 pos_x = 160.0f + (tag->base_pos[0] + base_x + scale * (tag->body_ofs[0] + tag->text_ofs[0])); + f32 pos_y = 120.0f - (tag->base_pos[1] + base_y + scale * (tag->body_ofs[1] + tag->text_ofs[1])); mTG_tag_data_c* tag_data_p = &mTG_label_table[tag->type]; submenu->overlay->set_char_matrix_proc(graph); diff --git a/src/game/m_time.c b/src/game/m_time.c index 6190819e..ec019736 100644 --- a/src/game/m_time.c +++ b/src/game/m_time.c @@ -248,7 +248,7 @@ extern void mTM_set_renew_is() { * @param renew_time Pointer to the lbRTC_ymd_c struct where the renewal time will be stored. * @param time Pointer to the lbRTC_time_c struct from which the renewal time will be taken. */ -extern void mTM_set_renew_time(lbRTC_ymd_c* renew_time, const lbRTC_time_c* time) { +extern void mTM_set_renew_time(lbRTC_ymd_c* renew_time, lbRTC_time_c* time) { renew_time->year = time->year; renew_time->month = time->month; renew_time->day = time->day; @@ -275,7 +275,7 @@ extern void mTM_ymd_2_time(lbRTC_time_c* time, lbRTC_ymd_c* ymd) { */ extern void mTM_renewal_renew_time() { lbRTC_ymd_c* renew_time = Save_GetPointer(renew_time); - const lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); + lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); // Check if the renewal time has changed if ( @@ -362,6 +362,7 @@ static int mTM_TimestepControl() { int add_sec; int tstep; +#if VERSION < VER_GAFU01_00 // Check if certain input conditions are met, and if so, adjust the time step and flags accordingly if (zurumode_flag >= 2 && debug_disp == 1 && (gamePT->pads[1].on.button & BUTTON_R) == BUTTON_R) { if (id < mTM_TIMESTEP_NUM) { @@ -386,6 +387,7 @@ static int mTM_TimestepControl() { id = 0; } } +#endif return id != 0; } diff --git a/src/game/m_train_control.c b/src/game/m_train_control.c index 928f24e3..e80fe94a 100644 --- a/src/game/m_train_control.c +++ b/src/game/m_train_control.c @@ -12,6 +12,7 @@ #include "m_lib.h" #include "m_name_table.h" #include "m_collision_bg.h" +#include "m_random_field.h" #define mTRC_RTC_TIME_SECONDS(rtc_time) \ (rtc_time->sec + (rtc_time->min + rtc_time->hour * mTM_MINUTES_IN_HOUR) * mTM_SECONDS_IN_MINUTE) @@ -38,40 +39,39 @@ static void mTRC_SetMicPos(GAME_PLAY* play, xyz_t* mic_pos) { mic_pos->z = pos.z + z; // equates to pos.z + 77.0f } -static void mTRC_KishaStatusLevel(GAME_PLAY* play, xyz_t pos, f32 speed) { - xyz_t mic_pos; - +static void mTRC_KishaStatusLevel(GAME_PLAY* play, f32 speed, xyz_t pos) { + f32 distance; + f32 distance2; f32 x; f32 y; f32 z; - s16 angle; + xyz_t mic_pos; u16 unsigned_angle; - f32 distance; - - s16 angle2; u16 unsigned_angle2; - f32 distance2; + u32 ongen; + u32 ongen2; mTRC_SetMicPos(play, &mic_pos); + x = pos.x - mic_pos.x; y = pos.y - mic_pos.y; z = pos.z - mic_pos.z; - angle = atans_table(z, x); - distance = sqrtf(x * x + y * y + z * z); + distance = sqrtf(SQ(x) + SQ(y) + SQ(z)); unsigned_angle = (int)angle; - + x = (pos.x - 250.0f) - mic_pos.x; y = pos.y - mic_pos.y; z = pos.z - mic_pos.z; + angle = atans_table(z, x); + distance2 = sqrtf(SQ(x) + SQ(y) + SQ(z)); + unsigned_angle2 = (int)angle; - angle2 = atans_table(z, x); - distance2 = sqrtf(x * x + y * y + z * z); - unsigned_angle2 = (int)angle2; - - sAdos_KishaStatusLevel(speed, (u32)Common_GetPointer(train_coming_flag), unsigned_angle, distance, - (u32)Common_GetPointer(train_exists_flag), unsigned_angle2, distance2); + ongen = (u32)Common_GetPointer(train_coming_flag); + ongen2 = (u32)Common_GetPointer(train_exists_flag); + sAdos_KishaStatusLevel(speed, ongen, distance, unsigned_angle, + ongen2, distance2, unsigned_angle2); } static void mTRC_KishaStatusTrg(u8 state) { @@ -85,15 +85,12 @@ static void mTRC_KishaStatusTrg(u8 state) { static int aTRC_area_check(GAME_PLAY* play, xyz_t pos) { int block_x; int block_z; - int x_diff; mFI_Wpos2BlockNum(&block_x, &block_z, pos); - x_diff = (block_x - play->block_table.block_x) >= 0 ? (block_x - play->block_table.block_x) - : -(block_x - play->block_table.block_x); - - if (x_diff >= 2 || block_z != play->block_table.block_z) { + if (ABS(block_x - play->block_table.block_x) >= 2 || block_z != play->block_table.block_z) { return FALSE; } + return TRUE; } @@ -123,11 +120,10 @@ static u32 mTRC_get_depart_time() { HOUR_MIN_SEC_TO_SECS(24, 19, 0) }; - int i = 0; - u32 depart_time; lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); u32 now_sec = mTRC_RTC_TIME_SECONDS(rtc_time); - int day; + u32 depart_time; + int i = 0; while (TRUE) { if (time_table[i] >= now_sec) { @@ -157,7 +153,11 @@ static void mTRC_mati_init() { pos.x = 2367.0f; pos.z = 740.0f; +#if VERSION >= VER_GAFU01_00 + pos.y = mRF_CheckFieldStep3() ? 300 : 180; +#else pos.y = 180.0f; +#endif Common_Set(train_position, pos); } @@ -175,7 +175,11 @@ static void mTRC_demo_init() { pos.x = 2037.0f; pos.z = 740.0f; +#if VERSION >= VER_GAFU01_00 + pos.y = mRF_CheckFieldStep3() ? 300 : 180; +#else pos.y = 180.0f; +#endif Common_Set(train_position, pos); } @@ -190,7 +194,11 @@ static void mTRC_call_init() { pos.x = 1904.0f; pos.z = 740.0f; +#if VERSION >= VER_GAFU01_00 + pos.y = mRF_CheckFieldStep3() ? 300 : 180; +#else pos.y = 180.0f; +#endif Common_Set(train_position, pos); } @@ -205,7 +213,11 @@ static void mTRC_norm_init() { pos.x = 320.0f; pos.z = 740.0f; +#if VERSION >= VER_GAFU01_00 + pos.y = mRF_CheckFieldStep3() ? 300 : 180; +#else pos.y = 180.0f; +#endif Common_Set(train_position, pos); } @@ -302,7 +314,7 @@ static void mTRC_trainControl(GAME_PLAY* play, int state) { } case mTRC_ACTION_BEGIN_SLOWDOWN: { - chase_f(&speed, mTRC_SLOW_SPEED, 0.01f); + chase_f(&speed, mTRC_SLOW_SPEED, mTRC_SLOW_RATE); if (pos.x > 2165.0f) { action = mTRC_ACTION_BEGIN_STOP; speed = mTRC_SLOW_SPEED; @@ -311,7 +323,7 @@ static void mTRC_trainControl(GAME_PLAY* play, int state) { } case mTRC_ACTION_BEGIN_STOP: { - chase_f(&speed, 0.0f, 0.005f); + chase_f(&speed, 0.0f, mTRC_STOP_RATE); if (fabsf(speed) < 0.008f) { signal = TRUE; timer = 48; @@ -361,7 +373,7 @@ static void mTRC_trainControl(GAME_PLAY* play, int state) { } case mTRC_ACTION_BEGIN_PULL_OUT: { - chase_f(&speed, mTRC_SLOW_SPEED, 0.00345f); + chase_f(&speed, mTRC_SLOW_SPEED, mTRC_START_RATE); if (timer == 0) { action = mTRC_ACTION_SPEED_UP; @@ -372,7 +384,7 @@ static void mTRC_trainControl(GAME_PLAY* play, int state) { } case mTRC_ACTION_SPEED_UP: { - chase_f(&speed, mTRC_FAST_SPEED, 0.00345); + chase_f(&speed, mTRC_FAST_SPEED, mTRC_SPEEDUP_RATE); if (pos.x > 4400.0f) { start_timer = mTRC_get_depart_time(); action = mTRC_ACTION_NONE; @@ -390,7 +402,7 @@ static void mTRC_trainControl(GAME_PLAY* play, int state) { } pos.x += 0.5f * speed; - mTRC_KishaStatusLevel(play, pos, speed); + mTRC_KishaStatusLevel(play, speed, pos); } if (now_state >= 0) { diff --git a/src/game/m_watch_my_step.c b/src/game/m_watch_my_step.c index 66414ac0..efc1d57f 100644 --- a/src/game/m_watch_my_step.c +++ b/src/game/m_watch_my_step.c @@ -249,7 +249,7 @@ extern void watch_my_step_draw(GAME_PLAY* play) { } case 4: { - int a = S_watch_my_step.opacity * 255.0f; + u8 a = S_watch_my_step.opacity * 255.0f; gDPSetPrimColor(font_gfx++, 0, a, 255, 255, 215, a); Matrix_push(); diff --git a/src/graph.c b/src/graph.c index 9d26720f..d2727890 100644 --- a/src/graph.c +++ b/src/graph.c @@ -34,257 +34,302 @@ u8 SoftResetEnable; #endif static int frame; // TODO: this is actually declared in graph_task_set00 -#define CONSTRUCT_THA_GA(tha_ga, name, name2) \ - (THA_GA_ct((tha_ga), sys_dynamic.##name, ##name2##_SIZE * sizeof(Gfx))) +#define CONSTRUCT_THA_GA(tha_ga, name, name2) (THA_GA_ct((tha_ga), sys_dynamic.##name, ##name2##_SIZE * sizeof(Gfx))) static void graph_setup_double_buffer(GRAPH* this) { - bzero(&sys_dynamic, sizeof(dynamic_t)); - sys_dynamic.start_magic = SYSDYNAMIC_START_MAGIC; - sys_dynamic.end_magic = SYSDYNAMIC_END_MAGIC; + bzero(&sys_dynamic, sizeof(dynamic_t)); + sys_dynamic.start_magic = SYSDYNAMIC_START_MAGIC; + sys_dynamic.end_magic = SYSDYNAMIC_END_MAGIC; - CONSTRUCT_THA_GA(&this->bg_opaque_thaga, new0, NEW0); - CONSTRUCT_THA_GA(&this->bg_translucent_thaga, new1, NEW1); - CONSTRUCT_THA_GA(&this->polygon_opaque_thaga, poly_opa, POLY_OPA); - CONSTRUCT_THA_GA(&this->polygon_translucent_thaga, poly_xlu, POLY_XLU); - CONSTRUCT_THA_GA(&this->overlay_thaga, overlay, OVERLAY); - CONSTRUCT_THA_GA(&this->work_thaga, work, WORK); - CONSTRUCT_THA_GA(&this->font_thaga, font, FONT); - CONSTRUCT_THA_GA(&this->shadow_thaga, shadow, SHADOW); - CONSTRUCT_THA_GA(&this->light_thaga, light, LIGHT); + CONSTRUCT_THA_GA(&this->bg_opaque_thaga, new0, NEW0); + CONSTRUCT_THA_GA(&this->bg_translucent_thaga, new1, NEW1); + CONSTRUCT_THA_GA(&this->polygon_opaque_thaga, poly_opa, POLY_OPA); + CONSTRUCT_THA_GA(&this->polygon_translucent_thaga, poly_xlu, POLY_XLU); + CONSTRUCT_THA_GA(&this->overlay_thaga, overlay, OVERLAY); + CONSTRUCT_THA_GA(&this->work_thaga, work, WORK); + CONSTRUCT_THA_GA(&this->font_thaga, font, FONT); + CONSTRUCT_THA_GA(&this->shadow_thaga, shadow, SHADOW); + CONSTRUCT_THA_GA(&this->light_thaga, light, LIGHT); - this->Gfx_list10 = sys_dynamic.new0; - this->Gfx_list11 = sys_dynamic.new1; - this->Gfx_list00 = sys_dynamic.poly_opa; - this->Gfx_list01 = sys_dynamic.poly_xlu; - this->Gfx_list04 = sys_dynamic.overlay; - this->Gfx_list05 = sys_dynamic.work; - this->Gfx_list07 = sys_dynamic.font; - this->Gfx_list08 = sys_dynamic.shadow; - this->Gfx_list09 = sys_dynamic.light; + this->Gfx_list10 = sys_dynamic.new0; + this->Gfx_list11 = sys_dynamic.new1; + this->Gfx_list00 = sys_dynamic.poly_opa; + this->Gfx_list01 = sys_dynamic.poly_xlu; + this->Gfx_list04 = sys_dynamic.overlay; + this->Gfx_list05 = sys_dynamic.work; + this->Gfx_list07 = sys_dynamic.font; + this->Gfx_list08 = sys_dynamic.shadow; + this->Gfx_list09 = sys_dynamic.light; - this->gfxsave = NULL; + this->gfxsave = NULL; } -#define ARE_INIT_PROCS_EQUAL(proc0, proc1) \ - (((void (*)(GAME*))proc0) == ((void (*)(GAME*))proc1)) +#define ARE_INIT_PROCS_EQUAL(proc0, proc1) (((void (*)(GAME*))proc0) == ((void (*)(GAME*))proc1)) static DLFTBL_GAME* game_get_next_game_dlftbl(GAME* game) { - void (*next_game_init_proc)(GAME*) = game_get_next_game_init(game); + void (*next_game_init_proc)(GAME*) = game_get_next_game_init(game); - if (ARE_INIT_PROCS_EQUAL(next_game_init_proc, first_game_init)) { - return &game_dlftbls[0]; - } else if (ARE_INIT_PROCS_EQUAL(next_game_init_proc, select_init)) { - return &game_dlftbls[1]; - } else if (ARE_INIT_PROCS_EQUAL(next_game_init_proc, play_init)) { - return &game_dlftbls[2]; - } else if (ARE_INIT_PROCS_EQUAL(next_game_init_proc, second_game_init)) { - return &game_dlftbls[3]; - } else if (ARE_INIT_PROCS_EQUAL(next_game_init_proc, trademark_init)) { - return &game_dlftbls[5]; - } else if (ARE_INIT_PROCS_EQUAL(next_game_init_proc, player_select_init)) { - return &game_dlftbls[6]; - } else if (ARE_INIT_PROCS_EQUAL(next_game_init_proc, save_menu_init)) { - return &game_dlftbls[7]; - } else if (ARE_INIT_PROCS_EQUAL(next_game_init_proc, famicom_emu_init)) { - return &game_dlftbls[8]; - } else if (ARE_INIT_PROCS_EQUAL(next_game_init_proc, prenmi_init)) { - return &game_dlftbls[9]; - } + if (ARE_INIT_PROCS_EQUAL(next_game_init_proc, first_game_init)) { + return &game_dlftbls[0]; + } else if (ARE_INIT_PROCS_EQUAL(next_game_init_proc, select_init)) { + return &game_dlftbls[1]; + } else if (ARE_INIT_PROCS_EQUAL(next_game_init_proc, play_init)) { + return &game_dlftbls[2]; + } else if (ARE_INIT_PROCS_EQUAL(next_game_init_proc, second_game_init)) { + return &game_dlftbls[3]; + } else if (ARE_INIT_PROCS_EQUAL(next_game_init_proc, trademark_init)) { + return &game_dlftbls[5]; + } else if (ARE_INIT_PROCS_EQUAL(next_game_init_proc, player_select_init)) { + return &game_dlftbls[6]; + } else if (ARE_INIT_PROCS_EQUAL(next_game_init_proc, save_menu_init)) { + return &game_dlftbls[7]; + } else if (ARE_INIT_PROCS_EQUAL(next_game_init_proc, famicom_emu_init)) { + return &game_dlftbls[8]; + } else if (ARE_INIT_PROCS_EQUAL(next_game_init_proc, prenmi_init)) { + return &game_dlftbls[9]; + } - return NULL; + return NULL; } extern void graph_ct(GRAPH* this) { - bzero(this, sizeof(GRAPH)); - this->frame_counter = 0; - this->cfb_bank = 0; - SETREG(SREG, 33, GETREG(SREG, 33) & ~2); - SETREG(SREG, 33, GETREG(SREG, 33) & ~1); - zurumode_init(); - GRAPH_SET_DOING_POINT(this, CT); + bzero(this, sizeof(GRAPH)); + this->frame_counter = 0; + this->cfb_bank = 0; + SETREG(SREG, 33, GETREG(SREG, 33) & ~2); + SETREG(SREG, 33, GETREG(SREG, 33) & ~1); + zurumode_init(); + GRAPH_SET_DOING_POINT(this, CT); } extern void graph_dt(GRAPH* this) { - GRAPH_SET_DOING_POINT(this, DT); - zurumode_cleanup(); + GRAPH_SET_DOING_POINT(this, DT); + zurumode_cleanup(); } static void graph_task_set00(GRAPH* this) { - ucode_info ucode[2]; - - GRAPH_SET_DOING_POINT(this, WAIT_TASK); - GRAPH_SET_DOING_POINT(this, WAIT_TASK_FINISHED); - if (ResetStatus < IRQ_RESET_DELAY) { - this->last_dl = this->Gfx_list05; - if (this->taskEndCallback != NULL) { - this->taskEndCallback(this, this->taskEndData); - } + ucode_info ucode[2]; + GRAPH_SET_DOING_POINT(this, WAIT_TASK); + GRAPH_SET_DOING_POINT(this, WAIT_TASK_FINISHED); if (ResetStatus < IRQ_RESET_DELAY) { - ucode[0].type = UCODE_TYPE_POLY_TEXT; - ucode[1].type = UCODE_TYPE_SPRITE_TEXT; - ucode[0].ucode_p = ucode_GetPolyTextStart(); - ucode[1].ucode_p = ucode_GetSpriteTextStart(); - JW_BeginFrame(); - emu64_init(); - emu64_set_ucode_info(2, ucode); - emu64_set_first_ucode(ucode[0].ucode_p); - emu64_taskstart(this->Gfx_list05); /* work data */ - emu64_cleanup(); - JW_EndFrame(); - frame++; + this->last_dl = this->Gfx_list05; + if (this->taskEndCallback != NULL) { + this->taskEndCallback(this, this->taskEndData); + } + + if (ResetStatus < IRQ_RESET_DELAY) { + ucode[0].type = UCODE_TYPE_POLY_TEXT; + ucode[1].type = UCODE_TYPE_SPRITE_TEXT; + ucode[0].ucode_p = ucode_GetPolyTextStart(); + ucode[1].ucode_p = ucode_GetSpriteTextStart(); + JW_BeginFrame(); + emu64_init(); + emu64_set_ucode_info(2, ucode); + emu64_set_first_ucode(ucode[0].ucode_p); + emu64_taskstart(this->Gfx_list05); /* work data */ + emu64_cleanup(); + JW_EndFrame(); + frame++; + } } - } } static int graph_draw_finish(GRAPH* this) { - int err; - OPEN_DISP(this); + int err; + OPEN_DISP(this); - gSPBranchList(NOW_WORK_DISP++, this->Gfx_list10); - gSPBranchList(NOW_BG_OPA_DISP++, this->Gfx_list08); - gSPBranchList(NOW_SHADOW_DISP++, this->Gfx_list11); - gSPBranchList(NOW_BG_XLU_DISP++, this->Gfx_list00); - gSPBranchList(NOW_POLY_OPA_DISP++, this->Gfx_list01); - gSPBranchList(NOW_POLY_XLU_DISP++, this->Gfx_list09); - gSPBranchList(NOW_LIGHT_DISP++, this->Gfx_list07); - gSPBranchList(NOW_FONT_DISP++, this->Gfx_list04); - gDPPipeSync(NOW_OVERLAY_DISP++); - gDPFullSync(NOW_OVERLAY_DISP++); - gSPEndDisplayList(NOW_OVERLAY_DISP++); + gSPBranchList(NOW_WORK_DISP++, this->Gfx_list10); + gSPBranchList(NOW_BG_OPA_DISP++, this->Gfx_list08); + gSPBranchList(NOW_SHADOW_DISP++, this->Gfx_list11); + gSPBranchList(NOW_BG_XLU_DISP++, this->Gfx_list00); + gSPBranchList(NOW_POLY_OPA_DISP++, this->Gfx_list01); + gSPBranchList(NOW_POLY_XLU_DISP++, this->Gfx_list09); + gSPBranchList(NOW_LIGHT_DISP++, this->Gfx_list07); + gSPBranchList(NOW_FONT_DISP++, this->Gfx_list04); + gDPPipeSync(NOW_OVERLAY_DISP++); + gDPFullSync(NOW_OVERLAY_DISP++); + gSPEndDisplayList(NOW_OVERLAY_DISP++); - CLOSE_DISP(this); - err = FALSE; + CLOSE_DISP(this); + err = FALSE; - SYSDYNAMIC_OPEN(); - if (!SYSDYNAMIC_CHECK_START()) { - _dbg_hungup(__FILE__, 417); - } + SYSDYNAMIC_OPEN(); + if (!SYSDYNAMIC_CHECK_START()) { +#if VERSION == VER_GAFU01_00 + _dbg_hungup(__FILE__, 416); +#elif VERSION == VER_GAFE01_00 + _dbg_hungup(__FILE__, 417); +#endif + } - if (!SYSDYNAMIC_CHECK_END()) { - err = TRUE; - _dbg_hungup(__FILE__, 425); - } - SYSDYNAMIC_CLOSE(); + if (!SYSDYNAMIC_CHECK_END()) { + err = TRUE; +#if VERSION == VER_GAFU01_00 + _dbg_hungup(__FILE__, 424); +#elif VERSION == VER_GAFE01_00 + _dbg_hungup(__FILE__, 425); +#endif + } + SYSDYNAMIC_CLOSE(); - if (THA_GA_isCrash(&this->polygon_opaque_thaga)) { - err = TRUE; - } + if (THA_GA_isCrash(&this->polygon_opaque_thaga)) { + err = TRUE; + } - if (THA_GA_isCrash(&this->polygon_translucent_thaga)) { - err = TRUE; - } + if (THA_GA_isCrash(&this->polygon_translucent_thaga)) { + err = TRUE; + } - if (THA_GA_isCrash(&this->overlay_thaga)) { - err = TRUE; - } + if (THA_GA_isCrash(&this->overlay_thaga)) { + err = TRUE; + } - if (THA_GA_isCrash(&this->font_thaga)) { - err = TRUE; - } + if (THA_GA_isCrash(&this->font_thaga)) { + err = TRUE; + } - if (THA_GA_isCrash(&this->shadow_thaga)) { - err = TRUE; - } + if (THA_GA_isCrash(&this->shadow_thaga)) { + err = TRUE; + } - if (THA_GA_isCrash(&this->light_thaga)) { - err = TRUE; - } + if (THA_GA_isCrash(&this->light_thaga)) { + err = TRUE; + } - if (THA_GA_isCrash(&this->bg_opaque_thaga)) { - err = TRUE; - } + if (THA_GA_isCrash(&this->bg_opaque_thaga)) { + err = TRUE; + } - if (THA_GA_isCrash(&this->bg_translucent_thaga)) { - err = TRUE; - } + if (THA_GA_isCrash(&this->bg_translucent_thaga)) { + err = TRUE; + } - return err; + return err; } static void do_soft_reset(GAME* game) { - SoftResetEnable = FALSE; - mBGM_reset(); - mVibctl_reset(); - sAdo_SoftReset(); - ResetTime = osGetTime(); - ResetStatus = IRQ_RESET_PRENMI; + SoftResetEnable = FALSE; + mBGM_reset(); + mVibctl_reset(); + sAdo_SoftReset(); + ResetTime = osGetTime(); + ResetStatus = IRQ_RESET_PRENMI; } static void reset_check(GRAPH* this, GAME* game) { - if (SoftResetEnable && osShutdown) { - do_soft_reset(game); - } -} - -static void graph_main(GRAPH* this, GAME* game) { - game->disable_prenmi = FALSE; - graph_setup_double_buffer(this); - game_get_controller(game); - game->disable_display = FALSE; - GRAPH_SET_DOING_POINT(this, GAME_MAIN); - game_main(game); - GRAPH_SET_DOING_POINT(this, GAME_MAIN_FINISHED); - if (ResetStatus < IRQ_RESET_DELAY) { - if (skip_frame < GETREG(SREG, 3)) { - skip_frame++; - this->frame_counter++; - } else if (game->disable_display == FALSE) { - skip_frame = 0; - if (graph_draw_finish(this) == FALSE) { - GRAPH_SET_DOING_POINT(this, TASK_SET); - graph_task_set00(this); - GRAPH_SET_DOING_POINT(this, TASK_SET_FINISHED); - this->frame_counter++; - - if ((GETREG(SREG, 33) & 1) != 0) { - SETREG(SREG, 33, GETREG(SREG, 33) & ~1); - } - } + if (SoftResetEnable && osShutdown) { + do_soft_reset(game); } - } - - if (GETREG(SREG, 20) < 2) { - GRAPH_SET_DOING_POINT(this, AUDIO); - sAdo_GameFrame(); - GRAPH_SET_DOING_POINT(this, AUDIO_FINISHED); - } - - reset_check(this, game); - - if (ResetStatus == IRQ_RESET_PRENMI && game->disable_prenmi == FALSE) { - GAME_GOTO_NEXT(game, prenmi, PRENMI); - } } +// Aus version removes debug frame skip logic +#if VERSION >= VER_GAFU01_00 +static void graph_main(GRAPH* this, GAME* game) { + game->disable_prenmi = FALSE; + graph_setup_double_buffer(this); + game_get_controller(game); + game->disable_display = FALSE; + GRAPH_SET_DOING_POINT(this, GAME_MAIN); + game_main(game); + GRAPH_SET_DOING_POINT(this, GAME_MAIN_FINISHED); + if (ResetStatus < IRQ_RESET_DELAY) { + if (game->disable_display == FALSE) { + if (graph_draw_finish(this) == FALSE) { + GRAPH_SET_DOING_POINT(this, TASK_SET); + graph_task_set00(this); + GRAPH_SET_DOING_POINT(this, TASK_SET_FINISHED); + this->frame_counter++; + + if ((GETREG(SREG, 33) & 1) != 0) { + SETREG(SREG, 33, GETREG(SREG, 33) & ~1); + } + } + } + } + + if (GETREG(SREG, 20) < 2) { + GRAPH_SET_DOING_POINT(this, AUDIO); + sAdo_GameFrame(); + GRAPH_SET_DOING_POINT(this, AUDIO_FINISHED); + } + + reset_check(this, game); + + if (ResetStatus == IRQ_RESET_PRENMI && game->disable_prenmi == FALSE) { + GAME_GOTO_NEXT(game, prenmi, PRENMI); + } +} +#else +static void graph_main(GRAPH* this, GAME* game) { + game->disable_prenmi = FALSE; + graph_setup_double_buffer(this); + game_get_controller(game); + game->disable_display = FALSE; + GRAPH_SET_DOING_POINT(this, GAME_MAIN); + game_main(game); + GRAPH_SET_DOING_POINT(this, GAME_MAIN_FINISHED); + if (ResetStatus < IRQ_RESET_DELAY) { + if (skip_frame < GETREG(SREG, 3)) { + skip_frame++; + this->frame_counter++; + } else if (game->disable_display == FALSE) { + skip_frame = 0; + if (graph_draw_finish(this) == FALSE) { + GRAPH_SET_DOING_POINT(this, TASK_SET); + graph_task_set00(this); + GRAPH_SET_DOING_POINT(this, TASK_SET_FINISHED); + this->frame_counter++; + + if ((GETREG(SREG, 33) & 1) != 0) { + SETREG(SREG, 33, GETREG(SREG, 33) & ~1); + } + } + } + } + + if (GETREG(SREG, 20) < 2) { + GRAPH_SET_DOING_POINT(this, AUDIO); + sAdo_GameFrame(); + GRAPH_SET_DOING_POINT(this, AUDIO_FINISHED); + } + + reset_check(this, game); + + if (ResetStatus == IRQ_RESET_PRENMI && game->disable_prenmi == FALSE) { + GAME_GOTO_NEXT(game, prenmi, PRENMI); + } +} +#endif + extern void graph_proc(void* arg) { - GRAPH* __graph = &graph_class; - DLFTBL_GAME* dlftbl = &game_dlftbls[0]; - graph_ct(&graph_class); + GRAPH* __graph = &graph_class; + DLFTBL_GAME* dlftbl = &game_dlftbls[0]; + graph_ct(&graph_class); - while (dlftbl != NULL) { - size_t size = dlftbl->alloc_size; - GAME* game = (GAME*)malloc(size); - game_class_p = game; - bzero(game, size); - GRAPH_SET_DOING_POINT(__graph, GAME_CT); - game_ct(game, dlftbl->init, __graph); - emu64_refresh(); - GRAPH_SET_DOING_POINT(__graph, GAME_CT_FINISHED); + while (dlftbl != NULL) { + size_t size = dlftbl->alloc_size; + GAME* game = (GAME*)malloc(size); + game_class_p = game; + bzero(game, size); + GRAPH_SET_DOING_POINT(__graph, GAME_CT); + game_ct(game, dlftbl->init, __graph); + emu64_refresh(); + GRAPH_SET_DOING_POINT(__graph, GAME_CT_FINISHED); - while (game_is_doing(game)) { - if (!dvderr_draw()) { - graph_main(__graph, game); - } + while (game_is_doing(game)) { + if (!dvderr_draw()) { + graph_main(__graph, game); + } + } + + dlftbl = game_get_next_game_dlftbl(game); + GRAPH_SET_DOING_POINT(__graph, GAME_18); + GRAPH_SET_DOING_POINT(__graph, GAME_DT); + game_dt(game); + GRAPH_SET_DOING_POINT(__graph, GAME_DT_FINISHED); + free(game); + game_class_p = NULL; } - dlftbl = game_get_next_game_dlftbl(game); - GRAPH_SET_DOING_POINT(__graph, GAME_18); - GRAPH_SET_DOING_POINT(__graph, GAME_DT); - game_dt(game); - GRAPH_SET_DOING_POINT(__graph, GAME_DT_FINISHED); - free(game); - game_class_p = NULL; - } - - graph_dt(__graph); + graph_dt(__graph); } diff --git a/src/lb_reki.c b/src/lb_reki.c index 4d25f7b1..fe69e5be 100644 --- a/src/lb_reki.c +++ b/src/lb_reki.c @@ -218,7 +218,7 @@ static int lbRk_KyuurekiDays(int year, int month) { * @param kyuu_ymd The input date in the kyuureki calendar. * @return TRUE if the conversion is successful, FALSE if the input date is invalid. */ -extern int lbRk_ToSeiyouReki(lbRTC_ymd_c* seiyo_ymd, const lbRTC_ymd_c* kyuu_ymd) { +extern int lbRk_ToSeiyouReki(lbRTC_ymd_c* seiyo_ymd, lbRTC_ymd_c* kyuu_ymd) { int seireki_days; int year; int month; @@ -275,7 +275,7 @@ extern int lbRk_ToSeiyouReki(lbRTC_ymd_c* seiyo_ymd, const lbRTC_ymd_c* kyuu_ymd * @param seiyo_ymd The input date in the Gregorian calendar. * @return TRUE if the conversion is successful, FALSE if the input date is invalid. */ -extern int lbRk_ToKyuuReki(lbRTC_ymd_c* kyuu_ymd, const lbRTC_ymd_c* seiyo_ymd) { +extern int lbRk_ToKyuuReki(lbRTC_ymd_c* kyuu_ymd, lbRTC_ymd_c* seiyo_ymd) { lbRTC_ymd_c kyuu_date = (lbRTC_ymd_c){lbRk_YEAR_MIN, lbRk_KYUU_MONTH_START, lbRk_KYUU_DAY_START}; lbRTC_ymd_c seyio_date; diff --git a/src/save_check.c_inc b/src/save_check.c_inc index 77e87c6b..d151c388 100644 --- a/src/save_check.c_inc +++ b/src/save_check.c_inc @@ -542,8 +542,8 @@ static int sChk_MaskCat_c_sub(MaskCat_c* mask_cat, int depth) { } static int sChk_check_save_data() { - int res = FALSE; Save_t* save = Common_GetPointer(save.save); + int res = FALSE; int i; for (i = 0; i < mHS_HOUSE_NUM; i++) { diff --git a/src/save_check_NSW.c_inc b/src/save_check_NSW.c_inc index 79922dec..e91611f1 100644 --- a/src/save_check_NSW.c_inc +++ b/src/save_check_NSW.c_inc @@ -98,9 +98,9 @@ static int sCck_CheckSaveData_nw_visitor_NSW(Private_c* priv) { static int sCck_CheckSaveData_my_org_no_table_NSW(Private_c* priv) { u8 my_org_no; int field = 0; + int i; int total = 0; u8* my_org_no_table = priv->my_org_no_table; - int i; int res; for (i = 0; i < mPr_ORIGINAL_DESIGN_COUNT; i++) { diff --git a/src/save_check_take.c_inc b/src/save_check_take.c_inc index 7539ded3..18410844 100644 --- a/src/save_check_take.c_inc +++ b/src/save_check_take.c_inc @@ -2,88 +2,86 @@ #include "m_font.h" static int sChk_board_save_check() { - mNtc_board_post_c* board = Save_Get(noticeboard); - int max = mNtc_notice_write_num(); - int i; - int j; - - for (i = 0; i < max; i++) { - u8* msg = board->message; - if (lbRTC_time_c_save_data_check(&board->post_time)) { - mFRm_ERRORLINE(65); - return TRUE; + mNtc_board_post_c* board = Save_Get(noticeboard); + int max = mNtc_notice_write_num(); + int i; + int j; + + for (i = 0; i < max; i++) { + u8* msg = board->message; + if (lbRTC_time_c_save_data_check(&board->post_time)) { + mFRm_ERRORLINE(65); + return TRUE; + } + + for (j = 0; j < MAIL_BODY_LEN; j++) { + if (mFont_char_save_data_check(msg[0])) { + mFRm_ERRORLINE(73); + return TRUE; + } + + msg++; + } + + board++; } - for (j = 0; j < MAIL_BODY_LEN; j++) { - if (mFont_char_save_data_check(msg[0])) { - mFRm_ERRORLINE(73); - return TRUE; - } - - msg++; - } - - board++; - } - - return FALSE; + return FALSE; } static int sChk_weather_save_check() { - u32 weather = mEnv_SAVE_GET_WEATHER_TYPE(Save_Get(weather)); - u32 intensity = mEnv_SAVE_GET_WEATHER_INTENSITY(Save_Get(weather)); - - if (intensity >= mEnv_WEATHER_INTENSITY_NUM || weather >= mEnv_WEATHER_LEAVES) { - mFRm_ERRORLINE(141); - return TRUE; - } - else { - return FALSE; - } + u32 weather = mEnv_SAVE_GET_WEATHER_TYPE(Save_Get(weather)); + u32 intensity = mEnv_SAVE_GET_WEATHER_INTENSITY(Save_Get(weather)); + + if (intensity >= mEnv_WEATHER_INTENSITY_NUM || weather >= mEnv_WEATHER_LEAVES) { + mFRm_ERRORLINE(141); + return TRUE; + } else { + return FALSE; + } } +// TODO: fakematch static int sChk_snowman_save_check() { - u8 year; - u8 month; - u8 day; - u8 hour; - mSN_snowman_save_c* data = Save_GetPointer(snowmen); +#if VERSION != VER_GAFE01_00 + mSN_snowman_save_c* data = Save_GetPointer(snowmen); +#endif + u8 year; + u8 month; + u8 day; + u8 hour; +#if VERSION == VER_GAFE01_00 + mSN_snowman_save_c* data = Save_GetPointer(snowmen); +#endif - year = Save_Get(snowman_year); - month = Save_Get(snowman_month); - day = Save_Get(snowman_day); - hour = Save_Get(snowman_hour); - - if ( - year > GAME_YEAR_MAX - 1 || - month > lbRTC_DECEMBER || - day > 31 || - hour >= 24 - ) { - mFRm_ERRORLINE(168); - return TRUE; - } - else { - int i; + year = Save_Get(snowman_year); + month = Save_Get(snowman_month); + day = Save_Get(snowman_day); + hour = Save_Get(snowman_hour); - for (i = 0; i < mSN_SAVE_COUNT; i++) { - mSN_snowman_data_c* data2 = data->snowmen_data + i; - - if (data2->score >= 4 || data2->exists > 1) { - mFRm_ERRORLINE(179); + if (year > GAME_YEAR_MAX - 1 || month > lbRTC_DECEMBER || day > 31 || hour >= 24) { + mFRm_ERRORLINE(168); return TRUE; - } - } - } + } else { + int i; - return FALSE; + for (i = 0; i < mSN_SAVE_COUNT; i++) { + mSN_snowman_data_c* data2 = data->snowmen_data + i; + + if (data2->score >= 4 || data2->exists > 1) { + mFRm_ERRORLINE(179); + return TRUE; + } + } + } + + return FALSE; } static int sChk_check_save_take() { - if (sChk_snowman_save_check() || sChk_board_save_check() || sChk_weather_save_check()) { - return TRUE; - } - else { - return FALSE; - } + if (sChk_snowman_save_check() || sChk_board_save_check() || sChk_weather_save_check()) { + return TRUE; + } else { + return FALSE; + } } diff --git a/src/save_menu.c b/src/save_menu.c index f18298d5..c16fd0f4 100644 --- a/src/save_menu.c +++ b/src/save_menu.c @@ -226,17 +226,17 @@ extern void save_menu_cleanup(GAME* game) { } extern void save_menu_init(GAME* game) { - GRAPH* g = game->graph; - View* view; GAME_SAVE_MENU* save_menu = (GAME_SAVE_MENU*)game; + View* view = &save_menu->view; + GRAPH* g = game->graph; int i; game->exec = &save_menu_main; game->cleanup = &save_menu_cleanup; - view = &save_menu->view; initView(view, g); view->flag = VIEW_UPDATE_ORTHOGRAPHIC; + new_Matrix(game); SetGameFrame(1); diff --git a/src/system/sys_math3d.c b/src/system/sys_math3d.c index 6adb5669..5fc54ad4 100644 --- a/src/system/sys_math3d.c +++ b/src/system/sys_math3d.c @@ -167,7 +167,7 @@ extern f32 Math3DLengthSquare(xyz_t* a, xyz_t* b) { return Math3DVecLengthSquare(&d); } -extern f32 Math3DLength(xyz_t* a, xyz_t* b) { +extern f32 Math3DLength(const xyz_t* a, const xyz_t* b) { return search_position_distance(a, b); } @@ -180,7 +180,7 @@ static f32 Math3DLength_s_f(s_xyz* a, xyz_t* b) { return Math3DVecLength(&d); } -extern void Math3DVectorProduct2Vec(const xyz_t* a, xyz_t* b, xyz_t* ret) { +extern void Math3DVectorProduct2Vec(const xyz_t* a, const xyz_t* b, xyz_t* ret) { ret->x = (a->y * b->z) - (a->z * b->y); ret->y = (a->z * b->x) - (a->x * b->z); ret->z = (a->x * b->y) - (a->y * b->x); @@ -252,16 +252,16 @@ FORCESTRIP xyz_t* _bss_func03() { } #endif -extern f32 Math3DPlaneFunc(f32 nox, f32 noy, f32 noz, f32 odist, xyz_t* pl) { +extern f32 Math3DPlaneFunc(f32 nox, f32 noy, f32 noz, f32 odist, const xyz_t* pl) { return ((nox * pl->x) + (noy * pl->y) + (noz * pl->z) + odist); } -extern f32 Math3DLengthPlaneAndPos(f32 nox, f32 noy, f32 noz, f32 odist, xyz_t* pl) { +extern f32 Math3DLengthPlaneAndPos(f32 nox, f32 noy, f32 noz, f32 odist, const xyz_t* pl) { f32 res = fabsf(Math3DSignedLengthPlaneAndPos(nox, noy, noz, odist, pl)); return res; } -extern f32 Math3DSignedLengthPlaneAndPos(f32 nox, f32 noy, f32 noz, f32 odist, xyz_t* pl) { +extern f32 Math3DSignedLengthPlaneAndPos(f32 nox, f32 noy, f32 noz, f32 odist, const xyz_t* pl) { f32 nm; @@ -323,7 +323,7 @@ extern int Math3DTriangleCrossYLine_scope(xyz_t* v0, xyz_t* v1, xyz_t* v2, f32 n f32 x, f32* yint, f32 y0, f32 y1) { xyz_t pl; f32 das, dbs; - if ((float)__fabs(noy) < 0.008f) { + if (F32_IS_ZERO(noy)) { return 0; } @@ -414,7 +414,7 @@ extern int Math3DTriangleCrossZCheck_general(xyz_t* v0, xyz_t* v1, xyz_t* v2, f3 return 1; } - if ((float)__fabs(noz) > 0.5f) { + if (fabsf(noz) > 0.5f) { if (Math3D_pointVsLineSegmentLengthSquare2D(x, y, v0->x, v0->y, v1->x, v1->y, &edge) && (edge < dist_sq)) { return 1; } @@ -451,7 +451,7 @@ extern int Math3D_pointVsLineSegmentLengthSquare2D(f32 x0, f32 y0, f32 x1, f32 y d = (diffx * diffx) + (diffy * diffy); - if ((float)__fabs(d) < 0.008f) { + if (F32_IS_ZERO(d)) { *lsq = 0; return 0; } @@ -471,21 +471,21 @@ extern int Math3D_pointVsLineSegmentLengthSquare2D(f32 x0, f32 y0, f32 x1, f32 y extern int Math3D_sphereCrossLineSegment(Math3D_sphere_c* s, Math3D_linef_c* l) { static xyz_t h; f32 lc; - f32 delta_sq; xyz_t linediff; - + f32 r_sq; f32 cen_x_sq; f32 cen_y_sq; f32 cen_z_sq; - + f32 ofs_x; f32 ofs_y; f32 ofs_z; - + f32 x; f32 y; f32 z; + f32 delta_sq; if ((Math3D_sphereCollisionPoint(s, &l->a)) || Math3D_sphereCollisionPoint(s, &l->b)) { return 1; @@ -648,6 +648,33 @@ extern int Math3D_pipeVsPos(Math3D_pipe_c* c, xyz_t* p) { } extern int Math3D_pipeCrossLine(Math3D_pipe_c* c, xyz_t* la, xyz_t* lb, xyz_t* ia, xyz_t* ib) { +#if VERSION >= VER_GAFU01_00 + int sa; + int sb; + int i; + int co; + int f = 0; + xyz_t ca; + xyz_t cb; + xyz_t ab; + xyz_t intpos[4]; + f32 z = 0.0f; + f32 fb; + f32 bix; + f32 biz; + f32 tix; + f32 tiz; + f32 iba; + f32 ibd; + f32 t2; + f32 fa = 0.0f; + f32 fba = 0.0f; + f32 t; + f32 rsqd; + f32 t3; + f32 rsq; + f32 dc; +#else f32 z = 0.0f; int f = 0; int sa, sb, i, co; @@ -667,6 +694,7 @@ extern int Math3D_pipeCrossLine(Math3D_pipe_c* c, xyz_t* la, xyz_t* lb, xyz_t* i f32 t3; f32 rsq; f32 dc; +#endif if (Math3D_pipeVsPos(c, la) && Math3D_pipeVsPos(c, lb)) { *ia = *la;