From bfea3513e6e848cb55160b134740a83f3d98fb57 Mon Sep 17 00:00:00 2001 From: Cuyler36 <24523422+Cuyler36@users.noreply.github.com> Date: Thu, 4 Jul 2024 17:52:37 -0400 Subject: [PATCH] Improve ac_train_door, ac_train_window & rename private --- include/ac_train_door.h | 20 +- include/ac_train_window.h | 6 +- include/audio_defs.h | 3 + include/m_common_data.h | 2 +- src/ac_animal_logo_misc.c | 4 +- src/ac_douzou_move.c_inc | 4 +- src/ac_haniwa_move.c_inc | 2 +- src/ac_museum_fossil.c | 7 +- src/ac_museum_picture.c | 2 +- src/ac_my_house_draw.c_inc | 4 +- src/ac_npc_curator_move.c_inc | 1524 +++++------ src/ac_npc_rcn_guide_move.c_inc | 2 +- src/ac_train_door.c | 47 +- src/ac_train_window.c | 638 +++-- src/ftr/ac_myfmanekin.c | 4 +- src/ftr/ac_myfumbrella.c | 4 +- src/m_all_grow_ovl.c | 2 +- src/m_calendar.c | 613 +++-- src/m_event.c | 4207 +++++++++++++++---------------- src/m_home.c | 714 +++--- src/m_house.c | 108 +- src/m_mail.c | 451 ++-- src/m_map_ovl.c | 1614 +++++------- src/m_museum.c | 983 ++++---- src/m_needlework.c | 372 ++- src/m_npc.c | 16 +- src/m_post_office.c | 819 +++--- src/m_private.c | 2026 ++++++++------- src/m_quest.c | 4 +- src/m_room_type.c | 4 +- src/m_shop.c | 3990 ++++++++++++++--------------- src/m_start_data_init.c | 8 +- src/m_trademark.c | 538 ++-- src/player_select.c | 414 ++- src/save_check_MYK.c_inc | 2 +- src/save_check_NSW.c_inc | 335 ++- src/save_check_YSD.c_inc | 123 +- src/save_check_komatu.c_inc | 134 +- src/save_menu.c | 330 ++- 39 files changed, 9460 insertions(+), 10620 deletions(-) diff --git a/include/ac_train_door.h b/include/ac_train_door.h index 59d630fd..e783d6b8 100644 --- a/include/ac_train_door.h +++ b/include/ac_train_door.h @@ -9,18 +9,17 @@ extern "C" { #endif +#define aTRD_JOINT_NUM 5 typedef struct traindoor_s { - ACTOR actor_class; - u8 pad [0x17C - 0x174]; - cKF_SkeletonInfo_R_c keyframe; - u8 pad2 [0x210 - 0x1ed]; - s_xyz work; - u8 pad3 [0x22e - 0x216]; - s_xyz target; - u8 pad4[0x24c - 0x234]; - int idle; -}TRAINDOOR_ACTOR; + /* 0x000 */ ACTOR actor_class; + /* 0x178 */ u8 pad[0x17C - 0x174]; + /* 0x17C */ cKF_SkeletonInfo_R_c keyframe; + /* 0x1EC */ u8 pad2[0x210 - 0x1EC]; + /* 0x210 */ s_xyz work[aTRD_JOINT_NUM]; + /* 0x22E */ s_xyz target[aTRD_JOINT_NUM]; + /* 0x24C */ int open_flag; +} TRAINDOOR_ACTOR; extern ACTOR_PROFILE TrainDoor_Profile; @@ -29,4 +28,3 @@ extern ACTOR_PROFILE TrainDoor_Profile; #endif #endif - diff --git a/include/ac_train_window.h b/include/ac_train_window.h index 8fd831d6..dd3b80ba 100644 --- a/include/ac_train_window.h +++ b/include/ac_train_window.h @@ -15,8 +15,7 @@ typedef int (*TRAIN_WINDOW_DRAW_TYPE)(ACTOR*, GAME*); #define CRV_DEBUG_GREEN_VALUE 89 #define CRV_DEBUG_BLUE_VALUE 90 - -typedef struct train_window_s{ +typedef struct train_window_s { ACTOR actor_class; TRAIN_WINDOW_DRAW_TYPE draw_type; s16 pallete_id; @@ -34,7 +33,7 @@ typedef struct train_window_s{ f32 scroll_speed; s_xyz pos; f32 lod_factor; -}TRAIN_WINDOW_ACTOR; +} TRAIN_WINDOW_ACTOR; extern ACTOR_PROFILE Train_Window_Profile; @@ -43,4 +42,3 @@ extern ACTOR_PROFILE Train_Window_Profile; #endif #endif - diff --git a/include/audio_defs.h b/include/audio_defs.h index b7061c33..d24a07ab 100644 --- a/include/audio_defs.h +++ b/include/audio_defs.h @@ -115,6 +115,9 @@ typedef enum audio_sound_effects { NA_SE_TOILE_CHAIR_SIT = 0x410, + NA_SE_TRAINDOOR0 = 0x412, + NA_SE_TRAINDOOR1, + NA_SE_BED_IN = 0x415, NA_SE_BED_NEGAERI, NA_SE_BED_OUT, diff --git a/include/m_common_data.h b/include/m_common_data.h index 43a32fb7..721a54af 100644 --- a/include/m_common_data.h +++ b/include/m_common_data.h @@ -86,7 +86,7 @@ typedef struct Save_s { /* 0x00001A */ u16 copy_protect; /* 'unique' value between [1, 65520] used for copy protection (see mCD_get_land_copyProtect) */ /* 0x00001C */ u8 pad_1C[4]; - /* 0x000020 */ Private_c private[PLAYER_NUM]; /* player data */ + /* 0x000020 */ Private_c private_data[PLAYER_NUM]; /* player data */ /* 0x009120 */ mLd_land_info_c land_info; /* town name & id */ /* 0x00912C */ mNtc_board_post_c noticeboard[mNtc_BOARD_POST_COUNT]; /* noticeboard posts */ /* 0x009CE4 */ u8 pad_9CE4[4]; diff --git a/src/ac_animal_logo_misc.c b/src/ac_animal_logo_misc.c index 64a2d1b2..d469dcbb 100644 --- a/src/ac_animal_logo_misc.c +++ b/src/ac_animal_logo_misc.c @@ -21,7 +21,7 @@ extern void flash_rom_and_player_info_clear() { bzero(save, sizeof(Save)); mFRm_ClearSaveCheckData(Save_GetPointer(save_check)); - priv_p = Save_GetPointer(private[0]); + priv_p = Save_GetPointer(private_data[0]); for (i = 0; i < PLAYER_NUM; i++) { mPr_ClearPrivateInfo(priv_p); priv_p++; @@ -96,7 +96,7 @@ extern void title_action_data_init_start_select(GAME_PLAY* play) { mCD_LoadLand(); mCPk_InitPak(0); - Common_Set(now_private, Save_GetPointer(private[0])); + Common_Set(now_private, Save_GetPointer(private_data[0])); Common_Set(player_no, 0); mTD_rtc_reserve(); diff --git a/src/ac_douzou_move.c_inc b/src/ac_douzou_move.c_inc index fdeb2659..175f5d24 100644 --- a/src/ac_douzou_move.c_inc +++ b/src/ac_douzou_move.c_inc @@ -15,7 +15,7 @@ static int aDOU_set_check(int house_no) { int player_no = mHS_get_pl_no(house_no); - Private_c* priv = Save_GetPointer(private[player_no]); + Private_c* priv = Save_GetPointer(private_data[player_no]); mHm_hs_c* house = Save_GetPointer(homes[house_no]); if (mEv_CheckTitleDemo() != 0 && mEv_CheckTitleDemo() != -1 && mEv_CheckTitleDemo() != -9) { @@ -35,7 +35,7 @@ static int aDOU_get_color(int house_no) { static int aDOU_get_douzou_type(int house_no) { int player_no = mHS_get_pl_no(house_no); - Private_c* priv = Save_GetPointer(private[player_no]); + Private_c* priv = Save_GetPointer(private_data[player_no]); s8 sex = mPr_SEX_MALE; s8 face = mPr_FACE_TYPE0; diff --git a/src/ac_haniwa_move.c_inc b/src/ac_haniwa_move.c_inc index d307efa5..789cadf3 100644 --- a/src/ac_haniwa_move.c_inc +++ b/src/ac_haniwa_move.c_inc @@ -9,7 +9,7 @@ static int aHNW_set_save_permission() { if (player_no < PLAYER_NUM) { int arrange_idx = mHS_get_arrange_idx(player_no); house = Save_GetPointer(homes[arrange_idx]); - pid = &Save_Get(private[player_no]).player_ID; + pid = &Save_Get(private_data[player_no]).player_ID; if (mPr_NullCheckPersonalID(pid) != TRUE && mPr_CheckCmpPersonalID(pid, &house->ownerID) == TRUE) { res = TRUE; diff --git a/src/ac_museum_fossil.c b/src/ac_museum_fossil.c index 3e3aba65..5d5f7f73 100644 --- a/src/ac_museum_fossil.c +++ b/src/ac_museum_fossil.c @@ -119,9 +119,10 @@ static void Museum_Fossil_Actor_move(ACTOR* actorx, GAME* game) { /* If the donator still lives in town we need to copy their name */ if (mMmd_DONATOR_EXISTS(donator)) { - mMsg_Set_free_str(mMsg_Get_base_window_p(), mMsg_FREE_STR0, - Save_Get(private[mMmd_DONATOR_PLR_IDX(donator)]).player_ID.player_name, - PLAYER_NAME_LEN); + mMsg_Set_free_str( + mMsg_Get_base_window_p(), mMsg_FREE_STR0, + Save_Get(private_data[mMmd_DONATOR_PLR_IDX(donator)]).player_ID.player_name, + PLAYER_NAME_LEN); } } diff --git a/src/ac_museum_picture.c b/src/ac_museum_picture.c index 476fd740..34981d03 100644 --- a/src/ac_museum_picture.c +++ b/src/ac_museum_picture.c @@ -194,7 +194,7 @@ static void Museum_Picture_Actor_move(ACTOR* actorx, GAME* game) { /* If the donator still lives in town we need to copy their name */ if (mMmd_DONATOR_EXISTS(donator)) { mMsg_Set_free_str(mMsg_Get_base_window_p(), mMsg_FREE_STR0, - Save_Get(private[mMmd_DONATOR_PLR_IDX(donator)]).player_ID.player_name, + Save_Get(private_data[mMmd_DONATOR_PLR_IDX(donator)]).player_ID.player_name, PLAYER_NAME_LEN); } } diff --git a/src/ac_my_house_draw.c_inc b/src/ac_my_house_draw.c_inc index 2e18f5fe..4a340995 100644 --- a/src/ac_my_house_draw.c_inc +++ b/src/ac_my_house_draw.c_inc @@ -239,8 +239,8 @@ static void aMHS_actor_draw(ACTOR* actorx, GAME* game) { gSPSegment(gfx++, G_MWO_SEGMENT_A, obj_myhome_mark_pal); } else { int org_idx = door_original & 7; - u16* pal = mNW_PaletteIdx2Palette(Save_Get(private[pl_no]).my_org[org_idx].palette); - u8* tex = Save_Get(private[pl_no]).my_org[org_idx].design.data; + u16* pal = mNW_PaletteIdx2Palette(Save_Get(private_data[pl_no]).my_org[org_idx].palette); + u8* tex = Save_Get(private_data[pl_no]).my_org[org_idx].design.data; gSPSegment(gfx++, G_MWO_SEGMENT_9, tex); gSPSegment(gfx++, G_MWO_SEGMENT_A, pal); diff --git a/src/ac_npc_curator_move.c_inc b/src/ac_npc_curator_move.c_inc index 51868beb..ac6dc697 100644 --- a/src/ac_npc_curator_move.c_inc +++ b/src/ac_npc_curator_move.c_inc @@ -1,1177 +1,1015 @@ static void aCR_set_animation(NPC_CURATOR_ACTOR* curator, int action) { - static int animeSeqNo[] = { 5, 5, 9 }; + static int animeSeqNo[] = { 5, 5, 9 }; - (*Common_Get(clip).npc_clip->animation_init_proc)((ACTOR*)curator, animeSeqNo[action], FALSE); + (*Common_Get(clip).npc_clip->animation_init_proc)((ACTOR*)curator, animeSeqNo[action], FALSE); } static void aCR_set_request_act(NPC_CURATOR_ACTOR* curator) { - curator->npc_class.request.act_priority = 4; - curator->npc_class.request.act_idx = 16; - curator->npc_class.request.act_type = 2; + curator->npc_class.request.act_priority = 4; + curator->npc_class.request.act_idx = 16; + curator->npc_class.request.act_type = 2; } static int aCR_check_sleep_time() { - int res = FALSE; + int res = FALSE; - if (Common_Get(time.now_sec) >= aCR_SLEEP_TIME_START && Common_Get(time.now_sec) < aCR_SLEEP_TIME_END) { - res = TRUE; - } + if (Common_Get(time.now_sec) >= aCR_SLEEP_TIME_START && Common_Get(time.now_sec) < aCR_SLEEP_TIME_END) { + res = TRUE; + } - return res; + return res; } static void aCR_sleep_wait(NPC_CURATOR_ACTOR* curator, GAME_PLAY* play) { - curator->sleep_wait_timer--; + curator->sleep_wait_timer--; - if (curator->sleep_wait_timer <= 0) { - aCR_setupAction(curator, play, aCR_ACTION_SLEEP); // Go back to sleep - } + if (curator->sleep_wait_timer <= 0) { + aCR_setupAction(curator, play, aCR_ACTION_SLEEP); // Go back to sleep + } } static void aCR_wait_init(NPC_CURATOR_ACTOR* curator) { - curator->npc_class.condition_info.demo_flg = 0; - curator->npc_class.head.angle_add_y = DEG2SHORT_ANGLE(5.625f); - curator->npc_class.movement.mv_angl = DEG2SHORT_ANGLE(0.0f); - curator->npc_class.movement.mv_add_angl = DEG2SHORT_ANGLE(5.625f); + curator->npc_class.condition_info.demo_flg = 0; + curator->npc_class.head.angle_add_y = DEG2SHORT_ANGLE(5.625f); + curator->npc_class.movement.mv_angl = DEG2SHORT_ANGLE(0.0f); + curator->npc_class.movement.mv_add_angl = DEG2SHORT_ANGLE(5.625f); } static void aCR_sleep_wait_init(NPC_CURATOR_ACTOR* curator) { - aCR_wait_init(curator); - curator->sleep_wait_timer = aCR_SLEEP_WAIT_TIMER; + aCR_wait_init(curator); + curator->sleep_wait_timer = aCR_SLEEP_WAIT_TIMER; } static void aCR_sleep_init(NPC_CURATOR_ACTOR* curator) { - curator->npc_class.condition_info.demo_flg = aNPC_COND_DEMO_SKIP_HEAD_LOOKAT; - curator->npc_class.head.angle_add_y = DEG2SHORT_ANGLE(1.40625f); - curator->_9B0 = 0; + curator->npc_class.condition_info.demo_flg = aNPC_COND_DEMO_SKIP_HEAD_LOOKAT; + curator->npc_class.head.angle_add_y = DEG2SHORT_ANGLE(1.40625f); + curator->_9B0 = 0; } typedef void (*aCR_INIT_PROC)(NPC_CURATOR_ACTOR*); static void aCR_setupAction(NPC_CURATOR_ACTOR* curator, GAME_PLAY* play, int action) { - static aCR_ACT_PROC process[aCR_ACTION_NUM] = { - (aCR_ACT_PROC)&none_proc1, - &aCR_sleep_wait, - (aCR_ACT_PROC)&none_proc1 - }; + static aCR_ACT_PROC process[aCR_ACTION_NUM] = { (aCR_ACT_PROC)&none_proc1, &aCR_sleep_wait, + (aCR_ACT_PROC)&none_proc1 }; - static aCR_INIT_PROC init_proc[aCR_ACTION_NUM] = { - &aCR_wait_init, - &aCR_sleep_wait_init, - &aCR_sleep_init - }; + static aCR_INIT_PROC init_proc[aCR_ACTION_NUM] = { &aCR_wait_init, &aCR_sleep_wait_init, &aCR_sleep_init }; - aCR_set_animation(curator, action); - curator->action = action; - curator->action_proc = process[action]; - (*init_proc[action])(curator); + aCR_set_animation(curator, action); + curator->action = action; + curator->action_proc = process[action]; + (*init_proc[action])(curator); } static void aCR_act_chg_data_proc(NPC_ACTOR* actorx, GAME_PLAY* play) { - NPC_CURATOR_ACTOR* curator = (NPC_CURATOR_ACTOR*)actorx; + NPC_CURATOR_ACTOR* curator = (NPC_CURATOR_ACTOR*)actorx; - curator->npc_class.action.act_obj = aNPC_ACT_OBJ_PLAYER; + curator->npc_class.action.act_obj = aNPC_ACT_OBJ_PLAYER; } static void aCR_act_init_proc(NPC_ACTOR* actorx, GAME_PLAY* play) { - NPC_CURATOR_ACTOR* curator = (NPC_CURATOR_ACTOR*)actorx; - int action; + NPC_CURATOR_ACTOR* curator = (NPC_CURATOR_ACTOR*)actorx; + int action; - if (curator->action == aCR_ACTION_WAIT) { - if (aCR_check_sleep_time() == TRUE) { - action = aCR_ACTION_SLEEP_WAIT; + if (curator->action == aCR_ACTION_WAIT) { + if (aCR_check_sleep_time() == TRUE) { + action = aCR_ACTION_SLEEP_WAIT; + } else { + action = aCR_ACTION_WAIT; + } + } else { + if (aCR_check_sleep_time() == TRUE) { + action = aCR_ACTION_SLEEP; + } else { + action = aCR_ACTION_WAIT; + } } - else { - action = aCR_ACTION_WAIT; - } - } - else { - if (aCR_check_sleep_time() == TRUE) { - action = aCR_ACTION_SLEEP; - } - else { - action = aCR_ACTION_WAIT; - } - } - actorx->action.step = 0; - aCR_setupAction(curator, play, action); + actorx->action.step = 0; + aCR_setupAction(curator, play, action); } static void aCR_act_main_proc(NPC_ACTOR* actorx, GAME_PLAY* play) { - NPC_CURATOR_ACTOR* curator = (NPC_CURATOR_ACTOR*)actorx; - - (*curator->action_proc)(curator, play); + NPC_CURATOR_ACTOR* curator = (NPC_CURATOR_ACTOR*)actorx; + + (*curator->action_proc)(curator, play); } static void aCR_act_proc(NPC_ACTOR* actorx, GAME_PLAY* play, int action) { - static aCR_ACTION_PROC act_proc[aCR_ACTION_NUM] = { - &aCR_act_init_proc, - &aCR_act_chg_data_proc, - &aCR_act_main_proc - }; + static aCR_ACTION_PROC act_proc[aCR_ACTION_NUM] = { &aCR_act_init_proc, &aCR_act_chg_data_proc, + &aCR_act_main_proc }; - (*act_proc[action])(actorx, play); + (*act_proc[action])(actorx, play); } static void aCR_think_main_proc(NPC_ACTOR* actorx, GAME_PLAY* play) { - NPC_CURATOR_ACTOR* curator = (NPC_CURATOR_ACTOR*)actorx; + NPC_CURATOR_ACTOR* curator = (NPC_CURATOR_ACTOR*)actorx; - if (curator->npc_class.action.step == aNPC_ACTION_END_STEP) { - aCR_set_request_act(curator); - } - else if (curator->npc_class.action.idx == 16) { - if (aCR_check_sleep_time() == TRUE) { - if (curator->action == aCR_ACTION_WAIT) { - aCR_setupAction(curator, play, aCR_ACTION_SLEEP_WAIT); - } + if (curator->npc_class.action.step == aNPC_ACTION_END_STEP) { + aCR_set_request_act(curator); + } else if (curator->npc_class.action.idx == 16) { + if (aCR_check_sleep_time() == TRUE) { + if (curator->action == aCR_ACTION_WAIT) { + aCR_setupAction(curator, play, aCR_ACTION_SLEEP_WAIT); + } + } else if (curator->action == aCR_ACTION_SLEEP) { + aCR_setupAction(curator, play, aCR_ACTION_WAIT); + } } - else if (curator->action == aCR_ACTION_SLEEP) { - aCR_setupAction(curator, play, aCR_ACTION_WAIT); - } - } } static void aCR_think_init_proc(NPC_ACTOR* actorx, GAME_PLAY* play) { - NPC_CURATOR_ACTOR* curator = (NPC_CURATOR_ACTOR*)actorx; - int action; + NPC_CURATOR_ACTOR* curator = (NPC_CURATOR_ACTOR*)actorx; + int action; - if (aCR_check_sleep_time() == TRUE) { - action = aCR_ACTION_SLEEP; - } - else { - action = aCR_ACTION_WAIT; - } + if (aCR_check_sleep_time() == TRUE) { + action = aCR_ACTION_SLEEP; + } else { + action = aCR_ACTION_WAIT; + } - curator->action = action; - curator->npc_class.action.act_proc = &aCR_act_proc; - aCR_set_request_act(curator); + curator->action = action; + curator->npc_class.action.act_proc = &aCR_act_proc; + aCR_set_request_act(curator); } typedef void (*aCR_THINK_PROC)(NPC_ACTOR*, GAME_PLAY*); static void aCR_think_proc(NPC_ACTOR* actorx, GAME_PLAY* play, int think_idx) { - static aCR_THINK_PROC think_proc[2] = { - &aCR_think_init_proc, - &aCR_think_main_proc - }; + static aCR_THINK_PROC think_proc[2] = { &aCR_think_init_proc, &aCR_think_main_proc }; - (*think_proc[think_idx])(actorx, play); + (*think_proc[think_idx])(actorx, play); } static void aCR_schedule_init_proc(NPC_ACTOR* actorx, GAME_PLAY* play) { - actorx->think.think_proc = &aCR_think_proc; - actorx->condition_info.hide_request = FALSE; - (*Common_Get(clip).npc_clip->think_proc)(actorx, play, aNPC_THINK_IN_BLOCK, aNPC_THINK_TYPE_INIT); + actorx->think.think_proc = &aCR_think_proc; + actorx->condition_info.hide_request = FALSE; + (*Common_Get(clip).npc_clip->think_proc)(actorx, play, aNPC_THINK_IN_BLOCK, aNPC_THINK_TYPE_INIT); } static void aCR_schedule_main_proc(NPC_ACTOR* actorx, GAME_PLAY* play) { - if ((*Common_Get(clip).npc_clip->think_proc)(actorx, play, -1, aNPC_THINK_TYPE_CHK_INTERRUPT) == FALSE) { - (*Common_Get(clip).npc_clip->think_proc)(actorx, play, -1, aNPC_THINK_TYPE_MAIN); - } + if ((*Common_Get(clip).npc_clip->think_proc)(actorx, play, -1, aNPC_THINK_TYPE_CHK_INTERRUPT) == FALSE) { + (*Common_Get(clip).npc_clip->think_proc)(actorx, play, -1, aNPC_THINK_TYPE_MAIN); + } } typedef void (*aCR_SCHEDULE_PROC)(NPC_ACTOR*, GAME_PLAY*); static void aCR_schedule_proc(NPC_ACTOR* actorx, GAME_PLAY* play, int proc_idx) { - static aCR_SCHEDULE_PROC sched_proc[] = { - &aCR_schedule_init_proc, - &aCR_schedule_main_proc - }; + static aCR_SCHEDULE_PROC sched_proc[] = { &aCR_schedule_init_proc, &aCR_schedule_main_proc }; - (*sched_proc[proc_idx])(actorx, play); + (*sched_proc[proc_idx])(actorx, play); } enum { - aCR_FOSSIL_TYPE_TRICERA, - aCR_FOSSIL_TYPE_TREX, - aCR_FOSSIL_TYPE_APATO, - aCR_FOSSIL_TYPE_STEGO, - aCR_FOSSIL_TYPE_PTERA, - aCR_FOSSIL_TYPE_PLESIO, - aCR_FOSSIL_TYPE_MAMMOTH, + aCR_FOSSIL_TYPE_TRICERA, + aCR_FOSSIL_TYPE_TREX, + aCR_FOSSIL_TYPE_APATO, + aCR_FOSSIL_TYPE_STEGO, + aCR_FOSSIL_TYPE_PTERA, + aCR_FOSSIL_TYPE_PLESIO, + aCR_FOSSIL_TYPE_MAMMOTH, - aCR_FOSSIL_TYPE_NUM + aCR_FOSSIL_TYPE_NUM }; static int aCR_get_fossil_type(mActor_name_t item) { - static int fossil_ftr_start[aCR_FOSSIL_TYPE_NUM] = { - FTR_DINO_TRICERA_SKULL, - FTR_DINO_TREX_SKULL, - FTR_DINO_APATO_SKULL, - FTR_DINO_STEGO_SKULL, - FTR_DINO_PTERA_SKULL, - FTR_DINO_PLESIO_SKULL, - FTR_DINO_MAMMOTH_SKULL - }; + static int fossil_ftr_start[aCR_FOSSIL_TYPE_NUM] = { FTR_DINO_TRICERA_SKULL, FTR_DINO_TREX_SKULL, + FTR_DINO_APATO_SKULL, FTR_DINO_STEGO_SKULL, + FTR_DINO_PTERA_SKULL, FTR_DINO_PLESIO_SKULL, + FTR_DINO_MAMMOTH_SKULL }; - static int fossil_ftr_end[aCR_FOSSIL_TYPE_NUM] = { - FTR_DINO_TRICERA_BODY+3, - FTR_DINO_TREX_BODY+3, - FTR_DINO_APATO_BODY+3, - FTR_DINO_STEGO_BODY+3, - FTR_DINO_PTERA_LEFT_WING+3, - FTR_DINO_PLESIO_TORSO+3, - FTR_DINO_MAMMOTH_TORSO+3 - }; + static int fossil_ftr_end[aCR_FOSSIL_TYPE_NUM] = { FTR_DINO_TRICERA_BODY + 3, FTR_DINO_TREX_BODY + 3, + FTR_DINO_APATO_BODY + 3, FTR_DINO_STEGO_BODY + 3, + FTR_DINO_PTERA_LEFT_WING + 3, FTR_DINO_PLESIO_TORSO + 3, + FTR_DINO_MAMMOTH_TORSO + 3 }; - int res = -1; - int i; + int res = -1; + int i; - for (i = 0; i < aCR_FOSSIL_TYPE_NUM; i++) { - if (item >= fossil_ftr_start[i] && item <= fossil_ftr_end[i]) { - res = i; - break; + for (i = 0; i < aCR_FOSSIL_TYPE_NUM; i++) { + if (item >= fossil_ftr_start[i] && item <= fossil_ftr_end[i]) { + res = i; + break; + } } - } - return res; + return res; } typedef struct { - int count; - mActor_name_t* parts; + int count; + mActor_name_t* parts; } aCR_fossil_part_c; #define aCR_GetFossilPartDonator(item_no) \ - mMmd_FossilInfo(((item_no) >= FTR_DINO_START && (item_no) <= FTR_DINO_END) ? FTR_IDX_2_NO((item_no - FTR_DINO_START)) : 0) -#define aCR_GetArtDonator(item_no) \ - mMmd_ArtInfo(((item_no) >= FTR_PAINTING0 && (item_no) <= FTR_PAINTING14_WEST) ? FTR_IDX_2_NO((item_no - FTR_PAINTING0)) : 0) + mMmd_FossilInfo( \ + ((item_no) >= FTR_DINO_START && (item_no) <= FTR_DINO_END) ? FTR_IDX_2_NO((item_no - FTR_DINO_START)) : 0) +#define aCR_GetArtDonator(item_no) \ + mMmd_ArtInfo(((item_no) >= FTR_PAINTING0 && (item_no) <= FTR_PAINTING14_WEST) \ + ? FTR_IDX_2_NO((item_no - FTR_PAINTING0)) \ + : 0) #define aCR_GetInsectDonator(item_no) \ - mMmd_InsectInfo(((item_no) >= ITM_INSECT_START && (item_no) < ITM_INSECT_END) ? (item_no - ITM_INSECT_START) : 0) + mMmd_InsectInfo(((item_no) >= ITM_INSECT_START && (item_no) < ITM_INSECT_END) ? (item_no - ITM_INSECT_START) : 0) #define aCR_GetFishDonator(item_no) \ - mMmd_FishInfo(((item_no) >= ITM_FISH_START && (item_no) <= ITM_FISH_END) ? (item_no - ITM_FISH_START) : 0) + mMmd_FishInfo(((item_no) >= ITM_FISH_START && (item_no) <= ITM_FISH_END) ? (item_no - ITM_FISH_START) : 0) static int aCR_chk_fossil_parts_complete_sub(int type) { - static mActor_name_t trikera_parts[] = { FTR_DINO_TRICERA_SKULL, FTR_DINO_TRICERA_TAIL, FTR_DINO_TRICERA_BODY }; - static mActor_name_t trex_parts[] = { FTR_DINO_TREX_SKULL, FTR_DINO_TREX_TAIL, FTR_DINO_TREX_BODY }; - static mActor_name_t bront_parts[] = { FTR_DINO_APATO_SKULL, FTR_DINO_APATO_TAIL, FTR_DINO_APATO_BODY }; - static mActor_name_t stego_parts[] = { FTR_DINO_STEGO_SKULL, FTR_DINO_STEGO_TAIL, FTR_DINO_STEGO_BODY }; - static mActor_name_t ptera_parts[] = { FTR_DINO_PTERA_SKULL, FTR_DINO_PTERA_RIGHT_WING, FTR_DINO_PTERA_LEFT_WING }; - static mActor_name_t hutaba_parts[] = { FTR_DINO_PLESIO_SKULL, FTR_DINO_PLESIO_NECK, FTR_DINO_PLESIO_TORSO }; - static mActor_name_t mammoth_parts[] = { FTR_DINO_MAMMOTH_SKULL, FTR_DINO_MAMMOTH_TORSO }; - static aCR_fossil_part_c fossil_parts[aCR_FOSSIL_TYPE_NUM] = { - { ARRAY_COUNT(trikera_parts), trikera_parts }, - { ARRAY_COUNT(trex_parts), trex_parts }, - { ARRAY_COUNT(bront_parts), bront_parts }, - { ARRAY_COUNT(stego_parts), stego_parts }, - { ARRAY_COUNT(ptera_parts), ptera_parts }, - { ARRAY_COUNT(hutaba_parts), hutaba_parts }, - { ARRAY_COUNT(mammoth_parts), mammoth_parts } - }; + static mActor_name_t trikera_parts[] = { FTR_DINO_TRICERA_SKULL, FTR_DINO_TRICERA_TAIL, FTR_DINO_TRICERA_BODY }; + static mActor_name_t trex_parts[] = { FTR_DINO_TREX_SKULL, FTR_DINO_TREX_TAIL, FTR_DINO_TREX_BODY }; + static mActor_name_t bront_parts[] = { FTR_DINO_APATO_SKULL, FTR_DINO_APATO_TAIL, FTR_DINO_APATO_BODY }; + static mActor_name_t stego_parts[] = { FTR_DINO_STEGO_SKULL, FTR_DINO_STEGO_TAIL, FTR_DINO_STEGO_BODY }; + static mActor_name_t ptera_parts[] = { FTR_DINO_PTERA_SKULL, FTR_DINO_PTERA_RIGHT_WING, FTR_DINO_PTERA_LEFT_WING }; + static mActor_name_t hutaba_parts[] = { FTR_DINO_PLESIO_SKULL, FTR_DINO_PLESIO_NECK, FTR_DINO_PLESIO_TORSO }; + static mActor_name_t mammoth_parts[] = { FTR_DINO_MAMMOTH_SKULL, FTR_DINO_MAMMOTH_TORSO }; + static aCR_fossil_part_c fossil_parts[aCR_FOSSIL_TYPE_NUM] = { + { ARRAY_COUNT(trikera_parts), trikera_parts }, { ARRAY_COUNT(trex_parts), trex_parts }, + { ARRAY_COUNT(bront_parts), bront_parts }, { ARRAY_COUNT(stego_parts), stego_parts }, + { ARRAY_COUNT(ptera_parts), ptera_parts }, { ARRAY_COUNT(hutaba_parts), hutaba_parts }, + { ARRAY_COUNT(mammoth_parts), mammoth_parts } + }; - aCR_fossil_part_c* fossil_part = &fossil_parts[type]; - int i = fossil_part->count; - mActor_name_t* fossil_part_p = fossil_part->parts; - int res = TRUE; + aCR_fossil_part_c* fossil_part = &fossil_parts[type]; + int i = fossil_part->count; + mActor_name_t* fossil_part_p = fossil_part->parts; + int res = TRUE; - while (i != 0) { - int valid = aCR_GetFossilPartDonator(*fossil_part_p) >= mMmd_DONATOR_PLAYER1 - && aCR_GetFossilPartDonator(*fossil_part_p) <= mMmd_DONATOR_DELETED_PLAYER; - - if (!valid) { - res = FALSE; - break; + while (i != 0) { + int valid = aCR_GetFossilPartDonator(*fossil_part_p) >= mMmd_DONATOR_PLAYER1 && + aCR_GetFossilPartDonator(*fossil_part_p) <= mMmd_DONATOR_DELETED_PLAYER; + + if (!valid) { + res = FALSE; + break; + } + + fossil_part_p++; + i--; } - - fossil_part_p++; - i--; - } - return res; + return res; } static void aCR_chk_fossil_parts_complete(NPC_CURATOR_ACTOR* curator, GAME_PLAY* play) { - static int msg_no_table[aCR_FOSSIL_TYPE_NUM] = { - 0x2F78, - 0x2F79, - 0x2F7A, - 0x2F7B, - 0x2F7C, - 0x2F7D, - 0x2F7E - }; - - int fossil_type = aCR_get_fossil_type(play->submenu.item_p->item); - int msg_no = 0x2F84; + static int msg_no_table[aCR_FOSSIL_TYPE_NUM] = { 0x2F78, 0x2F79, 0x2F7A, 0x2F7B, 0x2F7C, 0x2F7D, 0x2F7E }; - if (fossil_type != -1 && aCR_chk_fossil_parts_complete_sub(fossil_type) == TRUE) { - msg_no = msg_no_table[fossil_type]; - } + int fossil_type = aCR_get_fossil_type(play->submenu.item_p->item); + int msg_no = 0x2F84; - mMsg_Set_continue_msg_num(mMsg_Get_base_window_p(), msg_no); - curator->msg_no = msg_no; - (*curator->setupTalkAction_proc)(curator, play, aCR_TALK_THANKS_FOSSIL_MSG_END_WAIT); + if (fossil_type != -1 && aCR_chk_fossil_parts_complete_sub(fossil_type) == TRUE) { + msg_no = msg_no_table[fossil_type]; + } + + mMsg_Set_continue_msg_num(mMsg_Get_base_window_p(), msg_no); + curator->msg_no = msg_no; + (*curator->setupTalkAction_proc)(curator, play, aCR_TALK_THANKS_FOSSIL_MSG_END_WAIT); } static void aCR_chk_fossil_complete(NPC_CURATOR_ACTOR* curator, GAME_PLAY* play) { - static int msg_no[] = { 0x2F73, 0x2F85 }; - static int next_act_idx[] = { aCR_TALK_CHK_CONTINUE_TO_DONATE3, aCR_TALK_CHK_ALL_COMPLETE }; + static int msg_no[] = { 0x2F73, 0x2F85 }; + static int next_act_idx[] = { aCR_TALK_CHK_CONTINUE_TO_DONATE3, aCR_TALK_CHK_ALL_COMPLETE }; - mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); - int complete = FALSE; + mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); + int complete = FALSE; - if (mMmd_CountDisplayedFossil() == mMmd_FOSSIL_NUM) { - complete = TRUE; - } + if (mMmd_CountDisplayedFossil() == mMmd_FOSSIL_NUM) { + complete = TRUE; + } - mMsg_Set_continue_msg_num(msg_p, msg_no[complete]); - curator->msg_no = msg_no[complete]; - (*curator->setupTalkAction_proc)(curator, play, next_act_idx[complete]); + mMsg_Set_continue_msg_num(msg_p, msg_no[complete]); + curator->msg_no = msg_no[complete]; + (*curator->setupTalkAction_proc)(curator, play, next_act_idx[complete]); } static void aCR_chk_art_complete(NPC_CURATOR_ACTOR* curator, GAME_PLAY* play) { - static int msg_no[] = { 0x2F73, 0x2F75 }; - static int next_act_idx[] = { aCR_TALK_CHK_CONTINUE_TO_DONATE3, aCR_TALK_CHK_ALL_COMPLETE }; + static int msg_no[] = { 0x2F73, 0x2F75 }; + static int next_act_idx[] = { aCR_TALK_CHK_CONTINUE_TO_DONATE3, aCR_TALK_CHK_ALL_COMPLETE }; - int complete = FALSE; + int complete = FALSE; - if (mMmd_CountDisplayedArt() == mMmd_ART_NUM) { - complete = TRUE; - } + if (mMmd_CountDisplayedArt() == mMmd_ART_NUM) { + complete = TRUE; + } - mMsg_Set_continue_msg_num(mMsg_Get_base_window_p(), msg_no[complete]); - curator->msg_no = msg_no[complete]; - (*curator->setupTalkAction_proc)(curator, play, next_act_idx[complete]); + mMsg_Set_continue_msg_num(mMsg_Get_base_window_p(), msg_no[complete]); + curator->msg_no = msg_no[complete]; + (*curator->setupTalkAction_proc)(curator, play, next_act_idx[complete]); } static void aCR_chk_fish_complete(NPC_CURATOR_ACTOR* curator, GAME_PLAY* play) { - static int msg_no[] = { 0x2F73, 0x2F8A }; - static int next_act_idx[] = { aCR_TALK_CHK_CONTINUE_TO_DONATE3, aCR_TALK_CHK_ALL_COMPLETE }; + static int msg_no[] = { 0x2F73, 0x2F8A }; + static int next_act_idx[] = { aCR_TALK_CHK_CONTINUE_TO_DONATE3, aCR_TALK_CHK_ALL_COMPLETE }; - int complete = FALSE; + int complete = FALSE; - if (mMmd_CountDisplayedFish() == mMmd_FISH_NUM) { - complete = TRUE; - } + if (mMmd_CountDisplayedFish() == mMmd_FISH_NUM) { + complete = TRUE; + } - mMsg_Set_continue_msg_num(mMsg_Get_base_window_p(), msg_no[complete]); - curator->msg_no = msg_no[complete]; - (*curator->setupTalkAction_proc)(curator, play, next_act_idx[complete]); + mMsg_Set_continue_msg_num(mMsg_Get_base_window_p(), msg_no[complete]); + curator->msg_no = msg_no[complete]; + (*curator->setupTalkAction_proc)(curator, play, next_act_idx[complete]); } static void aCR_chk_insect_complete(NPC_CURATOR_ACTOR* curator, GAME_PLAY* play) { - static int msg_no[] = { 0x2F73, 0x2F88 }; - static int next_act_idx[] = { aCR_TALK_CHK_CONTINUE_TO_DONATE3, aCR_TALK_CHK_ALL_COMPLETE }; + static int msg_no[] = { 0x2F73, 0x2F88 }; + static int next_act_idx[] = { aCR_TALK_CHK_CONTINUE_TO_DONATE3, aCR_TALK_CHK_ALL_COMPLETE }; - int complete = FALSE; + int complete = FALSE; - if (mMmd_CountDisplayedInsect() == mMmd_INSECT_NUM) { - complete = TRUE; - } + if (mMmd_CountDisplayedInsect() == mMmd_INSECT_NUM) { + complete = TRUE; + } - mMsg_Set_continue_msg_num(mMsg_Get_base_window_p(), msg_no[complete]); - curator->msg_no = msg_no[complete]; - (*curator->setupTalkAction_proc)(curator, play, next_act_idx[complete]); + mMsg_Set_continue_msg_num(mMsg_Get_base_window_p(), msg_no[complete]); + curator->msg_no = msg_no[complete]; + (*curator->setupTalkAction_proc)(curator, play, next_act_idx[complete]); } static void aCR_set_after_explain_insect(NPC_CURATOR_ACTOR* curator, GAME_PLAY* play) { - static int msg_no[] = { - 0x3A56, - 0x3A56, - 0x3A56, - 0x3A56, - 0x3A57, - 0x3A57, - 0x3A5D, - 0x3A57, - 0x3A5E, - 0x3A58, - 0x3A58, - 0x3A58, - 0x3A5F, - 0x3A59, - 0x3A59, - 0x3A5A, - 0x3A5A, - 0x3A5A, - 0x3A5A, - 0x3A5B, - 0x3A5B, - 0x3A5B, - 0x3A61, - 0x3A62, - 0x3A5C, - 0x3A5C, - 0x3A63, - 0x3A64, - 0x3A56, - 0x3A5B, - 0x3A5B, - 0x3A60, - 0x3A6B, - 0x3A69, - 0x3A65, - 0x3A6C, - 0x3A68, - 0x3A6A, - 0x3A66, - 0x3A67 - }; + static int msg_no[] = { 0x3A56, 0x3A56, 0x3A56, 0x3A56, 0x3A57, 0x3A57, 0x3A5D, 0x3A57, 0x3A5E, 0x3A58, + 0x3A58, 0x3A58, 0x3A5F, 0x3A59, 0x3A59, 0x3A5A, 0x3A5A, 0x3A5A, 0x3A5A, 0x3A5B, + 0x3A5B, 0x3A5B, 0x3A61, 0x3A62, 0x3A5C, 0x3A5C, 0x3A63, 0x3A64, 0x3A56, 0x3A5B, + 0x3A5B, 0x3A60, 0x3A6B, 0x3A69, 0x3A65, 0x3A6C, 0x3A68, 0x3A6A, 0x3A66, 0x3A67 }; - int insect_type = curator->donated_item - ITM_INSECT_START; + int insect_type = curator->donated_item - ITM_INSECT_START; - if (insect_type < 0 || insect_type >= INSECT_ONLY_NUM) { - insect_type = 0; - } + if (insect_type < 0 || insect_type >= INSECT_ONLY_NUM) { + insect_type = 0; + } - mMsg_Set_continue_msg_num(mMsg_Get_base_window_p(), msg_no[insect_type]); - curator->msg_no = msg_no[insect_type]; - (*curator->setupTalkAction_proc)(curator, play, aCR_TALK_AFTER_EXPLAIN_INSECT); + mMsg_Set_continue_msg_num(mMsg_Get_base_window_p(), msg_no[insect_type]); + curator->msg_no = msg_no[insect_type]; + (*curator->setupTalkAction_proc)(curator, play, aCR_TALK_AFTER_EXPLAIN_INSECT); } static void aCR_set_item_name_str(mActor_name_t item) { - u8 item_str[mIN_ITEM_NAME_LEN]; + u8 item_str[mIN_ITEM_NAME_LEN]; - mIN_copy_name_str(item_str, item); - mMsg_Set_item_str_art(mMsg_Get_base_window_p(), mMsg_FREE_STR0, item_str, sizeof(item_str), mIN_get_item_article(item)); + mIN_copy_name_str(item_str, item); + mMsg_Set_item_str_art(mMsg_Get_base_window_p(), mMsg_FREE_STR0, item_str, sizeof(item_str), + mIN_get_item_article(item)); } static void aCR_set_other_player_name_str(int player_no) { - mMsg_Set_free_str(mMsg_Get_base_window_p(), mMsg_FREE_STR0, Save_Get(private[player_no]).player_ID.player_name, PLAYER_NAME_LEN); + mMsg_Set_free_str(mMsg_Get_base_window_p(), mMsg_FREE_STR0, Save_Get(private_data[player_no]).player_ID.player_name, + PLAYER_NAME_LEN); } static int aCR_countDisplayed() { - return mMmd_CountDisplayedFossil() + mMmd_CountDisplayedArt() + mMmd_CountDisplayedInsect() + mMmd_CountDisplayedFish(); + return mMmd_CountDisplayedFossil() + mMmd_CountDisplayedArt() + mMmd_CountDisplayedInsect() + + mMmd_CountDisplayedFish(); } static int aCR_get_msg_no_after_talk() { - static int msg_no[] = { 0x2F58, 0x2F59, 0x2F5A, 0x2F5B }; - int displayed = aCR_countDisplayed(); - int idx; + static int msg_no[] = { 0x2F58, 0x2F59, 0x2F5A, 0x2F5B }; + int displayed = aCR_countDisplayed(); + int idx; - if (displayed == 0) { - idx = 0; - } - else if (displayed <= 36) { - idx = 1; - } - else if (displayed <= 84) { - idx = 2; - } - else { - idx = 3; - } + if (displayed == 0) { + idx = 0; + } else if (displayed <= 36) { + idx = 1; + } else if (displayed <= 84) { + idx = 2; + } else { + idx = 3; + } - return msg_no[idx]; + return msg_no[idx]; } static int aCR_get_idx_to_donate_fossil(mActor_name_t item) { - int donator = aCR_GetFossilPartDonator(item); + int donator = aCR_GetFossilPartDonator(item); - if (donator == (Common_Get(player_no) + 1)) { - return 4; - } - - switch (donator) { - case mMmd_DONATOR_NONE: - { - switch (item) { - case FTR_FOSSIL_TRILOBITE: - return 17; - case FTR_FOSSIL_AMMONITE: - return 18; - case FTR_FOSSIL_EGG: - return 19; - case FTR_FOSSIL_TRACK: - return 20; - case FTR_FOSSIL_AMBER: - return 21; - default: - return 16; - } + if (donator == (Common_Get(player_no) + 1)) { + return 4; } - case mMmd_DONATOR_DELETED_PLAYER: - return 12; - } + switch (donator) { + case mMmd_DONATOR_NONE: { + switch (item) { + case FTR_FOSSIL_TRILOBITE: + return 17; + case FTR_FOSSIL_AMMONITE: + return 18; + case FTR_FOSSIL_EGG: + return 19; + case FTR_FOSSIL_TRACK: + return 20; + case FTR_FOSSIL_AMBER: + return 21; + default: + return 16; + } + } - aCR_set_other_player_name_str(donator - 1); - return 8; + case mMmd_DONATOR_DELETED_PLAYER: + return 12; + } + + aCR_set_other_player_name_str(donator - 1); + return 8; } static int aCR_get_idx_to_donate_art(mActor_name_t item) { - int donator = aCR_GetArtDonator(item); + int donator = aCR_GetArtDonator(item); - switch (item) { - case FTR_PAINTING15_UNUSED: - case FTR_PAINTING16_UNUSED: - return 1; - } + switch (item) { + case FTR_PAINTING15_UNUSED: + case FTR_PAINTING16_UNUSED: + return 1; + } - if (donator == (Common_Get(player_no) + 1)) { - return 5; - } - - switch (donator) { - case mMmd_DONATOR_NONE: - return 22 + RANDOM(3); - case mMmd_DONATOR_DELETED_PLAYER: - return 13; - } + if (donator == (Common_Get(player_no) + 1)) { + return 5; + } - aCR_set_other_player_name_str(donator - 1); - return 9; + switch (donator) { + case mMmd_DONATOR_NONE: + return 22 + RANDOM(3); + case mMmd_DONATOR_DELETED_PLAYER: + return 13; + } + + aCR_set_other_player_name_str(donator - 1); + return 9; } static int aCR_get_idx_to_donate_insect(mActor_name_t item) { - int donator = aCR_GetInsectDonator(item); - int res; + int donator = aCR_GetInsectDonator(item); + int res; - if (donator == (Common_Get(player_no) + 1)) { - res = 7; - } - else { - switch (donator) { - case mMmd_DONATOR_NONE: - { - /* Is it a cockroach? */ - if (item == ITM_INSECT28) { - res = 26; - } - else { - res = 25; - } - break; + if (donator == (Common_Get(player_no) + 1)) { + res = 7; + } else { + switch (donator) { + case mMmd_DONATOR_NONE: { + /* Is it a cockroach? */ + if (item == ITM_INSECT28) { + res = 26; + } else { + res = 25; + } + break; + } + + case mMmd_DONATOR_DELETED_PLAYER: + res = 15; + break; + + default: + aCR_set_other_player_name_str(donator - 1); + res = 11; + break; + } } - case mMmd_DONATOR_DELETED_PLAYER: - res = 15; - break; - - default: - aCR_set_other_player_name_str(donator - 1); - res = 11; - break; - } - } - - return res; + return res; } static int aCR_get_idx_to_donate_fish(mActor_name_t item) { - int donator = aCR_GetFishDonator(item); + int donator = aCR_GetFishDonator(item); - if (donator == (Common_Get(player_no) + 1)) { - return 6; - } - - switch (donator) { - case mMmd_DONATOR_NONE: - return 27; + if (donator == (Common_Get(player_no) + 1)) { + return 6; + } - case mMmd_DONATOR_DELETED_PLAYER: - return 14; - } + switch (donator) { + case mMmd_DONATOR_NONE: + return 27; - aCR_set_other_player_name_str(donator - 1); - return 10; + case mMmd_DONATOR_DELETED_PLAYER: + return 14; + } + + aCR_set_other_player_name_str(donator - 1); + return 10; } static void aCR_after_talk_start_wait(NPC_CURATOR_ACTOR* curator, GAME_PLAY* play) { - mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); + mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); - if (mMsg_Check_MainNormalContinue(msg_p) == TRUE) { - int msg_no = aCR_get_msg_no_after_talk(); - - mMsg_Set_continue_msg_num(msg_p, msg_no); - (*curator->setupTalkAction_proc)(curator, play, aCR_TALK_END_WAIT); - } + if (mMsg_Check_MainNormalContinue(msg_p) == TRUE) { + int msg_no = aCR_get_msg_no_after_talk(); + + mMsg_Set_continue_msg_num(msg_p, msg_no); + (*curator->setupTalkAction_proc)(curator, play, aCR_TALK_END_WAIT); + } } static void aCR_chk_request(NPC_CURATOR_ACTOR* curator, GAME_PLAY* play) { - mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); - int talk_act; + mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); + int talk_act; - if (mMsg_Get_msg_num(msg_p) == 0x2F50 && mMsg_Check_MainNormalContinue(msg_p) == TRUE) { - switch (mChoice_Get_ChoseNum(mChoice_Get_base_window_p())) { - case mChoice_CHOICE0: - talk_act = aCR_TALK_MENU_OPEN_WAIT; - break; - case mChoice_CHOICE1: - talk_act = aCR_TALK_CHK_DECIDE_TO_DONATE; - break; - case mChoice_CHOICE2: - talk_act = aCR_TALK_AFTER_TALK_START_WAIT; - break; - default: - talk_act = aCR_TALK_END_WAIT; - break; + if (mMsg_Get_msg_num(msg_p) == 0x2F50 && mMsg_Check_MainNormalContinue(msg_p) == TRUE) { + switch (mChoice_Get_ChoseNum(mChoice_Get_base_window_p())) { + case mChoice_CHOICE0: + talk_act = aCR_TALK_MENU_OPEN_WAIT; + break; + case mChoice_CHOICE1: + talk_act = aCR_TALK_CHK_DECIDE_TO_DONATE; + break; + case mChoice_CHOICE2: + talk_act = aCR_TALK_AFTER_TALK_START_WAIT; + break; + default: + talk_act = aCR_TALK_END_WAIT; + break; + } + + (*curator->setupTalkAction_proc)(curator, play, talk_act); } - - (*curator->setupTalkAction_proc)(curator, play, talk_act); - } } static void aCR_chk_decide_to_donate(NPC_CURATOR_ACTOR* curator, GAME_PLAY* play) { - mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); - int talk_act; + mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); + int talk_act; - if (mMsg_Get_msg_num(msg_p) == 0x2F5F && mMsg_Check_MainNormalContinue(msg_p) == TRUE) { - switch (mChoice_Get_ChoseNum(mChoice_Get_base_window_p())) { - case mChoice_CHOICE0: - talk_act = aCR_TALK_CHK_DECIDE_TO_DONATE2; - break; - case mChoice_CHOICE1: - talk_act = aCR_TALK_END_WAIT; - break; - default: - talk_act = aCR_TALK_END_WAIT; - break; + if (mMsg_Get_msg_num(msg_p) == 0x2F5F && mMsg_Check_MainNormalContinue(msg_p) == TRUE) { + switch (mChoice_Get_ChoseNum(mChoice_Get_base_window_p())) { + case mChoice_CHOICE0: + talk_act = aCR_TALK_CHK_DECIDE_TO_DONATE2; + break; + case mChoice_CHOICE1: + talk_act = aCR_TALK_END_WAIT; + break; + default: + talk_act = aCR_TALK_END_WAIT; + break; + } + + (*curator->setupTalkAction_proc)(curator, play, talk_act); } - - (*curator->setupTalkAction_proc)(curator, play, talk_act); - } } static void aCR_chk_decide_to_donate2(NPC_CURATOR_ACTOR* curator, GAME_PLAY* play) { - mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); - int talk_act; + mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); + int talk_act; - if (mMsg_Get_msg_num(msg_p) == 0x2F60 && mMsg_Check_MainNormalContinue(msg_p) == TRUE) { - switch (mChoice_Get_ChoseNum(mChoice_Get_base_window_p())) { - case mChoice_CHOICE0: - talk_act = aCR_TALK_MENU_OPEN_WAIT; - break; - case mChoice_CHOICE1: - talk_act = aCR_TALK_END_WAIT; - break; - default: - talk_act = aCR_TALK_END_WAIT; - break; + if (mMsg_Get_msg_num(msg_p) == 0x2F60 && mMsg_Check_MainNormalContinue(msg_p) == TRUE) { + switch (mChoice_Get_ChoseNum(mChoice_Get_base_window_p())) { + case mChoice_CHOICE0: + talk_act = aCR_TALK_MENU_OPEN_WAIT; + break; + case mChoice_CHOICE1: + talk_act = aCR_TALK_END_WAIT; + break; + default: + talk_act = aCR_TALK_END_WAIT; + break; + } + + (*curator->setupTalkAction_proc)(curator, play, talk_act); } - - (*curator->setupTalkAction_proc)(curator, play, talk_act); - } } static void aCR_menu_open_wait(NPC_CURATOR_ACTOR* curator, GAME_PLAY* play) { - if (mMsg_Check_MainNormalContinue(mMsg_Get_base_window_p()) == TRUE) { - (*curator->setupTalkAction_proc)(curator, play, aCR_TALK_MSG_WIN_CLOSE_WAIT); - } + if (mMsg_Check_MainNormalContinue(mMsg_Get_base_window_p()) == TRUE) { + (*curator->setupTalkAction_proc)(curator, play, aCR_TALK_MSG_WIN_CLOSE_WAIT); + } } static void aCR_msg_win_close_wait(NPC_CURATOR_ACTOR* curator, GAME_PLAY* play) { - if (mMsg_Check_main_wait(mMsg_Get_base_window_p()) == TRUE) { - (*curator->setupTalkAction_proc)(curator, play, aCR_TALK_MENU_CLOSE_WAIT); - } + if (mMsg_Check_main_wait(mMsg_Get_base_window_p()) == TRUE) { + (*curator->setupTalkAction_proc)(curator, play, aCR_TALK_MENU_CLOSE_WAIT); + } } static void aCR_menu_close_wait(NPC_CURATOR_ACTOR* curator, GAME_PLAY* play) { - int talk_act; + int talk_act; - if (play->submenu.open_flag == FALSE) { - talk_act = aCR_TALK_GET_DEMO_START_WAIT; + if (play->submenu.open_flag == FALSE) { + talk_act = aCR_TALK_GET_DEMO_START_WAIT; - if (play->submenu.item_p->item == EMPTY_NO) { - talk_act = aCR_TALK_MSG_WIN_OPEN_WAIT; + if (play->submenu.item_p->item == EMPTY_NO) { + talk_act = aCR_TALK_MSG_WIN_OPEN_WAIT; + } + + (*curator->setupTalkAction_proc)(curator, play, talk_act); } - - (*curator->setupTalkAction_proc)(curator, play, talk_act); - } } static void aCR_get_demo_start_wait(NPC_CURATOR_ACTOR* curator, GAME_PLAY* play) { - if (Common_Get(clip).handOverItem_clip->request_mode == aHOI_REQUEST_TRANS_WAIT) { - (*curator->setupTalkAction_proc)(curator, play, aCR_TALK_GET_DEMO_END_WAIT); - } + if (Common_Get(clip).handOverItem_clip->request_mode == aHOI_REQUEST_TRANS_WAIT) { + (*curator->setupTalkAction_proc)(curator, play, aCR_TALK_GET_DEMO_END_WAIT); + } } static void aCR_get_demo_end_wait(NPC_CURATOR_ACTOR* curator, GAME_PLAY* play) { - if (Common_Get(clip).handOverItem_clip->request_mode == aHOI_REQUEST_GET_PULL_WAIT) { - curator->npc_class.talk_info.default_animation = 30; - (*curator->setupTalkAction_proc)(curator, play, aCR_TALK_MSG_WIN_OPEN_WAIT); - } + if (Common_Get(clip).handOverItem_clip->request_mode == aHOI_REQUEST_GET_PULL_WAIT) { + curator->npc_class.talk_info.default_animation = 30; + (*curator->setupTalkAction_proc)(curator, play, aCR_TALK_MSG_WIN_OPEN_WAIT); + } } -#define aCR_IS_FOSSIL(item) \ - ((item) >= FTR_DINO_START && (item) <= FTR_DINO_END) +#define aCR_IS_FOSSIL(item) ((item) >= FTR_DINO_START && (item) <= FTR_DINO_END) -#define aCR_IS_ART(item) \ - ((item) >= FTR_PAINTING0 && (item) <= FTR_PAINTING14_WEST) +#define aCR_IS_ART(item) ((item) >= FTR_PAINTING0 && (item) <= FTR_PAINTING14_WEST) -#define aCR_IS_INSECT(item) \ - ((item) >= ITM_INSECT_START && (item) < ITM_INSECT_END) +#define aCR_IS_INSECT(item) ((item) >= ITM_INSECT_START && (item) < ITM_INSECT_END) -#define aCR_IS_FISH(item) \ - ((item) >= ITM_FISH_START && (item) <= ITM_FISH_END) +#define aCR_IS_FISH(item) ((item) >= ITM_FISH_START && (item) <= ITM_FISH_END) typedef struct { - int msg_no; - int talk_act; + int msg_no; + int talk_act; } aCR_donate_act_c; static void aCR_msg_win_open_wait(NPC_CURATOR_ACTOR* curator, GAME_PLAY* play) { - static aCR_donate_act_c donate_act[] = { - { 0x2F63, aCR_TALK_END_WAIT }, - { 0x3A83, aCR_TALK_RETURN_DEMO_START_WAIT }, - { 0x2F64, aCR_TALK_RETURN_DEMO_START_WAIT }, - { 0x2F65, aCR_TALK_RETURN_DEMO_START_WAIT }, - { 0x2F6B, aCR_TALK_RETURN_DEMO_START_WAIT2 }, - { 0x2F6C, aCR_TALK_RETURN_DEMO_START_WAIT2 }, - { 0x2F6D, aCR_TALK_RETURN_DEMO_START_WAIT2 }, - { 0x2F6E, aCR_TALK_RETURN_DEMO_START_WAIT2 }, - { 0x2F67, aCR_TALK_RETURN_DEMO_START_WAIT2 }, - { 0x2F68, aCR_TALK_RETURN_DEMO_START_WAIT2 }, - { 0x2F69, aCR_TALK_RETURN_DEMO_START_WAIT2 }, - { 0x2F6A, aCR_TALK_RETURN_DEMO_START_WAIT2 }, - { 0x2F90, aCR_TALK_RETURN_DEMO_START_WAIT2 }, - { 0x2F91, aCR_TALK_RETURN_DEMO_START_WAIT2 }, - { 0x2F92, aCR_TALK_RETURN_DEMO_START_WAIT2 }, - { 0x2F93, aCR_TALK_RETURN_DEMO_START_WAIT2 }, - { 0x2F8F, aCR_TALK_PUTAWAY_DEMO_START_WAIT2 }, - { 0x2F7F, aCR_TALK_PUTAWAY_DEMO_START_WAIT3 }, - { 0x2F80, aCR_TALK_PUTAWAY_DEMO_START_WAIT3 }, - { 0x2F81, aCR_TALK_PUTAWAY_DEMO_START_WAIT3 }, - { 0x2F82, aCR_TALK_PUTAWAY_DEMO_START_WAIT3 }, - { 0x2F83, aCR_TALK_PUTAWAY_DEMO_START_WAIT3 }, - { 0x2F70, aCR_TALK_PUTAWAY_DEMO_START_WAIT }, - { 0x2F71, aCR_TALK_PUTAWAY_DEMO_START_WAIT }, - { 0x2F72, aCR_TALK_PUTAWAY_DEMO_START_WAIT }, - { 0x2F86, aCR_TALK_PUTAWAY_DEMO_START_WAIT5 }, - { 0x2F87, aCR_TALK_PUTAWAY_DEMO_START_WAIT4 }, - { 0x2F89, aCR_TALK_PUTAWAY_DEMO_START_WAIT5_2 } - }; + static aCR_donate_act_c donate_act[] = { { 0x2F63, aCR_TALK_END_WAIT }, + { 0x3A83, aCR_TALK_RETURN_DEMO_START_WAIT }, + { 0x2F64, aCR_TALK_RETURN_DEMO_START_WAIT }, + { 0x2F65, aCR_TALK_RETURN_DEMO_START_WAIT }, + { 0x2F6B, aCR_TALK_RETURN_DEMO_START_WAIT2 }, + { 0x2F6C, aCR_TALK_RETURN_DEMO_START_WAIT2 }, + { 0x2F6D, aCR_TALK_RETURN_DEMO_START_WAIT2 }, + { 0x2F6E, aCR_TALK_RETURN_DEMO_START_WAIT2 }, + { 0x2F67, aCR_TALK_RETURN_DEMO_START_WAIT2 }, + { 0x2F68, aCR_TALK_RETURN_DEMO_START_WAIT2 }, + { 0x2F69, aCR_TALK_RETURN_DEMO_START_WAIT2 }, + { 0x2F6A, aCR_TALK_RETURN_DEMO_START_WAIT2 }, + { 0x2F90, aCR_TALK_RETURN_DEMO_START_WAIT2 }, + { 0x2F91, aCR_TALK_RETURN_DEMO_START_WAIT2 }, + { 0x2F92, aCR_TALK_RETURN_DEMO_START_WAIT2 }, + { 0x2F93, aCR_TALK_RETURN_DEMO_START_WAIT2 }, + { 0x2F8F, aCR_TALK_PUTAWAY_DEMO_START_WAIT2 }, + { 0x2F7F, aCR_TALK_PUTAWAY_DEMO_START_WAIT3 }, + { 0x2F80, aCR_TALK_PUTAWAY_DEMO_START_WAIT3 }, + { 0x2F81, aCR_TALK_PUTAWAY_DEMO_START_WAIT3 }, + { 0x2F82, aCR_TALK_PUTAWAY_DEMO_START_WAIT3 }, + { 0x2F83, aCR_TALK_PUTAWAY_DEMO_START_WAIT3 }, + { 0x2F70, aCR_TALK_PUTAWAY_DEMO_START_WAIT }, + { 0x2F71, aCR_TALK_PUTAWAY_DEMO_START_WAIT }, + { 0x2F72, aCR_TALK_PUTAWAY_DEMO_START_WAIT }, + { 0x2F86, aCR_TALK_PUTAWAY_DEMO_START_WAIT5 }, + { 0x2F87, aCR_TALK_PUTAWAY_DEMO_START_WAIT4 }, + { 0x2F89, aCR_TALK_PUTAWAY_DEMO_START_WAIT5_2 } }; - mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); - mActor_name_t item; - int act_idx; - aCR_donate_act_c* donate_act_p; + mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); + mActor_name_t item; + int act_idx; + aCR_donate_act_c* donate_act_p; - if (mMsg_Check_not_series_main_wait(msg_p) == TRUE) { - act_idx = 0; - item = play->submenu.item_p->item; + if (mMsg_Check_not_series_main_wait(msg_p) == TRUE) { + act_idx = 0; + item = play->submenu.item_p->item; - if (item != EMPTY_NO) { - if (aCR_IS_FOSSIL(item) == TRUE) { - act_idx = aCR_get_idx_to_donate_fossil(item); - } - else if (aCR_IS_ART(item) == TRUE) { - act_idx = aCR_get_idx_to_donate_art(item); - } - else if (aCR_IS_INSECT(item) == TRUE) { - act_idx = aCR_get_idx_to_donate_insect(item); - } - else if (aCR_IS_FISH(item) == TRUE) { - act_idx = aCR_get_idx_to_donate_fish(item); - } - else if (item == ITM_FOSSIL) { - act_idx = 3; - } - else { - act_idx = 2; - } + if (item != EMPTY_NO) { + if (aCR_IS_FOSSIL(item) == TRUE) { + act_idx = aCR_get_idx_to_donate_fossil(item); + } else if (aCR_IS_ART(item) == TRUE) { + act_idx = aCR_get_idx_to_donate_art(item); + } else if (aCR_IS_INSECT(item) == TRUE) { + act_idx = aCR_get_idx_to_donate_insect(item); + } else if (aCR_IS_FISH(item) == TRUE) { + act_idx = aCR_get_idx_to_donate_fish(item); + } else if (item == ITM_FOSSIL) { + act_idx = 3; + } else { + act_idx = 2; + } - aCR_set_item_name_str(item); + aCR_set_item_name_str(item); + } + + donate_act_p = &donate_act[act_idx]; + curator->donated_item = item; + mMsg_Set_continue_msg_num(msg_p, donate_act_p->msg_no); + mMsg_Set_ForceNext(msg_p); + (*curator->setupTalkAction_proc)(curator, play, donate_act_p->talk_act); } - - donate_act_p = &donate_act[act_idx]; - curator->donated_item = item; - mMsg_Set_continue_msg_num(msg_p, donate_act_p->msg_no); - mMsg_Set_ForceNext(msg_p); - (*curator->setupTalkAction_proc)(curator, play, donate_act_p->talk_act); - } } static void aCR_return_demo_start_wait(NPC_CURATOR_ACTOR* curator, GAME_PLAY* play) { - int order = mDemo_Get_OrderValue(mDemo_ORDER_NPC0, 1); + int order = mDemo_Get_OrderValue(mDemo_ORDER_NPC0, 1); - if (order == 10) { - int talk_act = aCR_TALK_RETURN_DEMO_END_WAIT; + if (order == 10) { + int talk_act = aCR_TALK_RETURN_DEMO_END_WAIT; - if (curator->talk_act_idx != aCR_TALK_RETURN_DEMO_START_WAIT) { - talk_act = aCR_TALK_RETURN_DEMO_END_WAIT2; + if (curator->talk_act_idx != aCR_TALK_RETURN_DEMO_START_WAIT) { + talk_act = aCR_TALK_RETURN_DEMO_END_WAIT2; + } + + (*curator->setupTalkAction_proc)(curator, play, talk_act); } - - (*curator->setupTalkAction_proc)(curator, play, talk_act); - } } static void aCR_return_demo_end_wait(NPC_CURATOR_ACTOR* curator, GAME_PLAY* play) { - if (Common_Get(clip).handOverItem_clip->master_actor == NULL) { - mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); - int talk_act = aCR_TALK_CHK_CONTINUE_TO_DONATE; + if (Common_Get(clip).handOverItem_clip->master_actor == NULL) { + mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); + int talk_act = aCR_TALK_CHK_CONTINUE_TO_DONATE; - if (curator->talk_act_idx != aCR_TALK_RETURN_DEMO_END_WAIT) { - talk_act = aCR_TALK_CHK_CONTINUE_TO_DONATE2; + if (curator->talk_act_idx != aCR_TALK_RETURN_DEMO_END_WAIT) { + talk_act = aCR_TALK_CHK_CONTINUE_TO_DONATE2; + } + + curator->npc_class.talk_info.default_animation = -1; + mMsg_Unset_LockContinue(msg_p); + (*curator->setupTalkAction_proc)(curator, play, talk_act); } - - curator->npc_class.talk_info.default_animation = -1; - mMsg_Unset_LockContinue(msg_p); - (*curator->setupTalkAction_proc)(curator, play, talk_act); - } } static void aCR_chk_continue_to_donate(NPC_CURATOR_ACTOR* curator, GAME_PLAY* play) { - static int chk_msg_num[] = { 0x2F66, 0x2F6F, 0x2F73 }; + static int chk_msg_num[] = { 0x2F66, 0x2F6F, 0x2F73 }; - mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); - int donate_idx = curator->talk_act_idx - aCR_TALK_CHK_CONTINUE_TO_DONATE; + mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); + int donate_idx = curator->talk_act_idx - aCR_TALK_CHK_CONTINUE_TO_DONATE; - if (chk_msg_num[donate_idx] == mMsg_Get_msg_num(msg_p) && mMsg_Check_MainNormalContinue(msg_p)) { - int talk_act = aCR_TALK_END_WAIT; - int msg_no; + if (chk_msg_num[donate_idx] == mMsg_Get_msg_num(msg_p) && mMsg_Check_MainNormalContinue(msg_p)) { + int talk_act = aCR_TALK_END_WAIT; + int msg_no; - if (mChoice_Get_ChoseNum(mChoice_Get_base_window_p()) == mChoice_CHOICE0) { - talk_act = aCR_TALK_MENU_OPEN_WAIT; - msg_no = 0x2F62; + if (mChoice_Get_ChoseNum(mChoice_Get_base_window_p()) == mChoice_CHOICE0) { + talk_act = aCR_TALK_MENU_OPEN_WAIT; + msg_no = 0x2F62; + } else { + msg_no = aCR_get_msg_no_after_talk(); + } + + if (curator->talk_act_idx != aCR_TALK_CHK_CONTINUE_TO_DONATE3) { + mMsg_Set_continue_msg_num(msg_p, msg_no); + } + + (*curator->setupTalkAction_proc)(curator, play, talk_act); } - else { - msg_no = aCR_get_msg_no_after_talk(); - } - - if (curator->talk_act_idx != aCR_TALK_CHK_CONTINUE_TO_DONATE3) { - mMsg_Set_continue_msg_num(msg_p, msg_no); - } - - (*curator->setupTalkAction_proc)(curator, play, talk_act); - } } static void aCR_putaway_demo_start_wait(NPC_CURATOR_ACTOR* curator, GAME_PLAY* play) { - int order = mDemo_Get_OrderValue(mDemo_ORDER_NPC0, 1); - - if (order == 14) { - (*curator->setupTalkAction_proc)(curator, play, curator->talk_act_idx + (aCR_TALK_PUTAWAY_DEMO_END_WAIT - aCR_TALK_PUTAWAY_DEMO_START_WAIT)); - } + int order = mDemo_Get_OrderValue(mDemo_ORDER_NPC0, 1); + + if (order == 14) { + (*curator->setupTalkAction_proc)( + curator, play, curator->talk_act_idx + (aCR_TALK_PUTAWAY_DEMO_END_WAIT - aCR_TALK_PUTAWAY_DEMO_START_WAIT)); + } } static void aCR_putaway_demo_start_wait5_2(NPC_CURATOR_ACTOR* curator, GAME_PLAY* play) { - static int msg_no[FISH_NUM + 1] = { - 0x3A6D, - 0x3A6E, - 0x3A6D, - 0x3A80, - 0x3A6D, - 0x3A6D, - 0x3A6E, - 0x3A6F, - 0x3A6D, - 0x3A70, - 0x3A71, - 0x3A6D, - 0x3A6E, - 0x3A72, - 0x3A6D, - 0x3A6D, - 0x3A6D, - 0x3A73, - 0x3A6E, - 0x3A81, - 0x3A6E, - 0x3A74, - 0x3A6D, - 0x3A7D, - 0x3A75, - 0x3A76, - 0x3A6E, - 0x3A6E, - 0x3A7E, - 0x3A77, - 0x3A7D, - 0x3A79, - 0x3A7C, - 0x3A82, - 0x3A77, - 0x3A7F, - 0x3A6D, - 0x3A7A, - 0x3A7B, - 0x3A78 - // uninitialized entry here - }; + static int msg_no[FISH_NUM + 1] = { + 0x3A6D, 0x3A6E, 0x3A6D, 0x3A80, 0x3A6D, 0x3A6D, 0x3A6E, 0x3A6F, 0x3A6D, 0x3A70, 0x3A71, 0x3A6D, 0x3A6E, 0x3A72, + 0x3A6D, 0x3A6D, 0x3A6D, 0x3A73, 0x3A6E, 0x3A81, 0x3A6E, 0x3A74, 0x3A6D, 0x3A7D, 0x3A75, 0x3A76, 0x3A6E, 0x3A6E, + 0x3A7E, 0x3A77, 0x3A7D, 0x3A79, 0x3A7C, 0x3A82, 0x3A77, 0x3A7F, 0x3A6D, 0x3A7A, 0x3A7B, 0x3A78 + // uninitialized entry here + }; - mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); + mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); - if (mMsg_Get_msg_num(msg_p) == 0x2F89) { - int fish_type = curator->donated_item - ITM_FISH_START; + if (mMsg_Get_msg_num(msg_p) == 0x2F89) { + int fish_type = curator->donated_item - ITM_FISH_START; - if (fish_type < 0 || fish_type >= (FISH_NUM + 1)) { - fish_type = 0; + if (fish_type < 0 || fish_type >= (FISH_NUM + 1)) { + fish_type = 0; + } + + mMsg_Set_continue_msg_num(msg_p, msg_no[fish_type]); + (*curator->setupTalkAction_proc)(curator, play, aCR_TALK_PUTAWAY_DEMO_START_WAIT6); } - - mMsg_Set_continue_msg_num(msg_p, msg_no[fish_type]); - (*curator->setupTalkAction_proc)(curator, play, aCR_TALK_PUTAWAY_DEMO_START_WAIT6); - } } static void aCR_putaway_demo_end_wait(NPC_CURATOR_ACTOR* curator, GAME_PLAY* play) { - if (Common_Get(clip).handOverItem_clip->master_actor == NULL) { - curator->npc_class.talk_info.default_animation = -1; - mMsg_Unset_LockContinue(mMsg_Get_base_window_p()); + if (Common_Get(clip).handOverItem_clip->master_actor == NULL) { + curator->npc_class.talk_info.default_animation = -1; + mMsg_Unset_LockContinue(mMsg_Get_base_window_p()); - switch (curator->talk_act_idx) { - case aCR_TALK_PUTAWAY_DEMO_END_WAIT: - aCR_chk_art_complete(curator, play); - break; - case aCR_TALK_PUTAWAY_DEMO_END_WAIT2: - aCR_chk_fossil_parts_complete(curator, play); - break; - case aCR_TALK_PUTAWAY_DEMO_END_WAIT3: - aCR_chk_fossil_complete(curator, play); - break; - case aCR_TALK_PUTAWAY_DEMO_END_WAIT4: - aCR_chk_insect_complete(curator, play); - break; - case aCR_TALK_PUTAWAY_DEMO_END_WAIT5: - aCR_set_after_explain_insect(curator, play); - break; - case aCR_TALK_PUTAWAY_DEMO_END_WAIT6: - aCR_chk_fish_complete(curator, play); - break; + switch (curator->talk_act_idx) { + case aCR_TALK_PUTAWAY_DEMO_END_WAIT: + aCR_chk_art_complete(curator, play); + break; + case aCR_TALK_PUTAWAY_DEMO_END_WAIT2: + aCR_chk_fossil_parts_complete(curator, play); + break; + case aCR_TALK_PUTAWAY_DEMO_END_WAIT3: + aCR_chk_fossil_complete(curator, play); + break; + case aCR_TALK_PUTAWAY_DEMO_END_WAIT4: + aCR_chk_insect_complete(curator, play); + break; + case aCR_TALK_PUTAWAY_DEMO_END_WAIT5: + aCR_set_after_explain_insect(curator, play); + break; + case aCR_TALK_PUTAWAY_DEMO_END_WAIT6: + aCR_chk_fish_complete(curator, play); + break; + } } - } } static void aCR_after_explain_insect(NPC_CURATOR_ACTOR* curator, GAME_PLAY* play) { - mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); + mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); - if (curator->msg_no == mMsg_Get_msg_num(msg_p) && mMsg_Check_MainNormalContinue(msg_p)) { - aCR_chk_insect_complete(curator, play); - } + if (curator->msg_no == mMsg_Get_msg_num(msg_p) && mMsg_Check_MainNormalContinue(msg_p)) { + aCR_chk_insect_complete(curator, play); + } } static void aCR_thanks_fossil_msg_end_wait(NPC_CURATOR_ACTOR* curator, GAME_PLAY* play) { - mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); + mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); - if (curator->msg_no == mMsg_Get_msg_num(msg_p) && mMsg_Check_MainNormalContinue(msg_p)) { - aCR_chk_fossil_complete(curator, play); - } + if (curator->msg_no == mMsg_Get_msg_num(msg_p) && mMsg_Check_MainNormalContinue(msg_p)) { + aCR_chk_fossil_complete(curator, play); + } } static void aCR_chk_all_complete(NPC_CURATOR_ACTOR* curator, GAME_PLAY* play) { - static int msg_no[] = { 0x2F76, 0x2F77 }; - mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); + static int msg_no[] = { 0x2F76, 0x2F77 }; + mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); - if (curator->msg_no == mMsg_Get_msg_num(msg_p) && mMsg_Check_MainNormalContinue(msg_p) == TRUE) { - int msg_idx = 0; + if (curator->msg_no == mMsg_Get_msg_num(msg_p) && mMsg_Check_MainNormalContinue(msg_p) == TRUE) { + int msg_idx = 0; - if (aCR_countDisplayed() == (mMmd_FOSSIL_NUM + mMmd_ART_NUM + mMmd_INSECT_NUM + mMmd_FISH_NUM)) { - mMsm_SetCompMail(); - msg_idx = 1; + if (aCR_countDisplayed() == (mMmd_FOSSIL_NUM + mMmd_ART_NUM + mMmd_INSECT_NUM + mMmd_FISH_NUM)) { + mMsm_SetCompMail(); + msg_idx = 1; + } + + mMsg_Set_continue_msg_num(msg_p, msg_no[msg_idx]); + (*curator->setupTalkAction_proc)(curator, play, aCR_TALK_END_WAIT); } - - mMsg_Set_continue_msg_num(msg_p, msg_no[msg_idx]); - (*curator->setupTalkAction_proc)(curator, play, aCR_TALK_END_WAIT); - } } static void aCR_msg_win_close_wait_init(NPC_CURATOR_ACTOR* curator, GAME_PLAY* play) { - mMsg_request_main_disappear_wait_type1(mMsg_Get_base_window_p()); + mMsg_request_main_disappear_wait_type1(mMsg_Get_base_window_p()); } static void aCR_menu_close_wait_init(NPC_CURATOR_ACTOR* curator, GAME_PLAY* play) { - mSM_open_submenu(&play->submenu, mSM_OVL_INVENTORY, mSM_IV_OPEN_CURATOR, 0); + mSM_open_submenu(&play->submenu, mSM_OVL_INVENTORY, mSM_IV_OPEN_CURATOR, 0); } static void aCR_get_demo_end_wait_init(NPC_CURATOR_ACTOR* curator, GAME_PLAY* play) { - mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 1, 3); - Common_Get(clip).handOverItem_clip->player_after_mode = 8; + mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 1, 3); + Common_Get(clip).handOverItem_clip->player_after_mode = 8; } static void aCR_msg_win_open_wait_init(NPC_CURATOR_ACTOR* curator, GAME_PLAY* play) { - mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); + mMsg_Window_c* msg_p = mMsg_Get_base_window_p(); - mMsg_request_main_appear_wait_type1(msg_p); - mMsg_Unset_LockContinue(msg_p); + mMsg_request_main_appear_wait_type1(msg_p); + mMsg_Unset_LockContinue(msg_p); } static void aCR_return_demo_end_wait_init(NPC_CURATOR_ACTOR* curator, GAME_PLAY* play) { - mMsg_Set_LockContinue(mMsg_Get_base_window_p()); + mMsg_Set_LockContinue(mMsg_Get_base_window_p()); } static void aCR_putaway_demo_end_wait_init(NPC_CURATOR_ACTOR* curator, GAME_PLAY* play) { - Submenu_Item_c* sm_item_p = play->submenu.item_p; + Submenu_Item_c* sm_item_p = play->submenu.item_p; - if (mMmd_RequestMuseumDisplay(sm_item_p->item) == TRUE) { - mPr_SetPossessionItem(Common_Get(now_private), sm_item_p->slot_no, EMPTY_NO, mPr_ITEM_COND_NORMAL); - } + if (mMmd_RequestMuseumDisplay(sm_item_p->item) == TRUE) { + mPr_SetPossessionItem(Common_Get(now_private), sm_item_p->slot_no, EMPTY_NO, mPr_ITEM_COND_NORMAL); + } - mMsg_Set_LockContinue(mMsg_Get_base_window_p()); + mMsg_Set_LockContinue(mMsg_Get_base_window_p()); } typedef void (*aCR_TALK_INIT_PROC)(NPC_CURATOR_ACTOR*, GAME_PLAY*); static void aCR_talk_init_proc(NPC_CURATOR_ACTOR* curator, GAME_PLAY* play, int talk_act) { - static aCR_TALK_INIT_PROC init_proc[aCR_TALK_NUM] = { - (aCR_TALK_INIT_PROC)none_proc1, - (aCR_TALK_INIT_PROC)none_proc1, - (aCR_TALK_INIT_PROC)none_proc1, - (aCR_TALK_INIT_PROC)none_proc1, - (aCR_TALK_INIT_PROC)none_proc1, - (aCR_TALK_INIT_PROC)none_proc1, - &aCR_msg_win_close_wait_init, - &aCR_menu_close_wait_init, - (aCR_TALK_INIT_PROC)none_proc1, - &aCR_get_demo_end_wait_init, - &aCR_msg_win_open_wait_init, - (aCR_TALK_INIT_PROC)none_proc1, - (aCR_TALK_INIT_PROC)none_proc1, - &aCR_return_demo_end_wait_init, - &aCR_return_demo_end_wait_init, - (aCR_TALK_INIT_PROC)none_proc1, - (aCR_TALK_INIT_PROC)none_proc1, - (aCR_TALK_INIT_PROC)none_proc1, - (aCR_TALK_INIT_PROC)none_proc1, - (aCR_TALK_INIT_PROC)none_proc1, - (aCR_TALK_INIT_PROC)none_proc1, - (aCR_TALK_INIT_PROC)none_proc1, - (aCR_TALK_INIT_PROC)none_proc1, - (aCR_TALK_INIT_PROC)none_proc1, - (aCR_TALK_INIT_PROC)none_proc1, - &aCR_putaway_demo_end_wait_init, - &aCR_putaway_demo_end_wait_init, - &aCR_putaway_demo_end_wait_init, - &aCR_putaway_demo_end_wait_init, - &aCR_putaway_demo_end_wait_init, - &aCR_putaway_demo_end_wait_init, - (aCR_TALK_INIT_PROC)none_proc1, - (aCR_TALK_INIT_PROC)none_proc1, - (aCR_TALK_INIT_PROC)none_proc1 - }; + static aCR_TALK_INIT_PROC init_proc[aCR_TALK_NUM] = { + (aCR_TALK_INIT_PROC)none_proc1, (aCR_TALK_INIT_PROC)none_proc1, (aCR_TALK_INIT_PROC)none_proc1, + (aCR_TALK_INIT_PROC)none_proc1, (aCR_TALK_INIT_PROC)none_proc1, (aCR_TALK_INIT_PROC)none_proc1, + &aCR_msg_win_close_wait_init, &aCR_menu_close_wait_init, (aCR_TALK_INIT_PROC)none_proc1, + &aCR_get_demo_end_wait_init, &aCR_msg_win_open_wait_init, (aCR_TALK_INIT_PROC)none_proc1, + (aCR_TALK_INIT_PROC)none_proc1, &aCR_return_demo_end_wait_init, &aCR_return_demo_end_wait_init, + (aCR_TALK_INIT_PROC)none_proc1, (aCR_TALK_INIT_PROC)none_proc1, (aCR_TALK_INIT_PROC)none_proc1, + (aCR_TALK_INIT_PROC)none_proc1, (aCR_TALK_INIT_PROC)none_proc1, (aCR_TALK_INIT_PROC)none_proc1, + (aCR_TALK_INIT_PROC)none_proc1, (aCR_TALK_INIT_PROC)none_proc1, (aCR_TALK_INIT_PROC)none_proc1, + (aCR_TALK_INIT_PROC)none_proc1, &aCR_putaway_demo_end_wait_init, &aCR_putaway_demo_end_wait_init, + &aCR_putaway_demo_end_wait_init, &aCR_putaway_demo_end_wait_init, &aCR_putaway_demo_end_wait_init, + &aCR_putaway_demo_end_wait_init, (aCR_TALK_INIT_PROC)none_proc1, (aCR_TALK_INIT_PROC)none_proc1, + (aCR_TALK_INIT_PROC)none_proc1 + }; - (*init_proc[talk_act])(curator, play); + (*init_proc[talk_act])(curator, play); } static void aCR_setupTalkAction(NPC_CURATOR_ACTOR* curator, GAME_PLAY* play, int talk_act) { - static aCR_TALK_ACT_PROC process[aCR_TALK_NUM] = { - (aCR_TALK_INIT_PROC)&none_proc1, - &aCR_after_talk_start_wait, - &aCR_chk_request, - &aCR_chk_decide_to_donate, - &aCR_chk_decide_to_donate2, - &aCR_menu_open_wait, - &aCR_msg_win_close_wait, - &aCR_menu_close_wait, - &aCR_get_demo_start_wait, - &aCR_get_demo_end_wait, - &aCR_msg_win_open_wait, - &aCR_return_demo_start_wait, - &aCR_return_demo_start_wait, - &aCR_return_demo_end_wait, - &aCR_return_demo_end_wait, - &aCR_chk_continue_to_donate, - &aCR_chk_continue_to_donate, - &aCR_chk_continue_to_donate, - &aCR_putaway_demo_start_wait, - &aCR_putaway_demo_start_wait, - &aCR_putaway_demo_start_wait, - &aCR_putaway_demo_start_wait, - &aCR_putaway_demo_start_wait, - &aCR_putaway_demo_start_wait, - &aCR_putaway_demo_start_wait5_2, - &aCR_putaway_demo_end_wait, - &aCR_putaway_demo_end_wait, - &aCR_putaway_demo_end_wait, - &aCR_putaway_demo_end_wait, - &aCR_putaway_demo_end_wait, - &aCR_putaway_demo_end_wait, - &aCR_after_explain_insect, - &aCR_thanks_fossil_msg_end_wait, - &aCR_chk_all_complete - }; + static aCR_TALK_ACT_PROC process[aCR_TALK_NUM] = { (aCR_TALK_INIT_PROC)&none_proc1, + &aCR_after_talk_start_wait, + &aCR_chk_request, + &aCR_chk_decide_to_donate, + &aCR_chk_decide_to_donate2, + &aCR_menu_open_wait, + &aCR_msg_win_close_wait, + &aCR_menu_close_wait, + &aCR_get_demo_start_wait, + &aCR_get_demo_end_wait, + &aCR_msg_win_open_wait, + &aCR_return_demo_start_wait, + &aCR_return_demo_start_wait, + &aCR_return_demo_end_wait, + &aCR_return_demo_end_wait, + &aCR_chk_continue_to_donate, + &aCR_chk_continue_to_donate, + &aCR_chk_continue_to_donate, + &aCR_putaway_demo_start_wait, + &aCR_putaway_demo_start_wait, + &aCR_putaway_demo_start_wait, + &aCR_putaway_demo_start_wait, + &aCR_putaway_demo_start_wait, + &aCR_putaway_demo_start_wait, + &aCR_putaway_demo_start_wait5_2, + &aCR_putaway_demo_end_wait, + &aCR_putaway_demo_end_wait, + &aCR_putaway_demo_end_wait, + &aCR_putaway_demo_end_wait, + &aCR_putaway_demo_end_wait, + &aCR_putaway_demo_end_wait, + &aCR_after_explain_insect, + &aCR_thanks_fossil_msg_end_wait, + &aCR_chk_all_complete }; - curator->talk_act_idx = talk_act; - curator->talk_proc = process[talk_act]; - aCR_talk_init_proc(curator, play, talk_act); + curator->talk_act_idx = talk_act; + curator->talk_proc = process[talk_act]; + aCR_talk_init_proc(curator, play, talk_act); } static void aCR_set_talk_info(ACTOR* actorx) { - static int msg_no[2][2][2][3] = { - { - { { 0x2F8B, 0x2F8C, 0x2F8C }, { 0x2F8D, 0x2F95, 0x2F8E } }, - { { 0x2F4E, 0x2F4F, 0x2F4F }, { 0x2F51, 0x2F96, 0x2F52 } } - }, - { - { { 0x2F53, 0x2F54, 0x2F54 }, { 0x2F55, 0x2F94, 0x2F56 } }, - { { 0x2F53, 0x2F54, 0x2F54 }, { 0x2F55, 0x2F94, 0x2F56 } } - } - }; + static int msg_no[2][2][2][3] = { { { { 0x2F8B, 0x2F8C, 0x2F8C }, { 0x2F8D, 0x2F95, 0x2F8E } }, + { { 0x2F4E, 0x2F4F, 0x2F4F }, { 0x2F51, 0x2F96, 0x2F52 } } }, + { { { 0x2F53, 0x2F54, 0x2F54 }, { 0x2F55, 0x2F94, 0x2F56 } }, + { { 0x2F53, 0x2F54, 0x2F54 }, { 0x2F55, 0x2F94, 0x2F56 } } } }; - NPC_CURATOR_ACTOR* curator = (NPC_CURATOR_ACTOR*)actorx; + NPC_CURATOR_ACTOR* curator = (NPC_CURATOR_ACTOR*)actorx; - int talk_act = aCR_TALK_END_WAIT; - int sel_msg_no; + int talk_act = aCR_TALK_END_WAIT; + int sel_msg_no; - if (Common_Get(clip).aprilfool_control_clip != NULL && Common_Get(clip).aprilfool_control_clip->talk_chk_proc(SP_NPC_CURATOR) == FALSE) { - sel_msg_no = (*Common_Get(clip).aprilfool_control_clip->get_msg_num_proc)(SP_NPC_CURATOR, TRUE); - } - else { - int completed = FALSE; - int not_foreigner = FALSE; - int not_first_talk = FALSE; - int action_idx = 0; + if (Common_Get(clip).aprilfool_control_clip != NULL && + Common_Get(clip).aprilfool_control_clip->talk_chk_proc(SP_NPC_CURATOR) == FALSE) { + sel_msg_no = (*Common_Get(clip).aprilfool_control_clip->get_msg_num_proc)(SP_NPC_CURATOR, TRUE); + } else { + int completed = FALSE; + int not_foreigner = FALSE; + int not_first_talk = FALSE; + int action_idx = 0; - if (aCR_countDisplayed() == (mMmd_FOSSIL_NUM + mMmd_ART_NUM + mMmd_INSECT_NUM + mMmd_FISH_NUM)) { - completed = TRUE; - } - - if (mLd_PlayerManKindCheck() == FALSE) { - not_foreigner = TRUE; - } - - if (aNPC_SPNPC_BIT_GET(Common_Get(spnpc_first_talk_flags), aNPC_SPNPC_BIT_CURATOR)) { - not_first_talk = TRUE; - } - - if (aCR_check_sleep_time() == TRUE) { - if (curator->action == aCR_ACTION_SLEEP_WAIT) { - action_idx = 1; - } - } - else { - action_idx = 2; - } - - if (completed == FALSE) { - if (not_foreigner == FALSE) { - if (not_first_talk == FALSE) { - talk_act = aCR_TALK_AFTER_TALK_START_WAIT; + if (aCR_countDisplayed() == (mMmd_FOSSIL_NUM + mMmd_ART_NUM + mMmd_INSECT_NUM + mMmd_FISH_NUM)) { + completed = TRUE; } - } - else { - talk_act = aCR_TALK_CHK_REQUEST; - } + + if (mLd_PlayerManKindCheck() == FALSE) { + not_foreigner = TRUE; + } + + if (aNPC_SPNPC_BIT_GET(Common_Get(spnpc_first_talk_flags), aNPC_SPNPC_BIT_CURATOR)) { + not_first_talk = TRUE; + } + + if (aCR_check_sleep_time() == TRUE) { + if (curator->action == aCR_ACTION_SLEEP_WAIT) { + action_idx = 1; + } + } else { + action_idx = 2; + } + + if (completed == FALSE) { + if (not_foreigner == FALSE) { + if (not_first_talk == FALSE) { + talk_act = aCR_TALK_AFTER_TALK_START_WAIT; + } + } else { + talk_act = aCR_TALK_CHK_REQUEST; + } + } + + sel_msg_no = msg_no[completed][not_foreigner][not_first_talk][action_idx]; } - sel_msg_no = msg_no[completed][not_foreigner][not_first_talk][action_idx]; - } - - mDemo_Set_msg_num(sel_msg_no); - curator->talk_act_idx = talk_act; + mDemo_Set_msg_num(sel_msg_no); + curator->talk_act_idx = talk_act; } static void aCR_talk_request(ACTOR* actorx, GAME* game) { - mDemo_Request(mDemo_TYPE_TALK, actorx, &aCR_set_talk_info); + mDemo_Request(mDemo_TYPE_TALK, actorx, &aCR_set_talk_info); } static int aCR_talk_init(ACTOR* actorx, GAME* game) { - NPC_CURATOR_ACTOR* curator = (NPC_CURATOR_ACTOR*)actorx; - GAME_PLAY* play = (GAME_PLAY*)game; + NPC_CURATOR_ACTOR* curator = (NPC_CURATOR_ACTOR*)actorx; + GAME_PLAY* play = (GAME_PLAY*)game; - (*curator->setupTalkAction_proc)(curator, play, curator->talk_act_idx); - mDemo_Set_ListenAble(); - aNPC_SPNPC_BIT_SET(Common_Get(spnpc_first_talk_flags), aNPC_SPNPC_BIT_CURATOR); - curator->npc_class.head.angle_add_y = DEG2SHORT_ANGLE(5.625f); - curator->action = aCR_ACTION_WAIT; + (*curator->setupTalkAction_proc)(curator, play, curator->talk_act_idx); + mDemo_Set_ListenAble(); + aNPC_SPNPC_BIT_SET(Common_Get(spnpc_first_talk_flags), aNPC_SPNPC_BIT_CURATOR); + curator->npc_class.head.angle_add_y = DEG2SHORT_ANGLE(5.625f); + curator->action = aCR_ACTION_WAIT; - return TRUE; + return TRUE; } static int aCR_talk_end_chk(ACTOR* actorx, GAME* game) { - NPC_CURATOR_ACTOR* curator = (NPC_CURATOR_ACTOR*)actorx; - GAME_PLAY* play = (GAME_PLAY*)game; - int res = FALSE; + NPC_CURATOR_ACTOR* curator = (NPC_CURATOR_ACTOR*)actorx; + GAME_PLAY* play = (GAME_PLAY*)game; + int res = FALSE; - (*curator->talk_proc)(curator, play); + (*curator->talk_proc)(curator, play); - if (mDemo_Check(mDemo_TYPE_TALK, actorx) == FALSE) { - res = TRUE; - } + if (mDemo_Check(mDemo_TYPE_TALK, actorx) == FALSE) { + res = TRUE; + } - return res; + return res; } static void aCR_actor_move(ACTOR* actorx, GAME* game) { - (*Common_Get(clip).npc_clip->move_proc)(actorx, game); + (*Common_Get(clip).npc_clip->move_proc)(actorx, game); } diff --git a/src/ac_npc_rcn_guide_move.c_inc b/src/ac_npc_rcn_guide_move.c_inc index 06812005..8a72a78c 100644 --- a/src/ac_npc_rcn_guide_move.c_inc +++ b/src/ac_npc_rcn_guide_move.c_inc @@ -19,7 +19,7 @@ static int aNRG_set_request_act(NPC_RCN_GUIDE_ACTOR* rcn_guide, u8 act_prio, u8 } static void aNRG_set_house_master_name(int house_idx) { - mMsg_SET_FREE_STR(mMsg_FREE_STR0, Save_Get(private[mHS_get_pl_no(house_idx)]).player_ID.player_name, + mMsg_SET_FREE_STR(mMsg_FREE_STR0, Save_Get(private_data[mHS_get_pl_no(house_idx)]).player_ID.player_name, PLAYER_NAME_LEN); } diff --git a/src/ac_train_door.c b/src/ac_train_door.c index 8fe35bf7..6af90349 100644 --- a/src/ac_train_door.c +++ b/src/ac_train_door.c @@ -20,72 +20,69 @@ ACTOR_PROFILE TrainDoor_Profile = { &aTRD_actor_dt, &aTRD_actor_move, &aTRD_actor_draw, - NULL + NULL, }; extern cKF_Skeleton_R_c cKF_bs_r_obj_romtrain_door; extern cKF_Animation_R_c cKF_ba_r_obj_romtrain_door; -static void aTRD_actor_ct(ACTOR* actor, GAME* game){ +static void aTRD_actor_ct(ACTOR* actor, GAME* game) { TRAINDOOR_ACTOR* traindoor = (TRAINDOOR_ACTOR*)actor; - cKF_SkeletonInfo_R_ct(&traindoor->keyframe, &cKF_bs_r_obj_romtrain_door, NULL, &traindoor->work, &traindoor->target); - cKF_SkeletonInfo_R_init(&traindoor->keyframe,traindoor->keyframe.skeleton, &cKF_ba_r_obj_romtrain_door,1.0f,51.0f,1.0f, - 0.0f,0.0f,0,NULL); + cKF_SkeletonInfo_R_ct(&traindoor->keyframe, &cKF_bs_r_obj_romtrain_door, NULL, traindoor->work, traindoor->target); + cKF_SkeletonInfo_R_init(&traindoor->keyframe, traindoor->keyframe.skeleton, &cKF_ba_r_obj_romtrain_door, 1.0f, + 51.0f, 1.0f, 0.0f, 0.0f, 0, NULL); traindoor->keyframe.morph_counter = 0.0f; cKF_SkeletonInfo_R_play(&traindoor->keyframe); } -static void aTRD_actor_dt(ACTOR* actor, GAME* game){ +static void aTRD_actor_dt(ACTOR* actor, GAME* game) { TRAINDOOR_ACTOR* traindoor = (TRAINDOOR_ACTOR*)actor; cKF_SkeletonInfo_R_dt(&traindoor->keyframe); } -static void aTRD_set_door_SE(ACTOR* actor){ +static void aTRD_set_door_SE(ACTOR* actor) { TRAINDOOR_ACTOR* traindoor = (TRAINDOOR_ACTOR*)actor; - static f32 chk_pat[] = {2.0f, 27.0f}; - static u16 se_no[] = {1042, 1043,0, 0,0,0, 0,0,0}; + static f32 chk_pat[] = { 2.0f, 27.0f }; + static u16 se_no[] = { NA_SE_TRAINDOOR0, NA_SE_TRAINDOOR1 }; int i; - for(i = 0; i < 2; i++){ - - if(cKF_FrameControl_passCheck_now(&traindoor->keyframe.frame_control,chk_pat[i]) != 0){ + for (i = 0; i < 2; i++) { + if (cKF_FrameControl_passCheck_now(&traindoor->keyframe.frame_control, chk_pat[i])) { sAdo_OngenTrgStart(se_no[i], &traindoor->actor_class.world.position); - return; + break; } } } -static void aTRD_actor_move(ACTOR* actor, GAME* game){ +static void aTRD_actor_move(ACTOR* actor, GAME* game) { TRAINDOOR_ACTOR* traindoor = (TRAINDOOR_ACTOR*)actor; - if(traindoor->idle == 1){ - traindoor->idle = 0; + if (traindoor->open_flag == TRUE) { + traindoor->open_flag = FALSE; traindoor->keyframe.frame_control.speed = 0.5f; } - if(cKF_SkeletonInfo_R_play(&traindoor->keyframe) == 1){ + if (cKF_SkeletonInfo_R_play(&traindoor->keyframe) == cKF_FRAMECONTROL_REPEAT) { traindoor->keyframe.frame_control.current_frame = traindoor->keyframe.frame_control.start_frame; traindoor->keyframe.frame_control.speed = 0.0f; } + aTRD_set_door_SE(actor); } -static void aTRD_actor_draw(ACTOR* actor, GAME* game){ +static void aTRD_actor_draw(ACTOR* actor, GAME* game) { TRAINDOOR_ACTOR* traindoor = (TRAINDOOR_ACTOR*)actor; cKF_SkeletonInfo_R_c* keyf = &traindoor->keyframe; - Gfx* mtx; Mtx* mtxp; - - mtx = GRAPH_ALLOC(game->graph, (u32) keyf->skeleton->num_shown_joints * 64); - mtxp = (Mtx*)mtx; - if(mtxp != NULL){ + mtxp = GRAPH_ALLOC_TYPE(game->graph, Mtx, (u32)keyf->skeleton->num_shown_joints); + if (mtxp != NULL) { _texture_z_light_fog_prim(game->graph); texture_z_light_prim_xlu_disp(game->graph); - cKF_Si3_draw_R_SV(game,keyf, mtxp, NULL,NULL,NULL); + cKF_Si3_draw_R_SV(game, keyf, mtxp, NULL, NULL, NULL); } -} \ No newline at end of file +} diff --git a/src/ac_train_window.c b/src/ac_train_window.c index 0a8413eb..0d354e21 100644 --- a/src/ac_train_window.c +++ b/src/ac_train_window.c @@ -7,175 +7,170 @@ #include "m_play.h" #include "sys_matrix.h" - -u16 aTrainWindow_tree_pal_table[15][16]= { -{ -0x0724,0xA443, -0xBCA4,0xDD25, -0xF5E7,0xF209, -0xFECD,0x0545, -0x9885,0xA0C5, -0xAD05,0xBD66, -0xCDE8,0xD2FA, -0xE77C,0xF3BE -}, -{ -0x0724,0xA443, -0xBCA4,0xDD25, -0xF5E7,0xF209, -0xFECD,0x0655, -0x98C5,0xA105, -0xB165,0xC1E6, -0xD268,0xD2FA, -0xE77C,0xF3BE -}, -{ -0x0724,0xA443, -0xBCA4,0xDD25, -0xF5E7,0xF209, -0xFECD,0x0464, -0x90C3,0x9504, -0xA184,0xAA05, -0xB287,0xD2FA, -0xE77C,0xF3BE -}, -{ -0x0724,0xA443, -0xBCA4,0xDD25, -0xF5E7,0xF209, -0xFECD,0x0164, -0x80E5,0x8145, -0x89A4,0x9A60, -0xB300,0xD380, -0xEFE8,0x8000 -}, -{ -0x0724,0xA443, -0xBCA4,0xDD25, -0xF5E7,0xF209, -0xFECD,0x0C37, -0xB086,0xC8A7, -0xE0C7,0xF109, -0xF98C,0xFE10, -0xFF18,0x8000 -}, -{ -0x0724,0xA443, -0xBCA4,0xDD25, -0xF5E7,0xF209, -0xFECD,0x0066, -0x80C9,0x8127, -0x8186,0x8202, -0x82C1,0x9380, -0xCBE8,0x8000 -}, -{ -0x0724,0xA443, -0xBCA4,0xDD25, -0xF5E7,0xF209, -0xFECD,0x0058, -0x80C9,0x80E8, -0x8148,0x81C8, -0x8268,0x9326, -0xC3EB,0x8000 -}, -{ -0x0724,0xA443, -0xBCA4,0xDD25, -0xF5E7,0xF209, -0xFECD,0x0353, -0x8CC2,0x9102, -0x9963,0xA5C4, -0xB242,0xC6E4, -0xDB88,0x8000 -}, -{ -0x0724,0xA443, -0xBCA4,0xDD25, -0xF5E7,0xF209, -0xFECD,0x0564, -0x90C5,0x9924, -0xA984,0xBA03, -0xD2A3,0xE304, -0xEF6A,0x8000 -}, -{ -0x0724,0xA443, -0xBCA4,0xDD25, -0xF5E7,0xF209, -0xFECD,0x0842, -0xA463,0xB4A2, -0xC502,0xD961, -0xE9E1,0xF682, -0xFF26,0x8000 -}, -{ -0x0724,0xA443, -0xBCA4,0xDD25, -0xF5E7,0xF209, -0xFECD,0x0814, -0xB024,0xC044, -0xCC85,0xE0C6, -0xF128,0xFE0B, -0xFEEB,0x8000 -}, -{ -0x0724,0xA443, -0xBCA4,0xDD25, -0xF5E7,0xF209, -0xFECD,0x0734, -0xA484,0xAC83, -0xBCC4,0xD503, -0xE985,0xF629, -0xFF0E,0x8000 -}, -{ -0x0724,0xA443, -0xBCA4,0xDD25, -0xF5E7,0xF209, -0xFECD,0x0635, -0xA085,0xA8C5, -0xB505,0xC566, -0xD5E8,0xEE8A, -0xFF2C,0x8000 -}, -{ -0x0724,0xA443, -0xBCA4,0xDD25, -0xF5E7,0xF209, -0xFECD,0x0545, -0x9885,0xA0C5, -0xAD05,0xBD66, -0xCDE8,0xD2FA, -0xE77C,0xF3BE -}, -{ -0x0724,0xA443, -0xBCA4,0xDD25, -0xF5E7,0xF209, -0xFECD,0x0545, -0x9885,0xA0C5, -0xAD05,0xBD66, -0xCDE8,0xD2FA, -0xE77C,0xF3BE -} +// clang-format off +static u16 aTrainWindow_tree_pal_table[15][16] ATTRIBUTE_ALIGN(32) = { + { + 0x0724,0xA443, + 0xBCA4,0xDD25, + 0xF5E7,0xF209, + 0xFECD,0x0545, + 0x9885,0xA0C5, + 0xAD05,0xBD66, + 0xCDE8,0xD2FA, + 0xE77C,0xF3BE + }, + { + 0x0724,0xA443, + 0xBCA4,0xDD25, + 0xF5E7,0xF209, + 0xFECD,0x0655, + 0x98C5,0xA105, + 0xB165,0xC1E6, + 0xD268,0xD2FA, + 0xE77C,0xF3BE + }, + { + 0x0724,0xA443, + 0xBCA4,0xDD25, + 0xF5E7,0xF209, + 0xFECD,0x0464, + 0x90C3,0x9504, + 0xA184,0xAA05, + 0xB287,0xD2FA, + 0xE77C,0xF3BE + }, + { + 0x0724,0xA443, + 0xBCA4,0xDD25, + 0xF5E7,0xF209, + 0xFECD,0x0164, + 0x80E5,0x8145, + 0x89A4,0x9A60, + 0xB300,0xD380, + 0xEFE8,0x8000 + }, + { + 0x0724,0xA443, + 0xBCA4,0xDD25, + 0xF5E7,0xF209, + 0xFECD,0x0C37, + 0xB086,0xC8A7, + 0xE0C7,0xF109, + 0xF98C,0xFE10, + 0xFF18,0x8000 + }, + { + 0x0724,0xA443, + 0xBCA4,0xDD25, + 0xF5E7,0xF209, + 0xFECD,0x0066, + 0x80C9,0x8127, + 0x8186,0x8202, + 0x82C1,0x9380, + 0xCBE8,0x8000 + }, + { + 0x0724,0xA443, + 0xBCA4,0xDD25, + 0xF5E7,0xF209, + 0xFECD,0x0058, + 0x80C9,0x80E8, + 0x8148,0x81C8, + 0x8268,0x9326, + 0xC3EB,0x8000 + }, + { + 0x0724,0xA443, + 0xBCA4,0xDD25, + 0xF5E7,0xF209, + 0xFECD,0x0353, + 0x8CC2,0x9102, + 0x9963,0xA5C4, + 0xB242,0xC6E4, + 0xDB88,0x8000 + }, + { + 0x0724,0xA443, + 0xBCA4,0xDD25, + 0xF5E7,0xF209, + 0xFECD,0x0564, + 0x90C5,0x9924, + 0xA984,0xBA03, + 0xD2A3,0xE304, + 0xEF6A,0x8000 + }, + { + 0x0724,0xA443, + 0xBCA4,0xDD25, + 0xF5E7,0xF209, + 0xFECD,0x0842, + 0xA463,0xB4A2, + 0xC502,0xD961, + 0xE9E1,0xF682, + 0xFF26,0x8000 + }, + { + 0x0724,0xA443, + 0xBCA4,0xDD25, + 0xF5E7,0xF209, + 0xFECD,0x0814, + 0xB024,0xC044, + 0xCC85,0xE0C6, + 0xF128,0xFE0B, + 0xFEEB,0x8000 + }, + { + 0x0724,0xA443, + 0xBCA4,0xDD25, + 0xF5E7,0xF209, + 0xFECD,0x0734, + 0xA484,0xAC83, + 0xBCC4,0xD503, + 0xE985,0xF629, + 0xFF0E,0x8000 + }, + { + 0x0724,0xA443, + 0xBCA4,0xDD25, + 0xF5E7,0xF209, + 0xFECD,0x0635, + 0xA085,0xA8C5, + 0xB505,0xC566, + 0xD5E8,0xEE8A, + 0xFF2C,0x8000 + }, + { + 0x0724,0xA443, + 0xBCA4,0xDD25, + 0xF5E7,0xF209, + 0xFECD,0x0545, + 0x9885,0xA0C5, + 0xAD05,0xBD66, + 0xCDE8,0xD2FA, + 0xE77C,0xF3BE + }, + { + 0x0724,0xA443, + 0xBCA4,0xDD25, + 0xF5E7,0xF209, + 0xFECD,0x0545, + 0x9885,0xA0C5, + 0xAD05,0xBD66, + 0xCDE8,0xD2FA, + 0xE77C,0xF3BE + }, }; +// clang-format on -EVW_ANIME_SCROLL aTrainWindow_out_cloud = { - 0, -2, - 64, 64 -}; +static EVW_ANIME_SCROLL aTrainWindow_out_cloud = { 0, -2, 64, 64 }; -EVW_ANIME_DATA aTrainWindow_evw_anime_data = { - -2, EVW_ANIME_TYPE_SCROLL1, &aTrainWindow_out_cloud -}; +static EVW_ANIME_DATA aTrainWindow_evw_anime_data = { -2, EVW_ANIME_TYPE_SCROLL1, &aTrainWindow_out_cloud }; static void Train_Window_Actor_ct(ACTOR*, GAME*); static void Train_Window_Actor_dt(ACTOR*, GAME*); static void Train_Window_Actor_move(ACTOR*, GAME*); static void Train_Window_Actor_draw(ACTOR*, GAME*); - ACTOR_PROFILE Train_Window_Profile = { mAc_PROFILE_TRAIN_WINDOW, ACTOR_PART_ITEM, @@ -187,10 +182,9 @@ ACTOR_PROFILE Train_Window_Profile = { &Train_Window_Actor_dt, &Train_Window_Actor_move, &Train_Window_Actor_draw, - NULL + NULL, }; - static int aTrainWindow_NoDraw(ACTOR*, GAME*); static int aTrainWindow_DrawGoneOutTunnel(ACTOR*, GAME*); static int aTrainWindow_DrawInTunnel(ACTOR*, GAME*); @@ -201,83 +195,37 @@ extern Gfx rom_train_out_bgcloud_modelT[]; extern Gfx rom_train_out_bgtree_modelT[]; extern Gfx rom_train_out_shineglass_modelT[]; - -static int aTrainWindow_GetTreePalletIdx(){ +static int aTrainWindow_GetTreePalletIdx() { static u8 till_data[15][2] = { - { - 0x02,0x03 - }, - { - 0x02,0x11 - }, - { - 0x02,0x18 - }, - { - 0x04,0x03 - }, - { - 0x04,0x08 - }, - { - 0x07,0x16 - }, - { - 0x09,0x0F - }, - { - 0x0A,0x05 - }, - { - 0x0A,0x17 - }, - { - 0x0B,0x07 - }, - { - 0x0B,0x0E - }, - { - 0x0B,0x1C - }, - { - 0x0C,0x0A - }, - { - 0x0C,0x11 - }, - { - 0x0C,0x1F - } + { 0x02, 0x03 }, { 0x02, 0x11 }, { 0x02, 0x18 }, { 0x04, 0x03 }, { 0x04, 0x08 }, + { 0x07, 0x16 }, { 0x09, 0x0F }, { 0x0A, 0x05 }, { 0x0A, 0x17 }, { 0x0B, 0x07 }, + { 0x0B, 0x0E }, { 0x0B, 0x1C }, { 0x0C, 0x0A }, { 0x0C, 0x11 }, { 0x0C, 0x1F }, }; - + int i; lbRTC_month_t month = Common_Get(time.rtc_time.month); lbRTC_day_t day = Common_Get(time.rtc_time.day); - - for(i = 0; i < 15; i++){ + + for (i = 0; i < 15; i++) { if (month < till_data[i][0]) { return i; } - + if (month == till_data[i][0] && day <= till_data[i][1]) { return i; } } - + return 0; } +static void Train_Window_Actor_ct(ACTOR* actor, GAME* game) { + TRAIN_WINDOW_ACTOR* window = (TRAIN_WINDOW_ACTOR*)actor; - -static void Train_Window_Actor_ct(ACTOR* actor, GAME* game){ - TRAIN_WINDOW_ACTOR* window = (TRAIN_WINDOW_ACTOR* )actor; - - switch(Save_Get(scene_no)){ - case 49: - - case 15: - window->draw_type = aTrainWindow_NoDraw; + switch (Save_Get(scene_no)) { + case SCENE_START_DEMO: + case SCENE_START_DEMO3: + window->draw_type = &aTrainWindow_NoDraw; window->Single_Scrollx = 0; window->Single_Scrolly = 0; window->Two_Scrollx1 = 0; @@ -285,10 +233,10 @@ static void Train_Window_Actor_ct(ACTOR* actor, GAME* game){ window->Two_Scrollx2 = 0; window->Two_Scrolly2 = 0; window->scroll_speed = 0.07f; - break; + break; - case 16: - window->draw_type = aTrainWindow_DrawGoneOutTunnel; + case SCENE_START_DEMO2: + window->draw_type = &aTrainWindow_DrawGoneOutTunnel; window->Single_Scrollx = 1000; window->Single_Scrolly = 0; window->Two_Scrollx1 = 1000; @@ -296,7 +244,7 @@ static void Train_Window_Actor_ct(ACTOR* actor, GAME* game){ window->Two_Scrollx2 = 0; window->Two_Scrolly2 = 0; window->scroll_speed = 1.0f; - break; + break; } window->pallete_id = aTrainWindow_GetTreePalletIdx(); window->current_pallete = aTrainWindow_tree_pal_table[window->pallete_id]; @@ -304,72 +252,66 @@ static void Train_Window_Actor_ct(ACTOR* actor, GAME* game){ window->TreeScrolly = 0; window->pos.x = 0; window->pos.y = 0; - window->pos.z = 0; + window->pos.z = 0; window->xlu_alpha = 254.0f; } -static void Train_Window_Actor_dt(ACTOR* actor, GAME* game){ - +static void Train_Window_Actor_dt(ACTOR* actor, GAME* game) { } -static u8 aTW_GetNowAlpha(){ - - if((Common_Get(time.now_sec) >= 14400) && (Common_Get(time.now_sec) < 72000)){ - if(Common_Get(time.now_sec) < 43200){ +static u8 aTW_GetNowAlpha() { + + if ((Common_Get(time.now_sec) >= 14400) && (Common_Get(time.now_sec) < 72000)) { + if (Common_Get(time.now_sec) < 43200) { return 255.0f * ((f32)(Common_Get(time.now_sec) - 14400) / 28800.0f); } return 255.0f * (1.0f - ((f32)(Common_Get(time.now_sec) - 43200) / 28800.0f)); - } - else if(Common_Get(time.now_sec) < 14400) { + } else if (Common_Get(time.now_sec) < 14400) { return 200.0f * (1.0f - (0.5f + ((f32)Common_Get(time.now_sec) / 28800.0f))); - } - else{ - return 200.0f * ((f32)Common_Get(time.now_sec - 72000) / 28800.0f); + } else { + return 200.0f * ((f32)Common_Get(time.now_sec - 72000) / 28800.0f); } } -static void Train_Window_Actor_move(ACTOR* actor, GAME* game){ - TRAIN_WINDOW_ACTOR* window = (TRAIN_WINDOW_ACTOR* )actor; +static void Train_Window_Actor_move(ACTOR* actor, GAME* game) { + TRAIN_WINDOW_ACTOR* window = (TRAIN_WINDOW_ACTOR*)actor; f32 alpha; - + window->TreeScrollx += 5; add_calc(&window->xlu_alpha, aTW_GetNowAlpha(), window->scroll_speed, 50.0f, 1.0f); - if((Common_Get(time.now_sec) < 14400) || (Common_Get(time.now_sec) >= 72000)){ + if ((Common_Get(time.now_sec) < 14400) || (Common_Get(time.now_sec) >= 72000)) { alpha = 0.0f; - } - else if(Common_Get(time.now_sec) >= 43200){ + } else if (Common_Get(time.now_sec) >= 43200) { alpha = 160.0f + (-160.0f * ((f32)(Common_Get(time.now_sec) - 43200) / 28800.0f)); - } - else{ - alpha = 160.0f * ((f32)(Common_Get(time.now_sec) -14400) / 28800.0f); + } else { + alpha = 160.0f * ((f32)(Common_Get(time.now_sec) - 14400) / 28800.0f); } add_calc(&window->lod_factor, alpha, 0.3f, 50.0f, 1.0f); } -static int aTrainWindow_OperateScrollLimit(int a, int b, int c){ - - b >>= 1; - if(b != 0){ - if(b > 0){ - if(a+b > c){ +static int aTrainWindow_OperateScrollLimit(int a, int b, int c) { + b >>= 1; + if (b != 0) { + if (b > 0) { + if (a + b > c) { return c; } - return a+b; + return a + b; } - if(b >= 0){ - return a; + if (b >= 0) { + return a; } - if(a+b < c){ + if (a + b < c) { return c; } - return a+b; + return a + b; } return a; } -static Gfx* aTrainWindow_TileScroll(u32* x, u32* y, int xamt,int yamt, int xend, int yend, -int width, int height, GRAPH** graph){ +static Gfx* aTrainWindow_TileScroll(u32* x, u32* y, int xamt, int yamt, int xend, int yend, int width, int height, + GRAPH** graph) { *x = aTrainWindow_OperateScrollLimit(*x, xamt, xend); *y = aTrainWindow_OperateScrollLimit(*y, yamt, yend); @@ -377,9 +319,9 @@ int width, int height, GRAPH** graph){ return tex_scroll2(*graph, *x, *y, width, height); } -static Gfx* aTrainWindow_TileScroll2(u32* x1, u32* y1, int x1amt, int y1amt, int x1end, int y1end, int width1, int height1, -u32* x2, u32* y2, int x2amt, int y2amt, int x2end, int y2end, int width2, int height2, GRAPH** graph){ - +static Gfx* aTrainWindow_TileScroll2(u32* x1, u32* y1, int x1amt, int y1amt, int x1end, int y1end, int width1, + int height1, u32* x2, u32* y2, int x2amt, int y2amt, int x2end, int y2end, + int width2, int height2, GRAPH** graph) { *x1 = aTrainWindow_OperateScrollLimit(*x1, x1amt, x1end); *y1 = aTrainWindow_OperateScrollLimit(*y1, y1amt, y1end); @@ -389,22 +331,20 @@ u32* x2, u32* y2, int x2amt, int y2amt, int x2end, int y2end, int width2, int he return two_tex_scroll(*graph, 0, *x1, *y1, width1, height1, 1, *x2, *y2, width2, height2); } -static int aTrainWindow_DrawGoneOutTunnel(ACTOR* actor, GAME* game){ - TRAIN_WINDOW_ACTOR* window = (TRAIN_WINDOW_ACTOR* )actor; - +static int aTrainWindow_DrawGoneOutTunnel(ACTOR* actor, GAME* game) { + TRAIN_WINDOW_ACTOR* window = (TRAIN_WINDOW_ACTOR*)actor; + GRAPH** graph = &game->graph; Gfx* ssc; Gfx* tsc; - - ssc = aTrainWindow_TileScroll(&window->Single_Scrollx,&window->Single_Scrolly, - 0,0,1000,0, 64, 32, graph); - tsc = aTrainWindow_TileScroll2(&window->Two_Scrollx1, &window->Two_Scrolly1, 0,0,1000, 0, 64, 8, - &window->Two_Scrollx2, &window->Two_Scrolly2, 0,0,0,0,16,16,graph); - if((ssc == NULL) || (tsc == NULL)){ + ssc = aTrainWindow_TileScroll(&window->Single_Scrollx, &window->Single_Scrolly, 0, 0, 1000, 0, 64, 32, graph); + tsc = aTrainWindow_TileScroll2(&window->Two_Scrollx1, &window->Two_Scrolly1, 0, 0, 1000, 0, 64, 8, + &window->Two_Scrollx2, &window->Two_Scrolly2, 0, 0, 0, 0, 16, 16, graph); + + if ((ssc == NULL) || (tsc == NULL)) { return 0; - } - else{ + } else { OPEN_DISP(*graph); gSPSegment(NOW_POLY_OPA_DISP++, 11, ssc); @@ -412,7 +352,7 @@ static int aTrainWindow_DrawGoneOutTunnel(ACTOR* actor, GAME* game){ gSPSegment(NOW_POLY_OPA_DISP++, 12, tsc); gSPSegment(NOW_POLY_XLU_DISP++, 12, tsc); - + CLOSE_DISP(*graph); return 1; @@ -420,21 +360,19 @@ static int aTrainWindow_DrawGoneOutTunnel(ACTOR* actor, GAME* game){ } static int aTrainWindow_DrawGoingOutTunnel(ACTOR* actor, GAME* game) { - TRAIN_WINDOW_ACTOR* window = (TRAIN_WINDOW_ACTOR* )actor; - + TRAIN_WINDOW_ACTOR* window = (TRAIN_WINDOW_ACTOR*)actor; + Gfx* tsc; Gfx* ssc; GRAPH** graph = &game->graph; - - ssc = aTrainWindow_TileScroll(&window->Single_Scrollx,&window->Single_Scrolly, - 30,0,1000,0, 64, 32, graph); - tsc = aTrainWindow_TileScroll2(&window->Two_Scrollx1, &window->Two_Scrolly1, 30,0,1000, 0, 64, 8, - &window->Two_Scrollx2, &window->Two_Scrolly2, 0,0,0,0,16,16,graph); - if((ssc == NULL) || (tsc == NULL)){ + ssc = aTrainWindow_TileScroll(&window->Single_Scrollx, &window->Single_Scrolly, 30, 0, 1000, 0, 64, 32, graph); + tsc = aTrainWindow_TileScroll2(&window->Two_Scrollx1, &window->Two_Scrolly1, 30, 0, 1000, 0, 64, 8, + &window->Two_Scrollx2, &window->Two_Scrolly2, 0, 0, 0, 0, 16, 16, graph); + + if ((ssc == NULL) || (tsc == NULL)) { return 0; - } - else{ + } else { OPEN_DISP(*graph); gSPSegment(NOW_POLY_OPA_DISP++, 11, ssc); @@ -442,10 +380,10 @@ static int aTrainWindow_DrawGoingOutTunnel(ACTOR* actor, GAME* game) { gSPSegment(NOW_POLY_OPA_DISP++, 12, tsc); gSPSegment(NOW_POLY_XLU_DISP++, 12, tsc); - + CLOSE_DISP(*graph); - if(((int)window->Single_Scrollx == 1000) && ((int)window->Two_Scrollx1 == 1000)){ + if (((int)window->Single_Scrollx == 1000) && ((int)window->Two_Scrollx1 == 1000)) { window->draw_type = aTrainWindow_DrawGoneOutTunnel; window->pallete_id = aTrainWindow_GetTreePalletIdx(); window->current_pallete = aTrainWindow_tree_pal_table[window->pallete_id]; @@ -455,28 +393,26 @@ static int aTrainWindow_DrawGoingOutTunnel(ACTOR* actor, GAME* game) { } } -static int aTrainWindow_NoDraw(ACTOR* actor, GAME* game){ - TRAIN_WINDOW_ACTOR* window = (TRAIN_WINDOW_ACTOR* )actor; +static int aTrainWindow_NoDraw(ACTOR* actor, GAME* game) { + TRAIN_WINDOW_ACTOR* window = (TRAIN_WINDOW_ACTOR*)actor; window->draw_type = aTrainWindow_DrawInTunnel; return 0; } -static int aTrainWindow_DrawInTunnel(ACTOR* actor, GAME* game){ - TRAIN_WINDOW_ACTOR* window = (TRAIN_WINDOW_ACTOR* )actor; - +static int aTrainWindow_DrawInTunnel(ACTOR* actor, GAME* game) { + TRAIN_WINDOW_ACTOR* window = (TRAIN_WINDOW_ACTOR*)actor; + Gfx* tsc; Gfx* ssc; GRAPH** graph = &game->graph; - - ssc = aTrainWindow_TileScroll(&window->Single_Scrollx,&window->Single_Scrolly, - 0,0,1000,0, 64, 32, graph); - tsc = aTrainWindow_TileScroll2(&window->Two_Scrollx1, &window->Two_Scrolly1, 0,0,1000, 0, 64, 8, - &window->Two_Scrollx2, &window->Two_Scrolly2, 0,0,0,0,16,16,graph); - if((ssc == NULL) || (tsc == NULL)){ + ssc = aTrainWindow_TileScroll(&window->Single_Scrollx, &window->Single_Scrolly, 0, 0, 1000, 0, 64, 32, graph); + tsc = aTrainWindow_TileScroll2(&window->Two_Scrollx1, &window->Two_Scrolly1, 0, 0, 1000, 0, 64, 8, + &window->Two_Scrollx2, &window->Two_Scrolly2, 0, 0, 0, 0, 16, 16, graph); + + if ((ssc == NULL) || (tsc == NULL)) { return 0; - } - else{ + } else { OPEN_DISP(*graph); gSPSegment(NOW_POLY_OPA_DISP++, 11, ssc); @@ -484,96 +420,94 @@ static int aTrainWindow_DrawInTunnel(ACTOR* actor, GAME* game){ gSPSegment(NOW_POLY_OPA_DISP++, 12, tsc); gSPSegment(NOW_POLY_XLU_DISP++, 12, tsc); - + CLOSE_DISP(*graph); - if(Common_Get(sunlight_flag) != 0){ + if (Common_Get(sunlight_flag) != 0) { window->pallete_id = aTrainWindow_GetTreePalletIdx(); window->current_pallete = aTrainWindow_tree_pal_table[window->pallete_id]; window->draw_type = aTrainWindow_DrawGoingOutTunnel; - } return 1; } } -static void aTrainWindow_SetLightPrimColorDetail(GAME* game, u32 r, u32 g, u32 b, int l, int poly_a, int xlu_a){ +static void aTrainWindow_SetLightPrimColorDetail(GAME* game, u32 r, u32 g, u32 b, int l, int poly_a, int xlu_a) { GAME_PLAY* play = (GAME_PLAY*)game; int i; int current_color; u8 color[3]; GRAPH* graph; - for(i = 0; i < 3; i++){ + for (i = 0; i < 3; i++) { current_color = play->global_light.ambientColor[i] + play->kankyo.base_light.sun_color[i]; - switch(i){ + switch (i) { case 0: current_color += r; - break; + break; case 1: current_color += g; - break; + break; case 2: current_color += b; - break; + break; } - if(current_color < 0){ + if (current_color < 0) { current_color = 0; - }else if(current_color >= 256){ + } else if (current_color >= 256) { current_color = 255; } color[i] = current_color; } - if(l < 0){ + if (l < 0) { l = 0; - }else if(l > 255){ + } else if (l > 255) { l = 255; } - if(poly_a < 0){ + if (poly_a < 0) { poly_a = 0; - }else if(poly_a > 255){ + } else if (poly_a > 255) { poly_a = 255; } - if(xlu_a < 0){ + if (xlu_a < 0) { xlu_a = 0; - }else if(xlu_a > 255){ + } else if (xlu_a > 255) { xlu_a = 255; } - + graph = play->game.graph; - - OPEN_DISP(graph); + + OPEN_DISP(graph); gDPSetPrimColor(NOW_POLY_OPA_DISP++, 0, l, color[0], color[1], color[2], poly_a); - gDPSetPrimColor(NOW_POLY_XLU_DISP++, 0, l, color[0], color[1], color[2], xlu_a); + gDPSetPrimColor(NOW_POLY_XLU_DISP++, 0, l, color[0], color[1], color[2], xlu_a); CLOSE_DISP(graph); - } -static void aTrainWindow_SetTreeTextureScroll(ACTOR* actor, GAME* game){ - TRAIN_WINDOW_ACTOR* window = (TRAIN_WINDOW_ACTOR* )actor; +static void aTrainWindow_SetTreeTextureScroll(ACTOR* actor, GAME* game) { + TRAIN_WINDOW_ACTOR* window = (TRAIN_WINDOW_ACTOR*)actor; Gfx* tree; GRAPH** graph = &game->graph; - + tree = tex_scroll2(*graph, window->TreeScrollx, window->TreeScrolly, 128, 32); - OPEN_DISP(*graph); + OPEN_DISP(*graph); + + gSPSegment(NOW_POLY_OPA_DISP++, 8, tree); + gSPSegment(NOW_POLY_XLU_DISP++, 8, tree); - gSPSegment(NOW_POLY_OPA_DISP++,8, tree); - gSPSegment(NOW_POLY_XLU_DISP++,8, tree); - CLOSE_DISP(*graph); } -static void Train_Window_Actor_draw(ACTOR* actor, GAME* game){ +static void Train_Window_Actor_draw(ACTOR* actor, GAME* game) { GAME_PLAY* play = (GAME_PLAY*)game; - TRAIN_WINDOW_ACTOR* window = (TRAIN_WINDOW_ACTOR* )actor; - + TRAIN_WINDOW_ACTOR* window = (TRAIN_WINDOW_ACTOR*)actor; + GRAPH* graph = game->graph; - Matrix_translate(0.0f,0.0f,0.0f,FALSE); + Matrix_translate(0.0f, 0.0f, 0.0f, FALSE); Matrix_scale(0.05f, 0.05f, 0.05f, TRUE); - + OPEN_DISP(graph); gSPMatrix(NOW_POLY_OPA_DISP++, _Matrix_to_Mtx_new(game->graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -582,23 +516,23 @@ static void Train_Window_Actor_draw(ACTOR* actor, GAME* game){ _texture_z_light_fog_prim(game->graph); _texture_z_light_fog_prim_xlu(game->graph); - - if(window->draw_type(actor,game) != 0){ - aTrainWindow_SetLightPrimColorDetail(game, 0,0,0,127,255,(u8)window->xlu_alpha); - gSPSegment(NOW_POLY_XLU_DISP++,10, window->current_pallete); - Evw_Anime_Set(play, &aTrainWindow_evw_anime_data); - aTrainWindow_SetLightPrimColorDetail(game,0,0,0,43,255,window->xlu_alpha); - gSPDisplayList(NOW_POLY_OPA_DISP++,rom_train_out_tunnel_model); - aTrainWindow_SetLightPrimColorDetail(game,0,0,0,127,255,window->xlu_alpha); - gSPDisplayList(NOW_POLY_OPA_DISP++,rom_train_out_bgsky_model); - aTrainWindow_SetLightPrimColorDetail(game,0,0,0,127,255,window->xlu_alpha); - gSPDisplayList(NOW_POLY_XLU_DISP++,rom_train_out_bgcloud_modelT); + if (window->draw_type(actor, game) != 0) { + aTrainWindow_SetLightPrimColorDetail(game, 0, 0, 0, 127, 255, (u8)window->xlu_alpha); + gSPSegment(NOW_POLY_XLU_DISP++, 10, window->current_pallete); + Evw_Anime_Set(play, &aTrainWindow_evw_anime_data); + aTrainWindow_SetLightPrimColorDetail(game, 0, 0, 0, 43, 255, window->xlu_alpha); + gSPDisplayList(NOW_POLY_OPA_DISP++, rom_train_out_tunnel_model); + aTrainWindow_SetLightPrimColorDetail(game, 0, 0, 0, 127, 255, window->xlu_alpha); + gSPDisplayList(NOW_POLY_OPA_DISP++, rom_train_out_bgsky_model); + aTrainWindow_SetLightPrimColorDetail(game, 0, 0, 0, 127, 255, window->xlu_alpha); + gSPDisplayList(NOW_POLY_XLU_DISP++, rom_train_out_bgcloud_modelT); aTrainWindow_SetTreeTextureScroll(actor, game); - aTrainWindow_SetLightPrimColorDetail(game, GETREG(CRV, CRV_DEBUG_RED_VALUE) -80 ,GETREG(CRV, CRV_DEBUG_GREEN_VALUE) -70 ,GETREG(CRV, CRV_DEBUG_BLUE_VALUE) -160, GETREG(CRV,CRV_DEBUG_LOD_VALUE) + 27,255, window->xlu_alpha); - gSPDisplayList(NOW_POLY_XLU_DISP++,rom_train_out_bgtree_modelT); - aTrainWindow_SetLightPrimColorDetail(game,0,0,0,window->lod_factor,255,window->xlu_alpha); - gSPDisplayList(NOW_POLY_XLU_DISP++,rom_train_out_shineglass_modelT); - + aTrainWindow_SetLightPrimColorDetail( + game, GETREG(CRV, CRV_DEBUG_RED_VALUE) - 80, GETREG(CRV, CRV_DEBUG_GREEN_VALUE) - 70, + GETREG(CRV, CRV_DEBUG_BLUE_VALUE) - 160, GETREG(CRV, CRV_DEBUG_LOD_VALUE) + 27, 255, window->xlu_alpha); + gSPDisplayList(NOW_POLY_XLU_DISP++, rom_train_out_bgtree_modelT); + aTrainWindow_SetLightPrimColorDetail(game, 0, 0, 0, window->lod_factor, 255, window->xlu_alpha); + gSPDisplayList(NOW_POLY_XLU_DISP++, rom_train_out_shineglass_modelT); } CLOSE_DISP(graph); -} \ No newline at end of file +} diff --git a/src/ftr/ac_myfmanekin.c b/src/ftr/ac_myfmanekin.c index 2f461c97..0147a570 100644 --- a/src/ftr/ac_myfmanekin.c +++ b/src/ftr/ac_myfmanekin.c @@ -27,8 +27,8 @@ static void aMyfmanekin_dma(mActor_name_t ftr_name, u8* data) { int player_no = mHS_get_pl_no(house_no); u32 manekin_no = ((ftr_name - FTR_CLOTH_MANNIQUIN_MY_ORIGINAL0) >> 2); - mNW_CopyOriginalTexture(data, &Save_Get(private[player_no]).my_org[manekin_no & 7]); - mNW_CopyOriginalPalette(data + mNW_DESIGN_TEX_SIZE, &Save_Get(private[player_no]).my_org[manekin_no & 7]); + mNW_CopyOriginalTexture(data, &Save_Get(private_data[player_no]).my_org[manekin_no & 7]); + mNW_CopyOriginalPalette(data + mNW_DESIGN_TEX_SIZE, &Save_Get(private_data[player_no]).my_org[manekin_no & 7]); } static aFTR_vtable_c aMyfmanekin_func = { diff --git a/src/ftr/ac_myfumbrella.c b/src/ftr/ac_myfumbrella.c index acd72ed6..81288d50 100644 --- a/src/ftr/ac_myfumbrella.c +++ b/src/ftr/ac_myfumbrella.c @@ -27,8 +27,8 @@ static void aMFU_dma(mActor_name_t ftr_name, u8* data) { int player_no = mHS_get_pl_no(house_no); u32 manekin_no = ((ftr_name - FTR_MYUMBRELLA_START) >> 2); - mNW_CopyOriginalTexture(data, &Save_Get(private[player_no]).my_org[manekin_no & 7]); - mNW_CopyOriginalPalette(data + mNW_DESIGN_TEX_SIZE, &Save_Get(private[player_no]).my_org[manekin_no & 7]); + mNW_CopyOriginalTexture(data, &Save_Get(private_data[player_no]).my_org[manekin_no & 7]); + mNW_CopyOriginalPalette(data + mNW_DESIGN_TEX_SIZE, &Save_Get(private_data[player_no]).my_org[manekin_no & 7]); } static aFTR_vtable_c aMFU_func = { diff --git a/src/m_all_grow_ovl.c b/src/m_all_grow_ovl.c index 68ba573e..c1eea0af 100644 --- a/src/m_all_grow_ovl.c +++ b/src/m_all_grow_ovl.c @@ -2499,7 +2499,7 @@ static void mAGrw_SpoilAllPossession(int spoil_kabu) { int k; if (spoil_kabu == TRUE) { - priv = Save_Get(private); + priv = Save_Get(private_data); for (i = 0; i < PLAYER_NUM; i++) { mAGrw_SpoilPossession(priv->inventory.pockets, mPr_POCKETS_SLOT_COUNT); diff --git a/src/m_calendar.c b/src/m_calendar.c index 460eba3a..5376da5c 100644 --- a/src/m_calendar.c +++ b/src/m_calendar.c @@ -4,387 +4,360 @@ #include "m_common_data.h" static void mCD_calendar_clear_interval(mCD_player_calendar_c* calendar, int interval) { - u8 months[lbRTC_MONTHS_MAX]; - int i; + u8 months[lbRTC_MONTHS_MAX]; + int i; - for (i = 0; i < lbRTC_MONTHS_MAX; i++) { - months[i] = 0; - } - - for (i = 0; i < interval; i++) { - months[(calendar->month + i) % lbRTC_MONTHS_MAX] = 1; - } - - for (i = 0; i > interval; i--) { - months[(calendar->month + (lbRTC_MONTHS_MAX - 1) + i) % lbRTC_MONTHS_MAX] = 1; - } - - for (i = 0; i < lbRTC_MONTHS_MAX; i++) { - if (months[i] == 1) { - calendar->played_days[i] = 0; - calendar->event_days[i] = 0; + for (i = 0; i < lbRTC_MONTHS_MAX; i++) { + months[i] = 0; } - } - if (months[lbRTC_JUNE - 1] == 1) { - calendar->event_flags &= ~mCD_FLAG_MOTHERS_DAY; // 1 - } + for (i = 0; i < interval; i++) { + months[(calendar->month + i) % lbRTC_MONTHS_MAX] = 1; + } - if (months[lbRTC_JULY - 1] == 1) { - calendar->event_flags &= ~mCD_FLAG_TOWN_DAY; // 2 - } + for (i = 0; i > interval; i--) { + months[(calendar->month + (lbRTC_MONTHS_MAX - 1) + i) % lbRTC_MONTHS_MAX] = 1; + } - if (months[lbRTC_AUGUST - 1] == 1) { - calendar->event_flags &= ~(mCD_FLAG_METEOR_SHOWER | mCD_FLAG_FOUNDERS_DAY); // 12 (4 | 8) - } + for (i = 0; i < lbRTC_MONTHS_MAX; i++) { + if (months[i] == 1) { + calendar->played_days[i] = 0; + calendar->event_days[i] = 0; + } + } - if (months[lbRTC_SEPTEMBER - 1] == 1) { - calendar->event_flags &= ~mCD_FLAG_HARVEST_MOON_9; // 16 - } + if (months[lbRTC_JUNE - 1] == 1) { + calendar->event_flags &= ~mCD_FLAG_MOTHERS_DAY; // 1 + } - if (months[lbRTC_OCTOBER - 1] == 1) { - calendar->event_flags &= ~mCD_FLAG_HARVEST_MOON_10; // 32 - } + if (months[lbRTC_JULY - 1] == 1) { + calendar->event_flags &= ~mCD_FLAG_TOWN_DAY; // 2 + } - if (months[lbRTC_NOVEMBER - 1] == 1) { - calendar->event_flags &= ~mCD_FLAG_OFFICERS_DAY; // 64 - } + if (months[lbRTC_AUGUST - 1] == 1) { + calendar->event_flags &= ~(mCD_FLAG_METEOR_SHOWER | mCD_FLAG_FOUNDERS_DAY); // 12 (4 | 8) + } + + if (months[lbRTC_SEPTEMBER - 1] == 1) { + calendar->event_flags &= ~mCD_FLAG_HARVEST_MOON_9; // 16 + } + + if (months[lbRTC_OCTOBER - 1] == 1) { + calendar->event_flags &= ~mCD_FLAG_HARVEST_MOON_10; // 32 + } + + if (months[lbRTC_NOVEMBER - 1] == 1) { + calendar->event_flags &= ~mCD_FLAG_OFFICERS_DAY; // 64 + } } -static void mCD_calendar_clear_day(mCD_player_calendar_c* calendar, lbRTC_year_t year, lbRTC_month_t month, lbRTC_day_t day) { - lbRTC_day_t days = lbRTC_GetDaysByMonth(year, month); - int i; +static void mCD_calendar_clear_day(mCD_player_calendar_c* calendar, lbRTC_year_t year, lbRTC_month_t month, + lbRTC_day_t day) { + lbRTC_day_t days = lbRTC_GetDaysByMonth(year, month); + int i; - if (days != day) { - u32 days_bitfield = 0; - for (i = day; i < 31; i++) { - days_bitfield |= (1 << i); + if (days != day) { + u32 days_bitfield = 0; + for (i = day; i < 31; i++) { + days_bitfield |= (1 << i); + } + + calendar->played_days[month - 1] &= ~days_bitfield; + calendar->event_days[month - 1] &= ~days_bitfield; + + switch (month) { + case lbRTC_JUNE: { + lbRTC_weekday_t weekday = lbRTC_Week(year, month, day + 1); + + /* Calculate the current week and verify it's not the last week */ + if ((day - weekday) / lbRTC_WEEK + 1 < 3) { + calendar->event_flags &= ~mCD_FLAG_MOTHERS_DAY; + } + + break; + } + + case lbRTC_JULY: { + if (day < Save_Get(town_day)) { + calendar->event_flags &= ~mCD_FLAG_TOWN_DAY; + } + + break; + } + + case lbRTC_AUGUST: { + if (day < 12) { + calendar->event_flags &= ~mCD_FLAG_METEOR_SHOWER; + } + + if (day < 21) { + calendar->event_flags &= ~mCD_FLAG_FOUNDERS_DAY; + } + + break; + } + + case lbRTC_SEPTEMBER: { + lbRTC_ymd_c harvest_moon_day; + + lbRk_HarvestMoonDay(&harvest_moon_day, year); + + if (month == harvest_moon_day.month && day < harvest_moon_day.day) { + calendar->event_flags &= ~mCD_FLAG_HARVEST_MOON_9; + } + + break; + } + + case lbRTC_OCTOBER: { + lbRTC_ymd_c harvest_moon_day; + + lbRk_HarvestMoonDay(&harvest_moon_day, year); + + if (month == harvest_moon_day.month && day < harvest_moon_day.day) { + calendar->event_flags &= ~mCD_FLAG_HARVEST_MOON_10; + } + + break; + } + + case lbRTC_NOVEMBER: { + if (day < 11) { + calendar->event_flags &= ~mCD_FLAG_OFFICERS_DAY; + } + + break; + } + } } - - calendar->played_days[month - 1] &= ~days_bitfield; - calendar->event_days[month - 1] &= ~days_bitfield; - - switch (month) { - case lbRTC_JUNE: - { - lbRTC_weekday_t weekday = lbRTC_Week(year, month, day + 1); - - /* Calculate the current week and verify it's not the last week */ - if ((day - weekday) / lbRTC_WEEK + 1 < 3) { - calendar->event_flags &= ~mCD_FLAG_MOTHERS_DAY; - } - - break; - } - - case lbRTC_JULY: - { - if (day < Save_Get(town_day)) { - calendar->event_flags &= ~mCD_FLAG_TOWN_DAY; - } - - break; - } - - case lbRTC_AUGUST: - { - if (day < 12) { - calendar->event_flags &= ~mCD_FLAG_METEOR_SHOWER; - } - - if (day < 21) { - calendar->event_flags &= ~mCD_FLAG_FOUNDERS_DAY; - } - - break; - } - - case lbRTC_SEPTEMBER: - { - lbRTC_ymd_c harvest_moon_day; - - lbRk_HarvestMoonDay(&harvest_moon_day, year); - - if (month == harvest_moon_day.month && day < harvest_moon_day.day) { - calendar->event_flags &= ~mCD_FLAG_HARVEST_MOON_9; - } - - break; - } - - case lbRTC_OCTOBER: - { - lbRTC_ymd_c harvest_moon_day; - - lbRk_HarvestMoonDay(&harvest_moon_day, year); - - if (month == harvest_moon_day.month && day < harvest_moon_day.day) { - calendar->event_flags &= ~mCD_FLAG_HARVEST_MOON_10; - } - - break; - } - - case lbRTC_NOVEMBER: - { - if (day < 11) { - calendar->event_flags &= ~mCD_FLAG_OFFICERS_DAY; - } - - break; - } - } - } } static int mCD_GetIntervalMonths(lbRTC_year_t y0, lbRTC_month_t m0, lbRTC_year_t y1, lbRTC_month_t m1) { - return (m1 - m0) + (y1 - y0) * lbRTC_MONTHS_MAX; + return (m1 - m0) + (y1 - y0) * lbRTC_MONTHS_MAX; } extern void mCD_calendar_clear(int player_no) { - Private_c* priv = Save_Get(private); + Private_c* priv = Save_Get(private_data); - if (player_no == -1) { - player_no = Common_Get(player_no); - } + if (player_no == -1) { + player_no = Common_Get(player_no); + } - if (player_no != mPr_FOREIGNER) { - mem_clear((u8*)&priv[player_no].calendar, sizeof(mCD_player_calendar_c), 0); - } + if (player_no != mPr_FOREIGNER) { + mem_clear((u8*)&priv[player_no].calendar, sizeof(mCD_player_calendar_c), 0); + } } static int mCD_calendar_check_harvest_moon_viewing(mCD_player_calendar_c* calendar, lbRTC_month_t month) { - int res = FALSE; + int res = FALSE; - switch (month) { - case lbRTC_SEPTEMBER: - { - if ((calendar->event_flags & mCD_FLAG_HARVEST_MOON_9) != 0) { - res = TRUE; - } + switch (month) { + case lbRTC_SEPTEMBER: { + if ((calendar->event_flags & mCD_FLAG_HARVEST_MOON_9) != 0) { + res = TRUE; + } - break; + break; + } + + case lbRTC_OCTOBER: { + if ((calendar->event_flags & mCD_FLAG_HARVEST_MOON_10) != 0) { + res = TRUE; + } + + break; + } } - case lbRTC_OCTOBER: - { - if ((calendar->event_flags & mCD_FLAG_HARVEST_MOON_10) != 0) { - res = TRUE; - } - - break; - } - } - - return res; + return res; } extern void mCD_calendar_check_delete(int player_no, lbRTC_year_t year, lbRTC_month_t month, lbRTC_day_t day) { - if (player_no == -1) { - player_no = Common_Get(player_no); - } - - if (player_no != mPr_FOREIGNER) { - mCD_player_calendar_c* calendar = &Save_Get(private[player_no]).calendar; - - if (calendar->year == 0) { - mCD_calendar_clear(-1); + if (player_no == -1) { + player_no = Common_Get(player_no); } - else { - int interval = mCD_GetIntervalMonths(calendar->year, calendar->month, year, month); - if (interval >= lbRTC_MONTHS_MAX || interval <= -lbRTC_MONTHS_MAX) { - mCD_calendar_clear(-1); // clear entire calendar since interval is >= 1 year - } - else { - if (interval != 0) { - mCD_calendar_clear_interval(calendar, interval); // clear only interval months + if (player_no != mPr_FOREIGNER) { + mCD_player_calendar_c* calendar = &Save_Get(private_data[player_no]).calendar; + + if (calendar->year == 0) { + mCD_calendar_clear(-1); + } else { + int interval = mCD_GetIntervalMonths(calendar->year, calendar->month, year, month); + + if (interval >= lbRTC_MONTHS_MAX || interval <= -lbRTC_MONTHS_MAX) { + mCD_calendar_clear(-1); // clear entire calendar since interval is >= 1 year + } else { + if (interval != 0) { + mCD_calendar_clear_interval(calendar, interval); // clear only interval months + } + + mCD_calendar_clear_day(calendar, year, month, day); // clear days + } } - - mCD_calendar_clear_day(calendar, year, month, day); // clear days - } } - } } extern void mCD_calendar_wellcome_on() { - mCD_player_calendar_c* calendar = &Common_Get(now_private)->calendar; + mCD_player_calendar_c* calendar = &Common_Get(now_private)->calendar; - if (Common_Get(player_no) != mPr_FOREIGNER) { - lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); + if (Common_Get(player_no) != mPr_FOREIGNER) { + lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); - mCD_calendar_check_delete(-1, rtc_time->year, rtc_time->month, rtc_time->day); - calendar->played_days[rtc_time->month - 1] |= (1 << (rtc_time->day - 1)); - calendar->year = rtc_time->year; - calendar->month = rtc_time->month; - } + mCD_calendar_check_delete(-1, rtc_time->year, rtc_time->month, rtc_time->day); + calendar->played_days[rtc_time->month - 1] |= (1 << (rtc_time->day - 1)); + calendar->year = rtc_time->year; + calendar->month = rtc_time->month; + } } extern void mCD_calendar_event_on(lbRTC_year_t year, lbRTC_month_t month, lbRTC_day_t day, u8 event) { - if (Common_Get(player_no) != mPr_FOREIGNER) { - mCD_player_calendar_c* calendar; + if (Common_Get(player_no) != mPr_FOREIGNER) { + mCD_player_calendar_c* calendar; - mCD_calendar_check_delete(-1, year, month, day); - calendar = &Save_Get(private[Common_Get(player_no)]).calendar; + mCD_calendar_check_delete(-1, year, month, day); + calendar = &Save_Get(private_data[Common_Get(player_no)]).calendar; - switch (event) { - case 11: - { - calendar->event_flags |= mCD_FLAG_MOTHERS_DAY; + switch (event) { + case 11: { + calendar->event_flags |= mCD_FLAG_MOTHERS_DAY; - break; - } + break; + } - case 4: - { - calendar->event_flags |= mCD_FLAG_TOWN_DAY; + case 4: { + calendar->event_flags |= mCD_FLAG_TOWN_DAY; - break; - } + break; + } - case 16: - { - calendar->event_flags |= mCD_FLAG_METEOR_SHOWER; + case 16: { + calendar->event_flags |= mCD_FLAG_METEOR_SHOWER; - break; - } + break; + } - case 1: - { - calendar->event_flags |= mCD_FLAG_FOUNDERS_DAY; + case 1: { + calendar->event_flags |= mCD_FLAG_FOUNDERS_DAY; - break; - } + break; + } - case 17: - { - switch (month) { - case lbRTC_SEPTEMBER: - { - calendar->event_flags |= mCD_FLAG_HARVEST_MOON_9; + case 17: { + switch (month) { + case lbRTC_SEPTEMBER: { + calendar->event_flags |= mCD_FLAG_HARVEST_MOON_9; - break; - } + break; + } - case lbRTC_OCTOBER: - { - calendar->event_flags |= mCD_FLAG_HARVEST_MOON_10; + case lbRTC_OCTOBER: { + calendar->event_flags |= mCD_FLAG_HARVEST_MOON_10; - break; - } + break; + } + } + + break; + } + + case 19: { + calendar->event_flags |= mCD_FLAG_OFFICERS_DAY; + + break; + } + + case 255: { + break; + } + + default: { + calendar->event_days[month - 1] |= (1 << (day - 1)); + + break; + } } - - break; - } - - case 19: - { - calendar->event_flags |= mCD_FLAG_OFFICERS_DAY; - - break; - } - - case 255: - { - break; - } - - default: - { - calendar->event_days[month - 1] |= (1 << (day - 1)); - - break; - } } - } } extern int mCD_calendar_event_check(lbRTC_year_t year, lbRTC_month_t month, lbRTC_day_t day, int player_no, u8 event) { - int res = FALSE; + int res = FALSE; - if (player_no == -1) { - player_no = Common_Get(player_no); - } - - if (player_no != mPr_FOREIGNER) { - lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); - - int interval = (rtc_time->month - month) + (rtc_time->year - year) * lbRTC_MONTHS_MAX; - - if (interval >= 0 && interval < lbRTC_MONTHS_MAX) { - mCD_player_calendar_c* calendar = &Save_Get(private[player_no]).calendar; - - switch (event) { - case 11: - { - if (calendar->event_flags & mCD_FLAG_MOTHERS_DAY) { - res = TRUE; - } - - break; - } - - case 4: - { - if (calendar->event_flags & mCD_FLAG_TOWN_DAY) { - res = TRUE; - } - - break; - } - - case 16: - { - if (calendar->event_flags & mCD_FLAG_METEOR_SHOWER) { - res = TRUE; - } - - break; - } - - case 1: - { - if (calendar->event_flags & mCD_FLAG_FOUNDERS_DAY) { - res = TRUE; - } - - break; - } - - case 17: - { - if (mCD_calendar_check_harvest_moon_viewing(calendar, month) == TRUE) { - res = TRUE; - } - - break; - } - - case 19: - { - if (calendar->event_flags & mCD_FLAG_OFFICERS_DAY) { - res = TRUE; - } - - break; - } - - case 255: - { - break; - } - - default: - { - if (calendar->event_days[month - 1] & (1 << (day - 1))) { - res = TRUE; - } - - break; - } - } + if (player_no == -1) { + player_no = Common_Get(player_no); } - } - return res; + if (player_no != mPr_FOREIGNER) { + lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); + + int interval = (rtc_time->month - month) + (rtc_time->year - year) * lbRTC_MONTHS_MAX; + + if (interval >= 0 && interval < lbRTC_MONTHS_MAX) { + mCD_player_calendar_c* calendar = &Save_Get(private_data[player_no]).calendar; + + switch (event) { + case 11: { + if (calendar->event_flags & mCD_FLAG_MOTHERS_DAY) { + res = TRUE; + } + + break; + } + + case 4: { + if (calendar->event_flags & mCD_FLAG_TOWN_DAY) { + res = TRUE; + } + + break; + } + + case 16: { + if (calendar->event_flags & mCD_FLAG_METEOR_SHOWER) { + res = TRUE; + } + + break; + } + + case 1: { + if (calendar->event_flags & mCD_FLAG_FOUNDERS_DAY) { + res = TRUE; + } + + break; + } + + case 17: { + if (mCD_calendar_check_harvest_moon_viewing(calendar, month) == TRUE) { + res = TRUE; + } + + break; + } + + case 19: { + if (calendar->event_flags & mCD_FLAG_OFFICERS_DAY) { + res = TRUE; + } + + break; + } + + case 255: { + break; + } + + default: { + if (calendar->event_days[month - 1] & (1 << (day - 1))) { + res = TRUE; + } + + break; + } + } + } + } + + return res; } diff --git a/src/m_event.c b/src/m_event.c index c0b351d8..d2af204c 100644 --- a/src/m_event.c +++ b/src/m_event.c @@ -11,11 +11,11 @@ #include "m_soncho.h" enum { - mEv_INIT_NO_RENEWAL, - mEv_INIT_RENEWAL, - mEv_INIT_FORCE_RENEWAL, + mEv_INIT_NO_RENEWAL, + mEv_INIT_RENEWAL, + mEv_INIT_FORCE_RENEWAL, - mEv_INIT_NUM + mEv_INIT_NUM }; static int n_today_events = 0; @@ -26,849 +26,788 @@ static lbRTC_year_t weekday1st_year = 0; static lbRTC_weekday_t weekday1st[lbRTC_MONTHS_MAX]; typedef union ymdh { - struct { - u8 year; - u8 month; - u8 day; - u8 hour; - }; - u32 raw; + struct { + u8 year; + u8 month; + u8 day; + u8 hour; + }; + u32 raw; } mEv_ymdh_u; extern void mEv_ClearSpecialEvent(mEv_special_c* special_event) { - special_event->type = -1; - bzero(&special_event->event, sizeof(mEv_special_u)); - bzero(Common_GetPointer(special_event_common), sizeof(mEv_event_common_u)); + special_event->type = -1; + bzero(&special_event->event, sizeof(mEv_special_u)); + bzero(Common_GetPointer(special_event_common), sizeof(mEv_event_common_u)); } extern void mEv_ClearEventKabuPeddler(mEv_kabu_peddler_c* kabu_peddler) { - if (kabu_peddler != NULL) { - mPr_ClearAnyPersonalID(kabu_peddler->spoken_pids, TOTAL_PLAYER_NUM); - } + if (kabu_peddler != NULL) { + mPr_ClearAnyPersonalID(kabu_peddler->spoken_pids, TOTAL_PLAYER_NUM); + } } extern void mEv_ClearEventSaveInfo(mEv_event_save_c* save_event) { - mEv_ClearSpecialEvent(&save_event->special); - mEv_ClearEventKabuPeddler(&save_event->weekly.kabu_peddler); - save_event->flags = 0; + mEv_ClearSpecialEvent(&save_event->special); + mEv_ClearEventKabuPeddler(&save_event->weekly.kabu_peddler); + save_event->flags = 0; } extern void mEv_ClearEventInfo() { - mEv_event_save_c* event_save = Save_GetPointer(event_save_data); - u32* event_flag = Common_Get(event_flags); - int i; + mEv_event_save_c* event_save = Save_GetPointer(event_save_data); + u32* event_flag = Common_Get(event_flags); + int i; - for (i = 0; i < mEv_EVENT_TYPE_NUM; i++) { - event_flag[0] = 0; - event_flag++; - } + for (i = 0; i < mEv_EVENT_TYPE_NUM; i++) { + event_flag[0] = 0; + event_flag++; + } - Common_Get(event_flags[1]) = event_save->flags; - Common_Get(event_common).fieldday_event_id = -1; - Common_Get(event_common).fieldday_event_over_status = -1; + Common_Get(event_flags[1]) = event_save->flags; + Common_Get(event_common).fieldday_event_id = -1; + Common_Get(event_common).fieldday_event_over_status = -1; } extern void mEv_EventON(u32 event_kind) { - u32 type = mEv_GET_TYPE(event_kind); + u32 type = mEv_GET_TYPE(event_kind); - if (type < mEv_EVENT_TYPE_NUM) { - u32* flag_p = Common_GetPointer(event_flags[type]); - *flag_p |= (1 << mEv_GET_SUBTYPE(event_kind)); + if (type < mEv_EVENT_TYPE_NUM) { + u32* flag_p = Common_GetPointer(event_flags[type]); + *flag_p |= (1 << mEv_GET_SUBTYPE(event_kind)); - if (type == mEv_SAVED_EVENT) { - Save_Get(event_save_data).flags = *flag_p; + if (type == mEv_SAVED_EVENT) { + Save_Get(event_save_data).flags = *flag_p; + } } - } } extern void mEv_EventOFF(u32 event_kind) { - u32 type = mEv_GET_TYPE(event_kind); + u32 type = mEv_GET_TYPE(event_kind); - if (type < mEv_EVENT_TYPE_NUM) { - u32* flag_p = Common_GetPointer(event_flags[type]); - u32 mask = 1 << mEv_GET_SUBTYPE(event_kind); - - *flag_p &= ~mask; - if (type == mEv_SAVED_EVENT) { - Save_Get(event_save_data).flags = *flag_p; + if (type < mEv_EVENT_TYPE_NUM) { + u32* flag_p = Common_GetPointer(event_flags[type]); + u32 mask = 1 << mEv_GET_SUBTYPE(event_kind); + + *flag_p &= ~mask; + if (type == mEv_SAVED_EVENT) { + Save_Get(event_save_data).flags = *flag_p; + } } - } } extern int mEv_CheckEvent(u32 event_kind) { - u32 type = mEv_GET_TYPE(event_kind); - int res = FALSE; + u32 type = mEv_GET_TYPE(event_kind); + int res = FALSE; - if (type < mEv_EVENT_TYPE_NUM) { - u32* flags_p = Common_GetPointer(event_flags[type]); - - if (((*flags_p) >> mEv_GET_SUBTYPE(event_kind)) & 1) { - res = TRUE; + if (type < mEv_EVENT_TYPE_NUM) { + u32* flags_p = Common_GetPointer(event_flags[type]); + + if (((*flags_p) >> mEv_GET_SUBTYPE(event_kind)) & 1) { + res = TRUE; + } } - } - return res; + return res; } extern void mEv_ClearPersonalEventFlag(int player_no) { - mEv_EventOFF(mEv_SAVED_FIRSTJOB_PLR0 + player_no); - mEv_EventOFF(mEv_SAVED_FIRSTINTRO_PLR0 + player_no); - mEv_EventOFF(mEv_SAVED_HRAWAIT_PLR0 + player_no); - mEv_EventOFF(mEv_SAVED_HRATALK_PLR0 + player_no); - mEv_EventOFF(mEv_SAVED_FJOPENQUEST_PLR0 + player_no); - mEv_EventOFF(mEv_SAVED_GATEWAY_PLR0 + player_no); + mEv_EventOFF(mEv_SAVED_FIRSTJOB_PLR0 + player_no); + mEv_EventOFF(mEv_SAVED_FIRSTINTRO_PLR0 + player_no); + mEv_EventOFF(mEv_SAVED_HRAWAIT_PLR0 + player_no); + mEv_EventOFF(mEv_SAVED_HRATALK_PLR0 + player_no); + mEv_EventOFF(mEv_SAVED_FJOPENQUEST_PLR0 + player_no); + mEv_EventOFF(mEv_SAVED_GATEWAY_PLR0 + player_no); - { - aAPC_event_save_data_c* data = (aAPC_event_save_data_c*)mEv_get_save_area(mEv_EVENT_APRILFOOLS_DAY, 0); + { + aAPC_event_save_data_c* data = (aAPC_event_save_data_c*)mEv_get_save_area(mEv_EVENT_APRILFOOLS_DAY, 0); - if (data != NULL) { - data->talk_bitfield[player_no] = 0; + if (data != NULL) { + data->talk_bitfield[player_no] = 0; + } } - } } extern void mEv_SetFirstJob() { - if (Common_Get(player_no) < PLAYER_NUM) { - u32 ev = mEv_SAVED_FIRSTJOB_PLR0; + if (Common_Get(player_no) < PLAYER_NUM) { + u32 ev = mEv_SAVED_FIRSTJOB_PLR0; - ev += Common_Get(player_no); - mEv_EventON(ev); - } + ev += Common_Get(player_no); + mEv_EventON(ev); + } } extern int mEv_CheckRealArbeit() { - u32 player_no = Common_Get(player_no); - int res = FALSE; - - if ( - player_no < PLAYER_NUM && - ( - mEv_CheckEvent(mEv_SAVED_FIRSTJOB_PLR0 + player_no) == TRUE || - mEv_CheckEvent( mEv_SAVED_HRAWAIT_PLR0 + player_no) == TRUE - ) - ) { - res = TRUE; - } + u32 player_no = Common_Get(player_no); + int res = FALSE; - return res; + if (player_no < PLAYER_NUM && (mEv_CheckEvent(mEv_SAVED_FIRSTJOB_PLR0 + player_no) == TRUE || + mEv_CheckEvent(mEv_SAVED_HRAWAIT_PLR0 + player_no) == TRUE)) { + res = TRUE; + } + + return res; } extern int mEv_CheckArbeit() { - u32 player_no = Common_Get(player_no); - int res = FALSE; - - if ( - player_no < PLAYER_NUM && - ( - mEv_CheckEvent(mEv_SAVED_FIRSTJOB_PLR0 + player_no) == TRUE || - mEv_CheckEvent( mEv_SAVED_HRAWAIT_PLR0 + player_no) == TRUE || - mEv_CheckEvent( mEv_SAVED_HRATALK_PLR0 + player_no) == TRUE - ) - ) { - res = TRUE; - } + u32 player_no = Common_Get(player_no); + int res = FALSE; - return res; + if (player_no < PLAYER_NUM && (mEv_CheckEvent(mEv_SAVED_FIRSTJOB_PLR0 + player_no) == TRUE || + mEv_CheckEvent(mEv_SAVED_HRAWAIT_PLR0 + player_no) == TRUE || + mEv_CheckEvent(mEv_SAVED_HRATALK_PLR0 + player_no) == TRUE)) { + res = TRUE; + } + + return res; } extern int mFI_CheckFirstJob() { - u32 player_no = Common_Get(player_no); - int res = FALSE; - - if (player_no < PLAYER_NUM) { - u32 ev = mEv_SAVED_FIRSTJOB_PLR0; - ev += player_no; - - if (mEv_CheckEvent(ev) == TRUE) { - res = TRUE; - } - } + u32 player_no = Common_Get(player_no); + int res = FALSE; - return res; + if (player_no < PLAYER_NUM) { + u32 ev = mEv_SAVED_FIRSTJOB_PLR0; + ev += player_no; + + if (mEv_CheckEvent(ev) == TRUE) { + res = TRUE; + } + } + + return res; } extern void mEv_UnSetFirstJob() { - u32 player_no = Common_Get(player_no); + u32 player_no = Common_Get(player_no); - if (player_no < PLAYER_NUM) { - mEv_EventOFF(mEv_SAVED_FIRSTJOB_PLR0 + player_no); - mEv_EventON(mEv_SAVED_HRAWAIT_PLR0 + player_no); - } + if (player_no < PLAYER_NUM) { + mEv_EventOFF(mEv_SAVED_FIRSTJOB_PLR0 + player_no); + mEv_EventON(mEv_SAVED_HRAWAIT_PLR0 + player_no); + } } extern void mEv_SetFirstIntro() { - u32 player_no = Common_Get(player_no); + u32 player_no = Common_Get(player_no); - if (player_no < PLAYER_NUM) { - u32 ev = mEv_SAVED_FIRSTINTRO_PLR0; - ev += player_no; - - mEv_EventON(ev); - } + if (player_no < PLAYER_NUM) { + u32 ev = mEv_SAVED_FIRSTINTRO_PLR0; + ev += player_no; + + mEv_EventON(ev); + } } extern int mEv_CheckFirstIntro() { - u32 player_no = Common_Get(player_no); - int res = FALSE; + u32 player_no = Common_Get(player_no); + int res = FALSE; - if (player_no < PLAYER_NUM) { - u32 ev = mEv_SAVED_FIRSTINTRO_PLR0; - ev += player_no; - - if (mEv_CheckEvent(ev) == TRUE) { - res = TRUE; + if (player_no < PLAYER_NUM) { + u32 ev = mEv_SAVED_FIRSTINTRO_PLR0; + ev += player_no; + + if (mEv_CheckEvent(ev) == TRUE) { + res = TRUE; + } } - } - return res; + return res; } extern void mEv_UnSetFirstIntro() { - u32 player_no = Common_Get(player_no); + u32 player_no = Common_Get(player_no); - if (player_no < PLAYER_NUM) { - u32 ev = mEv_SAVED_FIRSTINTRO_PLR0; - ev += player_no; - mEv_EventOFF(ev); - } + if (player_no < PLAYER_NUM) { + u32 ev = mEv_SAVED_FIRSTINTRO_PLR0; + ev += player_no; + mEv_EventOFF(ev); + } } extern void mEv_SetGateway() { - u32 player_no = Common_Get(player_no); + u32 player_no = Common_Get(player_no); - if (player_no < TOTAL_PLAYER_NUM) { - u32 ev = mEv_SAVED_GATEWAY_PLR0; - ev += player_no; - mEv_EventON(ev); - } + if (player_no < TOTAL_PLAYER_NUM) { + u32 ev = mEv_SAVED_GATEWAY_PLR0; + ev += player_no; + mEv_EventON(ev); + } } extern int mEv_CheckGateway() { - u32 player_no = Common_Get(player_no); - int res = FALSE; + u32 player_no = Common_Get(player_no); + int res = FALSE; - if (player_no < TOTAL_PLAYER_NUM) { - u32 ev = mEv_SAVED_GATEWAY_PLR0; - ev += player_no; + if (player_no < TOTAL_PLAYER_NUM) { + u32 ev = mEv_SAVED_GATEWAY_PLR0; + ev += player_no; - if (mEv_CheckEvent(ev) == TRUE) { - res = TRUE; + if (mEv_CheckEvent(ev) == TRUE) { + res = TRUE; + } } - } - return res; + return res; } extern void mEv_UnSetGateway() { - u32 player_no = Common_Get(player_no); + u32 player_no = Common_Get(player_no); - if (player_no < TOTAL_PLAYER_NUM) { - u32 ev = mEv_SAVED_GATEWAY_PLR0; - ev += player_no; - - mEv_EventOFF(ev); - } + if (player_no < TOTAL_PLAYER_NUM) { + u32 ev = mEv_SAVED_GATEWAY_PLR0; + ev += player_no; + + mEv_EventOFF(ev); + } } static int title_demo_number = -1; extern int mEv_CheckTitleDemo() { - return title_demo_number; + return title_demo_number; } extern void mEv_SetTitleDemo(int demo_number) { - title_demo_number = demo_number; + title_demo_number = demo_number; } extern void mEv_RenewalDataEveryDay() { - if (mTM_check_renew_time(mTM_RENEW_TIME_DAILY) == TRUE) { - int i; - - for (i = 0; i < PLAYER_NUM; i++) { - - u32 check_event = mEv_SAVED_HRAWAIT_PLR0 + i; - if (mEv_CheckEvent(check_event) == TRUE) { - /* After a new day starts, turn off all players' 'wait a day' HRA event and turn on talk to Tom Nook HRA event */ - mEv_EventOFF(check_event); - mEv_EventON(mEv_SAVED_HRATALK_PLR0 + i); - } + if (mTM_check_renew_time(mTM_RENEW_TIME_DAILY) == TRUE) { + int i; + + for (i = 0; i < PLAYER_NUM; i++) { + + u32 check_event = mEv_SAVED_HRAWAIT_PLR0 + i; + if (mEv_CheckEvent(check_event) == TRUE) { + /* After a new day starts, turn off all players' 'wait a day' HRA event and turn on talk to Tom Nook HRA + * event */ + mEv_EventOFF(check_event); + mEv_EventON(mEv_SAVED_HRATALK_PLR0 + i); + } + } } - } } extern void mEv_GetEventWeather(s16* weather, s16* intensity) { - intensity[0] = mEnv_WEATHER_INTENSITY_HEAVY; + intensity[0] = mEnv_WEATHER_INTENSITY_HEAVY; - if (mEv_check_schedule(mEv_EVENT_WEATHER_CLEAR)) { - weather[0] = mEnv_WEATHER_CLEAR; - } - else if (mEv_check_schedule(mEv_EVENT_WEATHER_SNOW)) { - weather[0] = mEnv_WEATHER_SNOW; - } - else if (mEv_check_schedule(mEv_EVENT_WEATHER_SPORTS_FAIR)) { - weather[0] = mEnv_WEATHER_CLEAR; - } - else { - weather[0] = -1; // no event weather - } + if (mEv_check_schedule(mEv_EVENT_WEATHER_CLEAR)) { + weather[0] = mEnv_WEATHER_CLEAR; + } else if (mEv_check_schedule(mEv_EVENT_WEATHER_SNOW)) { + weather[0] = mEnv_WEATHER_SNOW; + } else if (mEv_check_schedule(mEv_EVENT_WEATHER_SPORTS_FAIR)) { + weather[0] = mEnv_WEATHER_CLEAR; + } else { + weather[0] = -1; // no event weather + } } #include "m_event_schedule.c_inc" static int event_rumor_table[] = { - mEv_EVENT_RUMOR_NEW_YEARS_DAY, - mEv_EVENT_RUMOR_KAMAKURA, - mEv_EVENT_RUMOR_VALENTINES_DAY, - mEv_EVENT_RUMOR_GROUNDHOG_DAY, - mEv_EVENT_RUMOR_APRILFOOLS_DAY, - mEv_EVENT_RUMOR_CHERRY_BLOSSOM_FESTIVAL, - mEv_EVENT_RUMOR_SPRING_SPORTS_FAIR, - mEv_EVENT_RUMOR_HARVEST_FESTIVAL, - mEv_EVENT_76, - mEv_EVENT_RUMOR_FISHING_TOURNEY_1, - mEv_EVENT_TALK_FISHING_TOURNEY_1, - mEv_EVENT_RUMOR_MORNING_AEROBICS, - mEv_EVENT_TALK_MORNING_AEROBICS, - mEv_EVENT_RUMOR_FIREWORKS_SHOW, - mEv_EVENT_76, - mEv_EVENT_RUMOR_METEOR_SHOWER, - mEv_EVENT_RUMOR_HARVEST_MOON_DAY, - mEv_EVENT_RUMOR_FALL_SPORTS_FAIR, - mEv_EVENT_RUMOR_MUSHROOM_SEASON, - mEv_EVENT_TALK_MUSHROOM_SEASON, - mEv_EVENT_RUMOR_HALLOWEEN, - mEv_EVENT_RUMOR_FISHING_TOURNEY_2, - mEv_EVENT_TALK_FISHING_TOURNEY_2, - mEv_EVENT_RUMOR_TOY_DAY, - mEv_EVENT_RUMOR_NEW_YEARS_EVE_COUNTDOWN + mEv_EVENT_RUMOR_NEW_YEARS_DAY, mEv_EVENT_RUMOR_KAMAKURA, mEv_EVENT_RUMOR_VALENTINES_DAY, + mEv_EVENT_RUMOR_GROUNDHOG_DAY, mEv_EVENT_RUMOR_APRILFOOLS_DAY, mEv_EVENT_RUMOR_CHERRY_BLOSSOM_FESTIVAL, + mEv_EVENT_RUMOR_SPRING_SPORTS_FAIR, mEv_EVENT_RUMOR_HARVEST_FESTIVAL, mEv_EVENT_76, + mEv_EVENT_RUMOR_FISHING_TOURNEY_1, mEv_EVENT_TALK_FISHING_TOURNEY_1, mEv_EVENT_RUMOR_MORNING_AEROBICS, + mEv_EVENT_TALK_MORNING_AEROBICS, mEv_EVENT_RUMOR_FIREWORKS_SHOW, mEv_EVENT_76, + mEv_EVENT_RUMOR_METEOR_SHOWER, mEv_EVENT_RUMOR_HARVEST_MOON_DAY, mEv_EVENT_RUMOR_FALL_SPORTS_FAIR, + mEv_EVENT_RUMOR_MUSHROOM_SEASON, mEv_EVENT_TALK_MUSHROOM_SEASON, mEv_EVENT_RUMOR_HALLOWEEN, + mEv_EVENT_RUMOR_FISHING_TOURNEY_2, mEv_EVENT_TALK_FISHING_TOURNEY_2, mEv_EVENT_RUMOR_TOY_DAY, + mEv_EVENT_RUMOR_NEW_YEARS_EVE_COUNTDOWN }; static int n_event_rumors = ARRAY_COUNT(event_rumor_table); -static u16 special_event_types[] = { - mEv_EVENT_SHOP_SALE, - mEv_EVENT_DESIGNER, - mEv_EVENT_BROKER_SALE, - mEv_EVENT_ARTIST, - mEv_EVENT_CARPET_PEDDLER, - mEv_EVENT_GYPSY -}; +static u16 special_event_types[] = { mEv_EVENT_SHOP_SALE, mEv_EVENT_DESIGNER, mEv_EVENT_BROKER_SALE, + mEv_EVENT_ARTIST, mEv_EVENT_CARPET_PEDDLER, mEv_EVENT_GYPSY }; static int n_special_event_type = ARRAY_COUNT(special_event_types); static int last_day_of_month(lbRTC_month_t month) { - static lbRTC_day_t last_day[lbRTC_MONTHS_MAX] = { - 31, 28, 31, 30, - 31, 30, 31, 31, - 30, 31, 30, 31 - }; + static lbRTC_day_t last_day[lbRTC_MONTHS_MAX] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; - lbRTC_year_t year = Common_Get(time.rtc_time.year); - lbRTC_day_t day = last_day[month - 1]; + lbRTC_year_t year = Common_Get(time.rtc_time.year); + lbRTC_day_t day = last_day[month - 1]; - if (month != lbRTC_FEBRUARY) { - return day; - } - else if (lbRTC_IS_LEAPYEAR(year)) { - return 29; - } - else { - return 28; - } + if (month != lbRTC_FEBRUARY) { + return day; + } else if (lbRTC_IS_LEAPYEAR(year)) { + return 29; + } else { + return 28; + } } 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_time_c* rtc_time = Common_GetPointer(time.rtc_time); + lbRTC_month_t month; + lbRTC_month_t temp; + lbRTC_month_t i; + int weekday; - month = rtc_time->month & 0xF; - weekday1st_year = rtc_time->year; + 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; - } - - weekday1st[month] = weekday; - - 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; - - if (t < 0) { - t += lbRTC_WEEK; - } - - weekday1st[temp] = 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; + weekday = (rtc_time->weekday + (1 - rtc_time->day)) % lbRTC_WEEK; if (weekday < 0) { - weekday += lbRTC_WEEK; + weekday += lbRTC_WEEK; } - weekday1st[temp] = weekday; - } + weekday1st[month] = weekday; + + 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; + + if (t < 0) { + t += lbRTC_WEEK; + } + + weekday1st[temp] = 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; + } + + weekday1st[temp] = weekday; + } } static int check_date_range(u16 date, u16 lower_bound, u16 upper_bound) { - int res; + int res; - if (lower_bound > upper_bound) { - res = FALSE; - if (lower_bound <= date || date <= upper_bound) { - res = TRUE; + if (lower_bound > upper_bound) { + res = FALSE; + if (lower_bound <= date || date <= upper_bound) { + res = TRUE; + } + } else { + res = FALSE; + if (lower_bound <= date && date <= upper_bound) { + res = TRUE; + } } - } - else { - res = FALSE; - if (lower_bound <= date && date <= upper_bound) { - res = TRUE; - } - } - return res; + return res; } static int check_ymdh_range(u32 ymdh, u32 lower_bound, u32 upper_bound) { - int res = FALSE; + int res = FALSE; - if (lower_bound <= ymdh && ymdh <= upper_bound) { - res = TRUE; - } + if (lower_bound <= ymdh && ymdh <= upper_bound) { + res = TRUE; + } - return res; + return res; } static u16 after_n_day(u16 month_day, int n_day) { - mEv_MonthDay_u after; - u8 day; + mEv_MonthDay_u after; + u8 day; - after.raw = month_day; + after.raw = month_day; - if (n_day >= 0) { - day = last_day_of_month(after.month); + if (n_day >= 0) { + day = last_day_of_month(after.month); - after.day = after.day + n_day; - if (after.day > day) { - if (after.month == lbRTC_DECEMBER) { - after.month = lbRTC_JANUARY; - } - else { - after.month++; - } + after.day = after.day + n_day; + if (after.day > day) { + if (after.month == lbRTC_DECEMBER) { + after.month = lbRTC_JANUARY; + } else { + after.month++; + } - after.day -= day; + after.day -= day; + } + } else { + after.day = after.day + n_day; + if ((after.day & 0x80) != 0 || after.day == 0) { + if (after.month == lbRTC_JANUARY) { + after.month = lbRTC_DECEMBER; + } else { + after.month--; + } + + day = last_day_of_month(after.month); + after.day += day; + } } - } - else { - after.day = after.day + n_day; - if ((after.day & 0x80) != 0 || after.day == 0) { - if (after.month == lbRTC_JANUARY) { - after.month = lbRTC_DECEMBER; - } - else { - after.month--; - } - day = last_day_of_month(after.month); - after.day += day; - } - } - - return after.raw; + return after.raw; } extern lbRTC_day_t mEv_get_next_weekday(lbRTC_weekday_t weekday) { - lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); - lbRTC_weekday_t next_weekday; - lbRTC_day_t day; - lbRTC_day_t last_day; + lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); + lbRTC_weekday_t next_weekday; + lbRTC_day_t day; + lbRTC_day_t last_day; - if (weekday >= rtc_time->weekday) { - day = rtc_time->day + (weekday - rtc_time->weekday); - } - else { - day = rtc_time->day + (lbRTC_WEEK - (rtc_time->weekday - weekday)); - } + if (weekday >= rtc_time->weekday) { + day = rtc_time->day + (weekday - rtc_time->weekday); + } else { + day = rtc_time->day + (lbRTC_WEEK - (rtc_time->weekday - weekday)); + } - last_day = last_day_of_month(rtc_time->month); + last_day = last_day_of_month(rtc_time->month); - if (day > last_day) { - day -= last_day; - } + if (day > last_day) { + day -= last_day; + } - return day; + return day; } -#define mEv_date_decode_weekday(day) ((day) & 0b00000111) // 0-6 (which weekday, Sunday-Saturday) +#define mEv_date_decode_weekday(day) ((day) & 0b00000111) // 0-6 (which weekday, Sunday-Saturday) #define mEv_date_decode_week(day) (((day) & 0b00111000) >> 3) // 0-5 (which week of the month, 1st, 2nd, 3rd, ...) static lbRTC_day_t m_weekday2day(lbRTC_month_t month, u8 day_enc) { - lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); - int week = mEv_date_decode_week(day_enc); // get the week of the month - int weekday = mEv_date_decode_weekday(day_enc); // get the weekday - lbRTC_day_t day = 0; - int last_day = last_day_of_month(month); + lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); + int week = mEv_date_decode_week(day_enc); // get the week of the month + int weekday = mEv_date_decode_weekday(day_enc); // get the weekday + lbRTC_day_t day = 0; + int last_day = last_day_of_month(month); - if (week == mEv_SCHEDULE_EVERY_WEEK) { - if (month > rtc_time->month) { - week = 1; /* 1st week of this month */ - } - else if (month < rtc_time->month) { - week = mEv_SCHEDULE_LAST_WEEKDAY_OF_MONTH; /* last weekday of the month */ - } - else { - day = rtc_time->day - (rtc_time->weekday - weekday); + if (week == mEv_SCHEDULE_EVERY_WEEK) { + if (month > rtc_time->month) { + week = 1; /* 1st week of this month */ + } else if (month < rtc_time->month) { + week = mEv_SCHEDULE_LAST_WEEKDAY_OF_MONTH; /* last weekday of the month */ + } else { + day = rtc_time->day - (rtc_time->weekday - weekday); - if (day > (u8)last_day) { - week = mEv_SCHEDULE_LAST_WEEKDAY_OF_MONTH; - } - else { - week = 0; /* cleared */ - } + if (day > (u8)last_day) { + week = mEv_SCHEDULE_LAST_WEEKDAY_OF_MONTH; + } else { + week = 0; /* cleared */ + } + } } - } - if (week == mEv_SCHEDULE_LAST_WEEKDAY_OF_MONTH) { - lbRTC_day_t d = last_day; - int t_day = (-1 + d + weekday1st[month]) % lbRTC_WEEK; /* get the weekday of the first day of next month */ + if (week == mEv_SCHEDULE_LAST_WEEKDAY_OF_MONTH) { + lbRTC_day_t d = last_day; + int t_day = (-1 + d + weekday1st[month]) % lbRTC_WEEK; /* get the weekday of the first day of next month */ - if (weekday <= t_day) { - day = d - (t_day - weekday); - } - else { - day = (d - (t_day - weekday)) - lbRTC_WEEK; - } - } - else if (week != 0) { - int t_day = weekday1st[month]; + if (weekday <= t_day) { + day = d - (t_day - weekday); + } else { + day = (d - (t_day - weekday)) - lbRTC_WEEK; + } + } else if (week != 0) { + int t_day = weekday1st[month]; - if (weekday >= t_day) { - day = 1 + (week - 1) * lbRTC_WEEK + (weekday - t_day); + if (weekday >= t_day) { + day = 1 + (week - 1) * lbRTC_WEEK + (weekday - t_day); + } else { + day = 1 + week * lbRTC_WEEK + (weekday - t_day); + } } - else { - day = 1 + week * lbRTC_WEEK + (weekday - t_day); - } - } - return day; + return day; } static lbRTC_weekday_t weekday1st[lbRTC_MONTHS_MAX]; extern int mEv_weekday2day(lbRTC_month_t month, int week, int weekday) { - lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); - lbRTC_day_t day = 0; + lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); + lbRTC_day_t day = 0; - if (week == mEv_SCHEDULE_EVERY_WEEK) { - if (month > rtc_time->month) { - week = 1; /* 1st week of this month */ + if (week == mEv_SCHEDULE_EVERY_WEEK) { + if (month > rtc_time->month) { + week = 1; /* 1st week of this month */ + } else if (month < rtc_time->month) { + week = mEv_SCHEDULE_LAST_WEEKDAY_OF_MONTH; /* last weekday of the month */ + } else { + day = rtc_time->day - (rtc_time->weekday - weekday); + week = 0; /* cleared */ + } } - else if (month < rtc_time->month) { - week = mEv_SCHEDULE_LAST_WEEKDAY_OF_MONTH; /* last weekday of the month */ - } - else { - day = rtc_time->day - (rtc_time->weekday - weekday); - week = 0; /* cleared */ - } - } - if (week == mEv_SCHEDULE_LAST_WEEKDAY_OF_MONTH) { - lbRTC_day_t last_day = last_day_of_month(month); - int t_day = (-1 + last_day + weekday1st[month]) % lbRTC_WEEK; /* get the weekday of the first day of next month */ + if (week == mEv_SCHEDULE_LAST_WEEKDAY_OF_MONTH) { + lbRTC_day_t last_day = last_day_of_month(month); + int t_day = + (-1 + last_day + weekday1st[month]) % lbRTC_WEEK; /* get the weekday of the first day of next month */ - if (weekday <= t_day) { - day = last_day - (t_day - weekday); - } - else { - day = (last_day - (t_day - weekday)) - lbRTC_WEEK; - } - } - else if (week != 0) { - int t_day = weekday1st[month]; + if (weekday <= t_day) { + day = last_day - (t_day - weekday); + } else { + day = (last_day - (t_day - weekday)) - lbRTC_WEEK; + } + } else if (week != 0) { + int t_day = weekday1st[month]; - if (weekday >= t_day) { - day = 1 + (week - 1) * lbRTC_WEEK + (weekday - t_day); + if (weekday >= t_day) { + day = 1 + (week - 1) * lbRTC_WEEK + (weekday - t_day); + } else { + day = 1 + week * lbRTC_WEEK + (weekday - t_day); + } } - else { - day = 1 + week * lbRTC_WEEK + (weekday - t_day); - } - } - return day; + return day; } static int get_end_time(u32 active_hours) { - int hour; - int i; + int hour; + int i; - if ((active_hours & ((1 << 24) - 1)) == 0) { - return -1; /* no active hours */ - } - - hour = 23; - for (i = 0; i < 24; i++) { - if ((active_hours & (1 << 23)) != 0) { - break; + if ((active_hours & ((1 << 24) - 1)) == 0) { + return -1; /* no active hours */ } - active_hours <<= 1; /* move hours left by one bit, MSB is latest hour */ - hour--; - } + hour = 23; + for (i = 0; i < 24; i++) { + if ((active_hours & (1 << 23)) != 0) { + break; + } - return hour; + active_hours <<= 1; /* move hours left by one bit, MSB is latest hour */ + hour--; + } + + return hour; } static mEv_event_today_c event_today[mEv_TODAY_EVENT_NUM]; static u8 index_today[mEv_EVENT_NUM]; extern int mEv_get_end_time(int event_type) { - u8 idx = index_today[event_type]; - mEv_event_today_c* ev_today = &event_today[idx]; + u8 idx = index_today[event_type]; + mEv_event_today_c* ev_today = &event_today[idx]; - if (idx == 0xFF) { - return -1; - } - else { - return get_end_time(ev_today->active_hours); - } + if (idx == 0xFF) { + return -1; + } else { + return get_end_time(ev_today->active_hours); + } } static int search_empty_event_today() { - int i; + int i; - for (i = 0; i < mEv_TODAY_EVENT_NUM; i++) { - if (event_today[i].type == -1) { - return i; + for (i = 0; i < mEv_TODAY_EVENT_NUM; i++) { + if (event_today[i].type == -1) { + return i; + } } - } - return i; + return i; } static int add_event_today(u16 month_day, mEv_schedule_c* schedule) { - mEv_event_today_c* ev_today; - u8 idx = index_today[schedule->type]; - int res = FALSE; + mEv_event_today_c* ev_today; + u8 idx = index_today[schedule->type]; + int res = FALSE; - if (idx != 0xFF) { - ev_today = &event_today[idx]; - res = FALSE; - } - else { - int idx = search_empty_event_today(); + if (idx != 0xFF) { + ev_today = &event_today[idx]; + res = FALSE; + } else { + int idx = search_empty_event_today(); - if (idx >= mEv_TODAY_EVENT_NUM) { - return FALSE; - } - - index_today[schedule->type] = idx; - ev_today = &event_today[idx]; - n_today_events++; - } + if (idx >= mEv_TODAY_EVENT_NUM) { + return FALSE; + } - { - u8 start_hour = schedule->date[0].d.hour; - u8 end_hour = schedule->date[1].d.hour; - u32 n; - lbRTC_hour_t i; - - if ((start_hour & mEv_SCHEDULE_TODAY) != 0) { - ev_today->begin_date.raw = month_day; - ev_today->end_date.raw = month_day; - start_hour &= ~mEv_SCHEDULE_TODAY; - end_hour &= ~mEv_SCHEDULE_TODAY; - } - else { - ev_today->begin_date.raw = schedule->date[0].md; - ev_today->end_date.raw = schedule->date[1].md; + index_today[schedule->type] = idx; + ev_today = &event_today[idx]; + n_today_events++; } - if ((start_hour & mEv_SCHEDULE_MULTIDAY) != 0) { - start_hour &= ~mEv_SCHEDULE_MULTIDAY; - end_hour &= ~mEv_SCHEDULE_MULTIDAY; + { + u8 start_hour = schedule->date[0].d.hour; + u8 end_hour = schedule->date[1].d.hour; + u32 n; + lbRTC_hour_t i; - if (month_day != schedule->date[0].md) { - start_hour = 0; - } + if ((start_hour & mEv_SCHEDULE_TODAY) != 0) { + ev_today->begin_date.raw = month_day; + ev_today->end_date.raw = month_day; + start_hour &= ~mEv_SCHEDULE_TODAY; + end_hour &= ~mEv_SCHEDULE_TODAY; + } else { + ev_today->begin_date.raw = schedule->date[0].md; + ev_today->end_date.raw = schedule->date[1].md; + } - if (month_day != schedule->date[1].md) { - end_hour = 23; - } + if ((start_hour & mEv_SCHEDULE_MULTIDAY) != 0) { + start_hour &= ~mEv_SCHEDULE_MULTIDAY; + end_hour &= ~mEv_SCHEDULE_MULTIDAY; + + if (month_day != schedule->date[0].md) { + start_hour = 0; + } + + if (month_day != schedule->date[1].md) { + end_hour = 23; + } + } + + n = 1; + for (i = 0; i < 24; i++) { + if (start_hour <= i && i <= end_hour) { + ev_today->active_hours |= n; + } + + n <<= 1; + } } - n = 1; - for (i = 0; i < 24; i++) { - if (start_hour <= i && i <= end_hour) { - ev_today->active_hours |= n; - } + ev_today->type = schedule->type; + ev_today->status |= mEv_STATUS_EXIST; - n <<= 1; - } - } - - ev_today->type = schedule->type; - ev_today->status |= mEv_STATUS_EXIST; - - return res; + return res; } static int check_and_clear_event_today(Event_c* event, int type) { - u8 idx = index_today[type]; + u8 idx = index_today[type]; - if (idx != 0xFF) { - mEv_event_today_c* today_event = &event_today[idx]; + if (idx != 0xFF) { + mEv_event_today_c* today_event = &event_today[idx]; - if ((today_event->status & mEv_STATUS_EXIST) == FALSE) { - int flags = 0; - mEv_place_data_c* place = mEv_get_common_place(today_event->type, 81); + if ((today_event->status & mEv_STATUS_EXIST) == FALSE) { + int flags = 0; + mEv_place_data_c* place = mEv_get_common_place(today_event->type, 81); - if (place != NULL && place->block.x == event->block_x && place->block.z == event->block_z) { - flags |= 0b00000001; // 1, in the block the event is supposed to exist - } + if (place != NULL && place->block.x == event->block_x && place->block.z == event->block_z) { + flags |= 0b00000001; // 1, in the block the event is supposed to exist + } - if (mEv_check_status(today_event->type, mEv_STATUS_RUN)) { - flags |= 0b00000010; // 2, event is currently running - today_event->active_hours = 0x20000000; - } + if (mEv_check_status(today_event->type, mEv_STATUS_RUN)) { + flags |= 0b00000010; // 2, event is currently running + today_event->active_hours = 0x20000000; + } - if (type == today_event->type && flags == 0) { - today_event->type = -1; - today_event->active_hours = 0; - today_event->end_date.raw = 0; - today_event->status = 0; - n_today_events--; - index_today[type] = 0xFF; + if (type == today_event->type && flags == 0) { + today_event->type = -1; + today_event->active_hours = 0; + today_event->end_date.raw = 0; + today_event->status = 0; + n_today_events--; + index_today[type] = 0xFF; - return TRUE; - } + return TRUE; + } + } } - } - return FALSE; + return FALSE; } static int delete_too_short_event(Event_c* event, int type, u32 date) { - u8 idx = index_today[type]; + u8 idx = index_today[type]; - if (idx != 0xFF) { - mEv_event_today_c* today_event = &event_today[idx]; - mEv_schedule_date_u new_date; + if (idx != 0xFF) { + mEv_event_today_c* today_event = &event_today[idx]; + mEv_schedule_date_u new_date; - switch (today_event->type) { - case mEv_EVENT_NEW_YEARS_DAY: - case mEv_EVENT_GROUNDHOG_DAY: - case mEv_EVENT_SPORTS_FAIR_BALL_TOSS: - case mEv_EVENT_SPORTS_FAIR_AEROBICS: - case mEv_EVENT_SPORTS_FAIR_TUG_OF_WAR: - case mEv_EVENT_SPORTS_FAIR_FOOT_RACE: - case mEv_EVENT_CHERRY_BLOSSOM_FESTIVAL: - case mEv_EVENT_FISHING_TOURNEY_1: - case mEv_EVENT_FIREWORKS_SHOW: - case mEv_EVENT_MORNING_AEROBICS: - case mEv_EVENT_HARVEST_MOON_FESTIVAL: - case mEv_EVENT_FISHING_TOURNEY_2: - case mEv_EVENT_HARVEST_FESTIVAL: - { - new_date.raw = date; - new_date.d.hour = mEv_get_end_time(today_event->type); + switch (today_event->type) { + case mEv_EVENT_NEW_YEARS_DAY: + case mEv_EVENT_GROUNDHOG_DAY: + case mEv_EVENT_SPORTS_FAIR_BALL_TOSS: + case mEv_EVENT_SPORTS_FAIR_AEROBICS: + case mEv_EVENT_SPORTS_FAIR_TUG_OF_WAR: + case mEv_EVENT_SPORTS_FAIR_FOOT_RACE: + case mEv_EVENT_CHERRY_BLOSSOM_FESTIVAL: + case mEv_EVENT_FISHING_TOURNEY_1: + case mEv_EVENT_FIREWORKS_SHOW: + case mEv_EVENT_MORNING_AEROBICS: + case mEv_EVENT_HARVEST_MOON_FESTIVAL: + case mEv_EVENT_FISHING_TOURNEY_2: + case mEv_EVENT_HARVEST_FESTIVAL: { + new_date.raw = date; + new_date.d.hour = mEv_get_end_time(today_event->type); - break; - } + break; + } - case mEv_EVENT_HALLOWEEN: - case mEv_EVENT_TOY_DAY_JINGLE: - case mEv_EVENT_NEW_YEARS_EVE_COUNTDOWN: - { - new_date.raw = 0; - new_date.md = today_event->end_date.raw; - new_date.d.hour = mEv_get_end_time(today_event->type); + case mEv_EVENT_HALLOWEEN: + case mEv_EVENT_TOY_DAY_JINGLE: + case mEv_EVENT_NEW_YEARS_EVE_COUNTDOWN: { + new_date.raw = 0; + new_date.md = today_event->end_date.raw; + new_date.d.hour = mEv_get_end_time(today_event->type); - break; - } + break; + } - default: - { - return FALSE; - } + default: { + return FALSE; + } + } + + if (new_date.raw != date) { + return FALSE; + } + + if (Common_Get(time.rtc_time).min < 55) { + return FALSE; + } + + Common_Get(event_common).too_short = type; } - if (new_date.raw != date) { - return FALSE; - } - - if (Common_Get(time.rtc_time).min < 55) { - return FALSE; - } - - Common_Get(event_common).too_short = type; - } - - return TRUE; + return TRUE; } static void init_today_event() { - int i; + int i; - for (i = 0; i < mEv_TODAY_EVENT_NUM; i++) { - mEv_event_today_c* ev_today = &event_today[i]; - - ev_today->type = -1; - ev_today->active_hours = 0; - ev_today->begin_date.raw = ev_today->end_date.raw = 0; - ev_today->status = 0; - } + for (i = 0; i < mEv_TODAY_EVENT_NUM; i++) { + mEv_event_today_c* ev_today = &event_today[i]; - n_today_events = 0; - for (i = 0; i < mEv_EVENT_NUM; i++) { - index_today[i] = 0xFF; - } + ev_today->type = -1; + ev_today->active_hours = 0; + ev_today->begin_date.raw = ev_today->end_date.raw = 0; + ev_today->status = 0; + } + + n_today_events = 0; + for (i = 0; i < mEv_EVENT_NUM; i++) { + index_today[i] = 0xFF; + } } static void init_time_seat() { - int i; + int i; - for (i = 0; i < mEv_TODAY_EVENT_NUM; i++) { - mEv_event_today_c* ev_today = &event_today[i]; - - ev_today->active_hours = 0; - ev_today->begin_date.raw = ev_today->end_date.raw = 0; - ev_today->status &= ~mEv_STATUS_EXIST; - } + for (i = 0; i < mEv_TODAY_EVENT_NUM; i++) { + mEv_event_today_c* ev_today = &event_today[i]; + + ev_today->active_hours = 0; + ev_today->begin_date.raw = ev_today->end_date.raw = 0; + ev_today->status &= ~mEv_STATUS_EXIST; + } } static int get_special_event_end_time(s16 event_type) { - int end_time = 0; + int end_time = 0; - switch (event_type) { - case mEv_EVENT_DESIGNER: - end_time = 5; - break; - case mEv_EVENT_ARTIST: - end_time = 5; - break; - case mEv_EVENT_CARPET_PEDDLER: - end_time = 5; - break; - case mEv_EVENT_GYPSY: - end_time = 20; - break; - case mEv_EVENT_BROKER_SALE: - end_time = 17; - break; - case mEv_EVENT_SHOP_SALE: - end_time = 23; - break; - } + switch (event_type) { + case mEv_EVENT_DESIGNER: + end_time = 5; + break; + case mEv_EVENT_ARTIST: + end_time = 5; + break; + case mEv_EVENT_CARPET_PEDDLER: + end_time = 5; + break; + case mEv_EVENT_GYPSY: + end_time = 20; + break; + case mEv_EVENT_BROKER_SALE: + end_time = 17; + break; + case mEv_EVENT_SHOP_SALE: + end_time = 23; + break; + } - return end_time; + return end_time; } #define mEv_MonthDay(m, d) (((u8)(m) << 8) | ((u8)(d))) @@ -879,693 +818,656 @@ static int get_special_event_end_time(s16 event_type) { #define mEv_YearMonthDayHour(y, m, d, h) ((u32)(((u8)(y) << 24) | ((u8)(m) << 16) | ((u8)(d) << 8) | ((u8)(h)))) -/* @nonmatching TODO: This function needs a lot of help matching. Current best scratch: https://decomp.me/scratch/0EXoP */ +/* @nonmatching TODO: This function needs a lot of help matching. Current best scratch: https://decomp.me/scratch/0EXoP + */ static int init_special_event(int new_event) { - lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); - mEv_special_c* special_ev = &Save_Get(event_save_data).special; - int res = FALSE; + lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); + mEv_special_c* special_ev = &Save_Get(event_save_data).special; + int res = FALSE; - switch (Common_Get(last_scene_no)) { - case SCENE_BUGGY: - case SCENE_BROKER_SHOP: - { - if (gamePT->frame_counter == 0) { - return FALSE; - } - - break; - } - } - - switch (Save_Get(scene_no)) { - case SCENE_BUGGY: - case SCENE_BROKER_SHOP: - return FALSE; - - case SCENE_SHOP0: - case SCENE_CONVENI: - case SCENE_SUPER: - case SCENE_DEPART: - case SCENE_DEPART_2: - { - if (Save_Get(event_save_common).special_event.type == mEv_EVENT_SHOP_SALE) { - return FALSE; - } - } - - // fallthrough case - default: - { - mEv_ymdh_u rtc_ymdh; - mEv_ymdh_u special_ymdh; - mEv_ymdh_u special_end_ymdh; - mEv_MonthDay_u special_monthday; - mEv_schedule_date_u rtc_sched; - u16 special_end_monthday; - u16 sale_day_monthday; - mEv_save_common_data_c* ev_save_common = Save_GetPointer(event_save_common); - - //u16 rtc_monthday = mEv_MonthDay(Common_Get(time.rtc_time.month), Common_Get(time.rtc_time.day)); - //u32 rtc_ymdh = (u32)(((Common_Get(time.rtc_time.year) % 100) << 24) | (rtc_monthday << 8) | Common_Get(time.rtc_time.hour)); - // u32 special_ymdh = (u32)(((Save_Get(event_year_ymd.year) % 100) << 24) | (Save_Get(event_save_common).dates[mEv_SAVE_DATE_SPECIAL0] << 8)); - // u32 special_end_ymdh = (u32)( - // (((Save_Get(event_year_ymd.year) % 100) - ((Save_Get(event_save_common).dates[mEv_SAVE_DATE_SPECIAL2] < Save_Get(event_save_common).dates[mEv_SAVE_DATE_SPECIAL0] && rtc_monthday < Save_Get(event_save_common).dates[mEv_SAVE_DATE_SPECIAL0]) ? 1 : 2)) << 24) | - // (Save_Get(event_save_common).dates[mEv_SAVE_DATE_SPECIAL0] << 8) | - // (u8)get_special_event_end_time(Save_Get(event_save_common).special_event.type) - // ); - - rtc_sched.raw = 0; - rtc_sched.d.month = rtc_time->month; - rtc_sched.d.day = rtc_time->day; - - rtc_ymdh.raw = (rtc_sched.md) << 8; - rtc_ymdh.year = rtc_time->year % 100; - rtc_ymdh.hour = rtc_time->hour; - - special_ymdh.raw = ev_save_common->dates[mEv_SAVE_DATE_SPECIAL0] << 8; - special_ymdh.year = Save_Get(event_year) % 100; - - //special_end_ymdh.raw = (special_ymdh.month_day.raw) << 8; - special_end_ymdh.year = (Save_Get(event_year) % 100) + ((ev_save_common->dates[mEv_SAVE_DATE_SPECIAL0] > ev_save_common->dates[mEv_SAVE_DATE_SPECIAL2] && ev_save_common->dates[mEv_SAVE_DATE_SPECIAL0] > rtc_sched.md) ? 0 : -1); - special_end_ymdh.hour = get_special_event_end_time(ev_save_common->special_event.type); - - - if (check_ymdh_range(rtc_ymdh.raw, special_ymdh.raw, special_end_ymdh.raw) == FALSE || new_event) { - int seed = Common_Get(now_private)->player_ID.player_id; - s16 type; - int next_event_day_gap; - - res |= TRUE; - mEv_ClearSpecialEvent(special_ev); - seed += 1 + rtc_time->year - rtc_time->month + rtc_time->day + rtc_time->hour; - /* Sale Day */ - sale_day_monthday = after_n_day(((lbRTC_NOVEMBER) << 8) | m_weekday2day(lbRTC_NOVEMBER, mEv_SCHEDULE_4TH_WEEKDAY(lbRTC_THURSDAY)), 1); - - do { - sad_label: - /* Select a new unique random event */ - do { - type = special_event_types[seed % n_special_event_type]; - seed++; - } while (type == Save_Get(event_save_common).special_event.type); - - mFAs_SetFieldRank(); - next_event_day_gap = 1 + - ((rtc_time->day + rtc_time->month * rtc_time->sec) % - ((mFAs_FIELDRANK_SIX + 1) - mFAs_GetFieldRank())); - - if (next_event_day_gap == 1) { - next_event_day_gap = 2; // minimum of 2 days between special events + switch (Common_Get(last_scene_no)) { + case SCENE_BUGGY: + case SCENE_BROKER_SHOP: { + if (gamePT->frame_counter == 0) { + return FALSE; } - special_monthday.raw = after_n_day(rtc_sched.md, next_event_day_gap); - if ((u16)rtc_sched.md <= sale_day_monthday && (u16)sale_day_monthday <= (u32)special_monthday.raw) { - /* Force the next special event to be Crazy Redd since Sale Day falls between now and the rolled event date */ - special_monthday.raw = sale_day_monthday; - type = mEv_EVENT_BROKER_SALE; - } - - /* Set event start hour */ - Save_Get(event_save_common).dates[mEv_SAVE_DATE_SPECIAL3] = 6; - - switch (type) { - case mEv_EVENT_GYPSY: - break; - - case mEv_EVENT_SHOP_SALE: - { - lbRTC_day_t last_day = last_day_of_month(special_monthday.month); - - if ( - special_monthday.day != last_day && - (special_monthday.raw < mEv_MonthDay(lbRTC_JANUARY, 1) || special_monthday.raw > mEv_MonthDay(lbRTC_JANUARY, 3)) && - mEv_CheckEvent(mEv_SAVED_RENEWSHOP) != TRUE - ) { - /* Set shop sale starting hour randomly between 12PM and 7PM */ - Save_Get(event_save_common).dates[mEv_SAVE_DATE_SPECIAL3] = 12 + RANDOM(8); - goto hate_gotos; - } - goto sad_label; - } - - case mEv_EVENT_BROKER_SALE: - { - if (special_monthday.raw != mEv_MonthDay(lbRTC_JULY, 4)) { - /* Set broker sale start hour to 6PM when it's not the Fireworks Festival */ - Save_Get(event_save_common).dates[mEv_SAVE_DATE_SPECIAL3] = 18; - goto hate_gotos; - } - goto sad_label; - } - - default: - goto hate_gotos; - break; - } - } while (special_monthday.raw == mEv_MonthDay(lbRTC_DECEMBER, 31)); - - Save_Get(event_save_common).dates[mEv_SAVE_DATE_SPECIAL3] = 21; // default event start time is 9pm? - - hate_gotos: - { - mEv_save_common_data_c* ev_save_common = Save_GetPointer(event_save_common); - u16 year; - - special_end_monthday = after_n_day(special_monthday.raw, type != mEv_EVENT_SHOP_SALE); // ?? - year = rtc_time->year; - ev_save_common->special_event.type = type; - ev_save_common->dates[mEv_SAVE_DATE_SPECIAL0] = rtc_sched.md; // current date - ev_save_common->dates[mEv_SAVE_DATE_SPECIAL1] = special_monthday.raw; // start date - ev_save_common->dates[mEv_SAVE_DATE_SPECIAL2] = special_end_monthday; // end date - Save_Set(event_year, year); - Save_Get(post_office).leaflet_recipient_flags.event_flags = 0b1111; // deliver leaflet to all players if necessary for event + break; } - } - break; } - } - return res; + switch (Save_Get(scene_no)) { + case SCENE_BUGGY: + case SCENE_BROKER_SHOP: + return FALSE; + + case SCENE_SHOP0: + case SCENE_CONVENI: + case SCENE_SUPER: + case SCENE_DEPART: + case SCENE_DEPART_2: { + if (Save_Get(event_save_common).special_event.type == mEv_EVENT_SHOP_SALE) { + return FALSE; + } + } + + // fallthrough case + default: { + mEv_ymdh_u rtc_ymdh; + mEv_ymdh_u special_ymdh; + mEv_ymdh_u special_end_ymdh; + mEv_MonthDay_u special_monthday; + mEv_schedule_date_u rtc_sched; + u16 special_end_monthday; + u16 sale_day_monthday; + mEv_save_common_data_c* ev_save_common = Save_GetPointer(event_save_common); + + // u16 rtc_monthday = mEv_MonthDay(Common_Get(time.rtc_time.month), Common_Get(time.rtc_time.day)); + // u32 rtc_ymdh = (u32)(((Common_Get(time.rtc_time.year) % 100) << 24) | (rtc_monthday << 8) | + // Common_Get(time.rtc_time.hour)); + // u32 special_ymdh = (u32)(((Save_Get(event_year_ymd.year) % 100) << 24) | + // (Save_Get(event_save_common).dates[mEv_SAVE_DATE_SPECIAL0] << 8)); u32 special_end_ymdh = (u32)( + // (((Save_Get(event_year_ymd.year) % 100) - ((Save_Get(event_save_common).dates[mEv_SAVE_DATE_SPECIAL2] + // < Save_Get(event_save_common).dates[mEv_SAVE_DATE_SPECIAL0] && rtc_monthday < + // Save_Get(event_save_common).dates[mEv_SAVE_DATE_SPECIAL0]) ? 1 : 2)) << 24) | + // (Save_Get(event_save_common).dates[mEv_SAVE_DATE_SPECIAL0] << 8) | + // (u8)get_special_event_end_time(Save_Get(event_save_common).special_event.type) + // ); + + rtc_sched.raw = 0; + rtc_sched.d.month = rtc_time->month; + rtc_sched.d.day = rtc_time->day; + + rtc_ymdh.raw = (rtc_sched.md) << 8; + rtc_ymdh.year = rtc_time->year % 100; + rtc_ymdh.hour = rtc_time->hour; + + special_ymdh.raw = ev_save_common->dates[mEv_SAVE_DATE_SPECIAL0] << 8; + special_ymdh.year = Save_Get(event_year) % 100; + + // special_end_ymdh.raw = (special_ymdh.month_day.raw) << 8; + special_end_ymdh.year = + (Save_Get(event_year) % 100) + + ((ev_save_common->dates[mEv_SAVE_DATE_SPECIAL0] > ev_save_common->dates[mEv_SAVE_DATE_SPECIAL2] && + ev_save_common->dates[mEv_SAVE_DATE_SPECIAL0] > rtc_sched.md) + ? 0 + : -1); + special_end_ymdh.hour = get_special_event_end_time(ev_save_common->special_event.type); + + if (check_ymdh_range(rtc_ymdh.raw, special_ymdh.raw, special_end_ymdh.raw) == FALSE || new_event) { + int seed = Common_Get(now_private)->player_ID.player_id; + s16 type; + int next_event_day_gap; + + res |= TRUE; + mEv_ClearSpecialEvent(special_ev); + seed += 1 + rtc_time->year - rtc_time->month + rtc_time->day + rtc_time->hour; + /* Sale Day */ + sale_day_monthday = after_n_day( + ((lbRTC_NOVEMBER) << 8) | m_weekday2day(lbRTC_NOVEMBER, mEv_SCHEDULE_4TH_WEEKDAY(lbRTC_THURSDAY)), + 1); + + do { + sad_label: + /* Select a new unique random event */ + do { + type = special_event_types[seed % n_special_event_type]; + seed++; + } while (type == Save_Get(event_save_common).special_event.type); + + mFAs_SetFieldRank(); + next_event_day_gap = 1 + ((rtc_time->day + rtc_time->month * rtc_time->sec) % + ((mFAs_FIELDRANK_SIX + 1) - mFAs_GetFieldRank())); + + if (next_event_day_gap == 1) { + next_event_day_gap = 2; // minimum of 2 days between special events + } + + special_monthday.raw = after_n_day(rtc_sched.md, next_event_day_gap); + if ((u16)rtc_sched.md <= sale_day_monthday && (u16)sale_day_monthday <= (u32)special_monthday.raw) { + /* Force the next special event to be Crazy Redd since Sale Day falls between now and the rolled + * event date */ + special_monthday.raw = sale_day_monthday; + type = mEv_EVENT_BROKER_SALE; + } + + /* Set event start hour */ + Save_Get(event_save_common).dates[mEv_SAVE_DATE_SPECIAL3] = 6; + + switch (type) { + case mEv_EVENT_GYPSY: + break; + + case mEv_EVENT_SHOP_SALE: { + lbRTC_day_t last_day = last_day_of_month(special_monthday.month); + + if (special_monthday.day != last_day && + (special_monthday.raw < mEv_MonthDay(lbRTC_JANUARY, 1) || + special_monthday.raw > mEv_MonthDay(lbRTC_JANUARY, 3)) && + mEv_CheckEvent(mEv_SAVED_RENEWSHOP) != TRUE) { + /* Set shop sale starting hour randomly between 12PM and 7PM */ + Save_Get(event_save_common).dates[mEv_SAVE_DATE_SPECIAL3] = 12 + RANDOM(8); + goto hate_gotos; + } + goto sad_label; + } + + case mEv_EVENT_BROKER_SALE: { + if (special_monthday.raw != mEv_MonthDay(lbRTC_JULY, 4)) { + /* Set broker sale start hour to 6PM when it's not the Fireworks Festival */ + Save_Get(event_save_common).dates[mEv_SAVE_DATE_SPECIAL3] = 18; + goto hate_gotos; + } + goto sad_label; + } + + default: + goto hate_gotos; + break; + } + } while (special_monthday.raw == mEv_MonthDay(lbRTC_DECEMBER, 31)); + + Save_Get(event_save_common).dates[mEv_SAVE_DATE_SPECIAL3] = 21; // default event start time is 9pm? + + hate_gotos: { + mEv_save_common_data_c* ev_save_common = Save_GetPointer(event_save_common); + u16 year; + + special_end_monthday = after_n_day(special_monthday.raw, type != mEv_EVENT_SHOP_SALE); // ?? + year = rtc_time->year; + ev_save_common->special_event.type = type; + ev_save_common->dates[mEv_SAVE_DATE_SPECIAL0] = rtc_sched.md; // current date + ev_save_common->dates[mEv_SAVE_DATE_SPECIAL1] = special_monthday.raw; // start date + ev_save_common->dates[mEv_SAVE_DATE_SPECIAL2] = special_end_monthday; // end date + Save_Set(event_year, year); + Save_Get(post_office).leaflet_recipient_flags.event_flags = + 0b1111; // deliver leaflet to all players if necessary for event + } + } + break; + } + } + + return res; } static int update_special_event(mEv_schedule_c* sched) { - s16 type = Save_Get(event_save_common).special_event.type; - int active = TRUE; - - switch (sched->type) { - case mEv_EVENT_ARTIST: - case mEv_EVENT_BROKER_SALE: - case mEv_EVENT_DESIGNER: - case mEv_EVENT_GYPSY: - case mEv_EVENT_SHOP_SALE: - case mEv_EVENT_CARPET_PEDDLER: - { - if (type != sched->type) { - sched->date[1].raw = 0; - sched->date[0].raw = 0; - active = FALSE; - } - break; + s16 type = Save_Get(event_save_common).special_event.type; + int active = TRUE; + + switch (sched->type) { + case mEv_EVENT_ARTIST: + case mEv_EVENT_BROKER_SALE: + case mEv_EVENT_DESIGNER: + case mEv_EVENT_GYPSY: + case mEv_EVENT_SHOP_SALE: + case mEv_EVENT_CARPET_PEDDLER: { + if (type != sched->type) { + sched->date[1].raw = 0; + sched->date[0].raw = 0; + active = FALSE; + } + break; + } + + case mEv_EVENT_HANDBILL_SHOP_SALE: { + if (type != mEv_EVENT_SHOP_SALE) { + sched->date[1].raw = 0; + sched->date[0].raw = 0; + active = FALSE; + } + break; + } + + case mEv_EVENT_HANDBILL_BROKER: { + if (type != mEv_EVENT_BROKER_SALE) { + sched->date[1].raw = 0; + sched->date[0].raw = 0; + active = FALSE; + } + break; + } + + default: + active = FALSE; + break; } - case mEv_EVENT_HANDBILL_SHOP_SALE: - { - if (type != mEv_EVENT_SHOP_SALE) { - sched->date[1].raw = 0; - sched->date[0].raw = 0; - active = FALSE; - } - break; - } - - case mEv_EVENT_HANDBILL_BROKER: - { - if (type != mEv_EVENT_BROKER_SALE) { - sched->date[1].raw = 0; - sched->date[0].raw = 0; - active = FALSE; - } - break; - } - - default: - active = FALSE; - break; - } - - return active; + return active; } extern u16 mEv_get_bargain_day() { - u16 bargain_day = 0; + u16 bargain_day = 0; - if (Save_Get(event_save_common).special_event.type == mEv_EVENT_SHOP_SALE) { - bargain_day = Save_Get(event_save_common).dates[mEv_SAVE_DATE_SPECIAL1]; - } + if (Save_Get(event_save_common).special_event.type == mEv_EVENT_SHOP_SALE) { + bargain_day = Save_Get(event_save_common).dates[mEv_SAVE_DATE_SPECIAL1]; + } - return bargain_day; + return bargain_day; } static int is_special_event_valid() { - mEv_schedule_date_u date; + mEv_schedule_date_u date; - date.raw = 0; - date.d.month = Common_Get(time.rtc_time.month); - date.d.day = Common_Get(time.rtc_time.day); + date.raw = 0; + date.d.month = Common_Get(time.rtc_time.month); + date.d.day = Common_Get(time.rtc_time.day); - return check_date_range( - date.md, - Save_Get(event_save_common).dates[mEv_SAVE_DATE_SPECIAL0], - Save_Get(event_save_common).dates[mEv_SAVE_DATE_SPECIAL2] - ); + return check_date_range(date.md, Save_Get(event_save_common).dates[mEv_SAVE_DATE_SPECIAL0], + Save_Get(event_save_common).dates[mEv_SAVE_DATE_SPECIAL2]); } extern u16 mEv_get_special_event_day() { - u16 day = 0; + u16 day = 0; - if (is_special_event_valid()) { - day = Save_Get(event_save_common).dates[mEv_SAVE_DATE_SPECIAL1]; - } + if (is_special_event_valid()) { + day = Save_Get(event_save_common).dates[mEv_SAVE_DATE_SPECIAL1]; + } - return day; + return day; } extern u16 mEv_get_special_event_type() { - u16 type = 0; + u16 type = 0; - if (is_special_event_valid()) { - type = Save_Get(event_save_common).special_event.type; - } + if (is_special_event_valid()) { + type = Save_Get(event_save_common).special_event.type; + } - return type; + return type; } extern int mEv_get_event_place(int event, int* bx, int* bz) { - mEv_place_data_c* place; + mEv_place_data_c* place; - if (mEv_check_status(event, mEv_STATUS_RUN) != FALSE) { - place = mEv_get_common_place(event, 81); + if (mEv_check_status(event, mEv_STATUS_RUN) != FALSE) { + place = mEv_get_common_place(event, 81); - if (place != NULL) { - *bx = place->block.x; - *bz = place->block.z; - return TRUE; + if (place != NULL) { + *bx = place->block.x; + *bz = place->block.z; + return TRUE; + } } - } - return FALSE; + return FALSE; } extern int mEv_bridge_time_check() { - lbRTC_time_c rtc_time = Common_Get(time.rtc_time); + lbRTC_time_c rtc_time = Common_Get(time.rtc_time); - return lbRTC_IsEqualDate( - Save_Get(bridge).build_date.year, Save_Get(bridge).build_date.month, Save_Get(bridge).build_date.day, - rtc_time.year, rtc_time.month, rtc_time.day - ); + return lbRTC_IsEqualDate(Save_Get(bridge).build_date.year, Save_Get(bridge).build_date.month, + Save_Get(bridge).build_date.day, rtc_time.year, rtc_time.month, rtc_time.day); } static void init_weekly_event() { - u16 sched_date; - lbRTC_time_c* rtc_time = &Common_Get(time.rtc_time); - mEv_kabu_peddler_c* kabu_peddler_data = &Save_Get(event_save_data).weekly.kabu_peddler; - mEv_MonthDay_u today_date; - u8 flag = 0; - u16 ghost_date; - u16 ghost_date2; - u16 monday_date; - u16 friday_date; - u16* event_dates = Save_Get(event_save_common).dates; + u16 sched_date; + lbRTC_time_c* rtc_time = &Common_Get(time.rtc_time); + mEv_kabu_peddler_c* kabu_peddler_data = &Save_Get(event_save_data).weekly.kabu_peddler; + mEv_MonthDay_u today_date; + u8 flag = 0; + u16 ghost_date; + u16 ghost_date2; + u16 monday_date; + u16 friday_date; + u16* event_dates = Save_Get(event_save_common).dates; - today_date.month = rtc_time->month; - today_date.day = rtc_time->day; - sched_date = event_dates[mEv_SAVE_DATE_WEEKLY]; - - switch (rtc_time->weekday) { - case lbRTC_SUNDAY: - { - /* Update Joan's data */ - if (today_date.raw != sched_date) { - mEv_ClearEventKabuPeddler(kabu_peddler_data); - sched_date = today_date.raw; - event_dates[mEv_SAVE_DATE_WEEKLY] = sched_date; - Save_Get(event_save_common).weekly_event.type = mEv_EVENT_KABU_PEDDLER; - flag = 1; - } - break; + today_date.month = rtc_time->month; + today_date.day = rtc_time->day; + sched_date = event_dates[mEv_SAVE_DATE_WEEKLY]; + + switch (rtc_time->weekday) { + case lbRTC_SUNDAY: { + /* Update Joan's data */ + if (today_date.raw != sched_date) { + mEv_ClearEventKabuPeddler(kabu_peddler_data); + sched_date = today_date.raw; + event_dates[mEv_SAVE_DATE_WEEKLY] = sched_date; + Save_Get(event_save_common).weekly_event.type = mEv_EVENT_KABU_PEDDLER; + flag = 1; + } + break; + } + + case lbRTC_SATURDAY: { + /* Update K.K. Slider's data */ + if (today_date.raw != sched_date) { + sched_date = today_date.raw; + event_dates[mEv_SAVE_DATE_WEEKLY] = sched_date; + Save_Get(event_save_common).weekly_event.type = mEv_EVENT_KK_SLIDER; + flag = 1; + } + break; + } + + default: { + monday_date = after_n_day(today_date.raw, lbRTC_MONDAY - rtc_time->weekday); + friday_date = after_n_day(today_date.raw, lbRTC_FRIDAY - rtc_time->weekday); + + /* Check if we should reschedule Gulliver */ + if (sched_date == 0 || check_date_range(sched_date, monday_date, friday_date) == FALSE) { + u8 ofs = 1 + (today_date.raw + rtc_time->hour) % 5; + /* Schedule a new date for the event between Monday & Friday */ + sched_date = after_n_day(today_date.raw, ofs - rtc_time->weekday); + event_dates[mEv_SAVE_DATE_WEEKLY] = sched_date; + Save_Get(event_save_common).weekly_event.type = mEv_EVENT_DOZAEMON; // Gulliver + Save_Get(event_save_common).dozaemon_completed = FALSE; + } + + /* Check if Guillver should spawn today */ + if (sched_date == today_date.raw) { + flag = mEv_EVENT_DOZAEMON; + } + + break; + } } - case lbRTC_SATURDAY: - { - /* Update K.K. Slider's data */ - if (today_date.raw != sched_date) { - sched_date = today_date.raw; - event_dates[mEv_SAVE_DATE_WEEKLY] = sched_date; - Save_Get(event_save_common).weekly_event.type = mEv_EVENT_KK_SLIDER; - flag = 1; - } - break; + /* Check if we should schedule Tortimer's 3rd bridge event */ + if (rtc_time->weekday == lbRTC_SATURDAY || (rtc_time->weekday != lbRTC_SUNDAY && sched_date != today_date.raw)) { + /* Gulliver wasn't scheduled today, so check the criteria is met */ + if (Common_Get(player_no) != mPr_FOREIGNER && Save_Get(now_npc_max) >= ANIMAL_NUM_MAX && + Save_Get(bridge).exists != TRUE && mSC_LightHouse_travel_check() == FALSE) { + flag = mEv_EVENT_SONCHO_BRIDGE_MAKE; + } + + /* Update bridge location seed and date */ + if (flag == mEv_EVENT_SONCHO_BRIDGE_MAKE && Save_Get(event_save_common).bridge_day != today_date.raw) { + Save_Get(event_save_common).bridge_day = today_date.raw; + Save_Get(event_save_common).bridge_flags.raw++; + } } - default: - { - monday_date = after_n_day(today_date.raw, lbRTC_MONDAY - rtc_time->weekday); - friday_date = after_n_day(today_date.raw, lbRTC_FRIDAY - rtc_time->weekday); - - /* Check if we should reschedule Gulliver */ - if (sched_date == 0 || check_date_range(sched_date, monday_date, friday_date) == FALSE) { - u8 ofs = 1 + (today_date.raw + rtc_time->hour) % 5; - /* Schedule a new date for the event between Monday & Friday */ - sched_date = after_n_day(today_date.raw, ofs - rtc_time->weekday); - event_dates[mEv_SAVE_DATE_WEEKLY] = sched_date; - Save_Get(event_save_common).weekly_event.type = mEv_EVENT_DOZAEMON; // Gulliver - Save_Get(event_save_common).dozaemon_completed = FALSE; - } - - /* Check if Guillver should spawn today */ - if (sched_date == today_date.raw) { - flag = mEv_EVENT_DOZAEMON; - } - - break; - } - } - - /* Check if we should schedule Tortimer's 3rd bridge event */ - if (rtc_time->weekday == lbRTC_SATURDAY || (rtc_time->weekday != lbRTC_SUNDAY && sched_date != today_date.raw)) { - /* Gulliver wasn't scheduled today, so check the criteria is met */ - if ( - Common_Get(player_no) != mPr_FOREIGNER && - Save_Get(now_npc_max) >= ANIMAL_NUM_MAX && - Save_Get(bridge).exists != TRUE && - mSC_LightHouse_travel_check() == FALSE - ) { - flag = mEv_EVENT_SONCHO_BRIDGE_MAKE; + /* Check if Blanca should spawn */ + if (flag != mEv_EVENT_DOZAEMON && flag != mEv_EVENT_SONCHO_BRIDGE_MAKE && + (mGH_check_birth2() || mMC_check_birth())) { + flag = mEv_EVENT_MASK_NPC; } - /* Update bridge location seed and date */ - if (flag == mEv_EVENT_SONCHO_BRIDGE_MAKE && Save_Get(event_save_common).bridge_day != today_date.raw) { - Save_Get(event_save_common).bridge_day = today_date.raw; - Save_Get(event_save_common).bridge_flags.raw++; + /* Initialize Wisp */ + Save_Get(event_save_common).weekly_event.flags = flag; + Save_Get(event_save_common).ghost_event_type = mEv_EVENT_NUM; // Wisp is not set to spawn + ghost_date = Save_Get(event_save_common).ghost_day; + monday_date = after_n_day(today_date.raw, -lbRTC_WEEK); + friday_date = after_n_day(today_date.raw, 4); + + /* Check if we should refresh Wisp's spawn date */ + if (ghost_date == 0 || check_date_range(ghost_date, monday_date, friday_date) == FALSE) { + ghost_date = after_n_day(today_date.raw, 2 + RANDOM(3)); + Save_Get(event_save_common).ghost_day = ghost_date; } - } - /* Check if Blanca should spawn */ - if ( - flag != mEv_EVENT_DOZAEMON && - flag != mEv_EVENT_SONCHO_BRIDGE_MAKE && - (mGH_check_birth2() || mMC_check_birth()) - ) { - flag = mEv_EVENT_MASK_NPC; - } - - /* Initialize Wisp */ - Save_Get(event_save_common).weekly_event.flags = flag; - Save_Get(event_save_common).ghost_event_type = mEv_EVENT_NUM; // Wisp is not set to spawn - ghost_date = Save_Get(event_save_common).ghost_day; - monday_date = after_n_day(today_date.raw, -lbRTC_WEEK); - friday_date = after_n_day(today_date.raw, 4); - - /* Check if we should refresh Wisp's spawn date */ - if (ghost_date == 0 || check_date_range(ghost_date, monday_date, friday_date) == FALSE) { - ghost_date = after_n_day(today_date.raw, 2 + RANDOM(3)); - Save_Get(event_save_common).ghost_day = ghost_date; - } - - /* Spawn Wisp if his scheduled appearance date is within [today-7, today] */ - if (check_date_range(ghost_date, monday_date, today_date.raw)) { - Save_Get(event_save_common).ghost_event_type = mEv_EVENT_GHOST; - } + /* Spawn Wisp if his scheduled appearance date is within [today-7, today] */ + if (check_date_range(ghost_date, monday_date, today_date.raw)) { + Save_Get(event_save_common).ghost_event_type = mEv_EVENT_GHOST; + } } static void update_soncho_event(mEv_schedule_c* sched) { - switch (sched->type) { - case mEv_EVENT_SONCHO_VACATION_JANUARY: - case mEv_EVENT_SONCHO_VACATION_FEBRUARY: - { - if (mSC_LightHouse_Event_Start() == FALSE) { - sched->date[1].raw = 0; - sched->date[0].raw = 0; - } + switch (sched->type) { + case mEv_EVENT_SONCHO_VACATION_JANUARY: + case mEv_EVENT_SONCHO_VACATION_FEBRUARY: { + if (mSC_LightHouse_Event_Start() == FALSE) { + sched->date[1].raw = 0; + sched->date[0].raw = 0; + } - break; + break; + } + + case mEv_EVENT_SONCHO_FISHING_TOURNEY_1: { + if (Save_Get(event_save_common).soncho_event_type != 0xFF) { + sched->date[1].raw = 0; + sched->date[0].raw = 0; + } + + break; + } + + case mEv_EVENT_SONCHO_FISHING_TOURNEY_2: { + if (Save_Get(event_save_common).soncho_event_type != 0xFF) { + sched->date[1].raw = 0; + sched->date[0].raw = 0; + } + + break; + } } - - case mEv_EVENT_SONCHO_FISHING_TOURNEY_1: - { - if (Save_Get(event_save_common).soncho_event_type != 0xFF) { - sched->date[1].raw = 0; - sched->date[0].raw = 0; - } - - break; - } - - case mEv_EVENT_SONCHO_FISHING_TOURNEY_2: - { - if (Save_Get(event_save_common).soncho_event_type != 0xFF) { - sched->date[1].raw = 0; - sched->date[0].raw = 0; - } - - break; - } - } } static void update_soncho_event2(mEv_schedule_c* sched) { - switch (sched->type) { - case mEv_EVENT_SONCHO_VACATION_JANUARY: - case mEv_EVENT_SONCHO_VACATION_FEBRUARY: - case mEv_EVENT_SONCHO_NEW_YEARS_DAY: - case mEv_EVENT_SONCHO_GROUNDHOG_DAY: - case mEv_EVENT_SONCHO_SPRING_SPORTS_FAIR: - case mEv_EVENT_SONCHO_APRILFOOLS_DAY: - case mEv_EVENT_SONCHO_CHERRY_BLOSSOM_FESTIVAL: - case mEv_EVENT_SONCHO_NATURE_DAY: - case mEv_EVENT_SONCHO_SPRING_CLEANING: - case mEv_EVENT_SONCHO_MOTHERS_DAY: - case mEv_EVENT_SONCHO_GRADUATION_DAY: - case mEv_EVENT_SONCHO_FATHERS_DAY: - case mEv_EVENT_SONCHO_FISHING_TOURNEY_1: - case mEv_EVENT_SONCHO_TOWN_DAY: - case mEv_EVENT_SONCHO_FIREWORKS_SHOW: - case mEv_EVENT_SONCHO_METEOR_SHOWER: - case mEv_EVENT_SONCHO_FOUNDERS_DAY: - case mEv_EVENT_SONCHO_LABOR_DAY: - case mEv_EVENT_SONCHO_FALL_SPORTS_FAIR: - case mEv_EVENT_SONCHO_HARVEST_MOON_FESTIVAL: - case mEv_EVENT_SONCHO_EXPLORERS_DAY: - case mEv_EVENT_SONCHO_HALLOWEEN: - case mEv_EVENT_SONCHO_MAYORS_DAY: - case mEv_EVENT_SONCHO_OFFICERS_DAY: - case mEv_EVENT_SONCHO_FISHING_TOURNEY_2: - case mEv_EVENT_SONCHO_HARVEST_FESTIVAL: - case mEv_EVENT_SONCHO_SALE_DAY: - case mEv_EVENT_SONCHO_SNOW_DAY: - case mEv_EVENT_SONCHO_TOY_DAY: - case mEv_EVENT_TALK_NEW_YEARS_COUNTDOWN: - { - if (Save_Get(event_save_common).weekly_event.flags == mEv_EVENT_SONCHO_BRIDGE_MAKE) { - Save_Get(event_save_common).weekly_event.flags = 0; - } + switch (sched->type) { + case mEv_EVENT_SONCHO_VACATION_JANUARY: + case mEv_EVENT_SONCHO_VACATION_FEBRUARY: + case mEv_EVENT_SONCHO_NEW_YEARS_DAY: + case mEv_EVENT_SONCHO_GROUNDHOG_DAY: + case mEv_EVENT_SONCHO_SPRING_SPORTS_FAIR: + case mEv_EVENT_SONCHO_APRILFOOLS_DAY: + case mEv_EVENT_SONCHO_CHERRY_BLOSSOM_FESTIVAL: + case mEv_EVENT_SONCHO_NATURE_DAY: + case mEv_EVENT_SONCHO_SPRING_CLEANING: + case mEv_EVENT_SONCHO_MOTHERS_DAY: + case mEv_EVENT_SONCHO_GRADUATION_DAY: + case mEv_EVENT_SONCHO_FATHERS_DAY: + case mEv_EVENT_SONCHO_FISHING_TOURNEY_1: + case mEv_EVENT_SONCHO_TOWN_DAY: + case mEv_EVENT_SONCHO_FIREWORKS_SHOW: + case mEv_EVENT_SONCHO_METEOR_SHOWER: + case mEv_EVENT_SONCHO_FOUNDERS_DAY: + case mEv_EVENT_SONCHO_LABOR_DAY: + case mEv_EVENT_SONCHO_FALL_SPORTS_FAIR: + case mEv_EVENT_SONCHO_HARVEST_MOON_FESTIVAL: + case mEv_EVENT_SONCHO_EXPLORERS_DAY: + case mEv_EVENT_SONCHO_HALLOWEEN: + case mEv_EVENT_SONCHO_MAYORS_DAY: + case mEv_EVENT_SONCHO_OFFICERS_DAY: + case mEv_EVENT_SONCHO_FISHING_TOURNEY_2: + case mEv_EVENT_SONCHO_HARVEST_FESTIVAL: + case mEv_EVENT_SONCHO_SALE_DAY: + case mEv_EVENT_SONCHO_SNOW_DAY: + case mEv_EVENT_SONCHO_TOY_DAY: + case mEv_EVENT_TALK_NEW_YEARS_COUNTDOWN: { + if (Save_Get(event_save_common).weekly_event.flags == mEv_EVENT_SONCHO_BRIDGE_MAKE) { + Save_Get(event_save_common).weekly_event.flags = 0; + } - break; + break; + } } - } - /* Update the event type to prefer these events over the fishing tourney event if they coincide */ - switch (sched->type) { - case mEv_EVENT_SONCHO_FATHERS_DAY: - case mEv_EVENT_SONCHO_OFFICERS_DAY: - Save_Get(event_save_common).soncho_event_type = sched->type; - break; - } + /* Update the event type to prefer these events over the fishing tourney event if they coincide */ + switch (sched->type) { + case mEv_EVENT_SONCHO_FATHERS_DAY: + case mEv_EVENT_SONCHO_OFFICERS_DAY: + Save_Get(event_save_common).soncho_event_type = sched->type; + break; + } } static void update_sports_fair(mEv_schedule_c* sched, lbRTC_day_t* equinox_day) { - lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); + lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); - switch (sched->type) { - case mEv_EVENT_SPRING_EQUINOX: - case mEv_EVENT_SONCHO_SPRING_SPORTS_FAIR: - { - if ( - rtc_time->month != lbRTC_MARCH || - rtc_time->day != lbRk_VernalEquinoxDay(rtc_time->year) - ) { - sched->date[1].raw = 0; - sched->date[0].raw = 0; - } - else { - sched->date[0].d.day = rtc_time->day; - sched->date[1].d.day = rtc_time->day; - *equinox_day = rtc_time->day; - } + switch (sched->type) { + case mEv_EVENT_SPRING_EQUINOX: + case mEv_EVENT_SONCHO_SPRING_SPORTS_FAIR: { + if (rtc_time->month != lbRTC_MARCH || rtc_time->day != lbRk_VernalEquinoxDay(rtc_time->year)) { + sched->date[1].raw = 0; + sched->date[0].raw = 0; + } else { + sched->date[0].d.day = rtc_time->day; + sched->date[1].d.day = rtc_time->day; + *equinox_day = rtc_time->day; + } - break; + break; + } + + case mEv_EVENT_RUMOR_SPRING_SPORTS_FAIR: { + int vernal_day = lbRk_VernalEquinoxDay(rtc_time->year); + + sched->date[0].d.day = vernal_day - 10; + sched->date[1].d.day = vernal_day - 1; + break; + } + + case mEv_EVENT_AUTUMN_EQUINOX: + case mEv_EVENT_SONCHO_FALL_SPORTS_FAIR: { + if (rtc_time->month != lbRTC_SEPTEMBER || rtc_time->day != lbRk_AutumnalEquinoxDay(rtc_time->year)) { + sched->date[1].raw = 0; + sched->date[0].raw = 0; + } else { + sched->date[0].d.day = rtc_time->day; + sched->date[1].d.day = rtc_time->day; + *equinox_day = rtc_time->day; + } + + break; + } + + case mEv_EVENT_RUMOR_FALL_SPORTS_FAIR: { + int autumnal_day = lbRk_AutumnalEquinoxDay(rtc_time->year); + + sched->date[0].d.day = autumnal_day - 10; + sched->date[1].d.day = autumnal_day - 1; + break; + } + + case mEv_EVENT_SPORTS_FAIR_BALL_TOSS: + case mEv_EVENT_SPORTS_FAIR_AEROBICS: + case mEv_EVENT_SPORTS_FAIR_TUG_OF_WAR: + case mEv_EVENT_SPORTS_FAIR_FOOT_RACE: + case mEv_EVENT_SPORTS_FAIR: + case mEv_EVENT_WEATHER_SPORTS_FAIR: { + if (*equinox_day == 0) { + sched->date[1].raw = 0; + sched->date[0].raw = 0; + } else { + sched->date[0].d.day = *equinox_day; + sched->date[1].d.day = *equinox_day; + } + + break; + } } - - case mEv_EVENT_RUMOR_SPRING_SPORTS_FAIR: - { - int vernal_day = lbRk_VernalEquinoxDay(rtc_time->year); - - sched->date[0].d.day = vernal_day - 10; - sched->date[1].d.day = vernal_day - 1; - break; - } - - case mEv_EVENT_AUTUMN_EQUINOX: - case mEv_EVENT_SONCHO_FALL_SPORTS_FAIR: - { - if ( - rtc_time->month != lbRTC_SEPTEMBER || - rtc_time->day != lbRk_AutumnalEquinoxDay(rtc_time->year) - ) { - sched->date[1].raw = 0; - sched->date[0].raw = 0; - } - else { - sched->date[0].d.day = rtc_time->day; - sched->date[1].d.day = rtc_time->day; - *equinox_day = rtc_time->day; - } - - break; - } - - case mEv_EVENT_RUMOR_FALL_SPORTS_FAIR: - { - int autumnal_day = lbRk_AutumnalEquinoxDay(rtc_time->year); - - sched->date[0].d.day = autumnal_day - 10; - sched->date[1].d.day = autumnal_day - 1; - break; - } - - case mEv_EVENT_SPORTS_FAIR_BALL_TOSS: - case mEv_EVENT_SPORTS_FAIR_AEROBICS: - case mEv_EVENT_SPORTS_FAIR_TUG_OF_WAR: - case mEv_EVENT_SPORTS_FAIR_FOOT_RACE: - case mEv_EVENT_SPORTS_FAIR: - case mEv_EVENT_WEATHER_SPORTS_FAIR: - { - if (*equinox_day == 0) { - sched->date[1].raw = 0; - sched->date[0].raw = 0; - } - else { - sched->date[0].d.day = *equinox_day; - sched->date[1].d.day = *equinox_day; - } - - break; - } - } } static void update_event_rumor(mEv_schedule_c* sched) { - lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); - int equinox_day; + lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); + int equinox_day; - switch (sched->type) { - case mEv_EVENT_RUMOR_SPRING_SPORTS_FAIR: - { - equinox_day = lbRk_VernalEquinoxDay(rtc_time->year); - sched->date[0].d.day = equinox_day - 10; - sched->date[1].d.day = equinox_day - 1; - break; + switch (sched->type) { + case mEv_EVENT_RUMOR_SPRING_SPORTS_FAIR: { + equinox_day = lbRk_VernalEquinoxDay(rtc_time->year); + sched->date[0].d.day = equinox_day - 10; + sched->date[1].d.day = equinox_day - 1; + break; + } + + case mEv_EVENT_TALK_FISHING_TOURNEY_1: + sched->date[1].d.day = + lbRTC_Weekly_day(rtc_time->year, lbRTC_JUNE, mEv_SCHEDULE_LAST_WEEKDAY_OF_MONTH, lbRTC_SUNDAY); + break; + + case mEv_EVENT_RUMOR_HARVEST_MOON_DAY: { + lbRTC_ymd_c harvest_moon_ymd; + lbRTC_time_c harvest_moon_day; + lbRTC_day_t beg_day; + lbRTC_month_t beg_month; + lbRTC_day_t end_day; + lbRTC_month_t end_month; + + lbRk_HarvestMoonDay(&harvest_moon_ymd, rtc_time->year); + harvest_moon_day.year = harvest_moon_ymd.year; + harvest_moon_day.month = harvest_moon_ymd.month; + harvest_moon_day.day = harvest_moon_ymd.day; + + /* Calculate rumor end date */ + lbRTC_Sub_DD(&harvest_moon_day, 1); + end_month = harvest_moon_day.month; + end_day = harvest_moon_day.day; + + /* Calculate rumor start date */ + lbRTC_Sub_DD(&harvest_moon_day, lbRTC_WEEK - 1); + + beg_month = harvest_moon_day.month; + beg_day = harvest_moon_day.day; + sched->date[0].d.month = beg_month; + sched->date[0].d.day = beg_day; + sched->date[1].d.month = end_month; + sched->date[1].d.day = end_day; + break; + } + + case mEv_EVENT_RUMOR_FALL_SPORTS_FAIR: { + equinox_day = lbRk_AutumnalEquinoxDay(rtc_time->year); + sched->date[0].d.day = equinox_day - 10; + sched->date[1].d.day = equinox_day - 1; + break; + } + + case mEv_EVENT_TALK_FISHING_TOURNEY_2: + sched->date[1].d.day = + lbRTC_Weekly_day(rtc_time->year, lbRTC_NOVEMBER, mEv_SCHEDULE_LAST_WEEKDAY_OF_MONTH, lbRTC_SUNDAY); + break; + + case mEv_EVENT_RUMOR_HARVEST_FESTIVAL: + sched->date[1].d.day = + lbRTC_Weekly_day(rtc_time->year, lbRTC_NOVEMBER, 4, lbRTC_THURSDAY) - 1; // 4th Thursday in November + break; } - - case mEv_EVENT_TALK_FISHING_TOURNEY_1: - sched->date[1].d.day = lbRTC_Weekly_day(rtc_time->year, lbRTC_JUNE, mEv_SCHEDULE_LAST_WEEKDAY_OF_MONTH, lbRTC_SUNDAY); - break; - - case mEv_EVENT_RUMOR_HARVEST_MOON_DAY: - { - lbRTC_ymd_c harvest_moon_ymd; - lbRTC_time_c harvest_moon_day; - lbRTC_day_t beg_day; - lbRTC_month_t beg_month; - lbRTC_day_t end_day; - lbRTC_month_t end_month; - - lbRk_HarvestMoonDay(&harvest_moon_ymd, rtc_time->year); - harvest_moon_day.year = harvest_moon_ymd.year; - harvest_moon_day.month = harvest_moon_ymd.month; - harvest_moon_day.day = harvest_moon_ymd.day; - - /* Calculate rumor end date */ - lbRTC_Sub_DD(&harvest_moon_day, 1); - end_month = harvest_moon_day.month; - end_day = harvest_moon_day.day; - - /* Calculate rumor start date */ - lbRTC_Sub_DD(&harvest_moon_day, lbRTC_WEEK - 1); - - beg_month = harvest_moon_day.month; - beg_day = harvest_moon_day.day; - sched->date[0].d.month = beg_month; - sched->date[0].d.day = beg_day; - sched->date[1].d.month = end_month; - sched->date[1].d.day = end_day; - break; - } - - case mEv_EVENT_RUMOR_FALL_SPORTS_FAIR: - { - equinox_day = lbRk_AutumnalEquinoxDay(rtc_time->year); - sched->date[0].d.day = equinox_day - 10; - sched->date[1].d.day = equinox_day - 1; - break; - } - - case mEv_EVENT_TALK_FISHING_TOURNEY_2: - sched->date[1].d.day = lbRTC_Weekly_day(rtc_time->year, lbRTC_NOVEMBER, mEv_SCHEDULE_LAST_WEEKDAY_OF_MONTH, lbRTC_SUNDAY); - break; - - case mEv_EVENT_RUMOR_HARVEST_FESTIVAL: - sched->date[1].d.day = lbRTC_Weekly_day(rtc_time->year, lbRTC_NOVEMBER, 4, lbRTC_THURSDAY) - 1; // 4th Thursday in November - break; - } } static void update_weekly_event(mEv_schedule_c* sched) { - s16 type = Save_Get(event_save_common).weekly_event.type; + s16 type = Save_Get(event_save_common).weekly_event.type; - switch (sched->type) { - case mEv_EVENT_KK_SLIDER: - case mEv_EVENT_KABU_PEDDLER: - { - if (type != sched->type) { - sched->date[1].raw = 0; - sched->date[0].raw = 0; - } + switch (sched->type) { + case mEv_EVENT_KK_SLIDER: + case mEv_EVENT_KABU_PEDDLER: { + if (type != sched->type) { + sched->date[1].raw = 0; + sched->date[0].raw = 0; + } - break; + break; + } + + case mEv_EVENT_DOZAEMON: { + if (Save_Get(event_save_common).weekly_event.flags == mEv_EVENT_SONCHO_BRIDGE_MAKE || type != sched->type) { + sched->date[1].raw = 0; + sched->date[0].raw = 0; + } + + break; + } + + case mEv_EVENT_SONCHO_BRIDGE_MAKE: + case mEv_EVENT_MASK_NPC: { + if (Save_Get(event_save_common).weekly_event.flags != sched->type) { + sched->date[1].raw = 0; + sched->date[0].raw = 0; + } + + break; + } + + case mEv_EVENT_BRIDGE_MAKE: { + if (Save_Get(bridge).pending != TRUE || Save_Get(bridge).exists || mEv_bridge_time_check() == lbRTC_OVER) { + sched->date[1].raw = 0; + sched->date[0].raw = 0; + } + + break; + } + + case mEv_EVENT_GHOST: { + if (Save_Get(event_save_common).ghost_event_type != mEv_EVENT_GHOST) { + sched->date[1].raw = 0; + sched->date[0].raw = 0; + } + + break; + } } - - case mEv_EVENT_DOZAEMON: - { - if (Save_Get(event_save_common).weekly_event.flags == mEv_EVENT_SONCHO_BRIDGE_MAKE || type != sched->type) { - sched->date[1].raw = 0; - sched->date[0].raw = 0; - } - - break; - } - - case mEv_EVENT_SONCHO_BRIDGE_MAKE: - case mEv_EVENT_MASK_NPC: - { - if (Save_Get(event_save_common).weekly_event.flags != sched->type) { - sched->date[1].raw = 0; - sched->date[0].raw = 0; - } - - break; - } - - case mEv_EVENT_BRIDGE_MAKE: - { - if (Save_Get(bridge).pending != TRUE || Save_Get(bridge).exists || mEv_bridge_time_check() == lbRTC_OVER) { - sched->date[1].raw = 0; - sched->date[0].raw = 0; - } - - break; - } - - case mEv_EVENT_GHOST: - { - if (Save_Get(event_save_common).ghost_event_type != mEv_EVENT_GHOST) { - sched->date[1].raw = 0; - sched->date[0].raw = 0; - } - - break; - } - } } // forward declarations @@ -1573,20 +1475,20 @@ static int clear_active(int type); static int set_active(int type); static void update_active(Event_c* event) { - mEv_place_data_c* place_data; + mEv_place_data_c* place_data; mEv_event_today_c* today_event; int hour = Common_Get(time.rtc_time.hour); int i; /* Update active events */ for (i = 0; i < mEv_TODAY_EVENT_NUM; i++) { - today_event = &event_today[i]; + today_event = &event_today[i]; if (today_event->type != -1 && index_today[today_event->type] != 0xFF) { if (mEv_check_status(today_event->type, mEv_STATUS_ERROR) != FALSE) { continue; } - + if (today_event->type == mEv_EVENT_SPORTS_FAIR && Common_Get(event_common).fieldday_event_over_status != today_event->type) { if (clear_active(today_event->type)) { @@ -1602,19 +1504,15 @@ static void update_active(Event_c* event) { } today_event->active_hours &= ~mEv_EVENT_HOUR_START_EVENT; - } - else if ( - today_event->type >= mEv_EVENT_ARTIST && today_event->type <= mEv_EVENT_CARPET_PEDDLER && - today_event->type == Save_Get(event_save_common).delete_event_id - ) { + } else if (today_event->type >= mEv_EVENT_ARTIST && today_event->type <= mEv_EVENT_CARPET_PEDDLER && + today_event->type == Save_Get(event_save_common).delete_event_id) { if (clear_active(today_event->type)) { event->changed_num++; } Save_Get(event_save_common).delete_event_id = 0; today_event->active_hours = mEv_EVENT_HOUR_CLEAR_EVENT; - } - else if ((today_event->active_hours & (1 << hour))) { + } else if ((today_event->active_hours & (1 << hour))) { if (Common_Get(event_common).fieldday_event_over_status != -1 && (today_event->type == mEv_EVENT_SPORTS_FAIR_BALL_TOSS || today_event->type == mEv_EVENT_SPORTS_FAIR_TUG_OF_WAR || @@ -1627,18 +1525,15 @@ static void update_active(Event_c* event) { } if (today_event->type != 0 && today_event->type == Common_Get(event_common).too_short) { today_event->active_hours |= mEv_EVENT_HOUR_TOO_SHORT_EVENT; - } - else if (set_active(today_event->type)) { + } else if (set_active(today_event->type)) { event->changed_num++; } - } - else { + } else { place_data = mEv_get_common_place(today_event->type, 81); if (today_event->type != 0 && today_event->type == Common_Get(event_common).too_short) { Common_Get(event_common).too_short = 0; - } - else if (place_data != NULL) { + } else if (place_data != NULL) { if (place_data->block.x != event->block_x || place_data->block.z != event->block_z) { if (clear_active(today_event->type)) { event->changed_num++; @@ -1649,7 +1544,7 @@ static void update_active(Event_c* event) { event->changed_num++; } } - } + } } if ((today_event->active_hours & mEv_EVENT_HOUR_CLEAR_EVENT) && @@ -1668,370 +1563,360 @@ static void update_active(Event_c* event) { } static u32 decode_date(u32 d) { - mEv_schedule_date_u date; - mEv_save_common_data_c* ev_common = Save_GetPointer(event_save_common); - lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); - int month; - int day; - int hour; + mEv_schedule_date_u date; + mEv_save_common_data_c* ev_common = Save_GetPointer(event_save_common); + lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); + int month; + int day; + int hour; - date.raw = d; + date.raw = d; - /* Process month */ - month = date.d.month; - if ((month & mEv_SCHEDULE_USE_SAVE_MONTH)) { - date.md = Save_Get(event_save_common).dates[month & 0xF]; - } - else if ((month & mEv_SCHEDULE_NOW_MONTH)) { - date.d.month = rtc_time->month; - } - else if ((month & mEv_SCHEDULE_HARVEST_MOON_DATE)) { - lbRTC_ymd_c harvest_moon_ymd; + /* Process month */ + month = date.d.month; + if ((month & mEv_SCHEDULE_USE_SAVE_MONTH)) { + date.md = Save_Get(event_save_common).dates[month & 0xF]; + } else if ((month & mEv_SCHEDULE_NOW_MONTH)) { + date.d.month = rtc_time->month; + } else if ((month & mEv_SCHEDULE_HARVEST_MOON_DATE)) { + lbRTC_ymd_c harvest_moon_ymd; - lbRk_HarvestMoonDay(&harvest_moon_ymd, rtc_time->year); - date.d.month = harvest_moon_ymd.month; - date.d.day = harvest_moon_ymd.day; - } - - /* Process day */ - day = date.d.day; - if ((day & mEv_SCHEDULE_WEEKLY)) { - date.d.day = m_weekday2day(date.d.month, day & ~mEv_SCHEDULE_DAY_AFTER); - - if ((day & mEv_SCHEDULE_DAY_AFTER)) { - date.md = after_n_day(date.md, 1); + lbRk_HarvestMoonDay(&harvest_moon_ymd, rtc_time->year); + date.d.month = harvest_moon_ymd.month; + date.d.day = harvest_moon_ymd.day; } - } - else if ((day & mEv_SCHEDULE_LAST_DAY_OF_MONTH)) { - date.d.day = last_day_of_month(date.d.month); - } - else if ((day & mEv_SCHEDULE_TOWN_DAY)) { - date.d.day = (date.d.day & ~mEv_SCHEDULE_TOWN_DAY) | Save_Get(town_day); - } - /* Process hour */ - hour = date.d.hour; - if ((hour & mEv_SCHEDULE_USE_SAVE_SLOT_VALUE)) { - date.d.hour = Save_Get(event_save_common).dates[(hour & 0x1F) % 8] | (hour & 0xC0); - } + /* Process day */ + day = date.d.day; + if ((day & mEv_SCHEDULE_WEEKLY)) { + date.d.day = m_weekday2day(date.d.month, day & ~mEv_SCHEDULE_DAY_AFTER); - return date.raw; + if ((day & mEv_SCHEDULE_DAY_AFTER)) { + date.md = after_n_day(date.md, 1); + } + } else if ((day & mEv_SCHEDULE_LAST_DAY_OF_MONTH)) { + date.d.day = last_day_of_month(date.d.month); + } else if ((day & mEv_SCHEDULE_TOWN_DAY)) { + date.d.day = (date.d.day & ~mEv_SCHEDULE_TOWN_DAY) | Save_Get(town_day); + } + + /* Process hour */ + hour = date.d.hour; + if ((hour & mEv_SCHEDULE_USE_SAVE_SLOT_VALUE)) { + date.d.hour = Save_Get(event_save_common).dates[(hour & 0x1F) % 8] | (hour & 0xC0); + } + + return date.raw; } static int set_one_time_active(int event) { - u8 idx = index_today[event]; + u8 idx = index_today[event]; - if (idx != 0xFF) { - mEv_event_today_c* ev_today = &event_today[idx]; - ev_today->active_hours |= mEv_EVENT_HOUR_START_EVENT; - return TRUE; - } + if (idx != 0xFF) { + mEv_event_today_c* ev_today = &event_today[idx]; + ev_today->active_hours |= mEv_EVENT_HOUR_START_EVENT; + return TRUE; + } - return FALSE; + return FALSE; } static int first_enter_check() { - switch (Common_Get(last_scene_no)) { - case SCENE_START_DEMO: - case SCENE_START_DEMO2: - case SCENE_PLAYERSELECT: - case SCENE_PLAYERSELECT_2: - case SCENE_PLAYERSELECT_3: - case SCENE_PLAYERSELECT_SAVE: - case SCENE_START_DEMO3: - return TRUE; + switch (Common_Get(last_scene_no)) { + case SCENE_START_DEMO: + case SCENE_START_DEMO2: + case SCENE_PLAYERSELECT: + case SCENE_PLAYERSELECT_2: + case SCENE_PLAYERSELECT_3: + case SCENE_PLAYERSELECT_SAVE: + case SCENE_START_DEMO3: + return TRUE; - default: - return FALSE; - } + default: + return FALSE; + } } static int effective_scene() { - switch (Save_Get(scene_no)) { - case SCENE_START_DEMO: - case SCENE_START_DEMO2: - case SCENE_PLAYERSELECT: - case SCENE_PLAYERSELECT_2: - case SCENE_PLAYERSELECT_3: - case SCENE_PLAYERSELECT_SAVE: - case SCENE_START_DEMO3: - return FALSE; + switch (Save_Get(scene_no)) { + case SCENE_START_DEMO: + case SCENE_START_DEMO2: + case SCENE_PLAYERSELECT: + case SCENE_PLAYERSELECT_2: + case SCENE_PLAYERSELECT_3: + case SCENE_PLAYERSELECT_SAVE: + case SCENE_START_DEMO3: + return FALSE; - default: - return TRUE; - } + default: + return TRUE; + } } static void update_schedule_today(Event_c* event) { - 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[Common_Get(player_no)]); - int i; - int type; + 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; + if (mEv_ArbeitPlayer_kari(Common_Get(player_no)) == FALSE) { + month = rtc_time->month; - today_date.d.month = month; - today_date.d.day = rtc_time->day; - today_date.d.hour = rtc_time->hour; - today_date.d._2 = 0; - Save_Get(event_save_common).dates[mEv_SAVE_DATE_TODAY] = today_date.md; + today_date.d.month = month; + today_date.d.day = rtc_time->day; + today_date.d.hour = rtc_time->hour; + today_date.d._2 = 0; + Save_Get(event_save_common).dates[mEv_SAVE_DATE_TODAY] = today_date.md; - birthday_date.month = priv->birthday.month; - birthday_date.day = priv->birthday.day; - Save_Get(event_save_common).dates[mEv_SAVE_DATE_BIRTHDAY] = birthday_date.raw; + birthday_date.month = priv->birthday.month; + birthday_date.day = priv->birthday.day; + Save_Get(event_save_common).dates[mEv_SAVE_DATE_BIRTHDAY] = birthday_date.raw; - Save_Get(event_save_common).soncho_event_type = 0xFF; + Save_Get(event_save_common).soncho_event_type = 0xFF; - /* Process every event */ - for (i = 0; i < ARRAY_COUNT(event_schedule_data); i++) { - memcpy(sched_p, &event_schedule_data[i], sizeof(mEv_schedule_c)); - - /* Perform necessary adjustments */ - update_soncho_event(sched_p); - update_sports_fair(sched_p, &equinox_day); - update_event_rumor(sched_p); - update_special_event(sched_p); - update_weekly_event(sched_p); + /* Process every event */ + for (i = 0; i < ARRAY_COUNT(event_schedule_data); i++) { + memcpy(sched_p, &event_schedule_data[i], sizeof(mEv_schedule_c)); - if (sched.type == mEv_EVENT_SUMMER_CAMPER) { - mEv_MonthDay_u camper_date; + /* Perform necessary adjustments */ + update_soncho_event(sched_p); + update_sports_fair(sched_p, &equinox_day); + update_event_rumor(sched_p); + update_special_event(sched_p); + update_weekly_event(sched_p); - switch (month) { - case lbRTC_JUNE: - case lbRTC_JULY: - case lbRTC_AUGUST: - sched.date[0].d.month = today_date.d.month; - break; + if (sched.type == mEv_EVENT_SUMMER_CAMPER) { + mEv_MonthDay_u camper_date; + + switch (month) { + case lbRTC_JUNE: + case lbRTC_JULY: + case lbRTC_AUGUST: + sched.date[0].d.month = today_date.d.month; + break; + } + + sched.date[0].raw = decode_date(sched.date[0].raw); + camper_date.month = sched.date[0].d.month; + camper_date.day = sched.date[0].d.day; + + /* Move back to the previous week if processing on Sunday */ + if (rtc_time->weekday == lbRTC_SUNDAY) { + camper_date.raw = after_n_day(camper_date.raw, -lbRTC_WEEK); + sched.date[0].d.month = camper_date.month; + sched.date[0].d.day = camper_date.day; + } + + /* Summer campers only stick around for one day */ + camper_date.raw = after_n_day(camper_date.raw, 1); + sched.date[1].d.month = camper_date.month; + sched.date[1].d.day = camper_date.day; + } else { + sched.date[0].raw = decode_date(sched.date[0].raw); + sched.date[1].raw = decode_date(sched.date[1].raw); + } + + /* Check & add event if it is currently active */ + if (check_date_range(today_date.md, sched.date[0].md, sched.date[1].md)) { + update_soncho_event2(sched_p); + add_event_today(today_date.md, sched_p); + } } - sched.date[0].raw = decode_date(sched.date[0].raw); - camper_date.month = sched.date[0].d.month; - camper_date.day = sched.date[0].d.day; - - /* Move back to the previous week if processing on Sunday */ - if (rtc_time->weekday == lbRTC_SUNDAY) { - camper_date.raw = after_n_day(camper_date.raw, -lbRTC_WEEK); - sched.date[0].d.month = camper_date.month; - sched.date[0].d.day = camper_date.day; + type = 0; + switch (Common_Get(last_scene_no)) { + case SCENE_KAMAKURA: + type = mEv_EVENT_KAMAKURA; + break; + case SCENE_BROKER_SHOP: + type = mEv_EVENT_BROKER_SALE; + break; + case SCENE_BUGGY: + type = mEv_EVENT_GYPSY; + break; + case SCENE_SHOP0: + case SCENE_CONVENI: + case SCENE_SUPER: + case SCENE_DEPART: + case SCENE_DEPART_2: + if (mEv_CheckEvent(mEv_SPNPC_EVENT)) { + type = mEv_EVENT_SHOP_SALE; + } + break; + case SCENE_TENT: + type = mEv_EVENT_SUMMER_CAMPER; + break; } - /* Summer campers only stick around for one day */ - camper_date.raw = after_n_day(camper_date.raw, 1); - sched.date[1].d.month = camper_date.month; - sched.date[1].d.day = camper_date.day; - } - else { - sched.date[0].raw = decode_date(sched.date[0].raw); - sched.date[1].raw = decode_date(sched.date[1].raw); - } + if (type != 0 && gamePT->frame_counter == 0) { + mEv_schedule_c new_ev_sched = { { + { 100, 0, 0, 23 }, + { 100, 0, 0, 0 }, + }, + 0, + 0 }; - /* Check & add event if it is currently active */ - if (check_date_range(today_date.md, sched.date[0].md, sched.date[1].md)) { - update_soncho_event2(sched_p); - add_event_today(today_date.md, sched_p); - } - } - - type = 0; - switch (Common_Get(last_scene_no)) { - case SCENE_KAMAKURA: - type = mEv_EVENT_KAMAKURA; - break; - case SCENE_BROKER_SHOP: - type = mEv_EVENT_BROKER_SALE; - break; - case SCENE_BUGGY: - type = mEv_EVENT_GYPSY; - break; - case SCENE_SHOP0: - case SCENE_CONVENI: - case SCENE_SUPER: - case SCENE_DEPART: - case SCENE_DEPART_2: - if (mEv_CheckEvent(mEv_SPNPC_EVENT)) { - type = mEv_EVENT_SHOP_SALE; + new_ev_sched.type = type; + new_ev_sched.date[1].d.month = rtc_time->month; + new_ev_sched.date[0].d.month = rtc_time->month; + new_ev_sched.date[1].d.day = rtc_time->day; + new_ev_sched.date[0].d.day = rtc_time->day; + add_event_today(today_date.md, &new_ev_sched); + set_one_time_active(type); } - break; - case SCENE_TENT: - type = mEv_EVENT_SUMMER_CAMPER; - break; - } - if (type != 0 && gamePT->frame_counter == 0) { - mEv_schedule_c new_ev_sched = { - { - { 100, 0, 0, 23 }, - { 100, 0, 0, 0 }, - }, - 0, - 0 - }; - - new_ev_sched.type = type; - new_ev_sched.date[1].d.month = rtc_time->month; - new_ev_sched.date[0].d.month = rtc_time->month; - new_ev_sched.date[1].d.day = rtc_time->day; - new_ev_sched.date[0].d.day = rtc_time->day; - add_event_today(today_date.md, &new_ev_sched); - set_one_time_active(type); - } - - type = 0; - switch (Save_Get(scene_no)) { - case SCENE_KAMAKURA: - type = mEv_EVENT_KAMAKURA; - break; - case SCENE_BROKER_SHOP: - type = mEv_EVENT_BROKER_SALE; - break; - case SCENE_BUGGY: - type = mEv_EVENT_GYPSY; - break; - case SCENE_SHOP0: - case SCENE_CONVENI: - case SCENE_SUPER: - case SCENE_DEPART: - case SCENE_DEPART_2: - if (mEv_CheckEvent(mEv_SPNPC_EVENT)) { - type = mEv_EVENT_SHOP_SALE; + type = 0; + switch (Save_Get(scene_no)) { + case SCENE_KAMAKURA: + type = mEv_EVENT_KAMAKURA; + break; + case SCENE_BROKER_SHOP: + type = mEv_EVENT_BROKER_SALE; + break; + case SCENE_BUGGY: + type = mEv_EVENT_GYPSY; + break; + case SCENE_SHOP0: + case SCENE_CONVENI: + case SCENE_SUPER: + case SCENE_DEPART: + case SCENE_DEPART_2: + if (mEv_CheckEvent(mEv_SPNPC_EVENT)) { + type = mEv_EVENT_SHOP_SALE; + } + break; + case SCENE_TENT: + type = mEv_EVENT_SUMMER_CAMPER; + break; } - break; - case SCENE_TENT: - type = mEv_EVENT_SUMMER_CAMPER; - break; - } - if (type != 0) { - mEv_schedule_c new_ev_sched = { - { - { 100, 0, 0, 23 }, - { 100, 0, 0, 0 }, - }, - 0, - 0 - }; + if (type != 0) { + mEv_schedule_c new_ev_sched = { { + { 100, 0, 0, 23 }, + { 100, 0, 0, 0 }, + }, + 0, + 0 }; - new_ev_sched.type = type; - new_ev_sched.date[1].d.month = rtc_time->month; - new_ev_sched.date[0].d.month = rtc_time->month; - new_ev_sched.date[1].d.day = rtc_time->day; - new_ev_sched.date[0].d.day = rtc_time->day; - add_event_today(today_date.md, &new_ev_sched); - } + new_ev_sched.type = type; + new_ev_sched.date[1].d.month = rtc_time->month; + new_ev_sched.date[0].d.month = rtc_time->month; + new_ev_sched.date[1].d.day = rtc_time->day; + new_ev_sched.date[0].d.day = rtc_time->day; + add_event_today(today_date.md, &new_ev_sched); + } - if (first_enter_check()) { - for (i = 0; i < mEv_EVENT_NUM; i++) { - delete_too_short_event(event, i, today_date.raw); - } - } + if (first_enter_check()) { + for (i = 0; i < mEv_EVENT_NUM; i++) { + delete_too_short_event(event, i, today_date.raw); + } + } - for (i = 0; i < mEv_EVENT_NUM; i++) { - check_and_clear_event_today(event, i); + for (i = 0; i < mEv_EVENT_NUM; i++) { + check_and_clear_event_today(event, i); + } } - } } static void calc_start_block(int* bx, int* bz) { - if (Common_Get(door_data).next_scene_id == 0) { - *bx = 3; - *bz = 2; + if (Common_Get(door_data).next_scene_id == 0) { + *bx = 3; + *bz = 2; - if (Common_Get(clip).demo_clip != NULL && Common_Get(clip).demo_clip->type == mDemo_CLIP_TYPE_RIDE_OFF_DEMO) { - *bz = 1; + if (Common_Get(clip).demo_clip != NULL && Common_Get(clip).demo_clip->type == mDemo_CLIP_TYPE_RIDE_OFF_DEMO) { + *bz = 1; + } + } else if (Common_Get(door_data).next_scene_id == SCENE_RANDOM_NPC_TEST) { + *bx = Common_Get(door_data).exit_position.x / mFI_BK_WORLDSIZE_X; + *bz = Common_Get(door_data).exit_position.z / mFI_BK_WORLDSIZE_Z; } - } - else if (Common_Get(door_data).next_scene_id == SCENE_RANDOM_NPC_TEST) { - *bx = Common_Get(door_data).exit_position.x / mFI_BK_WORLDSIZE_X; - *bz = Common_Get(door_data).exit_position.z / mFI_BK_WORLDSIZE_Z; - } } static void init_event(Event_c* event, int renewal_flag) { - event->month = 99; - event->day = 99; - event->hour = 99; - event->state = 0; - event->_02 = 0; - event->changed_num = 0; - event->block_z = 0; - event->block_x = 0; + event->month = 99; + event->day = 99; + event->hour = 99; + event->state = 0; + event->_02 = 0; + event->changed_num = 0; + event->block_z = 0; + event->block_x = 0; - calc_start_block(&event->block_x, &event->block_z); - funeral = FALSE; - dead = FALSE; - init_today_event(); + calc_start_block(&event->block_x, &event->block_z); + funeral = FALSE; + dead = FALSE; + init_today_event(); - if (renewal_flag != mEv_INIT_NO_RENEWAL) { - mEv_RenewalDataEveryDay(); - init_weekday1st(); - - if (init_special_event(FALSE)) { - Save_Get(event_save_common).special_event.flags = 1; + if (renewal_flag != mEv_INIT_NO_RENEWAL) { + mEv_RenewalDataEveryDay(); + init_weekday1st(); + + if (init_special_event(FALSE)) { + Save_Get(event_save_common).special_event.flags = 1; + } + + init_weekly_event(); + + if (mEv_LivePlayer(Common_Get(player_no)) && mEv_LiveSonchoPresent() == FALSE) { + update_schedule_today(event); + event->month = Common_Get(time.rtc_time.month); + event->day = Common_Get(time.rtc_time.day); + event->hour = Common_Get(time.rtc_time.hour); + update_active(event); + update_save_area(); + } } - - init_weekly_event(); - - if (mEv_LivePlayer(Common_Get(player_no)) && mEv_LiveSonchoPresent() == FALSE) { - update_schedule_today(event); - event->month = Common_Get(time.rtc_time.month); - event->day = Common_Get(time.rtc_time.day); - event->hour = Common_Get(time.rtc_time.hour); - update_active(event); - update_save_area(); - } - } } extern void mEv_init(Event_c* event) { - int renewal_flag = mEv_INIT_NO_RENEWAL; + int renewal_flag = mEv_INIT_NO_RENEWAL; - if (mEv_CheckTitleDemo() == 0 && effective_scene()) { - renewal_flag = mEv_INIT_RENEWAL; - } + if (mEv_CheckTitleDemo() == 0 && effective_scene()) { + renewal_flag = mEv_INIT_RENEWAL; + } - init_event(event, renewal_flag); + init_event(event, renewal_flag); } extern void mEv_init_force(Event_c* event) { - int renewal_flag = mEv_INIT_NO_RENEWAL; + int renewal_flag = mEv_INIT_NO_RENEWAL; - if (mEv_CheckTitleDemo() == 0) { - renewal_flag = mEv_INIT_FORCE_RENEWAL; - } + if (mEv_CheckTitleDemo() == 0) { + renewal_flag = mEv_INIT_FORCE_RENEWAL; + } - init_event(event, renewal_flag); + init_event(event, renewal_flag); } 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) { - u8 index = index_today[mEv_EVENT_MORNING_AEROBICS]; + /* Disable morning aerobics if it is scheduled and the weather is rain */ + if (Common_Get(weather) == mEnv_WEATHER_RAIN) { + u8 index = index_today[mEv_EVENT_MORNING_AEROBICS]; - if (index != 0xFF) { - 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; + if (index != 0xFF) { + 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; + } } - } } extern int mEv_PlayerOK() { - int res = FALSE; + int res = FALSE; - if (mPlib_able_player_warp_forEvent() && mPlib_Get_unable_wade() == FALSE) { - res = TRUE; - } + if (mPlib_able_player_warp_forEvent() && mPlib_Get_unable_wade() == FALSE) { + res = TRUE; + } - return res; + return res; } extern void mEv_run(Event_c* event) { @@ -2091,301 +1976,297 @@ extern void mEv_run(Event_c* event) { } } -static mActor_name_t l_ev_structure_table[] = { - BROKER_TENT, - FORTUNE_TENT, - DESIGNER_CAR, - KAMAKURA, - SAKURA_TABLE0, - AEROBICS_RADIO, - FIREWORKS_STALL0, - FIREWORKS_STALL1, - NEWYEAR_SHRINE0, - NEWYEAR_SHRINE1, - NEWYEAR_TABLE, - NEWYEAR_COUNTDOWN0, - NEWYEAR_COUNTDOWN1, - SPORTSFAIR_BALLS_RED, - SPORTSFAIR_BALLS_WHITE, - SPORTSFAIR_BASKET_RED, - SPORTSFAIR_BASKET_WHITE, - FISHCHECK_STAND0, - FISHCHECK_STAND1, - GHOG, - TENT, - SAKURA_TABLE1 -}; +static mActor_name_t l_ev_structure_table[] = { BROKER_TENT, + FORTUNE_TENT, + DESIGNER_CAR, + KAMAKURA, + SAKURA_TABLE0, + AEROBICS_RADIO, + FIREWORKS_STALL0, + FIREWORKS_STALL1, + NEWYEAR_SHRINE0, + NEWYEAR_SHRINE1, + NEWYEAR_TABLE, + NEWYEAR_COUNTDOWN0, + NEWYEAR_COUNTDOWN1, + SPORTSFAIR_BALLS_RED, + SPORTSFAIR_BALLS_WHITE, + SPORTSFAIR_BASKET_RED, + SPORTSFAIR_BASKET_WHITE, + FISHCHECK_STAND0, + FISHCHECK_STAND1, + GHOG, + TENT, + SAKURA_TABLE1 }; static int num_of_l_ev_structure = ARRAY_COUNT(l_ev_structure_table); extern void mEv_finish(Event_c* event) { - int ut_x; - int ut_z; - int bx; - int bz; - int i; - int bx_max = mFI_GetBlockXMax() - 1; - int bz_max = mFI_GetBlockZMax() - 1; + int ut_x; + int ut_z; + int bx; + int bz; + int i; + int bx_max = mFI_GetBlockXMax() - 1; + int bz_max = mFI_GetBlockZMax() - 1; - if (mFI_GET_TYPE(mFI_GetFieldId()) == mFI_FIELD_FG) { + if (mFI_GET_TYPE(mFI_GetFieldId()) == mFI_FIELD_FG) { - for (i = 0; i < num_of_l_ev_structure; i++) { - for (bx = 1; bx < bx_max; bx++) { - for (bz = 1; bz < bz_max; bz++) { - int ut; - mActor_name_t structure = l_ev_structure_table[i]; - - for (ut = 0; mFI_SearchFGInBlock(&ut_x, &ut_z, structure, bx, bz); ut) { - mFI_SetFGStructure_common(structure, bx, bz, ut_x, ut_z, mFI_SET_STRUCTURE_REMOVE); - ut++; - if (ut > UT_TOTAL_NUM) { - break; + for (i = 0; i < num_of_l_ev_structure; i++) { + for (bx = 1; bx < bx_max; bx++) { + for (bz = 1; bz < bz_max; bz++) { + int ut; + mActor_name_t structure = l_ev_structure_table[i]; + + for (ut = 0; mFI_SearchFGInBlock(&ut_x, &ut_z, structure, bx, bz); ut) { + mFI_SetFGStructure_common(structure, bx, bz, ut_x, ut_z, mFI_SET_STRUCTURE_REMOVE); + ut++; + if (ut > UT_TOTAL_NUM) { + break; + } + } + } } - } } - } } - } } extern int mEv_check_schedule(int event) { - int hour = Common_Get(time.rtc_time.hour); - u8 index = index_today[event]; - mEv_event_today_c* ev_today = &event_today[index]; + int hour = Common_Get(time.rtc_time.hour); + u8 index = index_today[event]; + mEv_event_today_c* ev_today = &event_today[index]; + + if (index == 0xFF) { + return FALSE; + } + + if ((ev_today->status & mEv_STATUS_STOP)) { + return FALSE; + } + + if ((ev_today->active_hours & mEv_EVENT_HOUR_TOO_SHORT_EVENT)) { + return FALSE; + } + + if ((ev_today->active_hours & (1 << hour)) != 0) { + return TRUE; + } - if (index == 0xFF) { return FALSE; - } - - if ((ev_today->status & mEv_STATUS_STOP)) { - return FALSE; - } - - if ((ev_today->active_hours & mEv_EVENT_HOUR_TOO_SHORT_EVENT)) { - return FALSE; - } - - if ((ev_today->active_hours & (1 << hour)) != 0) { - return TRUE; - } - - return FALSE; } extern int mEv_check_run_today(int event) { - u8 index = index_today[event]; - mEv_event_today_c* ev_today = &event_today[index]; + u8 index = index_today[event]; + mEv_event_today_c* ev_today = &event_today[index]; + + if (index == 0xFF) { + return FALSE; + } + + if ((ev_today->status & mEv_STATUS_STOP)) { + return FALSE; + } + + if (ev_today->active_hours != 0) { + return TRUE; + } - if (index == 0xFF) { return FALSE; - } - - if ((ev_today->status & mEv_STATUS_STOP)) { - return FALSE; - } - - if (ev_today->active_hours != 0) { - return TRUE; - } - - return FALSE; } extern void mEv_set_status(int event, s16 status) { - u8 index = index_today[event]; - mEv_event_today_c* ev_today = &event_today[index]; + u8 index = index_today[event]; + mEv_event_today_c* ev_today = &event_today[index]; - if (index != 0xFF) { - if (status == mEv_STATUS_ERROR) { - ev_today->status = 0; + if (index != 0xFF) { + if (status == mEv_STATUS_ERROR) { + ev_today->status = 0; + } + + status_edge |= status; + ev_today->status |= status; } - - status_edge |= status; - ev_today->status |= status; - } } static int set_active(int event) { - u8 index = index_today[event]; - mEv_event_today_c* ev_today = &event_today[index]; - int res = FALSE; + u8 index = index_today[event]; + mEv_event_today_c* ev_today = &event_today[index]; + int res = FALSE; - if (index != 0xFF) { - if ((ev_today->status & mEv_STATUS_ACTIVE) == 0) { - res = TRUE; // status updated + if (index != 0xFF) { + if ((ev_today->status & mEv_STATUS_ACTIVE) == 0) { + res = TRUE; // status updated + } + + status_edge |= mEv_STATUS_ACTIVE; + ev_today->status |= mEv_STATUS_ACTIVE; } - status_edge |= mEv_STATUS_ACTIVE; - ev_today->status |= mEv_STATUS_ACTIVE; - } - - return res; + return res; } extern void mEv_clear_status(int event, s16 status) { - u8 index = index_today[event]; - mEv_event_today_c* ev_today = &event_today[index]; + u8 index = index_today[event]; + mEv_event_today_c* ev_today = &event_today[index]; - if (index != 0xFF) { - ev_today->status &= ~status; - } + if (index != 0xFF) { + ev_today->status &= ~status; + } } static int clear_active(int event) { - u8 index = index_today[event]; - mEv_event_today_c* ev_today = &event_today[index]; - int res = FALSE; + u8 index = index_today[event]; + mEv_event_today_c* ev_today = &event_today[index]; + int res = FALSE; - if (index != 0xFF) { - if ((ev_today->status & mEv_STATUS_ACTIVE) != 0) { - res = TRUE; // status updated + if (index != 0xFF) { + if ((ev_today->status & mEv_STATUS_ACTIVE) != 0) { + res = TRUE; // status updated + } + + ev_today->status &= ~mEv_STATUS_ACTIVE; } - ev_today->status &= ~mEv_STATUS_ACTIVE; - } - - return res; + return res; } extern int mEv_check_status(int event, s16 status) { - u8 index = index_today[event]; - mEv_event_today_c* ev_today = &event_today[index]; + u8 index = index_today[event]; + mEv_event_today_c* ev_today = &event_today[index]; - if (index == 0xFF) { - return FALSE; - } + if (index == 0xFF) { + return FALSE; + } - /* Default to 'false' if the event is in an error state */ - if (status != mEv_STATUS_ERROR && (ev_today->status & mEv_STATUS_ERROR)) { - return FALSE; - } + /* Default to 'false' if the event is in an error state */ + if (status != mEv_STATUS_ERROR && (ev_today->status & mEv_STATUS_ERROR)) { + return FALSE; + } - return (ev_today->status & status) != 0; + return (ev_today->status & status) != 0; } extern int mEv_check_status_edge(s16 status) { - /* @BUG - developers almost certainly meant to use & here instead of | */ - #ifndef BUGFIXES - if ((status_edge | status) != 0) { - #else - if ((status_edge & status) != 0) { - #endif - return TRUE; - } +/* @BUG - developers almost certainly meant to use & here instead of | */ +#ifndef BUGFIXES + if ((status_edge | status) != 0) { +#else + if ((status_edge & status) != 0) { +#endif + return TRUE; + } - return FALSE; + return FALSE; } extern void mEv_set_keep(int event) { - int flags = Common_Get(event_keep_flags[event >> 5]); - flags |= (1 << (event & 0x1F)); - Common_Set(event_keep_flags[event >> 5], flags); + int flags = Common_Get(event_keep_flags[event >> 5]); + flags |= (1 << (event & 0x1F)); + Common_Set(event_keep_flags[event >> 5], flags); } extern void mEv_clear_keep(int event) { - int flags = Common_Get(event_keep_flags[event >> 5]); - flags &= ~(1 << (event & 0x1F)); - Common_Set(event_keep_flags[event >> 5], flags); + int flags = Common_Get(event_keep_flags[event >> 5]); + flags &= ~(1 << (event & 0x1F)); + Common_Set(event_keep_flags[event >> 5], flags); } extern int mEv_check_keep(int event) { - if ((Common_Get(event_keep_flags[event >> 5]) & (1 << (event & 0x1F)))) { - return TRUE; - } + if ((Common_Get(event_keep_flags[event >> 5]) & (1 << (event & 0x1F)))) { + return TRUE; + } - return FALSE; + return FALSE; } extern u8* mEv_reserve_save_area(int type, u8 id) { - lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); - int index = index_today[type]; - mEv_event_today_c* ev_today = &event_today[index]; - mEv_save_common_data_c* ev_save_common = Save_GetPointer(event_save_common); - int i; - int free_slot_idx = -1; - u8* data; - u8* ret; - int exist_slot = -1; + lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); + int index = index_today[type]; + mEv_event_today_c* ev_today = &event_today[index]; + mEv_save_common_data_c* ev_save_common = Save_GetPointer(event_save_common); + int i; + int free_slot_idx = -1; + u8* data; + u8* ret; + int exist_slot = -1; - for (i = 0; i < mEv_AREA_NUM; i++) { - if (((1 << i) & ev_save_common->area_use_bitfield) == 0) { - free_slot_idx = i; - continue; - } - else if (id != mEv_EVENT_NUM && ev_save_common->area[i].info.id == mEv_EVENT_NUM) { - exist_slot = i; - } - - if (type == ev_save_common->area[i].info.type && id == ev_save_common->area[i].info.id) { - free_slot_idx = i; - break; - } - } + for (i = 0; i < mEv_AREA_NUM; i++) { + if (((1 << i) & ev_save_common->area_use_bitfield) == 0) { + free_slot_idx = i; + continue; + } else if (id != mEv_EVENT_NUM && ev_save_common->area[i].info.id == mEv_EVENT_NUM) { + exist_slot = i; + } - if (free_slot_idx == -1 && exist_slot != -1) { - free_slot_idx = exist_slot; - } - - if (free_slot_idx != -1) { - mEv_area_c* const area = &ev_save_common->area[free_slot_idx]; - mEv_info_c* const info = &area->info; - ev_save_common->area_use_bitfield |= (1 << free_slot_idx); - ev_save_common->area[free_slot_idx].info.type = type; - ev_save_common->area[free_slot_idx].info.id = id; - - // issue seems to stem from ev_today->begin_date.month being used twice which promotes it to r11? - if ((u16)ev_today->begin_date.month > (u32)ev_today->end_date.month && (u16)ev_today->begin_date.month > (u32)rtc_time->month) { - ev_save_common->area[free_slot_idx].info.year = rtc_time->year - 1; - } - else { - ev_save_common->area[free_slot_idx].info.year = rtc_time->year; + if (type == ev_save_common->area[i].info.type && id == ev_save_common->area[i].info.id) { + free_slot_idx = i; + break; + } } - data = (u8*)ev_save_common->area[free_slot_idx].data; - ev_save_common->area[free_slot_idx].info.year = rtc_time->year; // ???? - ev_save_common->area[free_slot_idx].info.start_date.month = ev_today->begin_date.month; - ev_save_common->area[free_slot_idx].info.start_date.day = ev_today->begin_date.day; - ev_save_common->area[free_slot_idx].info.end_date.month = ev_today->end_date.month; - ev_save_common->area[free_slot_idx].info.end_date.day = ev_today->end_date.day; - memset(data, 0, sizeof(ev_save_common->area[free_slot_idx].data)); - ret = data; - } - else { - ret = NULL; - } + if (free_slot_idx == -1 && exist_slot != -1) { + free_slot_idx = exist_slot; + } - return ret; + if (free_slot_idx != -1) { + mEv_area_c* const area = &ev_save_common->area[free_slot_idx]; + mEv_info_c* const info = &area->info; + ev_save_common->area_use_bitfield |= (1 << free_slot_idx); + ev_save_common->area[free_slot_idx].info.type = type; + ev_save_common->area[free_slot_idx].info.id = id; + + // issue seems to stem from ev_today->begin_date.month being used twice which promotes it to r11? + if ((u16)ev_today->begin_date.month > (u32)ev_today->end_date.month && + (u16)ev_today->begin_date.month > (u32)rtc_time->month) { + ev_save_common->area[free_slot_idx].info.year = rtc_time->year - 1; + } else { + ev_save_common->area[free_slot_idx].info.year = rtc_time->year; + } + + data = (u8*)ev_save_common->area[free_slot_idx].data; + ev_save_common->area[free_slot_idx].info.year = rtc_time->year; // ???? + ev_save_common->area[free_slot_idx].info.start_date.month = ev_today->begin_date.month; + ev_save_common->area[free_slot_idx].info.start_date.day = ev_today->begin_date.day; + ev_save_common->area[free_slot_idx].info.end_date.month = ev_today->end_date.month; + ev_save_common->area[free_slot_idx].info.end_date.day = ev_today->end_date.day; + memset(data, 0, sizeof(ev_save_common->area[free_slot_idx].data)); + ret = data; + } else { + ret = NULL; + } + + return ret; } extern u8* mEv_get_save_area(int type, u8 id) { - mEv_save_common_data_c* ev_save_common = Save_GetPointer(event_save_common); - int i; + mEv_save_common_data_c* ev_save_common = Save_GetPointer(event_save_common); + int i; - for (i = 0; i < mEv_AREA_NUM; i++) { - if (((1 << i) & ev_save_common->area_use_bitfield) != 0) { - if (type == ev_save_common->area[i].info.type && id == ev_save_common->area[i].info.id) { - return (u8*)ev_save_common->area[i].data; - } + for (i = 0; i < mEv_AREA_NUM; i++) { + if (((1 << i) & ev_save_common->area_use_bitfield) != 0) { + if (type == ev_save_common->area[i].info.type && id == ev_save_common->area[i].info.id) { + return (u8*)ev_save_common->area[i].data; + } + } } - } - return NULL; + return NULL; } extern int mEv_clear_save_area(int type, u8 id) { - mEv_save_common_data_c* ev_save_common = Save_GetPointer(event_save_common); - int i; + mEv_save_common_data_c* ev_save_common = Save_GetPointer(event_save_common); + int i; - for (i = 0; i < mEv_AREA_NUM; i++) { - if (((1 << i) & ev_save_common->area_use_bitfield) != 0) { - if (type == ev_save_common->area[i].info.type && id == ev_save_common->area[i].info.id) { - ev_save_common->area_use_bitfield &= ~(1 << i); - return sizeof(ev_save_common->area[i].data); - } + for (i = 0; i < mEv_AREA_NUM; i++) { + if (((1 << i) & ev_save_common->area_use_bitfield) != 0) { + if (type == ev_save_common->area[i].info.type && id == ev_save_common->area[i].info.id) { + ev_save_common->area_use_bitfield &= ~(1 << i); + return sizeof(ev_save_common->area[i].data); + } + } } - } - return 0; + return 0; } static int update_save_area() { @@ -2428,413 +2309,369 @@ static int update_save_area() { } extern u8* mEv_reserve_common_area(int type, u8 id) { - mEv_common_data_c* ev_common = Common_GetPointer(event_common); - int i; - int exist_slot = -1; - u8* data; - u8* res; + mEv_common_data_c* ev_common = Common_GetPointer(event_common); + int i; + int exist_slot = -1; + u8* data; + u8* res; - for (i = 0; i < mEv_AREA_NUM; i++) { - if (((1 << i) & ev_common->area_use_bitfield) == 0) { - exist_slot = i; + for (i = 0; i < mEv_AREA_NUM; i++) { + if (((1 << i) & ev_common->area_use_bitfield) == 0) { + exist_slot = i; + } else if (type == ev_common->area[i].info.type && id == ev_common->area[i].info.id) { + exist_slot = i; + break; + } } - else if (type == ev_common->area[i].info.type && id == ev_common->area[i].info.id) { - exist_slot = i; - break; + + if (exist_slot != -1) { + ev_common->area_use_bitfield |= (1 << exist_slot); + data = (u8*)ev_common->area[exist_slot].data; + ev_common->area[exist_slot].info.type = type; + ev_common->area[exist_slot].info.id = id; + memset(data, 0, sizeof(ev_common->area[exist_slot].data)); + res = data; + } else { + res = NULL; } - } - if (exist_slot != -1) { - ev_common->area_use_bitfield |= (1 << exist_slot); - data = (u8*)ev_common->area[exist_slot].data; - ev_common->area[exist_slot].info.type = type; - ev_common->area[exist_slot].info.id = id; - memset(data, 0, sizeof(ev_common->area[exist_slot].data)); - res = data; - } - else { - res = NULL; - } - - return res; + return res; } extern u8* mEv_get_common_area(int type, u8 id) { - mEv_common_data_c* ev_common = Common_GetPointer(event_common); - int i; + mEv_common_data_c* ev_common = Common_GetPointer(event_common); + int i; - for (i = 0; i < mEv_AREA_NUM; i++) { - if (((1 << i) & ev_common->area_use_bitfield) != 0) { - if (type == ev_common->area[i].info.type && id == ev_common->area[i].info.id) { - return (u8*)ev_common->area[i].data; - } + for (i = 0; i < mEv_AREA_NUM; i++) { + if (((1 << i) & ev_common->area_use_bitfield) != 0) { + if (type == ev_common->area[i].info.type && id == ev_common->area[i].info.id) { + return (u8*)ev_common->area[i].data; + } + } } - } - return NULL; + return NULL; } extern int mEv_clear_common_area(int type, u8 id) { - mEv_common_data_c* ev_common = Common_GetPointer(event_common); - int i; + mEv_common_data_c* ev_common = Common_GetPointer(event_common); + int i; - for (i = 0; i < mEv_AREA_NUM; i++) { - if (((1 << i) & ev_common->area_use_bitfield) != 0) { - if (type == ev_common->area[i].info.type && id == ev_common->area[i].info.id) { - ev_common->area_use_bitfield &= ~(1 << i); - return sizeof(ev_common->area[i].data); - } + for (i = 0; i < mEv_AREA_NUM; i++) { + if (((1 << i) & ev_common->area_use_bitfield) != 0) { + if (type == ev_common->area[i].info.type && id == ev_common->area[i].info.id) { + ev_common->area_use_bitfield &= ~(1 << i); + return sizeof(ev_common->area[i].data); + } + } } - } - return 0; + return 0; } extern mEv_place_data_c* mEv_reserve_common_place(int type, u8 id) { - mEv_common_data_c* ev_common = Common_GetPointer(event_common); - int i; - int exist_slot = -1; - mEv_place_data_c* data; - mEv_place_data_c* res; + mEv_common_data_c* ev_common = Common_GetPointer(event_common); + int i; + int exist_slot = -1; + mEv_place_data_c* data; + mEv_place_data_c* res; - for (i = 0; i < mEv_PLACE_NUM; i++) { - if (((1 << i) & ev_common->place_use_bitfield) == 0) { - exist_slot = i; + for (i = 0; i < mEv_PLACE_NUM; i++) { + if (((1 << i) & ev_common->place_use_bitfield) == 0) { + exist_slot = i; + } else if (type == ev_common->place[i].info.type && id == ev_common->place[i].info.id) { + exist_slot = i; + break; + } } - else if (type == ev_common->place[i].info.type && id == ev_common->place[i].info.id) { - exist_slot = i; - break; + + if (exist_slot != -1) { + ev_common->place_use_bitfield |= (1 << exist_slot); + data = &ev_common->place[exist_slot].data; + ev_common->place[exist_slot].info.type = type; + ev_common->place[exist_slot].info.id = id; + memset(data, 0, sizeof(ev_common->place[exist_slot].data)); + res = data; + } else { + res = NULL; } - } - if (exist_slot != -1) { - ev_common->place_use_bitfield |= (1 << exist_slot); - data = &ev_common->place[exist_slot].data; - ev_common->place[exist_slot].info.type = type; - ev_common->place[exist_slot].info.id = id; - memset(data, 0, sizeof(ev_common->place[exist_slot].data)); - res = data; - } - else { - res = NULL; - } - - return res; + return res; } extern mEv_place_data_c* mEv_get_common_place(int type, u8 id) { - mEv_common_data_c* ev_common = Common_GetPointer(event_common); - int i; + mEv_common_data_c* ev_common = Common_GetPointer(event_common); + int i; - for (i = 0; i < mEv_PLACE_NUM; i++) { - if (((1 << i) & ev_common->place_use_bitfield) != 0) { - if (type == ev_common->place[i].info.type && id == ev_common->place[i].info.id) { - return &ev_common->place[i].data; - } + for (i = 0; i < mEv_PLACE_NUM; i++) { + if (((1 << i) & ev_common->place_use_bitfield) != 0) { + if (type == ev_common->place[i].info.type && id == ev_common->place[i].info.id) { + return &ev_common->place[i].data; + } + } } - } - return NULL; + return NULL; } extern int mEv_clear_common_place(int type, u8 id) { - mEv_common_data_c* ev_common = Common_GetPointer(event_common); - int i; + mEv_common_data_c* ev_common = Common_GetPointer(event_common); + int i; - for (i = 0; i < mEv_PLACE_NUM; i++) { - if (((1 << i) & ev_common->place_use_bitfield) != 0) { - if (type == ev_common->place[i].info.type && id == ev_common->place[i].info.id) { - ev_common->place_use_bitfield &= ~(1 << i); - return sizeof(ev_common->place[i].data); - } + for (i = 0; i < mEv_PLACE_NUM; i++) { + if (((1 << i) & ev_common->place_use_bitfield) != 0) { + if (type == ev_common->place[i].info.type && id == ev_common->place[i].info.id) { + ev_common->place_use_bitfield &= ~(1 << i); + return sizeof(ev_common->place[i].data); + } + } } - } - return 0; + return 0; } extern int mEv_use_block_by_other_event(int type, BlockOrUnit_c* block) { - mEv_common_data_c* ev_common = Common_GetPointer(event_common); - int i; + mEv_common_data_c* ev_common = Common_GetPointer(event_common); + int i; - for (i = 0; i < mEv_PLACE_NUM; i++) { - if (((1 << i) & ev_common->place_use_bitfield) != 0) { - if ( - ev_common->place[i].data.block.x == block->x && - ev_common->place[i].data.block.z == block->z && - ev_common->place[i].info.type != type - ) { - return TRUE; - } + for (i = 0; i < mEv_PLACE_NUM; i++) { + if (((1 << i) & ev_common->place_use_bitfield) != 0) { + if (ev_common->place[i].data.block.x == block->x && ev_common->place[i].data.block.z == block->z && + ev_common->place[i].info.type != type) { + return TRUE; + } + } } - } - return FALSE; + return FALSE; } extern void mEv_erase_FG_all_in_common_place() { - mEv_common_data_c* ev_common = Common_GetPointer(event_common); - int i; + mEv_common_data_c* ev_common = Common_GetPointer(event_common); + int i; - for (i = 0; i < mEv_PLACE_NUM; i++) { - if (((1 << i) & ev_common->place_use_bitfield) != 0) { - mEv_place_data_c* place_data = &ev_common->place[i].data; - - if (ITEM_NAME_GET_TYPE(place_data->actor_name) == NAME_TYPE_STRUCT) { - mFI_SetFGStructure_common( - place_data->actor_name, - place_data->block.x, - place_data->block.z, - place_data->unit.x, - place_data->unit.z, - mFI_SET_STRUCTURE_REMOVE - ); - } + for (i = 0; i < mEv_PLACE_NUM; i++) { + if (((1 << i) & ev_common->place_use_bitfield) != 0) { + mEv_place_data_c* place_data = &ev_common->place[i].data; + + if (ITEM_NAME_GET_TYPE(place_data->actor_name) == NAME_TYPE_STRUCT) { + mFI_SetFGStructure_common(place_data->actor_name, place_data->block.x, place_data->block.z, + place_data->unit.x, place_data->unit.z, mFI_SET_STRUCTURE_REMOVE); + } + } } - } } static int n_rumor = 0; static int rumor_table[40]; extern void mEv_clear_rumor() { - n_rumor = 0; + n_rumor = 0; } extern int mEv_spread_rumor(int type) { - rumor_table[n_rumor++] = type; - return n_rumor; + rumor_table[n_rumor++] = type; + return n_rumor; } extern int mEv_get_rumor() { - if (n_rumor != 0) { - return rumor_table[gamePT->frame_counter % n_rumor] | mEv_SET(mEv_TYPE3_EVENT, 0); - } + if (n_rumor != 0) { + return rumor_table[gamePT->frame_counter % n_rumor] | mEv_SET(mEv_TYPE3_EVENT, 0); + } - return 0; + return 0; } 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; - int i; + xyz_t pos = actor->world.position; + mEv_common_data_c* ev_common = Common_GetPointer(event_common); + mActor_name_t actor_name = actor->npc_id; + int i; - for (i = 0; i < mEv_PLACE_NUM; i++) { - if (((1 << i) & ev_common->place_use_bitfield) != 0) { - mEv_place_data_c* place_data = &ev_common->place[i].data; - - if ( - ev_common->place[i].info.type == type && - place_data->actor_name == actor_name - ) { - /* Check if the actor world position should be transferred to event data */ - if (place_data->flag & 1) { - mFI_Wpos2BlockNum(&place_data->block.x, &place_data->block.z, pos); - mFI_Wpos2UtNum_inBlock(&place_data->unit.x, &place_data->unit.z, pos); + for (i = 0; i < mEv_PLACE_NUM; i++) { + if (((1 << i) & ev_common->place_use_bitfield) != 0) { + mEv_place_data_c* place_data = &ev_common->place[i].data; + + if (ev_common->place[i].info.type == type && place_data->actor_name == actor_name) { + /* Check if the actor world position should be transferred to event data */ + if (place_data->flag & 1) { + mFI_Wpos2BlockNum(&place_data->block.x, &place_data->block.z, pos); + mFI_Wpos2UtNum_inBlock(&place_data->unit.x, &place_data->unit.z, pos); + } + + funeral = TRUE; + break; + } } - - funeral = TRUE; - break; - } } - } - mEv_set_status(type, mEv_STATUS_STOP); - dead = 3; + mEv_set_status(type, mEv_STATUS_STOP); + dead = 3; } extern int mEv_LiveSonchoPresent() { - if (Common_Get(demo_profiles[1]) == mAc_PROFILE_PRESENT_DEMO) { - return TRUE; - } + if (Common_Get(demo_profiles[1]) == mAc_PROFILE_PRESENT_DEMO) { + return TRUE; + } - if (Common_Get(clip).demo_clip2 != NULL && Common_Get(clip).demo_clip2->type == mDemo_CLIP_TYPE_PRESENT_DEMO) { - return TRUE; - } + if (Common_Get(clip).demo_clip2 != NULL && Common_Get(clip).demo_clip2->type == mDemo_CLIP_TYPE_PRESENT_DEMO) { + return TRUE; + } - return FALSE; + return FALSE; } extern int mEv_LivePlayer(u32 player_no) { - if (mEv_CheckTitleDemo() != 0) { - return FALSE; - } - - if (Common_Get(reset_flag) != 0) { - return FALSE; - } - - if (player_no < mPr_FOREIGNER) { - if ( - mEv_CheckEvent(mEv_SAVED_GATEWAY_PLR0 + player_no) == TRUE || - mEv_CheckEvent(mEv_SAVED_FIRSTINTRO_PLR0 + player_no) == TRUE - ) { - return FALSE; + if (mEv_CheckTitleDemo() != 0) { + return FALSE; } - } - else if (player_no < mPr_PLAYER_NUM) { - if (mEv_CheckEvent(mEv_SAVED_GATEWAY_PLR0 + player_no) == TRUE) { - return FALSE; - } - } - else { - return FALSE; - } - return TRUE; + if (Common_Get(reset_flag) != 0) { + return FALSE; + } + + if (player_no < mPr_FOREIGNER) { + if (mEv_CheckEvent(mEv_SAVED_GATEWAY_PLR0 + player_no) == TRUE || + mEv_CheckEvent(mEv_SAVED_FIRSTINTRO_PLR0 + player_no) == TRUE) { + return FALSE; + } + } else if (player_no < mPr_PLAYER_NUM) { + if (mEv_CheckEvent(mEv_SAVED_GATEWAY_PLR0 + player_no) == TRUE) { + return FALSE; + } + } else { + return FALSE; + } + + return TRUE; } extern int mEv_ArbeitPlayer_kari(u32 player_no) { - if (player_no < mPr_FOREIGNER && mEv_CheckEvent(mEv_SAVED_FIRSTJOB_PLR0 + player_no) == TRUE) { - return TRUE; - } + if (player_no < mPr_FOREIGNER && mEv_CheckEvent(mEv_SAVED_FIRSTJOB_PLR0 + player_no) == TRUE) { + return TRUE; + } - return FALSE; + return FALSE; } extern int mEv_ArbeitPlayer(u32 player_no) { - if ( - player_no < mPr_FOREIGNER && - (mEv_CheckEvent(mEv_SAVED_FIRSTJOB_PLR0 + player_no) == TRUE || - mEv_CheckEvent(mEv_SAVED_HRAWAIT_PLR0 + player_no) == TRUE) - ) { - return TRUE; - } + if (player_no < mPr_FOREIGNER && (mEv_CheckEvent(mEv_SAVED_FIRSTJOB_PLR0 + player_no) == TRUE || + mEv_CheckEvent(mEv_SAVED_HRAWAIT_PLR0 + player_no) == TRUE)) { + return TRUE; + } - return FALSE; + return FALSE; } extern void mEv_make_new_special_event() { - lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); - mEv_schedule_c sched; - mEv_schedule_date_u today_date; - mEv_schedule_c* sched_p = &sched; + lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); + mEv_schedule_c sched; + mEv_schedule_date_u today_date; + mEv_schedule_c* sched_p = &sched; - today_date.d.month = rtc_time->month; - today_date.d.day = rtc_time->day; - today_date.d._2 = 0; - today_date.d.hour = rtc_time->hour; + today_date.d.month = rtc_time->month; + today_date.d.day = rtc_time->day; + today_date.d._2 = 0; + today_date.d.hour = rtc_time->hour; - if (init_special_event(TRUE)) { - int i; + if (init_special_event(TRUE)) { + int i; - Save_Get(event_save_common).special_event.flags = 1; - for (i = 0; i < ARRAY_COUNT(event_schedule_data); i++) { - memcpy(sched_p, &event_schedule_data[i], sizeof(mEv_schedule_c)); + Save_Get(event_save_common).special_event.flags = 1; + for (i = 0; i < ARRAY_COUNT(event_schedule_data); i++) { + memcpy(sched_p, &event_schedule_data[i], sizeof(mEv_schedule_c)); - if (update_special_event(sched_p)) { - sched.date[0].raw = decode_date(sched.date[0].raw); - sched.date[1].raw = decode_date(sched.date[1].raw); + if (update_special_event(sched_p)) { + sched.date[0].raw = decode_date(sched.date[0].raw); + sched.date[1].raw = decode_date(sched.date[1].raw); - if (check_date_range(today_date.md, sched.date[0].md, sched.date[1].md)) { - add_event_today(today_date.md, sched_p); + if (check_date_range(today_date.md, sched.date[0].md, sched.date[1].md)) { + add_event_today(today_date.md, sched_p); + } + } } - } } - } } extern int mEv_GetMonth(Event_c* event) { - return event->month; + return event->month; } extern int mEv_GetDay(Event_c* event) { - return event->day; + return event->day; } extern int mEv_GetHour(Event_c* event) { - return event->hour; + return event->hour; } extern void mEv_debug_print4f(gfxprint_t* gfxprint) { - //int x = 0; - int i; - int event_idx = 0; + // 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)) { - gfxprint_color(gfxprint, 245, 200, 170, 255); - gfxprint_locate8x8(gfxprint, 3 + event_idx * 3, 5); - gfxprint_printf(gfxprint, "%3d", event_today[i].type); - event_idx++; - //x += 3; + 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)) { + gfxprint_color(gfxprint, 245, 200, 170, 255); + gfxprint_locate8x8(gfxprint, 3 + event_idx * 3, 5); + gfxprint_printf(gfxprint, "%3d", event_today[i].type); + event_idx++; + // x += 3; - if (event_idx >= 9) { - if (mEv_check_status(event_today[i].type, mEv_STATUS_ERROR) == FALSE) { - gfxprint_color(gfxprint, 245, 150, 120, 255); + if (event_idx >= 9) { + if (mEv_check_status(event_today[i].type, mEv_STATUS_ERROR) == FALSE) { + gfxprint_color(gfxprint, 245, 150, 120, 255); + } else if (mEv_check_status(event_today[i].type, mEv_STATUS_RUN)) { + gfxprint_color(gfxprint, 180, 150, 160, 255); + } else { + gfxprint_color(gfxprint, 140, 120, 120, 255); + } + + gfxprint_locate8x8(gfxprint, 9 + event_idx * 3, 5); + gfxprint_printf(gfxprint, "+"); + break; + } } - else if (mEv_check_status(event_today[i].type, mEv_STATUS_RUN)) { - gfxprint_color(gfxprint, 180, 150, 160, 255); - } - else { - gfxprint_color(gfxprint, 140, 120, 120, 255); - } - - gfxprint_locate8x8(gfxprint, 9 + event_idx * 3, 5); - gfxprint_printf(gfxprint, "+"); - break; - } - } - } } extern void mEv_sp_debug_print4f(gfxprint_t* gfxprint) { - gfxprint_color(gfxprint, 245, 200, 170, 255); - gfxprint_locate8x8(gfxprint, 3, 11); - gfxprint_printf( - gfxprint, - "%3d %02d-%02d-%02d", - Save_Get(event_save_common).special_event.type, - Save_Get(event_save_common).dates[mEv_SAVE_DATE_SPECIAL0] & 0xFF, // event rtc (current) day - Save_Get(event_save_common).dates[mEv_SAVE_DATE_SPECIAL1] & 0xFF, // event begin day - Save_Get(event_save_common).dates[mEv_SAVE_DATE_SPECIAL2] & 0xFF // event end day - ); + gfxprint_color(gfxprint, 245, 200, 170, 255); + gfxprint_locate8x8(gfxprint, 3, 11); + gfxprint_printf(gfxprint, "%3d %02d-%02d-%02d", Save_Get(event_save_common).special_event.type, + Save_Get(event_save_common).dates[mEv_SAVE_DATE_SPECIAL0] & 0xFF, // event rtc (current) day + Save_Get(event_save_common).dates[mEv_SAVE_DATE_SPECIAL1] & 0xFF, // event begin day + Save_Get(event_save_common).dates[mEv_SAVE_DATE_SPECIAL2] & 0xFF // event end day + ); - gfxprint_locate8x8(gfxprint, 30, 11); - gfxprint_printf( - gfxprint, - "%c%c%c%c%c%c%c%c", - mEv_CheckTitleDemo() ? 'T' : '.', - mEv_CheckFirstIntro() ? 'F' : '.', - mEv_CheckGateway() ? 'G' : '.', - mEv_CheckRealArbeit() ? 'R' : '.', - mEv_CheckArbeit() ? 'A' : '.', - mDemo_CheckDemo() ? 'D' : '.', - !mEv_PlayerOK() ? 'P' : '.', - !mEv_LivePlayer(Common_Get(player_no)) ? 'L' : '.' - ); + gfxprint_locate8x8(gfxprint, 30, 11); + gfxprint_printf(gfxprint, "%c%c%c%c%c%c%c%c", mEv_CheckTitleDemo() ? 'T' : '.', mEv_CheckFirstIntro() ? 'F' : '.', + mEv_CheckGateway() ? 'G' : '.', mEv_CheckRealArbeit() ? 'R' : '.', mEv_CheckArbeit() ? 'A' : '.', + mDemo_CheckDemo() ? 'D' : '.', !mEv_PlayerOK() ? 'P' : '.', + !mEv_LivePlayer(Common_Get(player_no)) ? 'L' : '.'); } extern int mEv_change(Event_c* event) { - return event->changed_num; + return event->changed_num; } extern int mEv_get_special_event_state() { - int special_events[] = { - mEv_EVENT_SHOP_SALE, - mEv_EVENT_DESIGNER, - mEv_EVENT_BROKER_SALE, - mEv_EVENT_ARTIST, - mEv_EVENT_CARPET_PEDDLER, - mEv_EVENT_GYPSY - }; + int special_events[] = { mEv_EVENT_SHOP_SALE, mEv_EVENT_DESIGNER, mEv_EVENT_BROKER_SALE, + mEv_EVENT_ARTIST, mEv_EVENT_CARPET_PEDDLER, mEv_EVENT_GYPSY }; - int active = FALSE; - int res = mEv_SPECIAL_STATE_UNSCHEDULED; - mEv_ymdh_u event_date_start; - mEv_ymdh_u today_date; - mEv_ymdh_u event_date; - mEv_ymdh_u today_date_start; - int event_type; + int active = FALSE; + int res = mEv_SPECIAL_STATE_UNSCHEDULED; + mEv_ymdh_u event_date_start; + mEv_ymdh_u today_date; + mEv_ymdh_u event_date; + mEv_ymdh_u today_date_start; + int event_type; - if (Save_Get(event_save_data).special.type <= mEv_SPNPC_END) { - event_type = special_events[Save_Get(event_save_data).special.type]; - } - else { - return FALSE; - } + if (Save_Get(event_save_data).special.type <= mEv_SPNPC_END) { + event_type = special_events[Save_Get(event_save_data).special.type]; + } else { + return FALSE; + } today_date.year = 0; today_date.month = Common_Get(time.rtc_time.month); @@ -2853,261 +2690,239 @@ extern int mEv_get_special_event_state() { event_date_start.hour = 0; if (event_type == mEv_EVENT_SHOP_SALE) { - if (event_date.raw == today_date.raw) { + if (event_date.raw == today_date.raw) { + active = TRUE; + } + } else if (mEv_check_status(event_type, mEv_STATUS_ACTIVE)) { active = TRUE; - } - } - else if (mEv_check_status(event_type, mEv_STATUS_ACTIVE)) { - active = TRUE; } if (active) { - res = mEv_SPECIAL_STATE_ACTIVE; - } - else if (check_ymdh_range(today_date.raw, event_date_start.raw, event_date.raw)) { - res = mEv_SPECIAL_STATE_SCHEDULED_TODAY; - } - else if (Save_Get(event_save_data).special.type != 0xFFFFFFFF && event_date_start.raw > today_date_start.raw) { - res = mEv_SPECIAL_STATE_SCHEDULED_LATER; + res = mEv_SPECIAL_STATE_ACTIVE; + } else if (check_ymdh_range(today_date.raw, event_date_start.raw, event_date.raw)) { + res = mEv_SPECIAL_STATE_SCHEDULED_TODAY; + } else if (Save_Get(event_save_data).special.type != 0xFFFFFFFF && event_date_start.raw > today_date_start.raw) { + res = mEv_SPECIAL_STATE_SCHEDULED_LATER; } - return res; + return res; } extern int mEv_snowman_born_check() { - mEv_ymdh_u snowman_date; - mEv_ymdh_u today_date; - mEv_ymdh_u snowman_date_end; + mEv_ymdh_u snowman_date; + mEv_ymdh_u today_date; + mEv_ymdh_u snowman_date_end; - today_date.year = Common_Get(time.rtc_time).year % 100; - today_date.month = Common_Get(time.rtc_time).month; - today_date.day = Common_Get(time.rtc_time).day; - today_date.hour = Common_Get(time.rtc_time).hour; + today_date.year = Common_Get(time.rtc_time).year % 100; + today_date.month = Common_Get(time.rtc_time).month; + today_date.day = Common_Get(time.rtc_time).day; + today_date.hour = Common_Get(time.rtc_time).hour; - snowman_date.year = Save_Get(snowman_year); - snowman_date.month = Save_Get(snowman_month); - snowman_date.day = Save_Get(snowman_day); - snowman_date.hour = Save_Get(snowman_hour); - - snowman_date_end.raw = snowman_date.raw; - snowman_date_end.hour = 5; + snowman_date.year = Save_Get(snowman_year); + snowman_date.month = Save_Get(snowman_month); + snowman_date.day = Save_Get(snowman_day); + snowman_date.hour = Save_Get(snowman_hour); - if (snowman_date.hour >= 6) { - mEv_MonthDay_u snowman_monthday; - mEv_MonthDay_u next_monthday; + snowman_date_end.raw = snowman_date.raw; + snowman_date_end.hour = 5; - snowman_monthday.month = snowman_date.month; - snowman_monthday.day = snowman_date.day; - next_monthday.raw = after_n_day(snowman_monthday.raw, 1); + if (snowman_date.hour >= 6) { + mEv_MonthDay_u snowman_monthday; + mEv_MonthDay_u next_monthday; - if (next_monthday.raw == mEv_MonthDay(lbRTC_JANUARY, 1)) { - snowman_date_end.year = (snowman_date_end.year + 1) % 100; + snowman_monthday.month = snowman_date.month; + snowman_monthday.day = snowman_date.day; + next_monthday.raw = after_n_day(snowman_monthday.raw, 1); + + if (next_monthday.raw == mEv_MonthDay(lbRTC_JANUARY, 1)) { + snowman_date_end.year = (snowman_date_end.year + 1) % 100; + } + + snowman_date_end.month = next_monthday.month; + snowman_date_end.day = next_monthday.day; } - snowman_date_end.month = next_monthday.month; - snowman_date_end.day = next_monthday.day; - } + if (check_ymdh_range(today_date.raw, snowman_date.raw, snowman_date_end.raw)) { + return FALSE; + } - if (check_ymdh_range(today_date.raw, snowman_date.raw, snowman_date_end.raw)) { - return FALSE; - } - - return TRUE; + return TRUE; } extern int mEv_someone_died() { - return dead; + return dead; } extern void mEv_special_event_soldout(int type) { - GAME_PLAY* play = (GAME_PLAY*)gamePT; - mEv_event_today_c* ev_today; - int i; + GAME_PLAY* play = (GAME_PLAY*)gamePT; + mEv_event_today_c* ev_today; + int i; - for (i = 0; i < mEv_TODAY_EVENT_NUM; i++) { - ev_today = &event_today[i]; - - if ( - ev_today->type != -1 && - index_today[ev_today->type] != 0xFF && - mEv_check_status(ev_today->type, mEv_STATUS_ERROR) == FALSE && - ev_today->type == type - ) { - if (clear_active(ev_today->type)) { - play->event.changed_num++; - } + for (i = 0; i < mEv_TODAY_EVENT_NUM; i++) { + ev_today = &event_today[i]; - ev_today->active_hours = mEv_EVENT_HOUR_CLEAR_EVENT; + if (ev_today->type != -1 && index_today[ev_today->type] != 0xFF && + mEv_check_status(ev_today->type, mEv_STATUS_ERROR) == FALSE && ev_today->type == type) { + if (clear_active(ev_today->type)) { + play->event.changed_num++; + } + + ev_today->active_hours = mEv_EVENT_HOUR_CLEAR_EVENT; + } } - } } extern void mEv_toland_clear_common() { - int* keep_flags = Common_Get(event_keep_flags); - int i; + int* keep_flags = Common_Get(event_keep_flags); + int i; - for (i = 0; i < ARRAY_COUNT(Common_Get(event_keep_flags)); i++) { - keep_flags[i] = 0; - } + for (i = 0; i < ARRAY_COUNT(Common_Get(event_keep_flags)); i++) { + keep_flags[i] = 0; + } - mem_clear(Common_GetPointer(event_common), sizeof(Common_Get(event_common)), 0); - mem_clear(Common_GetPointer(special_event_common), sizeof(Common_Get(special_event_common)), 0); + mem_clear(Common_GetPointer(event_common), sizeof(Common_Get(event_common)), 0); + mem_clear(Common_GetPointer(special_event_common), sizeof(Common_Get(special_event_common)), 0); } extern void mGH_animal_return_init() { - mem_clear(Save_GetPointer(return_animal), sizeof(Save_Get(return_animal)), 0); - Save_Get(return_animal).npc_id = EMPTY_NO; // ?? + mem_clear(Save_GetPointer(return_animal), sizeof(Save_Get(return_animal)), 0); + Save_Get(return_animal).npc_id = EMPTY_NO; // ?? } extern int mGH_check_birth2() { - lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); - Anmret_c* return_animal = Save_GetPointer(return_animal); - lbRTC_time_c time; - - if (return_animal->npc_id == EMPTY_NO) { + lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); + Anmret_c* return_animal = Save_GetPointer(return_animal); + lbRTC_time_c time; + + if (return_animal->npc_id == EMPTY_NO) { + return FALSE; + } + + /* Check that it's been less than 1 week since go home event was scheduled */ + lbRTC_TimeCopy(&time, &return_animal->renew_time); + lbRTC_Add_DD(&time, lbRTC_WEEK); + + if (lbRTC_IsEqualDate(time.year, time.month, time.day, rtc_time->year, rtc_time->month, rtc_time->day) == + lbRTC_LESS) { + return TRUE; + } + return FALSE; - } - - /* Check that it's been less than 1 week since go home event was scheduled */ - lbRTC_TimeCopy(&time, &return_animal->renew_time); - lbRTC_Add_DD(&time, lbRTC_WEEK); - - if ( - lbRTC_IsEqualDate( - time.year, time.month, time.day, - rtc_time->year, rtc_time->month, rtc_time->day - ) == lbRTC_LESS - ) { - return TRUE; - } - - return FALSE; } extern int mGH_check_birth() { - if ((Save_Get(return_animal).talk_bit & (1 << Common_Get(player_no))) != 0) { - return FALSE; - } + if ((Save_Get(return_animal).talk_bit & (1 << Common_Get(player_no))) != 0) { + return FALSE; + } - return mGH_check_birth2(); + return mGH_check_birth2(); } extern void mGH_check_delete() { - lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); - Anmret_c* return_animal = Save_GetPointer(return_animal); - Private_c* priv = Save_Get(private); + lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); + Anmret_c* return_animal = Save_GetPointer(return_animal); + Private_c* priv = Save_Get(private_data); - if (return_animal->npc_id != EMPTY_NO) { - if (Save_Get(npc_force_go_home) == TRUE) { - mGH_animal_return_init(); - } - else { - lbRTC_time_c time; + if (return_animal->npc_id != EMPTY_NO) { + if (Save_Get(npc_force_go_home) == TRUE) { + mGH_animal_return_init(); + } else { + lbRTC_time_c time; - lbRTC_TimeCopy(&time, &return_animal->renew_time); - /* Devs did this to fix a 'bug' with lbRTC_Add_DD which only allows going at most one month in the future */ - lbRTC_Add_DD(&time, 20); - lbRTC_Add_DD(&time, 20); - lbRTC_Add_DD(&time, 20); + lbRTC_TimeCopy(&time, &return_animal->renew_time); + /* Devs did this to fix a 'bug' with lbRTC_Add_DD which only allows going at most one month in the future */ + lbRTC_Add_DD(&time, 20); + lbRTC_Add_DD(&time, 20); + lbRTC_Add_DD(&time, 20); - if ( - lbRTC_IsEqualDate( - time.year, time.month, time.day, - rtc_time->year, rtc_time->month, rtc_time->day - ) != lbRTC_OVER - ) { - mGH_animal_return_init(); - } - else { - int i; + if (lbRTC_IsEqualDate(time.year, time.month, time.day, rtc_time->year, rtc_time->month, rtc_time->day) != + lbRTC_OVER) { + mGH_animal_return_init(); + } else { + int i; - if (mNpc_SearchAnimalinfo(Save_Get(animals), return_animal->npc_id, ANIMAL_NUM_MAX) != -1) { - mGH_animal_return_init(); // don't allow this animal to visit if a "version" of it lives in town + if (mNpc_SearchAnimalinfo(Save_Get(animals), return_animal->npc_id, ANIMAL_NUM_MAX) != -1) { + mGH_animal_return_init(); // don't allow this animal to visit if a "version" of it lives in town + } + + for (i = 0; i < PLAYER_NUM; i++) { + if (mPr_NullCheckPersonalID(&priv->player_ID) == FALSE && + (return_animal->talk_bit & (1 << i)) == 0) { + return; + } + + priv++; + } + + mGH_animal_return_init(); + } } - - for (i = 0; i < PLAYER_NUM; i++) { - if (mPr_NullCheckPersonalID(&priv->player_ID) == FALSE && (return_animal->talk_bit & (1 << i)) == 0) { - return; - } - - priv++; - } - - mGH_animal_return_init(); - } } - } } extern void mMC_mask_cat_init() { - MaskCat_c* mask_cat = Save_GetPointer(mask_cat); - u8 cloth_no = mask_cat->cloth_no; + MaskCat_c* mask_cat = Save_GetPointer(mask_cat); + u8 cloth_no = mask_cat->cloth_no; - mem_clear(mask_cat, sizeof(Save_Get(mask_cat)), 0); - mPr_ClearPersonalID(&mask_cat->design.creator_pid); - Save_Get(mask_cat).cloth_no = cloth_no; + mem_clear(mask_cat, sizeof(Save_Get(mask_cat)), 0); + mPr_ClearPersonalID(&mask_cat->design.creator_pid); + Save_Get(mask_cat).cloth_no = cloth_no; } extern int mMC_check_birth() { - if (Save_Get(mask_cat).design.creator_pid.player_id == 0xFFFF) { + if (Save_Get(mask_cat).design.creator_pid.player_id == 0xFFFF) { + return FALSE; + } + + if (Save_Get(mask_cat).talk_idx >= mMC_TALK_IDX_MAX) { + /* Talked more than the maximum amount of times allowed */ + mMC_mask_cat_init(); + return TRUE; + } + return FALSE; - } - - if (Save_Get(mask_cat).talk_idx >= mMC_TALK_IDX_MAX) { - /* Talked more than the maximum amount of times allowed */ - mMC_mask_cat_init(); - return TRUE; - } - - return FALSE; } extern int mMC_check_birth_day() { - switch (Common_Get(time.rtc_time.weekday)) { - case lbRTC_SUNDAY: - case lbRTC_MONDAY: - case lbRTC_WEDNESDAY: - case lbRTC_FRIDAY: - return FALSE; - - default: - return mMC_check_birth(); - } + switch (Common_Get(time.rtc_time.weekday)) { + case lbRTC_SUNDAY: + case lbRTC_MONDAY: + case lbRTC_WEDNESDAY: + case lbRTC_FRIDAY: + return FALSE; + + default: + return mMC_check_birth(); + } } extern void mMC_check_delete() { - MaskCat_c* mask_cat = Save_GetPointer(mask_cat); - lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); + MaskCat_c* mask_cat = Save_GetPointer(mask_cat); + lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); - if (mask_cat->design.creator_pid.player_id != 0xFFFF) { - lbRTC_time_c max_time; - lbRTC_time_c min_time; + if (mask_cat->design.creator_pid.player_id != 0xFFFF) { + lbRTC_time_c max_time; + lbRTC_time_c min_time; - lbRTC_TimeCopy(&max_time, &mask_cat->time); - lbRTC_TimeCopy(&min_time, &mask_cat->time); + lbRTC_TimeCopy(&max_time, &mask_cat->time); + lbRTC_TimeCopy(&min_time, &mask_cat->time); - lbRTC_Add_DD(&max_time, lbRTC_WEEK); - lbRTC_Sub_DD(&min_time, lbRTC_WEEK); + lbRTC_Add_DD(&max_time, lbRTC_WEEK); + lbRTC_Sub_DD(&min_time, lbRTC_WEEK); - if ( - mask_cat->talk_idx >= mMC_TALK_IDX_MAX || - lbRTC_IsEqualDate( - max_time.year, max_time.month, max_time.day, - rtc_time->year, rtc_time->month, rtc_time->day - ) != lbRTC_OVER || - lbRTC_IsEqualDate( - min_time.year, min_time.month, min_time.day, - rtc_time->year, rtc_time->month, rtc_time->day - ) != lbRTC_LESS - ) { - mMC_mask_cat_init(); + if (mask_cat->talk_idx >= mMC_TALK_IDX_MAX || + lbRTC_IsEqualDate(max_time.year, max_time.month, max_time.day, rtc_time->year, rtc_time->month, + rtc_time->day) != lbRTC_OVER || + lbRTC_IsEqualDate(min_time.year, min_time.month, min_time.day, rtc_time->year, rtc_time->month, + rtc_time->day) != lbRTC_LESS) { + mMC_mask_cat_init(); + } } - } } extern void mMC_set_time() { - MaskCat_c* mask_cat = Save_GetPointer(mask_cat); - lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); + MaskCat_c* mask_cat = Save_GetPointer(mask_cat); + lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); - lbRTC_TimeCopy(&mask_cat->time, rtc_time); + lbRTC_TimeCopy(&mask_cat->time, rtc_time); } diff --git a/src/m_home.c b/src/m_home.c index 047af196..5572b6ae 100644 --- a/src/m_home.c +++ b/src/m_home.c @@ -15,504 +15,582 @@ /* upstairs room base unit layout */ static mActor_name_t l_player_room_2_utinfo[UT_X_NUM * UT_Z_NUM] = { - RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - DOOR0, RSV_WALL_NO, RSV_WALL_NO, RSV_DOOR, RSV_DOOR, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_DOOR, RSV_DOOR, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - EMPTY_NO, EMPTY_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO + RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, DOOR0, RSV_WALL_NO, RSV_WALL_NO, RSV_DOOR, RSV_DOOR, + RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_DOOR, RSV_DOOR, RSV_WALL_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO }; /* basement room base unit layout */ static mActor_name_t l_player_room_bm_utinfo[UT_X_NUM * UT_Z_NUM] = { - RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_DOOR, RSV_DOOR, RSV_WALL_NO, RSV_WALL_NO, DOOR0, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, RSV_DOOR, RSV_DOOR, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO + RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, + RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_DOOR, RSV_DOOR, RSV_WALL_NO, RSV_WALL_NO, DOOR0, + RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, RSV_WALL_NO, RSV_DOOR, RSV_DOOR, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, + RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO }; /* small main room base unit layout */ static mActor_name_t l_proom_s_tmp[UT_X_NUM * UT_Z_NUM] = { - RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - RSV_WALL_NO, RSV_WALL_NO, RSV_DOOR, RSV_DOOR, RSV_WALL_NO, RSV_WALL_NO, DOOR0, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - EMPTY_NO, RSV_WALL_NO, RSV_DOOR, RSV_DOOR, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - EMPTY_NO, RSV_WALL_NO, EXIT_DOOR, EXIT_DOOR, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - EMPTY_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO + RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, RSV_WALL_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, + RSV_WALL_NO, RSV_DOOR, RSV_DOOR, RSV_WALL_NO, RSV_WALL_NO, DOOR0, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, RSV_DOOR, + RSV_DOOR, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EXIT_DOOR, EXIT_DOOR, RSV_WALL_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO }; /* medium main room base unit layout */ static mActor_name_t l_proom_m_tmp[UT_X_NUM * UT_Z_NUM] = { - RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_DOOR, RSV_DOOR, RSV_WALL_NO, RSV_WALL_NO, DOOR0, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_DOOR, RSV_DOOR, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EXIT_DOOR, EXIT_DOOR, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - EMPTY_NO, EMPTY_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO + RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_DOOR, RSV_DOOR, + RSV_WALL_NO, RSV_WALL_NO, DOOR0, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_DOOR, RSV_DOOR, RSV_WALL_NO, RSV_WALL_NO, + RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EXIT_DOOR, EXIT_DOOR, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO }; /* large main room base unit layout */ static mActor_name_t l_proom_l_tmp[UT_X_NUM * UT_Z_NUM] = { - RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - RSV_WALL_NO, DOOR1, RSV_WALL_NO, RSV_WALL_NO, RSV_DOOR, RSV_DOOR, RSV_WALL_NO, RSV_WALL_NO, DOOR0, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_DOOR, RSV_DOOR, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EXIT_DOOR, EXIT_DOOR, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO + RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, + RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + RSV_WALL_NO, DOOR1, RSV_WALL_NO, RSV_WALL_NO, RSV_DOOR, RSV_DOOR, RSV_WALL_NO, RSV_WALL_NO, DOOR0, + RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, RSV_WALL_NO, + RSV_WALL_NO, RSV_WALL_NO, RSV_DOOR, RSV_DOOR, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, + EXIT_DOOR, EXIT_DOOR, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, + RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO }; /* island cottage base unit layout */ static mActor_name_t l_proom_cottage_tmp[UT_X_NUM * UT_Z_NUM] = { - RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_DOOR, RSV_DOOR, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EXIT_DOOR, EXIT_DOOR, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, - EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO + RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, + RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, RSV_DOOR, RSV_DOOR, RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, + RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, RSV_WALL_NO, EXIT_DOOR, EXIT_DOOR, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, RSV_WALL_NO, + RSV_WALL_NO, RSV_WALL_NO, RSV_WALL_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO, + EMPTY_NO, EMPTY_NO, EMPTY_NO, EMPTY_NO }; #define HANIWA_MSG_LINES 4 // TODO: fix me - /** * @brief Clears the save data for a given home. - * + * * @param home_no Index of the home which will be cleared (0-3). **/ extern void mHm_ClearHomeInfo(int home_no) { - static int haniwa_msg[HANIWA_MSG_LINES] = { 0x76A, 0x76B, 0x76C, 0x76D }; /* These are probably defines somewhere from auto-gen */ + static int haniwa_msg[HANIWA_MSG_LINES] = { 0x76A, 0x76B, 0x76C, + 0x76D }; /* These are probably defines somewhere from auto-gen */ - int no; - mHm_hs_c* home; - u8 haniwa_msg_buf[HANIWA_MESSAGE_LEN]; - u16* item_p; - u16* src_p; - int i; - u8* haniwa_msg_p; - int j; + int no; + mHm_hs_c* home; + u8 haniwa_msg_buf[HANIWA_MESSAGE_LEN]; + u16* item_p; + u16* src_p; + int i; + u8* haniwa_msg_p; + int j; - no = home_no & 3; - home = Save_GetPointer(homes[no]); - bzero(home, sizeof(mHm_hs_c)); - mPr_ClearPersonalID(&home->ownerID); - bcopy(l_proom_s_tmp, home->floors[mHm_ROOM_MAIN].layer_main.items, (UT_X_NUM * UT_Z_NUM) * sizeof(u16)); - home->floors[mHm_ROOM_MAIN].layer_main.ftr_switch = 0; - *((u32*)&home->floors[mHm_ROOM_MAIN].layer_main.ftr_switch + 1) = 0; /* ftr_switch might be a union? */ - *((u32*)&home->floors[mHm_ROOM_MAIN].layer_main.ftr_switch + 0) = 0; + no = home_no & 3; + home = Save_GetPointer(homes[no]); + bzero(home, sizeof(mHm_hs_c)); + mPr_ClearPersonalID(&home->ownerID); + bcopy(l_proom_s_tmp, home->floors[mHm_ROOM_MAIN].layer_main.items, (UT_X_NUM * UT_Z_NUM) * sizeof(u16)); + home->floors[mHm_ROOM_MAIN].layer_main.ftr_switch = 0; + *((u32*)&home->floors[mHm_ROOM_MAIN].layer_main.ftr_switch + 1) = 0; /* ftr_switch might be a union? */ + *((u32*)&home->floors[mHm_ROOM_MAIN].layer_main.ftr_switch + 0) = 0; - item_p = (u16*)home->floors[mHm_ROOM_BASEMENT].layer_main.items; - src_p = l_player_room_bm_utinfo; - for (i = 0; i < UT_X_NUM * UT_Z_NUM; i++) { - *item_p++ = *src_p++; - } + item_p = (u16*)home->floors[mHm_ROOM_BASEMENT].layer_main.items; + src_p = l_player_room_bm_utinfo; + for (i = 0; i < UT_X_NUM * UT_Z_NUM; i++) { + *item_p++ = *src_p++; + } - item_p = ((u16*)home->floors[mHm_ROOM_UPPER].layer_main.items); - src_p = l_player_room_2_utinfo; - for (i = 0; i < UT_X_NUM * UT_Z_NUM; i++) { - *item_p++ = *src_p++; - } + item_p = ((u16*)home->floors[mHm_ROOM_UPPER].layer_main.items); + src_p = l_player_room_2_utinfo; + for (i = 0; i < UT_X_NUM * UT_Z_NUM; i++) { + *item_p++ = *src_p++; + } - mMl_clear_mail_box(home->mailbox, HOME_MAILBOX_SIZE); - Save_Set(homes[no].outlook_pal, no); - Save_Set(homes[no].next_outlook_pal, no); - mCkRh_InitGokiSaveData_1Room_ByHomeData(home); - mHm_SetDefaultPlayerRoomData(no); + mMl_clear_mail_box(home->mailbox, HOME_MAILBOX_SIZE); + Save_Set(homes[no].outlook_pal, no); + Save_Set(homes[no].next_outlook_pal, no); + mCkRh_InitGokiSaveData_1Room_ByHomeData(home); + mHm_SetDefaultPlayerRoomData(no); - haniwa_msg_p = home->haniwa.message; - for (j = 0; j < HANIWA_MSG_LINES; j++) { - int len; + haniwa_msg_p = home->haniwa.message; + for (j = 0; j < HANIWA_MSG_LINES; j++) { + int len; - mString_Load_StringFromRom(haniwa_msg_buf, HANIWA_MESSAGE_LEN, haniwa_msg[j]); - len = mMl_strlen(haniwa_msg_buf, HANIWA_MESSAGE_LEN, CHAR_SPACE); - haniwa_msg_buf[len] = CHAR_NEW_LINE; - mem_copy(haniwa_msg_p, haniwa_msg_buf, len + 1); - haniwa_msg_p += len + 1; - } + mString_Load_StringFromRom(haniwa_msg_buf, HANIWA_MESSAGE_LEN, haniwa_msg[j]); + len = mMl_strlen(haniwa_msg_buf, HANIWA_MESSAGE_LEN, CHAR_SPACE); + haniwa_msg_buf[len] = CHAR_NEW_LINE; + mem_copy(haniwa_msg_p, haniwa_msg_buf, len + 1); + haniwa_msg_p += len + 1; + } - Save_Set(keep_house_size[no], 0); - Save_Set(homes[no].door_original, 0xFF); + Save_Set(keep_house_size[no], 0); + Save_Set(homes[no].door_original, 0xFF); } /** * @brief Clears save data for all homes. **/ extern void mHm_ClearAllHomeInfo() { - int i; + int i; - for (i = 0; i < PLAYER_NUM; i++) { - mHm_ClearHomeInfo(i); - } + for (i = 0; i < PLAYER_NUM; i++) { + mHm_ClearHomeInfo(i); + } } /** * @brief Sets common_data's 'now_home' pointer to the current player's home. **/ extern void mHm_SetNowHome() { - mHm_hs_c* now_home = NULL; + mHm_hs_c* now_home = NULL; - if (Common_Get(player_no) < PLAYER_NUM) { - now_home = Save_GetPointer(homes[mHS_get_arrange_idx(Common_Get(player_no))]); - } + if (Common_Get(player_no) < PLAYER_NUM) { + now_home = Save_GetPointer(homes[mHS_get_arrange_idx(Common_Get(player_no))]); + } - Common_Set(now_home, now_home); + Common_Set(now_home, now_home); } /* sizeof(mHm_player_room_default_data_c) == 0x10 */ typedef struct { - /* 0x00 */ u8 wall_num; - /* 0x01 */ u8 floor_num; - /* 0x04 */ int item_ut_x; - /* 0x08 */ int item_ut_z; - /* 0x0C */ mActor_name_t item; + /* 0x00 */ u8 wall_num; + /* 0x01 */ u8 floor_num; + /* 0x04 */ int item_ut_x; + /* 0x08 */ int item_ut_z; + /* 0x0C */ mActor_name_t item; } mHm_player_room_default_data_c; /* list of default properties for each house */ static mHm_player_room_default_data_c l_mHm_player_room_default_data[PLAYER_NUM] = { - { 3, 38, 4, 1, FTR_TAPEDECK }, /* Top-left house, stone wall & old flooring */ - { 41, 42, 4, 1, FTR_TAPEDECK }, /* Top-right house, wood panelling & steel flooring */ - { 55, 5, 4, 1, FTR_TAPEDECK }, /* Bottom-left house, shanty wall & birch flooring */ - { 42, 34, 4, 1, FTR_TAPEDECK } /* Bottom-right house, concrete wall & charcoal tile */ + { 3, 38, 4, 1, FTR_TAPEDECK }, /* Top-left house, stone wall & old flooring */ + { 41, 42, 4, 1, FTR_TAPEDECK }, /* Top-right house, wood panelling & steel flooring */ + { 55, 5, 4, 1, FTR_TAPEDECK }, /* Bottom-left house, shanty wall & birch flooring */ + { 42, 34, 4, 1, FTR_TAPEDECK } /* Bottom-right house, concrete wall & charcoal tile */ }; /** * @brief Sets the default data for a given home. - * + * * @param home_no Index of the home which will receive the default data **/ extern void mHm_SetDefaultPlayerRoomData(int home_no) { - int i; + int i; - int ut_x = l_mHm_player_room_default_data[home_no & 3].item_ut_x; - int ut_z = l_mHm_player_room_default_data[home_no & 3].item_ut_z; + int ut_x = l_mHm_player_room_default_data[home_no & 3].item_ut_x; + int ut_z = l_mHm_player_room_default_data[home_no & 3].item_ut_z; - Save_Set(homes[home_no & 3].floors[mHm_ROOM_MAIN].layer_main.items[ut_z][ut_x], l_mHm_player_room_default_data[home_no & 3].item); - Save_Set(homes[home_no & 3].floors[mHm_ROOM_MAIN].layer_main.items[1][1], FTR_ORANGEBOX); - Save_Set(homes[home_no & 3].floors[mHm_ROOM_MAIN].layer_secondary.items[1][1], ITM_DIARY00); + Save_Set(homes[home_no & 3].floors[mHm_ROOM_MAIN].layer_main.items[ut_z][ut_x], + l_mHm_player_room_default_data[home_no & 3].item); + Save_Set(homes[home_no & 3].floors[mHm_ROOM_MAIN].layer_main.items[1][1], FTR_ORANGEBOX); + Save_Set(homes[home_no & 3].floors[mHm_ROOM_MAIN].layer_secondary.items[1][1], ITM_DIARY00); - for (i = 0; i < mHm_ROOM_NUM; i++) { - Save_Set(homes[home_no & 3].floors[i].wall_floor.flooring_idx, l_mHm_player_room_default_data[home_no & 3].floor_num); - Save_Set(homes[home_no & 3].floors[i].wall_floor.wallpaper_idx, l_mHm_player_room_default_data[home_no & 3].wall_num); - } + for (i = 0; i < mHm_ROOM_NUM; i++) { + Save_Set(homes[home_no & 3].floors[i].wall_floor.flooring_idx, + l_mHm_player_room_default_data[home_no & 3].floor_num); + Save_Set(homes[home_no & 3].floors[i].wall_floor.wallpaper_idx, + l_mHm_player_room_default_data[home_no & 3].wall_num); + } } /** * @brief Initializes the home's owner id to the given player's id. - * + * * @param home Pointer to the mHm_hs_c home which will be updated * @param player_no Index of the player whose id will be used **/ extern void mHm_InitHomeInfo(mHm_hs_c* home, int player_no) { - mPr_CopyPersonalID(&home->ownerID, Save_GetPointer(private[player_no].player_ID)); + mPr_CopyPersonalID(&home->ownerID, Save_GetPointer(private_data[player_no].player_ID)); } /** * @brief Sets/clears the wall and door layout for a given room. - * + * * @param dst Pointer to the room item actor data * @param roomtype Type of room to select correct room data (0-3) * @param set when TRUE copy data, when FALSE clear data **/ static void mHm_ChangeWallDoorFG(mActor_name_t* dst, int roomtype, int set) { - static mActor_name_t* player_room_tmp_table[mHm_ROOMTYPE_NUM] = { - l_proom_s_tmp, /* small room layout (default) */ - l_proom_m_tmp, /* medium room layout */ - l_proom_l_tmp, /* large room layout */ - l_proom_cottage_tmp /* island cottage layout */ - }; + static mActor_name_t* player_room_tmp_table[mHm_ROOMTYPE_NUM] = { + l_proom_s_tmp, /* small room layout (default) */ + l_proom_m_tmp, /* medium room layout */ + l_proom_l_tmp, /* large room layout */ + l_proom_cottage_tmp /* island cottage layout */ + }; - mActor_name_t* src; - int i; + mActor_name_t* src; + int i; - if (roomtype < mHm_ROOMTYPE_SMALL || roomtype >= mHm_ROOMTYPE_NUM) { - roomtype = mHm_ROOMTYPE_SMALL; - } - - src = player_room_tmp_table[roomtype]; - for (i = 0; i < UT_X_NUM * UT_Z_NUM; i++) { - if (*src != EMPTY_NO) { - if (set == FALSE) { - *dst = EMPTY_NO; /* clear */ - } - else { - *dst = *src; /* set */ - } + if (roomtype < mHm_ROOMTYPE_SMALL || roomtype >= mHm_ROOMTYPE_NUM) { + roomtype = mHm_ROOMTYPE_SMALL; } - src++; - dst++; - } + src = player_room_tmp_table[roomtype]; + for (i = 0; i < UT_X_NUM * UT_Z_NUM; i++) { + if (*src != EMPTY_NO) { + if (set == FALSE) { + *dst = EMPTY_NO; /* clear */ + } else { + *dst = *src; /* set */ + } + } + + src++; + dst++; + } } /** * @brief Clears the wall & door data for a room. - * + * * @param items Pointer to the room actor items * @param roomtype Type of room to clear **/ static void mHm_EraseWallDoor(mActor_name_t* items, int roomtype) { - mHm_ChangeWallDoorFG(items, roomtype, FALSE); + mHm_ChangeWallDoorFG(items, roomtype, FALSE); } /** * @brief Sets the wall & door data for a room. - * + * * @param items Pointer to the room actor items * @param roomtype Type of room to clear **/ static void mHm_SetWallDoor(mActor_name_t* items, int roomtype) { - mHm_ChangeWallDoorFG(items, roomtype, TRUE); + mHm_ChangeWallDoorFG(items, roomtype, TRUE); } /** * @brief Updates the wall & door data for the main room. - * + * * @param home Pointer to the mHm_hs_c home to update * @param home_size Size of the home (0-4, but only 1-4 should be used for this function) **/ static void mHm_RehouseWallDoor(mHm_hs_c* home, int home_size) { - static int room_size[mHm_HOMESIZE_NUM] = { - mHm_ROOMTYPE_SMALL, /* mHm_HOMESIZE_SMALL */ - mHm_ROOMTYPE_MEDIUM, /* mHm_HOMESIZE_MEDIUM */ - mHm_ROOMTYPE_LARGE, /* mHm_HOMESIZE_LARGE */ - mHm_ROOMTYPE_LARGE, /* mHm_HOMESIZE_UPPER */ - mHm_ROOMTYPE_SMALL /* mHm_HOMESIZE_STATUE */ - }; + static int room_size[mHm_HOMESIZE_NUM] = { + mHm_ROOMTYPE_SMALL, /* mHm_HOMESIZE_SMALL */ + mHm_ROOMTYPE_MEDIUM, /* mHm_HOMESIZE_MEDIUM */ + mHm_ROOMTYPE_LARGE, /* mHm_HOMESIZE_LARGE */ + mHm_ROOMTYPE_LARGE, /* mHm_HOMESIZE_UPPER */ + mHm_ROOMTYPE_SMALL /* mHm_HOMESIZE_STATUE */ + }; - int new_size; - int old_size; + int new_size; + int old_size; - if (home_size < mHm_HOMESIZE_MEDIUM || home_size >= mHm_HOMESIZE_NUM) { - home_size = mHm_HOMESIZE_MEDIUM; - } + if (home_size < mHm_HOMESIZE_MEDIUM || home_size >= mHm_HOMESIZE_NUM) { + home_size = mHm_HOMESIZE_MEDIUM; + } - old_size = room_size[home_size - 1]; - new_size = room_size[home_size]; + old_size = room_size[home_size - 1]; + new_size = room_size[home_size]; - mHm_EraseWallDoor((u16*)home->floors[mHm_ROOM_MAIN].layer_main.items, old_size); - mHm_EraseWallDoor((u16*)home->floors[mHm_ROOM_MAIN].layer_secondary.items, old_size); - mHm_SetWallDoor((u16*)home->floors[mHm_ROOM_MAIN].layer_main.items, new_size); - mHm_SetWallDoor((u16*)home->floors[mHm_ROOM_MAIN].layer_secondary.items, new_size); + mHm_EraseWallDoor((u16*)home->floors[mHm_ROOM_MAIN].layer_main.items, old_size); + mHm_EraseWallDoor((u16*)home->floors[mHm_ROOM_MAIN].layer_secondary.items, old_size); + mHm_SetWallDoor((u16*)home->floors[mHm_ROOM_MAIN].layer_main.items, new_size); + mHm_SetWallDoor((u16*)home->floors[mHm_ROOM_MAIN].layer_secondary.items, new_size); } -#define CHECK_ORDER_DATE(home, rtc_time) \ - ((home)->size_info.upgrade_order_date.day != (rtc_time)->day || \ - (home)->size_info.upgrade_order_date.month != (rtc_time)->month || \ - (home)->size_info.upgrade_order_date.year != (rtc_time)->year) +#define CHECK_ORDER_DATE(home, rtc_time) \ + ((home)->size_info.upgrade_order_date.day != (rtc_time)->day || \ + (home)->size_info.upgrade_order_date.month != (rtc_time)->month || \ + (home)->size_info.upgrade_order_date.year != (rtc_time)->year) /** * @brief Check if any house should be updated, and if so, update it. **/ extern void mHm_CheckRehouseOrder() { - mHm_hs_c* home = Save_Get(homes); - lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); - int i; + mHm_hs_c* home = Save_Get(homes); + lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); + int i; - for (i = 0; i < PLAYER_NUM; i++) { - if (mPr_NullCheckPersonalID(&home->ownerID) == FALSE) { - if (home->outlook_pal != home->next_outlook_pal) { - home->outlook_pal = home->next_outlook_pal; - } + for (i = 0; i < PLAYER_NUM; i++) { + if (mPr_NullCheckPersonalID(&home->ownerID) == FALSE) { + if (home->outlook_pal != home->next_outlook_pal) { + home->outlook_pal = home->next_outlook_pal; + } - if (home->size_info.size != home->size_info.next_size && home->size_info.next_size < mHm_HOMESIZE_STATUE) { - if (CHECK_ORDER_DATE(home, rtc_time)) { - home->outlook_pal = home->ordered_outlook_pal; - home->next_outlook_pal = home->ordered_outlook_pal; - home->size_info.size = home->size_info.next_size; - home->size_info.renew = TRUE; - mHm_RehouseWallDoor(home, home->size_info.size); + if (home->size_info.size != home->size_info.next_size && home->size_info.next_size < mHm_HOMESIZE_STATUE) { + if (CHECK_ORDER_DATE(home, rtc_time)) { + home->outlook_pal = home->ordered_outlook_pal; + home->next_outlook_pal = home->ordered_outlook_pal; + home->size_info.size = home->size_info.next_size; + home->size_info.renew = TRUE; + mHm_RehouseWallDoor(home, home->size_info.size); + } + } else { + if (home->size_info.basement_ordered) { + if (CHECK_ORDER_DATE(home, rtc_time)) { + mHm_SetBasement(i); + home->size_info.renew = TRUE; + } + } else if (home->size_info.statue_ordered == TRUE) { + if (CHECK_ORDER_DATE(home, rtc_time)) { + home->size_info.next_size = mHm_HOMESIZE_STATUE; + } + } + } } - } - else { - if (home->size_info.basement_ordered) { - if (CHECK_ORDER_DATE(home, rtc_time)) { - mHm_SetBasement(i); - home->size_info.renew = TRUE; - } - } - else if (home->size_info.statue_ordered == TRUE) { - if (CHECK_ORDER_DATE(home, rtc_time)) { - home->size_info.next_size = mHm_HOMESIZE_STATUE; - } - } - } + home++; } - home++; - } - for (i = 0; i < PLAYER_NUM; i++) { - u32* state_flags = Save_GetPointer(private[i].state_flags); - *state_flags &= (~0x200); /* TODO: these need an enum/defines */ - } + 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 */ + } } /** * @brief Stores the player's current house size for later. - * + * * @param player_no Index of the player whose house size will be saved * @return TRUE/FALSE house size was kept **/ extern int mHm_KeepHouseSize(u8 player_no) { - int arrange_idx; - mHm_hs_c* home; - u8* keep_house_size; - int res = FALSE; + int arrange_idx; + mHm_hs_c* home; + u8* keep_house_size; + int res = FALSE; - if (player_no < PLAYER_NUM) { - arrange_idx = mHS_get_arrange_idx(player_no); - home = Save_GetPointer(homes[arrange_idx]); - keep_house_size = Save_GetPointer(keep_house_size[arrange_idx]); - - res = TRUE; + if (player_no < PLAYER_NUM) { + arrange_idx = mHS_get_arrange_idx(player_no); + home = Save_GetPointer(homes[arrange_idx]); + keep_house_size = Save_GetPointer(keep_house_size[arrange_idx]); - /* I don't think this is a union or struct due to the unused first bit */ - /* But maybe... perhaps they used a pad bit for the topmost bit unlike other structs */ - *keep_house_size = 0; - *keep_house_size |= home->size_info.size; - *keep_house_size |= home->size_info.next_size << 3; - *keep_house_size |= home->size_info.renew << 6; - } + res = TRUE; - return res; + /* I don't think this is a union or struct due to the unused first bit */ + /* But maybe... perhaps they used a pad bit for the topmost bit unlike other structs */ + *keep_house_size = 0; + *keep_house_size |= home->size_info.size; + *keep_house_size |= home->size_info.next_size << 3; + *keep_house_size |= home->size_info.renew << 6; + } + + return res; } /** * @brief Checks whether the kept house size for a player is the same as the actual size. - * + * * @param player_no The index of the player whose house will be checked * @returns TRUE/FALSE house size and keep house size are the same **/ extern int mHm_CheckKeepHouseSize(u8 player_no) { - int arrange_idx; - mHm_hs_c* home; - u8* keep_house_size; - int res = FALSE; + int arrange_idx; + mHm_hs_c* home; + u8* keep_house_size; + int res = FALSE; - if (player_no < PLAYER_NUM) { - arrange_idx = mHS_get_arrange_idx(player_no); - keep_house_size = Save_GetPointer(keep_house_size[arrange_idx]); - home = Save_Get(homes + arrange_idx); + if (player_no < PLAYER_NUM) { + arrange_idx = mHS_get_arrange_idx(player_no); + keep_house_size = Save_GetPointer(keep_house_size[arrange_idx]); + home = Save_Get(homes + arrange_idx); - if ((*keep_house_size & 7) == home->size_info.size && - ((*keep_house_size >> 3) & 7) == home->size_info.next_size && - ((*keep_house_size >> 6) & 1) == home->size_info.renew) { - res = TRUE; + if ((*keep_house_size & 7) == home->size_info.size && + ((*keep_house_size >> 3) & 7) == home->size_info.next_size && + ((*keep_house_size >> 6) & 1) == home->size_info.renew) { + res = TRUE; + } } - } - return res; + return res; } /** * @brief Updates player house flags to include basement - * + * * @param home_no Index of the house whose basement flag will be enabled * @return TRUE/FALSE was flag set **/ extern int mHm_SetBasement(u8 home_no) { - if (home_no < PLAYER_NUM) { - mHm_flg_c* flags = Save_GetPointer(homes[home_no].flags); - if (flags->has_basement == FALSE) { - flags->has_basement = TRUE; - return TRUE; + if (home_no < PLAYER_NUM) { + mHm_flg_c* flags = Save_GetPointer(homes[home_no].flags); + if (flags->has_basement == FALSE) { + flags->has_basement = TRUE; + return TRUE; + } } - } - return FALSE; + return FALSE; } /** * @brief Sets the default island cottage data - * + * * @param cottage Pointer to the mHm_cottage_c cottage which will receive the default data **/ static void mHm_SetDefaultCottageData(mHm_cottage_c* cottage) { - if (cottage == NULL) { - return; - } + if (cottage == NULL) { + return; + } - cottage->room.wall_floor.flooring_idx = 13; - cottage->room.wall_floor.wallpaper_idx = 13; + cottage->room.wall_floor.flooring_idx = 13; + cottage->room.wall_floor.wallpaper_idx = 13; - cottage->room.layer_main.items[3][3] = FTR_REDALOHASHIRT; - cottage->room.layer_main.items[3][6] = FTR_BLUEALOHASHIRT; - cottage->room.layer_main.items[6][3] = FTR_REDALOHASHIRT; - cottage->room.layer_main.items[6][6] = FTR_BLUEALOHASHIRT; + cottage->room.layer_main.items[3][3] = FTR_REDALOHASHIRT; + cottage->room.layer_main.items[3][6] = FTR_BLUEALOHASHIRT; + cottage->room.layer_main.items[6][3] = FTR_REDALOHASHIRT; + cottage->room.layer_main.items[6][6] = FTR_BLUEALOHASHIRT; } /** * @brief Initialize an mHm_cottage_c cottage. - * + * * @param cottage Pointer to the mHm_cottage_c which will be initialized **/ extern void mHm_InitCottage(mHm_cottage_c* cottage) { - if (cottage != NULL) { - bzero(cottage, sizeof(mHm_cottage_c)); - mHm_SetWallDoor((u16*)cottage->room.layer_main.items, mHm_ROOMTYPE_COTTAGE); - mCkRh_InitGokiSaveData_IslandPlayerRoom(); - mHm_SetDefaultCottageData(cottage); - } + if (cottage != NULL) { + bzero(cottage, sizeof(mHm_cottage_c)); + mHm_SetWallDoor((u16*)cottage->room.layer_main.items, mHm_ROOMTYPE_COTTAGE); + mCkRh_InitGokiSaveData_IslandPlayerRoom(); + mHm_SetDefaultCottageData(cottage); + } } diff --git a/src/m_house.c b/src/m_house.c index ecf3c974..eb332b4d 100644 --- a/src/m_house.c +++ b/src/m_house.c @@ -11,7 +11,7 @@ /** * @brief Initializes the `house_arrangement` variable to its default state. - * + * * The default state is: * Player0: House0 * Player1: House1 @@ -19,98 +19,100 @@ * Player3: House3 **/ extern void mHS_house_init() { - Save_Set(house_arrangement, DEFAULT_ARRANGEMENT); + Save_Set(house_arrangement, DEFAULT_ARRANGEMENT); } /** * @brief Retrieves the house arrangement value for a given player index. - * + * * @return The house index for the player. **/ extern int mHS_get_arrange_idx(int player_no) { - return ARRANGE_GET(player_no); + return ARRANGE_GET(player_no); } /** * @brief Returns the index of the player who owns the house index from `house_arrangement`. - * + * * @return The owning player index for the house. **/ extern int mHS_get_pl_no(int house_no) { - int i; - u32 arrangement = Save_Get(house_arrangement); + int i; + u32 arrangement = Save_Get(house_arrangement); - for (i = 0; i < PLAYER_NUM; i++) { - if ((arrangement & 3) == house_no) { - break; + for (i = 0; i < PLAYER_NUM; i++) { + if ((arrangement & 3) == house_no) { + break; + } + + arrangement >>= 2; } - arrangement >>= 2; - } - - return i; + return i; } /** * @brief Returns the index of the player who owns a house by checking house owner IDs. - * + * * @return The owning player index for the house. **/ extern int mHS_get_pl_no_detail(int home_no) { - mHm_hs_c* home = Save_Get(homes + (home_no & 3)); + mHm_hs_c* home = Save_Get(homes + (home_no & 3)); - if (mPr_NullCheckPersonalID(&home->ownerID) == FALSE) { - int i; - for (i = 0; i < PLAYER_NUM; i++) { - if (mPr_CheckCmpPersonalID(&home->ownerID, Save_GetPointer(private[i].player_ID))) { - return i; - } + if (mPr_NullCheckPersonalID(&home->ownerID) == FALSE) { + int i; + for (i = 0; i < PLAYER_NUM; i++) { + if (mPr_CheckCmpPersonalID(&home->ownerID, Save_GetPointer(private_data[i].player_ID))) { + return i; + } + } } - } - return -1; + return -1; } /* TODO: this probably had some macro.. maybe refactor? */ /** * @brief Sets the house arrangement value for `player_no` to `house_no`. - * + * * This function also swaps houses with whichever player is set in house_arrangement * with the house currently assigned to `player_no`. - * + * * @return TRUE when successfully set, FALSE otherwise. **/ extern int mHS_set_use(int player_no, int house_no) { - int now_player_no; - u32 house_arrangement; - int mask; - int plr_shift; - int new_shift; - int res = FALSE; + int now_player_no; + u32 house_arrangement; + int mask; + int plr_shift; + int new_shift; + int res = FALSE; - if (player_no < PLAYER_NUM && house_no < PLAYER_NUM) { - now_player_no = mHS_get_pl_no(house_no); - if (mPr_NullCheckPersonalID(Save_GetPointer(homes[house_no].ownerID)) == TRUE) { - if (now_player_no != player_no) { - plr_shift = player_no * 2; - new_shift = now_player_no * 2; - house_arrangement = Save_Get(house_arrangement); - - /* create bitmask to clear previous saved indices */ - mask = 0xffffffff; - mask ^= (3 << plr_shift) | (3 << new_shift); /* Remove the bits relating to both player indicies */ + if (player_no < PLAYER_NUM && house_no < PLAYER_NUM) { + now_player_no = mHS_get_pl_no(house_no); + if (mPr_NullCheckPersonalID(Save_GetPointer(homes[house_no].ownerID)) == TRUE) { + if (now_player_no != player_no) { + plr_shift = player_no * 2; + new_shift = now_player_no * 2; + house_arrangement = Save_Get(house_arrangement); - /* Swap the player who currently owns our selected house with whatever house our player "owns" currently */ - Save_Set(house_arrangement, ( - ((house_arrangement & mask) | /* Clear old values */ - (((house_arrangement >> plr_shift) & 3)) << new_shift) | /* move current player house idx to old player house idx */ - (house_no << plr_shift))); /* set current player new house idx */ - } + /* create bitmask to clear previous saved indices */ + mask = 0xffffffff; + mask ^= (3 << plr_shift) | (3 << new_shift); /* Remove the bits relating to both player indicies */ - mHm_InitHomeInfo(Save_Get(homes + house_no), player_no); - res = TRUE; + /* Swap the player who currently owns our selected house with whatever house our player "owns" currently + */ + Save_Set(house_arrangement, + (((house_arrangement & mask) | /* Clear old values */ + (((house_arrangement >> plr_shift) & 3)) + << new_shift) | /* move current player house idx to old player house idx */ + (house_no << plr_shift))); /* set current player new house idx */ + } + + mHm_InitHomeInfo(Save_Get(homes + house_no), player_no); + res = TRUE; + } } - } - return res; + return res; } diff --git a/src/m_mail.c b/src/m_mail.c index 63b8c4e8..046d0ffc 100644 --- a/src/m_mail.c +++ b/src/m_mail.c @@ -16,365 +16,354 @@ static u8 footer[MAIL_FOOTER2_LEN]; static u8 header[MAIL_HEADER2_LEN]; extern int mMl_strlen(u8* str, int size, u8 end_char) { - u32 end_p = size + (u32)str; - int i; + u32 end_p = size + (u32)str; + int i; - end_p--; - for (size; size != 0; size--) { - - if (*(u8*)end_p != end_char) { - return size; - } - end_p--; - } + for (size; size != 0; size--) { - return 0; + if (*(u8*)end_p != end_char) { + return size; + } + + end_p--; + } + + return 0; } extern int mMl_strlen2(int* found, u8* str, int size, u8 end_char) { - int len = 0; + int len = 0; - if (found != NULL) { - *found = FALSE; - } - - for (size; size != 0; size--) { - len++; - if (*str == end_char) { - if (found != NULL) { - *found = TRUE; - } - break; + if (found != NULL) { + *found = FALSE; } - str++; - } + for (size; size != 0; size--) { + len++; + if (*str == end_char) { + if (found != NULL) { + *found = TRUE; + } + break; + } - return len; + str++; + } + + return len; } extern void mMl_clear_mail_header(Mail_hdr_c* header) { - mPr_ClearPersonalID(&header->recipient.personalID); - header->recipient.type = mMl_NAME_TYPE_CLEAR; + mPr_ClearPersonalID(&header->recipient.personalID); + header->recipient.type = mMl_NAME_TYPE_CLEAR; - mPr_ClearPersonalID(&header->sender.personalID); - header->sender.type = mMl_NAME_TYPE_CLEAR; + mPr_ClearPersonalID(&header->sender.personalID); + header->sender.type = mMl_NAME_TYPE_CLEAR; } extern void mMl_clear_mail(Mail_c* mail) { - bzero(mail, sizeof(Mail_c)); - mMl_clear_mail_header(&mail->header); - mem_clear(mail->content.header, MAIL_HEADER_LEN + MAIL_BODY_LEN + MAIL_FOOTER_LEN, CHAR_SPACE); - mail->content.font = -1; + bzero(mail, sizeof(Mail_c)); + mMl_clear_mail_header(&mail->header); + mem_clear(mail->content.header, MAIL_HEADER_LEN + MAIL_BODY_LEN + MAIL_FOOTER_LEN, CHAR_SPACE); + mail->content.font = -1; } extern void mMl_clear_mail_box(Mail_c* mail, int num) { - while (num != 0) { - num--; - mMl_clear_mail(mail); - mail++; - } + while (num != 0) { + num--; + mMl_clear_mail(mail); + mail++; + } } extern int mMl_check_not_used_mail(Mail_c* mail) { - int res = FALSE; - if (mail->content.font == 0xFF) { - res = TRUE; - } + int res = FALSE; + if (mail->content.font == 0xFF) { + res = TRUE; + } - return res; + return res; } extern void mMl_copy_header_name(Mail_c* dst, Mail_c* src) { - dst->header.recipient.type = src->header.recipient.type; - mPr_CopyPersonalID(&dst->header.recipient.personalID, &src->header.recipient.personalID); + dst->header.recipient.type = src->header.recipient.type; + mPr_CopyPersonalID(&dst->header.recipient.personalID, &src->header.recipient.personalID); } extern void mMl_set_to_plname(Mail_c* mail, PersonalID_c* pid) { - mPr_CopyPersonalID(&mail->header.recipient.personalID, pid); - mail->header.recipient.type = mMl_NAME_TYPE_PLAYER; + mPr_CopyPersonalID(&mail->header.recipient.personalID, pid); + mail->header.recipient.type = mMl_NAME_TYPE_PLAYER; } extern void mMl_set_playername(Mail_c* mail, PersonalID_c* pid) { - mPr_CopyPersonalID(&mail->header.sender.personalID, pid); - mail->header.sender.type = mMl_NAME_TYPE_PLAYER; + mPr_CopyPersonalID(&mail->header.sender.personalID, pid); + mail->header.sender.type = mMl_NAME_TYPE_PLAYER; } extern void mMl_init_mail(Mail_c* mail, PersonalID_c* pid) { - mMl_clear_mail(mail); - mMl_set_playername(mail, pid); - mail->content.font = mMl_FONT_SEND; - mail->content.mail_type = 0; - mail->content.paper_type = 0; + mMl_clear_mail(mail); + mMl_set_playername(mail, pid); + mail->content.font = mMl_FONT_SEND; + mail->content.mail_type = 0; + mail->content.paper_type = 0; } extern int mMl_chk_mail_free_space(Mail_c* mail, int num) { - int free_idx; + int free_idx; - for (free_idx = 0; free_idx < num; free_idx++) { - if (mMl_check_not_used_mail(mail) == TRUE) { - return free_idx; + for (free_idx = 0; free_idx < num; free_idx++) { + if (mMl_check_not_used_mail(mail) == TRUE) { + return free_idx; + } + + mail++; } - mail++; - } - - return -1; + return -1; } extern int mMl_count_use_mail_space(Mail_c* mail, int num) { - int used = 0; - int i; + int used = 0; + int i; - for (i = 0; i < num; i++) { - if (mMl_check_not_used_mail(mail) != TRUE) { - used++; + for (i = 0; i < num; i++) { + if (mMl_check_not_used_mail(mail) != TRUE) { + used++; + } + + mail++; } - mail++; - } - - return used; + return used; } extern void mMl_copy_mail(Mail_c* dst, Mail_c* src) { - mem_copy((u8*)dst, (u8*)src, sizeof(Mail_c)); + mem_copy((u8*)dst, (u8*)src, sizeof(Mail_c)); } extern void mMl_clear_mail_header_common(Mail_hs_c* header) { - header->header_back_start = -1; - header->unknown = 0; - mem_clear(header->header, MAIL_HEADER_LEN, CHAR_SPACE); - mem_clear(header->footer, MAIL_FOOTER_LEN, CHAR_SPACE); + header->header_back_start = -1; + header->unknown = 0; + mem_clear(header->header, MAIL_HEADER_LEN, CHAR_SPACE); + mem_clear(header->footer, MAIL_FOOTER_LEN, CHAR_SPACE); } extern void mMl_set_mail_name_npcinfo(Mail_nm_c* name, AnmPersonalID_c* anm_pid) { - u8 animal_name[PLAYER_NAME_LEN]; - - name->type = mMl_NAME_TYPE_NPC; - mNpc_GetNpcWorldNameAnm(animal_name, anm_pid); - mPr_CopyPlayerName(name->personalID.player_name, animal_name); - name->personalID.land_id = anm_pid->land_id; - mLd_CopyLandName(name->personalID.land_name, anm_pid->land_name); - name->personalID.player_id = (((anm_pid->npc_id & 0xFF) << 8) | anm_pid->name_id); + u8 animal_name[PLAYER_NAME_LEN]; + + name->type = mMl_NAME_TYPE_NPC; + mNpc_GetNpcWorldNameAnm(animal_name, anm_pid); + mPr_CopyPlayerName(name->personalID.player_name, animal_name); + name->personalID.land_id = anm_pid->land_id; + mLd_CopyLandName(name->personalID.land_name, anm_pid->land_name); + name->personalID.player_id = (((anm_pid->npc_id & 0xFF) << 8) | anm_pid->name_id); } extern int mMl_get_npcinfo_from_mail_name(AnmPersonalID_c* anm_pid, Mail_nm_c* name) { - int res = FALSE; + int res = FALSE; - if (name->type == mMl_NAME_TYPE_NPC) { - anm_pid->npc_id = ((name->personalID.player_id & 0xFF00) >> 8) | NPC_START; - anm_pid->land_id = name->personalID.land_id; - mLd_CopyLandName(anm_pid->land_name, name->personalID.land_name); - anm_pid->name_id = name->personalID.player_id; - anm_pid->looks = mNpc_GetLooks(anm_pid->npc_id); + if (name->type == mMl_NAME_TYPE_NPC) { + anm_pid->npc_id = ((name->personalID.player_id & 0xFF00) >> 8) | NPC_START; + anm_pid->land_id = name->personalID.land_id; + mLd_CopyLandName(anm_pid->land_name, name->personalID.land_name); + anm_pid->name_id = name->personalID.player_id; + anm_pid->looks = mNpc_GetLooks(anm_pid->npc_id); - res = TRUE; - } + res = TRUE; + } - return res; + return res; } extern int mMl_hunt_for_send_address(Mail_c* mail) { - int i; + int i; - if (mail->header.recipient.type != mMl_NAME_TYPE_PLAYER) { - return -1; - } - - for (i = 0; i < mHS_HOUSE_NUM; i++) { - if (mPr_CheckCmpPersonalID(&Save_Get(homes[i]).ownerID, &mail->header.recipient.personalID) == TRUE) { - return i; + if (mail->header.recipient.type != mMl_NAME_TYPE_PLAYER) { + return -1; } - } - return -1; + for (i = 0; i < mHS_HOUSE_NUM; i++) { + if (mPr_CheckCmpPersonalID(&Save_Get(homes[i]).ownerID, &mail->header.recipient.personalID) == TRUE) { + return i; + } + } + + return -1; } extern int mMl_check_send_mail(Mail_c* mail) { - return mail->content.font == mMl_FONT_SEND; + return mail->content.font == mMl_FONT_SEND; } extern int mMl_check_set_present_myself(Mail_c* mail) { - u8 font = mail->content.font; + u8 font = mail->content.font; - if (font == mMl_FONT_SEND || font == mMl_FONT_3 || font == mMl_FONT_4) { - return TRUE; - } + if (font == mMl_FONT_SEND || font == mMl_FONT_3 || font == mMl_FONT_4) { + return TRUE; + } - return FALSE; + return FALSE; } static void mMl_load_mail_data(Mail_c* mail, int mail_no) { - int header_back_start; + int header_back_start; - mHandbill_Load_HandbillFromRom(mail->content.header, &header_back_start, mail->content.footer, mail->content.body, mail_no); - mail->content.header_back_start = header_back_start; + mHandbill_Load_HandbillFromRom(mail->content.header, &header_back_start, mail->content.footer, mail->content.body, + mail_no); + mail->content.header_back_start = header_back_start; } /* TODO: fix bss ordering */ static void mMl_load_mail_data2(Mail_c* mail, int mail_no) { - //static u8 header[MAIL_HEADER2_LEN]; - //static u8 footer[MAIL_FOOTER2_LEN]; - int header_back_start; + // static u8 header[MAIL_HEADER2_LEN]; + // static u8 footer[MAIL_FOOTER2_LEN]; + int header_back_start; - mHandbill_Load_HandbillFromRom2(header, MAIL_HEADER2_LEN, &header_back_start, footer, MAIL_FOOTER2_LEN, mail->content.body, mail_no); + mHandbill_Load_HandbillFromRom2(header, MAIL_HEADER2_LEN, &header_back_start, footer, MAIL_FOOTER2_LEN, + mail->content.body, mail_no); - bcopy(header, mail->content.header, MAIL_HEADER_LEN); - bcopy(footer, mail->content.footer, MAIL_FOOTER_LEN); - mail->content.header_back_start = header_back_start; + bcopy(header, mail->content.header, MAIL_HEADER_LEN); + bcopy(footer, mail->content.footer, MAIL_FOOTER_LEN); + mail->content.header_back_start = header_back_start; } -static void mMl_get_mail_to_player_com(Mail_c* mail, PersonalID_c* recipient_pid, mActor_name_t present, mActor_name_t paper, u8* sender_name, int mail_no, u32 proc_type, u8 mail_type) { - static void (*get_proc[2])(Mail_c*, int) = { &mMl_load_mail_data, &mMl_load_mail_data2 }; - proc_type %= 2; - - mMl_clear_mail(mail); - (*get_proc[proc_type])(mail, mail_no); - mail->content.font = mMl_FONT_0; - mail->content.mail_type = mail_type; - - mPr_CopyPersonalID(&mail->header.recipient.personalID, recipient_pid); - mail->header.recipient.type = mMl_NAME_TYPE_PLAYER; +static void mMl_get_mail_to_player_com(Mail_c* mail, PersonalID_c* recipient_pid, mActor_name_t present, + mActor_name_t paper, u8* sender_name, int mail_no, u32 proc_type, u8 mail_type) { + static void (*get_proc[2])(Mail_c*, int) = { &mMl_load_mail_data, &mMl_load_mail_data2 }; + proc_type %= 2; - mPr_ClearPersonalID(&mail->header.sender.personalID); - mPr_CopyPlayerName(mail->header.sender.personalID.player_name, sender_name); - mail->header.sender.type = mMl_NAME_TYPE_MUSEUM; - - mail->present = present; - mail->content.paper_type = (paper - ITM_PAPER_START) % PAPER_UNIQUE_NUM; + mMl_clear_mail(mail); + (*get_proc[proc_type])(mail, mail_no); + mail->content.font = mMl_FONT_0; + mail->content.mail_type = mail_type; + + mPr_CopyPersonalID(&mail->header.recipient.personalID, recipient_pid); + mail->header.recipient.type = mMl_NAME_TYPE_PLAYER; + + mPr_ClearPersonalID(&mail->header.sender.personalID); + mPr_CopyPlayerName(mail->header.sender.personalID.player_name, sender_name); + mail->header.sender.type = mMl_NAME_TYPE_MUSEUM; + + mail->present = present; + mail->content.paper_type = (paper - ITM_PAPER_START) % PAPER_UNIQUE_NUM; } -static int mMl_send_mail_box_com(PersonalID_c* recipient_pid, int player_no, Mail_c* mail, mActor_name_t present, mActor_name_t paper, int mail_no, u8* sender_name, u32 proc_type, u8 mail_type) { - mHm_hs_c* house; - int res = FALSE; +static int mMl_send_mail_box_com(PersonalID_c* recipient_pid, int player_no, Mail_c* mail, mActor_name_t present, + mActor_name_t paper, int mail_no, u8* sender_name, u32 proc_type, u8 mail_type) { + mHm_hs_c* house; + int res = FALSE; - house = Save_GetPointer(homes[mHS_get_arrange_idx(player_no)]); + house = Save_GetPointer(homes[mHS_get_arrange_idx(player_no)]); - if (mPr_CheckCmpPersonalID(recipient_pid, &house->ownerID) == TRUE) { - int free_idx = mMl_chk_mail_free_space(house->mailbox, HOME_MAILBOX_SIZE); - if (free_idx != -1) { - mMl_get_mail_to_player_com(mail, recipient_pid, present, paper, sender_name, mail_no, proc_type, mail_type); - mMl_copy_mail(house->mailbox + free_idx, mail); - res = TRUE; + if (mPr_CheckCmpPersonalID(recipient_pid, &house->ownerID) == TRUE) { + int free_idx = mMl_chk_mail_free_space(house->mailbox, HOME_MAILBOX_SIZE); + if (free_idx != -1) { + mMl_get_mail_to_player_com(mail, recipient_pid, present, paper, sender_name, mail_no, proc_type, mail_type); + mMl_copy_mail(house->mailbox + free_idx, mail); + res = TRUE; + } } - } - return res; + return res; } -extern int mMl_send_mail_box(PersonalID_c* recipient_pid, int player_no, Mail_c* mail, mActor_name_t present, mActor_name_t paper, int mail_no, u8* sender_name, u32 proc_type) { - return mMl_send_mail_box_com(recipient_pid, player_no, mail, present, paper, mail_no, sender_name, proc_type, 0); +extern int mMl_send_mail_box(PersonalID_c* recipient_pid, int player_no, Mail_c* mail, mActor_name_t present, + mActor_name_t paper, int mail_no, u8* sender_name, u32 proc_type) { + return mMl_send_mail_box_com(recipient_pid, player_no, mail, present, paper, mail_no, sender_name, proc_type, 0); } -static int mMl_send_mail_postoffice_com(Mail_c* mail, PersonalID_c* recipient_pid, int player_no, mActor_name_t present, mActor_name_t paper, int mail_no, u8* sender_name, u32 proc_type, u8 mail_type) { - int res = FALSE; +static int mMl_send_mail_postoffice_com(Mail_c* mail, PersonalID_c* recipient_pid, int player_no, mActor_name_t present, + mActor_name_t paper, int mail_no, u8* sender_name, u32 proc_type, + u8 mail_type) { + int res = FALSE; - if (mPO_get_keep_mail_sum() < mPO_MAIL_STORAGE_SIZE) { - mMl_get_mail_to_player_com(mail, recipient_pid, present, paper, sender_name, mail_no, proc_type, mail_type); - res = mPO_receipt_proc(mail, mPO_SENDTYPE_MAIL); - } + if (mPO_get_keep_mail_sum() < mPO_MAIL_STORAGE_SIZE) { + mMl_get_mail_to_player_com(mail, recipient_pid, present, paper, sender_name, mail_no, proc_type, mail_type); + res = mPO_receipt_proc(mail, mPO_SENDTYPE_MAIL); + } - return res; + return res; } -extern int mMl_send_mail_postoffice(PersonalID_c* recipient_pid, int player_no, mActor_name_t present, mActor_name_t paper, int mail_no, u8* sender_name, u32 proc_type, u8 mail_type) { - return mMl_send_mail_postoffice_com(&l_ml_mail, recipient_pid, player_no, present, paper, mail_no, sender_name, proc_type, mail_type); +extern int mMl_send_mail_postoffice(PersonalID_c* recipient_pid, int player_no, mActor_name_t present, + mActor_name_t paper, int mail_no, u8* sender_name, u32 proc_type, u8 mail_type) { + return mMl_send_mail_postoffice_com(&l_ml_mail, recipient_pid, player_no, present, paper, mail_no, sender_name, + proc_type, mail_type); } -static int mMl_send_mail_com(PersonalID_c* recipient_pid, int player_no, mActor_name_t present, mActor_name_t paper, int mail_no, u8* sender_name, u32 proc_type, u8 mail_type) { - Mail_c* mail = &l_ml_mail; - int res = mMl_send_mail_box_com(recipient_pid, player_no, mail, present, paper, mail_no, sender_name, proc_type, mail_type); - if (res != TRUE) { - res = mMl_send_mail_postoffice_com(mail, recipient_pid, player_no, present, paper, mail_no, sender_name, proc_type, mail_type); - } +static int mMl_send_mail_com(PersonalID_c* recipient_pid, int player_no, mActor_name_t present, mActor_name_t paper, + int mail_no, u8* sender_name, u32 proc_type, u8 mail_type) { + Mail_c* mail = &l_ml_mail; + int res = mMl_send_mail_box_com(recipient_pid, player_no, mail, present, paper, mail_no, sender_name, proc_type, + mail_type); + if (res != TRUE) { + res = mMl_send_mail_postoffice_com(mail, recipient_pid, player_no, present, paper, mail_no, sender_name, + proc_type, mail_type); + } - return res; + return res; } -extern int mMl_send_mail(PersonalID_c* recipient_pid, int player_no, mActor_name_t present, mActor_name_t paper, int mail_no, u8* sender_name, u32 proc_type) { - return mMl_send_mail_com(recipient_pid, player_no, present, paper, mail_no, sender_name, proc_type, 0); +extern int mMl_send_mail(PersonalID_c* recipient_pid, int player_no, mActor_name_t present, mActor_name_t paper, + int mail_no, u8* sender_name, u32 proc_type) { + return mMl_send_mail_com(recipient_pid, player_no, present, paper, mail_no, sender_name, proc_type, 0); } typedef struct post_office_gift_info_s { - int mail_no; - mActor_name_t present; - mActor_name_t paper; - int player_received_flag; - u32 required_balance; + int mail_no; + mActor_name_t present; + mActor_name_t paper; + int player_received_flag; + u32 required_balance; } mMl_PostOffice_Info_c; static mMl_PostOffice_Info_c l_mml_postoffice_info[mMl_POSTOFFICE_GIFT_NUM] = { - { - 0x0246, - FTR_TISSUE, - ITM_PAPER00, - mPr_FLAG_POSTOFFICE_GIFT0, - 1000000 - }, - { - 0x0247, - FTR_PIGGY_BANK, - ITM_PAPER00, - mPr_FLAG_POSTOFFICE_GIFT1, - 10000000 - }, - { - 0x0248, - FTR_MAILBOX, - ITM_PAPER00, - mPr_FLAG_POSTOFFICE_GIFT2, - 100000000 - }, - { - 0x0249, - FTR_POST_MODEL, - ITM_PAPER00, - mPr_FLAG_POSTOFFICE_GIFT3, - 999999999 - } + { 0x0246, FTR_TISSUE, ITM_PAPER00, mPr_FLAG_POSTOFFICE_GIFT0, 1000000 }, + { 0x0247, FTR_PIGGY_BANK, ITM_PAPER00, mPr_FLAG_POSTOFFICE_GIFT1, 10000000 }, + { 0x0248, FTR_MAILBOX, ITM_PAPER00, mPr_FLAG_POSTOFFICE_GIFT2, 100000000 }, + { 0x0249, FTR_POST_MODEL, ITM_PAPER00, mPr_FLAG_POSTOFFICE_GIFT3, 999999999 } }; static void mMl_send_postoffice_mail() { - //static u8 free_str[16]; // TODO: fix bss ordering - static u8 debug_name[PLAYER_NAME_LEN] = { 0x91, 0x92, 0x93, 0x94, 0x95, 0x91, 0x00, 0x00 }; + // static u8 free_str[16]; // TODO: fix bss ordering + static u8 debug_name[PLAYER_NAME_LEN] = { 0x91, 0x92, 0x93, 0x94, 0x95, 0x91, 0x00, 0x00 }; - Private_c* priv = Save_Get(private); - mMl_PostOffice_Info_c* po_info; - int town_name_len; - int i; + Private_c* priv = Save_Get(private_data); + mMl_PostOffice_Info_c* po_info; + int town_name_len; + int i; - town_name_len = mLd_GetLandNameStringAddMura(free_str); - mHandbill_Set_free_str(0, free_str, town_name_len); + town_name_len = mLd_GetLandNameStringAddMura(free_str); + mHandbill_Set_free_str(0, free_str, town_name_len); - for (i = 0; i < PLAYER_NUM; i++) { - if (mPr_NullCheckPersonalID(&priv->player_ID) == FALSE) { - int j; + for (i = 0; i < PLAYER_NUM; i++) { + if (mPr_NullCheckPersonalID(&priv->player_ID) == FALSE) { + int j; - mHandbill_Set_free_str(1, priv->player_ID.player_name, PLAYER_NAME_LEN); - po_info = l_mml_postoffice_info; - for (j = 0; j < mMl_POSTOFFICE_GIFT_NUM; j++) { - if ((priv->bank_account >= po_info->required_balance) && - (priv->state_flags & po_info->player_received_flag) == FALSE - ) { - int res = mMl_send_mail_com(&priv->player_ID, i, po_info->present, po_info->paper, po_info->mail_no, debug_name, 0, 10); + mHandbill_Set_free_str(1, priv->player_ID.player_name, PLAYER_NAME_LEN); + po_info = l_mml_postoffice_info; + for (j = 0; j < mMl_POSTOFFICE_GIFT_NUM; j++) { + if ((priv->bank_account >= po_info->required_balance) && + (priv->state_flags & po_info->player_received_flag) == FALSE) { + int res = mMl_send_mail_com(&priv->player_ID, i, po_info->present, po_info->paper, po_info->mail_no, + debug_name, 0, 10); - if (res == TRUE) { - priv->state_flags |= po_info->player_received_flag; - } + if (res == TRUE) { + priv->state_flags |= po_info->player_received_flag; + } - break; + break; + } + + po_info++; + } } - po_info++; - } + priv++; } - - priv++; - } } extern void mMl_start_send_mail() { - mMl_send_postoffice_mail(); + mMl_send_postoffice_mail(); } diff --git a/src/m_map_ovl.c b/src/m_map_ovl.c index bf107cc2..16a5d08b 100644 --- a/src/m_map_ovl.c +++ b/src/m_map_ovl.c @@ -89,134 +89,48 @@ extern u8 kan_tizu_c7r1b_TA_tex_txt[]; extern u8 kan_tizu_mwf_TA_tex_txt[]; static u8* l_map_texture[mFM_BLOCK_TYPE_NUM] = { - kan_tizu_f_TA_tex_txt, - kan_tizu_f_TA_tex_txt, - kan_tizu_f_TA_tex_txt, - kan_tizu_f_TA_tex_txt, - kan_tizu_f_TA_tex_txt, - kan_tizu_f_TA_tex_txt, - kan_tizu_f_TA_tex_txt, - kan_tizu_f_TA_tex_txt, - kan_tizu_f_TA_tex_txt, - kan_tizu_f_TA_tex_txt, - kan_tizu_f_TA_tex_txt, - kan_tizu_tst1_TA_tex_txt, - kan_tizu_t_TA_tex_txt, - kan_tizu_tr1_TA_tex_txt, - kan_tizu_fmh_TA_tex_txt, - kan_tizu_c1_TA_tex_txt, - kan_tizu_c2_TA_tex_txt, - kan_tizu_c3_TA_tex_txt, - kan_tizu_c4_TA_tex_txt, - kan_tizu_c5_TA_tex_txt, - kan_tizu_c6_TA_tex_txt, - kan_tizu_c7_TA_tex_txt, - kan_tizu_c1r1_TA_tex_txt, - kan_tizu_c2r1_TA_tex_txt, - kan_tizu_c3r1_TA_tex_txt, - kan_tizu_c4r1_TA_tex_txt, - kan_tizu_c5r1_TA_tex_txt, - kan_tizu_c6r1_TA_tex_txt, - kan_tizu_c7r1_TA_tex_txt, - kan_tizu_c1r2_TA_tex_txt, - kan_tizu_c2r2_TA_tex_txt, - kan_tizu_c3r2_TA_tex_txt, - kan_tizu_c4r2_TA_tex_txt, - kan_tizu_c5r2_TA_tex_txt, - kan_tizu_c1r2_TA_tex_txt, - kan_tizu_c4r2_TA_tex_txt, - kan_tizu_c5r2_TA_tex_txt, - kan_tizu_c6r3_TA_tex_txt, - kan_tizu_c7r3_TA_tex_txt, - kan_tizu_f_TA_tex_txt, - kan_tizu_r1_TA_tex_txt, - kan_tizu_r2_TA_tex_txt, - kan_tizu_r2_TA_tex_txt, - kan_tizu_r4_TA_tex_txt, - kan_tizu_r5_TA_tex_txt, - kan_tizu_r6_TA_tex_txt, - kan_tizu_r7_TA_tex_txt, - kan_tizu_r1b_TA_tex_txt, - kan_tizu_r2b_TA_tex_txt, - kan_tizu_r2b_TA_tex_txt, - kan_tizu_r4b_TA_tex_txt, - kan_tizu_r5b_TA_tex_txt, - kan_tizu_r6b_TA_tex_txt, - kan_tizu_r7b_TA_tex_txt, - kan_tizu_c1s_TA_tex_txt, - kan_tizu_c2s_TA_tex_txt, - kan_tizu_c3s_TA_tex_txt, - kan_tizu_c4s_TA_tex_txt, - kan_tizu_c5s_TA_tex_txt, - kan_tizu_c6s_TA_tex_txt, - kan_tizu_c7s_TA_tex_txt, - kan_tizu_f_TA_tex_txt, - kan_tizu_f_TA_tex_txt, - kan_tizu_m_TA_tex_txt, - kan_tizu_mr1_TA_tex_txt, - kan_tizu_fsh_TA_tex_txt, - kan_tizu_fpk_TA_tex_txt, - kan_tizu_fpo_TA_tex_txt, - kan_tizu_fko_TA_tex_txt, - kan_tizu_pr1_TA_tex_txt, - kan_tizu_pr2_TA_tex_txt, - kan_tizu_pr2_TA_tex_txt, - kan_tizu_pr4_TA_tex_txt, - kan_tizu_pr5_TA_tex_txt, - kan_tizu_pr6_TA_tex_txt, - kan_tizu_pr7_TA_tex_txt, - kan_tizu_f_TA_tex_txt, - kan_tizu_r1_TA_tex_txt, - kan_tizu_c1_TA_tex_txt, - kan_tizu_c1_TA_tex_txt, - kan_tizu_c1_TA_tex_txt, - kan_tizu_c1_TA_tex_txt, - kan_tizu_mr1b_TA_tex_txt, - kan_tizu_mr1_TA_tex_txt, - kan_tizu_fmu_TA_tex_txt, - kan_tizu_fta_TA_tex_txt, - kan_tizu_tr1b_TA_tex_txt, - kan_tizu_c1r2b_TA_tex_txt, - kan_tizu_c3r1b_TA_tex_txt, - kan_tizu_c4r1b_TA_tex_txt, - kan_tizu_c4r2b_TA_tex_txt, - kan_tizu_c5r2b_TA_tex_txt, - kan_tizu_c6r1b_TA_tex_txt, - kan_tizu_c7r1b_TA_tex_txt, - kan_tizu_c7r1b_TA_tex_txt, - kan_tizu_c7r1b_TA_tex_txt, - kan_tizu_c7r1b_TA_tex_txt, - kan_tizu_c7r1b_TA_tex_txt, - kan_tizu_c7r1b_TA_tex_txt, - kan_tizu_c7r1b_TA_tex_txt, - kan_tizu_mwf_TA_tex_txt, - kan_tizu_mwf_TA_tex_txt, - kan_tizu_mwf_TA_tex_txt, - kan_tizu_mwf_TA_tex_txt, - kan_tizu_mwf_TA_tex_txt, - kan_tizu_c1r2b_TA_tex_txt, - kan_tizu_c4r2b_TA_tex_txt, - kan_tizu_c5r2b_TA_tex_txt + kan_tizu_f_TA_tex_txt, kan_tizu_f_TA_tex_txt, kan_tizu_f_TA_tex_txt, kan_tizu_f_TA_tex_txt, + kan_tizu_f_TA_tex_txt, kan_tizu_f_TA_tex_txt, kan_tizu_f_TA_tex_txt, kan_tizu_f_TA_tex_txt, + kan_tizu_f_TA_tex_txt, kan_tizu_f_TA_tex_txt, kan_tizu_f_TA_tex_txt, kan_tizu_tst1_TA_tex_txt, + kan_tizu_t_TA_tex_txt, kan_tizu_tr1_TA_tex_txt, kan_tizu_fmh_TA_tex_txt, kan_tizu_c1_TA_tex_txt, + kan_tizu_c2_TA_tex_txt, kan_tizu_c3_TA_tex_txt, kan_tizu_c4_TA_tex_txt, kan_tizu_c5_TA_tex_txt, + kan_tizu_c6_TA_tex_txt, kan_tizu_c7_TA_tex_txt, kan_tizu_c1r1_TA_tex_txt, kan_tizu_c2r1_TA_tex_txt, + kan_tizu_c3r1_TA_tex_txt, kan_tizu_c4r1_TA_tex_txt, kan_tizu_c5r1_TA_tex_txt, kan_tizu_c6r1_TA_tex_txt, + kan_tizu_c7r1_TA_tex_txt, kan_tizu_c1r2_TA_tex_txt, kan_tizu_c2r2_TA_tex_txt, kan_tizu_c3r2_TA_tex_txt, + kan_tizu_c4r2_TA_tex_txt, kan_tizu_c5r2_TA_tex_txt, kan_tizu_c1r2_TA_tex_txt, kan_tizu_c4r2_TA_tex_txt, + kan_tizu_c5r2_TA_tex_txt, kan_tizu_c6r3_TA_tex_txt, kan_tizu_c7r3_TA_tex_txt, kan_tizu_f_TA_tex_txt, + kan_tizu_r1_TA_tex_txt, kan_tizu_r2_TA_tex_txt, kan_tizu_r2_TA_tex_txt, kan_tizu_r4_TA_tex_txt, + kan_tizu_r5_TA_tex_txt, kan_tizu_r6_TA_tex_txt, kan_tizu_r7_TA_tex_txt, kan_tizu_r1b_TA_tex_txt, + kan_tizu_r2b_TA_tex_txt, kan_tizu_r2b_TA_tex_txt, kan_tizu_r4b_TA_tex_txt, kan_tizu_r5b_TA_tex_txt, + kan_tizu_r6b_TA_tex_txt, kan_tizu_r7b_TA_tex_txt, kan_tizu_c1s_TA_tex_txt, kan_tizu_c2s_TA_tex_txt, + kan_tizu_c3s_TA_tex_txt, kan_tizu_c4s_TA_tex_txt, kan_tizu_c5s_TA_tex_txt, kan_tizu_c6s_TA_tex_txt, + kan_tizu_c7s_TA_tex_txt, kan_tizu_f_TA_tex_txt, kan_tizu_f_TA_tex_txt, kan_tizu_m_TA_tex_txt, + kan_tizu_mr1_TA_tex_txt, kan_tizu_fsh_TA_tex_txt, kan_tizu_fpk_TA_tex_txt, kan_tizu_fpo_TA_tex_txt, + kan_tizu_fko_TA_tex_txt, kan_tizu_pr1_TA_tex_txt, kan_tizu_pr2_TA_tex_txt, kan_tizu_pr2_TA_tex_txt, + kan_tizu_pr4_TA_tex_txt, kan_tizu_pr5_TA_tex_txt, kan_tizu_pr6_TA_tex_txt, kan_tizu_pr7_TA_tex_txt, + kan_tizu_f_TA_tex_txt, kan_tizu_r1_TA_tex_txt, kan_tizu_c1_TA_tex_txt, kan_tizu_c1_TA_tex_txt, + kan_tizu_c1_TA_tex_txt, kan_tizu_c1_TA_tex_txt, kan_tizu_mr1b_TA_tex_txt, kan_tizu_mr1_TA_tex_txt, + kan_tizu_fmu_TA_tex_txt, kan_tizu_fta_TA_tex_txt, kan_tizu_tr1b_TA_tex_txt, kan_tizu_c1r2b_TA_tex_txt, + kan_tizu_c3r1b_TA_tex_txt, kan_tizu_c4r1b_TA_tex_txt, kan_tizu_c4r2b_TA_tex_txt, kan_tizu_c5r2b_TA_tex_txt, + kan_tizu_c6r1b_TA_tex_txt, kan_tizu_c7r1b_TA_tex_txt, kan_tizu_c7r1b_TA_tex_txt, kan_tizu_c7r1b_TA_tex_txt, + kan_tizu_c7r1b_TA_tex_txt, kan_tizu_c7r1b_TA_tex_txt, kan_tizu_c7r1b_TA_tex_txt, kan_tizu_c7r1b_TA_tex_txt, + kan_tizu_mwf_TA_tex_txt, kan_tizu_mwf_TA_tex_txt, kan_tizu_mwf_TA_tex_txt, kan_tizu_mwf_TA_tex_txt, + kan_tizu_mwf_TA_tex_txt, kan_tizu_c1r2b_TA_tex_txt, kan_tizu_c4r2b_TA_tex_txt, kan_tizu_c5r2b_TA_tex_txt }; -static u8 l_map_pal[mFM_BLOCK_TYPE_NUM] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, - 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0 -}; +static u8 l_map_pal[mFM_BLOCK_TYPE_NUM] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, + 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0 }; static u8 pluss_bridge[mFM_BLOCK_TYPE_NUM] = { - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x56, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x58, 0x59, 0xff, 0x5c, 0x5d, 0x57, 0xff, 0xff, - 0x5a, 0x5b, 0x69, 0x6a, 0x6b, 0xff, 0xff, 0xff, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x52, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x56, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x58, 0x59, 0xff, 0x5c, 0x5d, 0x57, 0xff, 0xff, 0x5a, 0x5b, 0x69, 0x6a, + 0x6b, 0xff, 0xff, 0xff, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x52, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; extern Gfx kan_win_model[]; @@ -242,19 +156,13 @@ extern mMP_HousePos_c mMP_house_pos_list[]; extern Gfx kan_win_mode[]; -static u16 kan_tizu1_pal[16] ATTRIBUTE_ALIGN(32) = { - 0x0000, 0xc3b0, 0x9e87, 0xd294, 0xca52, 0xbdef, 0xb5ad, 0xb9ce, - 0xa2e8, 0xb18c, 0xa705, 0xdaff, 0xab4a, 0xffff, 0xb635, 0xbe9f -}; +static u16 kan_tizu1_pal[16] ATTRIBUTE_ALIGN(32) = { 0x0000, 0xc3b0, 0x9e87, 0xd294, 0xca52, 0xbdef, 0xb5ad, 0xb9ce, + 0xa2e8, 0xb18c, 0xa705, 0xdaff, 0xab4a, 0xffff, 0xb635, 0xbe9f }; -static u16 kan_tizu2_pal[16] ATTRIBUTE_ALIGN(32) = { - 0x0000, 0xc3b0, 0x9e87, 0xc94a, 0xe70d, 0xe1ce, 0xb5ad, 0xb195, - 0xf390, 0xb18c, 0xa705, 0xffff, 0xd54a, 0xdaff, 0xb635, 0xbe9f -}; +static u16 kan_tizu2_pal[16] ATTRIBUTE_ALIGN(32) = { 0x0000, 0xc3b0, 0x9e87, 0xc94a, 0xe70d, 0xe1ce, 0xb5ad, 0xb195, + 0xf390, 0xb18c, 0xa705, 0xffff, 0xd54a, 0xdaff, 0xb635, 0xbe9f }; -static u16* l_kan_tizu_pal[2] = { - kan_tizu1_pal, kan_tizu2_pal -}; +static u16* l_kan_tizu_pal[2] = { kan_tizu1_pal, kan_tizu2_pal }; extern u8 kan_win_suuji1_tex_rgb_ia8[]; extern u8 kan_win_suuji2_tex_rgb_ia8[]; @@ -263,11 +171,8 @@ extern u8 kan_win_suuji4_tex_rgb_ia8[]; extern u8 kan_win_suuji5_tex_rgb_ia8[]; static u8* kan_win_evw_anime_1_tex_table[FG_BLOCK_X_NUM] = { - kan_win_suuji1_tex_rgb_ia8, - kan_win_suuji2_tex_rgb_ia8, - kan_win_suuji3_tex_rgb_ia8, - kan_win_suuji4_tex_rgb_ia8, - kan_win_suuji5_tex_rgb_ia8, + kan_win_suuji1_tex_rgb_ia8, kan_win_suuji2_tex_rgb_ia8, kan_win_suuji3_tex_rgb_ia8, + kan_win_suuji4_tex_rgb_ia8, kan_win_suuji5_tex_rgb_ia8, }; extern u8 kan_win_a_tex_rgb_ia8[]; @@ -278,12 +183,8 @@ extern u8 kan_win_e_tex_rgb_ia8[]; extern u8 kan_win_f_tex_rgb_ia8[]; static u8* kan_win_evw_anime_2_tex_table[FG_BLOCK_Z_NUM] = { - kan_win_a_tex_rgb_ia8, - kan_win_b_tex_rgb_ia8, - kan_win_c_tex_rgb_ia8, - kan_win_d_tex_rgb_ia8, - kan_win_e_tex_rgb_ia8, - kan_win_f_tex_rgb_ia8, + kan_win_a_tex_rgb_ia8, kan_win_b_tex_rgb_ia8, kan_win_c_tex_rgb_ia8, + kan_win_d_tex_rgb_ia8, kan_win_e_tex_rgb_ia8, kan_win_f_tex_rgb_ia8, }; extern Gfx kan_win_npcT_1_model[]; @@ -294,17 +195,9 @@ extern Gfx kan_win_npc2T_1_model[]; extern Gfx kan_win_npc2T_2_model[]; extern Gfx kan_win_npc2T_3_model[]; -static Gfx* kan_win_npcT_table[] = { - kan_win_npcT_1_model, - kan_win_npcT_2_model, - kan_win_npcT_3_model -}; +static Gfx* kan_win_npcT_table[] = { kan_win_npcT_1_model, kan_win_npcT_2_model, kan_win_npcT_3_model }; -static Gfx* kan_win_npc2T_table[] = { - kan_win_npc2T_1_model, - kan_win_npc2T_2_model, - kan_win_npc2T_3_model -}; +static Gfx* kan_win_npc2T_table[] = { kan_win_npc2T_1_model, kan_win_npc2T_2_model, kan_win_npc2T_3_model }; extern Gfx kan_win_genzaiT_model[]; @@ -324,1053 +217,860 @@ extern Gfx kan_win_mu_model[]; extern Gfx kan_win_ta_model[]; extern Gfx kan_win_funeT_model[]; -static mMP_LabelWord_c mMP_label_word_npc = { - -92.0f, -19.0f, - NULL, 0 -}; +static mMP_LabelWord_c mMP_label_word_npc = { -92.0f, -19.0f, NULL, 0 }; -static mMP_Label_c mMP_label_npc = { - -98.0f, -24.0f, - kan_win_npcT_1_model, - { &mMP_label_word_npc, NULL } -}; +static mMP_Label_c mMP_label_npc = { -98.0f, -24.0f, kan_win_npcT_1_model, { &mMP_label_word_npc, NULL } }; -static mMP_LabelWord_c mMP_label_word_player = { - -92.0f, -21.5f, - NULL, 0 -}; +static mMP_LabelWord_c mMP_label_word_player = { -92.0f, -21.5f, NULL, 0 }; -static mMP_Label_c mMP_label_player = { - -98.0f, -26.5f, - kan_win_playerT_model, - { &mMP_label_word_player, NULL } -}; +static mMP_Label_c mMP_label_player = { -98.0f, -26.5f, kan_win_playerT_model, { &mMP_label_word_player, NULL } }; static u8 mMP_label_str_shop[4] = { CHAR_S, CHAR_h, CHAR_o, CHAR_p }; -static mMP_LabelWord_c mMP_label_word_shop = { - -83.0f, -25.0f, - mMP_label_str_shop, 4 -}; +static mMP_LabelWord_c mMP_label_word_shop = { -83.0f, -25.0f, mMP_label_str_shop, 4 }; -static mMP_Label_c mMP_label_shop = { - -93.0f, -30.0f, - kan_win_omiseT_model, - { &mMP_label_word_shop, NULL } -}; +static mMP_Label_c mMP_label_shop = { -93.0f, -30.0f, kan_win_omiseT_model, { &mMP_label_word_shop, NULL } }; static u8 mMP_label_str_police[6] = { CHAR_P, CHAR_o, CHAR_l, CHAR_i, CHAR_c, CHAR_e }; -static mMP_LabelWord_c mMP_label_word_police = { - -83.0f, -19.0f, - mMP_label_str_police, 6 -}; +static mMP_LabelWord_c mMP_label_word_police = { -83.0f, -19.0f, mMP_label_str_police, 6 }; static u8 mMP_label_str_police2[7] = { CHAR_S, CHAR_t, CHAR_a, CHAR_t, CHAR_i, CHAR_o, CHAR_n }; -static mMP_LabelWord_c mMP_label_word_police2 = { - -83.0f, -31.0f, - mMP_label_str_police2, 7 -}; +static mMP_LabelWord_c mMP_label_word_police2 = { -83.0f, -31.0f, mMP_label_str_police2, 7 }; static mMP_Label_c mMP_label_police = { - -93.0f, -30.0f, - kan_win_koubanT_model, - { &mMP_label_word_police, &mMP_label_word_police2 } + -93.0f, -30.0f, kan_win_koubanT_model, { &mMP_label_word_police, &mMP_label_word_police2 } }; static u8 mMP_label_str_post[4] = { CHAR_P, CHAR_o, CHAR_s, CHAR_t }; -static mMP_LabelWord_c mMP_label_word_post = { - -83.0f, -19.0f, - mMP_label_str_post, 4 -}; +static mMP_LabelWord_c mMP_label_word_post = { -83.0f, -19.0f, mMP_label_str_post, 4 }; static u8 mMP_label_str_post2[6] = { CHAR_O, CHAR_f, CHAR_f, CHAR_i, CHAR_c, CHAR_e }; -static mMP_LabelWord_c mMP_label_word_post2 = { - -83.0f, -31.0f, - mMP_label_str_post2, 6 -}; +static mMP_LabelWord_c mMP_label_word_post2 = { -83.0f, -31.0f, mMP_label_str_post2, 6 }; static mMP_Label_c mMP_label_post = { - -93.0f, -30.0f, - kan_win_yuuT_model, - { &mMP_label_word_post, &mMP_label_word_post2 } + -93.0f, -30.0f, kan_win_yuuT_model, { &mMP_label_word_post, &mMP_label_word_post2 } }; static u8 mMP_label_str_shrine[7] = { CHAR_W, CHAR_i, CHAR_s, CHAR_h, CHAR_i, CHAR_n, CHAR_g }; -static mMP_LabelWord_c mMP_label_word_shrine = { - -83.0f, -19.0f, - mMP_label_str_shrine, 7 -}; +static mMP_LabelWord_c mMP_label_word_shrine = { -83.0f, -19.0f, mMP_label_str_shrine, 7 }; static u8 mMP_label_str_shrine2[4] = { CHAR_W, CHAR_e, CHAR_l, CHAR_l }; -static mMP_LabelWord_c mMP_label_word_shrine2 = { - -83.0f, -31.0f, - mMP_label_str_shrine2, 4 -}; +static mMP_LabelWord_c mMP_label_word_shrine2 = { -83.0f, -31.0f, mMP_label_str_shrine2, 4 }; static mMP_Label_c mMP_label_shrine = { - -93.0f, -30.0f, - kan_win_yashiroT_model, - { &mMP_label_word_shrine, & mMP_label_word_shrine2 } + -93.0f, -30.0f, kan_win_yashiroT_model, { &mMP_label_word_shrine, &mMP_label_word_shrine2 } }; static u8 mMP_label_str_station[5] = { CHAR_T, CHAR_r, CHAR_a, CHAR_i, CHAR_n }; -static mMP_LabelWord_c mMP_label_word_station = { - -83.0f, -19.0f, - mMP_label_str_station, 5 -}; +static mMP_LabelWord_c mMP_label_word_station = { -83.0f, -19.0f, mMP_label_str_station, 5 }; static u8 mMP_label_str_station2[7] = { CHAR_S, CHAR_t, CHAR_a, CHAR_t, CHAR_i, CHAR_o, CHAR_n }; -static mMP_LabelWord_c mMP_label_word_station2 = { - -83.0f, -31.0f, - mMP_label_str_station2, 7 -}; +static mMP_LabelWord_c mMP_label_word_station2 = { -83.0f, -31.0f, mMP_label_str_station2, 7 }; static mMP_Label_c mMP_label_station = { - -93.0f, -31.0f, - kan_win_ekiT_model, - { &mMP_label_word_station, &mMP_label_word_station2 } + -93.0f, -31.0f, kan_win_ekiT_model, { &mMP_label_word_station, &mMP_label_word_station2 } }; static u8 mMP_label_str_junk[4] = { CHAR_D, CHAR_u, CHAR_m, CHAR_p }; -static mMP_LabelWord_c mMP_label_word_junk = { - -83.0f, -25.0f, - mMP_label_str_junk, 4 -}; +static mMP_LabelWord_c mMP_label_word_junk = { -83.0f, -25.0f, mMP_label_str_junk, 4 }; -static mMP_Label_c mMP_label_junk = { - -93.0f, -30.0f, - kan_win_gomiT_model, - { &mMP_label_word_junk, NULL } -}; +static mMP_Label_c mMP_label_junk = { -93.0f, -30.0f, kan_win_gomiT_model, { &mMP_label_word_junk, NULL } }; static u8 mMP_label_str_museum[6] = { CHAR_M, CHAR_u, CHAR_s, CHAR_e, CHAR_u, CHAR_m }; -static mMP_LabelWord_c mMP_label_word_museum = { - -83.0f, -25.0f, - mMP_label_str_museum, 6 -}; +static mMP_LabelWord_c mMP_label_word_museum = { -83.0f, -25.0f, mMP_label_str_museum, 6 }; -static mMP_Label_c mMP_label_museum = { - -93.0f, -30.0f, - kan_win_mu_model, - { &mMP_label_word_museum, NULL } -}; +static mMP_Label_c mMP_label_museum = { -93.0f, -30.0f, kan_win_mu_model, { &mMP_label_word_museum, NULL } }; static u8 mMP_label_str_needle[6] = { CHAR_T, CHAR_a, CHAR_i, CHAR_l, CHAR_o, CHAR_r }; -static mMP_LabelWord_c mMP_label_word_needle = { - -83.0f, -25.0f, - mMP_label_str_needle, 6 -}; +static mMP_LabelWord_c mMP_label_word_needle = { -83.0f, -25.0f, mMP_label_str_needle, 6 }; -static mMP_Label_c mMP_label_needle = { - -93.0f, -30.0f, - kan_win_ta_model, - { &mMP_label_word_needle, NULL } -}; +static mMP_Label_c mMP_label_needle = { -93.0f, -30.0f, kan_win_ta_model, { &mMP_label_word_needle, NULL } }; static u8 mMP_label_str_port[4] = { CHAR_D, CHAR_o, CHAR_c, CHAR_k }; -static mMP_LabelWord_c mMP_label_word_port = { - -83.0f, -25.0f, - mMP_label_str_port, 4 -}; +static mMP_LabelWord_c mMP_label_word_port = { -83.0f, -25.0f, mMP_label_str_port, 4 }; -static mMP_Label_c mMP_label_port = { - -93.0f, -30.0f, - kan_win_funeT_model, - { &mMP_label_word_port, NULL } -}; +static mMP_Label_c mMP_label_port = { -93.0f, -30.0f, kan_win_funeT_model, { &mMP_label_word_port, NULL } }; -static mMP_Label_c* mMP_label_data[mMP_LABEL_NUM] = { - &mMP_label_npc, - &mMP_label_player, - &mMP_label_shop, - &mMP_label_police, - &mMP_label_post, - &mMP_label_shrine, - &mMP_label_station, - &mMP_label_junk, - &mMP_label_museum, - &mMP_label_needle, - &mMP_label_port -}; +static mMP_Label_c* mMP_label_data[mMP_LABEL_NUM] = { &mMP_label_npc, &mMP_label_player, &mMP_label_shop, + &mMP_label_police, &mMP_label_post, &mMP_label_shrine, + &mMP_label_station, &mMP_label_junk, &mMP_label_museum, + &mMP_label_needle, &mMP_label_port }; static int mMP_check_layer(f32 y) { - int layer; + int layer; - switch (mCoBG_Height2GetLayer(y)) { - case mCoBG_LAYER0: - layer = 2; - break; - case mCoBG_LAYER1: - layer = 1; - break; - case mCoBG_LAYER2: - layer = 0; - break; - default: - layer = 1; - break; - } + switch (mCoBG_Height2GetLayer(y)) { + case mCoBG_LAYER0: + layer = 2; + break; + case mCoBG_LAYER1: + layer = 1; + break; + case mCoBG_LAYER2: + layer = 0; + break; + default: + layer = 1; + break; + } - if (mRF_CheckFieldStep3() == FALSE) { - layer--; - } + if (mRF_CheckFieldStep3() == FALSE) { + layer--; + } - if (layer < 0) { - layer = 0; - } + if (layer < 0) { + layer = 0; + } - return layer; + return layer; } static int mMP_check_bg_kind(u8 kind) { - int res = TRUE; - if (kind <= 8 || kind == 0x3D || kind == 0x3E || kind == 9 || kind == 10) { - res = FALSE; - } + int res = TRUE; + if (kind <= 8 || kind == 0x3D || kind == 0x3E || kind == 9 || kind == 10) { + res = FALSE; + } - return res; + return res; } static void mMP_make_max_no_table(int* max_no_table, int count) { - int bz; - int i; - int j = 0; + int bz; + int i; + int j = 0; - for (i = 0; i < count; i++) { - max_no_table[i] = 39; - } - - //i = BLOCKXZ_2_BLOCKIDX(0, 1); - for (bz = 1; bz < mMP_BLOCKZ_MAX; bz++) { - u8 type; - int bx; - for (bx = 1; bx < mMP_BLOCKX_MAX; bx++) { - type = g_block_type_p[BLOCKXZ_2_BLOCKIDX(bx, bz)]; - if (mMP_check_bg_kind(type) == TRUE) { - max_no_table[0] = type; - - if (Save_Get(bridge.exists) && - Save_Get(bridge.block_x) == bx && - Save_Get(bridge.block_z) == bz && - pluss_bridge[type] != 0xFF - ) { - max_no_table[0] = pluss_bridge[type]; - } - - max_no_table++; - j++; - } - - if (j >= count) { - return; - } + for (i = 0; i < count; i++) { + max_no_table[i] = 39; + } + + // i = BLOCKXZ_2_BLOCKIDX(0, 1); + for (bz = 1; bz < mMP_BLOCKZ_MAX; bz++) { + u8 type; + int bx; + for (bx = 1; bx < mMP_BLOCKX_MAX; bx++) { + type = g_block_type_p[BLOCKXZ_2_BLOCKIDX(bx, bz)]; + if (mMP_check_bg_kind(type) == TRUE) { + max_no_table[0] = type; + + if (Save_Get(bridge.exists) && Save_Get(bridge.block_x) == bx && Save_Get(bridge.block_z) == bz && + pluss_bridge[type] != 0xFF) { + max_no_table[0] = pluss_bridge[type]; + } + + max_no_table++; + j++; + } + + if (j >= count) { + return; + } + } } - } } static void mMP_dma_texture(u8** texture_pp, int type) { - *texture_pp = l_map_texture[type]; + *texture_pp = l_map_texture[type]; } static void mMP_set_map_texture_pal(mMP_Overlay_c* map_ovl) { - int max_no_table[FG_BLOCK_TOTAL_NUM]; - int i; + int max_no_table[FG_BLOCK_TOTAL_NUM]; + int i; - mMP_make_max_no_table(max_no_table, FG_BLOCK_TOTAL_NUM); - for (i = 0; i < FG_BLOCK_TOTAL_NUM; i++) { - map_ovl->map_pal[i] = l_map_pal[max_no_table[i]]; - mMP_dma_texture(&map_ovl->map_texture[i], max_no_table[i]); - } + mMP_make_max_no_table(max_no_table, FG_BLOCK_TOTAL_NUM); + for (i = 0; i < FG_BLOCK_TOTAL_NUM; i++) { + map_ovl->map_pal[i] = l_map_pal[max_no_table[i]]; + mMP_dma_texture(&map_ovl->map_texture[i], max_no_table[i]); + } } static mActor_name_t mMP_GetFgBlockName(mMP_Overlay_c* map_ovl, int block_x, int block_z) { - return map_ovl->combination_table[Save_Get(combi_table[block_z][block_x]).combination_type].fg_id; + return map_ovl->combination_table[Save_Get(combi_table[block_z][block_x]).combination_type].fg_id; } static void mMP_set_house_data(mMP_Overlay_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] = { CHAR_f, CHAR_r, CHAR_e, CHAR_e, + CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE }; - 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); - mMP_HousePos_c* house_pos2; - Animal_c* animal = Save_Get(animals); - int residents; - int i; + 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; + int i; - /* Process player resident info first */ + /* Process player resident info first */ - player_block_label->label_cnt = PLAYER_NUM; - player_block_label->label_no = mMP_LABEL_PLAYER; + player_block_label->label_cnt = PLAYER_NUM; + player_block_label->label_no = mMP_LABEL_PLAYER; - residents = 0; - for (i = 0; i < PLAYER_NUM; i++) { - 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; + residents = 0; + for (i = 0; i < PLAYER_NUM; i++) { + 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; - residents++; - resident_p++; - } - - priv++; - } - - for (residents; residents < PLAYER_NUM; residents++, resident_p++) { - mPr_CopyPlayerName(resident_p->name, akiya_str); - resident_p->sex = -1; - resident_p->house_layer = 0; - - player_block_label->residents[residents] = resident_p; - } - - house_pos2 = 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; - 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; - - 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 (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; - } + player_block_label->residents[residents] = resident_p; + residents++; + resident_p++; } - 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]; - - label_info->residents[label_info->label_cnt] = resident_p; - label_info->label_cnt++; - label_info->label_no = mMP_LABEL_NPC; - } + priv++; } - } - /* 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]; + for (residents; residents < PLAYER_NUM; residents++, resident_p++) { + mPr_CopyPlayerName(resident_p->name, akiya_str); + resident_p->sex = -1; + resident_p->house_layer = 0; - if (resident->house_layer > next_resident->house_layer) { - label_info->residents[j] = next_resident; - label_info->residents[j + 1] = resident; - j = -1; - } + player_block_label->residents[residents] = resident_p; + } + + house_pos2 = 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; + 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; + + 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 (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; + } + } + + 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]; + + label_info->residents[label_info->label_cnt] = resident_p; + label_info->label_cnt++; + label_info->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; + } + } + } + + label_info++; } - } - - label_info++; } - } } static void mMP_set_field_data(mMP_Overlay_c* map_ovl) { - mMP_LabelInfo_c* label_info = (mMP_LabelInfo_c*)map_ovl->label_info; - int* block_kind_p = g_block_kind_p + BLOCKXZ_2_BLOCKIDX(1, 1); // start at the first non-border acre - int bx; - int bz; + mMP_LabelInfo_c* label_info = (mMP_LabelInfo_c*)map_ovl->label_info; + int* block_kind_p = g_block_kind_p + BLOCKXZ_2_BLOCKIDX(1, 1); // start at the first non-border acre + int bx; + int bz; + for (bz = 0; bz < FG_BLOCK_Z_NUM; bz++) { + for (bx = 0; bx < FG_BLOCK_X_NUM; bx++) { + if (label_info->label_cnt <= 0) { + int kind = *block_kind_p; - for (bz = 0; bz < FG_BLOCK_Z_NUM; bz++) { - for (bx = 0; bx < FG_BLOCK_X_NUM; bx++) { - if (label_info->label_cnt <= 0) { - int kind = *block_kind_p; + if (kind & mRF_BLOCKKIND_SHOP) { + label_info->label_no = mMP_LABEL_SHOP; + label_info->label_cnt = 2; + } else if (kind & mRF_BLOCKKIND_POLICE) { + label_info->label_no = mMP_LABEL_POLICE; + label_info->label_cnt = 2; + } else if (kind & mRF_BLOCKKIND_POSTOFFICE) { + label_info->label_no = mMP_LABEL_POST; + label_info->label_cnt = 2; + } else if (kind & mRF_BLOCKKIND_SHRINE) { + label_info->label_no = mMP_LABEL_SHRINE; + label_info->label_cnt = 2; + } else if (kind & mRF_BLOCKKIND_STATION) { + label_info->label_no = mMP_LABEL_STATION; + label_info->label_cnt = 2; + } else if (kind & mRF_BLOCKKIND_DUMP) { + label_info->label_no = mMP_LABEL_JUNK; + label_info->label_cnt = 2; + } else if (kind & mRF_BLOCKKIND_MUSEUM) { + label_info->label_no = mMP_LABEL_MUSEUM; + label_info->label_cnt = 2; + } else if (kind & mRF_BLOCKKIND_TAILORS) { + label_info->label_no = mMP_LABEL_NEEDLE; + label_info->label_cnt = 2; + } else if (kind & mRF_BLOCKKIND_DOCK) { + label_info->label_no = mMP_LABEL_PORT; + label_info->label_cnt = 2; + } + } - if (kind & mRF_BLOCKKIND_SHOP) { - label_info->label_no = mMP_LABEL_SHOP; - label_info->label_cnt = 2; - } - else if (kind & mRF_BLOCKKIND_POLICE) { - label_info->label_no = mMP_LABEL_POLICE; - label_info->label_cnt = 2; - } - else if (kind & mRF_BLOCKKIND_POSTOFFICE) { - label_info->label_no = mMP_LABEL_POST; - label_info->label_cnt = 2; - } - else if (kind & mRF_BLOCKKIND_SHRINE) { - label_info->label_no = mMP_LABEL_SHRINE; - label_info->label_cnt = 2; - } - else if (kind & mRF_BLOCKKIND_STATION) { - label_info->label_no = mMP_LABEL_STATION; - label_info->label_cnt = 2; - } - else if (kind & mRF_BLOCKKIND_DUMP) { - label_info->label_no = mMP_LABEL_JUNK; - label_info->label_cnt = 2; - } - else if (kind & mRF_BLOCKKIND_MUSEUM) { - label_info->label_no = mMP_LABEL_MUSEUM; - label_info->label_cnt = 2; - } - else if (kind & mRF_BLOCKKIND_TAILORS) { - label_info->label_no = mMP_LABEL_NEEDLE; - label_info->label_cnt = 2; - } - else if (kind & mRF_BLOCKKIND_DOCK) { - label_info->label_no = mMP_LABEL_PORT; - label_info->label_cnt = 2; - } - } - - label_info++; - block_kind_p++; + label_info++; + block_kind_p++; + } + + block_kind_p += 2; // skip X border acres } - - block_kind_p += 2; // skip X border acres - } } static void mMP_set_init_data(mMP_Overlay_c* map_ovl, mSM_MenuInfo_c* menu_info) { - mMP_LabelInfo_c* label_info = (mMP_LabelInfo_c*)map_ovl->label_info; - PLAYER_ACTOR* player = get_player_actor_withoutCheck((GAME_PLAY*)gamePT); - int block_x; - int block_z; - int i; + mMP_LabelInfo_c* label_info = (mMP_LabelInfo_c*)map_ovl->label_info; + PLAYER_ACTOR* player = get_player_actor_withoutCheck((GAME_PLAY*)gamePT); + int block_x; + int block_z; + int i; - if (Common_Get(field_type) != mFI_FIELDTYPE2_FG && Common_Get(door_data.next_scene_id) != 0) { - xyz_t pos; + if (Common_Get(field_type) != mFI_FIELDTYPE2_FG && Common_Get(door_data.next_scene_id) != 0) { + xyz_t pos; - xyz_t_move_s_xyz(&pos, Common_GetPointer(structure_exit_door_data.exit_position)); - mFI_Wpos2BlockNum(&block_x, &block_z, pos); - } - else { - mFI_Wpos2BlockNum(&block_x, &block_z, player->actor_class.world.position); - } + xyz_t_move_s_xyz(&pos, Common_GetPointer(structure_exit_door_data.exit_position)); + mFI_Wpos2BlockNum(&block_x, &block_z, pos); + } else { + mFI_Wpos2BlockNum(&block_x, &block_z, player->actor_class.world.position); + } - map_ovl->player_bx = block_x - 1; - map_ovl->player_bz = block_z - 1; + map_ovl->player_bx = block_x - 1; + map_ovl->player_bz = block_z - 1; - map_ovl->sel_bx = map_ovl->player_bx; - map_ovl->sel_bz = map_ovl->player_bz; + map_ovl->sel_bx = map_ovl->player_bx; + map_ovl->sel_bz = map_ovl->player_bz; - map_ovl->map_cursor_current_xpos = (f32)map_ovl->player_bx * mMP_BLOCK_SIZE_F; - map_ovl->map_cursor_current_zpos = -(f32)map_ovl->player_bz * mMP_BLOCK_SIZE_F; + map_ovl->map_cursor_current_xpos = (f32)map_ovl->player_bx * mMP_BLOCK_SIZE_F; + map_ovl->map_cursor_current_zpos = -(f32)map_ovl->player_bz * mMP_BLOCK_SIZE_F; - map_ovl->cursor_frame = 0; - - map_ovl->map_cursor_target_xpos = map_ovl->map_cursor_current_xpos; - map_ovl->map_cursor_target_zpos = map_ovl->map_cursor_current_zpos; + map_ovl->cursor_frame = 0; - mMP_set_map_texture_pal(map_ovl); + map_ovl->map_cursor_target_xpos = map_ovl->map_cursor_current_xpos; + map_ovl->map_cursor_target_zpos = map_ovl->map_cursor_current_zpos; - for (i = 0; i < FG_BLOCK_TOTAL_NUM; i++) { - label_info->label_cnt = 0; - label_info++; - } + mMP_set_map_texture_pal(map_ovl); - mMP_set_house_data(map_ovl, menu_info); - mMP_set_field_data(map_ovl); + for (i = 0; i < FG_BLOCK_TOTAL_NUM; i++) { + label_info->label_cnt = 0; + label_info++; + } - map_ovl->land_name_str_len = mMl_strlen(Save_Get(land_info.name), LAND_NAME_SIZE, CHAR_SPACE); + mMP_set_house_data(map_ovl, menu_info); + mMP_set_field_data(map_ovl); + + map_ovl->land_name_str_len = mMl_strlen(Save_Get(land_info.name), LAND_NAME_SIZE, CHAR_SPACE); } static void mMP_move_Move(Submenu* submenu, mSM_MenuInfo_c* menu) { - (*submenu->overlay->move_Move_proc)(submenu, menu); + (*submenu->overlay->move_Move_proc)(submenu, menu); } static void mMP_move_Play(Submenu* submenu, mSM_MenuInfo_c* menu) { - Submenu_Overlay_c* ovl = submenu->overlay; - int trigger = ovl->menu_control.trigger; - mMP_Overlay_c* map_ovl = ovl->map_ovl; - int cursor_moved = FALSE; + Submenu_Overlay_c* ovl = submenu->overlay; + int trigger = ovl->menu_control.trigger; + mMP_Overlay_c* map_ovl = ovl->map_ovl; + int cursor_moved = FALSE; - if ((trigger & (BUTTON_A | BUTTON_B | BUTTON_START)) || (menu->data0 == 1 && (trigger & BUTTON_X))) { - (*ovl->move_chg_base_proc)(menu, mSM_MOVE_OUT_TOP); - sAdo_SysTrgStart(0x17D); - } - else if (trigger & BUTTON_CLEFT) { - if (map_ovl->sel_bx != 0) { - map_ovl->sel_bx--; - map_ovl->map_cursor_target_xpos -= mMP_BLOCK_SIZE_F; - cursor_moved = TRUE; + if ((trigger & (BUTTON_A | BUTTON_B | BUTTON_START)) || (menu->data0 == 1 && (trigger & BUTTON_X))) { + (*ovl->move_chg_base_proc)(menu, mSM_MOVE_OUT_TOP); + sAdo_SysTrgStart(0x17D); + } else if (trigger & BUTTON_CLEFT) { + if (map_ovl->sel_bx != 0) { + map_ovl->sel_bx--; + map_ovl->map_cursor_target_xpos -= mMP_BLOCK_SIZE_F; + cursor_moved = TRUE; + } + } else if (trigger & BUTTON_CDOWN) { + if (map_ovl->sel_bz < FG_BLOCK_Z_NUM - 1) { + map_ovl->sel_bz++; + map_ovl->map_cursor_target_zpos -= mMP_BLOCK_SIZE_F; + cursor_moved = TRUE; + } + } else if (trigger & BUTTON_CUP) { + if (map_ovl->sel_bz != 0) { + map_ovl->sel_bz--; + map_ovl->map_cursor_target_zpos += mMP_BLOCK_SIZE_F; + cursor_moved = TRUE; + } + } else if (trigger & BUTTON_CRIGHT) { + if (map_ovl->sel_bx < FG_BLOCK_X_NUM - 1) { + map_ovl->sel_bx++; + map_ovl->map_cursor_target_xpos += mMP_BLOCK_SIZE_F; + cursor_moved = TRUE; + } } - } - else if (trigger & BUTTON_CDOWN) { - if (map_ovl->sel_bz < FG_BLOCK_Z_NUM - 1) { - map_ovl->sel_bz++; - map_ovl->map_cursor_target_zpos -= mMP_BLOCK_SIZE_F; - cursor_moved = TRUE; - } - } - else if (trigger & BUTTON_CUP) { - if (map_ovl->sel_bz != 0) { - map_ovl->sel_bz--; - map_ovl->map_cursor_target_zpos += mMP_BLOCK_SIZE_F; - cursor_moved = TRUE; - } - } - else if (trigger & BUTTON_CRIGHT) { - if (map_ovl->sel_bx < FG_BLOCK_X_NUM - 1) { - map_ovl->sel_bx++; - map_ovl->map_cursor_target_xpos += mMP_BLOCK_SIZE_F; - cursor_moved = TRUE; - } - } - if (cursor_moved == TRUE) { - menu->proc_status = 2; // TODO: enum & name - sAdo_SysTrgStart(NA_SE_CURSOL); - } + if (cursor_moved == TRUE) { + menu->proc_status = 2; // TODO: enum & name + sAdo_SysTrgStart(NA_SE_CURSOL); + } - map_ovl->cursor_frame++; - if (map_ovl->cursor_frame >= mMP_CURSOR_FRAMES) { - map_ovl->cursor_frame %= mMP_CURSOR_FRAMES; - } - else if (map_ovl->cursor_frame < 0) { - map_ovl->cursor_frame = 0; - } + map_ovl->cursor_frame++; + if (map_ovl->cursor_frame >= mMP_CURSOR_FRAMES) { + map_ovl->cursor_frame %= mMP_CURSOR_FRAMES; + } else if (map_ovl->cursor_frame < 0) { + map_ovl->cursor_frame = 0; + } } static void mMP_move_Wait(Submenu* submenu, mSM_MenuInfo_c* menu) { - mMP_Overlay_c* map_ovl = submenu->overlay->map_ovl; - f32 x_remain = add_calc(&map_ovl->map_cursor_current_xpos, map_ovl->map_cursor_target_xpos, 0.7f, 19.0f, 1.8f); - f32 z_remain = add_calc(&map_ovl->map_cursor_current_zpos, map_ovl->map_cursor_target_zpos, 0.7f, 19.0f, 1.8f); + mMP_Overlay_c* map_ovl = submenu->overlay->map_ovl; + f32 x_remain = add_calc(&map_ovl->map_cursor_current_xpos, map_ovl->map_cursor_target_xpos, 0.7f, 19.0f, 1.8f); + f32 z_remain = add_calc(&map_ovl->map_cursor_current_zpos, map_ovl->map_cursor_target_zpos, 0.7f, 19.0f, 1.8f); - if (fabsf(x_remain) < 0.1f && fabsf(z_remain) < 0.1f) { - menu->proc_status = 1; - } + if (fabsf(x_remain) < 0.1f && fabsf(z_remain) < 0.1f) { + menu->proc_status = 1; + } } static void mMP_move_End(Submenu* submenu, mSM_MenuInfo_c* menu) { - (*submenu->overlay->move_End_proc)(submenu, menu); + (*submenu->overlay->move_End_proc)(submenu, menu); } typedef void (*mMP_MOVE_PROC)(Submenu*, mSM_MenuInfo_c*); static void mMP_map_ovl_move(Submenu* submenu) { - static mMP_MOVE_PROC ovl_move_proc[5] = { - &mMP_move_Move, - &mMP_move_Play, - &mMP_move_Wait, - (mMP_MOVE_PROC)&none_proc1, - &mMP_move_End - }; + static mMP_MOVE_PROC ovl_move_proc[5] = { &mMP_move_Move, &mMP_move_Play, &mMP_move_Wait, + (mMP_MOVE_PROC)&none_proc1, &mMP_move_End }; - Submenu_Overlay_c* ovl = submenu->overlay; - mSM_MenuInfo_c* menu = &ovl->menu_info[mSM_OVL_MAP]; + Submenu_Overlay_c* ovl = submenu->overlay; + mSM_MenuInfo_c* menu = &ovl->menu_info[mSM_OVL_MAP]; - (*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); } static void mMP_map_draw_init() { - kan_win_wakuT_model_p = kan_win_wakuT_model; - kan_win_waku1T_model_p = kan_waku_w1T_model; - kan_win_waku2T_model_p = kan_waku_w2T_model; - kan_win_waku3T_model_p = kan_waku_w3T_model; - kan_win_waku4T_model_p = kan_waku_w4T_model; - kan_win_color0_mode_p = kan_win_color0_mode; - kan_win_color1_mode_p = kan_win_color1_mode; + kan_win_wakuT_model_p = kan_win_wakuT_model; + kan_win_waku1T_model_p = kan_waku_w1T_model; + kan_win_waku2T_model_p = kan_waku_w2T_model; + kan_win_waku3T_model_p = kan_waku_w3T_model; + kan_win_waku4T_model_p = kan_waku_w4T_model; + kan_win_color0_mode_p = kan_win_color0_mode; + kan_win_color1_mode_p = kan_win_color1_mode; } static int mMP_get_label_cnt(mMP_LabelInfo_c* label_info) { - int label_no = label_info->label_no; - if (label_no == mMP_LABEL_NPC || label_no == mMP_LABEL_PLAYER) { - return label_info->label_cnt; - } + int label_no = label_info->label_no; + if (label_no == mMP_LABEL_NPC || label_no == mMP_LABEL_PLAYER) { + return label_info->label_cnt; + } - return 1; + return 1; } static void mMP_set_house_dl(GRAPH* graph, mMP_Overlay_c* map_ovl, f32 pos_x, f32 pos_y) { - static f32 offset_x[3] = { 5.0f, 13.0f, 17.0f }; - static f32 offset_y[3] = { -4.0f, -11.0f, -18.0f }; + static f32 offset_x[3] = { 5.0f, 13.0f, 17.0f }; + static f32 offset_y[3] = { -4.0f, -11.0f, -18.0f }; - mMP_LabelInfo_c* label_info; - f32 y; - f32 base_x; - f32 temp_x; - f32 base_y; - mMP_ResidentInfo_c** resident_p; - int bz; - int bx; - int i; - Gfx* gfx; + mMP_LabelInfo_c* label_info; + f32 y; + f32 base_x; + f32 temp_x; + f32 base_y; + mMP_ResidentInfo_c** resident_p; + int bz; + int bx; + int i; + Gfx* gfx; - label_info = (mMP_LabelInfo_c*)map_ovl->label_info; + label_info = (mMP_LabelInfo_c*)map_ovl->label_info; - base_y = (pos_y + 45.7f) + (0.5f * mMP_BLOCK_SIZE_F); - base_x = (pos_x + 11.7f) - (0.5f * mMP_BLOCK_SIZE_F); + base_y = (pos_y + 45.7f) + (0.5f * mMP_BLOCK_SIZE_F); + base_x = (pos_x + 11.7f) - (0.5f * mMP_BLOCK_SIZE_F); - OPEN_DISP(graph); + OPEN_DISP(graph); - gfx = NOW_POLY_OPA_DISP; - gSPDisplayList(gfx++, kan_win_mode); + gfx = NOW_POLY_OPA_DISP; + gSPDisplayList(gfx++, kan_win_mode); - /* draw all villager houses */ + /* draw all villager houses */ - for (bz = 0; bz < FG_BLOCK_Z_NUM; bz++) { - temp_x = (pos_x + 11.7f) - (0.5f * mMP_BLOCK_SIZE_F); - for (bx = 0; bx < FG_BLOCK_X_NUM; bx++) { - if (label_info->label_no == mMP_LABEL_NPC) { - resident_p = label_info->residents; + for (bz = 0; bz < FG_BLOCK_Z_NUM; bz++) { + temp_x = (pos_x + 11.7f) - (0.5f * mMP_BLOCK_SIZE_F); + for (bx = 0; bx < FG_BLOCK_X_NUM; bx++) { + if (label_info->label_no == mMP_LABEL_NPC) { + resident_p = label_info->residents; - for (i = 0; i < label_info->label_cnt; i++) { - Matrix_scale(16.0f, 16.0f, 1.0f, 0); - Matrix_translate( - temp_x + offset_x[(*resident_p)->house_idx % 3], - base_y + offset_y[(*resident_p)->house_idx / 3], - 140.0f, - 1 - ); + for (i = 0; i < label_info->label_cnt; i++) { + Matrix_scale(16.0f, 16.0f, 1.0f, 0); + Matrix_translate(temp_x + offset_x[(*resident_p)->house_idx % 3], + base_y + offset_y[(*resident_p)->house_idx / 3], 140.0f, 1); - gSPMatrix(gfx++, _Matrix_to_Mtx_new(graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(gfx++, kan_win_npc2T_table[(*resident_p)->house_layer]); + gSPMatrix(gfx++, _Matrix_to_Mtx_new(graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(gfx++, kan_win_npc2T_table[(*resident_p)->house_layer]); - resident_p++; + resident_p++; + } + } + + temp_x += mMP_BLOCK_SIZE_F; + label_info++; } - } - temp_x += mMP_BLOCK_SIZE_F; - label_info++; + base_y -= mMP_BLOCK_SIZE_F; + // base_x = x_save; } - base_y -= mMP_BLOCK_SIZE_F; - //base_x = x_save; - } + /* draw "current acre" icon */ - /* draw "current acre" icon */ + Matrix_scale(16.0f, 16.0f, 1.0f, 0); + Matrix_translate( + ((pos_x + 11.7f) - (0.5f * mMP_BLOCK_SIZE_F) + (f32)map_ovl->player_bx * mMP_BLOCK_SIZE_F) + 3.0f + 5.0f, + (pos_y + 45.7f - (0.5f * mMP_BLOCK_SIZE_F) - (f32)map_ovl->player_bz * mMP_BLOCK_SIZE_F) + 4.0f + 5.0f, 140.0f, + 1); - Matrix_scale(16.0f, 16.0f, 1.0f, 0); - Matrix_translate( - ((pos_x + 11.7f) - (0.5f * mMP_BLOCK_SIZE_F) + (f32)map_ovl->player_bx * mMP_BLOCK_SIZE_F) + 3.0f + 5.0f, - (pos_y + 45.7f - (0.5f * mMP_BLOCK_SIZE_F) - (f32)map_ovl->player_bz * mMP_BLOCK_SIZE_F) + 4.0f + 5.0f, - 140.0f, - 1 - ); + gSPMatrix(gfx++, _Matrix_to_Mtx_new(graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(gfx++, kan_win_genzaiT_model); - gSPMatrix(gfx++, _Matrix_to_Mtx_new(graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(gfx++, kan_win_genzaiT_model); - - SET_POLY_OPA_DISP(gfx); - CLOSE_DISP(graph); + SET_POLY_OPA_DISP(gfx); + CLOSE_DISP(graph); } static void mMP_set_map_dl(GRAPH* graph, mMP_Overlay_c* map_ovl) { - int bz; - int bx; - int block = 0; - Gfx* gfx; + int bz; + int bx; + int block = 0; + Gfx* gfx; - OPEN_DISP(graph); + OPEN_DISP(graph); - gfx = NOW_POLY_OPA_DISP; - - gDPSetTextureAdjustMode(gfx++, G_TA_DOLPHIN); - gSPDisplayList(gfx++, kan_tizu_mode); - - Matrix_push(); - Matrix_translate(11.7f, 45.7f, 0.0f, 1); + gfx = NOW_POLY_OPA_DISP; - for (bz = 0; bz < FG_BLOCK_Z_NUM; bz++) { - for (bx = 0; bx < FG_BLOCK_X_NUM; bx++) { - gSPSegment(gfx++, G_MWO_SEGMENT_8, map_ovl->map_texture[block]); - gSPSegment(gfx++, G_MWO_SEGMENT_9, l_kan_tizu_pal[map_ovl->map_pal[block]]); - gSPMatrix(gfx++, _Matrix_to_Mtx_new(graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(gfx++, kan_tizu_model); + gDPSetTextureAdjustMode(gfx++, G_TA_DOLPHIN); + gSPDisplayList(gfx++, kan_tizu_mode); - /* move right one acre */ - Matrix_translate(mMP_BLOCK_SIZE_F, 0.0f, 0.0f, 1); - block++; + Matrix_push(); + Matrix_translate(11.7f, 45.7f, 0.0f, 1); + + for (bz = 0; bz < FG_BLOCK_Z_NUM; bz++) { + for (bx = 0; bx < FG_BLOCK_X_NUM; bx++) { + gSPSegment(gfx++, G_MWO_SEGMENT_8, map_ovl->map_texture[block]); + gSPSegment(gfx++, G_MWO_SEGMENT_9, l_kan_tizu_pal[map_ovl->map_pal[block]]); + gSPMatrix(gfx++, _Matrix_to_Mtx_new(graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(gfx++, kan_tizu_model); + + /* move right one acre */ + Matrix_translate(mMP_BLOCK_SIZE_F, 0.0f, 0.0f, 1); + block++; + } + + /* move left to '1' acre and down one acre */ + Matrix_translate((-mMP_BLOCK_SIZE_F) * FG_BLOCK_X_NUM, -mMP_BLOCK_SIZE_F, 0.0f, 1); } - /* move left to '1' acre and down one acre */ - Matrix_translate((-mMP_BLOCK_SIZE_F) * FG_BLOCK_X_NUM, -mMP_BLOCK_SIZE_F, 0.0f, 1); - } + Matrix_pull(); + gDPSetTextureAdjustMode(gfx++, G_TA_N64); - Matrix_pull(); - gDPSetTextureAdjustMode(gfx++, G_TA_N64); - - SET_POLY_OPA_DISP(gfx); - CLOSE_DISP(graph); + SET_POLY_OPA_DISP(gfx); + CLOSE_DISP(graph); } static void mMP_set_cursol_dl(GRAPH* graph, mMP_Overlay_c* map_ovl, f32 base_x, f32 base_y) { - static int col_g[mMP_CURSOR_FRAMES] = { - 0, - 1, - 2, - 5, - 10, - 20, - 50, - 75, - 90, - 100, - 90, - 75, - 50, - 20, - 10, - 5, - 2, - 1 - }; + static int col_g[mMP_CURSOR_FRAMES] = { 0, 1, 2, 5, 10, 20, 50, 75, 90, 100, 90, 75, 50, 20, 10, 5, 2, 1 }; - static f32 cursol_scale[mMP_CURSOR_FRAMES] = { - 1.0f, - 1.015f, - 1.03f, - 1.04f, - 1.05f, - 1.06f, - 1.07f, - 1.08f, - 1.09f, - 1.1f, - 1.09f, - 1.08f, - 1.07f, - 1.06f, - 1.05f, - 1.04f, - 1.03f, - 1.015f - }; + static f32 cursol_scale[mMP_CURSOR_FRAMES] = { 1.0f, 1.015f, 1.03f, 1.04f, 1.05f, 1.06f, 1.07f, 1.08f, 1.09f, + 1.1f, 1.09f, 1.08f, 1.07f, 1.06f, 1.05f, 1.04f, 1.03f, 1.015f }; - f32 x = map_ovl->map_cursor_current_xpos + base_x; - f32 y = map_ovl->map_cursor_current_zpos + base_y; - int frame = map_ovl->cursor_frame; - Gfx* gfx; + f32 x = map_ovl->map_cursor_current_xpos + base_x; + f32 y = map_ovl->map_cursor_current_zpos + base_y; + int frame = map_ovl->cursor_frame; + Gfx* gfx; - Matrix_scale(16.0f, 16.0f, 1.0f, 0); - Matrix_translate(x + 11.7f, y + 45.7f, 140.0f, 1); + Matrix_scale(16.0f, 16.0f, 1.0f, 0); + Matrix_translate(x + 11.7f, y + 45.7f, 140.0f, 1); - Matrix_scale(cursol_scale[frame], cursol_scale[frame], 1.0f, 1); + Matrix_scale(cursol_scale[frame], cursol_scale[frame], 1.0f, 1); - OPEN_DISP(graph); + OPEN_DISP(graph); - gfx = NOW_POLY_OPA_DISP; + gfx = NOW_POLY_OPA_DISP; - gSPMatrix(gfx++, _Matrix_to_Mtx_new(graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gDPSetPrimColor(gfx++, 0, 255, 255, col_g[frame], 255, 255); - gSPDisplayList(gfx++, kan_win_cursorT_model); + gSPMatrix(gfx++, _Matrix_to_Mtx_new(graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(gfx++, 0, 255, 255, col_g[frame], 255, 255); + gSPDisplayList(gfx++, kan_win_cursorT_model); - SET_POLY_OPA_DISP(gfx); + SET_POLY_OPA_DISP(gfx); - CLOSE_DISP(graph); + CLOSE_DISP(graph); } static void mMP_set_label_dl(GAME* game, mMP_LabelInfo_c* label_info, f32 xpos, f32 ypos) { - mMP_Label_c* label = mMP_label_data[label_info->label_no]; + mMP_Label_c* label = mMP_label_data[label_info->label_no]; - if (label != NULL) { - mMP_ResidentInfo_c** resident_p = label_info->residents; - mMP_LabelWord_c* word; - f32 base_x = 160.0f + xpos; - f32 base_y = 120.0f - ypos; - int i; + if (label != NULL) { + mMP_ResidentInfo_c** resident_p = label_info->residents; + mMP_LabelWord_c* word; + f32 base_x = 160.0f + xpos; + f32 base_y = 120.0f - ypos; + int i; - for (i = 0; i < mMP_LABEL_WORD_NUM; i++) { - word = label->words[i]; + for (i = 0; i < mMP_LABEL_WORD_NUM; i++) { + word = label->words[i]; - if (word != NULL) { - if (word->str == NULL) { - /* draw resident name label (villagers, players) */ - int j; + if (word != NULL) { + if (word->str == NULL) { + /* draw resident name label (villagers, players) */ + int j; - for (j = 0; j < label_info->label_cnt; j++) { - int width = mFont_GetStringWidth((*resident_p)->name, PLAYER_NAME_LEN, TRUE); - f32 scale_x = 54.0f / width; + for (j = 0; j < label_info->label_cnt; j++) { + int width = mFont_GetStringWidth((*resident_p)->name, PLAYER_NAME_LEN, TRUE); + f32 scale_x = 54.0f / width; - if (scale_x > 0.75f) { - scale_x = 0.75f; + if (scale_x > 0.75f) { + scale_x = 0.75f; + } + + if (resident_p[0]->sex != -1) { + mFont_SetLineStrings(game, resident_p[0]->name, PLAYER_NAME_LEN, base_x + word->ofs_x, + base_y - word->ofs_y, 255, 75, 40, 255, FALSE, TRUE, scale_x, 0.75f, + mFont_MODE_POLY); + } else { + mFont_SetLineStrings(game, resident_p[0]->name, PLAYER_NAME_LEN, base_x + word->ofs_x, + base_y - word->ofs_y, 165, 145, 140, 255, FALSE, TRUE, scale_x, 0.75f, + mFont_MODE_POLY); + } + + resident_p++; + base_y += 12.0f; + } + } else { + /* draw building name */ + mFont_SetLineStrings(game, word->str, word->str_len, base_x + word->ofs_x, base_y - word->ofs_y, + 120, 95, 205, 255, FALSE, TRUE, 0.75f, 0.75f, mFont_MODE_POLY); + } } - - if (resident_p[0]->sex != -1) { - mFont_SetLineStrings( - game, - resident_p[0]->name, PLAYER_NAME_LEN, - base_x + word->ofs_x, base_y - word->ofs_y, - 255, 75, 40, 255, - FALSE, TRUE, - scale_x, 0.75f, - mFont_MODE_POLY - ); - } - else { - mFont_SetLineStrings( - game, - resident_p[0]->name, PLAYER_NAME_LEN, - base_x + word->ofs_x, base_y - word->ofs_y, - 165, 145, 140, 255, - FALSE, TRUE, - scale_x, 0.75f, - mFont_MODE_POLY - ); - } - - resident_p++; - base_y += 12.0f; - } } - else { - /* draw building name */ - mFont_SetLineStrings( - game, - word->str, word->str_len, - base_x + word->ofs_x, base_y - word->ofs_y, - 120, 95, 205, 255, - FALSE, TRUE, - 0.75f, 0.75f, - mFont_MODE_POLY - ); - } - } } - } } static void mMP_set_base_dl(GRAPH* graph, mSM_MenuInfo_c* menu) { - Gfx* gfx; - - OPEN_DISP(graph); - gfx = NOW_POLY_OPA_DISP; - - if (menu->data0 == 0) { - gSPSegment(gfx++, G_MWO_SEGMENT_B, kan_win_color0_mode_p); - } - else { - gSPSegment(gfx++, G_MWO_SEGMENT_B, kan_win_color1_mode_p); - } - - gSPMatrix(gfx++, _Matrix_to_Mtx_new(graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(gfx++, kan_win_model); - - SET_POLY_OPA_DISP(gfx); - CLOSE_DISP(graph); -} - -static void mMP_set_win_dl(GRAPH* graph, mMP_Overlay_c* map_ovl, mMP_LabelInfo_c* label_info) { - int label_count = label_info->label_cnt; - Gfx* gfx; - - OPEN_DISP(graph); - gfx = NOW_POLY_OPA_DISP; - - /* move X-acre number texture into segment 8 and Z-acre character texture int segment 9 */ - gSPSegment(gfx++, G_MWO_SEGMENT_8, kan_win_evw_anime_1_tex_table[map_ovl->sel_bx]); - gSPSegment(gfx++, G_MWO_SEGMENT_9, kan_win_evw_anime_2_tex_table[map_ovl->sel_bz]); - - /* move label area texture into segment 10 based on number of labels */ - if (label_count == 4) { - gSPSegment(gfx++, G_MWO_SEGMENT_A, kan_win_waku4T_model_p); - } - else if (label_count == 3) { - gSPSegment(gfx++, G_MWO_SEGMENT_A, kan_win_waku3T_model_p); - } - else if (label_count == 1) { - gSPSegment(gfx++, G_MWO_SEGMENT_A, kan_win_wakuT_model_p); - } - else if (label_count == 0) { - gSPSegment(gfx++, G_MWO_SEGMENT_A, kan_win_waku1T_model_p); - } - else { /* label_count == 2 */ - gSPSegment(gfx++, G_MWO_SEGMENT_A, kan_win_waku2T_model_p); - } - - gSPMatrix(gfx++, _Matrix_to_Mtx_new(graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(gfx++, kan_win_model2); - - SET_POLY_OPA_DISP(gfx); - CLOSE_DISP(graph); -} - -static void mMP_set_label_top_dl(GRAPH* graph, mMP_LabelInfo_c* label_info) { - mMP_Label_c* label = mMP_label_data[label_info->label_no]; - mMP_ResidentInfo_c** resident_p; - - if (label != NULL) { - int count = mMP_get_label_cnt(label_info); - int i; Gfx* gfx; OPEN_DISP(graph); gfx = NOW_POLY_OPA_DISP; - Matrix_push(); - Matrix_translate(label->ofs_x, label->ofs_y, 0.0f, 1); - - if (label_info->label_no == mMP_LABEL_NPC) { - resident_p = label_info->residents; - } - else { - resident_p = NULL; + if (menu->data0 == 0) { + gSPSegment(gfx++, G_MWO_SEGMENT_B, kan_win_color0_mode_p); + } else { + gSPSegment(gfx++, G_MWO_SEGMENT_B, kan_win_color1_mode_p); } - for (i = 0; i < count; i++) { - gSPMatrix(gfx++, _Matrix_to_Mtx_new(graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - - if (resident_p != NULL && *resident_p != NULL && (*resident_p)->house_layer != 0) { - gSPDisplayList(gfx++, kan_win_npcT_table[(*resident_p)->house_layer]); - resident_p++; - } - else { - gSPDisplayList(gfx++, label->gfx); - - if (resident_p != NULL) { - resident_p++; - } - } - - Matrix_translate(0.0f, -12.0f, 0.0f, 1); - } - - Matrix_pull(); + gSPMatrix(gfx++, _Matrix_to_Mtx_new(graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(gfx++, kan_win_model); SET_POLY_OPA_DISP(gfx); CLOSE_DISP(graph); - } +} + +static void mMP_set_win_dl(GRAPH* graph, mMP_Overlay_c* map_ovl, mMP_LabelInfo_c* label_info) { + int label_count = label_info->label_cnt; + Gfx* gfx; + + OPEN_DISP(graph); + gfx = NOW_POLY_OPA_DISP; + + /* move X-acre number texture into segment 8 and Z-acre character texture int segment 9 */ + gSPSegment(gfx++, G_MWO_SEGMENT_8, kan_win_evw_anime_1_tex_table[map_ovl->sel_bx]); + gSPSegment(gfx++, G_MWO_SEGMENT_9, kan_win_evw_anime_2_tex_table[map_ovl->sel_bz]); + + /* move label area texture into segment 10 based on number of labels */ + if (label_count == 4) { + gSPSegment(gfx++, G_MWO_SEGMENT_A, kan_win_waku4T_model_p); + } else if (label_count == 3) { + gSPSegment(gfx++, G_MWO_SEGMENT_A, kan_win_waku3T_model_p); + } else if (label_count == 1) { + gSPSegment(gfx++, G_MWO_SEGMENT_A, kan_win_wakuT_model_p); + } else if (label_count == 0) { + gSPSegment(gfx++, G_MWO_SEGMENT_A, kan_win_waku1T_model_p); + } else { /* label_count == 2 */ + gSPSegment(gfx++, G_MWO_SEGMENT_A, kan_win_waku2T_model_p); + } + + gSPMatrix(gfx++, _Matrix_to_Mtx_new(graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(gfx++, kan_win_model2); + + SET_POLY_OPA_DISP(gfx); + CLOSE_DISP(graph); +} + +static void mMP_set_label_top_dl(GRAPH* graph, mMP_LabelInfo_c* label_info) { + mMP_Label_c* label = mMP_label_data[label_info->label_no]; + mMP_ResidentInfo_c** resident_p; + + if (label != NULL) { + int count = mMP_get_label_cnt(label_info); + int i; + Gfx* gfx; + + OPEN_DISP(graph); + gfx = NOW_POLY_OPA_DISP; + + Matrix_push(); + Matrix_translate(label->ofs_x, label->ofs_y, 0.0f, 1); + + if (label_info->label_no == mMP_LABEL_NPC) { + resident_p = label_info->residents; + } else { + resident_p = NULL; + } + + for (i = 0; i < count; i++) { + gSPMatrix(gfx++, _Matrix_to_Mtx_new(graph), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + + if (resident_p != NULL && *resident_p != NULL && (*resident_p)->house_layer != 0) { + gSPDisplayList(gfx++, kan_win_npcT_table[(*resident_p)->house_layer]); + resident_p++; + } else { + gSPDisplayList(gfx++, label->gfx); + + if (resident_p != NULL) { + resident_p++; + } + } + + Matrix_translate(0.0f, -12.0f, 0.0f, 1); + } + + Matrix_pull(); + + SET_POLY_OPA_DISP(gfx); + CLOSE_DISP(graph); + } } static void mMP_set_dl(Submenu* submenu, GAME* game, mSM_MenuInfo_c* menu) { - static u8 land_color[2][4] = { - { 255, 0, 255, 255 }, - { 60, 60, 255, 255 }, - }; + static u8 land_color[2][4] = { + { 255, 0, 255, 255 }, + { 60, 60, 255, 255 }, + }; - GRAPH* graph = game->graph; - mMP_Overlay_c* map_ovl = submenu->overlay->map_ovl; - u8* col = land_color[menu->data0]; - mMP_LabelInfo_c* label_info = &map_ovl->label_info[map_ovl->sel_bz][map_ovl->sel_bx]; - u8* land_name; - f32 xpos = menu->position[0]; - f32 ypos = menu->position[1]; - f32 str_xpos; - f32 str_ypos; + GRAPH* graph = game->graph; + mMP_Overlay_c* map_ovl = submenu->overlay->map_ovl; + u8* col = land_color[menu->data0]; + mMP_LabelInfo_c* label_info = &map_ovl->label_info[map_ovl->sel_bz][map_ovl->sel_bx]; + u8* land_name; + f32 xpos = menu->position[0]; + f32 ypos = menu->position[1]; + f32 str_xpos; + f32 str_ypos; + Matrix_scale(16.0f, 16.0f, 1.0f, 0); + Matrix_translate(xpos, ypos, 140.0f, 1); - Matrix_scale(16.0f, 16.0f, 1.0f, 0); - Matrix_translate(xpos, ypos, 140.0f, 1); + mMP_set_base_dl(graph, menu); + mMP_set_map_dl(graph, map_ovl); + mMP_set_win_dl(graph, map_ovl, label_info); + mMP_set_label_top_dl(graph, label_info); + mMP_set_house_dl(graph, map_ovl, xpos, ypos); + mMP_set_cursol_dl(graph, map_ovl, xpos, ypos); - mMP_set_base_dl(graph, menu); - mMP_set_map_dl(graph, map_ovl); - mMP_set_win_dl(graph, map_ovl, label_info); - mMP_set_label_top_dl(graph, label_info); - mMP_set_house_dl(graph, map_ovl, xpos, ypos); - mMP_set_cursol_dl(graph, map_ovl, xpos, ypos); + (*submenu->overlay->set_char_matrix_proc)(graph); - (*submenu->overlay->set_char_matrix_proc)(graph); + /* draw town name */ + land_name = Save_Get(land_info.name); + str_xpos = (xpos + -136.0f) + 24.0f; + str_ypos = (ypos + 102.0f) + -29.0f; + mFont_SetLineStrings(game, land_name, map_ovl->land_name_str_len, str_xpos + 160.0f, 120.0f - str_ypos, col[0], + col[1], col[2], 255, FALSE, TRUE, 1.0f, 1.0f, mFont_MODE_POLY); - /* draw town name */ - land_name = Save_Get(land_info.name); - str_xpos = (xpos + -136.0f) + 24.0f; - str_ypos = (ypos + 102.0f) + -29.0f; - mFont_SetLineStrings( - game, - land_name, map_ovl->land_name_str_len, - str_xpos + 160.0f, 120.0f - str_ypos, - col[0], col[1], col[2], 255, - FALSE, TRUE, - 1.0f, 1.0f, - mFont_MODE_POLY - ); - - mMP_set_label_dl(game, label_info, xpos, ypos); + mMP_set_label_dl(game, label_info, xpos, ypos); } static void mMP_map_ovl_draw(Submenu* submenu, GAME* game) { - Submenu_Overlay_c* overlay = submenu->overlay; - mSM_MenuInfo_c* menu = &overlay->menu_info[mSM_OVL_MAP]; + Submenu_Overlay_c* overlay = submenu->overlay; + mSM_MenuInfo_c* menu = &overlay->menu_info[mSM_OVL_MAP]; - (*menu->pre_draw_func)(submenu, game); - mMP_set_dl(submenu, game, menu); + (*menu->pre_draw_func)(submenu, game); + mMP_set_dl(submenu, game, menu); } extern void mMP_map_ovl_set_proc(Submenu* submenu) { - Submenu_Overlay_c* overlay = submenu->overlay; + Submenu_Overlay_c* overlay = submenu->overlay; - overlay->menu_control.menu_move_func = &mMP_map_ovl_move; - overlay->menu_control.menu_draw_func = &mMP_map_ovl_draw; + overlay->menu_control.menu_move_func = &mMP_map_ovl_move; + overlay->menu_control.menu_draw_func = &mMP_map_ovl_draw; } static void mMP_map_ovl_init(Submenu* submenu) { - Submenu_Overlay_c* overlay = submenu->overlay; - mSM_MenuInfo_c* menu = &overlay->menu_info[mSM_OVL_MAP]; + Submenu_Overlay_c* overlay = submenu->overlay; + mSM_MenuInfo_c* menu = &overlay->menu_info[mSM_OVL_MAP]; - overlay->menu_control.animation_flag = FALSE; - (*submenu->overlay->move_chg_base_proc)(menu, mSM_MOVE_IN_TOP); + overlay->menu_control.animation_flag = FALSE; + (*submenu->overlay->move_chg_base_proc)(menu, mSM_MOVE_IN_TOP); - sAdo_SysTrgStart(0x17C); - mMP_set_init_data(submenu->overlay->map_ovl, menu); + sAdo_SysTrgStart(0x17C); + mMP_set_init_data(submenu->overlay->map_ovl, menu); } extern void mMP_map_ovl_construct(Submenu* submenu) { - Submenu_Overlay_c* overlay = submenu->overlay; + Submenu_Overlay_c* overlay = submenu->overlay; - if (overlay->map_ovl == NULL) { - overlay->map_ovl = (mMP_Overlay_c*)zelda_malloc(sizeof(mMP_Overlay_c)); - mem_clear((u8*)overlay->map_ovl, sizeof(mMP_Overlay_c), 0); - overlay->map_ovl->combination_table = data_combi_table; - mMP_map_draw_init(); - } + if (overlay->map_ovl == NULL) { + overlay->map_ovl = (mMP_Overlay_c*)zelda_malloc(sizeof(mMP_Overlay_c)); + mem_clear((u8*)overlay->map_ovl, sizeof(mMP_Overlay_c), 0); + overlay->map_ovl->combination_table = data_combi_table; + mMP_map_draw_init(); + } - mMP_map_ovl_init(submenu); - mMP_map_ovl_set_proc(submenu); + mMP_map_ovl_init(submenu); + mMP_map_ovl_set_proc(submenu); } extern void mMP_map_ovl_destruct(Submenu* submenu) { - mMP_Overlay_c* map_ovl = submenu->overlay->map_ovl; + mMP_Overlay_c* map_ovl = submenu->overlay->map_ovl; - if (map_ovl != NULL) { - zelda_free(map_ovl); - } + if (map_ovl != NULL) { + zelda_free(map_ovl); + } - submenu->overlay->map_ovl = NULL; + submenu->overlay->map_ovl = NULL; } diff --git a/src/m_museum.c b/src/m_museum.c index 7ee06e1b..116bc243 100644 --- a/src/m_museum.c +++ b/src/m_museum.c @@ -12,666 +12,653 @@ #include "m_random_field_h.h" #include "m_common_data.h" -static u8 l_museum_name_str[PLAYER_NAME_LEN] = { CHAR_M, CHAR_u, CHAR_s, CHAR_e, CHAR_u, CHAR_m, CHAR_SPACE, CHAR_SPACE }; /* "Museum " */ +static u8 l_museum_name_str[PLAYER_NAME_LEN] = { + CHAR_M, CHAR_u, CHAR_s, CHAR_e, CHAR_u, CHAR_m, CHAR_SPACE, CHAR_SPACE +}; /* "Museum " */ static u8 present_name[mIN_ITEM_NAME_LEN]; /* TODO: reversed bss order */ static Mail_c l_mmsm_mail; extern void mMsm_ClearRecord(mMsm_record_c* record) { - bzero(record, sizeof(mMsm_record_c)); + bzero(record, sizeof(mMsm_record_c)); } extern void mMsm_GetMuseumMailName(Mail_nm_c* name) { - mPr_ClearPersonalID(&name->personalID); - mPr_CopyPlayerName(name->personalID.player_name, l_museum_name_str); - name->type = mMl_NAME_TYPE_MUSEUM; + mPr_ClearPersonalID(&name->personalID); + mPr_CopyPlayerName(name->personalID.player_name, l_museum_name_str); + name->type = mMl_NAME_TYPE_MUSEUM; } static void mMsm_OrderInformationMail() { - Private_c* priv = Save_Get(private); - int i; + Private_c* priv = Save_Get(private_data); + int i; - for (i = 0; i < PLAYER_NUM; i++) { - if (mPr_NullCheckPersonalID(&priv->player_ID) == FALSE && mPr_CheckMuseumAddress(priv) == FALSE) { - priv->museum_record.send_info_mail = TRUE; + for (i = 0; i < PLAYER_NUM; i++) { + if (mPr_NullCheckPersonalID(&priv->player_ID) == FALSE && mPr_CheckMuseumAddress(priv) == FALSE) { + priv->museum_record.send_info_mail = TRUE; + } + + priv++; } - - priv++; - } } extern void mMsm_SendInformationMail() { - Private_c* priv = Save_Get(private); - int i; + Private_c* priv = Save_Get(private_data); + int i; - for (i = 0; i < PLAYER_NUM; i++) { - if (mPr_NullCheckPersonalID(&priv->player_ID) == FALSE && mPr_CheckMuseumInfoMail(priv)) { - if (mMl_send_mail_box(&priv->player_ID, i, &l_mmsm_mail, EMPTY_NO, ITM_PAPER24, mMl_MUSEUM_INFO_MAIL_NO, l_museum_name_str, mMl_DATA2) == TRUE) { - priv->museum_record.contacted = TRUE; - priv->museum_record.send_info_mail = FALSE; - } + for (i = 0; i < PLAYER_NUM; i++) { + if (mPr_NullCheckPersonalID(&priv->player_ID) == FALSE && mPr_CheckMuseumInfoMail(priv)) { + if (mMl_send_mail_box(&priv->player_ID, i, &l_mmsm_mail, EMPTY_NO, ITM_PAPER24, mMl_MUSEUM_INFO_MAIL_NO, + l_museum_name_str, mMl_DATA2) == TRUE) { + priv->museum_record.contacted = TRUE; + priv->museum_record.send_info_mail = FALSE; + } + } + + priv++; } - - priv++; - } } static void mMsm_GetFossil(mActor_name_t* fossil) { - static int hit_table[mMsm_FOSSIL_TYPE_NUM] = { FALSE, TRUE }; + static int hit_table[mMsm_FOSSIL_TYPE_NUM] = { FALSE, TRUE }; - *fossil = mSP_RandomOneFossilSelect(hit_table[RANDOM(mMsm_FOSSIL_TYPE_NUM)]); + *fossil = mSP_RandomOneFossilSelect(hit_table[RANDOM(mMsm_FOSSIL_TYPE_NUM)]); } static int mMsm_GetFossilMailNo(mActor_name_t fossil) { - static int mail_no_table[25] = { - 0x10E, 0x110, 0x10F, 0x111, - 0x113, 0x112, 0x114, 0x116, - 0x115, 0x117, 0x119, 0x118, - 0x11A, 0x11B, 0x11C, 0x11D, - 0x11E, 0x11F, 0x120, 0x121, - 0x126, 0x125, 0x123, 0x124, - 0x122 - }; + static int mail_no_table[25] = { 0x10E, 0x110, 0x10F, 0x111, 0x113, 0x112, 0x114, 0x116, 0x115, + 0x117, 0x119, 0x118, 0x11A, 0x11B, 0x11C, 0x11D, 0x11E, 0x11F, + 0x120, 0x121, 0x126, 0x125, 0x123, 0x124, 0x122 }; - int type = 0; // invalid item - - if (fossil >= FTR_DINO_TRICERA_SKULL && fossil <= FTR_DINO_TRILOBITE_WEST) { - type = 1; // valid fossil - } + int type = 0; // invalid item - return mail_no_table[type != 0 ? (fossil - FTR_DINO_TRICERA_SKULL) >> 2 : 0]; + if (fossil >= FTR_DINO_TRICERA_SKULL && fossil <= FTR_DINO_TRILOBITE_WEST) { + type = 1; // valid fossil + } + + return mail_no_table[type != 0 ? (fossil - FTR_DINO_TRICERA_SKULL) >> 2 : 0]; } static void mMsm_GetRemailAddIdx(int* add, int* shift, int idx) { - *add = (idx << 2) / 8; - *shift = idx - (*add * 2); + *add = (idx << 2) / 8; + *shift = idx - (*add * 2); } static int mMsm_Idx2RemailKind(mMsm_remail_info_c* remail_info, int idx) { - int kind = -1; - int add = 0; - int shift = 0; + int kind = -1; + int add = 0; + int shift = 0; - if (remail_info != NULL && idx >= 0 && idx < mMsm_REMAIL_SLOTS) { - mMsm_GetRemailAddIdx(&add, &shift, idx); - kind = (remail_info->types[add] >> (shift << 2)) & 7; - } + if (remail_info != NULL && idx >= 0 && idx < mMsm_REMAIL_SLOTS) { + mMsm_GetRemailAddIdx(&add, &shift, idx); + kind = (remail_info->types[add] >> (shift << 2)) & 7; + } - return kind; + return kind; } static int mMsm_GetRemailFreeIdx(mMsm_remail_info_c* remail_info) { - int idx = -1; + int idx = -1; - if (remail_info != NULL) { - int i; + if (remail_info != NULL) { + int i; - for (i = 0; i < mMsm_REMAIL_SLOTS; i++) { - int kind = mMsm_Idx2RemailKind(remail_info, i); - - if (kind == mMsm_REMAIL_KIND_CLEAR || kind >= mMsm_REMAIL_KIND_NUM) { - idx = i; - break; - } + for (i = 0; i < mMsm_REMAIL_SLOTS; i++) { + int kind = mMsm_Idx2RemailKind(remail_info, i); + + if (kind == mMsm_REMAIL_KIND_CLEAR || kind >= mMsm_REMAIL_KIND_NUM) { + idx = i; + break; + } + } } - } - return idx; + return idx; } static void mMsm_Idx2SetRemailInfo(mMsm_remail_info_c* remail_info, int idx, int remail_type, mActor_name_t item_no) { - int slot_idx = 0; - int nibble = 0; + int slot_idx = 0; + int nibble = 0; - if (remail_info != NULL && idx >= 0 && idx < mMsm_REMAIL_SLOTS) { - int i; - - mMsm_GetRemailAddIdx(&slot_idx, &nibble, idx); - i = slot_idx; + if (remail_info != NULL && idx >= 0 && idx < mMsm_REMAIL_SLOTS) { + int i; - if (nibble == 0) { - u8 raw = remail_info->types[i]; - remail_info->types[i] = (raw & 0xF0) | remail_type & 7; + mMsm_GetRemailAddIdx(&slot_idx, &nibble, idx); + i = slot_idx; + + if (nibble == 0) { + u8 raw = remail_info->types[i]; + remail_info->types[i] = (raw & 0xF0) | remail_type & 7; + } else { + u8 raw = remail_info->types[i]; + remail_info->types[i] = (raw & 0x0F) | (remail_type & 7) << 4; + } + + remail_info->items[idx] = item_no; } - else { - u8 raw = remail_info->types[i]; - remail_info->types[i] = (raw & 0x0F) | (remail_type & 7) << 4; - } - - remail_info->items[idx] = item_no; - } } static void mMsm_Idx2ClearRemailInfo(mMsm_remail_info_c* remail_info, int idx) { - mMsm_Idx2SetRemailInfo(remail_info, idx, mMsm_REMAIL_KIND_CLEAR, EMPTY_NO); + mMsm_Idx2SetRemailInfo(remail_info, idx, mMsm_REMAIL_KIND_CLEAR, EMPTY_NO); } static void mMsm_PushRemailInfo(mMsm_remail_info_c* remail_info) { - int active = TRUE; + int active = TRUE; - if (remail_info != NULL) { - while (active == TRUE) { - int first_free_idx; - - active = FALSE; - first_free_idx = mMsm_GetRemailFreeIdx(remail_info); + if (remail_info != NULL) { + while (active == TRUE) { + int first_free_idx; - if (first_free_idx != -1) { - int used_slot_idx = first_free_idx + 1; + active = FALSE; + first_free_idx = mMsm_GetRemailFreeIdx(remail_info); - /* Count up until we've found the first used slot or reach the end */ - while (used_slot_idx < mMsm_REMAIL_SLOTS) { - int remail_type = mMsm_Idx2RemailKind(remail_info, used_slot_idx); + if (first_free_idx != -1) { + int used_slot_idx = first_free_idx + 1; - if (remail_type > mMsm_REMAIL_KIND_CLEAR && remail_type < mMsm_REMAIL_KIND_NUM) { - mMsm_Idx2SetRemailInfo(remail_info, first_free_idx, remail_type, remail_info->items[used_slot_idx]); - mMsm_Idx2ClearRemailInfo(remail_info, used_slot_idx); - active = TRUE; /* Continue searching */ - break; - } + /* Count up until we've found the first used slot or reach the end */ + while (used_slot_idx < mMsm_REMAIL_SLOTS) { + int remail_type = mMsm_Idx2RemailKind(remail_info, used_slot_idx); - used_slot_idx++; + if (remail_type > mMsm_REMAIL_KIND_CLEAR && remail_type < mMsm_REMAIL_KIND_NUM) { + mMsm_Idx2SetRemailInfo(remail_info, first_free_idx, remail_type, + remail_info->items[used_slot_idx]); + mMsm_Idx2ClearRemailInfo(remail_info, used_slot_idx); + active = TRUE; /* Continue searching */ + break; + } + + used_slot_idx++; + } + } } - } } - } } static void mMsm_SetRemailInfo(mMsm_remail_info_c* remail_info, Private_c* priv, mActor_name_t item) { - int kind = mMsm_REMAIL_KIND_CLEAR; + int kind = mMsm_REMAIL_KIND_CLEAR; - if (item != EMPTY_NO) { - int free_idx; - int private_idx = mPr_GetPrivateIdx(&priv->player_ID); + if (item != EMPTY_NO) { + int free_idx; + int private_idx = mPr_GetPrivateIdx(&priv->player_ID); - if (private_idx == -1) { - kind = mMsm_REMAIL_KIND_FOREIGNER; - } - else { - switch (mMmd_GetDisplayInfo(item)) { - case mMmd_DISPLAY_CANNOT_DONATE: - { - kind = mMsm_REMAIL_KIND_CANNOT_DONATE; - break; + if (private_idx == -1) { + kind = mMsm_REMAIL_KIND_FOREIGNER; + } else { + switch (mMmd_GetDisplayInfo(item)) { + case mMmd_DISPLAY_CANNOT_DONATE: { + kind = mMsm_REMAIL_KIND_CANNOT_DONATE; + break; + } + + case mMmd_DISPLAY_CAN_DONATE: { + kind = mMsm_REMAIL_KIND_DONATED; + mMmd_RequestMuseumDisplay(item); + break; + } + + case mMmd_DISPLAY_ALREADY_DONATED: { + kind = mMsm_REMAIL_KIND_ALREADY_DONATED; + break; + } + } } - case mMmd_DISPLAY_CAN_DONATE: - { - kind = mMsm_REMAIL_KIND_DONATED; - mMmd_RequestMuseumDisplay(item); - break; + free_idx = mMsm_GetRemailFreeIdx(remail_info); + if (free_idx != -1) { + mMsm_Idx2SetRemailInfo(remail_info, free_idx, kind, item); } - - case mMmd_DISPLAY_ALREADY_DONATED: - { - kind = mMsm_REMAIL_KIND_ALREADY_DONATED; - break; - } - } } - - free_idx = mMsm_GetRemailFreeIdx(remail_info); - if (free_idx != -1) { - mMsm_Idx2SetRemailInfo(remail_info, free_idx, kind, item); - } - } } static void mMsm_SendResultMail() { - static int remail_no_table[mMsm_REMAIL_KIND_NUM - 1] = { 0x22D, 0x22B, 0x22C, 0x22E }; - //static u8 present_name[mIN_ITEM_NAME_LEN]; /* TODO: reversed bss order */ + static int remail_no_table[mMsm_REMAIL_KIND_NUM - 1] = { 0x22D, 0x22B, 0x22C, 0x22E }; + // static u8 present_name[mIN_ITEM_NAME_LEN]; /* TODO: reversed bss order */ - int send_num[PLAYER_NUM]; - Private_c* priv_p = Save_Get(private); - Private_c* priv = priv_p; - mActor_name_t present; - u8 send_flags = 0b1111; - mActor_name_t fossil = EMPTY_NO; - mMsm_remail_info_c* remail_info; - int idx; - int i; + int send_num[PLAYER_NUM]; + Private_c* priv_p = Save_Get(private_data); + Private_c* priv = priv_p; + mActor_name_t present; + u8 send_flags = 0b1111; + mActor_name_t fossil = EMPTY_NO; + mMsm_remail_info_c* remail_info; + int idx; + int i; - bzero(send_num, PLAYER_NUM * sizeof(int)); + bzero(send_num, PLAYER_NUM * sizeof(int)); - /* Send 'remail' info */ - for (i = 0; i < PLAYER_NUM; i++) { - if (mPr_NullCheckPersonalID(&priv->player_ID) == FALSE) { - mMsm_record_c* record = &priv->museum_record; - if (record->contacted == TRUE) { - int landname_len; - mActor_name_t item; - - remail_info = &record->remail_info; - for (idx = 0; idx < mMsm_REMAIL_SLOTS; idx++) { - int remail_kind; - - present = EMPTY_NO; - remail_kind = mMsm_Idx2RemailKind(remail_info, idx); - - if (remail_kind <= mMsm_REMAIL_KIND_CLEAR || remail_kind >= mMsm_REMAIL_KIND_NUM) { - break; /* Reached end of populated remail slots */ - } - - landname_len = mMsg_Get_Length_String(Save_Get(land_info.name), LAND_NAME_SIZE); - mHandbill_Set_free_str(mHandbill_FREE_STR0, Save_Get(land_info.name), landname_len); - - item = remail_info->items[idx]; - if (item != EMPTY_NO) { - mIN_copy_name_str(present_name, item); - mHandbill_Set_free_str(mHandbill_FREE_STR1, present_name, mIN_ITEM_NAME_LEN); - - if (remail_kind != mMsm_REMAIL_KIND_DONATED) { - present = remail_info->items[idx]; - } - } - - if (mMl_send_mail(&priv->player_ID, i, present, ITM_PAPER24, remail_no_table[remail_kind - 1], l_museum_name_str, mMl_DATA2)) { - mMsm_Idx2ClearRemailInfo(remail_info, idx); - send_num[i]++; - - if (send_num[i] >= mMsm_MAX_MAIL) { - send_flags &= ~(1 << i); - break; - } - } - else { - /* If attempted mail was unable to be received, remove this player from the send pool and stop processing */ - send_flags &= ~(1 << i); - break; - } - } - - mMsm_PushRemailInfo(remail_info); - } - else { - send_flags &= ~(1 << i); - } - } - else { - send_flags &= ~(1 << i); - } - - priv++; - } - - /* Send fossil mail */ - while (send_flags != 0) { - priv = priv_p; + /* Send 'remail' info */ for (i = 0; i < PLAYER_NUM; i++) { - if (((send_flags >> i) & 1) == 1) { - mMsm_record_c* record = &priv->museum_record; - if (record->stored_fossil_num != 0) { - int mail_no; - - mMsm_GetFossil(&fossil); - mail_no = mMsm_GetFossilMailNo(fossil); + if (mPr_NullCheckPersonalID(&priv->player_ID) == FALSE) { + mMsm_record_c* record = &priv->museum_record; + if (record->contacted == TRUE) { + int landname_len; + mActor_name_t item; - if (mMl_send_mail(&priv->player_ID, i, fossil, ITM_PAPER24, mail_no, l_museum_name_str, mMl_DATA2)) { - record->stored_fossil_num--; - send_num[i]++; + remail_info = &record->remail_info; + for (idx = 0; idx < mMsm_REMAIL_SLOTS; idx++) { + int remail_kind; - if (send_num[i] >= mMsm_MAX_MAIL) { - send_flags &= ~(1 << i); + present = EMPTY_NO; + remail_kind = mMsm_Idx2RemailKind(remail_info, idx); + + if (remail_kind <= mMsm_REMAIL_KIND_CLEAR || remail_kind >= mMsm_REMAIL_KIND_NUM) { + break; /* Reached end of populated remail slots */ + } + + landname_len = mMsg_Get_Length_String(Save_Get(land_info.name), LAND_NAME_SIZE); + mHandbill_Set_free_str(mHandbill_FREE_STR0, Save_Get(land_info.name), landname_len); + + item = remail_info->items[idx]; + if (item != EMPTY_NO) { + mIN_copy_name_str(present_name, item); + mHandbill_Set_free_str(mHandbill_FREE_STR1, present_name, mIN_ITEM_NAME_LEN); + + if (remail_kind != mMsm_REMAIL_KIND_DONATED) { + present = remail_info->items[idx]; + } + } + + if (mMl_send_mail(&priv->player_ID, i, present, ITM_PAPER24, remail_no_table[remail_kind - 1], + l_museum_name_str, mMl_DATA2)) { + mMsm_Idx2ClearRemailInfo(remail_info, idx); + send_num[i]++; + + if (send_num[i] >= mMsm_MAX_MAIL) { + send_flags &= ~(1 << i); + break; + } + } else { + /* If attempted mail was unable to be received, remove this player from the send pool and stop + * processing */ + send_flags &= ~(1 << i); + break; + } + } + + mMsm_PushRemailInfo(remail_info); + } else { + send_flags &= ~(1 << i); } - } - else { + } else { send_flags &= ~(1 << i); - } } - else { - send_flags &= ~(1 << i); - } - } - priv++; + priv++; + } + + /* Send fossil mail */ + while (send_flags != 0) { + priv = priv_p; + for (i = 0; i < PLAYER_NUM; i++) { + if (((send_flags >> i) & 1) == 1) { + mMsm_record_c* record = &priv->museum_record; + if (record->stored_fossil_num != 0) { + int mail_no; + + mMsm_GetFossil(&fossil); + mail_no = mMsm_GetFossilMailNo(fossil); + + if (mMl_send_mail(&priv->player_ID, i, fossil, ITM_PAPER24, mail_no, l_museum_name_str, + mMl_DATA2)) { + record->stored_fossil_num--; + send_num[i]++; + + if (send_num[i] >= mMsm_MAX_MAIL) { + send_flags &= ~(1 << i); + } + } else { + send_flags &= ~(1 << i); + } + } else { + send_flags &= ~(1 << i); + } + } + + priv++; + } } - } } extern void mMsm_SendMuseumMail(Mail_c* mail) { - Mail_nm_c* sender_name; - Private_c* priv = NULL; + Mail_nm_c* sender_name; + Private_c* priv = NULL; - if (mail != NULL && Common_Get(now_private) != NULL && mail->header.sender.type == mMl_NAME_TYPE_PLAYER) { - sender_name = &mail->header.sender; + if (mail != NULL && Common_Get(now_private) != NULL && mail->header.sender.type == mMl_NAME_TYPE_PLAYER) { + sender_name = &mail->header.sender; - if (mPr_NullCheckPersonalID(&sender_name->personalID) == FALSE) { - if (mPr_CheckCmpPersonalID(&sender_name->personalID, &Common_Get(now_private)->player_ID) == TRUE) { - priv = Common_Get(now_private); - } - else { - int priv_idx = mPr_GetPrivateIdx(&sender_name->personalID); - - if (priv_idx != -1) { - priv = Save_Get(private + priv_idx); - } - } + if (mPr_NullCheckPersonalID(&sender_name->personalID) == FALSE) { + if (mPr_CheckCmpPersonalID(&sender_name->personalID, &Common_Get(now_private)->player_ID) == TRUE) { + priv = Common_Get(now_private); + } else { + int priv_idx = mPr_GetPrivateIdx(&sender_name->personalID); - if (priv != NULL) { - mActor_name_t present = mail->present; - - if (present != EMPTY_NO && present != RSV_NO) { - mMsm_record_c* record = &priv->museum_record; - - if (present == ITM_FOSSIL) { - u8 stored_fossils = record->stored_fossil_num; - - if (stored_fossils < mMsm_REMAIL_SLOTS) { - record->stored_fossil_num = stored_fossils + 1; + if (priv_idx != -1) { + priv = Save_Get(private_data + priv_idx); + } + } + + if (priv != NULL) { + mActor_name_t present = mail->present; + + if (present != EMPTY_NO && present != RSV_NO) { + mMsm_record_c* record = &priv->museum_record; + + if (present == ITM_FOSSIL) { + u8 stored_fossils = record->stored_fossil_num; + + if (stored_fossils < mMsm_REMAIL_SLOTS) { + record->stored_fossil_num = stored_fossils + 1; + } + } else { + mMsm_SetRemailInfo(&record->remail_info, priv, present); + record->remail_pending = TRUE; + } + } } - } - else { - mMsm_SetRemailInfo(&record->remail_info, priv, present); - record->remail_pending = TRUE; - } } - } } - } } extern int mMsm_GetDepositAbleNum(mActor_name_t* fg_items, mCoBG_Collision_u* col_data) { - int depositable_num = 0; - int i; + int depositable_num = 0; + int i; - if (fg_items != NULL && col_data != NULL) { - for (i = 0; i < UT_TOTAL_NUM; i++) { - if (*fg_items == EMPTY_NO && mCoBG_CheckHole_OrgAttr(col_data->data.unit_attribute)) { - depositable_num++; - } + if (fg_items != NULL && col_data != NULL) { + for (i = 0; i < UT_TOTAL_NUM; i++) { + if (*fg_items == EMPTY_NO && mCoBG_CheckHole_OrgAttr(col_data->data.unit_attribute)) { + depositable_num++; + } - fg_items++; - col_data++; + fg_items++; + col_data++; + } } - } - return depositable_num; + return depositable_num; } static int mMsm_GetDepositAbleNum_cancel(mActor_name_t* fg_items, mCoBG_Collision_u* col_data, u16* cancel_ut) { - int depositable_num = 0; - int ut_z; + int depositable_num = 0; + int ut_z; + + if (fg_items != NULL && col_data != NULL) { + 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 ((((*cancel_ut) >> ut_x) & 1) != TRUE && *fg_items == EMPTY_NO && + mCoBG_CheckHole_OrgAttr(col_data->data.unit_attribute)) { + depositable_num++; + } + + fg_items++; + col_data++; + } + + cancel_ut++; + } + } + + return depositable_num; +} + +extern void mMsm_DepositItemBlock_cancel(mActor_name_t* fg_items, mActor_name_t deposit_item, + mCoBG_Collision_u* col_data, u16* deposit, u16* cancel_ut, u8 valid_ut_count) { + int deposit_idx = RANDOM(valid_ut_count); + int ut_z; - if (fg_items != NULL && col_data != NULL) { 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 ((((*cancel_ut) >> ut_x) & 1) != TRUE && *fg_items == EMPTY_NO && mCoBG_CheckHole_OrgAttr(col_data->data.unit_attribute)) { - depositable_num++; + int ut_x; + + for (ut_x = 0; ut_x < UT_X_NUM; ut_x++) { + if ((((*cancel_ut) >> ut_x) & 1) != TRUE && *fg_items == EMPTY_NO && + mCoBG_CheckHole_OrgAttr(col_data->data.unit_attribute)) { + if (deposit_idx == 0) { + *fg_items = deposit_item; + ut_z = UT_Z_NUM; // break out of outer loop + *deposit |= (1 << ut_x); + break; + } else { + deposit_idx--; + } + } + + fg_items++; + col_data++; + } + + deposit++; + cancel_ut++; + } +} + +extern void mMsm_DepositItemBlock(mActor_name_t* fg_items, mActor_name_t item, int block_x, int block_z, u16* deposit, + u8 valid_ut_count) { + mCoBG_Collision_u* col_data = mFI_GetBkNum2ColTop(block_x, block_z); + int deposit_idx = RANDOM(valid_ut_count); + int ut; + + for (ut = 0; ut < UT_TOTAL_NUM; ut++) { + if (*fg_items == EMPTY_NO && mCoBG_CheckHole_OrgAttr(col_data->data.unit_attribute)) { + if (deposit_idx == 0) { + int ut_x = ut & (UT_X_NUM - 1); + int ut_z = ut >> 4; + + if (item != ITM_PITFALL) { + *fg_items = item; + deposit[ut_z] |= (1 << ut_x); + } else { + int hole_num = mCoBG_BnumUnum2HoleNumber(block_x, block_z, ut_x, ut_z); + + if (hole_num != -1) { + *fg_items = BURIED_PITFALL_START + hole_num; + } + } + + break; + } else { + deposit_idx--; + } } fg_items++; col_data++; - } - - cancel_ut++; } - } - - return depositable_num; } -extern void mMsm_DepositItemBlock_cancel(mActor_name_t* fg_items, mActor_name_t deposit_item, mCoBG_Collision_u* col_data, u16* deposit, u16* cancel_ut, u8 valid_ut_count) { - int deposit_idx = RANDOM(valid_ut_count); - 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 ((((*cancel_ut) >> ut_x) & 1) != TRUE && *fg_items == EMPTY_NO && mCoBG_CheckHole_OrgAttr(col_data->data.unit_attribute)) { - if (deposit_idx == 0) { - *fg_items = deposit_item; - ut_z = UT_Z_NUM; // break out of outer loop - *deposit |= (1 << ut_x); - break; - } - else { - deposit_idx--; - } - } - - fg_items++; - col_data++; - } - - deposit++; - cancel_ut++; - } -} - -extern void mMsm_DepositItemBlock(mActor_name_t* fg_items, mActor_name_t item, int block_x, int block_z, u16* deposit, u8 valid_ut_count) { - mCoBG_Collision_u* col_data = mFI_GetBkNum2ColTop(block_x, block_z); - int deposit_idx = RANDOM(valid_ut_count); - int ut; - - for (ut = 0; ut < UT_TOTAL_NUM; ut++) { - if (*fg_items == EMPTY_NO && mCoBG_CheckHole_OrgAttr(col_data->data.unit_attribute)) { - if (deposit_idx == 0) { - int ut_x = ut & (UT_X_NUM - 1); - int ut_z = ut >> 4; - - if (item != ITM_PITFALL) { - *fg_items = item; - deposit[ut_z] |= (1 << ut_x); - } - else { - int hole_num = mCoBG_BnumUnum2HoleNumber(block_x, block_z, ut_x, ut_z); - - if (hole_num != -1) { - *fg_items = BURIED_PITFALL_START + hole_num; - } - } - - break; - } - else { - deposit_idx--; - } - } - - fg_items++; - col_data++; - } -} - -static void mMsm_DepositFossilBlock(mActor_name_t* fg_items, mCoBG_Collision_u* col_data, u16* deposit, u16* cancel, u8 valid_ut_count) { - mMsm_DepositItemBlock_cancel(fg_items, ITM_FOSSIL, col_data, deposit, cancel, valid_ut_count); +static void mMsm_DepositFossilBlock(mActor_name_t* fg_items, mCoBG_Collision_u* col_data, u16* deposit, u16* cancel, + u8 valid_ut_count) { + mMsm_DepositItemBlock_cancel(fg_items, ITM_FOSSIL, col_data, deposit, cancel, valid_ut_count); } static void mMsm_DepositFossilBlockLine(int line, u16* cancel_ut) { - /* NOTE: line is a column (of Z-acres, for example the 1 column) */ + /* NOTE: line is a column (of Z-acres, for example the 1 column) */ - int depositable_acres; - u8 depositable_line[FG_BLOCK_Z_NUM]; - u16* cancel_ut_p; - int block_x = line + 1; - int block_z; + int depositable_acres; + u8 depositable_line[FG_BLOCK_Z_NUM]; + u16* cancel_ut_p; + int block_x = line + 1; + int block_z; - cancel_ut_p = cancel_ut; - depositable_acres = 0; - bzero(depositable_line, FG_BLOCK_Z_NUM * sizeof(u8)); - - for (block_z = 0; block_z < FG_BLOCK_Z_NUM; block_z++) { - int bad_acre = mFI_CheckBlockKind_OR( - block_x, block_z + 1, - mRF_BLOCKKIND_PLAYER | mRF_BLOCKKIND_SHRINE | mRF_BLOCKKIND_STATION | mRF_BLOCKKIND_POOL | mRF_BLOCKKIND_DUMP - ); - - if (bad_acre == FALSE) { - depositable_line[block_z] = mMsm_GetDepositAbleNum_cancel(Save_Get(fg[block_z][line]).items[0], mFI_GetBkNum2ColTop(block_x, block_z + 1), cancel_ut); - - if (depositable_line[block_z] != 0) { - depositable_acres++; - } - } - - cancel_ut += UT_Z_NUM * FG_BLOCK_X_NUM; - } - - if (depositable_acres > 0) { - int selected_z_acre; - - cancel_ut = cancel_ut_p; - selected_z_acre = RANDOM(depositable_acres); + cancel_ut_p = cancel_ut; + depositable_acres = 0; + bzero(depositable_line, FG_BLOCK_Z_NUM * sizeof(u8)); for (block_z = 0; block_z < FG_BLOCK_Z_NUM; block_z++) { - if (depositable_line[block_z] != 0) { - if (selected_z_acre == 0) { - mMsm_DepositFossilBlock(Save_Get(fg[block_z][line]).items[0], mFI_GetBkNum2ColTop(block_x, block_z + 1), Save_Get(deposit[line + block_z * FG_BLOCK_X_NUM]), cancel_ut, depositable_line[block_z]); - return; - } - else { - selected_z_acre--; - } - } + int bad_acre = mFI_CheckBlockKind_OR(block_x, block_z + 1, + mRF_BLOCKKIND_PLAYER | mRF_BLOCKKIND_SHRINE | mRF_BLOCKKIND_STATION | + mRF_BLOCKKIND_POOL | mRF_BLOCKKIND_DUMP); - cancel_ut += UT_Z_NUM * FG_BLOCK_X_NUM; + if (bad_acre == FALSE) { + depositable_line[block_z] = mMsm_GetDepositAbleNum_cancel( + Save_Get(fg[block_z][line]).items[0], mFI_GetBkNum2ColTop(block_x, block_z + 1), cancel_ut); + + if (depositable_line[block_z] != 0) { + depositable_acres++; + } + } + + cancel_ut += UT_Z_NUM * FG_BLOCK_X_NUM; + } + + if (depositable_acres > 0) { + int selected_z_acre; + + cancel_ut = cancel_ut_p; + selected_z_acre = RANDOM(depositable_acres); + + for (block_z = 0; block_z < FG_BLOCK_Z_NUM; block_z++) { + if (depositable_line[block_z] != 0) { + if (selected_z_acre == 0) { + mMsm_DepositFossilBlock( + Save_Get(fg[block_z][line]).items[0], mFI_GetBkNum2ColTop(block_x, block_z + 1), + Save_Get(deposit[line + block_z * FG_BLOCK_X_NUM]), cancel_ut, depositable_line[block_z]); + return; + } else { + selected_z_acre--; + } + } + + cancel_ut += UT_Z_NUM * FG_BLOCK_X_NUM; + } } - } } extern int mMsm_RecordDepositFossil(u8* record, mActor_name_t item, int block_x) { - int res = FALSE; + int res = FALSE; - if (item == ITM_FOSSIL) { - *record |= (1 << block_x); - res = TRUE; - } + if (item == ITM_FOSSIL) { + *record |= (1 << block_x); + res = TRUE; + } - return res; + return res; } extern u8 mMsm_GetDepositBlockNum(u8 record) { - u8 deposit_block_num = 0; - int block_x; + u8 deposit_block_num = 0; + int block_x; - for (block_x = 0; block_x < FG_BLOCK_X_NUM; block_x++) { - if (((record >> (block_x + 1)) & 1) == TRUE) { - deposit_block_num++; + for (block_x = 0; block_x < FG_BLOCK_X_NUM; block_x++) { + if (((record >> (block_x + 1)) & 1) == TRUE) { + deposit_block_num++; + } } - } - return deposit_block_num; + return deposit_block_num; } extern void mMsm_DepositFossil(u8 deposit_record, int fossil_count, u16* cancel_ut, int send_order_info) { - int deposit_count; - u16* cancel_ut_p = cancel_ut; - u8 already_deposited = mMsm_GetDepositBlockNum(deposit_record); - u8 available_blocks; - - if (fossil_count < mMsm_DEPOSIT_FOSSIL_MAX) { - deposit_count = mMsm_DEPOSIT_FOSSIL_MAX - fossil_count; - available_blocks = FG_BLOCK_X_NUM - already_deposited; + int deposit_count; + u16* cancel_ut_p = cancel_ut; + u8 already_deposited = mMsm_GetDepositBlockNum(deposit_record); + u8 available_blocks; - while (deposit_count > 0 && available_blocks != 0) { - int selected_row; - int block_x; + if (fossil_count < mMsm_DEPOSIT_FOSSIL_MAX) { + deposit_count = mMsm_DEPOSIT_FOSSIL_MAX - fossil_count; + available_blocks = FG_BLOCK_X_NUM - already_deposited; - cancel_ut = cancel_ut_p; - selected_row = RANDOM(available_blocks); - - for (block_x = 0; block_x < FG_BLOCK_X_NUM; block_x++) { - if (((deposit_record >> (block_x + 1)) & 1) == FALSE) { - if (selected_row <= 0) { - mMsm_DepositFossilBlockLine(block_x, cancel_ut); - available_blocks--; - deposit_record |= (1 << (block_x + 1)); - break; - } - else { - selected_row--; - } + while (deposit_count > 0 && available_blocks != 0) { + int selected_row; + int block_x; + + cancel_ut = cancel_ut_p; + selected_row = RANDOM(available_blocks); + + for (block_x = 0; block_x < FG_BLOCK_X_NUM; block_x++) { + if (((deposit_record >> (block_x + 1)) & 1) == FALSE) { + if (selected_row <= 0) { + mMsm_DepositFossilBlockLine(block_x, cancel_ut); + available_blocks--; + deposit_record |= (1 << (block_x + 1)); + break; + } else { + selected_row--; + } + } + + cancel_ut += UT_Z_NUM; + } + + deposit_count--; } - cancel_ut += UT_Z_NUM; - } - - deposit_count--; + if (send_order_info) { + mMsm_OrderInformationMail(); + } } - if (send_order_info) { - mMsm_OrderInformationMail(); - } - } - - mMsm_SendResultMail(); - mMsm_SendInformationMail(); + mMsm_SendResultMail(); + mMsm_SendInformationMail(); } static void mMsm_SetPrivateCompMail(Private_c* priv, int flag) { - if (priv != NULL) { - priv->state_flags |= flag; - } + if (priv != NULL) { + priv->state_flags |= flag; + } } static int mMsm_CheckSendCompMail() { - Private_c* priv = Save_Get(private); - int res = FALSE; - int i; - - for (i = 0; i < PLAYER_NUM; i++) { - if (mPr_NullCheckPersonalID(&priv->player_ID) == FALSE && (priv->state_flags & mPr_FLAG_MUSEUM_COMP_HANDBILL_SCHEDULED)) { - res = TRUE; - break; + Private_c* priv = Save_Get(private_data); + int res = FALSE; + int i; + + for (i = 0; i < PLAYER_NUM; i++) { + if (mPr_NullCheckPersonalID(&priv->player_ID) == FALSE && + (priv->state_flags & mPr_FLAG_MUSEUM_COMP_HANDBILL_SCHEDULED)) { + res = TRUE; + break; + } + + priv++; } - priv++; - } - - return res; + return res; } static void mMsm_SetSendCompMail() { - Private_c* priv = Save_Get(private); - int i; + Private_c* priv = Save_Get(private_data); + int i; - for (i = 0; i < PLAYER_NUM; i++) { - if (mPr_NullCheckPersonalID(&priv->player_ID) == FALSE) { - mMsm_SetPrivateCompMail(priv, mPr_FLAG_MUSEUM_COMP_HANDBILL_SCHEDULED); + for (i = 0; i < PLAYER_NUM; i++) { + if (mPr_NullCheckPersonalID(&priv->player_ID) == FALSE) { + mMsm_SetPrivateCompMail(priv, mPr_FLAG_MUSEUM_COMP_HANDBILL_SCHEDULED); + } + + priv++; } - - priv++; - } } extern void mMsm_SetCompMail() { - if ( - mMsm_CheckSendCompMail() == FALSE && - mMmd_CountDisplayedFossil() == mMmd_FOSSIL_NUM && - mMmd_CountDisplayedArt() == mMmd_ART_NUM && - mMmd_CountDisplayedInsect() == mMmd_INSECT_NUM && - mMmd_CountDisplayedFish() == mMmd_FISH_NUM - ) { - mMsm_SetSendCompMail(); - } + if (mMsm_CheckSendCompMail() == FALSE && mMmd_CountDisplayedFossil() == mMmd_FOSSIL_NUM && + mMmd_CountDisplayedArt() == mMmd_ART_NUM && mMmd_CountDisplayedInsect() == mMmd_INSECT_NUM && + mMmd_CountDisplayedFish() == mMmd_FISH_NUM) { + mMsm_SetSendCompMail(); + } } extern void mMsm_SendCompMail() { - Private_c* priv = Save_Get(private); - int state_flags; - int i; + Private_c* priv = Save_Get(private_data); + int state_flags; + int i; - for (i = 0; i < PLAYER_NUM; i++) { - state_flags = priv->state_flags; - if (mPr_NullCheckPersonalID(&priv->player_ID) == FALSE) { - /* Send completion letter & reward if scheduled but not yet received. */ - - if ( - (state_flags & mPr_FLAG_MUSEUM_COMP_HANDBILL_SCHEDULED) != 0 && - (state_flags & mPr_FLAG_MUSEUM_COMP_HANDBILL_RECEIVED) == 0 - ) { - int land_name_len = mMsg_Get_Length_String(Save_Get(land_info.name), LAND_NAME_SIZE); - - mHandbill_Set_free_str(mHandbill_FREE_STR0, Save_Get(land_info.name), land_name_len); + for (i = 0; i < PLAYER_NUM; i++) { + state_flags = priv->state_flags; + if (mPr_NullCheckPersonalID(&priv->player_ID) == FALSE) { + /* Send completion letter & reward if scheduled but not yet received. */ - if (mMl_send_mail_postoffice(&priv->player_ID, i, FTR_MUSEUM_MODEL, ITM_PAPER24, 0x22F, l_museum_name_str, mMl_DATA2, mMl_TYPE_MAIL) == TRUE) { - mMsm_SetPrivateCompMail(priv, mPr_FLAG_MUSEUM_COMP_HANDBILL_RECEIVED); + if ((state_flags & mPr_FLAG_MUSEUM_COMP_HANDBILL_SCHEDULED) != 0 && + (state_flags & mPr_FLAG_MUSEUM_COMP_HANDBILL_RECEIVED) == 0) { + int land_name_len = mMsg_Get_Length_String(Save_Get(land_info.name), LAND_NAME_SIZE); + + mHandbill_Set_free_str(mHandbill_FREE_STR0, Save_Get(land_info.name), land_name_len); + + if (mMl_send_mail_postoffice(&priv->player_ID, i, FTR_MUSEUM_MODEL, ITM_PAPER24, 0x22F, + l_museum_name_str, mMl_DATA2, mMl_TYPE_MAIL) == TRUE) { + mMsm_SetPrivateCompMail(priv, mPr_FLAG_MUSEUM_COMP_HANDBILL_RECEIVED); + } + } } - } - } - priv++; - } + priv++; + } } diff --git a/src/m_needlework.c b/src/m_needlework.c index 0d158fc2..e3721607 100644 --- a/src/m_needlework.c +++ b/src/m_needlework.c @@ -9,371 +9,351 @@ /** * @brief Initializes all designs' palette indexes for a player. - * + * * @param player_no The index of the player whose designs will be updated **/ static void mNW_InitMyOriginalPallet(int player_no) { - static u8 pal_table[mPr_ORIGINAL_DESIGN_COUNT] = { - 0, 8, 7, 7, - 0, 0, 0, 0 - }; + static u8 pal_table[mPr_ORIGINAL_DESIGN_COUNT] = { 0, 8, 7, 7, 0, 0, 0, 0 }; - int i; + int i; - for (i = 0; i < mPr_ORIGINAL_DESIGN_COUNT; i++) { - Save_Set(private[player_no & 3].my_org[i & 7].palette, pal_table[i]); - } + for (i = 0; i < mPr_ORIGINAL_DESIGN_COUNT; i++) { + Save_Set(private_data[player_no & 3].my_org[i & 7].palette, pal_table[i]); + } } /** * @brief Initializes all designs' names for a player. - * + * * @param player_no The index of the player whose designs will be renamed **/ static void mNW_InitMyOriginalName(int player_no) { - int i; + int i; - player_no &= 3; - for (i = 0; i < mPr_ORIGINAL_DESIGN_COUNT; i++) { - /* TODO: define for the string index? */ - mString_Load_StringFromRom( - Save_Get(private[player_no].my_org[i & 7].name), - mNW_ORIGINAL_DESIGN_NAME_LEN, - 0x6DF + i - ); - } + player_no &= 3; + for (i = 0; i < mPr_ORIGINAL_DESIGN_COUNT; i++) { + /* TODO: define for the string index? */ + mString_Load_StringFromRom(Save_Get(private_data[player_no].my_org[i & 7].name), mNW_ORIGINAL_DESIGN_NAME_LEN, + 0x6DF + i); + } } /** * @brief Initializes all designs' textures for a player. - * + * * @param player_no The index of the player whose designs will be updated **/ static void mNW_InitMyOriginalTexture(int player_no) { - int i; + int i; - player_no &= 3; - for (i = 0; i < mNW_DEFAULT_ORIGINAL_TEX_NUM; i++) { - _JW_GetResourceAram( - JW_GetAramAddress(27) + i * mNW_DESIGN_TEX_SIZE, - Save_Get(private[player_no].my_org[i & 7].design.data), - mNW_DESIGN_TEX_SIZE - ); - } + player_no &= 3; + for (i = 0; i < mNW_DEFAULT_ORIGINAL_TEX_NUM; i++) { + _JW_GetResourceAram(JW_GetAramAddress(27) + i * mNW_DESIGN_TEX_SIZE, + Save_Get(private_data[player_no].my_org[i & 7].design.data), mNW_DESIGN_TEX_SIZE); + } } /** * @brief Initializes all designs for all players. **/ extern void mNW_InitMyOriginal() { - int i; + int i; - for (i = 0; i < PLAYER_NUM; i++) { - mNW_InitOneMyOriginal(i); - } + for (i = 0; i < PLAYER_NUM; i++) { + mNW_InitOneMyOriginal(i); + } } /** * @brief Initializes a single player's designs. - * + * * @param player_no The index of the player whose designs will be initialized. **/ extern void mNW_InitOneMyOriginal(int player_no) { - int i; + int i; - mNW_InitMyOriginalPallet(player_no & 3); - mNW_InitMyOriginalName(player_no & 3); - mNW_InitMyOriginalTexture(player_no & 3); + mNW_InitMyOriginalPallet(player_no & 3); + mNW_InitMyOriginalName(player_no & 3); + mNW_InitMyOriginalTexture(player_no & 3); - for (i = mNW_DEFAULT_ORIGINAL_TEX_NUM; i < mPr_ORIGINAL_DESIGN_COUNT; i++) { - mNW_InitOriginalData(Save_Get(private[player_no].my_org + (i & 7))); - } + for (i = mNW_DEFAULT_ORIGINAL_TEX_NUM; i < mPr_ORIGINAL_DESIGN_COUNT; i++) { + mNW_InitOriginalData(Save_Get(private_data[player_no].my_org + (i & 7))); + } } /** * @brief Copies a default design texture into the supplied buffer. - * + * * @param dst The destination design texture buffer * @param tex_no The index of the texture to retrieve (0-7) **/ static void mNW_CopyNeedleworkDefaultTexture(u8* dst, int tex_no) { - u32 addr = JW_GetAramAddress(28); - _JW_GetResourceAram( - addr + (tex_no & 7) * mNW_DESIGN_TEX_SIZE, - dst, - mNW_DESIGN_TEX_SIZE - ); + u32 addr = JW_GetAramAddress(28); + _JW_GetResourceAram(addr + (tex_no & 7) * mNW_DESIGN_TEX_SIZE, dst, mNW_DESIGN_TEX_SIZE); } /** * @brief Initializes all Able Sisters' designs to their default textures. **/ static void mNW_InitNeedleworkTexture() { - int i; + int i; - for (i = 0; i < mNW_TOTAL_DESIGN_NUM; i++) { - mNW_CopyNeedleworkDefaultTexture(Save_Get(needlework.original_design[i & 7].design.data), i); - } + for (i = 0; i < mNW_TOTAL_DESIGN_NUM; i++) { + mNW_CopyNeedleworkDefaultTexture(Save_Get(needlework.original_design[i & 7].design.data), i); + } } /** * @brief Initializes all Able Sisters' designs to their default palettes. **/ static void mNW_InitNeedleworkPelatteNo() { - static u8 pal_table[mNW_TOTAL_DESIGN_NUM] = { - 7, 1, 10, 3, - 6, 0, 6, 7 - }; + static u8 pal_table[mNW_TOTAL_DESIGN_NUM] = { 7, 1, 10, 3, 6, 0, 6, 7 }; - int i; + int i; - for (i = 0; i < mNW_TOTAL_DESIGN_NUM; i++) { - Save_Set(needlework.original_design[i & 7].palette, pal_table[i]); - } + for (i = 0; i < mNW_TOTAL_DESIGN_NUM; i++) { + Save_Set(needlework.original_design[i & 7].palette, pal_table[i]); + } } /** * @brief Initializes all Able Sisters' designs to their default names. **/ static void mNW_InitNeedleworkTextureName() { - int i; + int i; - for (i = 0; i < mNW_TOTAL_DESIGN_NUM; i++) { - mString_Load_StringFromRom( - Save_Get(needlework.original_design[i & 7].name), - mNW_ORIGINAL_DESIGN_NAME_LEN, - 0x6E7 + i - ); - } + for (i = 0; i < mNW_TOTAL_DESIGN_NUM; i++) { + mString_Load_StringFromRom(Save_Get(needlework.original_design[i & 7].name), mNW_ORIGINAL_DESIGN_NAME_LEN, + 0x6E7 + i); + } } /** * @brief Initializes all Able Sisters' designs to their default data. **/ extern void mNW_InitNeedleworkData() { - mNW_InitNeedleworkTexture(); - mNW_InitNeedleworkPelatteNo(); - mNW_InitNeedleworkTextureName(); + mNW_InitNeedleworkTexture(); + mNW_InitNeedleworkPelatteNo(); + mNW_InitNeedleworkTextureName(); } /** * @brief Converts a design texture from GBA format to GC format. - * + * * @param agb Pointer to the source GBA texture * @param gc Pointer to the destination GC texture **/ extern void mNW_AGB_to_GC_texture(u8* agb, u8* gc) { - int i; + int i; - for (i = 0; i < mNW_DESIGN_TEX_SIZE; i++) { - u8 src = *agb++; - *gc++ = (((src >> 4) & 0xF) | ((src & 0xF) << 4)); - } + for (i = 0; i < mNW_DESIGN_TEX_SIZE; i++) { + u8 src = *agb++; + *gc++ = (((src >> 4) & 0xF) | ((src & 0xF) << 4)); + } } /** * @brief Converts a design texture from GC format to GBA format. - * + * * @param gc Pointer to the source GC texture * @param agb Pointer to the destination GBA texture **/ extern void mNW_GC_to_Agb_texture(u8* gc, u8* agb) { - mNW_AGB_to_GC_texture(gc, agb); + mNW_AGB_to_GC_texture(gc, agb); } /* RGB5A3 color palettes for each pattern palette aligned to 32 bytes */ /* These are aligned to 32 bytes for transfering to-and-from ARAM */ static u16 needlework0_pal[16] ATTRIBUTE_ALIGN(32) = { - ARGB8_to_RGB5A3(0xFF525252), ARGB8_to_RGB5A3(0xFFCE4A4A), ARGB8_to_RGB5A3(0xFFDE8442), ARGB8_to_RGB5A3(0xFFE7AD18), - ARGB8_to_RGB5A3(0xFFE7C621), ARGB8_to_RGB5A3(0xFFD6DE18), ARGB8_to_RGB5A3(0xFFB5E718), ARGB8_to_RGB5A3(0xFF84D652), - ARGB8_to_RGB5A3(0xFF39C66B), ARGB8_to_RGB5A3(0xFF29ADC6), ARGB8_to_RGB5A3(0xFF427BEF), ARGB8_to_RGB5A3(0xFF6B4AE7), - ARGB8_to_RGB5A3(0xFF945ACE), ARGB8_to_RGB5A3(0xFFBD42B5), ARGB8_to_RGB5A3(0xFF000000), ARGB8_to_RGB5A3(0xFFFFFFFF), + ARGB8_to_RGB5A3(0xFF525252), ARGB8_to_RGB5A3(0xFFCE4A4A), ARGB8_to_RGB5A3(0xFFDE8442), ARGB8_to_RGB5A3(0xFFE7AD18), + ARGB8_to_RGB5A3(0xFFE7C621), ARGB8_to_RGB5A3(0xFFD6DE18), ARGB8_to_RGB5A3(0xFFB5E718), ARGB8_to_RGB5A3(0xFF84D652), + ARGB8_to_RGB5A3(0xFF39C66B), ARGB8_to_RGB5A3(0xFF29ADC6), ARGB8_to_RGB5A3(0xFF427BEF), ARGB8_to_RGB5A3(0xFF6B4AE7), + ARGB8_to_RGB5A3(0xFF945ACE), ARGB8_to_RGB5A3(0xFFBD42B5), ARGB8_to_RGB5A3(0xFF000000), ARGB8_to_RGB5A3(0xFFFFFFFF), }; static u16 needlework1_pal[16] ATTRIBUTE_ALIGN(32) = { - ARGB8_to_RGB5A3(0xFF525252), ARGB8_to_RGB5A3(0xFFFF8C8C), ARGB8_to_RGB5A3(0xFFFFCE84), ARGB8_to_RGB5A3(0xFFFFE75A), - ARGB8_to_RGB5A3(0xFFFFF763), ARGB8_to_RGB5A3(0xFFFFFF84), ARGB8_to_RGB5A3(0xFFDEFF52), ARGB8_to_RGB5A3(0xFFB5FF84), - ARGB8_to_RGB5A3(0xFF7BF7AD), ARGB8_to_RGB5A3(0xFF63E7F7), ARGB8_to_RGB5A3(0xFF84C6FF), ARGB8_to_RGB5A3(0xFFA59CFF), - ARGB8_to_RGB5A3(0xFFD69CFF), ARGB8_to_RGB5A3(0xFFFF9CF7), ARGB8_to_RGB5A3(0xFF8C8C8C), ARGB8_to_RGB5A3(0xFFFFFFFF), + ARGB8_to_RGB5A3(0xFF525252), ARGB8_to_RGB5A3(0xFFFF8C8C), ARGB8_to_RGB5A3(0xFFFFCE84), ARGB8_to_RGB5A3(0xFFFFE75A), + ARGB8_to_RGB5A3(0xFFFFF763), ARGB8_to_RGB5A3(0xFFFFFF84), ARGB8_to_RGB5A3(0xFFDEFF52), ARGB8_to_RGB5A3(0xFFB5FF84), + ARGB8_to_RGB5A3(0xFF7BF7AD), ARGB8_to_RGB5A3(0xFF63E7F7), ARGB8_to_RGB5A3(0xFF84C6FF), ARGB8_to_RGB5A3(0xFFA59CFF), + ARGB8_to_RGB5A3(0xFFD69CFF), ARGB8_to_RGB5A3(0xFFFF9CF7), ARGB8_to_RGB5A3(0xFF8C8C8C), ARGB8_to_RGB5A3(0xFFFFFFFF), }; static u16 needlework2_pal[16] ATTRIBUTE_ALIGN(32) = { - ARGB8_to_RGB5A3(0xFF525252), ARGB8_to_RGB5A3(0xFF9C1818), ARGB8_to_RGB5A3(0xFFAD5208), ARGB8_to_RGB5A3(0xFFB57B00), - ARGB8_to_RGB5A3(0xFFB59400), ARGB8_to_RGB5A3(0xFFA5AD00), ARGB8_to_RGB5A3(0xFF84B500), ARGB8_to_RGB5A3(0xFF52A531), - ARGB8_to_RGB5A3(0xFF089439), ARGB8_to_RGB5A3(0xFF007B94), ARGB8_to_RGB5A3(0xFF104ABD), ARGB8_to_RGB5A3(0xFF3918AD), - ARGB8_to_RGB5A3(0xFF5A2994), ARGB8_to_RGB5A3(0xFF8C087B), ARGB8_to_RGB5A3(0xFF080808), ARGB8_to_RGB5A3(0xFFFFFFFF), + ARGB8_to_RGB5A3(0xFF525252), ARGB8_to_RGB5A3(0xFF9C1818), ARGB8_to_RGB5A3(0xFFAD5208), ARGB8_to_RGB5A3(0xFFB57B00), + ARGB8_to_RGB5A3(0xFFB59400), ARGB8_to_RGB5A3(0xFFA5AD00), ARGB8_to_RGB5A3(0xFF84B500), ARGB8_to_RGB5A3(0xFF52A531), + ARGB8_to_RGB5A3(0xFF089439), ARGB8_to_RGB5A3(0xFF007B94), ARGB8_to_RGB5A3(0xFF104ABD), ARGB8_to_RGB5A3(0xFF3918AD), + ARGB8_to_RGB5A3(0xFF5A2994), ARGB8_to_RGB5A3(0xFF8C087B), ARGB8_to_RGB5A3(0xFF080808), ARGB8_to_RGB5A3(0xFFFFFFFF), }; static u16 needlework3_pal[16] ATTRIBUTE_ALIGN(32) = { - ARGB8_to_RGB5A3(0xFF525252), ARGB8_to_RGB5A3(0xFF42945A), ARGB8_to_RGB5A3(0xFF73C68C), ARGB8_to_RGB5A3(0xFF94E7AD), - ARGB8_to_RGB5A3(0xFF008C7B), ARGB8_to_RGB5A3(0xFF5AB5AD), ARGB8_to_RGB5A3(0xFF84C6C6), ARGB8_to_RGB5A3(0xFF2173A5), - ARGB8_to_RGB5A3(0xFF4A9CCE), ARGB8_to_RGB5A3(0xFF6BADDE), ARGB8_to_RGB5A3(0xFF7384BD), ARGB8_to_RGB5A3(0xFF6B73AD), - ARGB8_to_RGB5A3(0xFF525294), ARGB8_to_RGB5A3(0xFF39397B), ARGB8_to_RGB5A3(0xFF181863), ARGB8_to_RGB5A3(0xFFFFFFFF), + ARGB8_to_RGB5A3(0xFF525252), ARGB8_to_RGB5A3(0xFF42945A), ARGB8_to_RGB5A3(0xFF73C68C), ARGB8_to_RGB5A3(0xFF94E7AD), + ARGB8_to_RGB5A3(0xFF008C7B), ARGB8_to_RGB5A3(0xFF5AB5AD), ARGB8_to_RGB5A3(0xFF84C6C6), ARGB8_to_RGB5A3(0xFF2173A5), + ARGB8_to_RGB5A3(0xFF4A9CCE), ARGB8_to_RGB5A3(0xFF6BADDE), ARGB8_to_RGB5A3(0xFF7384BD), ARGB8_to_RGB5A3(0xFF6B73AD), + ARGB8_to_RGB5A3(0xFF525294), ARGB8_to_RGB5A3(0xFF39397B), ARGB8_to_RGB5A3(0xFF181863), ARGB8_to_RGB5A3(0xFFFFFFFF), }; static u16 needlework4_pal[16] ATTRIBUTE_ALIGN(32) = { - ARGB8_to_RGB5A3(0xFF525252), ARGB8_to_RGB5A3(0xFF9C8452), ARGB8_to_RGB5A3(0xFFBD945A), ARGB8_to_RGB5A3(0xFFD6BD84), - ARGB8_to_RGB5A3(0xFF9C5252), ARGB8_to_RGB5A3(0xFFCE7363), ARGB8_to_RGB5A3(0xFFEF9C8C), ARGB8_to_RGB5A3(0xFF8C6384), - ARGB8_to_RGB5A3(0xFFA584B5), ARGB8_to_RGB5A3(0xFFDEB5DE), ARGB8_to_RGB5A3(0xFFBD8484), ARGB8_to_RGB5A3(0xFFAD736B), - ARGB8_to_RGB5A3(0xFF945252), ARGB8_to_RGB5A3(0xFF7B3939), ARGB8_to_RGB5A3(0xFF631810), ARGB8_to_RGB5A3(0xFFFFFFFF), + ARGB8_to_RGB5A3(0xFF525252), ARGB8_to_RGB5A3(0xFF9C8452), ARGB8_to_RGB5A3(0xFFBD945A), ARGB8_to_RGB5A3(0xFFD6BD84), + ARGB8_to_RGB5A3(0xFF9C5252), ARGB8_to_RGB5A3(0xFFCE7363), ARGB8_to_RGB5A3(0xFFEF9C8C), ARGB8_to_RGB5A3(0xFF8C6384), + ARGB8_to_RGB5A3(0xFFA584B5), ARGB8_to_RGB5A3(0xFFDEB5DE), ARGB8_to_RGB5A3(0xFFBD8484), ARGB8_to_RGB5A3(0xFFAD736B), + ARGB8_to_RGB5A3(0xFF945252), ARGB8_to_RGB5A3(0xFF7B3939), ARGB8_to_RGB5A3(0xFF631810), ARGB8_to_RGB5A3(0xFFFFFFFF), }; static u16 needlework5_pal[16] ATTRIBUTE_ALIGN(32) = { - ARGB8_to_RGB5A3(0xFF525252), ARGB8_to_RGB5A3(0xFFEF5A00), ARGB8_to_RGB5A3(0xFFFF9C42), ARGB8_to_RGB5A3(0xFFFFCE84), - ARGB8_to_RGB5A3(0xFFFFEFA5), ARGB8_to_RGB5A3(0xFF8C4A29), ARGB8_to_RGB5A3(0xFFB57B5A), ARGB8_to_RGB5A3(0xFFE7AD8C), - ARGB8_to_RGB5A3(0xFFFFDEBD), ARGB8_to_RGB5A3(0xFF318CFF), ARGB8_to_RGB5A3(0xFF63B5FF), ARGB8_to_RGB5A3(0xFF9CDEFF), - ARGB8_to_RGB5A3(0xFFC6E7FF), ARGB8_to_RGB5A3(0xFF6B6B6B), ARGB8_to_RGB5A3(0xFF000000), ARGB8_to_RGB5A3(0xFFFFFFFF), + ARGB8_to_RGB5A3(0xFF525252), ARGB8_to_RGB5A3(0xFFEF5A00), ARGB8_to_RGB5A3(0xFFFF9C42), ARGB8_to_RGB5A3(0xFFFFCE84), + ARGB8_to_RGB5A3(0xFFFFEFA5), ARGB8_to_RGB5A3(0xFF8C4A29), ARGB8_to_RGB5A3(0xFFB57B5A), ARGB8_to_RGB5A3(0xFFE7AD8C), + ARGB8_to_RGB5A3(0xFFFFDEBD), ARGB8_to_RGB5A3(0xFF318CFF), ARGB8_to_RGB5A3(0xFF63B5FF), ARGB8_to_RGB5A3(0xFF9CDEFF), + ARGB8_to_RGB5A3(0xFFC6E7FF), ARGB8_to_RGB5A3(0xFF6B6B6B), ARGB8_to_RGB5A3(0xFF000000), ARGB8_to_RGB5A3(0xFFFFFFFF), }; static u16 needlework6_pal[16] ATTRIBUTE_ALIGN(32) = { - ARGB8_to_RGB5A3(0xFF525252), ARGB8_to_RGB5A3(0xFF39B542), ARGB8_to_RGB5A3(0xFF63DE5A), ARGB8_to_RGB5A3(0xFF8CEF84), - ARGB8_to_RGB5A3(0xFFB5FFAD), ARGB8_to_RGB5A3(0xFF2121C6), ARGB8_to_RGB5A3(0xFF5252F7), ARGB8_to_RGB5A3(0xFF8484FF), - ARGB8_to_RGB5A3(0xFFB5B5FF), ARGB8_to_RGB5A3(0xFFCE3939), ARGB8_to_RGB5A3(0xFFDE6B6B), ARGB8_to_RGB5A3(0xFFE78C9C), - ARGB8_to_RGB5A3(0xFFEFBDBD), ARGB8_to_RGB5A3(0xFF6B6B6B), ARGB8_to_RGB5A3(0xFF000000), ARGB8_to_RGB5A3(0xFFFFFFFF), + ARGB8_to_RGB5A3(0xFF525252), ARGB8_to_RGB5A3(0xFF39B542), ARGB8_to_RGB5A3(0xFF63DE5A), ARGB8_to_RGB5A3(0xFF8CEF84), + ARGB8_to_RGB5A3(0xFFB5FFAD), ARGB8_to_RGB5A3(0xFF2121C6), ARGB8_to_RGB5A3(0xFF5252F7), ARGB8_to_RGB5A3(0xFF8484FF), + ARGB8_to_RGB5A3(0xFFB5B5FF), ARGB8_to_RGB5A3(0xFFCE3939), ARGB8_to_RGB5A3(0xFFDE6B6B), ARGB8_to_RGB5A3(0xFFE78C9C), + ARGB8_to_RGB5A3(0xFFEFBDBD), ARGB8_to_RGB5A3(0xFF6B6B6B), ARGB8_to_RGB5A3(0xFF000000), ARGB8_to_RGB5A3(0xFFFFFFFF), }; static u16 needlework7_pal[16] ATTRIBUTE_ALIGN(32) = { - ARGB8_to_RGB5A3(0xFF525252), ARGB8_to_RGB5A3(0xFF082100), ARGB8_to_RGB5A3(0xFF425A39), ARGB8_to_RGB5A3(0xFF6B8463), - ARGB8_to_RGB5A3(0xFF9CB594), ARGB8_to_RGB5A3(0xFF5A2900), ARGB8_to_RGB5A3(0xFF7B4A21), ARGB8_to_RGB5A3(0xFFA5734A), - ARGB8_to_RGB5A3(0xFFD6A57B), ARGB8_to_RGB5A3(0xFF947B00), ARGB8_to_RGB5A3(0xFFB59439), ARGB8_to_RGB5A3(0xFFCEB56B), - ARGB8_to_RGB5A3(0xFFDED69C), ARGB8_to_RGB5A3(0xFF6B6B6B), ARGB8_to_RGB5A3(0xFF000000), ARGB8_to_RGB5A3(0xFFFFFFFF), + ARGB8_to_RGB5A3(0xFF525252), ARGB8_to_RGB5A3(0xFF082100), ARGB8_to_RGB5A3(0xFF425A39), ARGB8_to_RGB5A3(0xFF6B8463), + ARGB8_to_RGB5A3(0xFF9CB594), ARGB8_to_RGB5A3(0xFF5A2900), ARGB8_to_RGB5A3(0xFF7B4A21), ARGB8_to_RGB5A3(0xFFA5734A), + ARGB8_to_RGB5A3(0xFFD6A57B), ARGB8_to_RGB5A3(0xFF947B00), ARGB8_to_RGB5A3(0xFFB59439), ARGB8_to_RGB5A3(0xFFCEB56B), + ARGB8_to_RGB5A3(0xFFDED69C), ARGB8_to_RGB5A3(0xFF6B6B6B), ARGB8_to_RGB5A3(0xFF000000), ARGB8_to_RGB5A3(0xFFFFFFFF), }; static u16 needlework8_pal[16] ATTRIBUTE_ALIGN(32) = { - ARGB8_to_RGB5A3(0xFF525252), ARGB8_to_RGB5A3(0xFF2121FF), ARGB8_to_RGB5A3(0xFFFF2121), ARGB8_to_RGB5A3(0xFFD6D600), - ARGB8_to_RGB5A3(0xFF6363FF), ARGB8_to_RGB5A3(0xFFFF6363), ARGB8_to_RGB5A3(0xFFD6D663), ARGB8_to_RGB5A3(0xFF9494FF), - ARGB8_to_RGB5A3(0xFFFF9494), ARGB8_to_RGB5A3(0xFFD6D694), ARGB8_to_RGB5A3(0xFFADADFF), ARGB8_to_RGB5A3(0xFFFFADAD), - ARGB8_to_RGB5A3(0xFFE7E7AD), ARGB8_to_RGB5A3(0xFF6B6B6B), ARGB8_to_RGB5A3(0xFF000000), ARGB8_to_RGB5A3(0xFFFFFFFF), + ARGB8_to_RGB5A3(0xFF525252), ARGB8_to_RGB5A3(0xFF2121FF), ARGB8_to_RGB5A3(0xFFFF2121), ARGB8_to_RGB5A3(0xFFD6D600), + ARGB8_to_RGB5A3(0xFF6363FF), ARGB8_to_RGB5A3(0xFFFF6363), ARGB8_to_RGB5A3(0xFFD6D663), ARGB8_to_RGB5A3(0xFF9494FF), + ARGB8_to_RGB5A3(0xFFFF9494), ARGB8_to_RGB5A3(0xFFD6D694), ARGB8_to_RGB5A3(0xFFADADFF), ARGB8_to_RGB5A3(0xFFFFADAD), + ARGB8_to_RGB5A3(0xFFE7E7AD), ARGB8_to_RGB5A3(0xFF6B6B6B), ARGB8_to_RGB5A3(0xFF000000), ARGB8_to_RGB5A3(0xFFFFFFFF), }; static u16 needlework9_pal[16] ATTRIBUTE_ALIGN(32) = { - ARGB8_to_RGB5A3(0xFF525252), ARGB8_to_RGB5A3(0xFF21A521), ARGB8_to_RGB5A3(0xFF39ADFF), ARGB8_to_RGB5A3(0xFF9C52EF), - ARGB8_to_RGB5A3(0xFF52BD52), ARGB8_to_RGB5A3(0xFF5AC6FF), ARGB8_to_RGB5A3(0xFFB59CFF), ARGB8_to_RGB5A3(0xFF6BD673), - ARGB8_to_RGB5A3(0xFF8CE7FF), ARGB8_to_RGB5A3(0xFFCEB5FF), ARGB8_to_RGB5A3(0xFF94DEAD), ARGB8_to_RGB5A3(0xFFBDF7FF), - ARGB8_to_RGB5A3(0xFFD6CEFF), ARGB8_to_RGB5A3(0xFF6B6B6B), ARGB8_to_RGB5A3(0xFF000000), ARGB8_to_RGB5A3(0xFFFFFFFF), + ARGB8_to_RGB5A3(0xFF525252), ARGB8_to_RGB5A3(0xFF21A521), ARGB8_to_RGB5A3(0xFF39ADFF), ARGB8_to_RGB5A3(0xFF9C52EF), + ARGB8_to_RGB5A3(0xFF52BD52), ARGB8_to_RGB5A3(0xFF5AC6FF), ARGB8_to_RGB5A3(0xFFB59CFF), ARGB8_to_RGB5A3(0xFF6BD673), + ARGB8_to_RGB5A3(0xFF8CE7FF), ARGB8_to_RGB5A3(0xFFCEB5FF), ARGB8_to_RGB5A3(0xFF94DEAD), ARGB8_to_RGB5A3(0xFFBDF7FF), + ARGB8_to_RGB5A3(0xFFD6CEFF), ARGB8_to_RGB5A3(0xFF6B6B6B), ARGB8_to_RGB5A3(0xFF000000), ARGB8_to_RGB5A3(0xFFFFFFFF), }; static u16 needlework10_pal[16] ATTRIBUTE_ALIGN(32) = { - ARGB8_to_RGB5A3(0xFF525252), ARGB8_to_RGB5A3(0xFFD60000), ARGB8_to_RGB5A3(0xFFFFBD00), ARGB8_to_RGB5A3(0xFFEFF731), - ARGB8_to_RGB5A3(0xFF4ACE42), ARGB8_to_RGB5A3(0xFF299C29), ARGB8_to_RGB5A3(0xFF528CBD), ARGB8_to_RGB5A3(0xFF424AAD), - ARGB8_to_RGB5A3(0xFF9452D6), ARGB8_to_RGB5A3(0xFFF77BDE), ARGB8_to_RGB5A3(0xFFA59439), ARGB8_to_RGB5A3(0xFF9C4242), - ARGB8_to_RGB5A3(0xFF5A3139), ARGB8_to_RGB5A3(0xFF6B6B6B), ARGB8_to_RGB5A3(0xFF000000), ARGB8_to_RGB5A3(0xFFFFFFFF), + ARGB8_to_RGB5A3(0xFF525252), ARGB8_to_RGB5A3(0xFFD60000), ARGB8_to_RGB5A3(0xFFFFBD00), ARGB8_to_RGB5A3(0xFFEFF731), + ARGB8_to_RGB5A3(0xFF4ACE42), ARGB8_to_RGB5A3(0xFF299C29), ARGB8_to_RGB5A3(0xFF528CBD), ARGB8_to_RGB5A3(0xFF424AAD), + ARGB8_to_RGB5A3(0xFF9452D6), ARGB8_to_RGB5A3(0xFFF77BDE), ARGB8_to_RGB5A3(0xFFA59439), ARGB8_to_RGB5A3(0xFF9C4242), + ARGB8_to_RGB5A3(0xFF5A3139), ARGB8_to_RGB5A3(0xFF6B6B6B), ARGB8_to_RGB5A3(0xFF000000), ARGB8_to_RGB5A3(0xFFFFFFFF), }; static u16 needlework11_pal[16] ATTRIBUTE_ALIGN(32) = { - ARGB8_to_RGB5A3(0xFF525252), ARGB8_to_RGB5A3(0xFFE7CE18), ARGB8_to_RGB5A3(0xFF21C618), ARGB8_to_RGB5A3(0xFFFF6B00), - ARGB8_to_RGB5A3(0xFF0000FF), ARGB8_to_RGB5A3(0xFF9400BD), ARGB8_to_RGB5A3(0xFFE7CE18), ARGB8_to_RGB5A3(0xFF00A500), - ARGB8_to_RGB5A3(0xFFCE4200), ARGB8_to_RGB5A3(0xFF0000D6), ARGB8_to_RGB5A3(0xFF5A008C), ARGB8_to_RGB5A3(0xFF9C8C18), - ARGB8_to_RGB5A3(0xFF008400), ARGB8_to_RGB5A3(0xFFA52100), ARGB8_to_RGB5A3(0xFF0000A5), ARGB8_to_RGB5A3(0xFF4A005A), + ARGB8_to_RGB5A3(0xFF525252), ARGB8_to_RGB5A3(0xFFE7CE18), ARGB8_to_RGB5A3(0xFF21C618), ARGB8_to_RGB5A3(0xFFFF6B00), + ARGB8_to_RGB5A3(0xFF0000FF), ARGB8_to_RGB5A3(0xFF9400BD), ARGB8_to_RGB5A3(0xFFE7CE18), ARGB8_to_RGB5A3(0xFF00A500), + ARGB8_to_RGB5A3(0xFFCE4200), ARGB8_to_RGB5A3(0xFF0000D6), ARGB8_to_RGB5A3(0xFF5A008C), ARGB8_to_RGB5A3(0xFF9C8C18), + ARGB8_to_RGB5A3(0xFF008400), ARGB8_to_RGB5A3(0xFFA52100), ARGB8_to_RGB5A3(0xFF0000A5), ARGB8_to_RGB5A3(0xFF4A005A), }; static u16 needlework12_pal[16] ATTRIBUTE_ALIGN(32) = { - ARGB8_to_RGB5A3(0xFF525252), ARGB8_to_RGB5A3(0xFFFF2121), ARGB8_to_RGB5A3(0xFFE7D600), ARGB8_to_RGB5A3(0xFFF739BD), - ARGB8_to_RGB5A3(0xFF00D69C), ARGB8_to_RGB5A3(0xFF107310), ARGB8_to_RGB5A3(0xFFC62121), ARGB8_to_RGB5A3(0xFFBDA500), - ARGB8_to_RGB5A3(0xFFCE3994), ARGB8_to_RGB5A3(0xFF009C6B), ARGB8_to_RGB5A3(0xFF214A21), ARGB8_to_RGB5A3(0xFF8C2121), - ARGB8_to_RGB5A3(0xFF846B00), ARGB8_to_RGB5A3(0xFF941863), ARGB8_to_RGB5A3(0xFF00734A), ARGB8_to_RGB5A3(0xFF183918), + ARGB8_to_RGB5A3(0xFF525252), ARGB8_to_RGB5A3(0xFFFF2121), ARGB8_to_RGB5A3(0xFFE7D600), ARGB8_to_RGB5A3(0xFFF739BD), + ARGB8_to_RGB5A3(0xFF00D69C), ARGB8_to_RGB5A3(0xFF107310), ARGB8_to_RGB5A3(0xFFC62121), ARGB8_to_RGB5A3(0xFFBDA500), + ARGB8_to_RGB5A3(0xFFCE3994), ARGB8_to_RGB5A3(0xFF009C6B), ARGB8_to_RGB5A3(0xFF214A21), ARGB8_to_RGB5A3(0xFF8C2121), + ARGB8_to_RGB5A3(0xFF846B00), ARGB8_to_RGB5A3(0xFF941863), ARGB8_to_RGB5A3(0xFF00734A), ARGB8_to_RGB5A3(0xFF183918), }; static u16 needlework13_pal[16] ATTRIBUTE_ALIGN(32) = { - ARGB8_to_RGB5A3(0xFF525252), ARGB8_to_RGB5A3(0xFFEFD6D6), ARGB8_to_RGB5A3(0xFFDEC6C6), ARGB8_to_RGB5A3(0xFFCEB5B5), - ARGB8_to_RGB5A3(0xFFBDA5A5), ARGB8_to_RGB5A3(0xFFAD9494), ARGB8_to_RGB5A3(0xFF9C8484), ARGB8_to_RGB5A3(0xFF8C7373), - ARGB8_to_RGB5A3(0xFF7B6363), ARGB8_to_RGB5A3(0xFF6B5252), ARGB8_to_RGB5A3(0xFF5A4242), ARGB8_to_RGB5A3(0xFF4A3131), - ARGB8_to_RGB5A3(0xFF392121), ARGB8_to_RGB5A3(0xFF291010), ARGB8_to_RGB5A3(0xFF180000), ARGB8_to_RGB5A3(0xFF100000), + ARGB8_to_RGB5A3(0xFF525252), ARGB8_to_RGB5A3(0xFFEFD6D6), ARGB8_to_RGB5A3(0xFFDEC6C6), ARGB8_to_RGB5A3(0xFFCEB5B5), + ARGB8_to_RGB5A3(0xFFBDA5A5), ARGB8_to_RGB5A3(0xFFAD9494), ARGB8_to_RGB5A3(0xFF9C8484), ARGB8_to_RGB5A3(0xFF8C7373), + ARGB8_to_RGB5A3(0xFF7B6363), ARGB8_to_RGB5A3(0xFF6B5252), ARGB8_to_RGB5A3(0xFF5A4242), ARGB8_to_RGB5A3(0xFF4A3131), + ARGB8_to_RGB5A3(0xFF392121), ARGB8_to_RGB5A3(0xFF291010), ARGB8_to_RGB5A3(0xFF180000), ARGB8_to_RGB5A3(0xFF100000), }; static u16 needlework14_pal[16] ATTRIBUTE_ALIGN(32) = { - ARGB8_to_RGB5A3(0xFF525252), ARGB8_to_RGB5A3(0xFFEFEFEF), ARGB8_to_RGB5A3(0xFFDEDEDE), ARGB8_to_RGB5A3(0xFFCECECE), - ARGB8_to_RGB5A3(0xFFBDBDBD), ARGB8_to_RGB5A3(0xFFADADAD), ARGB8_to_RGB5A3(0xFF9C9C9C), ARGB8_to_RGB5A3(0xFF8C8C8C), - ARGB8_to_RGB5A3(0xFF7B7B7B), ARGB8_to_RGB5A3(0xFF6B6B6B), ARGB8_to_RGB5A3(0xFF5A5A5A), ARGB8_to_RGB5A3(0xFF4A4A4A), - ARGB8_to_RGB5A3(0xFF393939), ARGB8_to_RGB5A3(0xFF292929), ARGB8_to_RGB5A3(0xFF181818), ARGB8_to_RGB5A3(0xFF101010), + ARGB8_to_RGB5A3(0xFF525252), ARGB8_to_RGB5A3(0xFFEFEFEF), ARGB8_to_RGB5A3(0xFFDEDEDE), ARGB8_to_RGB5A3(0xFFCECECE), + ARGB8_to_RGB5A3(0xFFBDBDBD), ARGB8_to_RGB5A3(0xFFADADAD), ARGB8_to_RGB5A3(0xFF9C9C9C), ARGB8_to_RGB5A3(0xFF8C8C8C), + ARGB8_to_RGB5A3(0xFF7B7B7B), ARGB8_to_RGB5A3(0xFF6B6B6B), ARGB8_to_RGB5A3(0xFF5A5A5A), ARGB8_to_RGB5A3(0xFF4A4A4A), + ARGB8_to_RGB5A3(0xFF393939), ARGB8_to_RGB5A3(0xFF292929), ARGB8_to_RGB5A3(0xFF181818), ARGB8_to_RGB5A3(0xFF101010), }; static u16 needlework15_pal[16] ATTRIBUTE_ALIGN(32) = { - ARGB8_to_RGB5A3(0xFF525252), ARGB8_to_RGB5A3(0xFFEF7B7B), ARGB8_to_RGB5A3(0xFFD61818), ARGB8_to_RGB5A3(0xFFF79418), - ARGB8_to_RGB5A3(0xFFE7E752), ARGB8_to_RGB5A3(0xFF006B00), ARGB8_to_RGB5A3(0xFF39B539), ARGB8_to_RGB5A3(0xFF0039B5), - ARGB8_to_RGB5A3(0xFF399CFF), ARGB8_to_RGB5A3(0xFF940094), ARGB8_to_RGB5A3(0xFFFF6BFF), ARGB8_to_RGB5A3(0xFF944208), - ARGB8_to_RGB5A3(0xFFEF9C5A), ARGB8_to_RGB5A3(0xFFFFC694), ARGB8_to_RGB5A3(0xFF000000), ARGB8_to_RGB5A3(0xFFFFFFFF), + ARGB8_to_RGB5A3(0xFF525252), ARGB8_to_RGB5A3(0xFFEF7B7B), ARGB8_to_RGB5A3(0xFFD61818), ARGB8_to_RGB5A3(0xFFF79418), + ARGB8_to_RGB5A3(0xFFE7E752), ARGB8_to_RGB5A3(0xFF006B00), ARGB8_to_RGB5A3(0xFF39B539), ARGB8_to_RGB5A3(0xFF0039B5), + ARGB8_to_RGB5A3(0xFF399CFF), ARGB8_to_RGB5A3(0xFF940094), ARGB8_to_RGB5A3(0xFFFF6BFF), ARGB8_to_RGB5A3(0xFF944208), + ARGB8_to_RGB5A3(0xFFEF9C5A), ARGB8_to_RGB5A3(0xFFFFC694), ARGB8_to_RGB5A3(0xFF000000), ARGB8_to_RGB5A3(0xFFFFFFFF), }; static u16* mNW_needlework_pallet_table[mNW_PALETTE_COUNT] = { - needlework0_pal, needlework1_pal, needlework2_pal, needlework3_pal, - needlework4_pal, needlework5_pal, needlework6_pal, needlework7_pal, - needlework8_pal, needlework9_pal, needlework10_pal, needlework11_pal, - needlework12_pal, needlework13_pal, needlework14_pal, needlework15_pal + needlework0_pal, needlework1_pal, needlework2_pal, needlework3_pal, needlework4_pal, needlework5_pal, + needlework6_pal, needlework7_pal, needlework8_pal, needlework9_pal, needlework10_pal, needlework11_pal, + needlework12_pal, needlework13_pal, needlework14_pal, needlework15_pal }; /** * @brief Gets a pointer to the requested palette color data. - * + * * @param palette_idx Index of the palette to retrieve (0-15) * @return Palette color data pointer **/ extern u16* mNW_PaletteIdx2Palette(int palette_idx) { - return mNW_needlework_pallet_table[palette_idx & 15]; + return mNW_needlework_pallet_table[palette_idx & 15]; } /** * @brief Copies one design class to another and updates data cache. - * + * * @param dst Destination design class * @param src Source design class **/ extern void mNW_CopyOriginalTextureClass(mNW_original_design_c* dst, mNW_original_design_c* src) { - bcopy(src, dst, sizeof(mNW_original_design_c)); - DCStoreRangeNoSync(dst->design.data, mNW_DESIGN_TEX_SIZE); + bcopy(src, dst, sizeof(mNW_original_design_c)); + DCStoreRangeNoSync(dst->design.data, mNW_DESIGN_TEX_SIZE); } /** * @brief Copies a design's texture data to a block of memory and updates data cache. - * + * * @param dst Destination pointer * @param src Source design class **/ extern void mNW_CopyOriginalTexture(void* dst, mNW_original_design_c* src) { - if (dst != NULL) { - bcopy(src->design.data, dst, mNW_DESIGN_TEX_SIZE); - DCStoreRangeNoSync(dst, mNW_DESIGN_TEX_SIZE); - } + if (dst != NULL) { + bcopy(src->design.data, dst, mNW_DESIGN_TEX_SIZE); + DCStoreRangeNoSync(dst, mNW_DESIGN_TEX_SIZE); + } } /** * @brief Copies a design's palette colors to a block of memory and updates data cache. - * + * * @param dst Destination pointer * @param src Source design class **/ extern void mNW_CopyOriginalPalette(void* dst, mNW_original_design_c* src) { - if (dst != NULL) { - bcopy(mNW_PaletteIdx2Palette(src->palette), dst, 16 * sizeof(u16)); - DCStoreRangeNoSync(dst, 16 * sizeof(u16)); - } + if (dst != NULL) { + bcopy(mNW_PaletteIdx2Palette(src->palette), dst, 16 * sizeof(u16)); + DCStoreRangeNoSync(dst, 16 * sizeof(u16)); + } } /** * @brief Copies a block of memory to a design's texture data and updates data cache. - * + * * @param dst The destination design class * @param src Source data pointer **/ extern void mNW_OverWriteOriginalTexture(mNW_original_design_c* dst, u8* src) { - if (src != NULL) { - u8* tex = dst->design.data; - bcopy(src, tex, mNW_DESIGN_TEX_SIZE); - DCStoreRangeNoSync(tex, mNW_DESIGN_TEX_SIZE); - } + if (src != NULL) { + u8* tex = dst->design.data; + bcopy(src, tex, mNW_DESIGN_TEX_SIZE); + DCStoreRangeNoSync(tex, mNW_DESIGN_TEX_SIZE); + } } /** * @brief Copies a block of memory to a design's name. - * + * * @param dst The destination design class * @param src Source name pointer **/ extern void mNW_OverWriteOriginalName(mNW_original_design_c* dst, u8* src) { - if (src != NULL) { - bcopy(src, dst->name, mNW_ORIGINAL_DESIGN_NAME_LEN); - } + if (src != NULL) { + bcopy(src, dst->name, mNW_ORIGINAL_DESIGN_NAME_LEN); + } } /* swap buffer for original design */ @@ -381,48 +361,48 @@ static mNW_original_design_c mNW_swap_work; /** * @brief Swaps two design classes' data in memory and updates data cache. - * + * * @param org0 First design class * @param org1 Second design class **/ extern void mNW_SwapOriginalData(mNW_original_design_c* org0, mNW_original_design_c* org1) { - bcopy(org0, &mNW_swap_work, sizeof(mNW_original_design_c)); - bcopy(org1, org0, sizeof(mNW_original_design_c)); - bcopy(&mNW_swap_work, org1, sizeof(mNW_original_design_c)); - DCStoreRangeNoSync(org0->design.data, mNW_DESIGN_TEX_SIZE); - DCStoreRangeNoSync(org1->design.data, mNW_DESIGN_TEX_SIZE); + bcopy(org0, &mNW_swap_work, sizeof(mNW_original_design_c)); + bcopy(org1, org0, sizeof(mNW_original_design_c)); + bcopy(&mNW_swap_work, org1, sizeof(mNW_original_design_c)); + DCStoreRangeNoSync(org0->design.data, mNW_DESIGN_TEX_SIZE); + DCStoreRangeNoSync(org1->design.data, mNW_DESIGN_TEX_SIZE); } /** * @brief Initializes a design class to 'blank' data. - * + * * @param design The design which will be initialized **/ extern void mNW_InitOriginalData(mNW_original_design_c* design) { - static u8 name[mNW_ORIGINAL_DESIGN_NAME_LEN] = "blank "; + static u8 name[mNW_ORIGINAL_DESIGN_NAME_LEN] = "blank "; - u8* tex; - mNW_OverWriteOriginalName(design, name); - tex = design->design.data; - mem_clear(tex, mNW_DESIGN_TEX_SIZE, 0xFF); - DCStoreRangeNoSync(tex, mNW_DESIGN_TEX_SIZE); - design->palette = 0; + u8* tex; + mNW_OverWriteOriginalName(design, name); + tex = design->design.data; + mem_clear(tex, mNW_DESIGN_TEX_SIZE, 0xFF); + DCStoreRangeNoSync(tex, mNW_DESIGN_TEX_SIZE); + design->palette = 0; } /** * @brief Initializes a player's design related data to the default state. - * + * * @param player_no The index of the player whose design data will be initialized **/ extern void mNW_InitPrivateOriginalData(int player_no) { - int i; - Private_c* private = Save_Get(private + player_no); + int i; + Private_c* private = Save_Get(private_data + player_no); - for (i = 0; i < mPr_ORIGINAL_DESIGN_COUNT; i++) { - private->my_org_no_table[i] = i; - } + for (i = 0; i < mPr_ORIGINAL_DESIGN_COUNT; i++) { + private->my_org_no_table[i] = i; + } - for (i = 0; i < mPr_ORIGINAL_DESIGN_COUNT; i++) { - mNW_InitOriginalData(private->my_org + i); - } + for (i = 0; i < mPr_ORIGINAL_DESIGN_COUNT; i++) { + mNW_InitOriginalData(private->my_org + i); + } } diff --git a/src/m_npc.c b/src/m_npc.c index e0af6a8d..9c70f023 100644 --- a/src/m_npc.c +++ b/src/m_npc.c @@ -410,7 +410,7 @@ extern void mNpc_RenewalAnimalMemory() { for (j = 0; j < ANIMAL_MEMORY_NUM; j++) { if (mNpc_CheckFreeAnimalMemory(memory) == FALSE && mLd_CheckThisLand(memory->memory_player_id.land_name, memory->memory_player_id.land_id) == TRUE) { - priv = Save_Get(private); + priv = Save_Get(private_data); for (k = 0; k < PLAYER_NUM; k++) { if (mPr_NullCheckPersonalID(&priv->player_ID) == FALSE && @@ -481,7 +481,7 @@ extern int mNpc_GetOldPlayerAnimalMemoryIdx(Anmmem_c* memory, int num) { for (i = 0; i < num; i++) { if (mNpc_CheckFreeAnimalMemory(memory) == FALSE && mLd_CheckThisLand(memory->memory_player_id.land_name, memory->memory_player_id.land_id) == TRUE) { - priv = Save_Get(private); + priv = Save_Get(private_data); for (j = 0; j < PLAYER_NUM; j++) { if (mPr_NullCheckPersonalID(&priv->player_ID) == FALSE && @@ -756,7 +756,7 @@ static int mNpc_GetAnimalMemoryFriend_Land_Sex(Anmmem_c* memory, int num, int se if (mNpc_CheckFreeAnimalMemory(memory) == FALSE) { priv_idx = mPr_GetPrivateIdx(&memory->memory_player_id); - if (priv_idx != -1 && Save_Get(private[priv_idx]).gender == sex && + if (priv_idx != -1 && Save_Get(private_data[priv_idx]).gender == sex && mNpc_SelectBestFriend(&best_friend, memory, &best_friendship) == TRUE) { res = i; } @@ -3176,7 +3176,7 @@ static int mNpc_DecideRemoveAnimalNo_Friend(Animal_c* animal, int ignored_idx, i n_players = 0; num_possible = 0; remove_bitfield = 0; - priv_p = Save_Get(private); + priv_p = Save_Get(private_data); for (i = 0; i < PLAYER_NUM; i++) { if (mPr_NullCheckPersonalID(&priv_p->player_ID) == FALSE) { @@ -3190,7 +3190,7 @@ static int mNpc_DecideRemoveAnimalNo_Friend(Animal_c* animal, int ignored_idx, i for (i = 0; i < ANIMAL_NUM_MAX; i++) { if (mNpc_CheckFreeAnimalInfo(animal) == FALSE && i != ignored_idx) { met = 0; - priv_p = Save_Get(private); + priv_p = Save_Get(private_data); for (j = 0; j < PLAYER_NUM; j++) { if (mPr_NullCheckPersonalID(&priv_p->player_ID) == FALSE) { @@ -3456,7 +3456,7 @@ extern void mNpc_FirstClearGoodbyMail() { } static void mNpc_SetGoodbyAnimalMail(Anm_GoodbyMail_c* goodby_mail, AnmPersonalID_c* anm_id) { - Private_c* priv = Save_Get(private); + Private_c* priv = Save_Get(private_data); int i; if (anm_id != NULL && mNpc_CheckFreeAnimalPersonalID(anm_id) == FALSE) { @@ -3519,7 +3519,7 @@ static int mNpc_SendGoodbyAnimalMailOne(Mail_c* mail, PersonalID_c* pid, int pla } static void mNpc_SendGoodbyAnimalMail(Anm_GoodbyMail_c* goodby_mail) { - Private_c* priv = Save_Get(private); + Private_c* priv = Save_Get(private_data); int i; if (mNpc_CheckFreeAnimalPersonalID(&goodby_mail->id) == FALSE) { @@ -7083,7 +7083,7 @@ static int mNpc_SendHPMail_analysis(PersonalID_c* pid, AnmPersonalID_c* anm_id, } extern void mNpc_SendHPMail() { - Private_c* priv = Save_Get(private); + Private_c* priv = Save_Get(private_data); Private_c* priv_p; Animal_c* animal = Save_Get(animals); AnmHPMail_c* hp_mail; diff --git a/src/m_post_office.c b/src/m_post_office.c index de5390b0..5fb900d1 100644 --- a/src/m_post_office.c +++ b/src/m_post_office.c @@ -17,524 +17,517 @@ #include "m_scene_table.h" static int mPO_keep_contents(Mail_c* mail) { - int res = FALSE; + int res = FALSE; - int free_idx = mMl_chk_mail_free_space(Save_Get(post_office).mail, mPO_MAIL_STORAGE_SIZE); - if (free_idx >= 0) { - mMl_copy_mail(Save_Get(post_office).mail + free_idx, mail); - mMl_clear_mail(mail); - res = TRUE; - } + int free_idx = mMl_chk_mail_free_space(Save_Get(post_office).mail, mPO_MAIL_STORAGE_SIZE); + if (free_idx >= 0) { + mMl_copy_mail(Save_Get(post_office).mail + free_idx, mail); + mMl_clear_mail(mail); + res = TRUE; + } - return res; + return res; } extern int mPO_count_mail(int house_no) { - int used = mMl_count_use_mail_space(Save_Get(homes[house_no]).mailbox, HOME_MAILBOX_SIZE); - Mail_c* mail = Save_Get(post_office).mail; - int i; + int used = mMl_count_use_mail_space(Save_Get(homes[house_no]).mailbox, HOME_MAILBOX_SIZE); + Mail_c* mail = Save_Get(post_office).mail; + int i; - for (i = 0; i < mPO_MAIL_STORAGE_SIZE; i++) { - if (house_no == mMl_hunt_for_send_address(mail)) { - used++; + for (i = 0; i < mPO_MAIL_STORAGE_SIZE; i++) { + if (house_no == mMl_hunt_for_send_address(mail)) { + used++; + } + + mail++; } - - mail++; - } - return used; + return used; } extern int mPO_get_keep_mail_sum() { - PostOffice_c* post_office = Save_GetPointer(post_office); + PostOffice_c* post_office = Save_GetPointer(post_office); - return post_office->keep_mail_sum_players + post_office->keep_mail_sum_npcs; + return post_office->keep_mail_sum_players + post_office->keep_mail_sum_npcs; } static void mPO_adjust_keep_mail() { - Mail_c* mail = Save_Get(post_office).mail; - int i; - s16 recipient_flags = 0; - s16 keep_mail_player_num = 0; + Mail_c* mail = Save_Get(post_office).mail; + int i; + s16 recipient_flags = 0; + s16 keep_mail_player_num = 0; - for (i = 0; i < mPO_MAIL_STORAGE_SIZE; i++) { - if (mMl_check_not_used_mail(mail) == FALSE) { - int house_idx = mMl_hunt_for_send_address(mail); - if (house_idx != -1) { - keep_mail_player_num++; - recipient_flags |= (1 << house_idx); - } - else { - mMl_clear_mail(mail); - } + for (i = 0; i < mPO_MAIL_STORAGE_SIZE; i++) { + if (mMl_check_not_used_mail(mail) == FALSE) { + int house_idx = mMl_hunt_for_send_address(mail); + if (house_idx != -1) { + keep_mail_player_num++; + recipient_flags |= (1 << house_idx); + } else { + mMl_clear_mail(mail); + } + } + mail++; } - mail++; - } - Save_Set(post_office.mail_recipient_flags, recipient_flags); - Save_Set(post_office.keep_mail_sum_players, keep_mail_player_num); - Save_Set(post_office.keep_mail_sum_npcs, 0); + Save_Set(post_office.mail_recipient_flags, recipient_flags); + Save_Set(post_office.keep_mail_sum_players, keep_mail_player_num); + Save_Set(post_office.keep_mail_sum_npcs, 0); } static int mPO_receipt_check_mail(Mail_c* mail) { - int res = FALSE; + int res = FALSE; - switch (mail->header.recipient.type) { - case mMl_NAME_TYPE_PLAYER: - { - int house_idx = mMl_hunt_for_send_address(mail); - if (house_idx != -1 && mPO_count_mail(house_idx) < HOME_MAILBOX_SIZE) { - res = mPO_keep_contents(mail); - if (res == TRUE) { - Save_Get(post_office.mail_recipient_flags) |= (1 << house_idx); - Save_Get(post_office.keep_mail_sum_players)++; - } - } + switch (mail->header.recipient.type) { + case mMl_NAME_TYPE_PLAYER: { + int house_idx = mMl_hunt_for_send_address(mail); + if (house_idx != -1 && mPO_count_mail(house_idx) < HOME_MAILBOX_SIZE) { + res = mPO_keep_contents(mail); + if (res == TRUE) { + Save_Get(post_office.mail_recipient_flags) |= (1 << house_idx); + Save_Get(post_office.keep_mail_sum_players)++; + } + } - break; - } - - case mMl_NAME_TYPE_NPC: - { - if (mNpc_ReceiveHPMail(mail) == FALSE) { - mNpc_SendMailtoNpc(mail); - } - - res = mPO_keep_contents(mail); - if (res == TRUE) { - Save_Get(post_office).keep_mail_sum_npcs++; - } - - break; - } - - case mMl_NAME_TYPE_MUSEUM: - { - mMsm_SendMuseumMail(mail); - mMl_clear_mail(mail); - - Save_Get(post_office).keep_mail_sum_npcs++; - res = TRUE; - - break; - } - } - - return res; -} - -extern int mPO_receipt_proc(Mail_c* mail, int send_type) { - int res = FALSE; - - switch (send_type) { - case mPO_SENDTYPE_MAIL: - { - res = mPO_receipt_check_mail(mail); - break; - } - - case mPO_SENDTYPE_LEAFLET: - { - mMl_copy_mail(&Save_Get(post_office).leaflet, mail); - Save_Set(post_office.leaflet_recipient_flags.leaflet_flags, 0); - res = TRUE; - break; - } - - case mPO_SENDTYPE_EVENT_LEAFLET: - { - mMl_copy_mail(&Save_Get(post_office).event_leaflet, mail); - Save_Set(post_office.leaflet_recipient_flags.event_flags, 0); - res = TRUE; - break; - } - } - - return res; -} - -static int mPO_copy_contents(int house_no, Mail_c* mail) { - int res = FALSE; - int free_slot = mMl_chk_mail_free_space(Save_Get(homes[house_no]).mailbox, HOME_MAILBOX_SIZE); - - if (free_slot >= 0) { - mMl_copy_mail(Save_Get(homes[house_no]).mailbox + free_slot, mail); - res = TRUE; - } - - return res; -} - -static void mPO_delivery_mail_with_item(Mail_c* mail, int mail_no, mActor_name_t present, PersonalID_c* pid) { - int header_back_start; - - mHandbill_Load_HandbillFromRom(mail->content.header, &header_back_start, mail->content.footer, mail->content.body, mail_no); - - mail->content.font = mMl_FONT_0; - mail->content.header_back_start = header_back_start; - mail->content.mail_type = 7; - mail->content.paper_type = ITM_PAPER55; - mail->present = present; - - mMl_set_to_plname(mail, pid); -} - -static int mPO_delivery_mail_with_order_ftr_sub(int house_no, PersonalID_c* pid, mPr_catalog_order_c* order) { - Mail_c mail; - u8 item_name[mIN_ITEM_NAME_LEN]; - - mMl_clear_mail(&mail); - mIN_copy_name_str(item_name, order->item); - mHandbill_Set_free_str(0, item_name, mIN_ITEM_NAME_LEN); - mPO_delivery_mail_with_item(&mail, 0x049 + order->shop_level, order->item, pid); - return mPO_copy_contents(house_no, &mail); -} - -static void mPO_delivery_mail_with_order_ftr(int house_no, int player_no) { - Private_c* priv = Save_GetPointer(private[player_no]); - - if (priv->exists == TRUE) { - mPr_catalog_order_c* order = priv->catalog_orders; - int i; - - for (i = 0; i < mPr_CATALOG_ORDER_NUM; i++) { - if (order->item != EMPTY_NO) { - if (mPO_delivery_mail_with_order_ftr_sub(house_no, &priv->player_ID, order) == FALSE) { - return; - } - - order->item = EMPTY_NO; - } - - order++; - } - } -} - -static void mPO_delivery_mail_with_ticket_set_free_str(lbRTC_month_t month) { - u8 month_str[9]; - u8 day_str[4]; - - int days = lbRTC_GetDaysByMonth(Common_Get(time.rtc_time.year), month); - mString_Load_MonthStringFromRom(month_str, month); - mString_Load_DayStringFromRom(day_str, days); - mHandbill_Set_free_str(4, month_str, 9); - mHandbill_Set_free_str(5, day_str, 4); -} - -static int mPO_delivery_mail_with_ticket_sub(int house_no, PersonalID_c* pid, mActor_name_t present) { - Mail_c mail; - - mMl_clear_mail(&mail); - mPO_delivery_mail_with_item(&mail, 0x057, present, pid); - return mPO_copy_contents(house_no, &mail); -} - -static void mPO_delivery_mail_with_ticket(int house_no, int player_no) { - mActor_name_t ticket; - Private_c* priv = Save_GetPointer(private[player_no]); - - if (priv->exists == TRUE) { - int ticket_num = priv->inventory.lotto_ticket_mail_storage; - - if (ticket_num != 0) { - int minus_ticket; - mActor_name_t ticket_id; - lbRTC_month_t ticket_month = priv->inventory.lotto_ticket_expiry_month; - - mPO_delivery_mail_with_ticket_set_free_str(ticket_month); - ticket = ITM_TICKET_START + (ticket_month - 1) * 8; - - for (ticket_num; ticket_num != 0; ticket_num -= minus_ticket) { - minus_ticket = ticket_num < 5 ? ticket_num : 5; - ticket_id = ticket + minus_ticket - 1; - if (mPO_delivery_mail_with_ticket_sub(house_no, &priv->player_ID, ticket_id) == FALSE) { - break; - } - } - } - - priv->inventory.lotto_ticket_mail_storage = ticket_num; - } -} - -static int mPO_delivery_mail_sub(int house_no) { - PostOffice_c* post_office; - Mail_c* po_mail; - int i; - int res = TRUE; - - po_mail = Save_Get(post_office).mail; - post_office = Save_GetPointer(post_office); - - for (i = 0; i < mPO_MAIL_STORAGE_SIZE; i++, po_mail++) { - if (mMl_check_not_used_mail(po_mail) == FALSE) { - int dst_house_no = mMl_hunt_for_send_address(po_mail); - if (dst_house_no != -1) { - if (house_no == mPO_DELIVER_ALL_HOUSES || dst_house_no == house_no) { - if (mPO_copy_contents(dst_house_no, po_mail) == TRUE) { - post_office->keep_mail_sum_players--; - mMl_clear_mail(po_mail); - } - else { - res = FALSE; // failed to deliver the mail, house mailbox is likely full - } - } - } - else { - switch (po_mail->header.recipient.type) { - case mMl_NAME_TYPE_PLAYER: - post_office->keep_mail_sum_players--; break; } - mMl_clear_mail(po_mail); - } - } - } + case mMl_NAME_TYPE_NPC: { + if (mNpc_ReceiveHPMail(mail) == FALSE) { + mNpc_SendMailtoNpc(mail); + } - Save_Set(post_office.keep_mail_sum_npcs, 0); - return res; + res = mPO_keep_contents(mail); + if (res == TRUE) { + Save_Get(post_office).keep_mail_sum_npcs++; + } + + break; + } + + case mMl_NAME_TYPE_MUSEUM: { + mMsm_SendMuseumMail(mail); + mMl_clear_mail(mail); + + Save_Get(post_office).keep_mail_sum_npcs++; + res = TRUE; + + break; + } + } + + return res; +} + +extern int mPO_receipt_proc(Mail_c* mail, int send_type) { + int res = FALSE; + + switch (send_type) { + case mPO_SENDTYPE_MAIL: { + res = mPO_receipt_check_mail(mail); + break; + } + + case mPO_SENDTYPE_LEAFLET: { + mMl_copy_mail(&Save_Get(post_office).leaflet, mail); + Save_Set(post_office.leaflet_recipient_flags.leaflet_flags, 0); + res = TRUE; + break; + } + + case mPO_SENDTYPE_EVENT_LEAFLET: { + mMl_copy_mail(&Save_Get(post_office).event_leaflet, mail); + Save_Set(post_office.leaflet_recipient_flags.event_flags, 0); + res = TRUE; + break; + } + } + + return res; +} + +static int mPO_copy_contents(int house_no, Mail_c* mail) { + int res = FALSE; + int free_slot = mMl_chk_mail_free_space(Save_Get(homes[house_no]).mailbox, HOME_MAILBOX_SIZE); + + if (free_slot >= 0) { + mMl_copy_mail(Save_Get(homes[house_no]).mailbox + free_slot, mail); + res = TRUE; + } + + return res; +} + +static void mPO_delivery_mail_with_item(Mail_c* mail, int mail_no, mActor_name_t present, PersonalID_c* pid) { + int header_back_start; + + mHandbill_Load_HandbillFromRom(mail->content.header, &header_back_start, mail->content.footer, mail->content.body, + mail_no); + + mail->content.font = mMl_FONT_0; + mail->content.header_back_start = header_back_start; + mail->content.mail_type = 7; + mail->content.paper_type = ITM_PAPER55; + mail->present = present; + + mMl_set_to_plname(mail, pid); +} + +static int mPO_delivery_mail_with_order_ftr_sub(int house_no, PersonalID_c* pid, mPr_catalog_order_c* order) { + Mail_c mail; + u8 item_name[mIN_ITEM_NAME_LEN]; + + mMl_clear_mail(&mail); + mIN_copy_name_str(item_name, order->item); + mHandbill_Set_free_str(0, item_name, mIN_ITEM_NAME_LEN); + mPO_delivery_mail_with_item(&mail, 0x049 + order->shop_level, order->item, pid); + return mPO_copy_contents(house_no, &mail); +} + +static void mPO_delivery_mail_with_order_ftr(int house_no, int player_no) { + Private_c* priv = Save_GetPointer(private_data[player_no]); + + if (priv->exists == TRUE) { + mPr_catalog_order_c* order = priv->catalog_orders; + int i; + + for (i = 0; i < mPr_CATALOG_ORDER_NUM; i++) { + if (order->item != EMPTY_NO) { + if (mPO_delivery_mail_with_order_ftr_sub(house_no, &priv->player_ID, order) == FALSE) { + return; + } + + order->item = EMPTY_NO; + } + + order++; + } + } +} + +static void mPO_delivery_mail_with_ticket_set_free_str(lbRTC_month_t month) { + u8 month_str[9]; + u8 day_str[4]; + + int days = lbRTC_GetDaysByMonth(Common_Get(time.rtc_time.year), month); + mString_Load_MonthStringFromRom(month_str, month); + mString_Load_DayStringFromRom(day_str, days); + mHandbill_Set_free_str(4, month_str, 9); + mHandbill_Set_free_str(5, day_str, 4); +} + +static int mPO_delivery_mail_with_ticket_sub(int house_no, PersonalID_c* pid, mActor_name_t present) { + Mail_c mail; + + mMl_clear_mail(&mail); + mPO_delivery_mail_with_item(&mail, 0x057, present, pid); + return mPO_copy_contents(house_no, &mail); +} + +static void mPO_delivery_mail_with_ticket(int house_no, int player_no) { + mActor_name_t ticket; + Private_c* priv = Save_GetPointer(private_data[player_no]); + + if (priv->exists == TRUE) { + int ticket_num = priv->inventory.lotto_ticket_mail_storage; + + if (ticket_num != 0) { + int minus_ticket; + mActor_name_t ticket_id; + lbRTC_month_t ticket_month = priv->inventory.lotto_ticket_expiry_month; + + mPO_delivery_mail_with_ticket_set_free_str(ticket_month); + ticket = ITM_TICKET_START + (ticket_month - 1) * 8; + + for (ticket_num; ticket_num != 0; ticket_num -= minus_ticket) { + minus_ticket = ticket_num < 5 ? ticket_num : 5; + ticket_id = ticket + minus_ticket - 1; + if (mPO_delivery_mail_with_ticket_sub(house_no, &priv->player_ID, ticket_id) == FALSE) { + break; + } + } + } + + priv->inventory.lotto_ticket_mail_storage = ticket_num; + } +} + +static int mPO_delivery_mail_sub(int house_no) { + PostOffice_c* post_office; + Mail_c* po_mail; + int i; + int res = TRUE; + + po_mail = Save_Get(post_office).mail; + post_office = Save_GetPointer(post_office); + + for (i = 0; i < mPO_MAIL_STORAGE_SIZE; i++, po_mail++) { + if (mMl_check_not_used_mail(po_mail) == FALSE) { + int dst_house_no = mMl_hunt_for_send_address(po_mail); + if (dst_house_no != -1) { + if (house_no == mPO_DELIVER_ALL_HOUSES || dst_house_no == house_no) { + if (mPO_copy_contents(dst_house_no, po_mail) == TRUE) { + post_office->keep_mail_sum_players--; + mMl_clear_mail(po_mail); + } else { + res = FALSE; // failed to deliver the mail, house mailbox is likely full + } + } + } else { + switch (po_mail->header.recipient.type) { + case mMl_NAME_TYPE_PLAYER: + post_office->keep_mail_sum_players--; + break; + } + + mMl_clear_mail(po_mail); + } + } + } + + Save_Set(post_office.keep_mail_sum_npcs, 0); + return res; } static void mPO_delivery_one_address_mail(int house_no) { - if (mPO_delivery_mail_sub(house_no) == TRUE) { - s16 mask = (1 << house_no) ^ 0b1111; - Save_Get(post_office.mail_recipient_flags) &= mask; // clear out delivered houses - } + if (mPO_delivery_mail_sub(house_no) == TRUE) { + s16 mask = (1 << house_no) ^ 0b1111; + Save_Get(post_office.mail_recipient_flags) &= mask; // clear out delivered houses + } } static void mPO_delivery_one_address_special_mail(int house_no) { - int player_no = mHS_get_pl_no(house_no); + int player_no = mHS_get_pl_no(house_no); - mPO_delivery_mail_with_ticket(house_no, player_no); - mPO_delivery_mail_with_order_ftr(house_no, player_no); + mPO_delivery_mail_with_ticket(house_no, player_no); + mPO_delivery_mail_with_order_ftr(house_no, player_no); } static void mPO_delivery_one_address_leaflet(s16* leaflet_received_flags, Mail_c* leaflet, int house_no) { - if ((((*leaflet_received_flags) >> house_no) & 1) == FALSE) { - mHm_hs_c* house = Save_GetPointer(homes[house_no]); + if ((((*leaflet_received_flags) >> house_no) & 1) == FALSE) { + mHm_hs_c* house = Save_GetPointer(homes[house_no]); - if (house->ownerID.land_id == 0xFFFF) { - *leaflet_received_flags |= (1 << house_no); // unclaimed houses are marked "received" - } - else { - int player_no = mHS_get_pl_no(house_no); - if (player_no < mPr_FOREIGNER && mEv_ArbeitPlayer(player_no) == FALSE) { - mMl_set_to_plname(leaflet, &house->ownerID); - if (mPO_copy_contents(house_no, leaflet) == TRUE) { - *leaflet_received_flags |= (1 << house_no); + if (house->ownerID.land_id == 0xFFFF) { + *leaflet_received_flags |= (1 << house_no); // unclaimed houses are marked "received" + } else { + int player_no = mHS_get_pl_no(house_no); + if (player_no < mPr_FOREIGNER && mEv_ArbeitPlayer(player_no) == FALSE) { + mMl_set_to_plname(leaflet, &house->ownerID); + if (mPO_copy_contents(house_no, leaflet) == TRUE) { + *leaflet_received_flags |= (1 << house_no); + } + } } - } } - } } static void mPO_delivery_one_address_event_leaflet(int house_no) { - Mail_c* ev_leaflet = &Save_Get(post_office).event_leaflet; - int special_type = mEv_get_special_event_type(); - int leaflet_event_type; + Mail_c* ev_leaflet = &Save_Get(post_office).event_leaflet; + int special_type = mEv_get_special_event_type(); + int leaflet_event_type; - switch (ev_leaflet->content.mail_type) { - case mMl_TYPE_SHOP_SALE_LEAFLET: - leaflet_event_type = mEv_EVENT_SHOP_SALE; - break; + switch (ev_leaflet->content.mail_type) { + case mMl_TYPE_SHOP_SALE_LEAFLET: + leaflet_event_type = mEv_EVENT_SHOP_SALE; + break; - case mMl_TYPE_BROKER_SALE_LEAFLET: - leaflet_event_type = mEv_EVENT_BROKER_SALE; - break; + case mMl_TYPE_BROKER_SALE_LEAFLET: + leaflet_event_type = mEv_EVENT_BROKER_SALE; + break; - default: - leaflet_event_type = -1; - break; - } + default: + leaflet_event_type = -1; + break; + } - if (leaflet_event_type == special_type) { - mPO_delivery_one_address_leaflet(&Save_Get(post_office).leaflet_recipient_flags.event_flags, ev_leaflet, house_no); - } + if (leaflet_event_type == special_type) { + mPO_delivery_one_address_leaflet(&Save_Get(post_office).leaflet_recipient_flags.event_flags, ev_leaflet, + house_no); + } } extern int mPO_delivery_one_address(int house_no) { - mPO_delivery_one_address_mail(house_no); - mPO_delivery_one_address_leaflet(&Save_Get(post_office).leaflet_recipient_flags.leaflet_flags, &Save_Get(post_office).leaflet, house_no); - mPO_delivery_one_address_event_leaflet(house_no); + mPO_delivery_one_address_mail(house_no); + mPO_delivery_one_address_leaflet(&Save_Get(post_office).leaflet_recipient_flags.leaflet_flags, + &Save_Get(post_office).leaflet, house_no); + mPO_delivery_one_address_event_leaflet(house_no); } static void mPO_delivery_mail() { - mPO_delivery_mail_sub(mPO_DELIVER_ALL_HOUSES); - mPO_adjust_keep_mail(); + mPO_delivery_mail_sub(mPO_DELIVER_ALL_HOUSES); + mPO_adjust_keep_mail(); } static void mPO_delivery_leaflet() { - int house_no; + int house_no; - for (house_no = 0; house_no < mHS_HOUSE_NUM; house_no++) { - mPO_delivery_one_address_leaflet(&Save_Get(post_office).leaflet_recipient_flags.leaflet_flags, &Save_Get(post_office).leaflet, house_no); - mPO_delivery_one_address_event_leaflet(house_no); - } + for (house_no = 0; house_no < mHS_HOUSE_NUM; house_no++) { + mPO_delivery_one_address_leaflet(&Save_Get(post_office).leaflet_recipient_flags.leaflet_flags, + &Save_Get(post_office).leaflet, house_no); + mPO_delivery_one_address_event_leaflet(house_no); + } } extern void mPO_delivery_all_address_proc() { - mPO_delivery_mail(); - mPO_delivery_leaflet(); + mPO_delivery_mail(); + mPO_delivery_leaflet(); } static int mPO_make_post_man(GAME_PLAY* play) { - static int bx_add[2] = { -1, 1 }; - static int ux_table[2] = { UT_X_NUM - 1, 0 }; + static int bx_add[2] = { -1, 1 }; + static int ux_table[2] = { UT_X_NUM - 1, 0 }; - int pl_block_x; - int pl_block_z; - u32 block_kind; + int pl_block_x; + int pl_block_z; + u32 block_kind; - int po_block_x; - int po_block_z; - int res = FALSE; + int po_block_x; + int po_block_z; + int res = FALSE; - if (Save_Get(scene_no) == SCENE_FG) { - mFI_BlockKind2BkNum(&pl_block_x, &pl_block_z, mRF_BLOCKKIND_PLAYER); - block_kind = mFI_BkNum2BlockKind(play->block_table.block_x, play->block_table.block_z); + if (Save_Get(scene_no) == SCENE_FG) { + mFI_BlockKind2BkNum(&pl_block_x, &pl_block_z, mRF_BLOCKKIND_PLAYER); + block_kind = mFI_BkNum2BlockKind(play->block_table.block_x, play->block_table.block_z); - if (block_kind != mRF_BLOCKKIND_NONE) { - if ((block_kind & mRF_BLOCKKIND_PLAYER) != 0) { - int bx_add_idx; - int spawned_postman; + if (block_kind != mRF_BLOCKKIND_NONE) { + if ((block_kind & mRF_BLOCKKIND_PLAYER) != 0) { + int bx_add_idx; + int spawned_postman; - mFI_BlockKind2BkNum(&po_block_x, &po_block_z, mRF_BLOCKKIND_POSTOFFICE); - bx_add_idx = pl_block_x >= po_block_x ? 0 : 1; - spawned_postman = (*Common_Get(clip).npc_clip->setupActor_proc)(play, SP_NPC_POST_MAN, -1, -1, 0, play->block_table.block_x + bx_add[bx_add_idx], play->block_table.block_z, ux_table[bx_add_idx], 7); + mFI_BlockKind2BkNum(&po_block_x, &po_block_z, mRF_BLOCKKIND_POSTOFFICE); + bx_add_idx = pl_block_x >= po_block_x ? 0 : 1; + spawned_postman = (*Common_Get(clip).npc_clip->setupActor_proc)( + play, SP_NPC_POST_MAN, -1, -1, 0, play->block_table.block_x + bx_add[bx_add_idx], + play->block_table.block_z, ux_table[bx_add_idx], 7); - if (spawned_postman == TRUE) { - res = TRUE; - } - } - else if ((block_kind & mRF_BLOCKKIND_POSTOFFICE) != 0) { - if (Common_Get(force_mail_delivery_flag) == TRUE) { - int post_utx; - int post_utz; - int spawned_postman; - ACTOR* post_office_structure = Actor_info_fgName_search(&play->actor_info, POST_OFFICE, ACTOR_PART_ITEM); + if (spawned_postman == TRUE) { + res = TRUE; + } + } else if ((block_kind & mRF_BLOCKKIND_POSTOFFICE) != 0) { + if (Common_Get(force_mail_delivery_flag) == TRUE) { + int post_utx; + int post_utz; + int spawned_postman; + ACTOR* post_office_structure = + Actor_info_fgName_search(&play->actor_info, POST_OFFICE, ACTOR_PART_ITEM); - if (post_office_structure != NULL) { - mFI_Wpos2UtNum_inBlock(&post_utx, &post_utz, post_office_structure->world.position); - spawned_postman = (*Common_Get(clip).npc_clip->setupActor_proc)(play, SP_NPC_POST_MAN, -1, -1, 1, play->block_table.block_x, play->block_table.block_z, post_utx - 3, post_utz); + if (post_office_structure != NULL) { + mFI_Wpos2UtNum_inBlock(&post_utx, &post_utz, post_office_structure->world.position); + spawned_postman = (*Common_Get(clip).npc_clip->setupActor_proc)( + play, SP_NPC_POST_MAN, -1, -1, 1, play->block_table.block_x, play->block_table.block_z, + post_utx - 3, post_utz); - if (spawned_postman == TRUE) { - res = TRUE; + if (spawned_postman == TRUE) { + res = TRUE; + } + } + } + } else { + mPO_delivery_all_address_proc(); + res = TRUE; } - } + } else { + mPO_delivery_all_address_proc(); + res = TRUE; } - } - else { + } else { mPO_delivery_all_address_proc(); res = TRUE; - } } - else { - mPO_delivery_all_address_proc(); - res = TRUE; - } - } - else { - mPO_delivery_all_address_proc(); - res = TRUE; - } - return res; + return res; } static void mPO_set_next_delivery_time(lbRTC_time_c* time) { - if (time->hour < 9) { - time->hour = 9; - } - else if (time->hour < 17) { - time->hour = 17; - } - else { - lbRTC_Add_DD(time, 1); - time->hour = 9; - } + if (time->hour < 9) { + time->hour = 9; + } else if (time->hour < 17) { + time->hour = 17; + } else { + lbRTC_Add_DD(time, 1); + time->hour = 9; + } - time->min = 0; - time->sec = 0; - lbRTC_TimeCopy(&Save_Get(post_office).delivery_time, time); + time->min = 0; + time->sec = 0; + lbRTC_TimeCopy(&Save_Get(post_office).delivery_time, time); } static void mPO_delivery_proc(GAME_PLAY* play) { - lbRTC_time_c time; + lbRTC_time_c time; - lbRTC_TimeCopy(&time, Common_GetPointer(time.rtc_time)); + lbRTC_TimeCopy(&time, Common_GetPointer(time.rtc_time)); - if ((lbRTC_IsOverTime(&Save_Get(post_office).delivery_time, &time) == lbRTC_OVER || Common_Get(force_mail_delivery_flag) == TRUE) && - (mPO_make_post_man(play) == TRUE) - ) { - mPO_set_next_delivery_time(&time); - Common_Set(force_mail_delivery_flag, FALSE); - } + if ((lbRTC_IsOverTime(&Save_Get(post_office).delivery_time, &time) == lbRTC_OVER || + Common_Get(force_mail_delivery_flag) == TRUE) && + (mPO_make_post_man(play) == TRUE)) { + mPO_set_next_delivery_time(&time); + Common_Set(force_mail_delivery_flag, FALSE); + } } static void mPO_first_delivery_proc() { - int deliver = FALSE; - lbRTC_time_c time; + int deliver = FALSE; + lbRTC_time_c time; - lbRTC_TimeCopy(&time, Common_GetPointer(time.rtc_time)); + lbRTC_TimeCopy(&time, Common_GetPointer(time.rtc_time)); - if (lbRTC_IsOverTime(&Save_Get(post_office).delivery_time, &time) == lbRTC_OVER || Common_Get(force_mail_delivery_flag) == TRUE) { - deliver = TRUE; - mPO_set_next_delivery_time(&time); - Common_Set(force_mail_delivery_flag, FALSE); - } + if (lbRTC_IsOverTime(&Save_Get(post_office).delivery_time, &time) == lbRTC_OVER || + Common_Get(force_mail_delivery_flag) == TRUE) { + deliver = TRUE; + mPO_set_next_delivery_time(&time); + Common_Set(force_mail_delivery_flag, FALSE); + } - if (deliver == TRUE) { - mPO_delivery_mail(); - } + if (deliver == TRUE) { + mPO_delivery_mail(); + } - if (mLd_PlayerManKindCheck() == FALSE) { - int house_no = mHS_get_arrange_idx(Common_Get(player_no)); - mPO_delivery_one_address_special_mail(house_no); - } + if (mLd_PlayerManKindCheck() == FALSE) { + int house_no = mHS_get_arrange_idx(Common_Get(player_no)); + mPO_delivery_one_address_special_mail(house_no); + } - if (deliver == TRUE) { - mPO_delivery_leaflet(); - } + if (deliver == TRUE) { + mPO_delivery_leaflet(); + } } extern void mPO_business_proc(GAME_PLAY* play) { - if ((Common_Get(clip).demo_clip == NULL && Common_Get(clip).demo_clip2 == NULL) || - (Common_Get(clip).demo_clip != NULL && Common_Get(clip).demo_clip->type == mDemo_CLIP_TYPE_INTRO_DEMO) - ) { - int scene = Save_Get(scene_no); + if ((Common_Get(clip).demo_clip == NULL && Common_Get(clip).demo_clip2 == NULL) || + (Common_Get(clip).demo_clip != NULL && Common_Get(clip).demo_clip->type == mDemo_CLIP_TYPE_INTRO_DEMO)) { + int scene = Save_Get(scene_no); - switch (scene) { - default: - mPO_delivery_proc(play); - break; + switch (scene) { + default: + mPO_delivery_proc(play); + break; - case SCENE_PLAYERSELECT: - case SCENE_PLAYERSELECT_2: - case SCENE_PLAYERSELECT_3: - case SCENE_PLAYERSELECT_SAVE: - case SCENE_TITLE_DEMO: - return; + case SCENE_PLAYERSELECT: + case SCENE_PLAYERSELECT_2: + case SCENE_PLAYERSELECT_3: + case SCENE_PLAYERSELECT_SAVE: + case SCENE_TITLE_DEMO: + return; + } } - } } extern void mPO_first_work() { - lbRTC_time_c* time = &Save_Get(save_check).time; - if (mTM_AreTimesEqual(time, &mTM_rtcTime_clear_code) == FALSE && lbRTC_IsOverRTC(time) == FALSE) { - Common_Set(force_mail_delivery_flag, TRUE); - } + lbRTC_time_c* time = &Save_Get(save_check).time; + if (mTM_AreTimesEqual(time, &mTM_rtcTime_clear_code) == FALSE && lbRTC_IsOverRTC(time) == FALSE) { + Common_Set(force_mail_delivery_flag, TRUE); + } - mPO_first_delivery_proc(); - mPO_adjust_keep_mail(); + mPO_first_delivery_proc(); + mPO_adjust_keep_mail(); } extern void mPO_post_office_init() { - bzero(Save_GetPointer(post_office), sizeof(PostOffice_c)); - mMl_clear_mail_box(Save_Get(post_office).mail, mPO_MAIL_STORAGE_SIZE); - mMl_clear_mail(&Save_Get(post_office).leaflet); - mMl_clear_mail(&Save_Get(post_office).event_leaflet); - Save_Get(post_office).leaflet_recipient_flags.raw = 0x000F000F; - lbRTC_TimeCopy(&Save_Get(post_office).delivery_time, Common_GetPointer(time.rtc_time)); + bzero(Save_GetPointer(post_office), sizeof(PostOffice_c)); + mMl_clear_mail_box(Save_Get(post_office).mail, mPO_MAIL_STORAGE_SIZE); + mMl_clear_mail(&Save_Get(post_office).leaflet); + mMl_clear_mail(&Save_Get(post_office).event_leaflet); + Save_Get(post_office).leaflet_recipient_flags.raw = 0x000F000F; + lbRTC_TimeCopy(&Save_Get(post_office).delivery_time, Common_GetPointer(time.rtc_time)); } diff --git a/src/m_private.c b/src/m_private.c index c478a8a3..e4a55652 100644 --- a/src/m_private.c +++ b/src/m_private.c @@ -22,1478 +22,1466 @@ static Mail_c l_mpr_mail; Private_c g_foreigner_private; extern void mPr_ClearPlayerName(u8* buf) { - mem_clear(buf, PLAYER_NAME_LEN, CHAR_SPACE); + mem_clear(buf, PLAYER_NAME_LEN, CHAR_SPACE); } extern void mPr_CopyPlayerName(u8* dst, u8* src) { - mem_copy(dst, src, PLAYER_NAME_LEN); + mem_copy(dst, src, PLAYER_NAME_LEN); } extern int mPr_NullCheckPlayerName(u8* name_p) { - int res = FALSE; - int i; + int res = FALSE; + int i; - for (i = 0; i < PLAYER_NAME_LEN; i++) { - if (name_p[0] != CHAR_SPACE) { - break; + for (i = 0; i < PLAYER_NAME_LEN; i++) { + if (name_p[0] != CHAR_SPACE) { + break; + } + name_p++; } - name_p++; - } - if (i == PLAYER_NAME_LEN) { - res = TRUE; - } + if (i == PLAYER_NAME_LEN) { + res = TRUE; + } - return res; + return res; } extern int mPr_CheckCmpPlayerName(u8* name0, u8* name1) { - int res = FALSE; + int res = FALSE; - if (mPr_NullCheckPlayerName(name0) == FALSE && mPr_NullCheckPlayerName(name1) == FALSE) { - res = mem_cmp(name0, name1, PLAYER_NAME_LEN); - } + if (mPr_NullCheckPlayerName(name0) == FALSE && mPr_NullCheckPlayerName(name1) == FALSE) { + res = mem_cmp(name0, name1, PLAYER_NAME_LEN); + } - return res; + return res; } extern int mPr_GetPlayerName(u8* buf, int player_no) { - PersonalID_c* pid; - int res = FALSE; + PersonalID_c* pid; + int res = FALSE; - if (mLd_PlayerManKindCheckNo(player_no) == FALSE) { - pid = &Save_Get(private[player_no]).player_ID; + if (mLd_PlayerManKindCheckNo(player_no) == FALSE) { + pid = &Save_Get(private_data[player_no]).player_ID; - if (mPr_NullCheckPersonalID(pid) == FALSE) { - mPr_CopyPlayerName(buf, pid->player_name); - res = TRUE; + if (mPr_NullCheckPersonalID(pid) == FALSE) { + mPr_CopyPlayerName(buf, pid->player_name); + res = TRUE; + } + } else if (mLd_PlayerManKindCheckNo(Common_Get(player_no)) == TRUE) { + mPr_CopyPlayerName(buf, Common_Get(now_private)->player_ID.player_name); + res = TRUE; } - } - else if (mLd_PlayerManKindCheckNo(Common_Get(player_no)) == TRUE) { - mPr_CopyPlayerName(buf, Common_Get(now_private)->player_ID.player_name); - res = TRUE; - } - return res; + return res; } extern int mPr_NullCheckPersonalID(PersonalID_c* pid) { - int res = FALSE; + int res = FALSE; - if (pid->land_id == 0xFFFF && mPr_NullCheckPlayerName(pid->player_name) == TRUE) { - res = TRUE; - } + if (pid->land_id == 0xFFFF && mPr_NullCheckPlayerName(pid->player_name) == TRUE) { + res = TRUE; + } - return res; + return res; } extern void mPr_ClearPersonalID(PersonalID_c* pid) { - mPr_ClearPlayerName(pid->player_name); - mLd_ClearLandName(pid->land_name); - pid->land_id = 0xFFFF; - pid->player_id = 0xFFFF; + mPr_ClearPlayerName(pid->player_name); + mLd_ClearLandName(pid->land_name); + pid->land_id = 0xFFFF; + pid->player_id = 0xFFFF; } extern void mPr_ClearAnyPersonalID(PersonalID_c* pid, int count) { - for (count; count != 0; count--) { - mPr_ClearPersonalID(pid); - pid++; - } + for (count; count != 0; count--) { + mPr_ClearPersonalID(pid); + pid++; + } } extern void mPr_CopyPersonalID(PersonalID_c* dst, PersonalID_c* src) { - mem_copy((u8*)dst, (u8*)src, sizeof(PersonalID_c)); + mem_copy((u8*)dst, (u8*)src, sizeof(PersonalID_c)); } extern int mPr_CheckCmpPersonalID(PersonalID_c* pid0, PersonalID_c* pid1) { - int res = FALSE; + int res = FALSE; - if ( - pid0->land_id == pid1->land_id && - pid0->player_id == pid1->player_id && - mLd_CheckCmpLandName(pid0->land_name, pid1->land_name) == TRUE && - mPr_CheckCmpPlayerName(pid0->player_name, pid1->player_name) == TRUE - ) { - res = TRUE; - } + if (pid0->land_id == pid1->land_id && pid0->player_id == pid1->player_id && + mLd_CheckCmpLandName(pid0->land_name, pid1->land_name) == TRUE && + mPr_CheckCmpPlayerName(pid0->player_name, pid1->player_name) == TRUE) { + res = TRUE; + } - return res; + return res; } // TODO: this might actually be file-local but I'm not sure, DnM+ inlined it extern void mPr_ClearPrivateBirthday(mPr_birthday_c* birthday) { - birthday->year = 0xFFFF; - birthday->month = 0xFF; - birthday->day = 0xFF; + birthday->year = 0xFFFF; + birthday->month = 0xFF; + birthday->day = 0xFF; } extern void mPr_ClearAnimalMemory(mPr_animal_memory_c* memory) { - memory->npc_id = 0xFFFF; - mLd_ClearLandName(memory->land_name); + memory->npc_id = 0xFFFF; + mLd_ClearLandName(memory->land_name); } extern void mPr_ClearPrivateInfo(Private_c* private_info) { - bzero(private_info, sizeof(Private_c)); + bzero(private_info, sizeof(Private_c)); - mPr_ClearPersonalID(&private_info->player_ID); - private_info->gender = mPr_SEX_MALE; - mQst_ClearDelivery(private_info->deliveries, mPr_DELIVERY_QUEST_NUM); - mQst_ClearErrand(private_info->errands, mPr_ERRAND_QUEST_NUM); - mMl_clear_mail_box(private_info->mail, mPr_INVENTORY_MAIL_COUNT); - mMl_clear_mail_header_common(&private_info->saved_mail_header); - mPlib_change_player_cloth_info_lv2(private_info, ITM_CLOTH001); - mNpc_ClearAnimalPersonalID(&private_info->stored_anm_id); - mPr_ClearPrivateBirthday(&private_info->birthday); - private_info->backgound_texture = ITM_CLOTH226; - mNpc_ClearRemail(&private_info->remail); - mPr_ClearAnimalMemory(&private_info->animal_memory); - mPr_ClearMapInfo(private_info->maps, mPr_FOREIGN_MAP_COUNT); - mMsm_ClearRecord(&private_info->museum_record); - private_info->state_flags = 1; + mPr_ClearPersonalID(&private_info->player_ID); + private_info->gender = mPr_SEX_MALE; + mQst_ClearDelivery(private_info->deliveries, mPr_DELIVERY_QUEST_NUM); + mQst_ClearErrand(private_info->errands, mPr_ERRAND_QUEST_NUM); + mMl_clear_mail_box(private_info->mail, mPr_INVENTORY_MAIL_COUNT); + mMl_clear_mail_header_common(&private_info->saved_mail_header); + mPlib_change_player_cloth_info_lv2(private_info, ITM_CLOTH001); + mNpc_ClearAnimalPersonalID(&private_info->stored_anm_id); + mPr_ClearPrivateBirthday(&private_info->birthday); + private_info->backgound_texture = ITM_CLOTH226; + mNpc_ClearRemail(&private_info->remail); + mPr_ClearAnimalMemory(&private_info->animal_memory); + mPr_ClearMapInfo(private_info->maps, mPr_FOREIGN_MAP_COUNT); + mMsm_ClearRecord(&private_info->museum_record); + private_info->state_flags = 1; } static int mPr_GetRandomFace() { - return (fqrand() * (f32)mPr_FACE_TYPE_NUM); + return (fqrand() * (f32)mPr_FACE_TYPE_NUM); } static int mPr_GetRandomOriginalFace() { - Private_c* priv = Save_Get(private); - Private_c* pr2; - - //Private_c* pr2; - int j; - int player_exist_num = 0; - int face; - int i; + Private_c* priv = Save_Get(private_data); + Private_c* pr2; - { - Private_c* pr = priv; - for (i = 0; i < PLAYER_NUM; i++) { - if (pr != NULL && mPr_NullCheckPersonalID(&pr->player_ID) == FALSE) { - player_exist_num++; - } - pr++; - } - } + // Private_c* pr2; + int j; + int player_exist_num = 0; + int face; + int i; - face = RANDOM(mPr_FACE_TYPE_NUM - player_exist_num); - for (player_exist_num; player_exist_num > 0; player_exist_num--) { - pr2 = priv; - for (j = 0; j < PLAYER_NUM; j++) { - if (pr2 != NULL && mPr_NullCheckPersonalID(&pr2->player_ID) == FALSE && pr2->face == face) { - face++; - - if (face >= mPr_FACE_TYPE_NUM) { - face = mPr_FACE_TYPE0; + { + Private_c* pr = priv; + for (i = 0; i < PLAYER_NUM; i++) { + if (pr != NULL && mPr_NullCheckPersonalID(&pr->player_ID) == FALSE) { + player_exist_num++; + } + pr++; } - break; - } - - pr2++; } - } - return face; + face = RANDOM(mPr_FACE_TYPE_NUM - player_exist_num); + for (player_exist_num; player_exist_num > 0; player_exist_num--) { + pr2 = priv; + for (j = 0; j < PLAYER_NUM; j++) { + if (pr2 != NULL && mPr_NullCheckPersonalID(&pr2->player_ID) == FALSE && pr2->face == face) { + face++; + + if (face >= mPr_FACE_TYPE_NUM) { + face = mPr_FACE_TYPE0; + } + break; + } + + pr2++; + } + } + + return face; } -static mActor_name_t mPr_boy_cloth_table[8] = { ITM_CLOTH000, ITM_CLOTH001, ITM_CLOTH002, ITM_CLOTH003, ITM_CLOTH004, ITM_CLOTH005, ITM_CLOTH006, ITM_CLOTH007 }; -static mActor_name_t mPr_girl_cloth_table[8] = { ITM_CLOTH008, ITM_CLOTH009, ITM_CLOTH010, ITM_CLOTH011, ITM_CLOTH012, ITM_CLOTH013, ITM_CLOTH014, ITM_CLOTH015 }; +static mActor_name_t mPr_boy_cloth_table[8] = { ITM_CLOTH000, ITM_CLOTH001, ITM_CLOTH002, ITM_CLOTH003, + ITM_CLOTH004, ITM_CLOTH005, ITM_CLOTH006, ITM_CLOTH007 }; +static mActor_name_t mPr_girl_cloth_table[8] = { ITM_CLOTH008, ITM_CLOTH009, ITM_CLOTH010, ITM_CLOTH011, + ITM_CLOTH012, ITM_CLOTH013, ITM_CLOTH014, ITM_CLOTH015 }; static mActor_name_t mPr_GetRandomCloth(u8 sex) { - static mActor_name_t* cloth_table[mPr_SEX_NUM] = { mPr_boy_cloth_table, mPr_girl_cloth_table }; - static int cloth_max[mPr_SEX_NUM] = { 8, 8 }; + static mActor_name_t* cloth_table[mPr_SEX_NUM] = { mPr_boy_cloth_table, mPr_girl_cloth_table }; + static int cloth_max[mPr_SEX_NUM] = { 8, 8 }; - u8 s = sex; - int sel_cloth; - mActor_name_t* t; - mActor_name_t cloth; + u8 s = sex; + int sel_cloth; + mActor_name_t* t; + mActor_name_t cloth; - if (s >= mPr_SEX_NUM) { - s = mPr_SEX_MALE; - } + if (s >= mPr_SEX_NUM) { + s = mPr_SEX_MALE; + } - t = cloth_table[s]; - sel_cloth = RANDOM(cloth_max[s]); - cloth = t[sel_cloth]; - return cloth; + t = cloth_table[s]; + sel_cloth = RANDOM(cloth_max[s]); + cloth = t[sel_cloth]; + return cloth; } extern void mPr_SetNowPrivateCloth() { - Private_c* priv = Common_Get(now_private); + Private_c* priv = Common_Get(now_private); - if (priv != NULL) { - mPlib_change_player_cloth_info_lv2(priv, mPr_GetRandomCloth(priv->gender)); - } + if (priv != NULL) { + mPlib_change_player_cloth_info_lv2(priv, mPr_GetRandomCloth(priv->gender)); + } } extern void mPr_InitPrivateInfo(Private_c* priv) { - mLd_land_info_c* land_info = Save_GetPointer(land_info); - Private_c* o_priv = Save_Get(private); - int id_existed = FALSE; - int face = mPr_GetRandomOriginalFace(); - int pid; - int i; + mLd_land_info_c* land_info = Save_GetPointer(land_info); + Private_c* o_priv = Save_Get(private_data); + int id_existed = FALSE; + int face = mPr_GetRandomOriginalFace(); + int pid; + int i; - priv->player_ID.land_id = land_info->id; - mLd_CopyLandName(priv->player_ID.land_name, land_info->name); - - pid = fqrand() * 253.0f; + priv->player_ID.land_id = land_info->id; + mLd_CopyLandName(priv->player_ID.land_name, land_info->name); - for (i = 0; i < PLAYER_NUM - 1; i++) { - int j; + pid = fqrand() * 253.0f; - for (j = 0; j < PLAYER_NUM; j++) { - if ((u16)pid == o_priv[j].player_ID.player_id) { - id_existed = TRUE; - pid++; // move to next PID - break; - } + for (i = 0; i < PLAYER_NUM - 1; i++) { + int j; + + for (j = 0; j < PLAYER_NUM; j++) { + if ((u16)pid == o_priv[j].player_ID.player_id) { + id_existed = TRUE; + pid++; // move to next PID + break; + } + } + + if (id_existed == FALSE) { + break; + } + + id_existed = FALSE; } - if (id_existed == FALSE) { - break; + priv->player_ID.player_id = 0xF000 | pid; + priv->exists = TRUE; + mPlib_change_player_cloth_info_lv2(priv, mPr_GetRandomCloth(mPr_SEX_MALE)); + priv->gender = mPr_SEX_MALE; + priv->inventory.loan = 100; + priv->face = face; + + for (i = 0; i < mPr_ORIGINAL_DESIGN_COUNT; i++) { + priv->my_org_no_table[i] = i; } - - id_existed = FALSE; - } - - priv->player_ID.player_id = 0xF000 | pid; - priv->exists = TRUE; - mPlib_change_player_cloth_info_lv2(priv, mPr_GetRandomCloth(mPr_SEX_MALE)); - priv->gender = mPr_SEX_MALE; - priv->inventory.loan = 100; - priv->face = face; - - for (i = 0; i < mPr_ORIGINAL_DESIGN_COUNT; i++) { - priv->my_org_no_table[i] = i; - } } extern void mPr_CopyPrivateInfo(Private_c* dst, Private_c* src) { - bcopy(src, dst, sizeof(Private_c)); + bcopy(src, dst, sizeof(Private_c)); } extern int mPr_CheckPrivate(Private_c* priv) { - int res = FALSE; + int res = FALSE; - if (mLd_CHECK_LAND_ID(priv->player_ID.land_id)) { - res = TRUE; - } + if (mLd_CHECK_LAND_ID(priv->player_ID.land_id)) { + res = TRUE; + } - return res; + return res; } extern int mPr_CheckCmpPrivate(Private_c* priv0, Private_c* priv1) { - int res = FALSE; + int res = FALSE; - if (mPr_CheckCmpPersonalID(&priv0->player_ID, &priv1->player_ID) == TRUE) { - res = TRUE; - } + if (mPr_CheckCmpPersonalID(&priv0->player_ID, &priv1->player_ID) == TRUE) { + res = TRUE; + } - return res; + return res; } extern int mPr_GetPrivateIdx(PersonalID_c* pid) { - Private_c* priv = Save_Get(private); - int res = -1; + Private_c* priv = Save_Get(private_data); + int res = -1; - if (mPr_NullCheckPersonalID(pid) == FALSE) { - int i; + if (mPr_NullCheckPersonalID(pid) == FALSE) { + int i; - for (i = 0; i < PLAYER_NUM; i++) { - if (mPr_CheckCmpPersonalID(pid, &priv->player_ID) == TRUE) { - res = i; - break; - } + for (i = 0; i < PLAYER_NUM; i++) { + if (mPr_CheckCmpPersonalID(pid, &priv->player_ID) == TRUE) { + res = i; + break; + } - priv++; + priv++; + } } - } - return res; + return res; } extern int mPr_GetPossessionItemIdx(Private_c* priv, mActor_name_t item) { - int idx = -1; - - if (priv != NULL) { - mActor_name_t* pockets = priv->inventory.pockets; - int i; + int idx = -1; - for (i = 0; i < mPr_POCKETS_SLOT_COUNT; i++) { - mActor_name_t it = *pockets; - if (it == item) { - idx = i; - break; - } + if (priv != NULL) { + mActor_name_t* pockets = priv->inventory.pockets; + int i; - pockets++; + for (i = 0; i < mPr_POCKETS_SLOT_COUNT; i++) { + mActor_name_t it = *pockets; + if (it == item) { + idx = i; + break; + } + + pockets++; + } } - } - return idx; + return idx; } extern int mPr_GetPossessionItemIdxWithCond(Private_c* priv, mActor_name_t item, u32 cond) { - int idx = -1; - - if (priv != NULL) { - mActor_name_t* pockets = priv->inventory.pockets; - int i; + int idx = -1; - for (i = 0; i < mPr_POCKETS_SLOT_COUNT; i++) { - mActor_name_t it = *pockets; - if (it == item && cond == mPr_GET_ITEM_COND(priv->inventory.item_conditions, i)) { - idx = i; - break; - } + if (priv != NULL) { + mActor_name_t* pockets = priv->inventory.pockets; + int i; - pockets++; + for (i = 0; i < mPr_POCKETS_SLOT_COUNT; i++) { + mActor_name_t it = *pockets; + if (it == item && cond == mPr_GET_ITEM_COND(priv->inventory.item_conditions, i)) { + idx = i; + break; + } + + pockets++; + } } - } - return idx; + return idx; } -extern int mPr_GetPossessionItemIdxFGTypeWithCond_cancel(Private_c* priv, mActor_name_t fg_type, u32 cond, mActor_name_t cancel_item) { - int idx = -1; - - if (priv != NULL) { - mActor_name_t* pockets = priv->inventory.pockets; - int i; +extern int mPr_GetPossessionItemIdxFGTypeWithCond_cancel(Private_c* priv, mActor_name_t fg_type, u32 cond, + mActor_name_t cancel_item) { + int idx = -1; - for (i = 0; i < mPr_POCKETS_SLOT_COUNT; i++) { - if (ITEM_NAME_GET_TYPE(*pockets) == fg_type && cond == mPr_GET_ITEM_COND(priv->inventory.item_conditions, i) && *pockets != cancel_item) { - idx = i; - break; - } - - pockets++; + if (priv != NULL) { + mActor_name_t* pockets = priv->inventory.pockets; + int i; + + for (i = 0; i < mPr_POCKETS_SLOT_COUNT; i++) { + if (ITEM_NAME_GET_TYPE(*pockets) == fg_type && + cond == mPr_GET_ITEM_COND(priv->inventory.item_conditions, i) && *pockets != cancel_item) { + idx = i; + break; + } + + pockets++; + } } - } - return idx; + return idx; } extern int mPr_GetPossessionItemIdxItem1Category(Private_c* priv, u8 item1_type) { - int idx = -1; - - if (priv != NULL) { - mActor_name_t* pockets = priv->inventory.pockets; - int i; + int idx = -1; - for (i = 0; i < mPr_POCKETS_SLOT_COUNT; i++) { - if (ITEM_NAME_GET_TYPE(*pockets) == NAME_TYPE_ITEM1 && GET_NAME_ITEM1_CATEGORY(*pockets) == item1_type) { - idx = i; - break; - } - pockets++; + if (priv != NULL) { + mActor_name_t* pockets = priv->inventory.pockets; + int i; + + for (i = 0; i < mPr_POCKETS_SLOT_COUNT; i++) { + if (ITEM_NAME_GET_TYPE(*pockets) == NAME_TYPE_ITEM1 && GET_NAME_ITEM1_CATEGORY(*pockets) == item1_type) { + idx = i; + break; + } + pockets++; + } } - } - return idx; + return idx; } -extern int mPr_GetPossessionItemIdxItem1CategoryWithCond_cancel(Private_c* priv, u8 item1_type, u32 cond, mActor_name_t cancel_item) { - int idx = -1; - - if (priv != NULL) { - mActor_name_t* pockets = priv->inventory.pockets; - int i; +extern int mPr_GetPossessionItemIdxItem1CategoryWithCond_cancel(Private_c* priv, u8 item1_type, u32 cond, + mActor_name_t cancel_item) { + int idx = -1; - for (i = 0; i < mPr_POCKETS_SLOT_COUNT; i++) { - if (ITEM_NAME_GET_TYPE(*pockets) == NAME_TYPE_ITEM1 && GET_NAME_ITEM1_CATEGORY(*pockets) == item1_type && cond == mPr_GET_ITEM_COND(priv->inventory.item_conditions, i) && *pockets != cancel_item) { - idx = i; - break; - } - pockets++; + if (priv != NULL) { + mActor_name_t* pockets = priv->inventory.pockets; + int i; + + for (i = 0; i < mPr_POCKETS_SLOT_COUNT; i++) { + if (ITEM_NAME_GET_TYPE(*pockets) == NAME_TYPE_ITEM1 && GET_NAME_ITEM1_CATEGORY(*pockets) == item1_type && + cond == mPr_GET_ITEM_COND(priv->inventory.item_conditions, i) && *pockets != cancel_item) { + idx = i; + break; + } + pockets++; + } } - } - return idx; + return idx; } -extern int mPr_GetPossessionItemIdxKindWithCond(Private_c* priv, mActor_name_t kind_start, mActor_name_t kind_end, u32 cond) { - int idx = -1; - - if (priv != NULL) { - mActor_name_t* pockets = priv->inventory.pockets; - int i; +extern int mPr_GetPossessionItemIdxKindWithCond(Private_c* priv, mActor_name_t kind_start, mActor_name_t kind_end, + u32 cond) { + int idx = -1; - for (i = 0; i < mPr_POCKETS_SLOT_COUNT; i++) { - if (*pockets >= kind_start && *pockets < kind_end && cond == mPr_GET_ITEM_COND(priv->inventory.item_conditions, i)) { - idx = i; - break; - } - pockets++; + if (priv != NULL) { + mActor_name_t* pockets = priv->inventory.pockets; + int i; + + for (i = 0; i < mPr_POCKETS_SLOT_COUNT; i++) { + if (*pockets >= kind_start && *pockets < kind_end && + cond == mPr_GET_ITEM_COND(priv->inventory.item_conditions, i)) { + idx = i; + break; + } + pockets++; + } } - } - return idx; + return idx; } extern int mPr_GetPossessionItemSum(Private_c* priv, mActor_name_t item) { - int sum = 0; + int sum = 0; - if (priv != NULL) { - mActor_name_t* pockets = priv->inventory.pockets; - int i; + if (priv != NULL) { + mActor_name_t* pockets = priv->inventory.pockets; + int i; - for (i = 0; i < mPr_POCKETS_SLOT_COUNT; i++) { - if (*pockets == item) { - sum++; - } - pockets++; + for (i = 0; i < mPr_POCKETS_SLOT_COUNT; i++) { + if (*pockets == item) { + sum++; + } + pockets++; + } } - } - return sum; + return sum; } extern int mPr_GetPossessionItemSumWithCond(Private_c* priv, mActor_name_t item, u32 cond) { - int sum = 0; + int sum = 0; - if (priv != NULL) { - mActor_name_t* pockets = priv->inventory.pockets; - int i; + if (priv != NULL) { + mActor_name_t* pockets = priv->inventory.pockets; + int i; - for (i = 0; i < mPr_POCKETS_SLOT_COUNT; i++) { - if (*pockets == item && cond == mPr_GET_ITEM_COND(priv->inventory.item_conditions, i)) { - sum++; - } - pockets++; + for (i = 0; i < mPr_POCKETS_SLOT_COUNT; i++) { + if (*pockets == item && cond == mPr_GET_ITEM_COND(priv->inventory.item_conditions, i)) { + sum++; + } + pockets++; + } } - } - return sum; + return sum; } -extern int mPr_GetPossessionItemSumFGTypeWithCond_cancel(Private_c* priv, mActor_name_t fg_type, u32 cond, mActor_name_t cancel_item) { - int sum = 0; +extern int mPr_GetPossessionItemSumFGTypeWithCond_cancel(Private_c* priv, mActor_name_t fg_type, u32 cond, + mActor_name_t cancel_item) { + int sum = 0; - if (priv != NULL) { - mActor_name_t* pockets = priv->inventory.pockets; - int i; + if (priv != NULL) { + mActor_name_t* pockets = priv->inventory.pockets; + int i; - for (i = 0; i < mPr_POCKETS_SLOT_COUNT; i++) { - if (ITEM_NAME_GET_TYPE(*pockets) == fg_type && cond == mPr_GET_ITEM_COND(priv->inventory.item_conditions, i) && *pockets != cancel_item) { - sum++; - } - pockets++; + for (i = 0; i < mPr_POCKETS_SLOT_COUNT; i++) { + if (ITEM_NAME_GET_TYPE(*pockets) == fg_type && + cond == mPr_GET_ITEM_COND(priv->inventory.item_conditions, i) && *pockets != cancel_item) { + sum++; + } + pockets++; + } } - } - return sum; + return sum; } -extern int mPr_GetPossessionItemSumItemCategoryWithCond_cancel(Private_c* priv, u8 item1_type, u32 cond, mActor_name_t cancel_item) { - int sum = 0; +extern int mPr_GetPossessionItemSumItemCategoryWithCond_cancel(Private_c* priv, u8 item1_type, u32 cond, + mActor_name_t cancel_item) { + int sum = 0; - if (priv != NULL) { - mActor_name_t* pockets = priv->inventory.pockets; - int i; + if (priv != NULL) { + mActor_name_t* pockets = priv->inventory.pockets; + int i; - for (i = 0; i < mPr_POCKETS_SLOT_COUNT; i++) { - if (ITEM_NAME_GET_TYPE(*pockets) == NAME_TYPE_ITEM1 && GET_NAME_ITEM1_CATEGORY(*pockets) == item1_type && cond == mPr_GET_ITEM_COND(priv->inventory.item_conditions, i) && *pockets != cancel_item) { - sum++; - } - pockets++; + for (i = 0; i < mPr_POCKETS_SLOT_COUNT; i++) { + if (ITEM_NAME_GET_TYPE(*pockets) == NAME_TYPE_ITEM1 && GET_NAME_ITEM1_CATEGORY(*pockets) == item1_type && + cond == mPr_GET_ITEM_COND(priv->inventory.item_conditions, i) && *pockets != cancel_item) { + sum++; + } + pockets++; + } } - } - return sum; + return sum; } extern int mPr_GetPossessionItemSumItemCategoryWithCond(Private_c* priv, u8 item1_type, u32 cond) { - int sum = 0; + int sum = 0; - if (priv != NULL) { - mActor_name_t* pockets = priv->inventory.pockets; - int i; + if (priv != NULL) { + mActor_name_t* pockets = priv->inventory.pockets; + int i; - for (i = 0; i < mPr_POCKETS_SLOT_COUNT; i++) { - if (ITEM_NAME_GET_TYPE(*pockets) == NAME_TYPE_ITEM1 && GET_NAME_ITEM1_CATEGORY(*pockets) == item1_type && cond == mPr_GET_ITEM_COND(priv->inventory.item_conditions, i)) { - sum++; - } - pockets++; + for (i = 0; i < mPr_POCKETS_SLOT_COUNT; i++) { + if (ITEM_NAME_GET_TYPE(*pockets) == NAME_TYPE_ITEM1 && GET_NAME_ITEM1_CATEGORY(*pockets) == item1_type && + cond == mPr_GET_ITEM_COND(priv->inventory.item_conditions, i)) { + sum++; + } + pockets++; + } } - } - return sum; + return sum; } -extern int mPr_GetPossessionItemSumKindWithCond(Private_c* priv, mActor_name_t kind_start, mActor_name_t kind_end, u32 cond) { - int sum = 0; +extern int mPr_GetPossessionItemSumKindWithCond(Private_c* priv, mActor_name_t kind_start, mActor_name_t kind_end, + u32 cond) { + int sum = 0; - if (priv != NULL) { - mActor_name_t* pockets = priv->inventory.pockets; - int i; + if (priv != NULL) { + mActor_name_t* pockets = priv->inventory.pockets; + int i; - for (i = 0; i < mPr_POCKETS_SLOT_COUNT; i++) { - if (*pockets >= kind_start && *pockets < kind_end && cond == mPr_GET_ITEM_COND(priv->inventory.item_conditions, i)) { - sum++; - } - pockets++; + for (i = 0; i < mPr_POCKETS_SLOT_COUNT; i++) { + if (*pockets >= kind_start && *pockets < kind_end && + cond == mPr_GET_ITEM_COND(priv->inventory.item_conditions, i)) { + sum++; + } + pockets++; + } } - } - return sum; + return sum; } extern void mPr_SetItemCollectBit(mActor_name_t item) { - mActor_name_t ftr_item_no = mRmTp_Item1ItemNo2FtrItemNo_AtPlayerRoom(item, 0); - int item_type; + mActor_name_t ftr_item_no = mRmTp_Item1ItemNo2FtrItemNo_AtPlayerRoom(item, 0); + int item_type; - if ((ftr_item_no >= FTR_FISH00 && ftr_item_no <= FTR_FISH39_WEST) || (ftr_item_no >= FTR_INSECT00 && ftr_item_no <= FTR_INSECT39_WEST)) { - return; - } + if ((ftr_item_no >= FTR_FISH00 && ftr_item_no <= FTR_FISH39_WEST) || + (ftr_item_no >= FTR_INSECT00 && ftr_item_no <= FTR_INSECT39_WEST)) { + return; + } - item_type = ITEM_NAME_GET_TYPE(ftr_item_no); + item_type = ITEM_NAME_GET_TYPE(ftr_item_no); - if (item_type == NAME_TYPE_FTR0 || item_type == NAME_TYPE_FTR1) { - int ftr_idx = mRmTp_FtrItemNo2FtrIdx(ftr_item_no); + if (item_type == NAME_TYPE_FTR0 || item_type == NAME_TYPE_FTR1) { + int ftr_idx = mRmTp_FtrItemNo2FtrIdx(ftr_item_no); if (ftr_idx >= 0 && ftr_idx < FTR_NUM) { - Common_Get(now_private)->furniture_collected_bitfield[ftr_idx >> 5] |= (1 << (ftr_idx & 31)); + Common_Get(now_private)->furniture_collected_bitfield[ftr_idx >> 5] |= (1 << (ftr_idx & 31)); } - - } - else if (item_type == NAME_TYPE_ITEM1) { - int category = ITEM_NAME_GET_CAT(ftr_item_no); + + } else if (item_type == NAME_TYPE_ITEM1) { + int category = ITEM_NAME_GET_CAT(ftr_item_no); if (category == ITEM1_CAT_PAPER) { - int idx = (ftr_item_no - ITM_PAPER_START) % 64; // 64 unique stationery - Common_Get(now_private)->paper_collected_bitfield[idx >> 5] |= (1 << (idx & 31)); + int idx = (ftr_item_no - ITM_PAPER_START) % 64; // 64 unique stationery + Common_Get(now_private)->paper_collected_bitfield[idx >> 5] |= (1 << (idx & 31)); + } else if (category == ITEM1_CAT_CARPET) { + int idx = ftr_item_no - ITM_CARPET_START; + Common_Get(now_private)->carpet_collected_bitfield[idx >> 5] |= (1 << (idx & 31)); + } else if (category == ITEM1_CAT_WALL) { + int idx = ftr_item_no - ITM_WALL_START; + Common_Get(now_private)->wall_collected_bitfield[idx >> 5] |= (1 << (idx & 31)); + } else if (category == ITEM1_CAT_MINIDISK) { + mActor_name_t idx = + ftr_item_no - ITM_MINIDISK_START; // why is this one u16, probably mActor_name_t type or something? + Common_Get(now_private)->music_collected_bitfield[idx >> 5] |= (1 << (idx & 31)); } - else if (category == ITEM1_CAT_CARPET) { - int idx = ftr_item_no - ITM_CARPET_START; - Common_Get(now_private)->carpet_collected_bitfield[idx >> 5] |= (1 << (idx & 31)); - } - else if (category == ITEM1_CAT_WALL) { - int idx = ftr_item_no - ITM_WALL_START; - Common_Get(now_private)->wall_collected_bitfield[idx >> 5] |= (1 << (idx & 31)); - } - else if (category == ITEM1_CAT_MINIDISK) { - mActor_name_t idx = ftr_item_no - ITM_MINIDISK_START; // why is this one u16, probably mActor_name_t type or something? - Common_Get(now_private)->music_collected_bitfield[idx >> 5] |= (1 << (idx & 31)); - } - } + } } extern mActor_name_t mPr_DummyPresentToTruePresent() { - mActor_name_t true_present = EMPTY_NO; + mActor_name_t true_present = EMPTY_NO; - /* 80% chance of rolling furniture from town's rare list */ - if (RANDOM(5) != 0) { - mSP_SelectRandomItem_New(NULL, &true_present, 1, NULL, 0, mSP_KIND_FURNITURE, mSP_LISTTYPE_RARE, FALSE); - } + /* 80% chance of rolling furniture from town's rare list */ + if (RANDOM(5) != 0) { + mSP_SelectRandomItem_New(NULL, &true_present, 1, NULL, 0, mSP_KIND_FURNITURE, mSP_LISTTYPE_RARE, FALSE); + } - /* 20% (and default case) to get random non-native fruit */ - if (true_present == EMPTY_NO) { - true_present = mFI_GetOtherFruit(); - } + /* 20% (and default case) to get random non-native fruit */ + if (true_present == EMPTY_NO) { + true_present = mFI_GetOtherFruit(); + } - return true_present; + return true_present; } extern void mPr_SetPossessionItem(Private_c* priv, int idx, mActor_name_t item, u32 cond) { - switch (item) { - case ITM_PRESENT: - { - item = mPr_DummyPresentToTruePresent(); - cond = mPr_ITEM_COND_PRESENT; - break; + switch (item) { + case ITM_PRESENT: { + item = mPr_DummyPresentToTruePresent(); + cond = mPr_ITEM_COND_PRESENT; + break; + } + + case ITM_GOLDEN_NET_PRESENT: { + item = ITM_GOLDEN_NET; + cond = mPr_ITEM_COND_PRESENT; + break; + } + + case ITM_GOLDEN_AXE_PRESENT: { + item = ITM_GOLDEN_AXE; + cond = mPr_ITEM_COND_PRESENT; + break; + } + + case ITM_GOLDEN_SHOVEL_PRESENT: { + item = ITM_GOLDEN_SHOVEL; + cond = mPr_ITEM_COND_PRESENT; + break; + } + + case ITM_GOLDEN_ROD_PRESENT: { + item = ITM_GOLDEN_ROD; + cond = mPr_ITEM_COND_PRESENT; + break; + } } - case ITM_GOLDEN_NET_PRESENT: - { - item = ITM_GOLDEN_NET; - cond = mPr_ITEM_COND_PRESENT; - break; + priv->inventory.pockets[idx] = item; + priv->inventory.item_conditions = + ((priv->inventory.item_conditions & (~(u32)(mPr_ITEM_COND_NUM << (idx * 2)))) | (cond << (idx * 2))); + + if (cond == mPr_ITEM_COND_NORMAL) { + mPr_SetItemCollectBit(item); } - - case ITM_GOLDEN_AXE_PRESENT: - { - item = ITM_GOLDEN_AXE; - cond = mPr_ITEM_COND_PRESENT; - break; - } - - case ITM_GOLDEN_SHOVEL_PRESENT: - { - item = ITM_GOLDEN_SHOVEL; - cond = mPr_ITEM_COND_PRESENT; - break; - } - - case ITM_GOLDEN_ROD_PRESENT: - { - item = ITM_GOLDEN_ROD; - cond = mPr_ITEM_COND_PRESENT; - break; - } - } - - priv->inventory.pockets[idx] = item; - priv->inventory.item_conditions = ((priv->inventory.item_conditions & (~(u32)(mPr_ITEM_COND_NUM << (idx * 2)))) | (cond << (idx * 2))); - - if (cond == mPr_ITEM_COND_NORMAL) { - mPr_SetItemCollectBit(item); - } } extern int mPr_SetFreePossessionItem(Private_c* priv, mActor_name_t item, u32 cond) { - int idx = mPr_GetPossessionItemIdx(priv, EMPTY_NO); - int res; + int idx = mPr_GetPossessionItemIdx(priv, EMPTY_NO); + int res; - if (idx == -1) { - res = FALSE; - } - else { - mPr_SetPossessionItem(priv, idx, item, cond); - res = TRUE; - } + if (idx == -1) { + res = FALSE; + } else { + mPr_SetPossessionItem(priv, idx, item, cond); + res = TRUE; + } - return res; + return res; } extern void mPr_AddFirstJobHint(Private_c* priv) { - int hints = priv->hint_count + 1; - if ((hints & 0x7F) >= 10) { - hints = 0x80; // signal all hints have been given - } + int hints = priv->hint_count + 1; + if ((hints & 0x7F) >= 10) { + hints = 0x80; // signal all hints have been given + } - priv->hint_count = hints; + priv->hint_count = hints; } extern int mPr_GetFirstJobHintTime(Private_c* priv) { - return priv->hint_count & 0x7F; + return priv->hint_count & 0x7F; } extern int mPr_CheckFirstJobHint(Private_c* priv) { - return (priv->hint_count & 0x80) >> 7; + return (priv->hint_count & 0x80) >> 7; } extern s16 mPr_GetMoneyPower() { - s16 money_power = Common_Get(money_power); - Private_c* priv = Common_Get(now_private); + s16 money_power = Common_Get(money_power); + Private_c* priv = Common_Get(now_private); - if (priv != NULL) { - switch (priv->destiny.type) { - case mPr_DESTINY_MONEY_LUCK: - { - money_power += 100; - break; - } + if (priv != NULL) { + switch (priv->destiny.type) { + case mPr_DESTINY_MONEY_LUCK: { + money_power += 100; + break; + } - case mPr_DESTINY_BAD_LUCK: - { - money_power -= 50; - break; - } + case mPr_DESTINY_BAD_LUCK: { + money_power -= 50; + break; + } + } } - } - if (money_power < mPr_MONEY_POWER_MIN) { - money_power = mPr_MONEY_POWER_MIN; - } + if (money_power < mPr_MONEY_POWER_MIN) { + money_power = mPr_MONEY_POWER_MIN; + } - return money_power; + return money_power; } extern s16 mPr_GetGoodsPower() { - s16 goods_power = Common_Get(goods_power); - Private_c* priv = Common_Get(now_private); + s16 goods_power = Common_Get(goods_power); + Private_c* priv = Common_Get(now_private); - if (priv != NULL) { - switch (priv->destiny.type) { - case mPr_DESTINY_GOODS_LUCK: - { - goods_power += 30; - break; - } + if (priv != NULL) { + switch (priv->destiny.type) { + case mPr_DESTINY_GOODS_LUCK: { + goods_power += 30; + break; + } - case mPr_DESTINY_BAD_LUCK: - { - goods_power -= 30; - break; - } + case mPr_DESTINY_BAD_LUCK: { + goods_power -= 30; + break; + } + } } - } - if (goods_power > mPr_GOODS_POWER_MAX) { - return mPr_GOODS_POWER_MAX; - } - - if (goods_power < mPr_GOODS_POWER_MIN) { - goods_power = mPr_GOODS_POWER_MIN; - } + if (goods_power > mPr_GOODS_POWER_MAX) { + return mPr_GOODS_POWER_MAX; + } - return goods_power; + if (goods_power < mPr_GOODS_POWER_MIN) { + goods_power = mPr_GOODS_POWER_MIN; + } + + return goods_power; } extern int mPr_CheckMuseumAddress(Private_c* priv) { - int res = FALSE; + int res = FALSE; - if (priv != NULL && priv->museum_record.contacted) { - res = TRUE; - } + if (priv != NULL && priv->museum_record.contacted) { + res = TRUE; + } - return res; + return res; } extern int mPr_CheckMuseumInfoMail(Private_c* priv) { - int res = FALSE; + int res = FALSE; - if (priv != NULL && priv->museum_record.send_info_mail) { - res = TRUE; - } + if (priv != NULL && priv->museum_record.send_info_mail) { + res = TRUE; + } - return res; + return res; } extern Private_c* mPr_GetForeignerP() { - return &g_foreigner_private; + return &g_foreigner_private; } extern int mPr_LoadPak_and_SetPrivateInfo2(Private_c* unused_private, u8 player_no) { - Private_c* priv; - int res = FALSE; + Private_c* priv; + int res = FALSE; - if (player_no < mPr_FOREIGNER) { - u32 loan; - mHm_hs_c* house; - Private_c* priv = Save_Get(private + player_no); - if (mPr_CheckCmpPrivate(priv, &g_foreigner_private) == TRUE) { - house = Save_GetPointer(homes[mHS_get_arrange_idx(player_no)]); - loan = priv->inventory.loan; - mPr_CopyPrivateInfo(priv, &g_foreigner_private); - if (mHm_CheckKeepHouseSize(player_no) == FALSE || house->size_info.next_size == mHm_HOMESIZE_STATUE) { - priv->inventory.loan = loan; - } + if (player_no < mPr_FOREIGNER) { + u32 loan; + mHm_hs_c* house; + Private_c* priv = Save_Get(private_data + player_no); + if (mPr_CheckCmpPrivate(priv, &g_foreigner_private) == TRUE) { + house = Save_GetPointer(homes[mHS_get_arrange_idx(player_no)]); + loan = priv->inventory.loan; + mPr_CopyPrivateInfo(priv, &g_foreigner_private); + if (mHm_CheckKeepHouseSize(player_no) == FALSE || house->size_info.next_size == mHm_HOMESIZE_STATUE) { + priv->inventory.loan = loan; + } - res = TRUE; - Common_Set(now_private, priv); - Common_Set(player_no, player_no); - } - } - else { - mHm_hs_c* house; - int exist_player; - u32 loan; - int i; - - priv = Save_Get(private); - for (i = 0; i < PLAYER_NUM; i++) { - exist_player = mPr_CheckCmpPrivate(priv, &g_foreigner_private); - if (exist_player == TRUE) { - house = Save_GetPointer(homes[mHS_get_arrange_idx(i)]); - loan = priv->inventory.loan; + res = TRUE; + Common_Set(now_private, priv); + Common_Set(player_no, player_no); + } + } else { + mHm_hs_c* house; + int exist_player; + u32 loan; + int i; - g_foreigner_private.museum_record.contacted = priv->museum_record.contacted; - mPr_CopyPrivateInfo(priv, &g_foreigner_private); + priv = Save_Get(private_data); + for (i = 0; i < PLAYER_NUM; i++) { + exist_player = mPr_CheckCmpPrivate(priv, &g_foreigner_private); + if (exist_player == TRUE) { + house = Save_GetPointer(homes[mHS_get_arrange_idx(i)]); + loan = priv->inventory.loan; - if (mHm_CheckKeepHouseSize(i) == FALSE || house->size_info.next_size == mHm_HOMESIZE_STATUE) { - priv->inventory.loan = loan; + g_foreigner_private.museum_record.contacted = priv->museum_record.contacted; + mPr_CopyPrivateInfo(priv, &g_foreigner_private); + + if (mHm_CheckKeepHouseSize(i) == FALSE || house->size_info.next_size == mHm_HOMESIZE_STATUE) { + priv->inventory.loan = loan; + } + + res = TRUE; + Common_Set(now_private, priv); + Common_Set(player_no, i); + break; + } + + priv++; } - res = TRUE; - Common_Set(now_private, priv); - Common_Set(player_no, i); - break; - } - - priv++; + if (exist_player == FALSE) { + res = TRUE; + Common_Set(now_private, &g_foreigner_private); + Common_Set(player_no, mPr_FOREIGNER); + } } - if (exist_player == FALSE) { - res = TRUE; - Common_Set(now_private, &g_foreigner_private); - Common_Set(player_no, mPr_FOREIGNER); - } - } - - return res; + return res; } extern void mPr_ClearMotherMailInfo(mPr_mother_mail_info_c* mother_mail) { - mother_mail->date = mTM_rtcTime_ymd_clear_code; - bzero(&mother_mail->data, sizeof(mPr_mother_mail_data_c)); + mother_mail->date = mTM_rtcTime_ymd_clear_code; + bzero(&mother_mail->data, sizeof(mPr_mother_mail_data_c)); } static int mPr_GetMotherMailPaperType(int month, int day) { - static u8 paper_table[lbRTC_MONTHS_MAX] = { - 13, 49, 32, 12, 62, 14, 19, 11, 59, 46, 47, 17 - }; + static u8 paper_table[lbRTC_MONTHS_MAX] = { 13, 49, 32, 12, 62, 14, 19, 11, 59, 46, 47, 17 }; - Private_c* priv = Common_Get(now_private); - int paper; + Private_c* priv = Common_Get(now_private); + int paper; - /* TODO: should paper be enums? */ - if (priv->birthday.month == month && priv->birthday.day == day) { - paper = 1; - } - else if (month == lbRTC_JANUARY && day == 1) { - paper = 63; - } - else if (month == lbRTC_AUGUST && day == 8) { - paper = 48; - } - else if (month == lbRTC_DECEMBER && day == 24) { - paper = 23; - } - else { - int idx = month - 1; - paper = paper_table[idx]; - } + /* TODO: should paper be enums? */ + if (priv->birthday.month == month && priv->birthday.day == day) { + paper = 1; + } else if (month == lbRTC_JANUARY && day == 1) { + paper = 63; + } else if (month == lbRTC_AUGUST && day == 8) { + paper = 48; + } else if (month == lbRTC_DECEMBER && day == 24) { + paper = 23; + } else { + int idx = month - 1; + paper = paper_table[idx]; + } - return paper - 1; + return paper - 1; } static void mPr_GetMotherMail(Mail_c* mail, PersonalID_c* pid, mActor_name_t present, int stationery, int mail_no) { - int header_back_pos; + int header_back_pos; - mMl_clear_mail(mail); - mHandbill_Load_HandbillFromRom(mail->content.header, &header_back_pos, mail->content.footer, mail->content.body, mail_no); - mail->content.header_back_start = header_back_pos; - mail->content.font = 0; // TODO: enum - mail->content.mail_type = 4; // TODO: enum, this is "from mom" - mMl_set_to_plname(mail, pid); - mail->present = present; - mail->content.paper_type = stationery; + mMl_clear_mail(mail); + mHandbill_Load_HandbillFromRom(mail->content.header, &header_back_pos, mail->content.footer, mail->content.body, + mail_no); + mail->content.header_back_start = header_back_pos; + mail->content.font = 0; // TODO: enum + mail->content.mail_type = 4; // TODO: enum, this is "from mom" + mMl_set_to_plname(mail, pid); + mail->present = present; + mail->content.paper_type = stationery; } -static int mPr_SendMotherMailPost(PersonalID_c* pid, int player_no, mActor_name_t present, int stationery, int mail_no) { - Mail_c* mail; - mHm_hs_c* home; - int res = FALSE; +static int mPr_SendMotherMailPost(PersonalID_c* pid, int player_no, mActor_name_t present, int stationery, + int mail_no) { + Mail_c* mail; + mHm_hs_c* home; + int res = FALSE; - mail = &l_mpr_mail; - home = Save_GetPointer(homes[mHS_get_arrange_idx(player_no)]); + mail = &l_mpr_mail; + home = Save_GetPointer(homes[mHS_get_arrange_idx(player_no)]); - if (mPr_CheckCmpPersonalID(pid, &home->ownerID) == TRUE) { - int mailbox_idx = mMl_chk_mail_free_space(home->mailbox, HOME_MAILBOX_SIZE); - if (mailbox_idx != -1) { - mPr_GetMotherMail(mail, pid, present, stationery, mail_no); - mMl_copy_mail(&home->mailbox[mailbox_idx], mail); - res = TRUE; + if (mPr_CheckCmpPersonalID(pid, &home->ownerID) == TRUE) { + int mailbox_idx = mMl_chk_mail_free_space(home->mailbox, HOME_MAILBOX_SIZE); + if (mailbox_idx != -1) { + mPr_GetMotherMail(mail, pid, present, stationery, mail_no); + mMl_copy_mail(&home->mailbox[mailbox_idx], mail); + res = TRUE; + } else if (mPO_get_keep_mail_sum() < mPO_MAIL_STORAGE_SIZE) { + mPr_GetMotherMail(mail, pid, present, stationery, mail_no); + res = mPO_receipt_proc(mail, mPO_SENDTYPE_MAIL); + } } - else if (mPO_get_keep_mail_sum() < mPO_MAIL_STORAGE_SIZE) { - mPr_GetMotherMail(mail, pid, present, stationery, mail_no); - res = mPO_receipt_proc(mail, mPO_SENDTYPE_MAIL); - } - } - return res; + return res; } static int mPr_SendMotherMailDate(mPr_mother_mail_info_c* mother_mail, lbRTC_time_c* send_time) { - mActor_name_t present = EMPTY_NO; - int mail_no = -1; - int res = FALSE; + mActor_name_t present = EMPTY_NO; + int mail_no = -1; + int res = FALSE; - if (Common_Get(now_private)->birthday.month == send_time->month && Common_Get(now_private)->birthday.day == send_time->day) { - mail_no = 0x184 + RANDOM(mPr_MOTHER_MAIL_MONTHLY_NUM); - present = FTR_BIRTHDAY_CAKE; - } - else if (send_time->month == send_time->day) { - int letter_num = (send_time->month - 1) * mPr_MOTHER_MAIL_MONTHLY_NUM + RANDOM(mPr_MOTHER_MAIL_MONTHLY_NUM); - mail_no = 0x164 + letter_num; - - if (send_time->month == lbRTC_JANUARY) { - present = ITM_MONEY_10000; - } - else if (letter_num == 18) { // TODO: these probably have enums... - present = ITM_FOOD_MUSHROOM; - } - } - else { - if (send_time->month == lbRTC_APRIL && send_time->day == 1) { - mail_no = 0x180; // April Fools - } - else if (mEv_check_status(mEv_EVENT_MOTHERS_DAY, mEv_STATUS_ACTIVE) == TRUE) { - mail_no = 0x17C; - } - else if (mEv_check_status(mEv_EVENT_FATHERS_DAY, mEv_STATUS_ACTIVE) == TRUE) { - mail_no = 0x17E; - } - else if (send_time->month == lbRTC_DECEMBER && send_time->day == 24) { - mail_no = 0x182; // Toy Day (Christmas) - mSP_SelectRandomItem_New(NULL, &present, 1, NULL, 0, mSP_KIND_FURNITURE, mSP_LISTTYPE_ABC, FALSE); - } + if (Common_Get(now_private)->birthday.month == send_time->month && + Common_Get(now_private)->birthday.day == send_time->day) { + mail_no = 0x184 + RANDOM(mPr_MOTHER_MAIL_MONTHLY_NUM); + present = FTR_BIRTHDAY_CAKE; + } else if (send_time->month == send_time->day) { + int letter_num = (send_time->month - 1) * mPr_MOTHER_MAIL_MONTHLY_NUM + RANDOM(mPr_MOTHER_MAIL_MONTHLY_NUM); + mail_no = 0x164 + letter_num; - if (mail_no != -1) { - /* Randomize between two letter variants */ - mail_no += RANDOM(mPr_MOTHER_MAIL_MONTHLY_NUM); - } + if (send_time->month == lbRTC_JANUARY) { + present = ITM_MONEY_10000; + } else if (letter_num == 18) { // TODO: these probably have enums... + present = ITM_FOOD_MUSHROOM; + } + } else { + if (send_time->month == lbRTC_APRIL && send_time->day == 1) { + mail_no = 0x180; // April Fools + } else if (mEv_check_status(mEv_EVENT_MOTHERS_DAY, mEv_STATUS_ACTIVE) == TRUE) { + mail_no = 0x17C; + } else if (mEv_check_status(mEv_EVENT_FATHERS_DAY, mEv_STATUS_ACTIVE) == TRUE) { + mail_no = 0x17E; + } else if (send_time->month == lbRTC_DECEMBER && send_time->day == 24) { + mail_no = 0x182; // Toy Day (Christmas) + mSP_SelectRandomItem_New(NULL, &present, 1, NULL, 0, mSP_KIND_FURNITURE, mSP_LISTTYPE_ABC, FALSE); + } + + if (mail_no != -1) { + /* Randomize between two letter variants */ + mail_no += RANDOM(mPr_MOTHER_MAIL_MONTHLY_NUM); + } } - if (mail_no != -1) { - if (mPr_SendMotherMailPost(&Common_Get(now_private)->player_ID, Common_Get(player_no), present, mPr_GetMotherMailPaperType(send_time->month, send_time->day), mail_no) == TRUE) { - mTM_set_renew_time(&mother_mail->date, send_time); + if (mail_no != -1) { + if (mPr_SendMotherMailPost(&Common_Get(now_private)->player_ID, Common_Get(player_no), present, + mPr_GetMotherMailPaperType(send_time->month, send_time->day), mail_no) == TRUE) { + mTM_set_renew_time(&mother_mail->date, send_time); + } + + res = TRUE; } - res = TRUE; - } - - return res; + return res; } static int mPr_CheckMotherMailMonthly(mPr_mother_mail_data_c* send_data, int month, int idx) { - if (month == lbRTC_AUGUST) { - return (send_data->august >> (idx)) & 1; // August gets its own byte because it has more than two event letters - } - else { - int shift = (month - 1) * 2; - int slot = shift / 8; - shift -= slot * 8; - idx += shift; + if (month == lbRTC_AUGUST) { + return (send_data->august >> (idx)) & 1; // August gets its own byte because it has more than two event letters + } else { + int shift = (month - 1) * 2; + int slot = shift / 8; + shift -= slot * 8; + idx += shift; - return (send_data->monthly[slot] >> idx) & 1; - } + return (send_data->monthly[slot] >> idx) & 1; + } } static int mPr_GetMotherMailMonthlyNotSendNum(mPr_mother_mail_data_c* send_data, int month) { - int slot; - int not_send_num = 0; - int i; + int slot; + int not_send_num = 0; + int i; - if (month == lbRTC_AUGUST) { - for (i = 0; i < 8; i++) { - if (((send_data->august >> i) & 1) == 0) { - not_send_num++; - } + if (month == lbRTC_AUGUST) { + for (i = 0; i < 8; i++) { + if (((send_data->august >> i) & 1) == 0) { + not_send_num++; + } + } + } else { + u8 byte; + int shift = (month - 1) * 2; + slot = shift / 8; + shift -= slot * 8; + byte = send_data->monthly[slot]; + + for (i = 0; i < 2; i++) { + if (((byte >> shift) & 1) == 0) { + not_send_num++; + shift++; + } + } } - } - else { - u8 byte; - int shift = (month - 1) * 2; - slot = shift / 8; - shift -= slot * 8; - byte = send_data->monthly[slot]; - for (i = 0; i < 2; i++) { - if (((byte >> shift) & 1) == 0) { - not_send_num++; - shift++; - } - } - } - - return not_send_num; + return not_send_num; } static void mPr_SetMotherMailMonthly(mPr_mother_mail_data_c* send_data, int month, int idx) { - if (month == lbRTC_AUGUST) { - send_data->august |= 1 << idx; - } - else { - /* TODO: almost certainly a fake match */ - u8* s; - int slot; - int shift; - - shift = (month - 1) * 2; - slot = ((month - 1) * 2) / 8; - shift -= slot * 8; - idx += shift; + if (month == lbRTC_AUGUST) { + send_data->august |= 1 << idx; + } else { + /* TODO: almost certainly a fake match */ + u8* s; + int slot; + int shift; - s = send_data->monthly + slot; - *s |= 1 << idx; - } + shift = (month - 1) * 2; + slot = ((month - 1) * 2) / 8; + shift -= slot * 8; + idx += shift; + + s = send_data->monthly + slot; + *s |= 1 << idx; + } } -static void mPr_GetMotherMailMonthlyData(mPr_mother_mail_data_c* send_data, int* mail_no, mActor_name_t* present, int* event_no, int month, int not_send_num) { - static int mail_start_no_table[mTM_SEASON_NUM] = { 0x18C, 0x192, 0x186, 0x19E }; - static mActor_name_t may_2_item_table[1] = { ITM_CLOTH105 }; // fortune shirt - static mActor_name_t december_2_item_table[6] = { - ITM_CLOTH108, // aurora knit - ITM_CLOTH109, // winter sweater - ITM_CLOTH110, // go-go shirt - ITM_CLOTH144, // deer shirt - ITM_CLOTH145, // blue check shirt - ITM_CLOTH156 // fish knit - }; +static void mPr_GetMotherMailMonthlyData(mPr_mother_mail_data_c* send_data, int* mail_no, mActor_name_t* present, + int* event_no, int month, int not_send_num) { + static int mail_start_no_table[mTM_SEASON_NUM] = { 0x18C, 0x192, 0x186, 0x19E }; + static mActor_name_t may_2_item_table[1] = { ITM_CLOTH105 }; // fortune shirt + static mActor_name_t december_2_item_table[6] = { + ITM_CLOTH108, // aurora knit + ITM_CLOTH109, // winter sweater + ITM_CLOTH110, // go-go shirt + ITM_CLOTH144, // deer shirt + ITM_CLOTH145, // blue check shirt + ITM_CLOTH156 // fish knit + }; - int max; - int mail_start_idx; - int selected_event; - int i; - - *present = EMPTY_NO; - mail_start_idx = 3; + int max; + int mail_start_idx; + int selected_event; + int i; - if (month <= lbRTC_FEBRUARY) { + *present = EMPTY_NO; mail_start_idx = 3; - } - else if (month <= lbRTC_MAY) { - mail_start_idx = 0; - } - else if (month <= lbRTC_AUGUST) { - mail_start_idx = 1; - } - else if (month <= lbRTC_NOVEMBER) { - mail_start_idx = 2; - } - *mail_no = mail_start_no_table[mail_start_idx]; - - selected_event = RANDOM(not_send_num); - max = mPr_MOTHER_MAIL_MONTHLY_NUM; - if (month == lbRTC_AUGUST) { - max = 8; - } - - for (i = 0; i < max; i++) { - if (mPr_CheckMotherMailMonthly(send_data, month, i) == FALSE) { - if (selected_event <= 0) { - *event_no = i; - break; - } - - selected_event--; + if (month <= lbRTC_FEBRUARY) { + mail_start_idx = 3; + } else if (month <= lbRTC_MAY) { + mail_start_idx = 0; + } else if (month <= lbRTC_AUGUST) { + mail_start_idx = 1; + } else if (month <= lbRTC_NOVEMBER) { + mail_start_idx = 2; } - } - *mail_no += *event_no + (month - 1 - mail_start_idx * 3) * 2; + *mail_no = mail_start_no_table[mail_start_idx]; - if (month == lbRTC_MAY && *event_no == 1) { - *present = may_2_item_table[RANDOM(1)]; - } - else if (month == lbRTC_DECEMBER) { - if (*event_no == 0) { - *present = ITM_FOOD_APPLE; + selected_event = RANDOM(not_send_num); + max = mPr_MOTHER_MAIL_MONTHLY_NUM; + if (month == lbRTC_AUGUST) { + max = 8; } - else { - *present = december_2_item_table[RANDOM(6)]; + + for (i = 0; i < max; i++) { + if (mPr_CheckMotherMailMonthly(send_data, month, i) == FALSE) { + if (selected_event <= 0) { + *event_no = i; + break; + } + + selected_event--; + } + } + + *mail_no += *event_no + (month - 1 - mail_start_idx * 3) * 2; + + if (month == lbRTC_MAY && *event_no == 1) { + *present = may_2_item_table[RANDOM(1)]; + } else if (month == lbRTC_DECEMBER) { + if (*event_no == 0) { + *present = ITM_FOOD_APPLE; + } else { + *present = december_2_item_table[RANDOM(6)]; + } + } else if (month == lbRTC_NOVEMBER) { + *present = ITM_FOOD_MUSHROOM; } - } - else if (month == lbRTC_NOVEMBER) { - *present = ITM_FOOD_MUSHROOM; - } } static int mPr_GetMotherMailNormalNotSendNum(mPr_mother_mail_data_c* send_data) { - int not_send_num = 0; - int i; - int j; + int not_send_num = 0; + int i; + int j; - for (i = 0; i < mPr_MOTHER_MAIL_NORMAL_NUM; i++) { - for (j = 0; j < 8; j++) { - if (((send_data->normal[i] >> j) & 1) == 0) { - not_send_num++; - } + for (i = 0; i < mPr_MOTHER_MAIL_NORMAL_NUM; i++) { + for (j = 0; j < 8; j++) { + if (((send_data->normal[i] >> j) & 1) == 0) { + not_send_num++; + } + } } - } - return not_send_num; + return not_send_num; } static void mPr_SetMotherMailNormal(mPr_mother_mail_data_c* send_data, int idx) { - int slot = idx / 8; - idx -= (idx / 8) * 8; - send_data->normal[slot] |= (1 << idx); + int slot = idx / 8; + idx -= (idx / 8) * 8; + send_data->normal[slot] |= (1 << idx); } static int mPr_CheckMotherMailNormal(mPr_mother_mail_data_c* send_data, int idx) { - int slot = idx / 8; - idx -= (idx / 8) * 8; - return (send_data->normal[slot] >> idx) & 1; + int slot = idx / 8; + idx -= (idx / 8) * 8; + return (send_data->normal[slot] >> idx) & 1; } // TODO: we need to make an enum for each player mother mail event id -static void mPr_GetMotherMailNormalData(mPr_mother_mail_data_c* send_data, int* mail_no, mActor_name_t* present, int* event_no, int no_send_num) { - int selected_event; - int i; +static void mPr_GetMotherMailNormalData(mPr_mother_mail_data_c* send_data, int* mail_no, mActor_name_t* present, + int* event_no, int no_send_num) { + int selected_event; + int i; - *event_no = -1; - selected_event = RANDOM(no_send_num); + *event_no = -1; + selected_event = RANDOM(no_send_num); - for (i = 0; i < 56; i++) { - if (mPr_CheckMotherMailNormal(send_data, i) == FALSE) { - if (selected_event <= 0) { - *event_no = i; - break; - } + for (i = 0; i < 56; i++) { + if (mPr_CheckMotherMailNormal(send_data, i) == FALSE) { + if (selected_event <= 0) { + *event_no = i; + break; + } - selected_event--; + selected_event--; + } } - } - *mail_no = 0x12C + *event_no; + *mail_no = 0x12C + *event_no; - switch (*event_no) { - case 1: - case 16: - mSP_SelectRandomItem_New(NULL, present, 1, NULL, 0, mSP_KIND_CLOTH, mSP_LISTTYPE_ABC, FALSE); - break; + switch (*event_no) { + case 1: + case 16: + mSP_SelectRandomItem_New(NULL, present, 1, NULL, 0, mSP_KIND_CLOTH, mSP_LISTTYPE_ABC, FALSE); + break; - case 3: - case 21: - case 22: - case 47: - *present = mFI_GetOtherFruit(); - break; + case 3: + case 21: + case 22: + case 47: + *present = mFI_GetOtherFruit(); + break; - case 12: - *present = ITM_MONEY_1000; - break; + case 12: + *present = ITM_MONEY_1000; + break; - case 37: - *present = FTR_PAPA_BEAR; - break; + case 37: + *present = FTR_PAPA_BEAR; + break; - case 38: - *present = FTR_DRACAENA; - break; + case 38: + *present = FTR_DRACAENA; + break; - case 40: - mSP_RandomUmbSelect(present, 1); - break; + case 40: + mSP_RandomUmbSelect(present, 1); + break; - default: - *present = EMPTY_NO; - break; - } + default: + *present = EMPTY_NO; + break; + } } static void mPr_SendMotherMailNormal(mPr_mother_mail_info_c* mother_mail, lbRTC_time_c* send_time) { - int mail_no = -1; - int monthly_not_send_num = 0; - int event_no; - mActor_name_t present = EMPTY_NO; + int mail_no = -1; + int monthly_not_send_num = 0; + int event_no; + mActor_name_t present = EMPTY_NO; - if (RANDOM(100) < 20) { - int not_send_num = mPr_GetMotherMailNormalNotSendNum(&mother_mail->data); - if (not_send_num == 0) { - bzero(&mother_mail->data, sizeof(mPr_mother_mail_data_c)); - monthly_not_send_num = mPr_GetMotherMailMonthlyNotSendNum(&mother_mail->data, send_time->month); + if (RANDOM(100) < 20) { + int not_send_num = mPr_GetMotherMailNormalNotSendNum(&mother_mail->data); + if (not_send_num == 0) { + bzero(&mother_mail->data, sizeof(mPr_mother_mail_data_c)); + monthly_not_send_num = mPr_GetMotherMailMonthlyNotSendNum(&mother_mail->data, send_time->month); + } + + if (monthly_not_send_num > 0) { + mPr_GetMotherMailMonthlyData(&mother_mail->data, &mail_no, &present, &event_no, send_time->month, + monthly_not_send_num); + + if (mPr_SendMotherMailPost(&Common_Get(now_private)->player_ID, Common_Get(player_no), present, + mPr_GetMotherMailPaperType(send_time->month, send_time->day), mail_no) == TRUE) { + mPr_SetMotherMailMonthly(&mother_mail->data, send_time->month, event_no); + } + } else { + mPr_GetMotherMailNormalData(&mother_mail->data, &mail_no, &present, &event_no, not_send_num); + + if (mPr_SendMotherMailPost(&Common_Get(now_private)->player_ID, Common_Get(player_no), present, + mPr_GetMotherMailPaperType(send_time->month, send_time->day), mail_no) == TRUE) { + mPr_SetMotherMailNormal(&mother_mail->data, event_no); + } + } } - if (monthly_not_send_num > 0) { - mPr_GetMotherMailMonthlyData(&mother_mail->data, &mail_no, &present, &event_no, send_time->month, monthly_not_send_num); - - if (mPr_SendMotherMailPost(&Common_Get(now_private)->player_ID, Common_Get(player_no), present, mPr_GetMotherMailPaperType(send_time->month, send_time->day), mail_no) == TRUE) { - mPr_SetMotherMailMonthly(&mother_mail->data, send_time->month, event_no); - } - } - else { - mPr_GetMotherMailNormalData(&mother_mail->data, &mail_no, &present, &event_no, not_send_num); - - if (mPr_SendMotherMailPost(&Common_Get(now_private)->player_ID, Common_Get(player_no), present, mPr_GetMotherMailPaperType(send_time->month, send_time->day), mail_no) == TRUE) { - mPr_SetMotherMailNormal(&mother_mail->data, event_no); - } - } - } - - mTM_set_renew_time(&mother_mail->date, send_time); + mTM_set_renew_time(&mother_mail->date, send_time); } static void mPr_SendMotherMail(mPr_mother_mail_info_c* mother_mail, lbRTC_time_c* send_time) { - if (mPr_SendMotherMailDate(mother_mail, send_time) == FALSE) { - mPr_SendMotherMailNormal(mother_mail, send_time); - } + if (mPr_SendMotherMailDate(mother_mail, send_time) == FALSE) { + mPr_SendMotherMailNormal(mother_mail, send_time); + } } extern void mPr_SendMailFromMother() { - Private_c* priv = Common_Get(now_private); - u8 player_no = Common_Get(player_no); - lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); - - if (mLd_PlayerManKindCheckNo(player_no) == FALSE && priv != NULL && mPr_NullCheckPersonalID(&priv->player_ID) == FALSE) { - mPr_mother_mail_info_c* mother_mail = Save_GetPointer(mother_mail[player_no]); - lbRTC_ymd_c* mail_date = &mother_mail->date; + Private_c* priv = Common_Get(now_private); + u8 player_no = Common_Get(player_no); + lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); - if (mail_date->year != mTM_rtcTime_ymd_clear_code.year && mail_date->month != mTM_rtcTime_ymd_clear_code.month && mail_date->day != mTM_rtcTime_ymd_clear_code.day) { - if (mail_date->year != rtc_time->year || mail_date->month != rtc_time->month || mail_date->day != rtc_time->day) { - mPr_SendMotherMail(mother_mail, rtc_time); - } + if (mLd_PlayerManKindCheckNo(player_no) == FALSE && priv != NULL && + mPr_NullCheckPersonalID(&priv->player_ID) == FALSE) { + mPr_mother_mail_info_c* mother_mail = Save_GetPointer(mother_mail[player_no]); + lbRTC_ymd_c* mail_date = &mother_mail->date; + + if (mail_date->year != mTM_rtcTime_ymd_clear_code.year && + mail_date->month != mTM_rtcTime_ymd_clear_code.month && mail_date->day != mTM_rtcTime_ymd_clear_code.day) { + if (mail_date->year != rtc_time->year || mail_date->month != rtc_time->month || + mail_date->day != rtc_time->day) { + mPr_SendMotherMail(mother_mail, rtc_time); + } + } else { + mTM_set_renew_time(mail_date, rtc_time); + } } - else { - mTM_set_renew_time(mail_date, rtc_time); - } - } } static void mPr_GetForeingerAnimalMail(Mail_c* mail, Private_c* priv, mPr_animal_memory_c* anm_mem) { - AnmPersonalID_c anm_pid; - int mail_no; - u8 npc_name[ANIMAL_NAME_LEN]; - u8 header[40]; - u8 footer[48]; - int ofs; - u8 looks; - int header_back_start; + AnmPersonalID_c anm_pid; + int mail_no; + u8 npc_name[ANIMAL_NAME_LEN]; + u8 header[40]; + u8 footer[48]; + int ofs; + u8 looks; + int header_back_start; - looks = mNpc_GetLooks(anm_mem->npc_id); - ofs = RANDOM(3); - mail_no = 0xFC; - mail_no += ofs + looks * 3; - mHandbill_Set_free_str(0, priv->player_ID.player_name, PLAYER_NAME_LEN); // player's name - mNpc_LoadNpcNameString(npc_name, anm_mem->npc_id); - mHandbill_Set_free_str(1, npc_name, ANIMAL_NAME_LEN); // animal's name - mHandbill_Set_free_str(2, anm_mem->land_name, LAND_NAME_SIZE); // animal's current town name - mHandbill_Set_free_str(3, priv->player_ID.land_name, LAND_NAME_SIZE); // player's town name - mHandbill_Load_HandbillFromRom2(header, 40, &header_back_start, footer, 48, mail->content.body, mail_no); - mem_copy(mail->content.header, header, mHandbill_HEADER_LEN); - mem_copy(mail->content.footer, footer, mHandbill_FOOTER_LEN); + looks = mNpc_GetLooks(anm_mem->npc_id); + ofs = RANDOM(3); + mail_no = 0xFC; + mail_no += ofs + looks * 3; + mHandbill_Set_free_str(0, priv->player_ID.player_name, PLAYER_NAME_LEN); // player's name + mNpc_LoadNpcNameString(npc_name, anm_mem->npc_id); + mHandbill_Set_free_str(1, npc_name, ANIMAL_NAME_LEN); // animal's name + mHandbill_Set_free_str(2, anm_mem->land_name, LAND_NAME_SIZE); // animal's current town name + mHandbill_Set_free_str(3, priv->player_ID.land_name, LAND_NAME_SIZE); // player's town name + mHandbill_Load_HandbillFromRom2(header, 40, &header_back_start, footer, 48, mail->content.body, mail_no); + mem_copy(mail->content.header, header, mHandbill_HEADER_LEN); + mem_copy(mail->content.footer, footer, mHandbill_FOOTER_LEN); - mail->content.header_back_start = header_back_start; - mail->content.font = 0; - mail->content.mail_type = 0; - mail->present = EMPTY_NO; - mail->content.paper_type = mNpc_GetPaperType(); + mail->content.header_back_start = header_back_start; + mail->content.font = 0; + mail->content.mail_type = 0; + mail->present = EMPTY_NO; + mail->content.paper_type = mNpc_GetPaperType(); - anm_pid.npc_id = anm_mem->npc_id; - anm_pid.land_id = mLd_BITMASK; - mLd_CopyLandName(anm_pid.land_name, anm_mem->land_name); - anm_pid.name_id = anm_mem->npc_id; - anm_pid.looks = looks; + anm_pid.npc_id = anm_mem->npc_id; + anm_pid.land_id = mLd_BITMASK; + mLd_CopyLandName(anm_pid.land_name, anm_mem->land_name); + anm_pid.name_id = anm_mem->npc_id; + anm_pid.looks = looks; - mMl_set_mail_name_npcinfo(&mail->header.sender, &anm_pid); - mPr_CopyPersonalID(&mail->header.recipient.personalID, &priv->player_ID); - mail->header.recipient.type = mMl_NAME_TYPE_PLAYER; + mMl_set_mail_name_npcinfo(&mail->header.sender, &anm_pid); + mPr_CopyPersonalID(&mail->header.recipient.personalID, &priv->player_ID); + mail->header.recipient.type = mMl_NAME_TYPE_PLAYER; } extern void mPr_SendForeingerAnimalMail(Private_c* priv) { - Mail_c* mail = &l_mpr_mail; - mPr_animal_memory_c* anm_mem = &priv->animal_memory; + Mail_c* mail = &l_mpr_mail; + mPr_animal_memory_c* anm_mem = &priv->animal_memory; - if (mLd_PlayerManKindCheck() == FALSE) { - if (anm_mem->npc_id != RSV_NO && ITEM_NAME_GET_TYPE(anm_mem->npc_id) == NAME_TYPE_NPC && mPO_get_keep_mail_sum() < mPO_MAIL_STORAGE_SIZE) { - mMl_clear_mail(mail); - mPr_GetForeingerAnimalMail(mail, priv, anm_mem); - mPO_receipt_proc(mail, mPO_SENDTYPE_MAIL); - mPr_ClearAnimalMemory(anm_mem); + if (mLd_PlayerManKindCheck() == FALSE) { + if (anm_mem->npc_id != RSV_NO && ITEM_NAME_GET_TYPE(anm_mem->npc_id) == NAME_TYPE_NPC && + mPO_get_keep_mail_sum() < mPO_MAIL_STORAGE_SIZE) { + mMl_clear_mail(mail); + mPr_GetForeingerAnimalMail(mail, priv, anm_mem); + mPO_receipt_proc(mail, mPO_SENDTYPE_MAIL); + mPr_ClearAnimalMemory(anm_mem); + } } - } } extern void mPr_StartSetCompleteTalkInfo() { - if (mSM_CHECK_ALL_FISH_GET()) { - Common_Get(now_private)->complete_fish_insect_flags |= (1 << 0); - } + if (mSM_CHECK_ALL_FISH_GET()) { + Common_Get(now_private)->complete_fish_insect_flags |= (1 << 0); + } - if (mSM_CHECK_ALL_INSECT_GET()) { - Common_Get(now_private)->complete_fish_insect_flags |= (1 << 2); - } + if (mSM_CHECK_ALL_INSECT_GET()) { + Common_Get(now_private)->complete_fish_insect_flags |= (1 << 2); + } } static void mPr_SetCompleteTalk(u8* comp_insect_fish_flags, int type) { - *comp_insect_fish_flags |= (1 << (type * 2) + 1); + *comp_insect_fish_flags |= (1 << (type * 2) + 1); } static int mPr_GetCompleteTalk(u8 comp_insect_fish_flags, int type) { - return (comp_insect_fish_flags >> ((type * 2) + 1)) & 1; + return (comp_insect_fish_flags >> ((type * 2) + 1)) & 1; } extern void mPr_SetFishCompleteTalk() { - mPr_SetCompleteTalk(&Common_Get(now_private)->complete_fish_insect_flags, 0); + mPr_SetCompleteTalk(&Common_Get(now_private)->complete_fish_insect_flags, 0); } extern int mPr_CheckFishCompleteTalk(u8 player_no) { - int res = FALSE; + int res = FALSE; - if (player_no < mPr_FOREIGNER && mPr_GetCompleteTalk(Save_Get(private[player_no]).complete_fish_insect_flags, 0) == TRUE) { - res = TRUE; - } + if (player_no < mPr_FOREIGNER && + mPr_GetCompleteTalk(Save_Get(private_data[player_no]).complete_fish_insect_flags, 0) == TRUE) { + res = TRUE; + } - return res; + return res; } extern void mPr_SetInsectCompleteTalk() { - mPr_SetCompleteTalk(&Common_Get(now_private)->complete_fish_insect_flags, 1); + mPr_SetCompleteTalk(&Common_Get(now_private)->complete_fish_insect_flags, 1); } extern int mPr_CheckInsectCompleteTalk(u8 player_no) { - int res = FALSE; + int res = FALSE; - if (player_no < mPr_FOREIGNER && mPr_GetCompleteTalk(Save_Get(private[player_no]).complete_fish_insect_flags, 1) == TRUE) { - res = TRUE; - } + if (player_no < mPr_FOREIGNER && + mPr_GetCompleteTalk(Save_Get(private_data[player_no]).complete_fish_insect_flags, 1) == TRUE) { + res = TRUE; + } - return res; + return res; } static int mPr_GetTalkPermission(u8 comp_insect_fish_flags, int type) { - int base = type * 2; - int talk = base + 1; + int base = type * 2; + int talk = base + 1; - int res = FALSE; - if (((comp_insect_fish_flags >> base) & 1) == 0 || ((comp_insect_fish_flags >> talk) & 1) == 0) { - res = TRUE; - } + int res = FALSE; + if (((comp_insect_fish_flags >> base) & 1) == 0 || ((comp_insect_fish_flags >> talk) & 1) == 0) { + res = TRUE; + } - return res; + return res; } extern int mPr_GetFishCompTalkPermission() { - int res = FALSE; + int res = FALSE; - if (mSM_CHECK_ALL_FISH_GET()) { - res = mPr_GetTalkPermission(Common_Get(now_private)->complete_fish_insect_flags, 0); - } + if (mSM_CHECK_ALL_FISH_GET()) { + res = mPr_GetTalkPermission(Common_Get(now_private)->complete_fish_insect_flags, 0); + } - return res; + return res; } extern int mPr_GetInsectCompTalkPermission() { - int res = FALSE; + int res = FALSE; - if (mSM_CHECK_ALL_INSECT_GET()) { - res = mPr_GetTalkPermission(Common_Get(now_private)->complete_fish_insect_flags, 1); - } + if (mSM_CHECK_ALL_INSECT_GET()) { + res = mPr_GetTalkPermission(Common_Get(now_private)->complete_fish_insect_flags, 1); + } - return res; + return res; } extern void mPr_ClearMapInfo(mPr_map_info_c* map_info, int max) { - for (max; max != 0; max--) { - mLd_ClearLandName(map_info->land_name); - map_info->land_id = 0; - map_info++; - } + for (max; max != 0; max--) { + mLd_ClearLandName(map_info->land_name); + map_info->land_id = 0; + map_info++; + } } static void mPr_CopyMapInfo(mPr_map_info_c* dst, mPr_map_info_c* src) { - mem_copy((u8*)dst, (u8*)src, sizeof(mPr_map_info_c)); + mem_copy((u8*)dst, (u8*)src, sizeof(mPr_map_info_c)); } static void mPr_SetMapThisLand(mPr_map_info_c* map_info) { - if (map_info != NULL) { - mLd_CopyLandName(map_info->land_name, Save_Get(land_info).name); - map_info->land_id = Save_Get(land_info).id; - } + if (map_info != NULL) { + mLd_CopyLandName(map_info->land_name, Save_Get(land_info).name); + map_info->land_id = Save_Get(land_info).id; + } } static int mPr_GetMapFreeIdx(mPr_map_info_c* map_info, int max) { - int res = -1; - int i; - - for (i = 0; i < max; i++) { - if (!mLd_CheckId(map_info->land_id) || mLd_NullCheckLandName(map_info->land_name) == TRUE) { - res = i; - break; - } - - map_info++; - } - - return res; -} - -static int mPr_GetLandMapIdx(mPr_map_info_c* map_info, int max, mLd_land_info_c* land_info) { - int res = -1; - - if (map_info != NULL && land_info != NULL) { + int res = -1; int i; for (i = 0; i < max; i++) { - if (mLd_CheckCmpLand(map_info->land_name, map_info->land_id, land_info->name, land_info->id) == TRUE) { - res = i; - break; - } + if (!mLd_CheckId(map_info->land_id) || mLd_NullCheckLandName(map_info->land_name) == TRUE) { + res = i; + break; + } - map_info++; + map_info++; } - } - return res; + return res; +} + +static int mPr_GetLandMapIdx(mPr_map_info_c* map_info, int max, mLd_land_info_c* land_info) { + int res = -1; + + if (map_info != NULL && land_info != NULL) { + int i; + + for (i = 0; i < max; i++) { + if (mLd_CheckCmpLand(map_info->land_name, map_info->land_id, land_info->name, land_info->id) == TRUE) { + res = i; + break; + } + + map_info++; + } + } + + return res; } extern int mPr_GetThisLandMapIdx(mPr_map_info_c* map_info, int max) { - return mPr_GetLandMapIdx(map_info, max, Save_GetPointer(land_info)); + return mPr_GetLandMapIdx(map_info, max, Save_GetPointer(land_info)); } static void mPr_PushMapInfo(mPr_map_info_c* map_info, int max) { - if (map_info != NULL) { - max--; + if (map_info != NULL) { + max--; - if (max > 0) { - for (max; max > 0; max--) { - mPr_CopyMapInfo(map_info, map_info + 1); - map_info++; - } + if (max > 0) { + for (max; max > 0; max--) { + mPr_CopyMapInfo(map_info, map_info + 1); + map_info++; + } + } + + mPr_ClearMapInfo(map_info, 1); } - - mPr_ClearMapInfo(map_info, 1); - } } extern void mPr_SetNewMap(mPr_map_info_c* map_info, int max) { - if (map_info != NULL && mPr_GetThisLandMapIdx(map_info, max) == -1) { - int free_idx = mPr_GetMapFreeIdx(map_info, max); - if (free_idx != -1) { - map_info += free_idx; - } - else { - mPr_PushMapInfo(map_info, max); - free_idx = max - 1; - map_info += free_idx; - } + if (map_info != NULL && mPr_GetThisLandMapIdx(map_info, max) == -1) { + int free_idx = mPr_GetMapFreeIdx(map_info, max); + if (free_idx != -1) { + map_info += free_idx; + } else { + mPr_PushMapInfo(map_info, max); + free_idx = max - 1; + map_info += free_idx; + } - if (map_info != NULL) { - mPr_SetMapThisLand(map_info); + if (map_info != NULL) { + mPr_SetMapThisLand(map_info); + } } - } } extern void mPr_RenewalMapInfo(mPr_map_info_c* map_info, int max, mLd_land_info_c* land_info) { - mPr_map_info_c map_save; + mPr_map_info_c map_save; - int map_idx = mPr_GetLandMapIdx(map_info, max, land_info); - if (map_idx != -1) { - mPr_CopyMapInfo(&map_save, map_info + map_idx); - mPr_PushMapInfo(map_info + map_idx, max - map_idx); - - map_idx = mPr_GetMapFreeIdx(map_info, max); + int map_idx = mPr_GetLandMapIdx(map_info, max, land_info); if (map_idx != -1) { - mPr_CopyMapInfo(map_info + map_idx, &map_save); + mPr_CopyMapInfo(&map_save, map_info + map_idx); + mPr_PushMapInfo(map_info + map_idx, max - map_idx); + + map_idx = mPr_GetMapFreeIdx(map_info, max); + if (map_idx != -1) { + mPr_CopyMapInfo(map_info + map_idx, &map_save); + } } - } } extern void mPr_RandomSetPlayerData_title_demo() { - Private_c* priv = Common_Get(now_private); - int i; + Private_c* priv = Common_Get(now_private); + int i; - priv->gender = RANDOM(4); // why not RANDOM(2)??? - priv->gender &= 1; - mPlib_change_player_cloth_info_lv2(priv, mPr_GetRandomCloth(priv->gender)); - priv->face = mPr_GetRandomFace(); + priv->gender = RANDOM(4); // why not RANDOM(2)??? + priv->gender &= 1; + mPlib_change_player_cloth_info_lv2(priv, mPr_GetRandomCloth(priv->gender)); + priv->face = mPr_GetRandomFace(); - for (i = 0; i < mHS_HOUSE_NUM; i++) { - Save_Get(homes[i]).door_original = -1; - } + for (i = 0; i < mHS_HOUSE_NUM; i++) { + Save_Get(homes[i]).door_original = -1; + } } extern void mPr_PrintMapInfo_debug(gfxprint_t* gfxprint) { - Private_c* priv = Common_Get(now_private); - mPr_map_info_c* map_info; - int i; + Private_c* priv = Common_Get(now_private); + mPr_map_info_c* map_info; + int i; - if (priv != NULL) { - map_info = priv->maps; - gfxprint_color(gfxprint, 30, 100, 100, 255); - gfxprint_locate8x8(gfxprint, 3, 21); - gfxprint_printf(gfxprint, "%04x ", Save_Get(land_info).id); + if (priv != NULL) { + map_info = priv->maps; + gfxprint_color(gfxprint, 30, 100, 100, 255); + gfxprint_locate8x8(gfxprint, 3, 21); + gfxprint_printf(gfxprint, "%04x ", Save_Get(land_info).id); - gfxprint_locate8x8(gfxprint, 3, 22); - gfxprint_color(gfxprint, 30, 200, 70, 255); + gfxprint_locate8x8(gfxprint, 3, 22); + gfxprint_color(gfxprint, 30, 200, 70, 255); - for (i = 0; i < mPr_FOREIGN_MAP_COUNT; i++) { - if (i == 4) { - gfxprint_locate8x8(gfxprint, 3, 23); - } + for (i = 0; i < mPr_FOREIGN_MAP_COUNT; i++) { + if (i == 4) { + gfxprint_locate8x8(gfxprint, 3, 23); + } - if (mLd_CheckId(map_info->land_id) == TRUE) { - gfxprint_printf(gfxprint, "%04x ", map_info->land_id); - } - else { - gfxprint_printf(gfxprint, "**** "); - } + if (mLd_CheckId(map_info->land_id) == TRUE) { + gfxprint_printf(gfxprint, "%04x ", map_info->land_id); + } else { + gfxprint_printf(gfxprint, "**** "); + } - map_info++; + map_info++; + } } - } } diff --git a/src/m_quest.c b/src/m_quest.c index f7076d73..8c82288f 100644 --- a/src/m_quest.c +++ b/src/m_quest.c @@ -1038,8 +1038,8 @@ extern void mQst_PrintQuestInfo(gfxprint_t* gfxprint) { delivery = priv->deliveries; errand = priv->errands; } else { - delivery = Save_Get(private[0]).deliveries; - errand = Save_Get(private[0]).errands; + delivery = Save_Get(private_data[0]).deliveries; + errand = Save_Get(private_data[0]).errands; } gfxprint_color(gfxprint, 220, 50, 50, 255); diff --git a/src/m_room_type.c b/src/m_room_type.c index 2559faa2..20e5cd8d 100644 --- a/src/m_room_type.c +++ b/src/m_room_type.c @@ -2110,7 +2110,7 @@ extern void mRmTp_CopyWallData(u8* dst, int wall_no) { int room_idx = mRmTp_GetPlayerRoomIdx(); int valid2 = mHS_get_pl_no_detail(room_idx) >= 0 && mHS_get_pl_no_detail(room_idx) < PLAYER_NUM; int player_no = valid2 ? mHS_get_pl_no_detail(room_idx) : 0; - mNW_original_design_c* original = &Save_Get(private[player_no]).my_org[tex_idx & 7]; + mNW_original_design_c* original = &Save_Get(private_data[player_no]).my_org[tex_idx & 7]; mNW_CopyOriginalPalette(dst, original); mNW_CopyOriginalTexture(dst + mNW_PALETTE_SIZE, original); @@ -2137,7 +2137,7 @@ extern void mRmTp_CopyFloorData(u8* dst, int floor_no) { int room_idx = mRmTp_GetPlayerRoomIdx(); int valid2 = mHS_get_pl_no_detail(room_idx) >= 0 && mHS_get_pl_no_detail(room_idx) < PLAYER_NUM; int player_no = valid2 ? mHS_get_pl_no_detail(room_idx) : 0; - mNW_original_design_c* original = &Save_Get(private[player_no]).my_org[tex_idx & 7]; + mNW_original_design_c* original = &Save_Get(private_data[player_no]).my_org[tex_idx & 7]; mNW_CopyOriginalPalette(dst, original); mNW_CopyOriginalTexture(dst + mNW_PALETTE_SIZE, original); diff --git a/src/m_shop.c b/src/m_shop.c index b7b12558..b373110d 100644 --- a/src/m_shop.c +++ b/src/m_shop.c @@ -17,655 +17,582 @@ extern mActor_name_t* mSP_cloth_list[]; extern mActor_name_t* mSP_carpet_list[]; extern mActor_name_t* mSP_wall_list[]; -static mActor_name_t diary_listA[6] = { - ITM_DIARY01, ITM_DIARY04, ITM_DIARY07, ITM_DIARY10, ITM_DIARY13, EMPTY_NO -}; +static mActor_name_t diary_listA[6] = { ITM_DIARY01, ITM_DIARY04, ITM_DIARY07, ITM_DIARY10, ITM_DIARY13, EMPTY_NO }; -static mActor_name_t diary_listB[6] = { - ITM_DIARY02, ITM_DIARY05, ITM_DIARY08, ITM_DIARY11, ITM_DIARY14, EMPTY_NO -}; +static mActor_name_t diary_listB[6] = { ITM_DIARY02, ITM_DIARY05, ITM_DIARY08, ITM_DIARY11, ITM_DIARY14, EMPTY_NO }; -static mActor_name_t diary_listC[7] = { - ITM_DIARY03, ITM_DIARY06, ITM_DIARY09, ITM_DIARY12, ITM_DIARY15, ITM_DIARY00, EMPTY_NO -}; +static mActor_name_t diary_listC[7] = { ITM_DIARY03, ITM_DIARY06, ITM_DIARY09, ITM_DIARY12, + ITM_DIARY15, ITM_DIARY00, EMPTY_NO }; -static mActor_name_t* mSP_diary_list[mSP_LIST_NUM] = { - diary_listA, - diary_listB, - diary_listC, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL -}; +static mActor_name_t* mSP_diary_list[mSP_LIST_NUM] = { diary_listA, diary_listB, diary_listC, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL }; -static mActor_name_t** mSP_goods_seg_inf[mSP_KIND_EXTENDED_MAX] = { - mSP_ftr_list, - mSP_binsen_list, - mSP_cloth_list, - mSP_carpet_list, - mSP_wall_list, - mSP_diary_list -}; +static mActor_name_t** mSP_goods_seg_inf[mSP_KIND_EXTENDED_MAX] = { mSP_ftr_list, mSP_binsen_list, mSP_cloth_list, + mSP_carpet_list, mSP_wall_list, mSP_diary_list }; static void mSP_InitItemTable(mActor_name_t* item_table, int count) { - int i; + int i; - if (item_table == NULL) { - return; - } + if (item_table == NULL) { + return; + } - for (i = 0; i < count; i++) { - *item_table++ = EMPTY_NO; - } + for (i = 0; i < count; i++) { + *item_table++ = EMPTY_NO; + } } static mActor_name_t* mSP_SelectListFromPriority(mActor_name_t** lists, u8* priorities, int list_type) { - mActor_name_t* list = NULL; + mActor_name_t* list = NULL; - switch (list_type) { - case mSP_LISTTYPE_EVENT: - list = lists[mSP_LIST_EVENT]; - break; - case mSP_LISTTYPE_TRAIN: - list = lists[mSP_LIST_TRAIN]; - break; - case mSP_LISTTYPE_LOTTERY: - list = lists[mSP_LIST_LOTTERY]; - break; - case mSP_LISTTYPE_HALLOWEEN: - list = lists[mSP_LIST_HALLOWEEN]; - break; - case mSP_LISTTYPE_HALLOWEEN2: - list = lists[mSP_LIST_HALLOWEEN2]; - break; - case mSP_LISTTYPE_PRESENT: - list = lists[mSP_LIST_PRESENT]; - break; - case mSP_LISTTYPE_CHRISTMAS: - list = lists[mSP_LIST_CHRISTMAS]; - break; - case mSP_LISTTYPE_SNOW: - list = lists[mSP_LIST_SNOW]; - break; - case mSP_LISTTYPE_JONASON: - list = lists[mSP_LIST_JONASON]; - break; - case mSP_LISTTYPE_POSTOFFICE: - list = lists[mSP_LIST_POSTOFFICE]; - break; - case mSP_LISTTYPE_NINTENDO64: - list = lists[mSP_LIST_NINTENDO64]; - break; - case mSP_LISTTYPE_SPECIALPRESENT: - list = lists[mSP_LIST_SPECIALPRESENT]; - break; - case mSP_LISTTYPE_ISLAND: - list = lists[mSP_LIST_ISLAND]; - break; - case mSP_LISTTYPE_ISLANDFAMICOM: - list = lists[mSP_LIST_ISLANDFAMICOM]; - break; - case mSP_LISTTYPE_HOMEPAGE: - list = lists[mSP_LIST_HOMEPAGE]; - break; - case mSP_LISTTYPE_EVENTPRESENTCHUMON: - list = lists[mSP_LIST_EVENTPRESENTCHUMON]; - break; - case mSP_LISTTYPE_KAMAKURA: - list = lists[mSP_LIST_KAMAKURA]; - break; - case mSP_LISTTYPE_HARVEST: - list = lists[mSP_LIST_HARVEST]; - break; - case mSP_LISTTYPE_MARIO: - list = lists[mSP_LIST_MARIO]; - break; - case mSP_LISTTYPE_TENT: - list = lists[mSP_LIST_TENT]; - break; + switch (list_type) { + case mSP_LISTTYPE_EVENT: + list = lists[mSP_LIST_EVENT]; + break; + case mSP_LISTTYPE_TRAIN: + list = lists[mSP_LIST_TRAIN]; + break; + case mSP_LISTTYPE_LOTTERY: + list = lists[mSP_LIST_LOTTERY]; + break; + case mSP_LISTTYPE_HALLOWEEN: + list = lists[mSP_LIST_HALLOWEEN]; + break; + case mSP_LISTTYPE_HALLOWEEN2: + list = lists[mSP_LIST_HALLOWEEN2]; + break; + case mSP_LISTTYPE_PRESENT: + list = lists[mSP_LIST_PRESENT]; + break; + case mSP_LISTTYPE_CHRISTMAS: + list = lists[mSP_LIST_CHRISTMAS]; + break; + case mSP_LISTTYPE_SNOW: + list = lists[mSP_LIST_SNOW]; + break; + case mSP_LISTTYPE_JONASON: + list = lists[mSP_LIST_JONASON]; + break; + case mSP_LISTTYPE_POSTOFFICE: + list = lists[mSP_LIST_POSTOFFICE]; + break; + case mSP_LISTTYPE_NINTENDO64: + list = lists[mSP_LIST_NINTENDO64]; + break; + case mSP_LISTTYPE_SPECIALPRESENT: + list = lists[mSP_LIST_SPECIALPRESENT]; + break; + case mSP_LISTTYPE_ISLAND: + list = lists[mSP_LIST_ISLAND]; + break; + case mSP_LISTTYPE_ISLANDFAMICOM: + list = lists[mSP_LIST_ISLANDFAMICOM]; + break; + case mSP_LISTTYPE_HOMEPAGE: + list = lists[mSP_LIST_HOMEPAGE]; + break; + case mSP_LISTTYPE_EVENTPRESENTCHUMON: + list = lists[mSP_LIST_EVENTPRESENTCHUMON]; + break; + case mSP_LISTTYPE_KAMAKURA: + list = lists[mSP_LIST_KAMAKURA]; + break; + case mSP_LISTTYPE_HARVEST: + list = lists[mSP_LIST_HARVEST]; + break; + case mSP_LISTTYPE_MARIO: + list = lists[mSP_LIST_MARIO]; + break; + case mSP_LISTTYPE_TENT: + list = lists[mSP_LIST_TENT]; + break; - case mSP_LISTTYPE_ABC: - default: - { - int i; + case mSP_LISTTYPE_ABC: + default: { + int i; - for (i = 0; i < 3; i++, priorities++) { - if (list_type == priorities[0]) { - switch (i) { - case mSP_LISTTYPE_COMMON: - list = lists[mSP_LIST_A]; - break; - case mSP_LISTTYPE_UNCOMMON: - list = lists[mSP_LIST_B]; - break; - case mSP_LISTTYPE_RARE: - list = lists[mSP_LIST_C]; - break; - } + for (i = 0; i < 3; i++, priorities++) { + if (list_type == priorities[0]) { + switch (i) { + case mSP_LISTTYPE_COMMON: + list = lists[mSP_LIST_A]; + break; + case mSP_LISTTYPE_UNCOMMON: + list = lists[mSP_LIST_B]; + break; + case mSP_LISTTYPE_RARE: + list = lists[mSP_LIST_C]; + break; + } + } + } + break; } - } - break; } - } - if (list == NULL) { - list = lists[mSP_LIST_A]; - } + if (list == NULL) { + list = lists[mSP_LIST_A]; + } - return list; + return list; } -static void mSP_SetSeasonFTR_local_december(mActor_name_t* item_table, int count, mActor_name_t ftr0, mActor_name_t ftr1) { - if (count > 1) { - item_table[0] = ftr0; - item_table[1] = ftr1; - } - else if (fqrand() < 0.5f) { - item_table[0] = ftr0; - } - else { - item_table[0] = ftr1; - } +static void mSP_SetSeasonFTR_local_december(mActor_name_t* item_table, int count, mActor_name_t ftr0, + mActor_name_t ftr1) { + if (count > 1) { + item_table[0] = ftr0; + item_table[1] = ftr1; + } else if (fqrand() < 0.5f) { + item_table[0] = ftr0; + } else { + item_table[0] = ftr1; + } } static void mSP_SetSeasonFTR(mActor_name_t* item_table, int count) { - lbRTC_time_c rtc_time = Common_Get(time.rtc_time); - lbRTC_month_t month = rtc_time.month; - lbRTC_day_t day = rtc_time.day; + lbRTC_time_c rtc_time = Common_Get(time.rtc_time); + lbRTC_month_t month = rtc_time.month; + lbRTC_day_t day = rtc_time.day; - if (count > 0 && month == lbRTC_DECEMBER) { - - if (day <= 24) { - mSP_SetSeasonFTR_local_december(item_table, count, FTR_FESTIVE_TREE, FTR_BIG_FESTIVE_TREE); + if (count > 0 && month == lbRTC_DECEMBER) { + + if (day <= 24) { + mSP_SetSeasonFTR_local_december(item_table, count, FTR_FESTIVE_TREE, FTR_BIG_FESTIVE_TREE); + } else if (day >= 26) { + mSP_SetSeasonFTR_local_december(item_table, count, FTR_FESTIVE_CANDLE, FTR_FESTIVE_FLAG); + } } - else if (day >= 26) { - mSP_SetSeasonFTR_local_december(item_table, count, FTR_FESTIVE_CANDLE, FTR_FESTIVE_FLAG); - } - } } static mActor_name_t* mSP_GetItemList(mActor_name_t** lists, u8* priorities, int list_type) { - if (list_type == mSP_LISTTYPE_ABC) { - int abc_roll = RANDOM(100); - int goods_power = mPr_GetGoodsPower(); - int rare_chance; - int uncommon_chance; + if (list_type == mSP_LISTTYPE_ABC) { + int abc_roll = RANDOM(100); + int goods_power = mPr_GetGoodsPower(); + int rare_chance; + int uncommon_chance; - if (goods_power < 0) { - uncommon_chance = goods_power + 40; /* [10%, 39%] */ - rare_chance = 5; /* always 5% chance */ - /* common_chance = [85%, 66%] */ - } - else { - rare_chance = goods_power + 5; /* [5%, 55%] */ - uncommon_chance = rare_chance + 35; /* always 35% chance */ - /* common_chance = [60%, 10%]*/ - } + if (goods_power < 0) { + uncommon_chance = goods_power + 40; /* [10%, 39%] */ + rare_chance = 5; /* always 5% chance */ + /* common_chance = [85%, 66%] */ + } else { + rare_chance = goods_power + 5; /* [5%, 55%] */ + uncommon_chance = rare_chance + 35; /* always 35% chance */ + /* common_chance = [60%, 10%]*/ + } - if (abc_roll < rare_chance) { - return mSP_SelectListFromPriority(lists, priorities, mSP_LISTTYPE_RARE); + if (abc_roll < rare_chance) { + return mSP_SelectListFromPriority(lists, priorities, mSP_LISTTYPE_RARE); + } else if (abc_roll < uncommon_chance) { + return mSP_SelectListFromPriority(lists, priorities, mSP_LISTTYPE_UNCOMMON); + } else { + return mSP_SelectListFromPriority(lists, priorities, mSP_LISTTYPE_COMMON); + } + } else { + return mSP_SelectListFromPriority(lists, priorities, list_type); } - else if (abc_roll < uncommon_chance) { - return mSP_SelectListFromPriority(lists, priorities, mSP_LISTTYPE_UNCOMMON); - } - else { - return mSP_SelectListFromPriority(lists, priorities, mSP_LISTTYPE_COMMON); - } - } - else { - return mSP_SelectListFromPriority(lists, priorities, list_type); - } } static int mSP_GoodsExistAlready(mActor_name_t* goods_table, int count, mActor_name_t item) { - int i; + int i; - if (goods_table != NULL) { - for (i = 0; i < count; i++) { - if (goods_table[i] == item) { - return TRUE; - } + if (goods_table != NULL) { + for (i = 0; i < count; i++) { + if (goods_table[i] == item) { + return TRUE; + } + } } - } - return FALSE; + return FALSE; } extern int mSP_CollectCheck(mActor_name_t item) { - mActor_name_t ftr_item = mRmTp_Item1ItemNo2FtrItemNo_AtPlayerRoom(item, FALSE); - u32* bitfield; - int idx; + mActor_name_t ftr_item = mRmTp_Item1ItemNo2FtrItemNo_AtPlayerRoom(item, FALSE); + u32* bitfield; + int idx; - bitfield = NULL; + bitfield = NULL; - switch (ITEM_NAME_GET_TYPE(ftr_item)) { - case NAME_TYPE_FTR0: - case NAME_TYPE_FTR1: - { - bitfield = Common_Get(now_private)->furniture_collected_bitfield; - idx = mRmTp_FtrItemNo2FtrIdx(ftr_item); - break; + switch (ITEM_NAME_GET_TYPE(ftr_item)) { + case NAME_TYPE_FTR0: + case NAME_TYPE_FTR1: { + bitfield = Common_Get(now_private)->furniture_collected_bitfield; + idx = mRmTp_FtrItemNo2FtrIdx(ftr_item); + break; + } + + case NAME_TYPE_ITEM1: { + switch (ITEM_NAME_GET_CAT(ftr_item)) { + case ITEM1_CAT_PAPER: { + bitfield = Common_Get(now_private)->paper_collected_bitfield; + idx = (ftr_item - ITM_PAPER_START) % PAPER_UNIQUE_NUM; + break; + } + + case ITEM1_CAT_WALL: { + bitfield = Common_Get(now_private)->wall_collected_bitfield; + idx = ftr_item - ITM_WALL_START; + break; + } + + case ITEM1_CAT_CARPET: { + bitfield = Common_Get(now_private)->carpet_collected_bitfield; + idx = ftr_item - ITM_CARPET_START; + break; + } + + case ITEM1_CAT_MINIDISK: { + bitfield = Common_Get(now_private)->music_collected_bitfield; + idx = (mActor_name_t)(ftr_item - ITM_MINIDISK_START); + break; + } + } + + break; + } } - case NAME_TYPE_ITEM1: - { - switch (ITEM_NAME_GET_CAT(ftr_item)) { - case ITEM1_CAT_PAPER: - { - bitfield = Common_Get(now_private)->paper_collected_bitfield; - idx = (ftr_item - ITM_PAPER_START) % PAPER_UNIQUE_NUM; - break; - } - - case ITEM1_CAT_WALL: - { - bitfield = Common_Get(now_private)->wall_collected_bitfield; - idx = ftr_item - ITM_WALL_START; - break; - } - - case ITEM1_CAT_CARPET: - { - bitfield = Common_Get(now_private)->carpet_collected_bitfield; - idx = ftr_item - ITM_CARPET_START; - break; - } - - case ITEM1_CAT_MINIDISK: - { - bitfield = Common_Get(now_private)->music_collected_bitfield; - idx = (mActor_name_t)(ftr_item - ITM_MINIDISK_START); - break; - } - } - - break; + if (bitfield == NULL) { + return FALSE; } - } - if (bitfield == NULL) { - return FALSE; - } - - return ((1 << (idx & 0x1F)) & bitfield[idx >> 5]) != 0; + return ((1 << (idx & 0x1F)) & bitfield[idx >> 5]) != 0; } static int mSP_CountElementInCommonList(mActor_name_t* list) { - int count = 0; + int count = 0; - for (list; list[0] != EMPTY_NO; list++, count++) { } + for (list; list[0] != EMPTY_NO; list++, count++) {} - return count; + return count; } static int mSP_CountElementInCommonList_collect(mActor_name_t* list, int* selected_idx, int uncollected_only) { - int count = 0; - int selected; - mActor_name_t* list_p; + int count = 0; + int selected; + mActor_name_t* list_p; - if (uncollected_only == FALSE) { - count = mSP_CountElementInCommonList(list); - selected_idx[0] = RANDOM(count); - - return count; - } + if (uncollected_only == FALSE) { + count = mSP_CountElementInCommonList(list); + selected_idx[0] = RANDOM(count); - /* Count all uncollected items in the list */ - for (list_p = list; list_p[0] != EMPTY_NO; list_p++) { - if (mSP_CollectCheck(list_p[0]) == FALSE) { - count++; + return count; } - } - if (count == 0) { + /* Count all uncollected items in the list */ + for (list_p = list; list_p[0] != EMPTY_NO; list_p++) { + if (mSP_CollectCheck(list_p[0]) == FALSE) { + count++; + } + } + + if (count == 0) { + selected_idx[0] = 0; + return 0; + } + + selected = RANDOM(count); selected_idx[0] = 0; - return 0; - } - - selected = RANDOM(count); - selected_idx[0] = 0; - for (list_p = list; list_p[0] != EMPTY_NO && selected > 0; list_p++) { - if (mSP_CollectCheck(list_p[0]) == FALSE) { - selected--; + for (list_p = list; list_p[0] != EMPTY_NO && selected > 0; list_p++) { + if (mSP_CollectCheck(list_p[0]) == FALSE) { + selected--; + } + + selected_idx[0]++; } - selected_idx[0]++; - } - - return count; + return count; } static int mSP_get_cloth_season() { - lbRTC_time_c rtc_time = Common_Get(time.rtc_time); - lbRTC_month_t month = rtc_time.month; - int res; + lbRTC_time_c rtc_time = Common_Get(time.rtc_time); + lbRTC_month_t month = rtc_time.month; + int res; - switch (month) { - case lbRTC_JANUARY: - res = mSP_CLOTH_SEASON_WINTER; - break; + switch (month) { + case lbRTC_JANUARY: + res = mSP_CLOTH_SEASON_WINTER; + break; - case lbRTC_FEBRUARY: - { - if (rtc_time.day > 24) { - res = mSP_CLOTH_SEASON_SPRING; - } - else { - res = mSP_CLOTH_SEASON_WINTER; - } + case lbRTC_FEBRUARY: { + if (rtc_time.day > 24) { + res = mSP_CLOTH_SEASON_SPRING; + } else { + res = mSP_CLOTH_SEASON_WINTER; + } - break; + break; + } + + case lbRTC_MARCH: + case lbRTC_APRIL: + res = mSP_CLOTH_SEASON_SPRING; + break; + + case lbRTC_MAY: { + if (rtc_time.day > 26) { + res = mSP_CLOTH_SEASON_SUMMER; + } else { + res = mSP_CLOTH_SEASON_SPRING; + } + + break; + } + + case lbRTC_JUNE: + case lbRTC_JULY: + res = mSP_CLOTH_SEASON_SUMMER; + break; + + case lbRTC_AUGUST: { + if (rtc_time.day > 26) { + res = mSP_CLOTH_SEASON_AUTUMN; + } else { + res = mSP_CLOTH_SEASON_SUMMER; + } + + break; + } + + case lbRTC_SEPTEMBER: + case lbRTC_OCTOBER: + res = mSP_CLOTH_SEASON_AUTUMN; + break; + + case lbRTC_NOVEMBER: { + if (rtc_time.day > 26) { + res = mSP_CLOTH_SEASON_WINTER; + } else { + res = mSP_CLOTH_SEASON_AUTUMN; + } + + break; + } + + case lbRTC_DECEMBER: + res = mSP_CLOTH_SEASON_WINTER; + break; } - case lbRTC_MARCH: - case lbRTC_APRIL: - res = mSP_CLOTH_SEASON_SPRING; - break; - - case lbRTC_MAY: - { - if (rtc_time.day > 26) { - res = mSP_CLOTH_SEASON_SUMMER; - } - else { - res = mSP_CLOTH_SEASON_SPRING; - } - - break; - } - - case lbRTC_JUNE: - case lbRTC_JULY: - res = mSP_CLOTH_SEASON_SUMMER; - break; - - case lbRTC_AUGUST: - { - if (rtc_time.day > 26) { - res = mSP_CLOTH_SEASON_AUTUMN; - } - else { - res = mSP_CLOTH_SEASON_SUMMER; - } - - break; - } - - case lbRTC_SEPTEMBER: - case lbRTC_OCTOBER: - res = mSP_CLOTH_SEASON_AUTUMN; - break; - - case lbRTC_NOVEMBER: - { - if (rtc_time.day > 26) { - res = mSP_CLOTH_SEASON_WINTER; - } - else { - res = mSP_CLOTH_SEASON_AUTUMN; - } - - break; - } - - case lbRTC_DECEMBER: - res = mSP_CLOTH_SEASON_WINTER; - break; - } - - return res; + return res; } extern u8 cloth_season_cnt[]; static int mSP_CountElementInClothList(int* selected) { - u8* count_p = cloth_season_cnt; - int cloth_season = mSP_get_cloth_season(); - int cloth_count = count_p[mSP_CLOTH_SEASON_ANY] + count_p[cloth_season]; - - selected[0] = RANDOM(cloth_count); // random cloth selected - - if (selected[0] >= cloth_season_cnt[mSP_CLOTH_SEASON_ANY]) { - int i; + u8* count_p = cloth_season_cnt; + int cloth_season = mSP_get_cloth_season(); + int cloth_count = count_p[mSP_CLOTH_SEASON_ANY] + count_p[cloth_season]; - /* seasonal cloths are sequential in the item lists, so add previous season counts to the selected index */ - for (i = mSP_CLOTH_SEASON_SPRING; i < cloth_season; i++) { - selected[0] += count_p[i]; + selected[0] = RANDOM(cloth_count); // random cloth selected + + if (selected[0] >= cloth_season_cnt[mSP_CLOTH_SEASON_ANY]) { + int i; + + /* seasonal cloths are sequential in the item lists, so add previous season counts to the selected index */ + for (i = mSP_CLOTH_SEASON_SPRING; i < cloth_season; i++) { + selected[0] += count_p[i]; + } } - } - return cloth_count; + return cloth_count; } static int mSP_CountElementInClothList_collect(mActor_name_t* list, int* selected, int uncollected_only) { - u8* count_p = cloth_season_cnt; + u8* count_p = cloth_season_cnt; - if (uncollected_only == FALSE) { - return mSP_CountElementInClothList(selected); - } - else { - int cloth_season; - int count; - mActor_name_t* list_p; - mActor_name_t* list_p2; - int uncollected_num; - int n; - int s; - int i; - cloth_season = mSP_get_cloth_season(); - uncollected_num = 0; - count = 0; + if (uncollected_only == FALSE) { + return mSP_CountElementInClothList(selected); + } else { + int cloth_season; + int count; + mActor_name_t* list_p; + mActor_name_t* list_p2; + int uncollected_num; + int n; + int s; + int i; + cloth_season = mSP_get_cloth_season(); + uncollected_num = 0; + count = 0; - for (list_p = list; count < count_p[mSP_CLOTH_SEASON_ANY] && list_p != NULL; list_p++) { - if (mSP_CollectCheck(list_p[0]) == FALSE) { - uncollected_num++; - } + for (list_p = list; count < count_p[mSP_CLOTH_SEASON_ANY] && list_p != NULL; list_p++) { + if (mSP_CollectCheck(list_p[0]) == FALSE) { + uncollected_num++; + } - count++; - } - - n = count_p[mSP_CLOTH_SEASON_ANY]; - for (i = mSP_CLOTH_SEASON_SPRING; i < cloth_season; i++) { - n += count_p[i]; // add intermediate season counts - } - - i = n; - s = n + count_p[cloth_season]; - list_p2 = list + (int)n; - for (list_p = list_p2; i < s && list_p != NULL; list_p++) { - if (mSP_CollectCheck(list_p[0]) == FALSE) { - uncollected_num++; - } - - i++; - } - - if (uncollected_num == 0) { - selected[0] = 0; - return 0; - } - else { - int selected_idx = RANDOM(uncollected_num); - - count = 0; - selected[0] = 0; - for (list; count < count_p[mSP_CLOTH_SEASON_ANY] && list != NULL && selected_idx > 0; list++) { - if (mSP_CollectCheck(list[0]) == FALSE) { - selected_idx--; + count++; } - selected[0]++; - count++; - } - - i = n; - for (list_p2; i < s && list_p2 != NULL && selected_idx > 0; list_p2++) { - if (mSP_CollectCheck(list_p2[0]) == FALSE) { - selected_idx--; + n = count_p[mSP_CLOTH_SEASON_ANY]; + for (i = mSP_CLOTH_SEASON_SPRING; i < cloth_season; i++) { + n += count_p[i]; // add intermediate season counts } - selected[0]++; - i++; - } - } + i = n; + s = n + count_p[cloth_season]; + list_p2 = list + (int)n; + for (list_p = list_p2; i < s && list_p != NULL; list_p++) { + if (mSP_CollectCheck(list_p[0]) == FALSE) { + uncollected_num++; + } - return uncollected_num; - } + i++; + } + + if (uncollected_num == 0) { + selected[0] = 0; + return 0; + } else { + int selected_idx = RANDOM(uncollected_num); + + count = 0; + selected[0] = 0; + for (list; count < count_p[mSP_CLOTH_SEASON_ANY] && list != NULL && selected_idx > 0; list++) { + if (mSP_CollectCheck(list[0]) == FALSE) { + selected_idx--; + } + + selected[0]++; + count++; + } + + i = n; + for (list_p2; i < s && list_p2 != NULL && selected_idx > 0; list_p2++) { + if (mSP_CollectCheck(list_p2[0]) == FALSE) { + selected_idx--; + } + + selected[0]++; + i++; + } + } + + return uncollected_num; + } } static int mSP_NoList(mActor_name_t* items_table, int count, mActor_name_t* list) { - if (list == NULL) { - int i; + if (list == NULL) { + int i; - for (i = 0; i < count; i++) { - items_table[0] = EMPTY_NO; - items_table++; + for (i = 0; i < count; i++) { + items_table[0] = EMPTY_NO; + items_table++; + } + + return TRUE; } - return TRUE; - } - - return FALSE; + return FALSE; } static void mSP_SetDummyItem(mActor_name_t* items_table, int count, int kind) { - mActor_name_t dummy_table[mSP_KIND_EXTENDED_MAX] = { - FTR_CLASSIC_WARDROBE, - ITM_PAPER00, - ITM_CLOTH000, - ITM_CARPET00, - ITM_WALL00, - ITM_DIARY00 - }; + mActor_name_t dummy_table[mSP_KIND_EXTENDED_MAX] = { FTR_CLASSIC_WARDROBE, ITM_PAPER00, ITM_CLOTH000, + ITM_CARPET00, ITM_WALL00, ITM_DIARY00 }; - mActor_name_t dummy_item = dummy_table[kind]; - int i; + mActor_name_t dummy_item = dummy_table[kind]; + int i; - for (i = 0; i < count; i++) { - items_table[i] = dummy_item; - } + for (i = 0; i < count; i++) { + items_table[i] = dummy_item; + } } -extern void mSP_SelectRandomItem_New( - GAME* game, - mActor_name_t* goods_table, - int goods_count, - mActor_name_t* goods_exist_table, - int goods_exist_count, - int category, - int list_type, - int uncollected_only -) { - mSP_InitItemTable(goods_table, goods_count); +extern void mSP_SelectRandomItem_New(GAME* game, mActor_name_t* goods_table, int goods_count, + mActor_name_t* goods_exist_table, int goods_exist_count, int category, + int list_type, int uncollected_only) { + mSP_InitItemTable(goods_table, goods_count); - if (goods_count != 0 && goods_table != NULL) { - if (goods_table != NULL) { - u8 abc_priorities[3]; - mActor_name_t** goods_seg_p = mSP_goods_seg_inf[category]; - int i = 0; + if (goods_count != 0 && goods_table != NULL) { + if (goods_table != NULL) { + u8 abc_priorities[3]; + mActor_name_t** goods_seg_p = mSP_goods_seg_inf[category]; + int i = 0; - mSP_GetGoodsPriority(abc_priorities, category); + mSP_GetGoodsPriority(abc_priorities, category); - while (i < goods_count) { - mActor_name_t* item_list_p = mSP_GetItemList(goods_seg_p, abc_priorities, list_type); - int list_item_count; - int selected_idx; + while (i < goods_count) { + mActor_name_t* item_list_p = mSP_GetItemList(goods_seg_p, abc_priorities, list_type); + int list_item_count; + int selected_idx; - if (mSP_NoList(goods_table, goods_count, item_list_p) != FALSE) { - mSP_SetDummyItem(goods_table, goods_count, category); - return; + if (mSP_NoList(goods_table, goods_count, item_list_p) != FALSE) { + mSP_SetDummyItem(goods_table, goods_count, category); + return; + } + + if (category == mSP_KIND_CLOTH && (list_type == mSP_LISTTYPE_ABC || list_type == mSP_LIST_A || + list_type == mSP_LIST_B || list_type == mSP_LIST_C)) { + list_item_count = mSP_CountElementInClothList_collect(item_list_p, &selected_idx, uncollected_only); + } else { + list_item_count = + mSP_CountElementInCommonList_collect(item_list_p, &selected_idx, uncollected_only); + } + + if (list_item_count == 0) { + mSP_InitItemTable(goods_table, goods_count); + return; + } + + if (mSP_GoodsExistAlready(goods_table, goods_count, item_list_p[selected_idx]) == FALSE && + mSP_GoodsExistAlready(goods_exist_table, goods_exist_count, item_list_p[selected_idx]) == FALSE && + Save_Get(shop).rare_item != item_list_p[selected_idx]) { + goods_table[i] = item_list_p[selected_idx]; + i++; + } else if (list_item_count < goods_count + goods_exist_count) { + /* forcibly add duplicate items if the list size is less than total possible goods */ + goods_table[i] = item_list_p[selected_idx]; + i++; + } + } + } else { + mSP_SetDummyItem(goods_table, goods_count, category); // ????? } - - if ( - category == mSP_KIND_CLOTH && - (list_type == mSP_LISTTYPE_ABC || list_type == mSP_LIST_A || list_type == mSP_LIST_B || list_type == mSP_LIST_C) - ) { - list_item_count = mSP_CountElementInClothList_collect(item_list_p, &selected_idx, uncollected_only); - } - else { - list_item_count = mSP_CountElementInCommonList_collect(item_list_p, &selected_idx, uncollected_only); - } - - if (list_item_count == 0) { - mSP_InitItemTable(goods_table, goods_count); - return; - } - - if ( - mSP_GoodsExistAlready(goods_table, goods_count, item_list_p[selected_idx]) == FALSE && - mSP_GoodsExistAlready(goods_exist_table, goods_exist_count, item_list_p[selected_idx]) == FALSE && - Save_Get(shop).rare_item != item_list_p[selected_idx] - ) { - goods_table[i] = item_list_p[selected_idx]; - i++; - } - else if (list_item_count < goods_count + goods_exist_count) { - /* forcibly add duplicate items if the list size is less than total possible goods */ - goods_table[i] = item_list_p[selected_idx]; - i++; - } - } } - else { - mSP_SetDummyItem(goods_table, goods_count, category); // ????? - } - } } static int mSP_CountPriceTableElement(u16* price_table) { - int n = 0; + int n = 0; - while (price_table[0] != 0xFFFF) { - price_table++; - n++; - } + while (price_table[0] != 0xFFFF) { + price_table++; + n++; + } - return n; + return n; } -extern int mSP_ShopSaleReport(mActor_name_t sold_item, mActor_name_t* goods_table, int goods_count, mActor_name_t rsv_item) { - int i; +extern int mSP_ShopSaleReport(mActor_name_t sold_item, mActor_name_t* goods_table, int goods_count, + mActor_name_t rsv_item) { + int i; - if (sold_item == ITM_HUKUBUKURO_BAG) { - Save_Get(shop).flowers_candy_grab_bag_count--; - return FALSE; - } - - if (sold_item == ITM_FOOD_CANDY) { - Save_Get(shop).flowers_candy_grab_bag_count--; - return FALSE; - } - - for (i = 0; i < goods_count; i++) { - if (sold_item == goods_table[i]) { - goods_table[i] = rsv_item; - return FALSE; + if (sold_item == ITM_HUKUBUKURO_BAG) { + Save_Get(shop).flowers_candy_grab_bag_count--; + return FALSE; + } + + if (sold_item == ITM_FOOD_CANDY) { + Save_Get(shop).flowers_candy_grab_bag_count--; + return FALSE; + } + + for (i = 0; i < goods_count; i++) { + if (sold_item == goods_table[i]) { + goods_table[i] = rsv_item; + return FALSE; + } + } + + if (sold_item == Save_Get(shop).rare_item) { + Save_Get(shop).rare_item = rsv_item; + return FALSE; } - } - if (sold_item == Save_Get(shop).rare_item) { - Save_Get(shop).rare_item = rsv_item; return FALSE; - } - - return FALSE; } extern u16 binsen_price_table[]; @@ -692,582 +619,507 @@ static u16* l_md_price_info = md_price_table; static u16* l_diary_price_info = diary_price_table; static u16* l_insect_price_info = insect_price_table; -static u16** l_price_info[ITEM1_CAT_NUM] = { - &l_binsen_price_info, - NULL, - &l_tool_price_info, - &l_fish_price_info, - &l_cloth_price_info, - NULL, - &l_carpet_price_info, - &l_wall_price_info, - &l_food_price_info, - &l_plant_price_info, - &l_md_price_info, - &l_diary_price_info, - NULL, - &l_insect_price_info, - NULL, - NULL -}; +static u16** l_price_info[ITEM1_CAT_NUM] = { &l_binsen_price_info, + NULL, + &l_tool_price_info, + &l_fish_price_info, + &l_cloth_price_info, + NULL, + &l_carpet_price_info, + &l_wall_price_info, + &l_food_price_info, + &l_plant_price_info, + &l_md_price_info, + &l_diary_price_info, + NULL, + &l_insect_price_info, + NULL, + NULL }; static mActor_name_t mSP_item1_start_idx_table[ITEM1_CAT_NUM] = { - ITM_PAPER_START, - ITM_MONEY_START, - ITM_TOOL_START, - ITM_FISH_START, - ITM_CLOTH_START, - ITM_ETC_START, - ITM_CARPET_START, - ITM_WALL_START, - ITM_FOOD_START, - ITM_ENV_START, - ITM_MINIDISK_START, - ITM_DIARY_START, - ITM_TICKET_START, - ITM_INSECT_START, - ITM_HUKUBUKURO_START, - ITM_KABU_START + ITM_PAPER_START, ITM_MONEY_START, ITM_TOOL_START, ITM_FISH_START, ITM_CLOTH_START, ITM_ETC_START, + ITM_CARPET_START, ITM_WALL_START, ITM_FOOD_START, ITM_ENV_START, ITM_MINIDISK_START, ITM_DIARY_START, + ITM_TICKET_START, ITM_INSECT_START, ITM_HUKUBUKURO_START, ITM_KABU_START }; extern u16 ftr_price_table[]; extern u32 mSP_ItemNo2ItemPrice(mActor_name_t item_no) { - static u32 shellfish_price_table[ITM_SHELL_END - ITM_SHELL_START] = { - 160, 80, 600, 120, 240, 1800, 1400, 1000 - }; + static u32 shellfish_price_table[ITM_SHELL_END - ITM_SHELL_START] = { 160, 80, 600, 120, 240, 1800, 1400, 1000 }; - lbRTC_time_c rtc_time = Common_Get(time.rtc_time); - lbRTC_year_t year = rtc_time.year; - u32 price = 0; + lbRTC_time_c rtc_time = Common_Get(time.rtc_time); + lbRTC_year_t year = rtc_time.year; + u32 price = 0; - if (item_no == ITM_HUKUBUKURO_BAG) { - return year; - } + if (item_no == ITM_HUKUBUKURO_BAG) { + return year; + } - item_no = mRmTp_FtrItemNo2Item1ItemNo(item_no, FALSE); - if (item_no >= ITM_SHELL0 && item_no <= ITM_SHELL7) { - u32 idx = item_no - ITM_SHELL0; - - return shellfish_price_table[idx % 8]; - } + item_no = mRmTp_FtrItemNo2Item1ItemNo(item_no, FALSE); + if (item_no >= ITM_SHELL0 && item_no <= ITM_SHELL7) { + u32 idx = item_no - ITM_SHELL0; - if (item_no == ITM_SIGNBOARD) { - return mSP_SIGNBOARD_PRICE; - } + return shellfish_price_table[idx % 8]; + } - switch (ITEM_NAME_GET_TYPE(item_no)) { - case NAME_TYPE_ITEM1: - { - u16** price_list_pp = l_price_info[ITEM_NAME_GET_CAT(item_no)]; + if (item_no == ITM_SIGNBOARD) { + return mSP_SIGNBOARD_PRICE; + } - if (price_list_pp != NULL && &price != NULL) { - u16* price_list_p = *price_list_pp; - int idx = item_no - mSP_item1_start_idx_table[ITEM_NAME_GET_CAT(item_no)]; + switch (ITEM_NAME_GET_TYPE(item_no)) { + case NAME_TYPE_ITEM1: { + u16** price_list_pp = l_price_info[ITEM_NAME_GET_CAT(item_no)]; - if (item_no >= ITM_PAPER_START && item_no <= (ITM_PAPER_END - 1)) { - int paper_idx = (item_no - ITM_PAPER_START); + if (price_list_pp != NULL && &price != NULL) { + u16* price_list_p = *price_list_pp; + int idx = item_no - mSP_item1_start_idx_table[ITEM_NAME_GET_CAT(item_no)]; - idx = (item_no - ITM_PAPER_START) % PAPER_UNIQUE_NUM; - if (idx < mSP_CountPriceTableElement(price_list_p)) { - price = price_list_p[idx]; - price = price * ((paper_idx / 64) + 1); - return price; - } - } + if (item_no >= ITM_PAPER_START && item_no <= (ITM_PAPER_END - 1)) { + int paper_idx = (item_no - ITM_PAPER_START); - if (idx < mSP_CountPriceTableElement(price_list_p)) { - switch (item_no) { - case ITM_FOOD_APPLE: - case ITM_FOOD_CHERRY: - case ITM_FOOD_PEAR: - case ITM_FOOD_PEACH: - case ITM_FOOD_ORANGE: - { - if (Save_Get(fruit) != item_no) { - return mSP_FOREIGN_FRUIT_PRICE; - } - - break; + idx = (item_no - ITM_PAPER_START) % PAPER_UNIQUE_NUM; + if (idx < mSP_CountPriceTableElement(price_list_p)) { + price = price_list_p[idx]; + price = price * ((paper_idx / 64) + 1); + return price; + } + } + + if (idx < mSP_CountPriceTableElement(price_list_p)) { + switch (item_no) { + case ITM_FOOD_APPLE: + case ITM_FOOD_CHERRY: + case ITM_FOOD_PEAR: + case ITM_FOOD_PEACH: + case ITM_FOOD_ORANGE: { + if (Save_Get(fruit) != item_no) { + return mSP_FOREIGN_FRUIT_PRICE; + } + + break; + } + } + + price = price_list_p[idx]; + return price; + } + + return 0; } - } - - price = price_list_p[idx]; - return price; + break; } - return 0; - } + case NAME_TYPE_FTR0: + case NAME_TYPE_FTR1: { + if (&price != NULL) { + int ftr_idx = mRmTp_FtrItemNo2FtrIdx(item_no); + u16* price_list_p = ftr_price_table; - break; - } + if (ftr_idx < mSP_CountPriceTableElement(price_list_p)) { + price = price_list_p[ftr_idx]; + return price; + } - case NAME_TYPE_FTR0: - case NAME_TYPE_FTR1: - { - if (&price != NULL) { - int ftr_idx = mRmTp_FtrItemNo2FtrIdx(item_no); - u16* price_list_p = ftr_price_table; + return 0; + } - if (ftr_idx < mSP_CountPriceTableElement(price_list_p)) { - price = price_list_p[ftr_idx]; - return price; + break; } - return 0; - } - - break; + default: { + return 0; + } } - default: - { - return 0; - } - } - - return 0; + return 0; } extern int mSP_SearchItemCategoryPriority(mActor_name_t item_no, int category, int list_type, GAME* game) { - u8 abc_priorities[3]; - mActor_name_t** lists_p = mSP_goods_seg_inf[category]; - mActor_name_t* list_p; - int count; - int i; + u8 abc_priorities[3]; + mActor_name_t** lists_p = mSP_goods_seg_inf[category]; + mActor_name_t* list_p; + int count; + int i; - mSP_GetGoodsPriority(abc_priorities, category); - list_p = mSP_GetItemList(lists_p, abc_priorities, list_type); - count = mSP_CountElementInCommonList(list_p); + mSP_GetGoodsPriority(abc_priorities, category); + list_p = mSP_GetItemList(lists_p, abc_priorities, list_type); + count = mSP_CountElementInCommonList(list_p); - if (list_p != NULL) { - for (i = 0; i < count; i++) { - if (item_no == list_p[i]) { - return TRUE; - } + if (list_p != NULL) { + for (i = 0; i < count; i++) { + if (item_no == list_p[i]) { + return TRUE; + } + } } - } - return FALSE; + return FALSE; } static int mSP_ItemNo2GoodsListCategory(mActor_name_t item_no) { - if (ITEM_IS_FTR(item_no)) { - return mSP_KIND_FURNITURE; - } - else if (item_no >= ITM_PAPER_START && item_no < ITM_PAPER_END) { - return mSP_KIND_PAPER; - } - else if (item_no >= ITM_CLOTH_START && item_no < ITM_CLOTH_END) { - return mSP_KIND_CLOTH; - } - else if (item_no >= ITM_WALL_START && item_no < ITM_WALL_END) { - return mSP_KIND_WALLPAPER; - } - else if (item_no >= ITM_CARPET_START && item_no < ITM_CARPET_END) { - return mSP_KIND_CARPET; - } - else if (item_no >= ITM_DIARY_START && item_no <= (ITM_DIARY_END-1)) { - return mSP_KIND_DIARY; - } + if (ITEM_IS_FTR(item_no)) { + return mSP_KIND_FURNITURE; + } else if (item_no >= ITM_PAPER_START && item_no < ITM_PAPER_END) { + return mSP_KIND_PAPER; + } else if (item_no >= ITM_CLOTH_START && item_no < ITM_CLOTH_END) { + return mSP_KIND_CLOTH; + } else if (item_no >= ITM_WALL_START && item_no < ITM_WALL_END) { + return mSP_KIND_WALLPAPER; + } else if (item_no >= ITM_CARPET_START && item_no < ITM_CARPET_END) { + return mSP_KIND_CARPET; + } else if (item_no >= ITM_DIARY_START && item_no <= (ITM_DIARY_END - 1)) { + return mSP_KIND_DIARY; + } - return -1; + return -1; } static u8 l_zakka_goods[mSP_GOODS_TYPE_NUM] = { - 1, // stationery - 1, // clothing - 1, // ABC ftr - 0, // rare ftr - 1, // carpet - 1, // wallpaper - 1, // ?? - 0, // ?? - 1, // saplings - 2, // tools - 2 // plants + 1, // stationery + 1, // clothing + 1, // ABC ftr + 0, // rare ftr + 1, // carpet + 1, // wallpaper + 1, // ?? + 0, // ?? + 1, // saplings + 2, // tools + 2 // plants }; static u8 l_conbini_goods[mSP_GOODS_TYPE_NUM] = { - 2, // stationery - 2, // clothing - 2, // ABC ftr - 0, // rare ftr - 1, // carpet - 1, // wallpaper - 1, // ?? - 0, // ?? - 1, // saplings - 3, // tools - 3 // plants + 2, // stationery + 2, // clothing + 2, // ABC ftr + 0, // rare ftr + 1, // carpet + 1, // wallpaper + 1, // ?? + 0, // ?? + 1, // saplings + 3, // tools + 3 // plants }; static u8 l_super_goods[mSP_GOODS_TYPE_NUM] = { - 2, // stationery - 3, // clothing - 3, // ABC ftr - 1, // rare ftr - 2, // carpet - 2, // wallpaper - 1, // ?? - 0, // ?? - 2, // saplings - 2, // tools - 4 // plants + 2, // stationery + 3, // clothing + 3, // ABC ftr + 1, // rare ftr + 2, // carpet + 2, // wallpaper + 1, // ?? + 0, // ?? + 2, // saplings + 2, // tools + 4 // plants }; static u8 l_dsuper_goods[mSP_GOODS_TYPE_NUM] = { - 4, // stationery - 5, // clothing - 5, // ABC ftr - 1, // rare ftr - 3, // carpet - 3, // wallpaper - 1, // ?? - 0, // ?? - 3, // saplings - 3, // tools - 5 // plants + 4, // stationery + 5, // clothing + 5, // ABC ftr + 1, // rare ftr + 3, // carpet + 3, // wallpaper + 1, // ?? + 0, // ?? + 3, // saplings + 3, // tools + 5 // plants }; -static u8* l_goods_count_table[mSP_SHOP_TYPE_NUM] = { - l_zakka_goods, - l_conbini_goods, - l_super_goods, - l_dsuper_goods -}; +static u8* l_goods_count_table[mSP_SHOP_TYPE_NUM] = { l_zakka_goods, l_conbini_goods, l_super_goods, l_dsuper_goods }; static void mSP_MakeRandomGoodsList(GAME* game, int* count, mActor_name_t* goods_list) { - int shop_level = mSP_GetShopLevel(); - u8* goods_count = l_goods_count_table[shop_level]; - Shop_c* shop = Save_GetPointer(shop); - mActor_name_t rare; + int shop_level = mSP_GetShopLevel(); + u8* goods_count = l_goods_count_table[shop_level]; + Shop_c* shop = Save_GetPointer(shop); + mActor_name_t rare; - /* roll rare furniture if the shop has one */ - if (goods_count[mSP_GOODS_TYPE_RARE_FTR] != 0) { - mSP_SelectRandomItem_New(game, &rare, 1, NULL, 0, mSP_KIND_FURNITURE, mSP_LISTTYPE_RARE, FALSE); - } - else { - rare = EMPTY_NO; - } - - Save_Get(shop).rare_item = rare; - - /* roll ABC list furniture */ - mSP_SelectRandomItem_New(game, goods_list + count[0], goods_count[mSP_GOODS_TYPE_FTR], NULL, 0, mSP_KIND_FURNITURE, mSP_LISTTYPE_ABC, FALSE); - mSP_SetSeasonFTR(goods_list + count[0], goods_count[mSP_GOODS_TYPE_FTR]); // replace with seasonal furniture if necessary - count[0] += goods_count[mSP_GOODS_TYPE_FTR]; - - /* check for grab bag sale */ - if (mSP_Chk_HukubukuroSail()) { - shop->flowers_candy_grab_bag_count += (s8)goods_count[mSP_GOODS_TYPE_PAPER]; - if (shop_level >= mSP_SHOP_TYPE_SUPER) { - shop->flowers_candy_grab_bag_count += 1; + /* roll rare furniture if the shop has one */ + if (goods_count[mSP_GOODS_TYPE_RARE_FTR] != 0) { + mSP_SelectRandomItem_New(game, &rare, 1, NULL, 0, mSP_KIND_FURNITURE, mSP_LISTTYPE_RARE, FALSE); + } else { + rare = EMPTY_NO; } - } - else { - /* no grab bag sale, so roll paper & diaries */ - mSP_SelectRandomItem_New(game, goods_list + count[0], goods_count[mSP_GOODS_TYPE_PAPER], NULL, 0, mSP_KIND_PAPER, mSP_LISTTYPE_ABC, FALSE); - count[0] += goods_count[mSP_GOODS_TYPE_PAPER]; - /* only roll diaries for Nookway or higher */ - if (shop_level >= mSP_SHOP_TYPE_SUPER) { - mSP_SelectRandomItem_New(game, goods_list + count[0], 1, NULL, 0, mSP_KIND_DIARY, mSP_LISTTYPE_ABC, FALSE); - count[0] += 1; + Save_Get(shop).rare_item = rare; + + /* roll ABC list furniture */ + mSP_SelectRandomItem_New(game, goods_list + count[0], goods_count[mSP_GOODS_TYPE_FTR], NULL, 0, mSP_KIND_FURNITURE, + mSP_LISTTYPE_ABC, FALSE); + mSP_SetSeasonFTR(goods_list + count[0], + goods_count[mSP_GOODS_TYPE_FTR]); // replace with seasonal furniture if necessary + count[0] += goods_count[mSP_GOODS_TYPE_FTR]; + + /* check for grab bag sale */ + if (mSP_Chk_HukubukuroSail()) { + shop->flowers_candy_grab_bag_count += (s8)goods_count[mSP_GOODS_TYPE_PAPER]; + if (shop_level >= mSP_SHOP_TYPE_SUPER) { + shop->flowers_candy_grab_bag_count += 1; + } + } else { + /* no grab bag sale, so roll paper & diaries */ + mSP_SelectRandomItem_New(game, goods_list + count[0], goods_count[mSP_GOODS_TYPE_PAPER], NULL, 0, + mSP_KIND_PAPER, mSP_LISTTYPE_ABC, FALSE); + count[0] += goods_count[mSP_GOODS_TYPE_PAPER]; + + /* only roll diaries for Nookway or higher */ + if (shop_level >= mSP_SHOP_TYPE_SUPER) { + mSP_SelectRandomItem_New(game, goods_list + count[0], 1, NULL, 0, mSP_KIND_DIARY, mSP_LISTTYPE_ABC, FALSE); + count[0] += 1; + } } - } - /* roll clothing */ - mSP_SelectRandomItem_New(game, goods_list + count[0], goods_count[mSP_GOODS_TYPE_CLOTH], NULL, 0, mSP_KIND_CLOTH, mSP_LISTTYPE_ABC, FALSE); - count[0] += goods_count[mSP_GOODS_TYPE_CLOTH]; + /* roll clothing */ + mSP_SelectRandomItem_New(game, goods_list + count[0], goods_count[mSP_GOODS_TYPE_CLOTH], NULL, 0, mSP_KIND_CLOTH, + mSP_LISTTYPE_ABC, FALSE); + count[0] += goods_count[mSP_GOODS_TYPE_CLOTH]; - /* roll carpets */ - mSP_SelectRandomItem_New(game, goods_list + count[0], goods_count[mSP_GOODS_TYPE_CARPET], NULL, 0, mSP_KIND_CARPET, mSP_LISTTYPE_ABC, FALSE); - count[0] += goods_count[mSP_GOODS_TYPE_CARPET]; + /* roll carpets */ + mSP_SelectRandomItem_New(game, goods_list + count[0], goods_count[mSP_GOODS_TYPE_CARPET], NULL, 0, mSP_KIND_CARPET, + mSP_LISTTYPE_ABC, FALSE); + count[0] += goods_count[mSP_GOODS_TYPE_CARPET]; - /* roll wallpaper */ - mSP_SelectRandomItem_New(game, goods_list + count[0], goods_count[mSP_GOODS_TYPE_WALL], NULL, 0, mSP_KIND_WALLPAPER, mSP_LISTTYPE_ABC, FALSE); - count[0] += goods_count[mSP_GOODS_TYPE_WALL]; + /* roll wallpaper */ + mSP_SelectRandomItem_New(game, goods_list + count[0], goods_count[mSP_GOODS_TYPE_WALL], NULL, 0, mSP_KIND_WALLPAPER, + mSP_LISTTYPE_ABC, FALSE); + count[0] += goods_count[mSP_GOODS_TYPE_WALL]; } extern int mSP_CountElementInGoodsList() { - mActor_name_t* items = Save_Get(shop).items; - int goods_count = 0; - int i; + mActor_name_t* items = Save_Get(shop).items; + int goods_count = 0; + int i; - for (i = 0; i < mSP_GOODS_COUNT; i++) { - if (items[i] != EMPTY_NO) { - goods_count++; + for (i = 0; i < mSP_GOODS_COUNT; i++) { + if (items[i] != EMPTY_NO) { + goods_count++; + } } - } - return goods_count; + return goods_count; } static void mSP_SelectTool(mActor_name_t* goods_list, int* count, int tool_num, int shop_level) { - static int table[4] = { ITM_SHOVEL, ITM_NET, ITM_ROD, ITM_AXE }; + static int table[4] = { ITM_SHOVEL, ITM_NET, ITM_ROD, ITM_AXE }; - int tools_added = 0; - u16 paint_idx = Save_Get(shop).shop_info.paint_color; - u32 sales_sum = Save_Get(shop).sales_sum; - f32 tool_max; + int tools_added = 0; + u16 paint_idx = Save_Get(shop).shop_info.paint_color; + u32 sales_sum = Save_Get(shop).sales_sum; + f32 tool_max; - /* tool lockout based on sales sum is only applicable to Nook's Cranny */ - if (shop_level > mSP_SHOP_TYPE_ZAKKA) { - tool_max = 4;/* shove, net, rod, axe */ - } - else if (sales_sum < mSP_NET_SALES_SUM) { - tool_max = 1; /* shovel only */ - } - else if (sales_sum < mSP_ROD_SALES_SUM) { - tool_max = 2; /* shovel, net */ - } - else if (sales_sum < mSP_AXE_SALES_SUM) { - tool_max = 3; /* shovel, net, rod */ - } - else { - tool_max = 4; /* shove, net, rod, axe */ - } - - if (tool_num > (int)tool_max) { - tool_num = (int)tool_max; - } - - /* - This implementation kind of sucks. - At best case there's a (1/4)^4 (~0.4%) chance of - rolling all four unique tools in a single go. - */ - while (tools_added < tool_num) { - int idx = RANDOM_F(tool_max); - mActor_name_t tool = table[idx]; - - /* Don't allow duplicate tools */ - if (mSP_GoodsExistAlready(goods_list, count[0], tool) == FALSE) { - goods_list[(int)count[0]] = tool; - tools_added++; - count[0]++; - } - } - - /* Add paint & signboard if shop is Nookway or greater */ - if (shop_level >= mSP_SHOP_TYPE_SUPER) { - if (paint_idx >= PAINT_NUM) { - paint_idx = 0; /* wrap over to beginning */ + /* tool lockout based on sales sum is only applicable to Nook's Cranny */ + if (shop_level > mSP_SHOP_TYPE_ZAKKA) { + tool_max = 4; /* shove, net, rod, axe */ + } else if (sales_sum < mSP_NET_SALES_SUM) { + tool_max = 1; /* shovel only */ + } else if (sales_sum < mSP_ROD_SALES_SUM) { + tool_max = 2; /* shovel, net */ + } else if (sales_sum < mSP_AXE_SALES_SUM) { + tool_max = 3; /* shovel, net, rod */ + } else { + tool_max = 4; /* shove, net, rod, axe */ } - goods_list[count[0]] = ITM_RED_PAINT + paint_idx; - paint_idx++; - Save_Get(shop).shop_info.paint_color = paint_idx; - count[0]++; - goods_list[count[0]] = ITM_SIGNBOARD; - count[0]++; - } + if (tool_num > (int)tool_max) { + tool_num = (int)tool_max; + } - /* Add umbrella */ - mSP_RandomUmbSelect(goods_list + count[0], 1); - count[0]++; + /* + This implementation kind of sucks. + At best case there's a (1/4)^4 (~0.4%) chance of + rolling all four unique tools in a single go. + */ + while (tools_added < tool_num) { + int idx = RANDOM_F(tool_max); + mActor_name_t tool = table[idx]; + + /* Don't allow duplicate tools */ + if (mSP_GoodsExistAlready(goods_list, count[0], tool) == FALSE) { + goods_list[(int)count[0]] = tool; + tools_added++; + count[0]++; + } + } + + /* Add paint & signboard if shop is Nookway or greater */ + if (shop_level >= mSP_SHOP_TYPE_SUPER) { + if (paint_idx >= PAINT_NUM) { + paint_idx = 0; /* wrap over to beginning */ + } + + goods_list[count[0]] = ITM_RED_PAINT + paint_idx; + paint_idx++; + Save_Get(shop).shop_info.paint_color = paint_idx; + count[0]++; + goods_list[count[0]] = ITM_SIGNBOARD; + count[0]++; + } + + /* Add umbrella */ + mSP_RandomUmbSelect(goods_list + count[0], 1); + count[0]++; } -static void mSP_SelectPlant(mActor_name_t* goods_list, int* count, int flower_count, int sapling_count, int shop_level) { - u8 flower_use[FLOWER_NUM]; - int i; +static void mSP_SelectPlant(mActor_name_t* goods_list, int* count, int flower_count, int sapling_count, + int shop_level) { + u8 flower_use[FLOWER_NUM]; + int i; - if (mSP_CheckHallowinDay()) { - Save_Get(shop).flowers_candy_grab_bag_count = flower_count; - flower_count = sapling_count; - sapling_count = 0; - } - - if (shop_level >= mSP_SHOP_TYPE_SUPER && sapling_count > 0) { - goods_list[count[0]] = ITM_CEDAR_SAPLING; - sapling_count--; - count[0] += 1; - } - - for (i = 0; i < sapling_count; i++) { - goods_list[count[0]] = ITM_SAPLING; - count[0] += 1; - } - - for (i = 0; i < FLOWER_NUM; i++) { - flower_use[i] = FALSE; - } - - while (flower_count > 0) { - int idx = RANDOM(FLOWER_NUM); - - if (flower_use[idx] == FALSE) { - goods_list[count[0]] = ITM_WHITE_PANSY_BAG + idx; - flower_use[idx] = TRUE; - flower_count--; - count[0] += 1; + if (mSP_CheckHallowinDay()) { + Save_Get(shop).flowers_candy_grab_bag_count = flower_count; + flower_count = sapling_count; + sapling_count = 0; + } + + if (shop_level >= mSP_SHOP_TYPE_SUPER && sapling_count > 0) { + goods_list[count[0]] = ITM_CEDAR_SAPLING; + sapling_count--; + count[0] += 1; + } + + for (i = 0; i < sapling_count; i++) { + goods_list[count[0]] = ITM_SAPLING; + count[0] += 1; + } + + for (i = 0; i < FLOWER_NUM; i++) { + flower_use[i] = FALSE; + } + + while (flower_count > 0) { + int idx = RANDOM(FLOWER_NUM); + + if (flower_use[idx] == FALSE) { + goods_list[count[0]] = ITM_WHITE_PANSY_BAG + idx; + flower_use[idx] = TRUE; + flower_count--; + count[0] += 1; + } } - } } static void mSP_MakeGoodsList(GAME* game) { - int count = 0; - mActor_name_t* shop_items = Save_Get(shop).items; - Shop_c* shop = Save_GetPointer(shop); - int shop_level = mSP_GetShopLevel(); - u8* goods_count = l_goods_count_table[shop_level]; - u8 tool_count = goods_count[mSP_GOODS_TYPE_TOOL]; - u8 flower_count = goods_count[mSP_GOODS_TYPE_PLANT]; - u8 sapling_count = goods_count[mSP_GOODS_TYPE_SAPLING]; + int count = 0; + mActor_name_t* shop_items = Save_Get(shop).items; + Shop_c* shop = Save_GetPointer(shop); + int shop_level = mSP_GetShopLevel(); + u8* goods_count = l_goods_count_table[shop_level]; + u8 tool_count = goods_count[mSP_GOODS_TYPE_TOOL]; + u8 flower_count = goods_count[mSP_GOODS_TYPE_PLANT]; + u8 sapling_count = goods_count[mSP_GOODS_TYPE_SAPLING]; - if (mSP_CheckFukubikiDay() == FALSE) { - if (mSP_Chk_HukubukuroSail() != FALSE) { - shop->flowers_candy_grab_bag_count = 0; + if (mSP_CheckFukubikiDay() == FALSE) { + if (mSP_Chk_HukubukuroSail() != FALSE) { + shop->flowers_candy_grab_bag_count = 0; + } + + mSP_MakeRandomGoodsList(game, &count, shop_items); + + if (mSP_Chk_HukubukuroSail() != FALSE) { + shop->flowers_candy_grab_bag_count += (s8)tool_count; + shop->flowers_candy_grab_bag_count += (s8)flower_count; + shop->flowers_candy_grab_bag_count += (s8)sapling_count; + + if (shop_level >= mSP_SHOP_TYPE_SUPER) { + shop->flowers_candy_grab_bag_count++; // add signboard & paint + shop->flowers_candy_grab_bag_count++; + } + } else { + mSP_SelectTool(shop_items, &count, tool_count, shop_level & 3); + mSP_SelectPlant(shop_items, &count, flower_count, sapling_count, shop_level & 3); + } } - - mSP_MakeRandomGoodsList(game, &count, shop_items); - - if (mSP_Chk_HukubukuroSail() != FALSE) { - shop->flowers_candy_grab_bag_count += (s8)tool_count; - shop->flowers_candy_grab_bag_count += (s8)flower_count; - shop->flowers_candy_grab_bag_count += (s8)sapling_count; - - if (shop_level >= mSP_SHOP_TYPE_SUPER) { - shop->flowers_candy_grab_bag_count++; // add signboard & paint - shop->flowers_candy_grab_bag_count++; - } - } - else { - mSP_SelectTool(shop_items, &count, tool_count, shop_level & 3); - mSP_SelectPlant(shop_items, &count, flower_count, sapling_count, shop_level & 3); - } - } } static void mSP_MakeLotteryList(GAME* game) { - mActor_name_t* lottery_items = Save_Get(shop).lottery_items; - mActor_name_t unobtained_lottery_item; + mActor_name_t* lottery_items = Save_Get(shop).lottery_items; + mActor_name_t unobtained_lottery_item; - mSP_SelectRandomItem_New( - game, - &unobtained_lottery_item, - 1, - NULL, - 0, - mSP_KIND_FURNITURE, - mSP_LISTTYPE_LOTTERY, - TRUE - ); + mSP_SelectRandomItem_New(game, &unobtained_lottery_item, 1, NULL, 0, mSP_KIND_FURNITURE, mSP_LISTTYPE_LOTTERY, + TRUE); - if (unobtained_lottery_item == EMPTY_NO) { - mSP_SelectRandomItem_New( - game, - lottery_items, - mSP_LOTTERY_ITEM_COUNT, - NULL, - 0, - mSP_KIND_FURNITURE, - mSP_LISTTYPE_LOTTERY, - FALSE - ); - } - else { - mSP_SelectRandomItem_New( - game, - lottery_items + 1, - mSP_LOTTERY_ITEM_COUNT - 1, - &unobtained_lottery_item, - 1, - mSP_KIND_FURNITURE, - mSP_LISTTYPE_LOTTERY, - FALSE - ); + if (unobtained_lottery_item == EMPTY_NO) { + mSP_SelectRandomItem_New(game, lottery_items, mSP_LOTTERY_ITEM_COUNT, NULL, 0, mSP_KIND_FURNITURE, + mSP_LISTTYPE_LOTTERY, FALSE); + } else { + mSP_SelectRandomItem_New(game, lottery_items + 1, mSP_LOTTERY_ITEM_COUNT - 1, &unobtained_lottery_item, 1, + mSP_KIND_FURNITURE, mSP_LISTTYPE_LOTTERY, FALSE); - lottery_items[0] = unobtained_lottery_item; - } + lottery_items[0] = unobtained_lottery_item; + } } extern int mSP_CheckExchangeDay2() { - Shop_c* shop = Save_GetPointer(shop); - lbRTC_time_c rtc_time = Common_Get(time.rtc_time); - int res = lbRTC_IsEqualTime( - &rtc_time, - &shop->exchange_time, - lbRTC_CHECK_DAYS | lbRTC_CHECK_MONTHS | lbRTC_CHECK_YEARS - ); + Shop_c* shop = Save_GetPointer(shop); + lbRTC_time_c rtc_time = Common_Get(time.rtc_time); + int res = + lbRTC_IsEqualTime(&rtc_time, &shop->exchange_time, lbRTC_CHECK_DAYS | lbRTC_CHECK_MONTHS | lbRTC_CHECK_YEARS); - return res == lbRTC_EQUAL; + return res == lbRTC_EQUAL; } extern int mSP_CheckExchangeMonth() { - Shop_c* shop = Save_GetPointer(shop); - lbRTC_time_c rtc_time = Common_Get(time.rtc_time); - int res = lbRTC_IsEqualTime( - &rtc_time, - &shop->exchange_time, - lbRTC_CHECK_MONTHS | lbRTC_CHECK_YEARS - ); + Shop_c* shop = Save_GetPointer(shop); + lbRTC_time_c rtc_time = Common_Get(time.rtc_time); + int res = lbRTC_IsEqualTime(&rtc_time, &shop->exchange_time, lbRTC_CHECK_MONTHS | lbRTC_CHECK_YEARS); - return res == lbRTC_EQUAL; + return res == lbRTC_EQUAL; } extern void mSP_NewExchangeDay() { - Save_Get(shop).exchange_time = Common_Get(time.rtc_time); + Save_Get(shop).exchange_time = Common_Get(time.rtc_time); } /* @unused size: 0x104 */ // ? mSP_SearchRareFurniture(...) extern void mSP_ShopItsumoChirashi(int house_no, int shop_level, mActor_name_t item, int type, int send_proc) { - static int rare_chirashi_bunmen[mSP_SHOP_TYPE_NUM][2] = { - { 18, 18 }, - { 19, 19 }, - { 21, 20 }, - { 23, 22 } - }; + static int rare_chirashi_bunmen[mSP_SHOP_TYPE_NUM][2] = { { 18, 18 }, { 19, 19 }, { 21, 20 }, { 23, 22 } }; - if (Save_Get(homes[house_no]).ownerID.land_id != 0xFFFF) { - int free_mail_idx = mMl_chk_mail_free_space(Save_Get(homes[house_no]).mailbox, HOME_MAILBOX_SIZE); + if (Save_Get(homes[house_no]).ownerID.land_id != 0xFFFF) { + int free_mail_idx = mMl_chk_mail_free_space(Save_Get(homes[house_no]).mailbox, HOME_MAILBOX_SIZE); - if (mEv_ArbeitPlayer(mHS_get_pl_no(house_no) & 3) != TRUE) { - u8 item_name_str[mIN_ITEM_NAME_LEN]; - Mail_c leaflet; - int header_back_start; + if (mEv_ArbeitPlayer(mHS_get_pl_no(house_no) & 3) != TRUE) { + u8 item_name_str[mIN_ITEM_NAME_LEN]; + Mail_c leaflet; + int header_back_start; - mIN_copy_name_str(item_name_str, item); - mHandbill_Set_free_str(mHandbill_FREE_STR7, item_name_str, mIN_ITEM_NAME_LEN); - mMl_clear_mail(&leaflet); - mHandbill_Load_HandbillFromRom( - leaflet.content.header, - &header_back_start, - leaflet.content.footer, - leaflet.content.body, - rare_chirashi_bunmen[shop_level][type & 1] - ); - leaflet.content.font = mMl_FONT_0; - leaflet.content.header_back_start = header_back_start; - leaflet.content.mail_type = mMl_TYPE_SHOP_SALE_LEAFLET; - leaflet.content.paper_type = ITM_PAPER55; // simple paper + mIN_copy_name_str(item_name_str, item); + mHandbill_Set_free_str(mHandbill_FREE_STR7, item_name_str, mIN_ITEM_NAME_LEN); + mMl_clear_mail(&leaflet); + mHandbill_Load_HandbillFromRom(leaflet.content.header, &header_back_start, leaflet.content.footer, + leaflet.content.body, rare_chirashi_bunmen[shop_level][type & 1]); + leaflet.content.font = mMl_FONT_0; + leaflet.content.header_back_start = header_back_start; + leaflet.content.mail_type = mMl_TYPE_SHOP_SALE_LEAFLET; + leaflet.content.paper_type = ITM_PAPER55; // simple paper - switch (send_proc) { - case mPO_SENDTYPE_MAIL: - { - mPO_receipt_proc(&leaflet, mPO_SENDTYPE_LEAFLET); + switch (send_proc) { + case mPO_SENDTYPE_MAIL: { + mPO_receipt_proc(&leaflet, mPO_SENDTYPE_LEAFLET); - break; + break; + } + + default: { + if (free_mail_idx >= 0) { + mPr_CopyPersonalID(&leaflet.header.recipient.personalID, + &Save_Get(private_data[mHS_get_pl_no(house_no) & 3]).player_ID); + leaflet.header.recipient.type = mMl_NAME_TYPE_PLAYER; + + mMl_copy_mail(Save_Get(homes[house_no]).mailbox + free_mail_idx, &leaflet); + } + + break; + } + } } - - default: - { - if (free_mail_idx >= 0) { - mPr_CopyPersonalID(&leaflet.header.recipient.personalID, &Save_Get(private[mHS_get_pl_no(house_no) & 3]).player_ID); - leaflet.header.recipient.type = mMl_NAME_TYPE_PLAYER; - - mMl_copy_mail(Save_Get(homes[house_no]).mailbox + free_mail_idx, &leaflet); - } - - break; - } - } } - } } extern void mSP_SetShopRareFurnitureChirashi(int player_no, mActor_name_t* goods_list, int goods_count, GAME* game) { @@ -1284,8 +1136,8 @@ extern void mSP_SetShopRareFurnitureChirashi(int player_no, mActor_name_t* goods } /* Check if we're on the last day of the month */ - if (Common_Get(time.rtc_time).day == lbRTC_GetDaysByMonth(Common_Get(time.rtc_time).year, - Common_Get(time.rtc_time).month)) { + if (Common_Get(time.rtc_time).day == + lbRTC_GetDaysByMonth(Common_Get(time.rtc_time).year, Common_Get(time.rtc_time).month)) { mCkRh_SavePlayTime(player_no); } else if (mEv_CheckEvent(mEv_SAVED_RENEWSHOP) == TRUE) { mCkRh_SavePlayTime(player_no); // shop was already 'renewed' today @@ -1297,46 +1149,40 @@ extern void mSP_SetShopRareFurnitureChirashi(int player_no, mActor_name_t* goods if (bargain_day != 0) { u32 month = mEv_TO_MONTH(bargain_day); u32 day = mEv_TO_DAY(bargain_day); - if (Common_Get(time.rtc_time).month == month && - Common_Get(time.rtc_time).day == day) { + if (Common_Get(time.rtc_time).month == month && Common_Get(time.rtc_time).day == day) { mCkRh_SavePlayTime(player_no); // shop 'bargin' event is active return; } } - + goki_time = Save_Get(homes[arrange_idx]).goki.time; lbRTC_Add_DD(&goki_time, 1); home = Save_GetPointer(homes[arrange_idx]); /* check if the current date & time is past the renew time */ - if (home->goki.time.year == rtc_time->year && - home->goki.time.month == rtc_time->month && - home->goki.time.day == rtc_time->day) return; - - if (goki_time.year == rtc_time->year && - goki_time.month == rtc_time->month && - goki_time.day == rtc_time->day && - goki_time.hour < mTM_FIELD_RENEW_HOUR) return; - - if (rtc_time->hour < mTM_FIELD_RENEW_HOUR || - rtc_time->hour > mSP_GetShopCloseTime()) return; + if (home->goki.time.year == rtc_time->year && home->goki.time.month == rtc_time->month && + home->goki.time.day == rtc_time->day) + return; - if (mSP_SearchItemCategoryPriority(Save_Get(shop).rare_item, - mSP_KIND_FURNITURE, - mSP_LISTTYPE_RARE, game)) { + if (goki_time.year == rtc_time->year && goki_time.month == rtc_time->month && goki_time.day == rtc_time->day && + goki_time.hour < mTM_FIELD_RENEW_HOUR) + return; + + if (rtc_time->hour < mTM_FIELD_RENEW_HOUR || rtc_time->hour > mSP_GetShopCloseTime()) + return; + + if (mSP_SearchItemCategoryPriority(Save_Get(shop).rare_item, mSP_KIND_FURNITURE, mSP_LISTTYPE_RARE, game)) { rare_item = Save_Get(shop).rare_item; is_rare_item = TRUE; } else { int i; - + /* spotlight item in shop wasn't the rare item, so check all * the goods for one */ for (i = 0; i < goods_count; i++) { - if (mSP_ItemNo2GoodsListCategory(goods_list[i]) == - mSP_KIND_FURNITURE) { - is_rare_item = mSP_SearchItemCategoryPriority( - goods_list[i], mSP_KIND_FURNITURE, - mSP_LISTTYPE_RARE, game); + if (mSP_ItemNo2GoodsListCategory(goods_list[i]) == mSP_KIND_FURNITURE) { + is_rare_item = + mSP_SearchItemCategoryPriority(goods_list[i], mSP_KIND_FURNITURE, mSP_LISTTYPE_RARE, game); if (is_rare_item != FALSE) { rare_item = goods_list[i]; @@ -1353,9 +1199,7 @@ extern void mSP_SetShopRareFurnitureChirashi(int player_no, mActor_name_t* goods int arrange_idx = mHS_get_arrange_idx(p); if (mHS_get_pl_no_detail(arrange_idx) != -1) { - mSP_ShopItsumoChirashi(arrange_idx, shop_level, - rare_item, is_rare_item, - mPO_SENDTYPE_LEAFLET); + mSP_ShopItsumoChirashi(arrange_idx, shop_level, rare_item, is_rare_item, mPO_SENDTYPE_LEAFLET); mCkRh_SavePlayTime(player_no); } } @@ -1363,1399 +1207,1269 @@ extern void mSP_SetShopRareFurnitureChirashi(int player_no, mActor_name_t* goods } extern void mSP_SetRenewalChiraswhi_AppoDay() { - static int chirashi_idx_appoday[mSP_SHOP_TYPE_NUM] = { 0x1B, 0x1B, 0x1C, 0x1D }; - Mail_c leaflet; - Mail_ct_c* content = &leaflet.content; - int header_back_start; + static int chirashi_idx_appoday[mSP_SHOP_TYPE_NUM] = { 0x1B, 0x1B, 0x1C, 0x1D }; + Mail_c leaflet; + Mail_ct_c* content = &leaflet.content; + int header_back_start; - if (Save_Get(shop).shop_info.upgrading_today && mEv_CheckEvent(mEv_SAVED_RENEWSHOP) == FALSE) { - int shop_level = mSP_GetRealShopLevel(); - int i; + if (Save_Get(shop).shop_info.upgrading_today && mEv_CheckEvent(mEv_SAVED_RENEWSHOP) == FALSE) { + int shop_level = mSP_GetRealShopLevel(); + int i; - for (i = 0; i < mHS_HOUSE_NUM; i++) { - int player_no = mHS_get_pl_no(i) & 3; - int free_mail_idx = mMl_chk_mail_free_space(Save_Get(homes[i]).mailbox, HOME_MAILBOX_SIZE); + for (i = 0; i < mHS_HOUSE_NUM; i++) { + int player_no = mHS_get_pl_no(i) & 3; + int free_mail_idx = mMl_chk_mail_free_space(Save_Get(homes[i]).mailbox, HOME_MAILBOX_SIZE); - if (free_mail_idx >= 0 && Save_Get(homes[i]).ownerID.land_id != 0xFFFF && mEv_ArbeitPlayer(player_no) == FALSE) { + if (free_mail_idx >= 0 && Save_Get(homes[i]).ownerID.land_id != 0xFFFF && + mEv_ArbeitPlayer(player_no) == FALSE) { - mMl_clear_mail(&leaflet); - mHandbill_Load_HandbillFromRom( - content->header, - &header_back_start, - content->footer, - content->body, - chirashi_idx_appoday[shop_level] - ); - leaflet.content.font = mMl_FONT_0; - leaflet.content.header_back_start = header_back_start; - leaflet.content.mail_type = mMl_TYPE_SHOP_SALE_LEAFLET; - leaflet.content.paper_type = ITM_PAPER55; // simple paper + mMl_clear_mail(&leaflet); + mHandbill_Load_HandbillFromRom(content->header, &header_back_start, content->footer, content->body, + chirashi_idx_appoday[shop_level]); + leaflet.content.font = mMl_FONT_0; + leaflet.content.header_back_start = header_back_start; + leaflet.content.mail_type = mMl_TYPE_SHOP_SALE_LEAFLET; + leaflet.content.paper_type = ITM_PAPER55; // simple paper - mPr_CopyPersonalID(&leaflet.header.recipient.personalID, &Save_Get(private[mHS_get_pl_no(i) & 3]).player_ID); - leaflet.header.recipient.type = mMl_NAME_TYPE_PLAYER; + mPr_CopyPersonalID(&leaflet.header.recipient.personalID, + &Save_Get(private_data[mHS_get_pl_no(i) & 3]).player_ID); + leaflet.header.recipient.type = mMl_NAME_TYPE_PLAYER; - mMl_copy_mail(Save_Get(homes[i]).mailbox + free_mail_idx, &leaflet); - } + mMl_copy_mail(Save_Get(homes[i]).mailbox + free_mail_idx, &leaflet); + } + } + + Save_Get(shop).shop_info.upgrading_today = FALSE; } - - Save_Get(shop).shop_info.upgrading_today = FALSE; - } } extern void mSP_ExchangeLineUp_InGame(GAME* game) { - if (mSP_CheckExchangeDay2()) { - if (mSP_CheckExchangeMonth()) { - mSP_LotteryLineUp_GameAlloc(game); - } + if (mSP_CheckExchangeDay2()) { + if (mSP_CheckExchangeMonth()) { + mSP_LotteryLineUp_GameAlloc(game); + } - mSP_NewExchangeDay(); - mSP_ExchangeLineUp_GameAlloc(game); - Save_Get(shop).shop_info.not_loaded_before = TRUE; - mSP_SetShopRareFurnitureChirashi(Common_Get(player_no), Save_Get(shop).items, mSP_GOODS_COUNT, game); - } + mSP_NewExchangeDay(); + mSP_ExchangeLineUp_GameAlloc(game); + Save_Get(shop).shop_info.not_loaded_before = TRUE; + mSP_SetShopRareFurnitureChirashi(Common_Get(player_no), Save_Get(shop).items, mSP_GOODS_COUNT, game); + } } extern void mSP_PlusSales(u32 sum) { - Save_Get(shop).sales_sum += sum; + Save_Get(shop).sales_sum += sum; - if (mSP_GetShopLevel() == mSP_SHOP_TYPE_ZAKKA) { - if (Save_Get(shop).sales_sum > mSP_COMBINI_SUM) { - Save_Get(shop).sales_sum = mSP_COMBINI_SUM; + if (mSP_GetShopLevel() == mSP_SHOP_TYPE_ZAKKA) { + if (Save_Get(shop).sales_sum > mSP_COMBINI_SUM) { + Save_Get(shop).sales_sum = mSP_COMBINI_SUM; + } + } else if (mSP_GetShopLevel() == mSP_SHOP_TYPE_COMBINI) { + if (Save_Get(shop).sales_sum > mSP_SUPER_SUM) { + Save_Get(shop).sales_sum = mSP_SUPER_SUM; + } + } else if (mSP_GetShopLevel() == mSP_SHOP_TYPE_SUPER) { + if (Save_Get(shop).sales_sum > mSP_DSUPER_SUM) { + Save_Get(shop).sales_sum = mSP_DSUPER_SUM; + } } - } - else if (mSP_GetShopLevel() == mSP_SHOP_TYPE_COMBINI) { - if (Save_Get(shop).sales_sum > mSP_SUPER_SUM) { - Save_Get(shop).sales_sum = mSP_SUPER_SUM; - } - } - else if (mSP_GetShopLevel() == mSP_SHOP_TYPE_SUPER) { - if (Save_Get(shop).sales_sum > mSP_DSUPER_SUM) { - Save_Get(shop).sales_sum = mSP_DSUPER_SUM; - } - } } /* @unused size: 0x74 */ // extern int mSP_GetVisitorCount() extern int mSP_SetNewVisitor() { - if (mLd_PlayerManKindCheck()) { - Save_Get(shop).visitor_flag = TRUE; - return TRUE; - } + if (mLd_PlayerManKindCheck()) { + Save_Get(shop).visitor_flag = TRUE; + return TRUE; + } - return FALSE; + return FALSE; } extern u32 mSP_GetSalesSum() { - return Save_Get(shop).sales_sum; + return Save_Get(shop).sales_sum; } extern int mSP_GetShopLevel() { - return Save_Get(shop).shop_info.shop_level; + return Save_Get(shop).shop_info.shop_level; } extern int mSP_RenewShopLevel() { - if (Save_Get(shop).shop_info.shop_level != (u8)mSP_GetRealShopLevel()) { - Save_Get(shop).shop_info.shop_level = mSP_GetRealShopLevel(); - return TRUE; - } + if (Save_Get(shop).shop_info.shop_level != (u8)mSP_GetRealShopLevel()) { + Save_Get(shop).shop_info.shop_level = mSP_GetRealShopLevel(); + return TRUE; + } - return FALSE; + return FALSE; } extern int mSP_GetRealShopLevel() { - u32 sales_sum = mSP_GetSalesSum(); - - if (sales_sum >= mSP_DSUPER_SUM && Save_Get(shop).visitor_flag != FALSE) { - return mSP_SHOP_TYPE_DSUPER; - } - else if (sales_sum >= mSP_SUPER_SUM) { - return mSP_SHOP_TYPE_SUPER; - } + u32 sales_sum = mSP_GetSalesSum(); - return sales_sum >= mSP_COMBINI_SUM ? mSP_SHOP_TYPE_COMBINI : mSP_SHOP_TYPE_ZAKKA; + if (sales_sum >= mSP_DSUPER_SUM && Save_Get(shop).visitor_flag != FALSE) { + return mSP_SHOP_TYPE_DSUPER; + } else if (sales_sum >= mSP_SUPER_SUM) { + return mSP_SHOP_TYPE_SUPER; + } + + return sales_sum >= mSP_COMBINI_SUM ? mSP_SHOP_TYPE_COMBINI : mSP_SHOP_TYPE_ZAKKA; } extern int mSP_GetGoodsPercent(int priority) { - int goods_power = mPr_GetGoodsPower(); + int goods_power = mPr_GetGoodsPower(); - if (priority >= 0 && priority <= mSP_PRIORITY_RARE) { - int rare; - int uncommon; + if (priority >= 0 && priority <= mSP_PRIORITY_RARE) { + int rare; + int uncommon; - if (goods_power < 0) { - uncommon = goods_power + 35 + 5; - rare = 5; - } - else { - rare = goods_power + 5; - uncommon = rare + 35; - } + if (goods_power < 0) { + uncommon = goods_power + 35 + 5; + rare = 5; + } else { + rare = goods_power + 5; + uncommon = rare + 35; + } - switch (priority) { - case mSP_PRIORITY_COMMON: - return 100 - uncommon; - case mSP_PRIORITY_UNCOMMON: - return uncommon - rare; - case mSP_PRIORITY_RARE: - return rare; - default: + switch (priority) { + case mSP_PRIORITY_COMMON: + return 100 - uncommon; + case mSP_PRIORITY_UNCOMMON: + return uncommon - rare; + case mSP_PRIORITY_RARE: + return rare; + default: + return 0; + } + } else { return 0; } - } - else { - return 0; - } } extern void mSP_PrintNowShopSalesSum(gfxprint_t* gfxprint) { - if (mFI_CheckFieldData()) { - int shop_level = mSP_GetShopLevel(); - int status = mSP_ShopOpen(); - u32 sales_sum = mSP_GetSalesSum(); - u32 working_sum; + if (mFI_CheckFieldData()) { + int shop_level = mSP_GetShopLevel(); + int status = mSP_ShopOpen(); + u32 sales_sum = mSP_GetSalesSum(); + u32 working_sum; - switch (shop_level) { - case mSP_SHOP_TYPE_ZAKKA: - working_sum = sales_sum; - break; - case mSP_SHOP_TYPE_COMBINI: - working_sum = sales_sum - mSP_COMBINI_SUM; - break; - case mSP_SHOP_TYPE_SUPER: - working_sum = sales_sum - mSP_SUPER_SUM; - break; - default: - working_sum = sales_sum - mSP_DSUPER_SUM; - break; + switch (shop_level) { + case mSP_SHOP_TYPE_ZAKKA: + working_sum = sales_sum; + break; + case mSP_SHOP_TYPE_COMBINI: + working_sum = sales_sum - mSP_COMBINI_SUM; + break; + case mSP_SHOP_TYPE_SUPER: + working_sum = sales_sum - mSP_SUPER_SUM; + break; + default: + working_sum = sales_sum - mSP_DSUPER_SUM; + break; + } + + gfxprint_color(gfxprint, 200, 200, 250, 255); + gfxprint_locate8x8(gfxprint, 3, 12); + + if (mEv_CheckEvent(mEv_SAVED_RENEWSHOP) == FALSE) { + gfxprint_printf(gfxprint, "%d %d %s", shop_level, working_sum, mSP_ShopStatus2String(status)); + + gfxprint_color(gfxprint, 200, 200, 250, 255); + gfxprint_printf(gfxprint, "A%2d,%2d,%2d,%2d,%2d", + mSP_GetGoodsPercent(Save_Get(shop).priority_lists[mSP_KIND_FURNITURE].a), + mSP_GetGoodsPercent(Save_Get(shop).priority_lists[mSP_KIND_WALLPAPER].a), + mSP_GetGoodsPercent(Save_Get(shop).priority_lists[mSP_KIND_CARPET].a), + mSP_GetGoodsPercent(Save_Get(shop).priority_lists[mSP_KIND_CLOTH].a), + mSP_GetGoodsPercent(Save_Get(shop).priority_lists[mSP_KIND_PAPER].a)); + } else { + gfxprint_color(gfxprint, 200, 100, 100, 255); + gfxprint_printf(gfxprint, "%d %d %s->%d.%d.%d", shop_level, working_sum, mSP_ShopStatus2String(status), + Save_Get(shop).renewal_time.year, Save_Get(shop).renewal_time.month, + Save_Get(shop).renewal_time.day); + + gfxprint_color(gfxprint, 200, 200, 250, 255); + gfxprint_printf(gfxprint, " A%2d,%2d,%2d,%2d,%2d", + mSP_GetGoodsPercent(Save_Get(shop).priority_lists[mSP_KIND_FURNITURE].a), + mSP_GetGoodsPercent(Save_Get(shop).priority_lists[mSP_KIND_WALLPAPER].a), + mSP_GetGoodsPercent(Save_Get(shop).priority_lists[mSP_KIND_CARPET].a), + mSP_GetGoodsPercent(Save_Get(shop).priority_lists[mSP_KIND_CLOTH].a), + mSP_GetGoodsPercent(Save_Get(shop).priority_lists[mSP_KIND_PAPER].a)); + } + + gfxprint_color(gfxprint, 200, 200, 250, 255); + gfxprint_locate8x8(gfxprint, 3, 13); + gfxprint_printf(gfxprint, "B%2d,%2d,%2d,%2d,%2d", + mSP_GetGoodsPercent(Save_Get(shop).priority_lists[mSP_KIND_FURNITURE].b), + mSP_GetGoodsPercent(Save_Get(shop).priority_lists[mSP_KIND_WALLPAPER].b), + mSP_GetGoodsPercent(Save_Get(shop).priority_lists[mSP_KIND_CARPET].b), + mSP_GetGoodsPercent(Save_Get(shop).priority_lists[mSP_KIND_CLOTH].b), + mSP_GetGoodsPercent(Save_Get(shop).priority_lists[mSP_KIND_PAPER].b)); + gfxprint_printf(gfxprint, "C%2d,%2d,%2d,%2d,%2d", + mSP_GetGoodsPercent(Save_Get(shop).priority_lists[mSP_KIND_FURNITURE].c), + mSP_GetGoodsPercent(Save_Get(shop).priority_lists[mSP_KIND_WALLPAPER].c), + mSP_GetGoodsPercent(Save_Get(shop).priority_lists[mSP_KIND_CARPET].c), + mSP_GetGoodsPercent(Save_Get(shop).priority_lists[mSP_KIND_CLOTH].c), + mSP_GetGoodsPercent(Save_Get(shop).priority_lists[mSP_KIND_PAPER].c)); } - - gfxprint_color(gfxprint, 200, 200, 250, 255); - gfxprint_locate8x8(gfxprint, 3, 12); - - if (mEv_CheckEvent(mEv_SAVED_RENEWSHOP) == FALSE) { - gfxprint_printf(gfxprint, "%d %d %s", shop_level, working_sum, mSP_ShopStatus2String(status)); - - gfxprint_color(gfxprint, 200, 200, 250, 255); - gfxprint_printf( - gfxprint, - "A%2d,%2d,%2d,%2d,%2d", - mSP_GetGoodsPercent(Save_Get(shop).priority_lists[mSP_KIND_FURNITURE].a), - mSP_GetGoodsPercent(Save_Get(shop).priority_lists[mSP_KIND_WALLPAPER].a), - mSP_GetGoodsPercent(Save_Get(shop).priority_lists[mSP_KIND_CARPET].a), - mSP_GetGoodsPercent(Save_Get(shop).priority_lists[mSP_KIND_CLOTH].a), - mSP_GetGoodsPercent(Save_Get(shop).priority_lists[mSP_KIND_PAPER].a) - ); - } - else { - gfxprint_color(gfxprint, 200, 100, 100, 255); - gfxprint_printf( - gfxprint, - "%d %d %s->%d.%d.%d", - shop_level, - working_sum, - mSP_ShopStatus2String(status), - Save_Get(shop).renewal_time.year, - Save_Get(shop).renewal_time.month, - Save_Get(shop).renewal_time.day - ); - - gfxprint_color(gfxprint, 200, 200, 250, 255); - gfxprint_printf( - gfxprint, - " A%2d,%2d,%2d,%2d,%2d", - mSP_GetGoodsPercent(Save_Get(shop).priority_lists[mSP_KIND_FURNITURE].a), - mSP_GetGoodsPercent(Save_Get(shop).priority_lists[mSP_KIND_WALLPAPER].a), - mSP_GetGoodsPercent(Save_Get(shop).priority_lists[mSP_KIND_CARPET].a), - mSP_GetGoodsPercent(Save_Get(shop).priority_lists[mSP_KIND_CLOTH].a), - mSP_GetGoodsPercent(Save_Get(shop).priority_lists[mSP_KIND_PAPER].a) - ); - } - - gfxprint_color(gfxprint, 200, 200, 250, 255); - gfxprint_locate8x8(gfxprint, 3, 13); - gfxprint_printf( - gfxprint, - "B%2d,%2d,%2d,%2d,%2d", - mSP_GetGoodsPercent(Save_Get(shop).priority_lists[mSP_KIND_FURNITURE].b), - mSP_GetGoodsPercent(Save_Get(shop).priority_lists[mSP_KIND_WALLPAPER].b), - mSP_GetGoodsPercent(Save_Get(shop).priority_lists[mSP_KIND_CARPET].b), - mSP_GetGoodsPercent(Save_Get(shop).priority_lists[mSP_KIND_CLOTH].b), - mSP_GetGoodsPercent(Save_Get(shop).priority_lists[mSP_KIND_PAPER].b) - ); - gfxprint_printf( - gfxprint, - "C%2d,%2d,%2d,%2d,%2d", - mSP_GetGoodsPercent(Save_Get(shop).priority_lists[mSP_KIND_FURNITURE].c), - mSP_GetGoodsPercent(Save_Get(shop).priority_lists[mSP_KIND_WALLPAPER].c), - mSP_GetGoodsPercent(Save_Get(shop).priority_lists[mSP_KIND_CARPET].c), - mSP_GetGoodsPercent(Save_Get(shop).priority_lists[mSP_KIND_CLOTH].c), - mSP_GetGoodsPercent(Save_Get(shop).priority_lists[mSP_KIND_PAPER].c) - ); - } } extern void mSP_GetGoodsPriority(u8* abc_priorities, int category) { - mSP_goods_priority_list_c* priorities = Save_Get(shop).priority_lists; + mSP_goods_priority_list_c* priorities = Save_Get(shop).priority_lists; - if (category == mSP_KIND_DIARY) { - category = mSP_KIND_FURNITURE; - } + if (category == mSP_KIND_DIARY) { + category = mSP_KIND_FURNITURE; + } - abc_priorities[0] = priorities[category].a; - abc_priorities[1] = priorities[category].b; - abc_priorities[2] = priorities[category].c; + abc_priorities[0] = priorities[category].a; + abc_priorities[1] = priorities[category].b; + abc_priorities[2] = priorities[category].c; } static void mSP_SetExchangeDay() { - Save_Get(shop).exchange_time = Common_Get(time.rtc_time); + Save_Get(shop).exchange_time = Common_Get(time.rtc_time); } static void mSP_InitGoods() { - Shop_c* shop = Save_GetPointer(shop); - mActor_name_t* items = shop->items; - int i; + Shop_c* shop = Save_GetPointer(shop); + mActor_name_t* items = shop->items; + int i; - for (i = 0; i < mSP_GOODS_COUNT; i++) { - *items++ = EMPTY_NO; - } + for (i = 0; i < mSP_GOODS_COUNT; i++) { + *items++ = EMPTY_NO; + } } extern void mSP_ExchangeLineUp_ZeldaMalloc() { - mSP_InitGoods(); - mSP_MakeGoodsList(NULL); - mSP_SetExchangeDay(); + mSP_InitGoods(); + mSP_MakeGoodsList(NULL); + mSP_SetExchangeDay(); } extern void mSP_LotteryLineUp_ZeldaMalloc() { - mSP_MakeLotteryList(NULL); + mSP_MakeLotteryList(NULL); } extern void mSP_ExchangeLineUp_GameAlloc(GAME* game) { - mSP_InitGoods(); - mSP_MakeGoodsList(game); - mSP_SetExchangeDay(); + mSP_InitGoods(); + mSP_MakeGoodsList(game); + mSP_SetExchangeDay(); } extern void mSP_LotteryLineUp_GameAlloc(GAME* game) { - mSP_MakeLotteryList(game); + mSP_MakeLotteryList(game); } extern void mSP_InitShopSaveData() { - Shop_c* shop = Save_GetPointer(shop); - PersonalID_c* pid = shop->unused_ids; - mActor_name_t* lottery_items = shop->lottery_items; - int i = 0; + Shop_c* shop = Save_GetPointer(shop); + PersonalID_c* pid = shop->unused_ids; + mActor_name_t* lottery_items = shop->lottery_items; + int i = 0; - while (i < mSP_PERSONAL_ID_COUNT) { - mPr_ClearPersonalID(pid); - pid++; - i++; - } + while (i < mSP_PERSONAL_ID_COUNT) { + mPr_ClearPersonalID(pid); + pid++; + i++; + } - mSP_InitGoods(); - Save_Get(shop).rare_item = EMPTY_NO; + mSP_InitGoods(); + Save_Get(shop).rare_item = EMPTY_NO; - for (i = 0; i < mSP_LOTTERY_ITEM_COUNT; i++) { - lottery_items[0] = EMPTY_NO; - lottery_items++; - } + for (i = 0; i < mSP_LOTTERY_ITEM_COUNT; i++) { + lottery_items[0] = EMPTY_NO; + lottery_items++; + } - Save_Get(shop).flowers_candy_grab_bag_count = 0; - shop->sales_sum = 0; - shop->exchange_time = Common_Get(time.rtc_time); - shop->exchange_time.month--; - shop->shop_info.shop_level = mSP_SHOP_TYPE_ZAKKA; - shop->renewal_time = shop->exchange_time; - shop->shop_info.upgrading_today = FALSE; - Save_Get(shop).visitor_flag = FALSE; + Save_Get(shop).flowers_candy_grab_bag_count = 0; + shop->sales_sum = 0; + shop->exchange_time = Common_Get(time.rtc_time); + shop->exchange_time.month--; + shop->shop_info.shop_level = mSP_SHOP_TYPE_ZAKKA; + shop->renewal_time = shop->exchange_time; + shop->shop_info.upgrading_today = FALSE; + Save_Get(shop).visitor_flag = FALSE; } static void mSP_DecideUniqueCommonList(mSP_goods_priority_list_c* priority_list) { - static mSP_goods_priority_list_c priority_candidate[6] = { - { mSP_PRIORITY_COMMON, mSP_PRIORITY_UNCOMMON, mSP_PRIORITY_RARE, 0 }, - { mSP_PRIORITY_COMMON, mSP_PRIORITY_RARE, mSP_PRIORITY_UNCOMMON, 0 }, - { mSP_PRIORITY_UNCOMMON, mSP_PRIORITY_COMMON, mSP_PRIORITY_RARE, 0 }, - { mSP_PRIORITY_RARE, mSP_PRIORITY_COMMON, mSP_PRIORITY_UNCOMMON, 0 }, - { mSP_PRIORITY_RARE, mSP_PRIORITY_UNCOMMON, mSP_PRIORITY_COMMON, 0 }, - { mSP_PRIORITY_UNCOMMON, mSP_PRIORITY_RARE, mSP_PRIORITY_COMMON, 0 } - }; + static mSP_goods_priority_list_c priority_candidate[6] = { + { mSP_PRIORITY_COMMON, mSP_PRIORITY_UNCOMMON, mSP_PRIORITY_RARE, 0 }, + { mSP_PRIORITY_COMMON, mSP_PRIORITY_RARE, mSP_PRIORITY_UNCOMMON, 0 }, + { mSP_PRIORITY_UNCOMMON, mSP_PRIORITY_COMMON, mSP_PRIORITY_RARE, 0 }, + { mSP_PRIORITY_RARE, mSP_PRIORITY_COMMON, mSP_PRIORITY_UNCOMMON, 0 }, + { mSP_PRIORITY_RARE, mSP_PRIORITY_UNCOMMON, mSP_PRIORITY_COMMON, 0 }, + { mSP_PRIORITY_UNCOMMON, mSP_PRIORITY_RARE, mSP_PRIORITY_COMMON, 0 } + }; - priority_list[0] = priority_candidate[RANDOM(6)]; + priority_list[0] = priority_candidate[RANDOM(6)]; } static void mSP_DecideGoodsCommonList() { - mSP_goods_priority_list_c* priority_lists = Save_Get(shop).priority_lists; + mSP_goods_priority_list_c* priority_lists = Save_Get(shop).priority_lists; - mSP_DecideUniqueCommonList(&priority_lists[mSP_KIND_FURNITURE]); - mSP_DecideUniqueCommonList(&priority_lists[mSP_KIND_PAPER]); - mSP_DecideUniqueCommonList(&priority_lists[mSP_KIND_CLOTH]); - mSP_DecideUniqueCommonList(&priority_lists[mSP_KIND_CARPET]); - mSP_DecideUniqueCommonList(&priority_lists[mSP_KIND_WALLPAPER]); + mSP_DecideUniqueCommonList(&priority_lists[mSP_KIND_FURNITURE]); + mSP_DecideUniqueCommonList(&priority_lists[mSP_KIND_PAPER]); + mSP_DecideUniqueCommonList(&priority_lists[mSP_KIND_CLOTH]); + mSP_DecideUniqueCommonList(&priority_lists[mSP_KIND_CARPET]); + mSP_DecideUniqueCommonList(&priority_lists[mSP_KIND_WALLPAPER]); } extern void mSP_ShopGameStartCt(GAME* game) { - mSP_DecideGoodsCommonList(); - mSP_InitShopSaveData(); - mSP_ExchangeLineUp_InGame(game); + mSP_DecideGoodsCommonList(); + mSP_InitShopSaveData(); + mSP_ExchangeLineUp_InGame(game); } extern mActor_name_t mSP_GetNowShopBgNum() { - switch (Save_Get(scene_no)) { - case SCENE_SHOP0: - { - if (Common_Get(tanuki_shop_status) == mSP_TANUKI_SHOP_STATUS_FUKUBIKI) { - return 0xFA; - } + switch (Save_Get(scene_no)) { + case SCENE_SHOP0: { + if (Common_Get(tanuki_shop_status) == mSP_TANUKI_SHOP_STATUS_FUKUBIKI) { + return 0xFA; + } - return 0xF8; + return 0xF8; + } + + case SCENE_CONVENI: { + if (Common_Get(tanuki_shop_status) == mSP_TANUKI_SHOP_STATUS_FUKUBIKI) { + return 0xFB; + } + + return 0xFE; + } + + case SCENE_SUPER: { + if (Common_Get(tanuki_shop_status) == mSP_TANUKI_SHOP_STATUS_FUKUBIKI) { + return 0xFC; + } + + return 0x102; + } + + case SCENE_DEPART: { + if (Common_Get(tanuki_shop_status) == mSP_TANUKI_SHOP_STATUS_FUKUBIKI) { + return 0xFD; + } + + return 0x100; + } + + case SCENE_DEPART_2: + return 0x101; + + default: + return 0xFE; } - - case SCENE_CONVENI: - { - if (Common_Get(tanuki_shop_status) == mSP_TANUKI_SHOP_STATUS_FUKUBIKI) { - return 0xFB; - } - - return 0xFE; - } - - case SCENE_SUPER: - { - if (Common_Get(tanuki_shop_status) == mSP_TANUKI_SHOP_STATUS_FUKUBIKI) { - return 0xFC; - } - - return 0x102; - } - - case SCENE_DEPART: - { - if (Common_Get(tanuki_shop_status) == mSP_TANUKI_SHOP_STATUS_FUKUBIKI) { - return 0xFD; - } - - return 0x100; - } - - case SCENE_DEPART_2: - return 0x101; - - default: - return 0xFE; - } } static int mSP_what_special_sale; extern int mSP_WhatSpecialSale() { - return mSP_what_special_sale; + return mSP_what_special_sale; } extern mActor_name_t mSP_GetNowShopFgNum() { - int event_kind = Save_Get(event_save_data).special.event.bargin.kind; - - switch (Save_Get(scene_no)) { - case SCENE_SHOP0: - { - if (Common_Get(tanuki_shop_status) == mSP_TANUKI_SHOP_STATUS_EVENT) { - if (event_kind == mSP_KIND_FURNITURE) { - mSP_what_special_sale = mSP_KIND_FURNITURE; - return 0x163; + int event_kind = Save_Get(event_save_data).special.event.bargin.kind; + + switch (Save_Get(scene_no)) { + case SCENE_SHOP0: { + if (Common_Get(tanuki_shop_status) == mSP_TANUKI_SHOP_STATUS_EVENT) { + if (event_kind == mSP_KIND_FURNITURE) { + mSP_what_special_sale = mSP_KIND_FURNITURE; + return 0x163; + } + + if (event_kind == mSP_KIND_CLOTH) { + mSP_what_special_sale = mSP_KIND_CLOTH; + return 0x166; + } + + if (event_kind == mSP_KIND_WALLPAPER) { + mSP_what_special_sale = mSP_KIND_WALLPAPER; + return 0x165; + } + + mSP_what_special_sale = mSP_KIND_CARPET; + return 0x164; + } + + if (Common_Get(tanuki_shop_status) == mSP_TANUKI_SHOP_STATUS_FUKUBIKI) { + return 0x14D; + } + + return 0x22; } - if (event_kind == mSP_KIND_CLOTH) { - mSP_what_special_sale = mSP_KIND_CLOTH; - return 0x166; + case SCENE_CONVENI: { + if (Common_Get(tanuki_shop_status) == mSP_TANUKI_SHOP_STATUS_EVENT) { + if (Save_Get(event_save_data).special.event.bargin.kind == mSP_KIND_FURNITURE) { + mSP_what_special_sale = mSP_KIND_FURNITURE; + return 0x167; + } + + if (Save_Get(event_save_data).special.event.bargin.kind == mSP_KIND_CLOTH) { + mSP_what_special_sale = mSP_KIND_CLOTH; + return 0x16A; + } + + if (Save_Get(event_save_data).special.event.bargin.kind == mSP_KIND_WALLPAPER) { + mSP_what_special_sale = mSP_KIND_WALLPAPER; + return 0x169; + } + + mSP_what_special_sale = mSP_KIND_CARPET; + return 0x168; + } + + if (Common_Get(tanuki_shop_status) == mSP_TANUKI_SHOP_STATUS_FUKUBIKI) { + return 0x14E; + } + + return 0x23; } - if (event_kind == mSP_KIND_WALLPAPER) { - mSP_what_special_sale = mSP_KIND_WALLPAPER; - return 0x165; + case SCENE_SUPER: { + if (Common_Get(tanuki_shop_status) == mSP_TANUKI_SHOP_STATUS_EVENT) { + if (Save_Get(event_save_data).special.event.bargin.kind == mSP_KIND_FURNITURE) { + mSP_what_special_sale = mSP_KIND_FURNITURE; + return 0x16B; + } + + if (Save_Get(event_save_data).special.event.bargin.kind == mSP_KIND_CLOTH) { + mSP_what_special_sale = mSP_KIND_CLOTH; + return 0x16E; + } + + if (Save_Get(event_save_data).special.event.bargin.kind == mSP_KIND_WALLPAPER) { + mSP_what_special_sale = mSP_KIND_WALLPAPER; + return 0x16D; + } + + mSP_what_special_sale = mSP_KIND_CARPET; + return 0x16C; + } + + if (Common_Get(tanuki_shop_status) == mSP_TANUKI_SHOP_STATUS_FUKUBIKI) { + return 0x14F; + } + + return 0x24; } - mSP_what_special_sale = mSP_KIND_CARPET; - return 0x164; - } + case SCENE_DEPART: { + if (Common_Get(tanuki_shop_status) == mSP_TANUKI_SHOP_STATUS_EVENT) { + return 0x16F; + } - if (Common_Get(tanuki_shop_status) == mSP_TANUKI_SHOP_STATUS_FUKUBIKI) { - return 0x14D; - } + if (Common_Get(tanuki_shop_status) == mSP_TANUKI_SHOP_STATUS_FUKUBIKI) { + return 0x150; + } - return 0x22; + return 0x25; + } + + case SCENE_DEPART_2: { + if (Common_Get(tanuki_shop_status) == mSP_TANUKI_SHOP_STATUS_EVENT) { + if (Save_Get(event_save_data).special.event.bargin.kind == mSP_KIND_FURNITURE) { + mSP_what_special_sale = mSP_KIND_FURNITURE; + return 0x170; + } + + if (Save_Get(event_save_data).special.event.bargin.kind == mSP_KIND_CLOTH) { + mSP_what_special_sale = mSP_KIND_CLOTH; + return 0x173; + } + + if (Save_Get(event_save_data).special.event.bargin.kind == mSP_KIND_WALLPAPER) { + mSP_what_special_sale = mSP_KIND_WALLPAPER; + return 0x172; + } + + mSP_what_special_sale = mSP_KIND_CARPET; + return 0x171; + } + + return 0x26; + } + + default: + return 0x25; } - - case SCENE_CONVENI: - { - if (Common_Get(tanuki_shop_status) == mSP_TANUKI_SHOP_STATUS_EVENT) { - if (Save_Get(event_save_data).special.event.bargin.kind == mSP_KIND_FURNITURE) { - mSP_what_special_sale = mSP_KIND_FURNITURE; - return 0x167; - } - - if (Save_Get(event_save_data).special.event.bargin.kind == mSP_KIND_CLOTH) { - mSP_what_special_sale = mSP_KIND_CLOTH; - return 0x16A; - } - - if (Save_Get(event_save_data).special.event.bargin.kind == mSP_KIND_WALLPAPER) { - mSP_what_special_sale = mSP_KIND_WALLPAPER; - return 0x169; - } - - mSP_what_special_sale = mSP_KIND_CARPET; - return 0x168; - } - - if (Common_Get(tanuki_shop_status) == mSP_TANUKI_SHOP_STATUS_FUKUBIKI) { - return 0x14E; - } - - return 0x23; - } - - case SCENE_SUPER: - { - if (Common_Get(tanuki_shop_status) == mSP_TANUKI_SHOP_STATUS_EVENT) { - if (Save_Get(event_save_data).special.event.bargin.kind == mSP_KIND_FURNITURE) { - mSP_what_special_sale = mSP_KIND_FURNITURE; - return 0x16B; - } - - if (Save_Get(event_save_data).special.event.bargin.kind == mSP_KIND_CLOTH) { - mSP_what_special_sale = mSP_KIND_CLOTH; - return 0x16E; - } - - if (Save_Get(event_save_data).special.event.bargin.kind == mSP_KIND_WALLPAPER) { - mSP_what_special_sale = mSP_KIND_WALLPAPER; - return 0x16D; - } - - mSP_what_special_sale = mSP_KIND_CARPET; - return 0x16C; - } - - if (Common_Get(tanuki_shop_status) == mSP_TANUKI_SHOP_STATUS_FUKUBIKI) { - return 0x14F; - } - - return 0x24; - } - - case SCENE_DEPART: - { - if (Common_Get(tanuki_shop_status) == mSP_TANUKI_SHOP_STATUS_EVENT) { - return 0x16F; - } - - if (Common_Get(tanuki_shop_status) == mSP_TANUKI_SHOP_STATUS_FUKUBIKI) { - return 0x150; - } - - return 0x25; - } - - case SCENE_DEPART_2: - { - if (Common_Get(tanuki_shop_status) == mSP_TANUKI_SHOP_STATUS_EVENT) { - if (Save_Get(event_save_data).special.event.bargin.kind == mSP_KIND_FURNITURE) { - mSP_what_special_sale = mSP_KIND_FURNITURE; - return 0x170; - } - - if (Save_Get(event_save_data).special.event.bargin.kind == mSP_KIND_CLOTH) { - mSP_what_special_sale = mSP_KIND_CLOTH; - return 0x173; - } - - if (Save_Get(event_save_data).special.event.bargin.kind == mSP_KIND_WALLPAPER) { - mSP_what_special_sale = mSP_KIND_WALLPAPER; - return 0x172; - } - - mSP_what_special_sale = mSP_KIND_CARPET; - return 0x171; - } - - return 0x26; - } - - default: - return 0x25; - } } extern lbRTC_hour_t mSP_GetShopOpenTime() { - static lbRTC_hour_t shop_open_time_table[mSP_SHOP_TYPE_NUM] = { - 9, - 7, - 9, - 9 - }; + static lbRTC_hour_t shop_open_time_table[mSP_SHOP_TYPE_NUM] = { 9, 7, 9, 9 }; - int shop_level = mSP_GetShopLevel(); + int shop_level = mSP_GetShopLevel(); - if (Common_Get(time.rtc_time).day == lbRTC_GetDaysByMonth(Common_Get(time.rtc_time).year, Common_Get(time.rtc_time).month)) { - return 10; // lottery starts at 10AM - } - else { - return shop_open_time_table[shop_level]; - } + if (Common_Get(time.rtc_time).day == + lbRTC_GetDaysByMonth(Common_Get(time.rtc_time).year, Common_Get(time.rtc_time).month)) { + return 10; // lottery starts at 10AM + } else { + return shop_open_time_table[shop_level]; + } } extern lbRTC_hour_t mSP_GetShopCloseTime() { - static lbRTC_hour_t shop_close_time_table[mSP_SHOP_TYPE_NUM] = { - 22, - 23, - 22, - 22 - }; + static lbRTC_hour_t shop_close_time_table[mSP_SHOP_TYPE_NUM] = { 22, 23, 22, 22 }; - return shop_close_time_table[mSP_GetShopLevel()]; + return shop_close_time_table[mSP_GetShopLevel()]; } extern lbRTC_hour_t mSP_GetShopCloseTime_Bgm() { - static lbRTC_hour_t shop_close_time_table[mSP_SHOP_TYPE_NUM] = { - 22, - 23, - 22, - 22 - }; + static lbRTC_hour_t shop_close_time_table[mSP_SHOP_TYPE_NUM] = { 22, 23, 22, 22 }; - return shop_close_time_table[mSP_GetShopLevel()]; + return shop_close_time_table[mSP_GetShopLevel()]; } extern int mSP_InRenewal() { - if (mEv_CheckEvent(mEv_SAVED_RENEWSHOP) == TRUE) { - lbRTC_time_c renew_time = Save_Get(shop).renewal_time; - lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); + if (mEv_CheckEvent(mEv_SAVED_RENEWSHOP) == TRUE) { + lbRTC_time_c renew_time = Save_Get(shop).renewal_time; + lbRTC_time_c* rtc_time = Common_GetPointer(time.rtc_time); - lbRTC_Sub_DD(&renew_time, 1); + lbRTC_Sub_DD(&renew_time, 1); - if ( - lbRTC_IsOverTime(&renew_time, rtc_time) == lbRTC_OVER || - lbRTC_IsEqualTime(rtc_time, &renew_time, lbRTC_CHECK_YEARS | lbRTC_CHECK_MONTHS | lbRTC_CHECK_DAYS) != FALSE - ) { - return TRUE; + if (lbRTC_IsOverTime(&renew_time, rtc_time) == lbRTC_OVER || + lbRTC_IsEqualTime(rtc_time, &renew_time, lbRTC_CHECK_YEARS | lbRTC_CHECK_MONTHS | lbRTC_CHECK_DAYS) != + FALSE) { + return TRUE; + } } - } - return FALSE; + return FALSE; } /* @unused size: 0xF0 */ // int mSP_CheckSpecialSalesSoldOut(...) extern int mSP_ShopOpen() { - lbRTC_time_c rtc_time = Common_Get(time.rtc_time); - lbRTC_hour_t now_hour; + lbRTC_time_c rtc_time = Common_Get(time.rtc_time); + lbRTC_hour_t now_hour; - if (mEv_CheckFirstJob()) { - return mSP_SHOP_STATUS_OPEN; // shop is forcefully open during chores - } - - if (mEv_CheckEvent(mEv_SPNPC_SHOP) == TRUE) { - lbRTC_time_c bargin_time = Save_Get(event_save_data).special.event.bargin.start_time; - - if (bargin_time.day == rtc_time.day) { - lbRTC_time_c end_time = Save_Get(event_save_data).special.event.bargin.end_time; - lbRTC_time_c start_time_pre = bargin_time; - lbRTC_time_c end_time_post = end_time; - now_hour = rtc_time.hour; - - lbRTC_Sub_hh(&start_time_pre, 1); - lbRTC_Add_hh(&end_time_post, 1); - - if (now_hour >= mTM_FIELD_RENEW_HOUR && now_hour < mSP_GetShopOpenTime()) { - return mSP_SHOP_STATUS_PRE; - } - - if (now_hour < mTM_FIELD_RENEW_HOUR || now_hour >= mSP_GetShopCloseTime()) { - return mSP_SHOP_STATUS_END; - } - - if (lbRTC_IsOverTime(&start_time_pre, &rtc_time) == lbRTC_LESS) { - return mSP_SHOP_STATUS_OPEN; - } - - if (lbRTC_IsOverTime(&bargin_time, &rtc_time) == lbRTC_LESS) { - return mSP_SHOP_STATUS_PREEVENT; - } - - if (lbRTC_IsOverTime(&end_time, &rtc_time) == lbRTC_LESS) { - return mSP_SHOP_STATUS_OPENEVENT; - } - - if (lbRTC_IsOverTime(&end_time_post, &rtc_time) == lbRTC_LESS) { - return mSP_SHOP_STATUS_ENDEVENT; - } - - return mSP_SHOP_STATUS_OPEN; + if (mEv_CheckFirstJob()) { + return mSP_SHOP_STATUS_OPEN; // shop is forcefully open during chores } - } - now_hour = rtc_time.hour; + if (mEv_CheckEvent(mEv_SPNPC_SHOP) == TRUE) { + lbRTC_time_c bargin_time = Save_Get(event_save_data).special.event.bargin.start_time; - if (mSP_InRenewal() != FALSE) { - return mSP_SHOP_STATUS_RENEW; - } + if (bargin_time.day == rtc_time.day) { + lbRTC_time_c end_time = Save_Get(event_save_data).special.event.bargin.end_time; + lbRTC_time_c start_time_pre = bargin_time; + lbRTC_time_c end_time_post = end_time; + now_hour = rtc_time.hour; - if (now_hour >= mSP_GetShopOpenTime() && now_hour < mSP_GetShopCloseTime()) { - return mSP_SHOP_STATUS_OPEN; - } + lbRTC_Sub_hh(&start_time_pre, 1); + lbRTC_Add_hh(&end_time_post, 1); - if (now_hour >= mTM_FIELD_RENEW_HOUR && now_hour < mSP_GetShopOpenTime()) { - return mSP_SHOP_STATUS_PRE; - } + if (now_hour >= mTM_FIELD_RENEW_HOUR && now_hour < mSP_GetShopOpenTime()) { + return mSP_SHOP_STATUS_PRE; + } - return mSP_SHOP_STATUS_END; + if (now_hour < mTM_FIELD_RENEW_HOUR || now_hour >= mSP_GetShopCloseTime()) { + return mSP_SHOP_STATUS_END; + } + + if (lbRTC_IsOverTime(&start_time_pre, &rtc_time) == lbRTC_LESS) { + return mSP_SHOP_STATUS_OPEN; + } + + if (lbRTC_IsOverTime(&bargin_time, &rtc_time) == lbRTC_LESS) { + return mSP_SHOP_STATUS_PREEVENT; + } + + if (lbRTC_IsOverTime(&end_time, &rtc_time) == lbRTC_LESS) { + return mSP_SHOP_STATUS_OPENEVENT; + } + + if (lbRTC_IsOverTime(&end_time_post, &rtc_time) == lbRTC_LESS) { + return mSP_SHOP_STATUS_ENDEVENT; + } + + return mSP_SHOP_STATUS_OPEN; + } + } + + now_hour = rtc_time.hour; + + if (mSP_InRenewal() != FALSE) { + return mSP_SHOP_STATUS_RENEW; + } + + if (now_hour >= mSP_GetShopOpenTime() && now_hour < mSP_GetShopCloseTime()) { + return mSP_SHOP_STATUS_OPEN; + } + + if (now_hour >= mTM_FIELD_RENEW_HOUR && now_hour < mSP_GetShopOpenTime()) { + return mSP_SHOP_STATUS_PRE; + } + + return mSP_SHOP_STATUS_END; } extern void mSP_RandomHaniwaSelect(mActor_name_t* haniwa_list, int count) { - int i; + int i; - for (i = 0; i < count; i++) { - haniwa_list[i] = EMPTY_NO; - } - - for (i = 0; i < count; i++) { - int set = FALSE; - - while (!set) { - mActor_name_t haniwa = HANIWA_START + (mActor_name_t)FTR_NO_2_IDX(RANDOM(HANIWA_NUM)); - - if (mSP_GoodsExistAlready(haniwa_list, count, haniwa) == FALSE) { - haniwa_list[i] = haniwa; - set = TRUE; - } - else if (count > HANIWA_NUM) { - haniwa_list[i] = haniwa; - set = TRUE; - } + for (i = 0; i < count; i++) { + haniwa_list[i] = EMPTY_NO; + } + + for (i = 0; i < count; i++) { + int set = FALSE; + + while (!set) { + mActor_name_t haniwa = HANIWA_START + (mActor_name_t)FTR_NO_2_IDX(RANDOM(HANIWA_NUM)); + + if (mSP_GoodsExistAlready(haniwa_list, count, haniwa) == FALSE) { + haniwa_list[i] = haniwa; + set = TRUE; + } else if (count > HANIWA_NUM) { + haniwa_list[i] = haniwa; + set = TRUE; + } + } } - } } extern void mSP_RandomMDSelect(mActor_name_t* md_list, int count) { - int i; + int i; - for (i = 0; i < count; i++) { - md_list[i] = EMPTY_NO; - } - - for (i = 0; i < count; i++) { - int set = FALSE; - - while (!set) { - mActor_name_t md = ITM_MINIDISK_START + RANDOM(NOT_SECRET_MD_NUM); - - if (mSP_GoodsExistAlready(md_list, count, md) == FALSE) { - md_list[i] = md; - set = TRUE; - } - else if (count > NOT_SECRET_MD_NUM) { - md_list[i] = md; - set = TRUE; - } + for (i = 0; i < count; i++) { + md_list[i] = EMPTY_NO; + } + + for (i = 0; i < count; i++) { + int set = FALSE; + + while (!set) { + mActor_name_t md = ITM_MINIDISK_START + RANDOM(NOT_SECRET_MD_NUM); + + if (mSP_GoodsExistAlready(md_list, count, md) == FALSE) { + md_list[i] = md; + set = TRUE; + } else if (count > NOT_SECRET_MD_NUM) { + md_list[i] = md; + set = TRUE; + } + } } - } } extern void mSP_RandomUmbSelect(mActor_name_t* umb_list, int count) { - int i; + int i; - for (i = 0; i < count; i++) { - umb_list[i] = EMPTY_NO; - } - - for (i = 0; i < count; i++) { - int set = FALSE; - - while (!set) { - mActor_name_t umb = ITM_UMBRELLA00 + RANDOM(UMBRELLA_NUM); - - if (mSP_GoodsExistAlready(umb_list, count, umb) == FALSE) { - umb_list[i] = umb; - set = TRUE; - } - else if (count > UMBRELLA_NUM) { - umb_list[i] = umb; - set = TRUE; - } + for (i = 0; i < count; i++) { + umb_list[i] = EMPTY_NO; + } + + for (i = 0; i < count; i++) { + int set = FALSE; + + while (!set) { + mActor_name_t umb = ITM_UMBRELLA00 + RANDOM(UMBRELLA_NUM); + + if (mSP_GoodsExistAlready(umb_list, count, umb) == FALSE) { + umb_list[i] = umb; + set = TRUE; + } else if (count > UMBRELLA_NUM) { + umb_list[i] = umb; + set = TRUE; + } + } } - } } static int mSP_CountBirth(u8 birth_type) { - int count = 0; - u8* birth_type_p = mRmTp_CheckFtrBirthInfoTop(); - int i; - - for (i = 0; i < FTR_NUM; i++) { - if (birth_type_p[0] == birth_type) { - count++; - } - - birth_type_p++; - } - - return count; -} - -static mActor_name_t mSP_FtrBirthIdx2ItemNo(u8 birth_type, int birth_idx) { - int count = 0; - u8* birth_type_p = mRmTp_CheckFtrBirthInfoTop(); - int i; - - for (i = 0; i < FTR_NUM; i++) { - if (birth_type_p[0] == birth_type) { - if (count == birth_idx) { - return mRmTp_FtrIdx2FtrItemNo(i, mRmTp_DIRECT_SOUTH); - } - - count++; - } - - birth_type_p++; - } - - return FTR_DINO_TREX_SKULL; -} - -extern mActor_name_t mSP_RandomOneFossilSelect(int multi_fossil) { - u8 birth_type = multi_fossil == FALSE ? mRmTp_BIRTH_TYPE_SINGLE_FOSSIL : mRmTp_BIRTH_TYPE_MULTI_FOSSIL; - int count = mSP_CountBirth(birth_type); - - return mSP_FtrBirthIdx2ItemNo(birth_type, RANDOM(count)); -} - -extern int mSP_Chk_HukubukuroSail() { - lbRTC_time_c rtc_time = Common_Get(time.rtc_time); - lbRTC_year_t year = rtc_time.year; - lbRTC_month_t month = rtc_time.month; - lbRTC_day_t day = rtc_time.day; - - if (month == lbRTC_NOVEMBER) { - int black_friday = lbRTC_Weekly_day(year, lbRTC_NOVEMBER, 4, lbRTC_THURSDAY) + 1; - - if (black_friday == day) { - return TRUE; - } - } - - return FALSE; -} - -extern int mSP_CheckFukubikiDay() { - lbRTC_time_c rtc_time = Common_Get(time.rtc_time); - lbRTC_year_t year = rtc_time.year; - lbRTC_month_t month = rtc_time.month; - lbRTC_day_t day = rtc_time.day; - lbRTC_day_t days_in_month = lbRTC_GetDaysByMonth(year, month); - - return days_in_month == day; -} - -extern int mSP_SetGoods2ReservedPoint(mActor_name_t goods, mActor_name_t reserved_no) { - mActor_name_t* shop_fg = mFI_BkNumtoUtFGTop(0, 0); - int i; - - for (i = 0; i < UT_TOTAL_NUM; i++) { - if (reserved_no == shop_fg[0]) { - mFI_UtNumtoFGSet_common(goods, i % UT_X_NUM, i / UT_X_NUM, FALSE); - return TRUE; - } - - shop_fg++; - } - - return FALSE; -} - -extern int mSP_CheckHallowinDay() { - int res = FALSE; - lbRTC_time_c rtc_time = Common_Get(time.rtc_time); - lbRTC_month_t month = rtc_time.month; - lbRTC_day_t day = rtc_time.day; - - if ( - month == lbRTC_OCTOBER && - day >= 16 && - day <= 30 - ) { - res = TRUE; - } - - return res; -} - -extern void mSP_SetTanukiShopStatus() { - if (mSP_ShopOpen() == mSP_SHOP_STATUS_OPENEVENT) { - Common_Set(tanuki_shop_status, mSP_TANUKI_SHOP_STATUS_EVENT); - } - else if (mSP_CheckFukubikiDay()) { - Common_Set(tanuki_shop_status, mSP_TANUKI_SHOP_STATUS_FUKUBIKI); - } - else if (mSP_Chk_HukubukuroSail()) { - Common_Set(tanuki_shop_status, mSP_TANUKI_SHOP_STATUS_HUKUBUKURO_SALE); - } - else if (mSP_CheckHallowinDay()) { - Common_Set(tanuki_shop_status, mSP_TANUKI_SHOP_STATUS_HALLOWEEN); - } - else { - Common_Set(tanuki_shop_status, mSP_TANUKI_SHOP_STATUS_NORMAL); - } -} - -static u32 mSP_sack_amount[MONEY_NUM] = { - 100, - 1000, - 10000, - 30000 -}; - -static mActor_name_t mSP_itemNo[MONEY_NUM] = { - ITM_MONEY_100, - ITM_MONEY_1000, - ITM_MONEY_10000, - ITM_MONEY_30000 -}; - -extern int mSP_money_check(u32 amount) { - u32 money = Common_Get(now_private)->inventory.wallet; - int res = FALSE; - - if (money < amount) { + int count = 0; + u8* birth_type_p = mRmTp_CheckFtrBirthInfoTop(); int i; - for (i = 0; i < MONEY_NUM; i++) { - int sack_num = mPr_GetPossessionItemSumWithCond(Common_Get(now_private), mSP_itemNo[i], mPr_ITEM_COND_NORMAL); + for (i = 0; i < FTR_NUM; i++) { + if (birth_type_p[0] == birth_type) { + count++; + } - money += sack_num * mSP_sack_amount[i]; - if (money >= amount) { - res = TRUE; - break; - } - } - } - else { - res = TRUE; - } - - return res; -} - -static u32 mSP_get_sell_price_sub(u32 money, u32 amount) { - u32 sack_num; - int i; - - for (i = 0; i < MONEY_NUM; i++) { - for (sack_num = mPr_GetPossessionItemSumWithCond(Common_Get(now_private), mSP_itemNo[i], mPr_ITEM_COND_NORMAL); sack_num != 0; sack_num--) { - int sack_idx = mPr_GetPossessionItemIdxWithCond(Common_Get(now_private), mSP_itemNo[i], mPr_ITEM_COND_NORMAL); - - mPr_SetPossessionItem(Common_Get(now_private), sack_idx, EMPTY_NO, mPr_ITEM_COND_NORMAL); - money += mSP_sack_amount[i]; - - if (money >= amount) { - return money - amount; - } - } - } - - return 0; -} - -extern void mSP_get_sell_price(u32 amount) { - u32 money = Common_Get(now_private)->inventory.wallet; - - if (money < amount) { - money = mSP_get_sell_price_sub(money, amount); - } - else { - money -= amount; - } - - Common_Get(now_private)->inventory.wallet = money; -} - -static int mSP_GetNonePossessionItemCount_InList(mActor_name_t* list, int category, u32* collect_bitfield) { - mActor_name_t* list_p; - - if (list != NULL) { - int count = 0; - - for (list_p = list; list_p[0] != EMPTY_NO; list_p++) { - int collect_idx; - - if (category == mSP_KIND_FURNITURE) { - collect_idx = mRmTp_FtrItemNo2FtrIdx(list_p[0]); - } - else if (category == mSP_KIND_CARPET) { - collect_idx = list_p[0] - ITM_CARPET_START; - } - else { - collect_idx = list_p[0] - ITM_WALL_START; - } - - if (((collect_bitfield[collect_idx >> 5] >> (collect_idx & 0x1F)) & 1) == 0) { - count++; - } + birth_type_p++; } return count; - } +} - return 0; +static mActor_name_t mSP_FtrBirthIdx2ItemNo(u8 birth_type, int birth_idx) { + int count = 0; + u8* birth_type_p = mRmTp_CheckFtrBirthInfoTop(); + int i; + + for (i = 0; i < FTR_NUM; i++) { + if (birth_type_p[0] == birth_type) { + if (count == birth_idx) { + return mRmTp_FtrIdx2FtrItemNo(i, mRmTp_DIRECT_SOUTH); + } + + count++; + } + + birth_type_p++; + } + + return FTR_DINO_TREX_SKULL; +} + +extern mActor_name_t mSP_RandomOneFossilSelect(int multi_fossil) { + u8 birth_type = multi_fossil == FALSE ? mRmTp_BIRTH_TYPE_SINGLE_FOSSIL : mRmTp_BIRTH_TYPE_MULTI_FOSSIL; + int count = mSP_CountBirth(birth_type); + + return mSP_FtrBirthIdx2ItemNo(birth_type, RANDOM(count)); +} + +extern int mSP_Chk_HukubukuroSail() { + lbRTC_time_c rtc_time = Common_Get(time.rtc_time); + lbRTC_year_t year = rtc_time.year; + lbRTC_month_t month = rtc_time.month; + lbRTC_day_t day = rtc_time.day; + + if (month == lbRTC_NOVEMBER) { + int black_friday = lbRTC_Weekly_day(year, lbRTC_NOVEMBER, 4, lbRTC_THURSDAY) + 1; + + if (black_friday == day) { + return TRUE; + } + } + + return FALSE; +} + +extern int mSP_CheckFukubikiDay() { + lbRTC_time_c rtc_time = Common_Get(time.rtc_time); + lbRTC_year_t year = rtc_time.year; + lbRTC_month_t month = rtc_time.month; + lbRTC_day_t day = rtc_time.day; + lbRTC_day_t days_in_month = lbRTC_GetDaysByMonth(year, month); + + return days_in_month == day; +} + +extern int mSP_SetGoods2ReservedPoint(mActor_name_t goods, mActor_name_t reserved_no) { + mActor_name_t* shop_fg = mFI_BkNumtoUtFGTop(0, 0); + int i; + + for (i = 0; i < UT_TOTAL_NUM; i++) { + if (reserved_no == shop_fg[0]) { + mFI_UtNumtoFGSet_common(goods, i % UT_X_NUM, i / UT_X_NUM, FALSE); + return TRUE; + } + + shop_fg++; + } + + return FALSE; +} + +extern int mSP_CheckHallowinDay() { + int res = FALSE; + lbRTC_time_c rtc_time = Common_Get(time.rtc_time); + lbRTC_month_t month = rtc_time.month; + lbRTC_day_t day = rtc_time.day; + + if (month == lbRTC_OCTOBER && day >= 16 && day <= 30) { + res = TRUE; + } + + return res; +} + +extern void mSP_SetTanukiShopStatus() { + if (mSP_ShopOpen() == mSP_SHOP_STATUS_OPENEVENT) { + Common_Set(tanuki_shop_status, mSP_TANUKI_SHOP_STATUS_EVENT); + } else if (mSP_CheckFukubikiDay()) { + Common_Set(tanuki_shop_status, mSP_TANUKI_SHOP_STATUS_FUKUBIKI); + } else if (mSP_Chk_HukubukuroSail()) { + Common_Set(tanuki_shop_status, mSP_TANUKI_SHOP_STATUS_HUKUBUKURO_SALE); + } else if (mSP_CheckHallowinDay()) { + Common_Set(tanuki_shop_status, mSP_TANUKI_SHOP_STATUS_HALLOWEEN); + } else { + Common_Set(tanuki_shop_status, mSP_TANUKI_SHOP_STATUS_NORMAL); + } +} + +static u32 mSP_sack_amount[MONEY_NUM] = { 100, 1000, 10000, 30000 }; + +static mActor_name_t mSP_itemNo[MONEY_NUM] = { ITM_MONEY_100, ITM_MONEY_1000, ITM_MONEY_10000, ITM_MONEY_30000 }; + +extern int mSP_money_check(u32 amount) { + u32 money = Common_Get(now_private)->inventory.wallet; + int res = FALSE; + + if (money < amount) { + int i; + + for (i = 0; i < MONEY_NUM; i++) { + int sack_num = + mPr_GetPossessionItemSumWithCond(Common_Get(now_private), mSP_itemNo[i], mPr_ITEM_COND_NORMAL); + + money += sack_num * mSP_sack_amount[i]; + if (money >= amount) { + res = TRUE; + break; + } + } + } else { + res = TRUE; + } + + return res; +} + +static u32 mSP_get_sell_price_sub(u32 money, u32 amount) { + u32 sack_num; + int i; + + for (i = 0; i < MONEY_NUM; i++) { + for (sack_num = mPr_GetPossessionItemSumWithCond(Common_Get(now_private), mSP_itemNo[i], mPr_ITEM_COND_NORMAL); + sack_num != 0; sack_num--) { + int sack_idx = + mPr_GetPossessionItemIdxWithCond(Common_Get(now_private), mSP_itemNo[i], mPr_ITEM_COND_NORMAL); + + mPr_SetPossessionItem(Common_Get(now_private), sack_idx, EMPTY_NO, mPr_ITEM_COND_NORMAL); + money += mSP_sack_amount[i]; + + if (money >= amount) { + return money - amount; + } + } + } + + return 0; +} + +extern void mSP_get_sell_price(u32 amount) { + u32 money = Common_Get(now_private)->inventory.wallet; + + if (money < amount) { + money = mSP_get_sell_price_sub(money, amount); + } else { + money -= amount; + } + + Common_Get(now_private)->inventory.wallet = money; +} + +static int mSP_GetNonePossessionItemCount_InList(mActor_name_t* list, int category, u32* collect_bitfield) { + mActor_name_t* list_p; + + if (list != NULL) { + int count = 0; + + for (list_p = list; list_p[0] != EMPTY_NO; list_p++) { + int collect_idx; + + if (category == mSP_KIND_FURNITURE) { + collect_idx = mRmTp_FtrItemNo2FtrIdx(list_p[0]); + } else if (category == mSP_KIND_CARPET) { + collect_idx = list_p[0] - ITM_CARPET_START; + } else { + collect_idx = list_p[0] - ITM_WALL_START; + } + + if (((collect_bitfield[collect_idx >> 5] >> (collect_idx & 0x1F)) & 1) == 0) { + count++; + } + } + + return count; + } + + return 0; } static mActor_name_t mSP_GetNonePossessionItem_InList(mActor_name_t* list, int category, u32* collect_bitfield) { - int none_count = mSP_GetNonePossessionItemCount_InList(list, category, collect_bitfield); + int none_count = mSP_GetNonePossessionItemCount_InList(list, category, collect_bitfield); - if (none_count != 0 && list != NULL) { - int selected_idx = RANDOM(none_count); - mActor_name_t* list_p; - int count = 0; + if (none_count != 0 && list != NULL) { + int selected_idx = RANDOM(none_count); + mActor_name_t* list_p; + int count = 0; - for (list_p = list; list_p[0] != EMPTY_NO; list_p++) { - int collect_idx; + for (list_p = list; list_p[0] != EMPTY_NO; list_p++) { + int collect_idx; - if (category == mSP_KIND_FURNITURE) { - collect_idx = mRmTp_FtrItemNo2FtrIdx(list_p[0]); - } - else if (category == mSP_KIND_CARPET) { - collect_idx = list_p[0] - ITM_CARPET_START; - } - else { - collect_idx = list_p[0] - ITM_WALL_START; - } + if (category == mSP_KIND_FURNITURE) { + collect_idx = mRmTp_FtrItemNo2FtrIdx(list_p[0]); + } else if (category == mSP_KIND_CARPET) { + collect_idx = list_p[0] - ITM_CARPET_START; + } else { + collect_idx = list_p[0] - ITM_WALL_START; + } - if (((collect_bitfield[collect_idx >> 5] >> (collect_idx & 0x1F)) & 1) == 0) { - if (selected_idx == count) { - return list_p[0]; + if (((collect_bitfield[collect_idx >> 5] >> (collect_idx & 0x1F)) & 1) == 0) { + if (selected_idx == count) { + return list_p[0]; + } else { + count++; + } + } } - else { - count++; - } - } } - } - return EMPTY_NO; + return EMPTY_NO; } static mActor_name_t mSP_GetNonePossessionItem_InLotteryFurniture(int player_no) { - return mSP_GetNonePossessionItem_InList( - mSP_ftr_list[mSP_LIST_LOTTERY], - mSP_KIND_FURNITURE, - (player_no >= 0 && player_no < PLAYER_NUM) ? - Save_Get(private[player_no]).furniture_collected_bitfield : - Common_Get(now_private)->furniture_collected_bitfield - ); + return mSP_GetNonePossessionItem_InList(mSP_ftr_list[mSP_LIST_LOTTERY], mSP_KIND_FURNITURE, + (player_no >= 0 && player_no < PLAYER_NUM) + ? Save_Get(private_data[player_no]).furniture_collected_bitfield + : Common_Get(now_private)->furniture_collected_bitfield); } static mActor_name_t mSP_GetNonePossessionItem_InEventFurniture(int player_no) { - return mSP_GetNonePossessionItem_InList( - mSP_ftr_list[mSP_LIST_EVENT], - mSP_KIND_FURNITURE, - (player_no >= 0 && player_no < PLAYER_NUM) ? - Save_Get(private[player_no]).furniture_collected_bitfield : - Common_Get(now_private)->furniture_collected_bitfield - ); + return mSP_GetNonePossessionItem_InList(mSP_ftr_list[mSP_LIST_EVENT], mSP_KIND_FURNITURE, + (player_no >= 0 && player_no < PLAYER_NUM) + ? Save_Get(private_data[player_no]).furniture_collected_bitfield + : Common_Get(now_private)->furniture_collected_bitfield); } /* @fabricated @unused */ static mActor_name_t mSP_GetNonePossessionItem_InEventWall(int player_no) { - return mSP_GetNonePossessionItem_InList( - mSP_ftr_list[mSP_LIST_EVENT], - mSP_KIND_WALLPAPER, - (player_no >= 0 && player_no < PLAYER_NUM) ? - Save_Get(private[player_no]).wall_collected_bitfield : - Common_Get(now_private)->wall_collected_bitfield - ); + return mSP_GetNonePossessionItem_InList(mSP_ftr_list[mSP_LIST_EVENT], mSP_KIND_WALLPAPER, + (player_no >= 0 && player_no < PLAYER_NUM) + ? Save_Get(private_data[player_no]).wall_collected_bitfield + : Common_Get(now_private)->wall_collected_bitfield); } /* @fabricated @unused */ static mActor_name_t mSP_GetNonePossessionItem_InEventCarpet(int player_no) { - return mSP_GetNonePossessionItem_InList( - mSP_ftr_list[mSP_LIST_EVENT], - mSP_KIND_CARPET, - (player_no >= 0 && player_no < PLAYER_NUM) ? - Save_Get(private[player_no]).carpet_collected_bitfield : - Common_Get(now_private)->carpet_collected_bitfield - ); + return mSP_GetNonePossessionItem_InList(mSP_ftr_list[mSP_LIST_EVENT], mSP_KIND_CARPET, + (player_no >= 0 && player_no < PLAYER_NUM) + ? Save_Get(private_data[player_no]).carpet_collected_bitfield + : Common_Get(now_private)->carpet_collected_bitfield); } /* @fabricated @unused */ static mActor_name_t mSP_GetNonePossessionItem_InABCFurniture(int player_no) { - // TODO: check this impl is right using func size -- they probably did the list calc in this func itself - u8 abc_priorities[3]; + // TODO: check this impl is right using func size -- they probably did the list calc in this func itself + u8 abc_priorities[3]; - mSP_GetGoodsPriority(abc_priorities, mSP_KIND_FURNITURE); + mSP_GetGoodsPriority(abc_priorities, mSP_KIND_FURNITURE); - return mSP_GetNonePossessionItem_InList( - mSP_GetItemList(mSP_ftr_list, abc_priorities, mSP_LISTTYPE_ABC), - mSP_KIND_FURNITURE, - (player_no >= 0 && player_no < PLAYER_NUM) ? - Save_Get(private[player_no]).furniture_collected_bitfield : - Common_Get(now_private)->furniture_collected_bitfield - ); + return mSP_GetNonePossessionItem_InList( + mSP_GetItemList(mSP_ftr_list, abc_priorities, mSP_LISTTYPE_ABC), mSP_KIND_FURNITURE, + (player_no >= 0 && player_no < PLAYER_NUM) ? Save_Get(private_data[player_no]).furniture_collected_bitfield + : Common_Get(now_private)->furniture_collected_bitfield); } -typedef mActor_name_t (*mSP_GET_NONE_POSSESSION_ITEM_PROC)(int); +typedef mActor_name_t (*mSP_GET_NONE_POSSESSION_ITEM_PROC)(int); -static mActor_name_t mSP_CarryOutAlternativeRandomSelect(mSP_GET_NONE_POSSESSION_ITEM_PROC proc0, mSP_GET_NONE_POSSESSION_ITEM_PROC proc1, int player_no) { - int rng = RANDOM(100); +static mActor_name_t mSP_CarryOutAlternativeRandomSelect(mSP_GET_NONE_POSSESSION_ITEM_PROC proc0, + mSP_GET_NONE_POSSESSION_ITEM_PROC proc1, int player_no) { + int rng = RANDOM(100); - if ((rng & 1)) { - mActor_name_t item = (*proc0)(player_no); + if ((rng & 1)) { + mActor_name_t item = (*proc0)(player_no); - if (item == EMPTY_NO) { - item = (*proc1)(player_no); + if (item == EMPTY_NO) { + item = (*proc1)(player_no); - if (item != EMPTY_NO) { - return item; - } + if (item != EMPTY_NO) { + return item; + } + } else { + return item; + } + } else { + mActor_name_t item = (*proc1)(player_no); + + if (item == EMPTY_NO) { + item = (*proc0)(player_no); + + if (item != EMPTY_NO) { + return item; + } + } else { + return item; + } } - else { - return item; - } - } - else { - mActor_name_t item = (*proc1)(player_no); - if (item == EMPTY_NO) { - item = (*proc0)(player_no); - - if (item != EMPTY_NO) { - return item; - } - } - else { - return item; - } - } - - return EMPTY_NO; + return EMPTY_NO; } static mActor_name_t mSP_CarryOutAlternativeRandomSelect_NoneNULL(int category0, int list0, int category1, int list1) { - int rng = RANDOM(100); - mActor_name_t item; + int rng = RANDOM(100); + mActor_name_t item; - if ((rng & 1)) { - mSP_SelectRandomItem_New(NULL, &item, 1, NULL, 0, category0, list0, FALSE); - return item; - } - else { - mSP_SelectRandomItem_New(NULL, &item, 1, NULL, 0, category1, list1, FALSE); - return item; - } + if ((rng & 1)) { + mSP_SelectRandomItem_New(NULL, &item, 1, NULL, 0, category0, list0, FALSE); + return item; + } else { + mSP_SelectRandomItem_New(NULL, &item, 1, NULL, 0, category1, list1, FALSE); + return item; + } } /* @unused size: 0xB8 */ // extern mActor_name_t mSP_SelectNpcBirthdayPresent(...) static void mSP_SelectNpcBirthdayPresent() { - // necessary to include for data - static int priority[6][3] = { - { mSP_PRIORITY_COMMON, mSP_PRIORITY_UNCOMMON, mSP_PRIORITY_RARE }, - { mSP_PRIORITY_COMMON, mSP_PRIORITY_RARE, mSP_PRIORITY_RARE }, // lol based on this, I think it should've been common, rare, uncommon - { mSP_PRIORITY_UNCOMMON, mSP_PRIORITY_COMMON, mSP_PRIORITY_RARE }, - { mSP_PRIORITY_UNCOMMON, mSP_PRIORITY_RARE, mSP_PRIORITY_COMMON }, - { mSP_PRIORITY_RARE, mSP_PRIORITY_COMMON, mSP_PRIORITY_UNCOMMON }, - { mSP_PRIORITY_RARE, mSP_PRIORITY_UNCOMMON, mSP_PRIORITY_COMMON } - }; + // necessary to include for data + static int priority[6][3] = { + { mSP_PRIORITY_COMMON, mSP_PRIORITY_UNCOMMON, mSP_PRIORITY_RARE }, + { mSP_PRIORITY_COMMON, mSP_PRIORITY_RARE, + mSP_PRIORITY_RARE }, // lol based on this, I think it should've been common, rare, uncommon + { mSP_PRIORITY_UNCOMMON, mSP_PRIORITY_COMMON, mSP_PRIORITY_RARE }, + { mSP_PRIORITY_UNCOMMON, mSP_PRIORITY_RARE, mSP_PRIORITY_COMMON }, + { mSP_PRIORITY_RARE, mSP_PRIORITY_COMMON, mSP_PRIORITY_UNCOMMON }, + { mSP_PRIORITY_RARE, mSP_PRIORITY_UNCOMMON, mSP_PRIORITY_COMMON } + }; } extern mActor_name_t mSP_SelectFishginPresent(int player_no) { - mActor_name_t item = mSP_CarryOutAlternativeRandomSelect(&mSP_GetNonePossessionItem_InLotteryFurniture, &mSP_GetNonePossessionItem_InEventFurniture, player_no); + mActor_name_t item = mSP_CarryOutAlternativeRandomSelect(&mSP_GetNonePossessionItem_InLotteryFurniture, + &mSP_GetNonePossessionItem_InEventFurniture, player_no); - if (item != EMPTY_NO) { - return item; - } + if (item != EMPTY_NO) { + return item; + } - return mSP_CarryOutAlternativeRandomSelect_NoneNULL(mSP_KIND_FURNITURE, mSP_LISTTYPE_LOTTERY, mSP_KIND_FURNITURE, mSP_LISTTYPE_EVENT); + return mSP_CarryOutAlternativeRandomSelect_NoneNULL(mSP_KIND_FURNITURE, mSP_LISTTYPE_LOTTERY, mSP_KIND_FURNITURE, + mSP_LISTTYPE_EVENT); } -mActor_name_t mSP_gc_famicom_table[8] = { - FTR_FAMICOM_CLU_CLU_LAND, - FTR_FAMICOM_BALLOON_FIGHT, - FTR_FAMICOM_DONKEY_KONG, - FTR_FAMICOM_DK_JR_MATCH, - FTR_FAMICOM_PINBALL, - FTR_FAMICOM_TENNIS, - FTR_FAMICOM_GOLF, - FTR_FAMICOM_EXCITEBIKE -}; +mActor_name_t mSP_gc_famicom_table[8] = { FTR_FAMICOM_CLU_CLU_LAND, FTR_FAMICOM_BALLOON_FIGHT, FTR_FAMICOM_DONKEY_KONG, + FTR_FAMICOM_DK_JR_MATCH, FTR_FAMICOM_PINBALL, FTR_FAMICOM_TENNIS, + FTR_FAMICOM_GOLF, FTR_FAMICOM_EXCITEBIKE }; /* @unused size: 0xDC */ // static mActor_name_t mSP_RandomOneFamicomSelect(...) static mActor_name_t mSP_AGBRandomFamicomSelect() { - mActor_name_t item = EMPTY_NO; + mActor_name_t item = EMPTY_NO; - mSP_SelectRandomItem_New(NULL, &item, 1, NULL, 0, mSP_KIND_FURNITURE, mSP_LISTTYPE_ISLANDFAMICOM, FALSE); - return item; + mSP_SelectRandomItem_New(NULL, &item, 1, NULL, 0, mSP_KIND_FURNITURE, mSP_LISTTYPE_ISLANDFAMICOM, FALSE); + return item; } static mActor_name_t mSP_GetRandomTrash() { - static mActor_name_t trash_table[3] = { ITM_DUST0_EMPTY_CAN, ITM_DUST1_BOOT, ITM_DUST2_OLD_TIRE }; + static mActor_name_t trash_table[3] = { ITM_DUST0_EMPTY_CAN, ITM_DUST1_BOOT, ITM_DUST2_OLD_TIRE }; - return trash_table[RANDOM(3)]; + return trash_table[RANDOM(3)]; } static void mSP_SelectRandomItemToAGB_Unit(mActor_name_t* item, xyz_t* wpos, int ut_x, int ut_z) { - switch (item[0]) { - case 0xFEB2: - { - item[0] = mSP_GetRandomTrash(); - break; + switch (item[0]) { + case 0xFEB2: { + item[0] = mSP_GetRandomTrash(); + break; + } + + case 0xFEA1: { + mSP_SelectRandomItem_New(NULL, item, 1, NULL, 0, mSP_KIND_FURNITURE, mSP_LISTTYPE_COMMON, FALSE); + break; + } + + case 0xFEA2: { + mSP_SelectRandomItem_New(NULL, item, 1, NULL, 0, mSP_KIND_FURNITURE, mSP_LISTTYPE_RARE, FALSE); + break; + } + + case 0xFEA3: { + if ((RANDOM(10) & 1)) { + mSP_SelectRandomItem_New(NULL, item, 1, NULL, 0, mSP_KIND_FURNITURE, mSP_LISTTYPE_EVENT, FALSE); + } else { + mSP_SelectRandomItem_New(NULL, item, 1, NULL, 0, mSP_KIND_FURNITURE, mSP_LISTTYPE_LOTTERY, FALSE); + } + + break; + } + + case 0xFEA5: { + mSP_SelectRandomItem_New(NULL, item, 1, NULL, 0, mSP_KIND_FURNITURE, mSP_LISTTYPE_ISLAND, FALSE); + break; + } + + case 0xFEA4: { + item[0] = mSP_AGBRandomFamicomSelect(); + break; + } + + case 0xFEA9: { + mSP_RandomUmbSelect(item, 1); + break; + } + + case 0xFEA6: { + item[0] = mSP_RandomOneFossilSelect((RANDOM(4) & 1)); + break; + } + + case 0xFEA7: { + mSP_RandomMDSelect(item, 1); + break; + } + + case 0xFEA8: { + mSP_RandomHaniwaSelect(item, 1); + break; + } + + case 0xFEAA: { + mSP_SelectRandomItem_New(NULL, item, 1, NULL, 0, mSP_KIND_CARPET, mSP_LISTTYPE_COMMON, FALSE); + break; + } + + case 0xFEAB: { + mSP_SelectRandomItem_New(NULL, item, 1, NULL, 0, mSP_KIND_CARPET, mSP_LISTTYPE_RARE, FALSE); + break; + } + + case 0xFEAC: { + mSP_SelectRandomItem_New(NULL, item, 1, NULL, 0, mSP_KIND_WALLPAPER, mSP_LISTTYPE_COMMON, FALSE); + break; + } + + case 0xFEAD: { + mSP_SelectRandomItem_New(NULL, item, 1, NULL, 0, mSP_KIND_WALLPAPER, mSP_LISTTYPE_RARE, FALSE); + break; + } + + case 0xFEAE: { + mSP_SelectRandomItem_New(NULL, item, 1, NULL, 0, mSP_KIND_CLOTH, mSP_LISTTYPE_COMMON, FALSE); + break; + } + + case 0xFEAF: { + mSP_SelectRandomItem_New(NULL, item, 1, NULL, 0, mSP_KIND_CLOTH, mSP_LISTTYPE_RARE, FALSE); + break; + } + + case 0xFEB0: { + int hole_no = mCoBG_GetHoleNumber(*wpos); + + if (hole_no != -1) { + item[0] = HOLE_START + (mActor_name_t)hole_no; + } else { + item[0] = EMPTY_NO; + } + + break; + } + + case 0xFEB1: { + item[0] = ITM_WHITE_PANSY_BAG + RANDOM(FLOWER_NUM); + break; + } + + case ITM_KABU_10: + case ITM_KABU_50: + case ITM_KABU_100: { + item[0] = ITM_KABU_SPOILED; // spoil any turnips + break; + } + + case 0xF11F: { + item[0] = ACTOR_PROP_VILLAGER_SIGNBOARD; + break; + } } - - case 0xFEA1: - { - mSP_SelectRandomItem_New(NULL, item, 1, NULL, 0, mSP_KIND_FURNITURE, mSP_LISTTYPE_COMMON, FALSE); - break; - } - - case 0xFEA2: - { - mSP_SelectRandomItem_New(NULL, item, 1, NULL, 0, mSP_KIND_FURNITURE, mSP_LISTTYPE_RARE, FALSE); - break; - } - - case 0xFEA3: - { - if ((RANDOM(10) & 1)) { - mSP_SelectRandomItem_New(NULL, item, 1, NULL, 0, mSP_KIND_FURNITURE, mSP_LISTTYPE_EVENT, FALSE); - } - else { - mSP_SelectRandomItem_New(NULL, item, 1, NULL, 0, mSP_KIND_FURNITURE, mSP_LISTTYPE_LOTTERY, FALSE); - } - - break; - } - - case 0xFEA5: - { - mSP_SelectRandomItem_New(NULL, item, 1, NULL, 0, mSP_KIND_FURNITURE, mSP_LISTTYPE_ISLAND, FALSE); - break; - } - - case 0xFEA4: - { - item[0] = mSP_AGBRandomFamicomSelect(); - break; - } - - case 0xFEA9: - { - mSP_RandomUmbSelect(item, 1); - break; - } - - case 0xFEA6: - { - item[0] = mSP_RandomOneFossilSelect((RANDOM(4) & 1)); - break; - } - - case 0xFEA7: - { - mSP_RandomMDSelect(item, 1); - break; - } - - case 0xFEA8: - { - mSP_RandomHaniwaSelect(item, 1); - break; - } - - case 0xFEAA: - { - mSP_SelectRandomItem_New(NULL, item, 1, NULL, 0, mSP_KIND_CARPET, mSP_LISTTYPE_COMMON, FALSE); - break; - } - - case 0xFEAB: - { - mSP_SelectRandomItem_New(NULL, item, 1, NULL, 0, mSP_KIND_CARPET, mSP_LISTTYPE_RARE, FALSE); - break; - } - - case 0xFEAC: - { - mSP_SelectRandomItem_New(NULL, item, 1, NULL, 0, mSP_KIND_WALLPAPER, mSP_LISTTYPE_COMMON, FALSE); - break; - } - - case 0xFEAD: - { - mSP_SelectRandomItem_New(NULL, item, 1, NULL, 0, mSP_KIND_WALLPAPER, mSP_LISTTYPE_RARE, FALSE); - break; - } - - case 0xFEAE: - { - mSP_SelectRandomItem_New(NULL, item, 1, NULL, 0, mSP_KIND_CLOTH, mSP_LISTTYPE_COMMON, FALSE); - break; - } - - case 0xFEAF: - { - mSP_SelectRandomItem_New(NULL, item, 1, NULL, 0, mSP_KIND_CLOTH, mSP_LISTTYPE_RARE, FALSE); - break; - } - - case 0xFEB0: - { - int hole_no = mCoBG_GetHoleNumber(*wpos); - - if (hole_no != -1) { - item[0] = HOLE_START + (mActor_name_t)hole_no; - } - else { - item[0] = EMPTY_NO; - } - - break; - } - - case 0xFEB1: - { - item[0] = ITM_WHITE_PANSY_BAG + RANDOM(FLOWER_NUM); - break; - } - - case ITM_KABU_10: - case ITM_KABU_50: - case ITM_KABU_100: - { - item[0] = ITM_KABU_SPOILED; // spoil any turnips - break; - } - - case 0xF11F: - { - item[0] = ACTOR_PROP_VILLAGER_SIGNBOARD; - break; - } - } } #ifndef MUST_MATCH /* @nonmatching - minor float load/store issue with xyz_t.z & weird scheduling issue */ 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; - f32 x_pos; + int i; + int ut_x; + int ut_z; + xyz_t* wpos_p; + mActor_name_t* start_p; + mActor_name_t* item_p; + f32 x_pos; - xyz_t wpos = { 0.0f, 0.0f, 0.0f }; - int bx = 0; - int bz = 0; + xyz_t wpos = { 0.0f, 0.0f, 0.0f }; + int bx = 0; + int bz = 0; - mFI_BlockKind2BkNum(&bx, &bz, mRF_BLOCKKIND_ISLAND_LEFT); + 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; - x_pos = wpos.x; + /* 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]; - for (ut_z = 0; ut_z < UT_Z_NUM; ut_z++) { - wpos.x = x_pos; + 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; + x_pos = wpos.x; - for (ut_x = 0; ut_x < UT_X_NUM; ut_x++) { - // this matches instructions but out of order and wrong registers - mSP_SelectRandomItemToAGB_Unit(item_p, &wpos, ut_x, ut_z); - wpos.x += mFI_UT_WORLDSIZE_X_F; - item_p++; - } + for (ut_z = 0; ut_z < UT_Z_NUM; ut_z++) { + wpos.x = x_pos; - wpos.z += mFI_UT_WORLDSIZE_Z_F; - } - } + for (ut_x = 0; ut_x < UT_X_NUM; ut_x++) { + // this matches instructions but out of order and wrong registers + mSP_SelectRandomItemToAGB_Unit(item_p, &wpos, ut_x, ut_z); + wpos.x += mFI_UT_WORLDSIZE_X_F; + item_p++; + } - /* add correctly placed signboard actor */ - for (i = 0; i < mISL_FG_BLOCK_X_NUM; i++) { - start_p = &Save_Get(island).fgblock[0][i].items[0][0]; - 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++) { - if (item_p[0] == COTTAGE_NPC) { - start_p[((ut_x - 1) & 15) + (((ut_z + 1) & 0xF) << 4)] = ACTOR_PROP_VILLAGER_SIGNBOARD; + wpos.z += mFI_UT_WORLDSIZE_Z_F; } - - item_p++; - } } - } - /* remove incorrectly placed signboard actors */ - for (i = 0; i < mISL_FG_BLOCK_X_NUM; i++) { - start_p = &Save_Get(island).fgblock[0][i].items[0][0]; - item_p = &Save_Get(island).fgblock[0][i].items[0][0]; + /* add correctly placed signboard actor */ + for (i = 0; i < mISL_FG_BLOCK_X_NUM; i++) { + start_p = &Save_Get(island).fgblock[0][i].items[0][0]; + 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++) { - 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; + 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] == 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++) { + start_p = &Save_Get(island).fgblock[0][i].items[0][0]; + 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++) { + 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++; + } } - - item_p++; - } } - } } #else -const xyz_t lbl_806432b4 = {0.0f, 0.0f, 0.0f}; +const xyz_t lbl_806432b4 = { 0.0f, 0.0f, 0.0f }; REL_SYMBOL_AT(lbl_806432b4, 0x806432b4) #include "orderfloats/806432c0_806432c8.inc" extern asm void mSP_SelectRandomItemToAGB() { - #include "asm/803ebb44.s" +#include "asm/803ebb44.s" } #endif extern const char* mSP_ShopStatus2String(int status) { - static char dummy[] = "hahaha"; + static char dummy[] = "hahaha"; - static char* str_table[mSP_SHOP_STATUS_NUM] = { - "Pre", - "End", - "Opn", - "Rnw", - "PreEv", - "EndEv", - "OpnEv" - }; + static char* str_table[mSP_SHOP_STATUS_NUM] = { "Pre", "End", "Opn", "Rnw", "PreEv", "EndEv", "OpnEv" }; - if (status >= 0 && status < mSP_SHOP_STATUS_NUM) { - return str_table[status]; - } + if (status >= 0 && status < mSP_SHOP_STATUS_NUM) { + return str_table[status]; + } - return dummy; + return dummy; } extern mActor_name_t mSP_GetRandomStationToyItemNo() { - /* TODO: where does this go? DnM+ indicates no unused functions after this, but data appears after str_table in mSP_ShopStatus2String */ - static mActor_name_t train[2] = { - FTR_LOCOMOTIVE_MODEL, FTR_TRAIN_CAR_MODEL - }; + /* TODO: where does this go? DnM+ indicates no unused functions after this, but data appears after str_table in + * mSP_ShopStatus2String */ + static mActor_name_t train[2] = { FTR_LOCOMOTIVE_MODEL, FTR_TRAIN_CAR_MODEL }; - /* TODO: furniture item index enum/defines */ - return mRmTp_FtrIdx2FtrItemNo(0x42A + RANDOM(15), mRmTp_DIRECT_SOUTH); + /* TODO: furniture item index enum/defines */ + return mRmTp_FtrIdx2FtrItemNo(0x42A + RANDOM(15), mRmTp_DIRECT_SOUTH); } #include "../src/m_item_debug.c" diff --git a/src/m_start_data_init.c b/src/m_start_data_init.c index 9826b687..2ba4bcdc 100644 --- a/src/m_start_data_init.c +++ b/src/m_start_data_init.c @@ -183,7 +183,7 @@ static int mSDI_StartInitNew(GAME* game, int player_no, int malloc_flag) { osSyncPrintf("player no -- %d\n", player_no); Common_Set(player_no, player_no); - priv = Save_GetPointer(private[player_no]); + priv = Save_GetPointer(private_data[player_no]); Common_Set(now_private, priv); priv->gender = mPr_SEX_MALE; decide_fruit(Save_GetPointer(fruit)); @@ -211,7 +211,7 @@ static int mSDI_StartInitNew(GAME* game, int player_no, int malloc_flag) { /* Tree -> Cedar Tree */ mAGrw_ChangeTree2Cedar(); - priv_p = Save_Get(private); + priv_p = Save_Get(private_data); mMld_SetDefaultMelody(); mLd_LandDataInit(); @@ -292,7 +292,7 @@ static int mSDI_StartInitFrom(GAME* game, int player_no, int malloc_flag) { lbRTC_GetTime(Common_GetPointer(time.rtc_time)); if (mFRm_CheckSaveData() == TRUE) { - Private_c* priv = Save_Get(private + player_no); + Private_c* priv = Save_Get(private_data + player_no); if (mPr_CheckPrivate(priv) == TRUE) { @@ -349,7 +349,7 @@ static int mSDI_StartInitNewPlayer(GAME* game, int player_no, int malloc_flag) { lbRTC_GetTime(Common_GetPointer(time.rtc_time)); if (mFRm_CheckSaveData() == TRUE) { - Private_c* priv = Save_Get(private + player_no); + Private_c* priv = Save_Get(private_data + player_no); if (mPr_CheckPrivate(priv) != TRUE) { mPr_InitPrivateInfo(priv); diff --git a/src/m_trademark.c b/src/m_trademark.c index 5aa469ae..25773177 100644 --- a/src/m_trademark.c +++ b/src/m_trademark.c @@ -34,388 +34,328 @@ static int mTR_first_flag = TRUE; -static Door_data_c demo_1_door_data = { - SCENE_TITLE_DEMO, - 4, - FALSE, - 0, - { 2180, 200, 824 }, - EMPTY_NO, - 3, - {0,0,0} -}; +static Door_data_c demo_1_door_data = { SCENE_TITLE_DEMO, 4, FALSE, 0, { 2180, 200, 824 }, EMPTY_NO, 3, { 0, 0, 0 } }; -static Door_data_c demo_2_door_data = { - SCENE_TITLE_DEMO, - 4, - FALSE, - 0, - { 3218, 40, 3074 }, - EMPTY_NO, - 3, - {0,0,0} -}; +static Door_data_c demo_2_door_data = { SCENE_TITLE_DEMO, 4, FALSE, 0, { 3218, 40, 3074 }, EMPTY_NO, 3, { 0, 0, 0 } }; -static Door_data_c demo_3_door_data = { - SCENE_TITLE_DEMO, - 4, - FALSE, - 0, - { 2117, 160, 1488 }, - EMPTY_NO, - 3, - {0,0,0} -}; +static Door_data_c demo_3_door_data = { SCENE_TITLE_DEMO, 4, FALSE, 0, { 2117, 160, 1488 }, EMPTY_NO, 3, { 0, 0, 0 } }; -static Door_data_c demo_4_door_data = { - SCENE_TITLE_DEMO, - 4, - FALSE, - 0, - { 2899, 160, 1101 }, - EMPTY_NO, - 3, - {0,0,0} -}; +static Door_data_c demo_4_door_data = { SCENE_TITLE_DEMO, 4, FALSE, 0, { 2899, 160, 1101 }, EMPTY_NO, 3, { 0, 0, 0 } }; -static Door_data_c demo_5_door_data = { - SCENE_TITLE_DEMO, - 4, - FALSE, - 0, - { 1578, 40, 2472 }, - EMPTY_NO, - 3, - {0,0,0} -}; +static Door_data_c demo_5_door_data = { SCENE_TITLE_DEMO, 4, FALSE, 0, { 1578, 40, 2472 }, EMPTY_NO, 3, { 0, 0, 0 } }; -static Door_data_c* l_demo_door_data_table[mTD_TITLE_DEMO_NUM] = { - &demo_1_door_data, - &demo_2_door_data, - &demo_3_door_data, - &demo_4_door_data, - &demo_5_door_data -}; +static Door_data_c* l_demo_door_data_table[mTD_TITLE_DEMO_NUM] = { &demo_1_door_data, &demo_2_door_data, + &demo_3_door_data, &demo_4_door_data, + &demo_5_door_data }; -#define DEMO_NPC(name, bx, bz, utx, utz) { NPC_##name, (bx), (bz), (utx), (utz) } +#define DEMO_NPC(name, bx, bz, utx, utz) \ + { NPC_##name, (bx), (bz), (utx), (utz) } static mNpc_demo_npc_c demo_npc_list[] = { - DEMO_NPC(BOB, 1, 2, 3, 7), - DEMO_NPC(PAOLO, 1, 2, 8, 11), - DEMO_NPC(VESTA, 1, 4, 12, 11), - DEMO_NPC(JOEY, 2, 3, 5, 6), - DEMO_NPC(LOBO, 2, 3, 4, 12), - DEMO_NPC(CARRIE, 3, 5, 11, 5), - DEMO_NPC(TANK, 4, 3, 3, 12), - DEMO_NPC(BUZZ, 4, 4, 3, 4), - DEMO_NPC(RASHER, 4, 4, 12, 13), - DEMO_NPC(BIFF, 4, 6, 5, 6), - DEMO_NPC(SAMSON, 5, 2, 12, 4), - DEMO_NPC(JANE, 5, 2, 9, 11), - DEMO_NPC(TYBALT, 5, 4, 11, 4), - /* @BUG - mNpc_SetAnimalTitleDemo uses ANIMAL_NUM_MAX (15) but only 14 are set */ - #ifndef BUGFIXES - DEMO_NPC(CUBE, 5, 5, 5, 11) - #else - DEMO_NPC(CUBE, 5, 5, 5, 11), - { EMPTY_NO, 0, 0, 0, 0 } - #endif + DEMO_NPC(BOB, 1, 2, 3, 7), DEMO_NPC(PAOLO, 1, 2, 8, 11), DEMO_NPC(VESTA, 1, 4, 12, 11), + DEMO_NPC(JOEY, 2, 3, 5, 6), DEMO_NPC(LOBO, 2, 3, 4, 12), DEMO_NPC(CARRIE, 3, 5, 11, 5), + DEMO_NPC(TANK, 4, 3, 3, 12), DEMO_NPC(BUZZ, 4, 4, 3, 4), DEMO_NPC(RASHER, 4, 4, 12, 13), + DEMO_NPC(BIFF, 4, 6, 5, 6), DEMO_NPC(SAMSON, 5, 2, 12, 4), DEMO_NPC(JANE, 5, 2, 9, 11), + DEMO_NPC(TYBALT, 5, 4, 11, 4), +/* @BUG - mNpc_SetAnimalTitleDemo uses ANIMAL_NUM_MAX (15) but only 14 are set */ +#ifndef BUGFIXES + DEMO_NPC(CUBE, 5, 5, 5, 11) +#else + DEMO_NPC(CUBE, 5, 5, 5, 11), { EMPTY_NO, 0, 0, 0, 0 } +#endif }; static int demo_npc_num = sizeof(demo_npc_list) / sizeof(mNpc_demo_npc_c); static int set_npc_4_title_demo(GAME_TRADEMARK* trademark) { - Animal_c* animals = Save_Get(animals); - - mNpc_SetAnimalTitleDemo(demo_npc_list, animals, (GAME*)trademark); - mNpc_SetNpcList(Common_Get(npclist), animals, demo_npc_num, 0); + Animal_c* animals = Save_Get(animals); - return demo_npc_num; + mNpc_SetAnimalTitleDemo(demo_npc_list, animals, (GAME*)trademark); + mNpc_SetNpcList(Common_Get(npclist), animals, demo_npc_num, 0); + + return demo_npc_num; } typedef struct tradeday_s { - lbRTC_month_t month; - lbRTC_day_t day; - lbRTC_hour_t hour; - s16 weather; + lbRTC_month_t month; + lbRTC_day_t day; + lbRTC_hour_t hour; + s16 weather; } mTM_tradeday_c; static void mTM_demotime_set(int title_no) { - static mTM_tradeday_c tradeday_table[] = { - { lbRTC_APRIL, 6, 13, mEnv_WEATHER_SAKURA }, /* April 6th @ 1pm, Cherry Blossoms */ - { lbRTC_JUNE, 16, 13, mEnv_WEATHER_RAIN }, /* June 16th @ 1pm, Raining */ - { lbRTC_AUGUST, 1, 6, mEnv_WEATHER_CLEAR }, /* August 1st @ 6am, Clear */ - { lbRTC_NOVEMBER, 1, 16, mEnv_WEATHER_CLEAR }, /* November 1st @ 4pm, Clear */ - { lbRTC_FEBRUARY, 1, 2, mEnv_WEATHER_SNOW } /* February 1st @ 2am, Snowing */ - }; + static mTM_tradeday_c tradeday_table[] = { + { lbRTC_APRIL, 6, 13, mEnv_WEATHER_SAKURA }, /* April 6th @ 1pm, Cherry Blossoms */ + { lbRTC_JUNE, 16, 13, mEnv_WEATHER_RAIN }, /* June 16th @ 1pm, Raining */ + { lbRTC_AUGUST, 1, 6, mEnv_WEATHER_CLEAR }, /* August 1st @ 6am, Clear */ + { lbRTC_NOVEMBER, 1, 16, mEnv_WEATHER_CLEAR }, /* November 1st @ 4pm, Clear */ + { lbRTC_FEBRUARY, 1, 2, mEnv_WEATHER_SNOW } /* February 1st @ 2am, Snowing */ + }; - Common_Set(time.rtc_enabled, FALSE); - Common_Set(time.rtc_time.year, GAME_YEAR_MIN + 1); - Common_Set(time.rtc_time.min, 0); + Common_Set(time.rtc_enabled, FALSE); + Common_Set(time.rtc_time.year, GAME_YEAR_MIN + 1); + Common_Set(time.rtc_time.min, 0); - if (title_no != 0) { - Common_Set(time.rtc_time.month, tradeday_table[(title_no - 1)].month); - Common_Set(time.rtc_time.day, tradeday_table[(title_no - 1)].day); - Common_Set(time.rtc_time.hour, tradeday_table[(title_no - 1)].hour); - Common_Set(weather, tradeday_table[(title_no - 1)].weather); - } + if (title_no != 0) { + Common_Set(time.rtc_time.month, tradeday_table[(title_no - 1)].month); + Common_Set(time.rtc_time.day, tradeday_table[(title_no - 1)].day); + Common_Set(time.rtc_time.hour, tradeday_table[(title_no - 1)].hour); + Common_Set(weather, tradeday_table[(title_no - 1)].weather); + } } static void trademark_goto_demo_scene(GAME_TRADEMARK* trademark) { - int demo_no; - int i; - Private_c* n_private; - Save_t* save; - Private_c* private; + int demo_no; + int i; + Private_c* n_private; + Save_t* save; + Private_c* private; - save = Common_GetPointer(save.save); - mCPk_InitPak(0); - n_private = Save_Get(private); - Common_Set(now_private, n_private); + save = Common_GetPointer(save.save); + mCPk_InitPak(0); + n_private = Save_Get(private_data); + Common_Set(now_private, n_private); - if (mFRm_CheckSaveData() == FALSE) { - bzero(save, sizeof(Save_t)); - mFRm_ClearSaveCheckData(Save_GetPointer(save_check)); + if (mFRm_CheckSaveData() == FALSE) { + bzero(save, sizeof(Save_t)); + mFRm_ClearSaveCheckData(Save_GetPointer(save_check)); - private = n_private; - for (i = 0; i < PLAYER_NUM; i++) { - mPr_ClearPrivateInfo(private); - private++; + private = n_private; + for (i = 0; i < PLAYER_NUM; i++) { + mPr_ClearPrivateInfo(private); + private++; + } + + Save_Set(land_info.exists, TRUE); + Common_Set(house_owner_name, RSV_NO); + Common_Set(last_field_id, -1); } - Save_Set(land_info.exists, TRUE); - Common_Set(house_owner_name, RSV_NO); - Common_Set(last_field_id, -1); - } + mEv_ClearEventInfo(); - mEv_ClearEventInfo(); + demo_no = mEv_CheckTitleDemo(); + if (demo_no > 0) { + Door_data_c* demo_door_data = l_demo_door_data_table[demo_no - 1]; - demo_no = mEv_CheckTitleDemo(); - if (demo_no > 0) { - Door_data_c* demo_door_data = l_demo_door_data_table[demo_no - 1]; + Common_Set(door_data, *demo_door_data); + Common_Set(door_data.next_scene_id, demo_door_data->next_scene_id + 1); // go to next demo scene + mTM_demotime_set(demo_no); // set demo date, time, and weather + mPr_RandomSetPlayerData_title_demo(); // randomize player data + set_npc_4_title_demo(trademark); // set animals in the demo + Common_Set(transition.wipe_type, 3); + } - Common_Set(door_data, *demo_door_data); - Common_Set(door_data.next_scene_id, demo_door_data->next_scene_id + 1); // go to next demo scene - mTM_demotime_set(demo_no); // set demo date, time, and weather - mPr_RandomSetPlayerData_title_demo(); // randomize player data - set_npc_4_title_demo(trademark); // set animals in the demo - Common_Set(transition.wipe_type, 3); - } - - Save_Set(scene_no, SCENE_TITLE_DEMO); - mTM_set_season(); - Common_Set(submenu_disabled, TRUE); - GAME_GOTO_NEXT((GAME*)trademark, play, PLAY); + Save_Set(scene_no, SCENE_TITLE_DEMO); + mTM_set_season(); + Common_Set(submenu_disabled, TRUE); + GAME_GOTO_NEXT((GAME*)trademark, play, PLAY); } static void nintendo_logo_move(GAME_TRADEMARK* trademark) { - int timer; - int alpha2; - if (trademark->stage == 2) { - alpha2 = trademark->alpha2; - alpha2 += 0x880; - if (alpha2 >= 0xFF00) { - trademark->stage = 4; - alpha2 = 0xFF00; - } + int timer; + int alpha2; + if (trademark->stage == 2) { + alpha2 = trademark->alpha2; + alpha2 += 0x880; + if (alpha2 >= 0xFF00) { + trademark->stage = 4; + alpha2 = 0xFF00; + } - trademark->alpha2 = alpha2; - } - else if (trademark->stage == 4) { - if (trademark->logo_timer == 0) { - timer = 0; - } - else { - timer = --trademark->logo_timer; - } + trademark->alpha2 = alpha2; + } else if (trademark->stage == 4) { + if (trademark->logo_timer == 0) { + timer = 0; + } else { + timer = --trademark->logo_timer; + } - if (timer == 0) { - trademark->stage = 3; + if (timer == 0) { + trademark->stage = 3; + } } - } } static void nintendo_logo_draw(GAME_TRADEMARK* trademark) { - Gfx* gfx; - GRAPH* g = trademark->game.graph; - u8 a; + Gfx* gfx; + GRAPH* g = trademark->game.graph; + u8 a; - OPEN_DISP(g); - nintendo_logo_move(trademark); - gfx = NOW_POLY_OPA_DISP; - a = trademark->alpha2 >> 8; - make_dl_nintendo_logo(&gfx, a); - SET_POLY_OPA_DISP(gfx); - CLOSE_DISP(g); + OPEN_DISP(g); + nintendo_logo_move(trademark); + gfx = NOW_POLY_OPA_DISP; + a = trademark->alpha2 >> 8; + make_dl_nintendo_logo(&gfx, a); + SET_POLY_OPA_DISP(gfx); + CLOSE_DISP(g); } static void trademark_cancel(GAME_TRADEMARK* trademark) { - if (trademark->cancel != FALSE) { - return; - } + if (trademark->cancel != FALSE) { + return; + } - if (trademark->stage != 4) { - return; - } + if (trademark->stage != 4) { + return; + } - if (Common_Get(pad_connected) == FALSE) { - return; - } + if (Common_Get(pad_connected) == FALSE) { + return; + } - if ((gamePT->pads[0].on.button & BUTTON_START) != BUTTON_START) { - return; - } + if ((gamePT->pads[0].on.button & BUTTON_START) != BUTTON_START) { + return; + } - trademark->cancel = TRUE; + trademark->cancel = TRUE; } static void trademark_move(GAME_TRADEMARK* trademark) { - static u8 s_titlebgm[mTD_TITLE_DEMO_NUM] = { 83, 84, 85, 86, 87 }; // TODO: convert to enum/definitions + static u8 s_titlebgm[mTD_TITLE_DEMO_NUM] = { 83, 84, 85, 86, 87 }; // TODO: convert to enum/definitions - if (trademark->stage == 0) { - int titledemo_no = mTD_get_titledemo_no(); - mBGMPsComp_make_ps_lost_fanfare(s_titlebgm[titledemo_no], 360); - trademark->alpha = 0; - trademark->stage = 1; - } - - if (trademark->stage == 1) { - int move_timer; - if (trademark->move_timer == 0) { - move_timer = 0; - } - else { - move_timer = --trademark->move_timer; + if (trademark->stage == 0) { + int titledemo_no = mTD_get_titledemo_no(); + mBGMPsComp_make_ps_lost_fanfare(s_titlebgm[titledemo_no], 360); + trademark->alpha = 0; + trademark->stage = 1; } - if (move_timer == 0) { - trademark->stage = 2; - } - } + if (trademark->stage == 1) { + int move_timer; + if (trademark->move_timer == 0) { + move_timer = 0; + } else { + move_timer = --trademark->move_timer; + } - if (trademark->stage == 3 || trademark->cancel) { - if (trademark->alpha < 0xFF00) { - trademark->alpha += 0x880; + if (move_timer == 0) { + trademark->stage = 2; + } } - if (trademark->check != TRUE) { - trademark->check = TRUE; - } + if (trademark->stage == 3 || trademark->cancel) { + if (trademark->alpha < 0xFF00) { + trademark->alpha += 0x880; + } - if (trademark->alpha >= 0xFF00 && trademark->check == TRUE) { - trademark->alpha = 0xFF00; - trademark->stage = 5; + if (trademark->check != TRUE) { + trademark->check = TRUE; + } + + if (trademark->alpha >= 0xFF00 && trademark->check == TRUE) { + trademark->alpha = 0xFF00; + trademark->stage = 5; + } } - } } static void trademark_draw(GAME_TRADEMARK* trademark) { - GRAPH* g = trademark->game.graph; - Gfx* gfx; - - OPEN_DISP(g); + GRAPH* g = trademark->game.graph; + Gfx* gfx; - gSPSegment(NOW_POLY_OPA_DISP++, 0, 0); - DisplayList_initialize(g, 0, 0, 0, NULL); - if (mTR_first_flag == FALSE) { - if (trademark->stage >= 2) { - nintendo_logo_draw(trademark); + OPEN_DISP(g); + + gSPSegment(NOW_POLY_OPA_DISP++, 0, 0); + DisplayList_initialize(g, 0, 0, 0, NULL); + if (mTR_first_flag == FALSE) { + if (trademark->stage >= 2) { + nintendo_logo_draw(trademark); + } + + gfx = NOW_POLY_XLU_DISP; + fade_black_draw(&gfx, trademark->alpha >> 8); + SET_POLY_XLU_DISP(gfx); } - gfx = NOW_POLY_XLU_DISP; - fade_black_draw(&gfx, trademark->alpha >> 8); - SET_POLY_XLU_DISP(gfx); - } - - CLOSE_DISP(g); + CLOSE_DISP(g); } static void trademark_main(GAME* game) { - GAME_TRADEMARK* trademark = (GAME_TRADEMARK*)game; - GRAPH* g; + GAME_TRADEMARK* trademark = (GAME_TRADEMARK*)game; + GRAPH* g; - fqrand(); /* increment qrand seed every frame */ - trademark_cancel(trademark); - trademark_move(trademark); - trademark_draw(trademark); + fqrand(); /* increment qrand seed every frame */ + trademark_cancel(trademark); + trademark_move(trademark); + trademark_draw(trademark); - g = game->graph; - game_debug_draw_last(game, g); - game_draw_last(g); + g = game->graph; + game_debug_draw_last(game, g); + game_draw_last(g); - if (trademark->stage == 5) { - trademark->stage = 0; - trademark_goto_demo_scene(trademark); - mTR_first_flag = FALSE; - } + if (trademark->stage == 5) { + trademark->stage = 0; + trademark_goto_demo_scene(trademark); + mTR_first_flag = FALSE; + } } extern void trademark_cleanup(GAME* game) { - GAME_TRADEMARK* trademark = (GAME_TRADEMARK*)game; - mHm_hs_c* home = Save_Get(homes); - int i; + GAME_TRADEMARK* trademark = (GAME_TRADEMARK*)game; + mHm_hs_c* home = Save_Get(homes); + int i; - for (i = 0; i < PLAYER_NUM; i++) { - home->outlook_pal = i; - home->next_outlook_pal = i; + for (i = 0; i < PLAYER_NUM; i++) { + home->outlook_pal = i; + home->next_outlook_pal = i; - mMl_clear_mail_box(home->mailbox, HOME_MAILBOX_SIZE); - home++; - } + mMl_clear_mail_box(home->mailbox, HOME_MAILBOX_SIZE); + home++; + } - JW_SetLogoMode(0); - SoftResetEnable = TRUE; + JW_SetLogoMode(0); + SoftResetEnable = TRUE; } extern void trademark_init(GAME* game) { - GAME_TRADEMARK* trademark = (GAME_TRADEMARK*)game; - GRAPH* g = game->graph; + GAME_TRADEMARK* trademark = (GAME_TRADEMARK*)game; + GRAPH* g = game->graph; - common_data_reinit(); - mFI_SetClimate(mFI_CLIMATE_0); - game->exec = &trademark_main; - game->cleanup = &trademark_cleanup; - initView(&trademark->view, g); - new_Matrix(game); - trademark->alpha = 0xFF00; - trademark->alpha2 = 0; - trademark->logo_timer = 60; - trademark->move_timer = 16; - trademark->unused_254 = 0; - trademark->unused_210 = 0; - trademark->stage = 0; - trademark->unused_200.x = 0.0f; - trademark->unused_200.y = 0.0f; - trademark->unused_200.z = 0.0f; - trademark->unused_20c = 0.5f; - trademark->unused_25a62 = 0; - trademark->unused_25a64 = 5072; - trademark->unused_25a67 = 0; - trademark->cancel = FALSE; - trademark->check = FALSE; + common_data_reinit(); + mFI_SetClimate(mFI_CLIMATE_0); + game->exec = &trademark_main; + game->cleanup = &trademark_cleanup; + initView(&trademark->view, g); + new_Matrix(game); + trademark->alpha = 0xFF00; + trademark->alpha2 = 0; + trademark->logo_timer = 60; + trademark->move_timer = 16; + trademark->unused_254 = 0; + trademark->unused_210 = 0; + trademark->stage = 0; + trademark->unused_200.x = 0.0f; + trademark->unused_200.y = 0.0f; + trademark->unused_200.z = 0.0f; + trademark->unused_20c = 0.5f; + trademark->unused_25a62 = 0; + trademark->unused_25a64 = 5072; + trademark->unused_25a67 = 0; + trademark->cancel = FALSE; + trademark->check = FALSE; - if (mTR_first_flag) { - trademark->stage = 5; - } + if (mTR_first_flag) { + trademark->stage = 5; + } - SetGameFrame(1); - viBlack(FALSE); - JW_SetLogoMode(1); - mMsg_aram_init(); + SetGameFrame(1); + viBlack(FALSE); + JW_SetLogoMode(1); + mMsg_aram_init(); - Common_Set(player_no, 0); - Common_Set(player_data_mode, 0); - Common_Set(scene_from_title_demo, -1); - mNpc_ClearCacheName(); - mNpc_ClearInAnimal(); - mNpc_FirstClearGoodbyMail(); - mQst_ClearGrabItemInfo(); - mNpc_ClearIslandNpcRoomData(); - mCD_InitAll(); - mISL_ClearKeepIsland(); - mBI_ct(); - mFont_ct(); - mBGMPsComp_scene_mode(0); - mVibctl_init0(); - mFRm_clear_err_info(); - mEv_SetTitleDemo(mTD_demono_get()); + Common_Set(player_no, 0); + Common_Set(player_data_mode, 0); + Common_Set(scene_from_title_demo, -1); + mNpc_ClearCacheName(); + mNpc_ClearInAnimal(); + mNpc_FirstClearGoodbyMail(); + mQst_ClearGrabItemInfo(); + mNpc_ClearIslandNpcRoomData(); + mCD_InitAll(); + mISL_ClearKeepIsland(); + mBI_ct(); + mFont_ct(); + mBGMPsComp_scene_mode(0); + mVibctl_init0(); + mFRm_clear_err_info(); + mEv_SetTitleDemo(mTD_demono_get()); } diff --git a/src/player_select.c b/src/player_select.c index 889700ce..a6be9aa4 100644 --- a/src/player_select.c +++ b/src/player_select.c @@ -24,122 +24,115 @@ static u8 l_zaitaku_str[9] = { 0x3C, 0xEC, 0x01, 0x0F, 0x07, 0x10, 0xCA, 0x02, 0 static u8 l_yosokara_str[10] = { 0x60, 0x0E, 0x05, 0x7B, 0x00, 0x0E, 0xF7, 0x15, 0x06, 0x0F }; static void player_select_game_data_init(GAME_PLAYER_SELECT* player_select) { - int player_no = player_select->player_no; - mFI_ClearFieldData(); - if (mSDI_StartInitBefore((GAME*)player_select, player_no, mSDI_INIT_MODE_NEW, mSDI_MALLOC_FLAG_GAME) == TRUE) { - player_select->err_no = PLAYER_SELECT_INIT_ERR_SUCCESS; - } + int player_no = player_select->player_no; + mFI_ClearFieldData(); + if (mSDI_StartInitBefore((GAME*)player_select, player_no, mSDI_INIT_MODE_NEW, mSDI_MALLOC_FLAG_GAME) == TRUE) { + player_select->err_no = PLAYER_SELECT_INIT_ERR_SUCCESS; + } } static void player_select_game_data_init_save(GAME_PLAYER_SELECT* player_select) { - if (mSDI_StartInitBefore((GAME*)player_select, player_select->player_no, mSDI_INIT_MODE_FROM, mSDI_MALLOC_FLAG_GAME) == TRUE) { - player_select->err_no = PLAYER_SELECT_INIT_ERR_SUCCESS; - } - else { - player_select->err_no = PLAYER_SELECT_INIT_ERR_SAVE; - } + if (mSDI_StartInitBefore((GAME*)player_select, player_select->player_no, mSDI_INIT_MODE_FROM, + mSDI_MALLOC_FLAG_GAME) == TRUE) { + player_select->err_no = PLAYER_SELECT_INIT_ERR_SUCCESS; + } else { + player_select->err_no = PLAYER_SELECT_INIT_ERR_SAVE; + } } static void player_select_game_data_init_new_player(GAME_PLAYER_SELECT* player_select) { - if (mSDI_StartInitBefore((GAME*)player_select, player_select->player_no, mSDI_INIT_MODE_NEW_PLAYER, mSDI_MALLOC_FLAG_GAME) == TRUE) { - player_select->err_no = PLAYER_SELECT_INIT_ERR_SUCCESS; - } - else { - player_select->err_no = PLAYER_SELECT_INIT_ERR_SAVE; - } + if (mSDI_StartInitBefore((GAME*)player_select, player_select->player_no, mSDI_INIT_MODE_NEW_PLAYER, + mSDI_MALLOC_FLAG_GAME) == TRUE) { + player_select->err_no = PLAYER_SELECT_INIT_ERR_SUCCESS; + } else { + player_select->err_no = PLAYER_SELECT_INIT_ERR_SAVE; + } } static void player_select_game_data_init_pak(GAME_PLAYER_SELECT* player_select) { - if (mSDI_StartInitBefore((GAME*)player_select, player_select->player_no, mSDI_INIT_MODE_PAK, mSDI_MALLOC_FLAG_GAME) == TRUE) { - player_select->err_no = PLAYER_SELECT_INIT_ERR_SUCCESS; - } - else { - player_select->err_no = PLAYER_SELECT_INIT_ERR_PAK; - } + if (mSDI_StartInitBefore((GAME*)player_select, player_select->player_no, mSDI_INIT_MODE_PAK, + mSDI_MALLOC_FLAG_GAME) == TRUE) { + player_select->err_no = PLAYER_SELECT_INIT_ERR_SUCCESS; + } else { + player_select->err_no = PLAYER_SELECT_INIT_ERR_PAK; + } } static void player_select_game_data_init_err(GAME_PLAYER_SELECT* player_select) { - player_select->mode = PLAYER_SELECT_MODE_SELECTION; + player_select->mode = PLAYER_SELECT_MODE_SELECTION; } static PLAYER_SELECT_INIT_PROC l_init_proc[mSDI_INIT_MODE_NUM] = { - &player_select_game_data_init, - &player_select_game_data_init_new_player, - &player_select_game_data_init_save, - &player_select_game_data_init_pak, - &player_select_game_data_init_err + &player_select_game_data_init, &player_select_game_data_init_new_player, &player_select_game_data_init_save, + &player_select_game_data_init_pak, &player_select_game_data_init_err }; static void player_select_init_after(GAME_PLAYER_SELECT* player_select) { - mSDI_StartInitAfter((GAME*)player_select, FALSE, mSDI_MALLOC_FLAG_GAME); + mSDI_StartInitAfter((GAME*)player_select, FALSE, mSDI_MALLOC_FLAG_GAME); } static void player_select_next_mode(int* mode, int max) { - (*mode)++; - if (*mode >= max) { - *mode = 0; - } + (*mode)++; + if (*mode >= max) { + *mode = 0; + } } static void player_select_back_mode(int* mode, int max) { - (*mode)--; - if (*mode < 0) { - *mode = max - 1; - } + (*mode)--; + if (*mode < 0) { + *mode = max - 1; + } } static void player_select_move_main(GAME_PLAYER_SELECT* player_select) { - int mode = player_select->mode; + int mode = player_select->mode; - if (player_select->err_no == PLAYER_SELECT_INIT_ERR_NONE) { - if (chkTrigger(BUTTON_A)) { - int player_no = player_select->player_no; - if (mode == PLAYER_SELECT_MODE_SELECTION) { - player_select->mode = PLAYER_SELECT_MODE_PLAY; - } + if (player_select->err_no == PLAYER_SELECT_INIT_ERR_NONE) { + if (chkTrigger(BUTTON_A)) { + int player_no = player_select->player_no; + if (mode == PLAYER_SELECT_MODE_SELECTION) { + player_select->mode = PLAYER_SELECT_MODE_PLAY; + } - if (player_select->mode == PLAYER_SELECT_MODE_PLAY) { - (*player_select->init_procs[player_no])(player_select); - } + if (player_select->mode == PLAYER_SELECT_MODE_PLAY) { + (*player_select->init_procs[player_no])(player_select); + } + } + + if (chkTrigger(BUTTON_DDOWN) && player_select->mode == PLAYER_SELECT_MODE_SELECTION) { + if (player_select->land_exist == TRUE) { + player_select_next_mode(&player_select->player_no, SELECT_PLAYER_NUM); + } else { + player_select_next_mode(&player_select->player_no, PLAYER_NUM); + } + } + + if (chkTrigger(BUTTON_DUP) && player_select->mode == PLAYER_SELECT_MODE_SELECTION) { + if (player_select->land_exist == TRUE) { + player_select_back_mode(&player_select->player_no, SELECT_PLAYER_NUM); + } else { + player_select_back_mode(&player_select->player_no, PLAYER_NUM); + } + } + } else if (player_select->err_no == PLAYER_SELECT_INIT_ERR_SUCCESS) { + player_select_init_after(player_select); + GAME_GOTO_NEXT((GAME*)player_select, select, SELECT); + } else { + Common_Set(scene_from_title_demo, -1); + player_select->err_no = PLAYER_SELECT_INIT_ERR_NONE; + player_select->mode = PLAYER_SELECT_MODE_SELECTION; } - - if (chkTrigger(BUTTON_DDOWN) && player_select->mode == PLAYER_SELECT_MODE_SELECTION) { - if (player_select->land_exist == TRUE) { - player_select_next_mode(&player_select->player_no, SELECT_PLAYER_NUM); - } - else { - player_select_next_mode(&player_select->player_no, PLAYER_NUM); - } - } - - if (chkTrigger(BUTTON_DUP) && player_select->mode == PLAYER_SELECT_MODE_SELECTION) { - if (player_select->land_exist == TRUE) { - player_select_back_mode(&player_select->player_no, SELECT_PLAYER_NUM); - } - else { - player_select_back_mode(&player_select->player_no, PLAYER_NUM); - } - } - } - else if (player_select->err_no == PLAYER_SELECT_INIT_ERR_SUCCESS) { - player_select_init_after(player_select); - GAME_GOTO_NEXT((GAME*)player_select, select, SELECT); - } - else { - Common_Set(scene_from_title_demo, -1); - player_select->err_no = PLAYER_SELECT_INIT_ERR_NONE; - player_select->mode = PLAYER_SELECT_MODE_SELECTION; - } } static void str_add_word(u8* dst, const u8* word0, const u8* word1, int word0_len, int word1_len) { - for (word0_len; word0_len != 0; word0_len--) { - *dst++ = *word0++; - } + for (word0_len; word0_len != 0; word0_len--) { + *dst++ = *word0++; + } - for (word1_len; word1_len != 0; word1_len--) { - *dst++ = *word1++; - } + for (word1_len; word1_len != 0; word1_len--) { + *dst++ = *word1++; + } } static int l_ps_white_color[3] = { 250, 220, 100 }; @@ -149,186 +142,165 @@ static int l_ps_select_color[3] = { 200, 55, 55 }; static u8 _debug_player_select[10] = { 0xE4, 0xBA, 0x90, 0xB4, 0x90, 0x20, 0x0D, 0xC3, 0x0F, 0x07 }; static void player_select_draw_title(GAME_PLAYER_SELECT* player_select) { - mFont_SetMatrix(player_select->game.graph, mFont_MODE_FONT); - mFont_SetLineStrings_AndSpace( - (GAME*)player_select, - _debug_player_select, ARRAY_SIZE(_debug_player_select, u8), - 85.0f, 15.0f, - 200, 200, 200, 255, - FALSE, TRUE, 0, - 1.2f, 1.2f, - mFont_MODE_FONT - ); - mFont_UnSetMatrix(player_select->game.graph, mFont_MODE_FONT); + mFont_SetMatrix(player_select->game.graph, mFont_MODE_FONT); + mFont_SetLineStrings_AndSpace((GAME*)player_select, _debug_player_select, ARRAY_SIZE(_debug_player_select, u8), + 85.0f, 15.0f, 200, 200, 200, 255, FALSE, TRUE, 0, 1.2f, 1.2f, mFont_MODE_FONT); + mFont_UnSetMatrix(player_select->game.graph, mFont_MODE_FONT); } static void player_select_draw_player_no(GAME_PLAYER_SELECT* player_select) { - u8 name_buf[8 + SELECT_NAME_LEN]; - u8 pre_str[8] = { 0xED, 0xCA, 0x02, 0x15, 0xC3, 0x20, 0x20, 0x20 }; - int player_no = player_select->player_no; - int i; + u8 name_buf[8 + SELECT_NAME_LEN]; + u8 pre_str[8] = { 0xED, 0xCA, 0x02, 0x15, 0xC3, 0x20, 0x20, 0x20 }; + int player_no = player_select->player_no; + int i; - for (i = 0; i < PLAYER_NUM; i++) { - int* color; + for (i = 0; i < PLAYER_NUM; i++) { + int* color; - /* create text */ - mem_clear(name_buf, ARRAY_SIZE(name_buf, u8), CHAR_SPACE); - str_add_word(name_buf, pre_str, player_select->player_names[i], 8, SELECT_NAME_LEN); - - /* set player no */ - name_buf[6] = (u8)i | CHAR_ZERO; + /* create text */ + mem_clear(name_buf, ARRAY_SIZE(name_buf, u8), CHAR_SPACE); + str_add_word(name_buf, pre_str, player_select->player_names[i], 8, SELECT_NAME_LEN); - color = (player_no == i) ? l_ps_select_color : l_ps_white_color; + /* set player no */ + name_buf[6] = (u8)i | CHAR_ZERO; - mFont_SetMatrix(player_select->game.graph, mFont_MODE_FONT); - mFont_SetLineStrings_AndSpace( - (GAME*)player_select, - name_buf, ARRAY_SIZE(name_buf, u8), - 70.0f, 65.0f + 15.0f * i, - color[0], color[1], color[2], 255, - FALSE, TRUE, 0, - 0.8f, 0.8f, - mFont_MODE_FONT - ); - mFont_UnSetMatrix(player_select->game.graph, mFont_MODE_FONT); - } + color = (player_no == i) ? l_ps_select_color : l_ps_white_color; + + mFont_SetMatrix(player_select->game.graph, mFont_MODE_FONT); + mFont_SetLineStrings_AndSpace((GAME*)player_select, name_buf, ARRAY_SIZE(name_buf, u8), 70.0f, + 65.0f + 15.0f * i, color[0], color[1], color[2], 255, FALSE, TRUE, 0, 0.8f, 0.8f, + mFont_MODE_FONT); + mFont_UnSetMatrix(player_select->game.graph, mFont_MODE_FONT); + } } static void player_select_draw_yosokara(GAME_PLAYER_SELECT* player_select) { - u8* name = player_select->player_names[PLAYER_NUM]; - int* color = (player_select->player_no == PLAYER_NUM) ? l_ps_select_color : l_ps_white_color; + u8* name = player_select->player_names[PLAYER_NUM]; + int* color = (player_select->player_no == PLAYER_NUM) ? l_ps_select_color : l_ps_white_color; - mFont_SetMatrix(player_select->game.graph, mFont_MODE_FONT); - mFont_SetLineStrings_AndSpace( - (GAME*)player_select, - name, SELECT_NAME_LEN, - 70.0f, 65.0f + 15.0f * PLAYER_NUM, - color[0], color[1], color[2], 255, - FALSE, TRUE, 0, - 0.8f, 0.8f, - mFont_MODE_FONT - ); - mFont_UnSetMatrix(player_select->game.graph, mFont_MODE_FONT); + mFont_SetMatrix(player_select->game.graph, mFont_MODE_FONT); + mFont_SetLineStrings_AndSpace((GAME*)player_select, name, SELECT_NAME_LEN, 70.0f, 65.0f + 15.0f * PLAYER_NUM, + color[0], color[1], color[2], 255, FALSE, TRUE, 0, 0.8f, 0.8f, mFont_MODE_FONT); + mFont_UnSetMatrix(player_select->game.graph, mFont_MODE_FONT); } static void player_select_draw_main(GAME_PLAYER_SELECT* player_select) { - GRAPH* g = player_select->game.graph; + GRAPH* g = player_select->game.graph; - OPEN_DISP(g); + OPEN_DISP(g); - gSPSegment(NOW_POLY_OPA_DISP++, G_MWO_SEGMENT_0, 0); - gSPSegment(NOW_FONT_DISP++, G_MWO_SEGMENT_0, 0); + gSPSegment(NOW_POLY_OPA_DISP++, G_MWO_SEGMENT_0, 0); + gSPSegment(NOW_FONT_DISP++, G_MWO_SEGMENT_0, 0); - DisplayList_initialize(g, 0, 0, 0, NULL); + DisplayList_initialize(g, 0, 0, 0, NULL); - gDPPipeSync(NOW_POLY_OPA_DISP++); - - CLOSE_DISP(g); + gDPPipeSync(NOW_POLY_OPA_DISP++); - showView(&player_select->view, VIEW_UPDATE_ALL); - player_select_draw_title(player_select); - player_select_draw_player_no(player_select); - player_select_draw_yosokara(player_select); + CLOSE_DISP(g); + + showView(&player_select->view, VIEW_UPDATE_ALL); + player_select_draw_title(player_select); + player_select_draw_player_no(player_select); + player_select_draw_yosokara(player_select); } static void player_select_main(GAME* game) { - GAME_PLAYER_SELECT* player_select = (GAME_PLAYER_SELECT*)game; + GAME_PLAYER_SELECT* player_select = (GAME_PLAYER_SELECT*)game; - player_select_move_main(player_select); - player_select_draw_main(player_select); + player_select_move_main(player_select); + player_select_draw_main(player_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 player_select_cleanup(GAME* game) { } +extern void player_select_cleanup(GAME* game) { +} extern void player_select_init(GAME* game) { - GAME_PLAYER_SELECT* player_select = (GAME_PLAYER_SELECT*)game; - GRAPH* g = game->graph; - int i; - - game->exec = &player_select_main; - game->cleanup = &player_select_cleanup; + GAME_PLAYER_SELECT* player_select = (GAME_PLAYER_SELECT*)game; + GRAPH* g = game->graph; + int i; - { - View* view = &player_select->view; - initView(view, g); - view->flag = VIEW_UPDATE_ORTHOGRAPHIC; - } + game->exec = &player_select_main; + game->cleanup = &player_select_cleanup; - new_Matrix(game); - SetGameFrame(1); - - player_select->player_no = 0; - player_select->err_no = PLAYER_SELECT_INIT_ERR_NONE; - player_select->mode = PLAYER_SELECT_MODE_SELECTION; - - for (i = 0; i < SELECT_PLAYER_NUM; i++) { - int j; - - for (j = 0; j < 6; j++) { - player_select->player_names[i][j] = mitouroku_str[j]; + { + View* view = &player_select->view; + initView(view, g); + view->flag = VIEW_UPDATE_ORTHOGRAPHIC; } - for (j = 6; j < SELECT_NAME_LEN; j++) { - player_select->player_names[i][j] = CHAR_SPACE; - } + new_Matrix(game); + SetGameFrame(1); - player_select->player_types[i] = PLAYER_SELECT_PLAYER_MODE_NO_SAVE; - } + player_select->player_no = 0; + player_select->err_no = PLAYER_SELECT_INIT_ERR_NONE; + player_select->mode = PLAYER_SELECT_MODE_SELECTION; - for (i = 0; i < LAND_NAME_SIZE; i++) { - player_select->land_name[i] = CHAR_SPACE; - } - player_select->land_exist = FALSE; + for (i = 0; i < SELECT_PLAYER_NUM; i++) { + int j; - if (mFRm_CheckSaveData() == TRUE) { - Private_c* private_p = Save_Get(private); - for (i = 0; i < PLAYER_NUM; i++) { - u8* name = player_select->player_names[i]; - - if (mPr_CheckPrivate(private_p) == TRUE) { - mPr_CopyPlayerName(name, private_p->player_ID.player_name); - - if (private_p->exists == FALSE) { - mem_copy(name + PLAYER_NAME_LEN, l_gaishutu_str, 10); - player_select->player_types[i] = PLAYER_SELECT_PLAYER_MODE_OUT; + for (j = 0; j < 6; j++) { + player_select->player_names[i][j] = mitouroku_str[j]; } - else { - mem_copy(name + PLAYER_NAME_LEN, l_zaitaku_str, 9); - player_select->player_types[i] = PLAYER_SELECT_PLAYER_MODE_HOME; - } - } - else { - player_select->player_types[i] = PLAYER_SELECT_PLAYER_MODE_UNREGISTERED; - } - private_p++; + for (j = 6; j < SELECT_NAME_LEN; j++) { + player_select->player_names[i][j] = CHAR_SPACE; + } + + player_select->player_types[i] = PLAYER_SELECT_PLAYER_MODE_NO_SAVE; } - mLd_CopyLandName(player_select->land_name, Save_Get(land_info.name)); - player_select->land_exist = TRUE; - } + for (i = 0; i < LAND_NAME_SIZE; i++) { + player_select->land_name[i] = CHAR_SPACE; + } + player_select->land_exist = FALSE; - for (i = 0; i < SELECT_PLAYER_NAME_EXTRA; i++) { - player_select->player_names[PLAYER_NUM][i] = l_yosokara_str[i]; - } + if (mFRm_CheckSaveData() == TRUE) { + Private_c* private_p = Save_Get(private_data); + for (i = 0; i < PLAYER_NUM; i++) { + u8* name = player_select->player_names[i]; - for (i = SELECT_PLAYER_NAME_EXTRA; i < SELECT_NAME_LEN; i++) { - player_select->player_names[PLAYER_NUM][i] = CHAR_SPACE; - } + if (mPr_CheckPrivate(private_p) == TRUE) { + mPr_CopyPlayerName(name, private_p->player_ID.player_name); - player_select->player_types[PLAYER_NUM] = PLAYER_SELECT_PLAYER_MODE_OUT; + if (private_p->exists == FALSE) { + mem_copy(name + PLAYER_NAME_LEN, l_gaishutu_str, 10); + player_select->player_types[i] = PLAYER_SELECT_PLAYER_MODE_OUT; + } else { + mem_copy(name + PLAYER_NAME_LEN, l_zaitaku_str, 9); + player_select->player_types[i] = PLAYER_SELECT_PLAYER_MODE_HOME; + } + } else { + player_select->player_types[i] = PLAYER_SELECT_PLAYER_MODE_UNREGISTERED; + } - for (i = 0; i < SELECT_PLAYER_NUM; i++) { - player_select->init_procs[i] = l_init_proc[player_select->player_types[i]]; - } + private_p++; + } - Common_Set(player_no, 0); - Common_Set(player_data_mode, 0); - Common_Set(scene_from_title_demo, -1); -} \ No newline at end of file + mLd_CopyLandName(player_select->land_name, Save_Get(land_info.name)); + player_select->land_exist = TRUE; + } + + for (i = 0; i < SELECT_PLAYER_NAME_EXTRA; i++) { + player_select->player_names[PLAYER_NUM][i] = l_yosokara_str[i]; + } + + for (i = SELECT_PLAYER_NAME_EXTRA; i < SELECT_NAME_LEN; i++) { + player_select->player_names[PLAYER_NUM][i] = CHAR_SPACE; + } + + player_select->player_types[PLAYER_NUM] = PLAYER_SELECT_PLAYER_MODE_OUT; + + for (i = 0; i < SELECT_PLAYER_NUM; i++) { + player_select->init_procs[i] = l_init_proc[player_select->player_types[i]]; + } + + Common_Set(player_no, 0); + Common_Set(player_data_mode, 0); + Common_Set(scene_from_title_demo, -1); +} diff --git a/src/save_check_MYK.c_inc b/src/save_check_MYK.c_inc index 23f9536c..e5211265 100644 --- a/src/save_check_MYK.c_inc +++ b/src/save_check_MYK.c_inc @@ -182,7 +182,7 @@ static int sSC_CheckSaveData_Needlework() { for (i = 0; i < PLAYER_NUM; i++) { for (j = 0; j < mPr_ORIGINAL_DESIGN_COUNT; j++) { - if (sSC_CheckOneOriginalData(Save_Get(private + i)->my_org + j) == FALSE) { + if (sSC_CheckOneOriginalData(Save_Get(private_data + i)->my_org + j) == FALSE) { mFRm_ERRORLINE(348); return sSC_MYK_ERR_NEEDLEWORK; } diff --git a/src/save_check_NSW.c_inc b/src/save_check_NSW.c_inc index f159b398..79922dec 100644 --- a/src/save_check_NSW.c_inc +++ b/src/save_check_NSW.c_inc @@ -1,244 +1,225 @@ static int sChk_lbRTC_ymd_c_NSW(lbRTC_ymd_c* ymd) { - int res = FALSE; + int res = FALSE; - if (ymd->year < GAME_YEAR_MIN + 1 || ymd->year > GAME_YEAR_MAX - 1) { - res = TRUE; - } - - if (ymd->month == 0 || ymd->month > lbRTC_MONTHS_MAX) { - res = TRUE; - } - - if (ymd->day == 0 || ymd->day > 31) { - res = TRUE; - } - - if (res == TRUE) { - if (ymd->year == 0 && ymd->month == 0 && ymd->day == 0) { - res = FALSE; + if (ymd->year < GAME_YEAR_MIN + 1 || ymd->year > GAME_YEAR_MAX - 1) { + res = TRUE; } - else if (ymd->year == mTM_rtcTime_ymd_clear_code.year && ymd->month == mTM_rtcTime_ymd_clear_code.month && ymd->day == mTM_rtcTime_ymd_clear_code.day) { - res = FALSE; + + if (ymd->month == 0 || ymd->month > lbRTC_MONTHS_MAX) { + res = TRUE; } - + + if (ymd->day == 0 || ymd->day > 31) { + res = TRUE; + } + if (res == TRUE) { - mFRm_set_errInfo(l_mfrm_err_info, 91, l_mfrm_now_color); - } - } + if (ymd->year == 0 && ymd->month == 0 && ymd->day == 0) { + res = FALSE; + } else if (ymd->year == mTM_rtcTime_ymd_clear_code.year && ymd->month == mTM_rtcTime_ymd_clear_code.month && + ymd->day == mTM_rtcTime_ymd_clear_code.day) { + res = FALSE; + } - return res; + if (res == TRUE) { + mFRm_set_errInfo(l_mfrm_err_info, 91, l_mfrm_now_color); + } + } + + return res; } static int sCck_CheckSaveData_radiocard_NSW(Private_c* priv) { - mPr_day_day_c* radiocard_p = &priv->radiocard; - int res; + mPr_day_day_c* radiocard_p = &priv->radiocard; + int res; - if (sChk_lbRTC_ymd_c_NSW(&radiocard_p->last_date)) { - mFRm_ERRORLINE(112); - res = TRUE; - } - else if (radiocard_p->days > mPr_RADIOCARD_MAX_DAYS) { - mFRm_ERRORLINE(121); - res = TRUE; - } - else { - res = FALSE; - } + if (sChk_lbRTC_ymd_c_NSW(&radiocard_p->last_date)) { + mFRm_ERRORLINE(112); + res = TRUE; + } else if (radiocard_p->days > mPr_RADIOCARD_MAX_DAYS) { + mFRm_ERRORLINE(121); + res = TRUE; + } else { + res = FALSE; + } - return res; + return res; } static int sCck_CheckSaveData_calendar_NSW(Private_c* priv) { - int res; + int res; - if (priv->calendar.edit > 1) { - mFRm_ERRORLINE(143); - res = TRUE; - } - else if (priv->calendar.pad_63 != 0) { - mFRm_ERRORLINE(151); - res = TRUE; - } - else if ( - ( - priv->calendar.year < GAME_YEAR_MIN + 1 || priv->calendar.year > GAME_YEAR_MAX - 1 || - priv->calendar.month == 0 || priv->calendar.month > lbRTC_DECEMBER - ) && - (priv->calendar.year != 0 || priv->calendar.month != 0) - ) { - mFRm_ERRORLINE(164); - res = TRUE; - } - else { - res = FALSE; - } + if (priv->calendar.edit > 1) { + mFRm_ERRORLINE(143); + res = TRUE; + } else if (priv->calendar.pad_63 != 0) { + mFRm_ERRORLINE(151); + res = TRUE; + } else if ((priv->calendar.year < GAME_YEAR_MIN + 1 || priv->calendar.year > GAME_YEAR_MAX - 1 || + priv->calendar.month == 0 || priv->calendar.month > lbRTC_DECEMBER) && + (priv->calendar.year != 0 || priv->calendar.month != 0)) { + mFRm_ERRORLINE(164); + res = TRUE; + } else { + res = FALSE; + } - return res; + return res; } static int sCck_CheckSaveData_deposit_NSW(Private_c* priv) { - int res; - int deposit = priv->bank_account; + int res; + int deposit = priv->bank_account; - if (deposit < 0 || deposit > mPr_DEPOSIT_MAX) { - mFRm_ERRORLINE(184); - res = TRUE; - } - else { - res = FALSE; - } + if (deposit < 0 || deposit > mPr_DEPOSIT_MAX) { + mFRm_ERRORLINE(184); + res = TRUE; + } else { + res = FALSE; + } - return res; + return res; } static int sCck_CheckSaveData_nw_visitor_NSW(Private_c* priv) { - mPr_day_day_c* nw_visitor_p = &priv->nw_visitor; - int res; + mPr_day_day_c* nw_visitor_p = &priv->nw_visitor; + int res; - if (sChk_lbRTC_ymd_c_NSW(&nw_visitor_p->last_date) != FALSE && nw_visitor_p->last_date.year != 0) { - mFRm_ERRORLINE(204); - res = TRUE; - } - else { - res = FALSE; - } + if (sChk_lbRTC_ymd_c_NSW(&nw_visitor_p->last_date) != FALSE && nw_visitor_p->last_date.year != 0) { + mFRm_ERRORLINE(204); + res = TRUE; + } else { + res = FALSE; + } - return res; + return res; } static int sCck_CheckSaveData_my_org_no_table_NSW(Private_c* priv) { - u8 my_org_no; - int field = 0; - int total = 0; - u8* my_org_no_table = priv->my_org_no_table; - int i; - int res; + u8 my_org_no; + int field = 0; + 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++) { - my_org_no = my_org_no_table[i]; + for (i = 0; i < mPr_ORIGINAL_DESIGN_COUNT; i++) { + my_org_no = my_org_no_table[i]; - if (my_org_no >= mPr_ORIGINAL_DESIGN_COUNT) { - return TRUE; + if (my_org_no >= mPr_ORIGINAL_DESIGN_COUNT) { + return TRUE; + } + + total += my_org_no; + field |= (u16)(1 << my_org_no); } - total += my_org_no; - field |= (u16)(1 << my_org_no); - } + if ((u16)field != (u16)((1 << mPr_ORIGINAL_DESIGN_COUNT) - 1) && total != 0) { + mFRm_ERRORLINE(239); + res = TRUE; + } else { + res = FALSE; + } - if ((u16)field != (u16)((1 << mPr_ORIGINAL_DESIGN_COUNT) - 1) && total != 0) { - mFRm_ERRORLINE(239); - res = TRUE; - } - else { - res = FALSE; - } - - return res; + return res; } static int sCck_CheckSaveData_bridge_NSW() { - PlusBridge_c* bridge = Save_GetPointer(bridge); + PlusBridge_c* bridge = Save_GetPointer(bridge); - if (sChk_lbRTC_ymd_c_NSW(&bridge->build_date)) { - mFRm_ERRORLINE(259); - return TRUE; - } - else if (bridge->exists || bridge->pending) { - if ( - bridge->block_x == 0 || bridge->block_x > FG_BLOCK_X_NUM || - bridge->block_z == 0 || bridge->block_z > FG_BLOCK_Z_NUM - ) { - mFRm_ERRORLINE(271); - return TRUE; + if (sChk_lbRTC_ymd_c_NSW(&bridge->build_date)) { + mFRm_ERRORLINE(259); + return TRUE; + } else if (bridge->exists || bridge->pending) { + if (bridge->block_x == 0 || bridge->block_x > FG_BLOCK_X_NUM || bridge->block_z == 0 || + bridge->block_z > FG_BLOCK_Z_NUM) { + mFRm_ERRORLINE(271); + return TRUE; + } + } else if (bridge->block_x != 0 || bridge->block_z != 0) { + mFRm_ERRORLINE(280); + return TRUE; } - } - else if (bridge->block_x != 0 || bridge->block_z != 0) { - mFRm_ERRORLINE(280); - return TRUE; - } - return FALSE; + return FALSE; } static int sCck_CheckSaveData_fishRecord_NSW() { - mFR_record_c* record; - lbRTC_ymd_c ymd; - int i; + mFR_record_c* record; + lbRTC_ymd_c ymd; + int i; - for (i = 0; i < mFR_RECORD_NUM; i++) { - record = Save_Get(fishRecord + i); - mTM_set_renew_time(&ymd, &record->time); + for (i = 0; i < mFR_RECORD_NUM; i++) { + record = Save_Get(fishRecord + i); + mTM_set_renew_time(&ymd, &record->time); - if (record->size < 0) { - mFRm_ERRORLINE(307); - return TRUE; + if (record->size < 0) { + mFRm_ERRORLINE(307); + return TRUE; + } + + if (record->size != 0 && sChk_lbRTC_ymd_c_NSW(&ymd) == TRUE) { + mFRm_ERRORLINE(316); + return TRUE; + } } - if (record->size != 0 && sChk_lbRTC_ymd_c_NSW(&ymd) == TRUE) { - mFRm_ERRORLINE(316); - return TRUE; - } - } - - return FALSE; + return FALSE; } static int sCck_CheckSaveData_Anmret_NSW() { - Anmret_c* anmret = Save_GetPointer(return_animal); - int res; - lbRTC_ymd_c ymd; + Anmret_c* anmret = Save_GetPointer(return_animal); + int res; + lbRTC_ymd_c ymd; - if (anmret->npc_id != EMPTY_NO && ITEM_NAME_GET_TYPE(anmret->npc_id) != NAME_TYPE_NPC) { - mFRm_ERRORLINE(339); - res = TRUE; - } - else { - mTM_set_renew_time(&ymd, &anmret->renew_time); + if (anmret->npc_id != EMPTY_NO && ITEM_NAME_GET_TYPE(anmret->npc_id) != NAME_TYPE_NPC) { + mFRm_ERRORLINE(339); + res = TRUE; + } else { + mTM_set_renew_time(&ymd, &anmret->renew_time); - if (sChk_lbRTC_ymd_c_NSW(&ymd) == TRUE) { - mFRm_ERRORLINE(349); - res = TRUE; + if (sChk_lbRTC_ymd_c_NSW(&ymd) == TRUE) { + mFRm_ERRORLINE(349); + res = TRUE; + } else { + res = FALSE; + } } - else { - res = FALSE; - } - } - return res; + return res; } static int sCck_CheckSaveData_LightHouse_NSW() { - int res; + int res; - if (sChk_lbRTC_ymd_c_NSW(&Save_Get(LightHouse).renew_time) == TRUE) { - mFRm_ERRORLINE(368); - res = TRUE; - } - else { - res = FALSE; - } + if (sChk_lbRTC_ymd_c_NSW(&Save_Get(LightHouse).renew_time) == TRUE) { + mFRm_ERRORLINE(368); + res = TRUE; + } else { + res = FALSE; + } - return res; + return res; } static int sChk_CheckSaveData_NSW() { - int res = FALSE; - int i; + int res = FALSE; + int i; - for (i = 0; i < PLAYER_NUM; i++) { - Private_c* priv = Save_Get(private) + i; + for (i = 0; i < PLAYER_NUM; i++) { + Private_c* priv = Save_Get(private_data) + i; - res |= sCck_CheckSaveData_radiocard_NSW(priv); - res |= sCck_CheckSaveData_calendar_NSW(priv); - res |= sCck_CheckSaveData_deposit_NSW(priv); - res |= sCck_CheckSaveData_nw_visitor_NSW(priv); - res |= sCck_CheckSaveData_my_org_no_table_NSW(priv); - } + res |= sCck_CheckSaveData_radiocard_NSW(priv); + res |= sCck_CheckSaveData_calendar_NSW(priv); + res |= sCck_CheckSaveData_deposit_NSW(priv); + res |= sCck_CheckSaveData_nw_visitor_NSW(priv); + res |= sCck_CheckSaveData_my_org_no_table_NSW(priv); + } - res |= sCck_CheckSaveData_bridge_NSW(); - res |= sCck_CheckSaveData_fishRecord_NSW(); - res |= sCck_CheckSaveData_Anmret_NSW(); - res |= sCck_CheckSaveData_LightHouse_NSW(); + res |= sCck_CheckSaveData_bridge_NSW(); + res |= sCck_CheckSaveData_fishRecord_NSW(); + res |= sCck_CheckSaveData_Anmret_NSW(); + res |= sCck_CheckSaveData_LightHouse_NSW(); - return res; + return res; } diff --git a/src/save_check_YSD.c_inc b/src/save_check_YSD.c_inc index ebd91eec..dc845fc6 100644 --- a/src/save_check_YSD.c_inc +++ b/src/save_check_YSD.c_inc @@ -1,105 +1,78 @@ static int sCck_CheckSaveData_diary_body_YSD(Private_c* priv) { - return FALSE; + return FALSE; } static int sCCk_Check_ItemName(mActor_name_t item) { - /* TODO: do not hardcode this */ - static s16 item1_kinds[ITEM1_CAT_NUM] = { - 255, - 3, - 91, - 39, - 254, - 48, - 66, - 66, - 7, - 10, - 54, - 15, - 95, - 44, - 1, - 3 - }; + /* TODO: do not hardcode this */ + static s16 item1_kinds[ITEM1_CAT_NUM] = { 255, 3, 91, 39, 254, 48, 66, 66, 7, 10, 54, 15, 95, 44, 1, 3 }; - mActor_name_t item_name = (mActor_name_t)item; - int item_type = ITEM_NAME_GET_TYPE(item_name); - int res = FALSE; + mActor_name_t item_name = (mActor_name_t)item; + int item_type = ITEM_NAME_GET_TYPE(item_name); + int res = FALSE; - if (item_type == NAME_TYPE_ITEM1) { - int index = ITEM_NAME_GET_INDEX(item_name); - int category = ITEM_NAME_GET_CAT(item_name); - - if ( - index < 0 || - index > item1_kinds[category] || - item_name == ITM_SICKLE /* ??? why is this explicitly invalid... lol */ - ) { - res = TRUE; + if (item_type == NAME_TYPE_ITEM1) { + int index = ITEM_NAME_GET_INDEX(item_name); + int category = ITEM_NAME_GET_CAT(item_name); + + if (index < 0 || index > item1_kinds[category] || + item_name == ITM_SICKLE /* ??? why is this explicitly invalid... lol */ + ) { + res = TRUE; + } + } else if (item_name != EMPTY_NO && item_type != NAME_TYPE_FTR0 && item_type != NAME_TYPE_FTR1) { + mFRm_ERRORLINE(110); + res = TRUE; } - } - else if (item_name != EMPTY_NO && item_type != NAME_TYPE_FTR0 && item_type != NAME_TYPE_FTR1) { - mFRm_ERRORLINE(110); - res = TRUE; - } - return res; + return res; } static int sCCk_Check_ItemName_Possession(mActor_name_t item) { - int res = FALSE; + int res = FALSE; - if ( - sCCk_Check_ItemName(item) || - (item >= ITM_MY_ORG_UMBRELLA0 && item <= ITM_MY_ORG_UMBRELLA7) || - (item >= ITM_RED_PAINT && item <= ITM_BROWN_PAINT) || - item == ITM_PRESENT || - item == ITM_TOWN_MAP || - item == ITM_GOLDEN_NET_PRESENT || - item == ITM_GOLDEN_AXE_PRESENT || - item == ITM_GOLDEN_SHOVEL_PRESENT || - item == ITM_GOLDEN_ROD_PRESENT - ) { - mFRm_ERRORLINE(141); - res = TRUE; - } + if (sCCk_Check_ItemName(item) || (item >= ITM_MY_ORG_UMBRELLA0 && item <= ITM_MY_ORG_UMBRELLA7) || + (item >= ITM_RED_PAINT && item <= ITM_BROWN_PAINT) || item == ITM_PRESENT || item == ITM_TOWN_MAP || + item == ITM_GOLDEN_NET_PRESENT || item == ITM_GOLDEN_AXE_PRESENT || item == ITM_GOLDEN_SHOVEL_PRESENT || + item == ITM_GOLDEN_ROD_PRESENT) { + mFRm_ERRORLINE(141); + res = TRUE; + } - return res; + return res; } static int sCck_CheckSaveData_Item_YSD(Private_c* priv) { - int i; + int i; - for (i = 0; i < mPr_POCKETS_SLOT_COUNT; i++) { - sCCk_Check_ItemName_Possession(priv->inventory.pockets[i]); - } + for (i = 0; i < mPr_POCKETS_SLOT_COUNT; i++) { + sCCk_Check_ItemName_Possession(priv->inventory.pockets[i]); + } - return FALSE; + return FALSE; } static int sCck_CheckSaveData_Mail_YSD(Private_c* priv) { - int res = FALSE; - int i; + int res = FALSE; + int i; - for (i = 0; i < mPr_INVENTORY_MAIL_COUNT; i++) { - res |= sChk_Mail_c_sub(priv->mail + i, 0); - } + for (i = 0; i < mPr_INVENTORY_MAIL_COUNT; i++) { + res |= sChk_Mail_c_sub(priv->mail + i, 0); + } - return FALSE; + return FALSE; } static int sChk_CheckSaveData_YSD() { - int res = FALSE; - int i; + int res = FALSE; + int i; - for (i = 0; i < PLAYER_NUM; i++) { - Private_c* priv = Save_Get(private) + i; + for (i = 0; i < PLAYER_NUM; i++) { + Private_c* priv = Save_Get(private_data) + i; - res |= sCck_CheckSaveData_Item_YSD(priv); - res |= sCck_CheckSaveData_Mail_YSD(priv); - res |= sCck_CheckSaveData_diary_body_YSD(priv); - } + res |= sCck_CheckSaveData_Item_YSD(priv); + res |= sCck_CheckSaveData_Mail_YSD(priv); + res |= sCck_CheckSaveData_diary_body_YSD(priv); + } - return res; + return res; } diff --git a/src/save_check_komatu.c_inc b/src/save_check_komatu.c_inc index 049f502f..db06ef49 100644 --- a/src/save_check_komatu.c_inc +++ b/src/save_check_komatu.c_inc @@ -1,75 +1,75 @@ static int sChk_CheckSaveData_komatu() { - int i; - int j; + int i; + int j; - for (i = 0; i < PLAYER_NUM; i++) { - Private_c* priv = Save_Get(private) + i; + for (i = 0; i < PLAYER_NUM; i++) { + Private_c* priv = Save_Get(private_data) + i; - { - const u8 gender = priv->gender; - if (gender > mPr_SEX_FEMALE) { - return TRUE; - } - } - - { - s8 face = priv->face; - if (face < 0 || face >= mPr_FACE_TYPE_NUM) { - return TRUE; - } - } - - { - mPr_cloth_c* cloth = &priv->cloth; - u16 idx = cloth->idx; - mActor_name_t item; - - if (idx >= (256 + 8) || idx == 255) { - return TRUE; - } - - item = cloth->item; - if (item != EMPTY_NO) { - int valid_cloth = item == RSV_CLOTH || (item >= ITM_CLOTH000 && item < ITM_CLOTH_END); - - if (valid_cloth == FALSE) { - return TRUE; + { + const u8 gender = priv->gender; + if (gender > mPr_SEX_FEMALE) { + return TRUE; + } } - } - } - { - mPr_destiny_c* destiny = &priv->destiny; - - if (destiny->type >= mPr_DESTINY_NUM) { - return TRUE; - } - } - - { - mPr_sunburn_c* sunburn = &priv->sunburn; - s8 t = sunburn->rank; - s8 t2; - - if (t < 0 || t >= mPr_SUNBURN_RANK_NUM) { - return TRUE; - } - - t2 = sunburn->rankdown_days; - if (t2 < 0 || t2 > 2) { - return TRUE; - } - } - - { - u8 golden_items_collected = priv->golden_items_collected; - for (j = 4; j < 8; j++) { - if (golden_items_collected & ((u8)(1 << j))) { - return TRUE; + { + s8 face = priv->face; + if (face < 0 || face >= mPr_FACE_TYPE_NUM) { + return TRUE; + } } - } - } - } - return FALSE; + { + mPr_cloth_c* cloth = &priv->cloth; + u16 idx = cloth->idx; + mActor_name_t item; + + if (idx >= (256 + 8) || idx == 255) { + return TRUE; + } + + item = cloth->item; + if (item != EMPTY_NO) { + int valid_cloth = item == RSV_CLOTH || (item >= ITM_CLOTH000 && item < ITM_CLOTH_END); + + if (valid_cloth == FALSE) { + return TRUE; + } + } + } + + { + mPr_destiny_c* destiny = &priv->destiny; + + if (destiny->type >= mPr_DESTINY_NUM) { + return TRUE; + } + } + + { + mPr_sunburn_c* sunburn = &priv->sunburn; + s8 t = sunburn->rank; + s8 t2; + + if (t < 0 || t >= mPr_SUNBURN_RANK_NUM) { + return TRUE; + } + + t2 = sunburn->rankdown_days; + if (t2 < 0 || t2 > 2) { + return TRUE; + } + } + + { + u8 golden_items_collected = priv->golden_items_collected; + for (j = 4; j < 8; j++) { + if (golden_items_collected & ((u8)(1 << j))) { + return TRUE; + } + } + } + } + + return FALSE; } diff --git a/src/save_menu.c b/src/save_menu.c index 1098ba40..f18298d5 100644 --- a/src/save_menu.c +++ b/src/save_menu.c @@ -12,253 +12,239 @@ #include "m_common_data.h" static void save_menu_set_cursor_col(GAME_SAVE_MENU* save_menu) { - /* this was likely meant to be static */ - int cursor_col[10][3] = { - { 192, 120, 120 }, - { 224, 130, 130 }, - { 240, 150, 150 }, - { 255, 180, 180 }, - { 240, 150, 150 }, - { 224, 130, 130 }, - { 192, 120, 120 }, - { 128, 80, 80 }, - { 64, 64, 64 }, - { 128, 80, 80 }, - }; + /* this was likely meant to be static */ + int cursor_col[10][3] = { + { 192, 120, 120 }, { 224, 130, 130 }, { 240, 150, 150 }, { 255, 180, 180 }, { 240, 150, 150 }, + { 224, 130, 130 }, { 192, 120, 120 }, { 128, 80, 80 }, { 64, 64, 64 }, { 128, 80, 80 }, + }; - int (*dst)[3] = &save_menu->cursor_col[save_menu->mode]; - int (*color)[3] = &cursor_col[(u32)save_menu->frame / 4]; - int i; - for (i = 0; i < 3; i++) { - (*dst)[i] = (*color)[i]; - } + int(*dst)[3] = &save_menu->cursor_col[save_menu->mode]; + int(*color)[3] = &cursor_col[(u32)save_menu->frame / 4]; + int i; + for (i = 0; i < 3; i++) { + (*dst)[i] = (*color)[i]; + } } static void save_menu_reset_cursor_col(int (*color)[3]) { - int default_color[3] = { 40, 40, 40 }; - int i; + int default_color[3] = { 40, 40, 40 }; + int i; - for (i = 0; i < 3; i++) { - (*color)[i] = default_color[i]; - } + for (i = 0; i < 3; i++) { + (*color)[i] = default_color[i]; + } } typedef void (*SAVE_MENU_PROC)(GAME_SAVE_MENU*); static void save_menu_data_save_from(GAME_SAVE_MENU* save_menu) { - if ((int)Common_Get(player_no) != mPr_FOREIGNER) { - Common_Get(now_private)->exists = TRUE; - save_menu->error = SAVE_ERROR_EXIT; // OK - } - else { - save_menu->error = SAVE_ERROR_FLASHROM; // Player is foriegner - } + if ((int)Common_Get(player_no) != mPr_FOREIGNER) { + Common_Get(now_private)->exists = TRUE; + save_menu->error = SAVE_ERROR_EXIT; // OK + } else { + save_menu->error = SAVE_ERROR_FLASHROM; // Player is foriegner + } } static void save_menu_data_save_pak(GAME_SAVE_MENU* save_menu) { - Private_c* private = Common_Get(now_private); - if ((int)Common_Get(player_no) == mPr_FOREIGNER) { - AnmPersonalID_c* foriegn_id = mNpc_GetOtherAnimalPersonalID(NULL, 0); - if (foriegn_id != NULL) { - mNpc_CopyAnimalPersonalID(&private->stored_anm_id, foriegn_id); - } - } - - mCPk_PakOpen(mCPk_get_pkinfo(), 0); - if (mCPk_SavePak(Save_Get(private), Save_Get(animals), mCPk_get_pkinfo()) == TRUE) { - if (mLd_PlayerManKindCheck() == FALSE) { - Common_Get(now_private)->exists = FALSE; + Private_c* private = Common_Get(now_private); + if ((int)Common_Get(player_no) == mPr_FOREIGNER) { + AnmPersonalID_c* foriegn_id = mNpc_GetOtherAnimalPersonalID(NULL, 0); + if (foriegn_id != NULL) { + mNpc_CopyAnimalPersonalID(&private->stored_anm_id, foriegn_id); + } } - save_menu->error = SAVE_ERROR_EXIT; // OK - } - else { - save_menu->error = SAVE_ERROR_CPAK; // Failed to save to CPak - } + mCPk_PakOpen(mCPk_get_pkinfo(), 0); + if (mCPk_SavePak(Save_Get(private_data), Save_Get(animals), mCPk_get_pkinfo()) == TRUE) { + if (mLd_PlayerManKindCheck() == FALSE) { + Common_Get(now_private)->exists = FALSE; + } + + save_menu->error = SAVE_ERROR_EXIT; // OK + } else { + save_menu->error = SAVE_ERROR_CPAK; // Failed to save to CPak + } } static void save_menu_move_do_save(GAME_SAVE_MENU* save_menu) { - static SAVE_MENU_PROC save_proc[SAVE_MODE_NUM] = { &save_menu_data_save_from, &save_menu_data_save_pak }; + static SAVE_MENU_PROC save_proc[SAVE_MODE_NUM] = { &save_menu_data_save_from, &save_menu_data_save_pak }; - int mode = save_menu->mode; + int mode = save_menu->mode; - /* Check and save to select location */ - if (chkTrigger(BUTTON_A)) { - (*save_proc[mode])(save_menu); - } - - /* Check and change selected save mode */ - if (chkTrigger(BUTTON_R) || chkTrigger(BUTTON_DUP) || chkTrigger(BUTTON_DDOWN)) { - save_menu->frame = 0; - save_menu_reset_cursor_col(save_menu->cursor_col + mode); - save_menu->mode++; - - if (save_menu->mode >= SAVE_MODE_NUM) { - save_menu->mode = SAVE_MODE_BEGIN; + /* Check and save to select location */ + if (chkTrigger(BUTTON_A)) { + (*save_proc[mode])(save_menu); } - } - /* Check if should exit menu */ - if (chkTrigger(BUTTON_B)) { - save_menu->error = SAVE_ERROR_EXIT; // OK - } + /* Check and change selected save mode */ + if (chkTrigger(BUTTON_R) || chkTrigger(BUTTON_DUP) || chkTrigger(BUTTON_DDOWN)) { + save_menu->frame = 0; + save_menu_reset_cursor_col(save_menu->cursor_col + mode); + save_menu->mode++; + + if (save_menu->mode >= SAVE_MODE_NUM) { + save_menu->mode = SAVE_MODE_BEGIN; + } + } + + /* Check if should exit menu */ + if (chkTrigger(BUTTON_B)) { + save_menu->error = SAVE_ERROR_EXIT; // OK + } } static void save_menu_move_finish(GAME_SAVE_MENU* save_menu) { - GAME_GOTO_NEXT((GAME*)save_menu, trademark, TRADEMARK); + GAME_GOTO_NEXT((GAME*)save_menu, trademark, TRADEMARK); } static void save_menu_move_err(GAME_SAVE_MENU* save_menu) { - save_menu->error = SAVE_ERROR_NONE; // cleared + save_menu->error = SAVE_ERROR_NONE; // cleared } static void save_menu_move_main(GAME_SAVE_MENU* save_menu) { - static SAVE_MENU_PROC sub_proc[SAVE_ERROR_NUM] = { - &save_menu_move_do_save, - &save_menu_move_err, - &save_menu_move_err, - &save_menu_move_finish - }; + static SAVE_MENU_PROC sub_proc[SAVE_ERROR_NUM] = { &save_menu_move_do_save, &save_menu_move_err, + &save_menu_move_err, &save_menu_move_finish }; - int error = save_menu->error; + int error = save_menu->error; - if (error >= SAVE_ERROR_NONE && error < SAVE_ERROR_NUM) { - (*sub_proc[error])(save_menu); - } + if (error >= SAVE_ERROR_NONE && error < SAVE_ERROR_NUM) { + (*sub_proc[error])(save_menu); + } - save_menu_set_cursor_col(save_menu); - save_menu->frame++; + save_menu_set_cursor_col(save_menu); + save_menu->frame++; - if (save_menu->frame == 40) { - save_menu->frame = 0; - } + if (save_menu->frame == 40) { + save_menu->frame = 0; + } } static void save_menu_draw_title(GAME_SAVE_MENU* save_menu) { - /* This translates to 'セーブ メニュー' (save menu), the devs didn't bother translating it */ - u8 title[] = { 0x9E, 0x90, 0xDF, CHAR_SPACE, 0xB2, 0xA6, 0x8D, 0x90 }; + /* This translates to 'セーブ メニュー' (save menu), the devs didn't bother translating it */ + u8 title[] = { 0x9E, 0x90, 0xDF, CHAR_SPACE, 0xB2, 0xA6, 0x8D, 0x90 }; - mFont_SetMatrix(save_menu->game.graph, mFont_MODE_FONT); - mFont_SetLineStrings_AndSpace((GAME*)save_menu, title, ARRAY_SIZE(title, u8), 110.0f, 30.0f, 200, 50, 50, 255, FALSE, TRUE, FALSE, 1.1f, 1.1f, mFont_MODE_FONT); - mFont_UnSetMatrix(save_menu->game.graph, mFont_MODE_FONT); + mFont_SetMatrix(save_menu->game.graph, mFont_MODE_FONT); + mFont_SetLineStrings_AndSpace((GAME*)save_menu, title, ARRAY_SIZE(title, u8), 110.0f, 30.0f, 200, 50, 50, 255, + FALSE, TRUE, FALSE, 1.1f, 1.1f, mFont_MODE_FONT); + mFont_UnSetMatrix(save_menu->game.graph, mFont_MODE_FONT); } static void save_menu_draw_push_a(GAME_SAVE_MENU* save_menu) { - /* Push A Button */ - u8 push_a[] = { CHAR_P, CHAR_u, CHAR_s, CHAR_h, CHAR_SPACE, CHAR_A, CHAR_SPACE, CHAR_B, CHAR_u, CHAR_t, CHAR_t, CHAR_o, CHAR_n }; + /* Push A Button */ + u8 push_a[] = { CHAR_P, CHAR_u, CHAR_s, CHAR_h, CHAR_SPACE, CHAR_A, CHAR_SPACE, + CHAR_B, CHAR_u, CHAR_t, CHAR_t, CHAR_o, CHAR_n }; - mFont_SetMatrix(save_menu->game.graph, mFont_MODE_FONT); - mFont_SetLineStrings_AndSpace((GAME*)save_menu, push_a, ARRAY_SIZE(push_a, u8), 95.0f, 175.0f, 200, 200, 200, 255, FALSE, TRUE, FALSE, 0.8f, 0.8f, mFont_MODE_FONT); - mFont_UnSetMatrix(save_menu->game.graph, mFont_MODE_FONT); + mFont_SetMatrix(save_menu->game.graph, mFont_MODE_FONT); + mFont_SetLineStrings_AndSpace((GAME*)save_menu, push_a, ARRAY_SIZE(push_a, u8), 95.0f, 175.0f, 200, 200, 200, 255, + FALSE, TRUE, FALSE, 0.8f, 0.8f, mFont_MODE_FONT); + mFont_UnSetMatrix(save_menu->game.graph, mFont_MODE_FONT); } static void save_menu_draw_select_r(GAME_SAVE_MENU* save_menu) { - /* Select R Button */ - u8 select_r[] = { CHAR_S, CHAR_e, CHAR_l, CHAR_e, CHAR_c, CHAR_t, CHAR_SPACE, CHAR_R, CHAR_SPACE, CHAR_B, CHAR_u, CHAR_t, CHAR_t, CHAR_o, CHAR_n }; + /* Select R Button */ + u8 select_r[] = { CHAR_S, CHAR_e, CHAR_l, CHAR_e, CHAR_c, CHAR_t, CHAR_SPACE, CHAR_R, + CHAR_SPACE, CHAR_B, CHAR_u, CHAR_t, CHAR_t, CHAR_o, CHAR_n }; - mFont_SetMatrix(save_menu->game.graph, mFont_MODE_FONT); - mFont_SetLineStrings_AndSpace((GAME*)save_menu, select_r, ARRAY_SIZE(select_r, u8), 76.0f, 185.0f, 200, 200, 200, 255, FALSE, TRUE, FALSE, 0.8f, 0.8f, mFont_MODE_FONT); - mFont_UnSetMatrix(save_menu->game.graph, mFont_MODE_FONT); + mFont_SetMatrix(save_menu->game.graph, mFont_MODE_FONT); + mFont_SetLineStrings_AndSpace((GAME*)save_menu, select_r, ARRAY_SIZE(select_r, u8), 76.0f, 185.0f, 200, 200, 200, + 255, FALSE, TRUE, FALSE, 0.8f, 0.8f, mFont_MODE_FONT); + mFont_UnSetMatrix(save_menu->game.graph, mFont_MODE_FONT); } static void save_menu_draw_push_b(GAME_SAVE_MENU* save_menu) { - /* Push B Button to EXIT */ - u8 push_b[] = { CHAR_P, CHAR_u, CHAR_s, CHAR_h, CHAR_SPACE, CHAR_B, CHAR_SPACE, CHAR_B, CHAR_u, CHAR_t, CHAR_t, CHAR_o, CHAR_n, CHAR_SPACE, CHAR_t, CHAR_o, CHAR_SPACE, CHAR_E, CHAR_X, CHAR_I, CHAR_T }; + /* Push B Button to EXIT */ + u8 push_b[] = { CHAR_P, CHAR_u, CHAR_s, CHAR_h, CHAR_SPACE, CHAR_B, CHAR_SPACE, + CHAR_B, CHAR_u, CHAR_t, CHAR_t, CHAR_o, CHAR_n, CHAR_SPACE, + CHAR_t, CHAR_o, CHAR_SPACE, CHAR_E, CHAR_X, CHAR_I, CHAR_T }; - mFont_SetMatrix(save_menu->game.graph, mFont_MODE_FONT); - mFont_SetLineStrings_AndSpace((GAME*)save_menu, push_b, ARRAY_SIZE(push_b, u8), 50.0f, 210.0f, 200, 200, 200, 255, FALSE, TRUE, FALSE, 0.8f, 0.8f, mFont_MODE_FONT); - mFont_UnSetMatrix(save_menu->game.graph, mFont_MODE_FONT); + mFont_SetMatrix(save_menu->game.graph, mFont_MODE_FONT); + mFont_SetLineStrings_AndSpace((GAME*)save_menu, push_b, ARRAY_SIZE(push_b, u8), 50.0f, 210.0f, 200, 200, 200, 255, + FALSE, TRUE, FALSE, 0.8f, 0.8f, mFont_MODE_FONT); + mFont_UnSetMatrix(save_menu->game.graph, mFont_MODE_FONT); } static void save_menu_draw_select_mode(GAME_SAVE_MENU* save_menu) { - /* + /* - [0] = 'FlashRom にセーブ' "Save to FlashRom" - [1] = 'パック にセーブ ' "Save to Pak" + [0] = 'FlashRom にセーブ' "Save to FlashRom" + [1] = 'パック にセーブ ' "Save to Pak" - */ - u8 select_mode[SAVE_MODE_NUM][13] = { - { CHAR_F, CHAR_l, CHAR_a, CHAR_s, CHAR_h, CHAR_R, CHAR_o, CHAR_m, CHAR_SPACE, 0x15, 0x9E, 0x90, 0xDF }, - { 0xE2, 0x8F, 0x98, CHAR_SPACE, 0x15, 0x9E, 0x90, 0xDF, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE }, - }; + */ + u8 select_mode[SAVE_MODE_NUM][13] = { + { CHAR_F, CHAR_l, CHAR_a, CHAR_s, CHAR_h, CHAR_R, CHAR_o, CHAR_m, CHAR_SPACE, 0x15, 0x9E, 0x90, 0xDF }, + { 0xE2, 0x8F, 0x98, CHAR_SPACE, 0x15, 0x9E, 0x90, 0xDF, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, CHAR_SPACE, + CHAR_SPACE }, + }; - mFont_SetMatrix(save_menu->game.graph, mFont_MODE_FONT); - mFont_SetLineStrings_AndSpace( - (GAME*)save_menu, - select_mode[SAVE_MODE_FLASHROM], ARRAY_SIZE(select_mode[SAVE_MODE_FLASHROM], u8), - 60.0f, 85.0f, - save_menu->cursor_col[SAVE_MODE_FLASHROM][0], save_menu->cursor_col[SAVE_MODE_FLASHROM][1], save_menu->cursor_col[SAVE_MODE_FLASHROM][2], 255, - FALSE, TRUE, FALSE, - 1.2f, 1.2f, - mFont_MODE_FONT - ); - mFont_UnSetMatrix(save_menu->game.graph, mFont_MODE_FONT); + mFont_SetMatrix(save_menu->game.graph, mFont_MODE_FONT); + mFont_SetLineStrings_AndSpace( + (GAME*)save_menu, select_mode[SAVE_MODE_FLASHROM], ARRAY_SIZE(select_mode[SAVE_MODE_FLASHROM], u8), 60.0f, + 85.0f, save_menu->cursor_col[SAVE_MODE_FLASHROM][0], save_menu->cursor_col[SAVE_MODE_FLASHROM][1], + save_menu->cursor_col[SAVE_MODE_FLASHROM][2], 255, FALSE, TRUE, FALSE, 1.2f, 1.2f, mFont_MODE_FONT); + mFont_UnSetMatrix(save_menu->game.graph, mFont_MODE_FONT); - mFont_SetMatrix(save_menu->game.graph, mFont_MODE_FONT); - mFont_SetLineStrings_AndSpace( - (GAME*)save_menu, - select_mode[SAVE_MODE_CPAK], ARRAY_SIZE(select_mode[SAVE_MODE_CPAK], u8), - 100.0f, 125.0f, - save_menu->cursor_col[SAVE_MODE_CPAK][0], save_menu->cursor_col[SAVE_MODE_CPAK][1], save_menu->cursor_col[SAVE_MODE_CPAK][2], 255, - FALSE, TRUE, FALSE, - 1.2f, 1.2f, - mFont_MODE_FONT - ); - mFont_UnSetMatrix(save_menu->game.graph, mFont_MODE_FONT); + mFont_SetMatrix(save_menu->game.graph, mFont_MODE_FONT); + mFont_SetLineStrings_AndSpace( + (GAME*)save_menu, select_mode[SAVE_MODE_CPAK], ARRAY_SIZE(select_mode[SAVE_MODE_CPAK], u8), 100.0f, 125.0f, + save_menu->cursor_col[SAVE_MODE_CPAK][0], save_menu->cursor_col[SAVE_MODE_CPAK][1], + save_menu->cursor_col[SAVE_MODE_CPAK][2], 255, FALSE, TRUE, FALSE, 1.2f, 1.2f, mFont_MODE_FONT); + mFont_UnSetMatrix(save_menu->game.graph, mFont_MODE_FONT); } extern void save_menu_draw_main(GAME_SAVE_MENU* save_menu) { - GRAPH* g = save_menu->game.graph; + GRAPH* g = save_menu->game.graph; - OPEN_DISP(g); + OPEN_DISP(g); - gSPSegment(NOW_POLY_OPA_DISP++, G_MWO_SEGMENT_0, 0); - DisplayList_initialize(g, 0, 0, 0, NULL); - gDPPipeSync(NOW_POLY_OPA_DISP++); + gSPSegment(NOW_POLY_OPA_DISP++, G_MWO_SEGMENT_0, 0); + DisplayList_initialize(g, 0, 0, 0, NULL); + gDPPipeSync(NOW_POLY_OPA_DISP++); - CLOSE_DISP(g); + CLOSE_DISP(g); - showView(&save_menu->view, VIEW_UPDATE_ALL); - save_menu_draw_title(save_menu); - save_menu_draw_push_a(save_menu); - save_menu_draw_select_r(save_menu); - save_menu_draw_push_b(save_menu); - save_menu_draw_select_mode(save_menu); + showView(&save_menu->view, VIEW_UPDATE_ALL); + save_menu_draw_title(save_menu); + save_menu_draw_push_a(save_menu); + save_menu_draw_select_r(save_menu); + save_menu_draw_push_b(save_menu); + save_menu_draw_select_mode(save_menu); } static void save_menu_main(GAME* game) { - GRAPH* g; - GAME_SAVE_MENU* save_menu = (GAME_SAVE_MENU*)game; - save_menu_move_main(save_menu); - save_menu_draw_main(save_menu); + GRAPH* g; + GAME_SAVE_MENU* save_menu = (GAME_SAVE_MENU*)game; + save_menu_move_main(save_menu); + save_menu_draw_main(save_menu); - g = game->graph; - game_debug_draw_last(game, g); - game_draw_last(g); + g = game->graph; + game_debug_draw_last(game, g); + game_draw_last(g); } -extern void save_menu_cleanup(GAME* game) { } +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; - int i; + GRAPH* g = game->graph; + View* view; + GAME_SAVE_MENU* save_menu = (GAME_SAVE_MENU*)game; + int i; - game->exec = &save_menu_main; - game->cleanup = &save_menu_cleanup; + 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); + view = &save_menu->view; + initView(view, g); + view->flag = VIEW_UPDATE_ORTHOGRAPHIC; + new_Matrix(game); + SetGameFrame(1); - save_menu->frame = 0; - save_menu->mode = SAVE_MODE_BEGIN; - save_menu->error = SAVE_ERROR_NONE; + save_menu->frame = 0; + save_menu->mode = SAVE_MODE_BEGIN; + save_menu->error = SAVE_ERROR_NONE; - for (i = 0; i < SAVE_MODE_NUM; i++) { - save_menu_reset_cursor_col(save_menu->cursor_col + i); - } + for (i = 0; i < SAVE_MODE_NUM; i++) { + save_menu_reset_cursor_col(save_menu->cursor_col + i); + } }