diff options
| -rw-r--r-- | include/68AB30.h | 20 | ||||
| -rw-r--r-- | include/code_variables.h | 3 | ||||
| -rw-r--r-- | include/m_cockroach.h | 24 | ||||
| -rw-r--r-- | include/m_field_info.h | 29 | ||||
| -rw-r--r-- | include/m_home.h | 11 | ||||
| -rw-r--r-- | include/m_house.h | 2 | ||||
| -rw-r--r-- | linker_scripts/jp/symbol_addrs_code.txt | 28 | ||||
| -rw-r--r-- | src/code/m_cockroach.c | 173 | ||||
| -rw-r--r-- | src/code/m_start_data_init.c | 4 | ||||
| -rw-r--r-- | yamls/jp/code.yaml | 3 |
10 files changed, 257 insertions, 40 deletions
diff --git a/include/68AB30.h b/include/68AB30.h deleted file mode 100644 index 1281555..0000000 --- a/include/68AB30.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef C_68AB30_H -#define C_68AB30_H - -#include "ultra64.h" - -// void func_80066E90_jp(); -// void func_80066EB8_jp(); -// void func_80066F1C_jp(); -void mNW_InitMyOriginal(void); -// void func_80066F8C_jp(); -// void func_8006700C_jp(); -void mCkRh_DecideNowGokiFamilyCount(s32 player_no); -// void func_80067190_jp(); -// void func_80067264_jp(); -// void func_80067338_jp(); -// void func_800673BC_jp(); -// void func_800673CC_jp(); -// void func_80067414_jp(); - -#endif diff --git a/include/code_variables.h b/include/code_variables.h index eb70e01..526347a 100644 --- a/include/code_variables.h +++ b/include/code_variables.h @@ -60,7 +60,8 @@ // extern UNK_TYPE D_80102C68_jp; // extern UNK_TYPE D_80103C68_jp; // extern UNK_TYPE D_80103CE0_jp; -// extern UNK_TYPE D_80103D50_jp; +//TODO: find where this belongs +extern s32 CanLookGokiCount; // extern UNK_TYPE D_80103D55_jp; // extern UNK_TYPE D_80103D59_jp; // extern UNK_TYPE D_80103D60_jp; diff --git a/include/m_cockroach.h b/include/m_cockroach.h new file mode 100644 index 0000000..2e18ea3 --- /dev/null +++ b/include/m_cockroach.h @@ -0,0 +1,24 @@ +#ifndef M_COCKROACH_H +#define M_COCKROACH_H + +#include "ultra64.h" +#include "m_home.h" + +#define mCkRh_MAX_NUM 10 +#define mCkRh_MAX_LOOK_NUM 3 + +s32 mCkRh_GokiFamilyCount2Good(s32 count); +s32 mCkRh_InitGokiSaveData_1Room(s32 player); +void mCkRh_InitGokiSaveData_1Room_ByHomeData(mHm_hs_c * home); +void mCkRh_InitGokiSaveData_InitNewPlayer(void); +void mCkRh_SavePlayTime(s32 player); +s32 mCkRh_DaysGapCompareWithSaveTime(s32 player); +void mCkRh_DecideNowGokiFamilyCount(s32 player); +s32 mCkRh_PlussGokiN_NowRoom(s32 count); +s32 mCkRh_MinusGokiN_NowRoom(s32 count); +s32 mCkRh_NowSceneGokiFamilyCount(void); +void mCkRh_InitCanLookGokiCount(void); +s32 mCkRh_CalcCanLookGokiCount(s32 count); +s32 mCkRh_GetCanLookGokiCount(void); + +#endif diff --git a/include/m_field_info.h b/include/m_field_info.h index 556ede8..85da72a 100644 --- a/include/m_field_info.h +++ b/include/m_field_info.h @@ -7,10 +7,37 @@ struct Game_Play; +typedef enum FieldType { + /* 0 */ FI_FIELDTYPE_FG, + /* 1 */ FI_FIELDTYPE_1, + /* 2 */ FI_FIELDTYPE_2, + /* 3 */ FI_FIELDTYPE_ROOM, + /* 4 */ FI_FIELDTYPE_NPC_ROOM, + /* 5 */ FI_FIELDTYPE_DEMO, + /* 6 */ FI_FIELDTYPE_PLAYER_ROOM, + /* 7 */ FI_FIELDTYPE_NUM, +} FieldType; + + +#define FI_TO_FIELD_ID(type, index) (((type) << 12) | (index)) + +typedef enum FieldRoom { + /* 0x6000 */ FI_FIELD_PLAYER0_ROOM = FI_TO_FIELD_ID(FI_FIELDTYPE_PLAYER_ROOM, 0), + /* 0x6001 */ FI_FIELD_PLAYER1_ROOM, + /* 0x6002 */ FI_FIELD_PLAYER2_ROOM, + /* 0x6003 */ FI_FIELD_PLAYER3_ROOM, +} FieldRoom; + + +#define FI_GET_PLAYER_ROOM_NO(fieldId) (((fieldId)-FI_FIELD_PLAYER0_ROOM) & 3) +#define FI_IS_PLAYER_ROOM(fieldId) \ + ((fieldId) == FI_FIELD_PLAYER0_ROOM || (fieldId) == FI_FIELD_PLAYER1_ROOM || \ + (fieldId) == FI_FIELD_PLAYER2_ROOM || (fieldId) == FI_FIELD_PLAYER3_ROOM) + // void func_80087C30_jp(); // void func_80087C40_jp(); // void func_80087C64_jp(); -s32 mFI_GetFieldId(void); +u16 mFI_GetFieldId(void); // void func_80087C9C_jp(); // void func_80087D30_jp(); // void func_80087DC8_jp(); diff --git a/include/m_home.h b/include/m_home.h index 3d0b73c..787b447 100644 --- a/include/m_home.h +++ b/include/m_home.h @@ -4,6 +4,7 @@ #include "ultra64.h" #include "6DB420.h" #include "unk.h" +#include "lb_rtc.h" #define HOME_MAILBOX_SIZE 10 #define HANIWA_ITEM_HOLD_NUM 4 @@ -48,6 +49,13 @@ typedef struct Haniwa_c { /* 0x58 */ u32 bells; /* held bells from selling items */ } Haniwa_c; // size = 0x5C +// Original name is mHm_goki_c +typedef struct mHm_goki_c { + /* 0x00 */ lbRTC_ymd_t time; + /* 0x04 */ u8 num; + /* 0x05 */ u8 pad; +} mHm_goki_c; // size = 0x6 + typedef struct mHm_hs_c { /* 0x000 */ PersonalID unk_000; /* 0x010 */ UNK_TYPE1 unk_010[0x12]; @@ -56,7 +64,8 @@ typedef struct mHm_hs_c { /* 0x024 */ u8 unk_024; /* 0x025 */ UNK_TYPE1 unk025[0xABB]; /* 0xAE0 */ Haniwa_c haniwa; - /* 0xB3C */ UNK_TYPE1 unkB3C[0xC]; + /* 0xB3C */ mHm_goki_c goki; + /* 0xB42 */ UNK_TYPE1 unkB42[0x6]; } mHm_hs_c; // size = 0xB48 diff --git a/include/m_house.h b/include/m_house.h index 539a4a0..165dbf2 100644 --- a/include/m_house.h +++ b/include/m_house.h @@ -27,4 +27,6 @@ typedef enum mHS_HOUSE { /* 4 */ mHS_HOUSE_NUM } mHS_HOUSE; +s32 mHS_get_arrange_idx(s32 player); + #endif diff --git a/linker_scripts/jp/symbol_addrs_code.txt b/linker_scripts/jp/symbol_addrs_code.txt index a546c56..f642eca 100644 --- a/linker_scripts/jp/symbol_addrs_code.txt +++ b/linker_scripts/jp/symbol_addrs_code.txt @@ -591,19 +591,19 @@ func_80066D4C_jp = 0x80066D4C; // type:func func_80066DFC_jp = 0x80066DFC; // type:func func_80066E34_jp = 0x80066E34; // type:func clip_clear = 0x80066E50; // type:func -func_80066E90_jp = 0x80066E90; // type:func -func_80066EB8_jp = 0x80066EB8; // type:func -func_80066F1C_jp = 0x80066F1C; // type:func -mNW_InitMyOriginal = 0x80066F4C; // type:func -func_80066F8C_jp = 0x80066F8C; // type:func -func_8006700C_jp = 0x8006700C; // type:func +mCkRh_GokiFamilyCount2Good = 0x80066E90; // type:func +mCkRh_InitGokiSaveData_1Room = 0x80066EB8; // type:func +mCkRh_InitGokiSaveData_1Room_ByHomeData = 0x80066F1C; // type:func +mCkRh_InitGokiSaveData_InitNewPlayer = 0x80066F4C; // type:func +mCkRh_SavePlayTime = 0x80066F8C; // type:func +mCkRh_DaysGapCompareWithSaveTime = 0x8006700C; // type:func mCkRh_DecideNowGokiFamilyCount = 0x800670C0; // type:func -func_80067190_jp = 0x80067190; // type:func -func_80067264_jp = 0x80067264; // type:func -func_80067338_jp = 0x80067338; // type:func -func_800673BC_jp = 0x800673BC; // type:func -func_800673CC_jp = 0x800673CC; // type:func -func_80067414_jp = 0x80067414; // type:func +mCkRh_PlussGokiN_NowRoom = 0x80067190; // type:func +mCkRh_MinusGokiN_NowRoom = 0x80067264; // type:func +mCkRh_NowSceneGokiFamilyCount = 0x80067338; // type:func +mCkRh_InitCanLookGokiCount = 0x800673BC; // type:func +mCkRh_CalcCanLookGokiCount = 0x800673CC; // type:func +mCkRh_GetCanLookGokiCount = 0x80067414; // type:func func_80067430_jp = 0x80067430; // type:func func_800674B0_jp = 0x800674B0; // type:func func_800674D8_jp = 0x800674D8; // type:func @@ -1648,7 +1648,7 @@ func_800949D8_jp = 0x800949D8; // type:func func_80094A04_jp = 0x80094A04; // type:func mHm_CheckRehouseOrder = 0x80094A90; // type:func mHS_house_init = 0x80094BE0; // type:func -func_80094BF4_jp = 0x80094BF4; // type:func +mHS_get_arrange_idx = 0x80094BF4; // type:func func_80094C10_jp = 0x80094C10; // type:func func_80094C44_jp = 0x80094C44; // type:func func_80094CAC_jp = 0x80094CAC; // type:func @@ -4235,7 +4235,7 @@ D_80102C28_jp = 0x80102C28; // D_80102C68_jp = 0x80102C68; // D_80103C68_jp = 0x80103C68; // D_80103CE0_jp = 0x80103CE0; // -D_80103D50_jp = 0x80103D50; // +CanLookGokiCount = 0x80103D50; // type:s32 D_80103D55_jp = 0x80103D55; // type:u8 D_80103D59_jp = 0x80103D59; // type:u8 D_80103D60_jp = 0x80103D60; // diff --git a/src/code/m_cockroach.c b/src/code/m_cockroach.c new file mode 100644 index 0000000..da38126 --- /dev/null +++ b/src/code/m_cockroach.c @@ -0,0 +1,173 @@ + +#include "m_cockroach.h" +#include "m_common_data.h" +#include "m_house.h" +#include "m_field_info.h" +#include "code_variables.h" +#include "attributes.h" + +s32 mCkRh_GokiFamilyCount2Good(s32 count) { + if (count < 0) { + return 0; + } + + if (count > mCkRh_MAX_NUM) { + return mCkRh_MAX_NUM; + } + + return count; +} + +s32 mCkRh_InitGokiSaveData_1Room(s32 player) { + common_data.homes[player & 3].goki.num = 0; + common_data.homes[player & 3].goki.pad = 0; + common_data.homes[player & 3].goki.time.year = common_data.time.rtcTime.year; + common_data.homes[player & 3].goki.time.month = common_data.time.rtcTime.month; + common_data.homes[player & 3].goki.time.day = common_data.time.rtcTime.day; +} + +void mCkRh_InitGokiSaveData_1Room_ByHomeData(mHm_hs_c* home) { + home->goki.num = 0; + home->goki.pad = 0; + home->goki.time.year = common_data.time.rtcTime.year; + home->goki.time.month = common_data.time.rtcTime.month; + home->goki.time.day = common_data.time.rtcTime.day; +} + +void mCkRh_InitGokiSaveData_InitNewPlayer() { + s32 i; + + for (i = 0; i < PLAYER_NUM; i++) { + mCkRh_InitGokiSaveData_1Room(i); + } +} + +void mCkRh_SavePlayTime(s32 player) { + s32 home; + + if (player < PLAYER_NUM) { + home = mHS_get_arrange_idx(player) & 3; + common_data.homes[home].goki.time.year = common_data.time.rtcTime.year; + common_data.homes[home].goki.time.month = common_data.time.rtcTime.month; + common_data.homes[home].goki.time.day = common_data.time.rtcTime.day; + } +} + +s32 mCkRh_DaysGapCompareWithSaveTime(s32 player) { + s32 home; + s32 pad UNUSED; + + if (player < PLAYER_NUM) { + lbRTC_time_c gokiTime; + + home = mHS_get_arrange_idx(player) & 3; + gokiTime.year = common_data.homes[home].goki.time.year; + gokiTime.month = common_data.homes[home].goki.time.month; + gokiTime.day = common_data.homes[home].goki.time.day; + + gokiTime.weekday = lbRTC_Week(gokiTime.year, gokiTime.month, gokiTime.day); + gokiTime.hour = 1; + gokiTime.min = 1; + gokiTime.sec = 1; + + return lbRTC_GetIntervalDays(&gokiTime, &common_data.time.rtcTime); + } else { + return 0; + } +} + +void mCkRh_DecideNowGokiFamilyCount(s32 player) { + s32 dayGap; + s32 home; + + if (player < PLAYER_NUM) { + dayGap = mCkRh_DaysGapCompareWithSaveTime(player); + home = mHS_get_arrange_idx(player) & 3; + if (dayGap > 6) { + s32 gokiNum; + s32 count; + gokiNum = common_data.homes[home].goki.num; + count = gokiNum > 0 ? dayGap : dayGap - 6; + common_data.homes[home].goki.num = mCkRh_GokiFamilyCount2Good(count + gokiNum); + } + } +} + +s32 mCkRh_PlussGokiN_NowRoom(s32 count) { + u16 fieldId = mFI_GetFieldId(); + s32 player; + s32 housefieldId; + s32 homeId; + s32 num; + s32 pad[1] UNUSED; + + if (FI_IS_PLAYER_ROOM(fieldId)) { + player = common_data.player_no; + housefieldId = FI_GET_PLAYER_ROOM_NO(fieldId); + homeId = mHS_get_arrange_idx(player) & 3; + if ((player < PLAYER_NUM) && (housefieldId == homeId)) { + num = common_data.homes[homeId].goki.num; + + common_data.homes[homeId].goki.num = mCkRh_GokiFamilyCount2Good(count + num); + return TRUE; + } + } + return FALSE; +} + +s32 mCkRh_MinusGokiN_NowRoom(s32 count) { + u16 fieldId = mFI_GetFieldId(); + s32 player; + s32 housefieldId; + s32 homeId; + s32 num; + s32 pad[1] UNUSED; + + if (FI_IS_PLAYER_ROOM(fieldId)) { + player = common_data.player_no; + housefieldId = FI_GET_PLAYER_ROOM_NO(fieldId); + homeId = mHS_get_arrange_idx(player) & 3; + if ((player < PLAYER_NUM) && (housefieldId == homeId)) { + num = common_data.homes[homeId].goki.num; + common_data.homes[homeId].goki.num = mCkRh_GokiFamilyCount2Good(num - count); + return TRUE; + } + } + return FALSE; +} + +s32 mCkRh_NowSceneGokiFamilyCount() { + u16 fieldid = mFI_GetFieldId(); + + if (FI_IS_PLAYER_ROOM(fieldid)) { + return common_data.homes[FI_GET_PLAYER_ROOM_NO(fieldid)].goki.num; + } else { + return 0; + } +} + +void mCkRh_InitCanLookGokiCount() { + CanLookGokiCount = 0; +} + +s32 mCkRh_CalcCanLookGokiCount(s32 count) { + s32 calc = count + CanLookGokiCount; + + if (calc < 0) { + CanLookGokiCount = 0; + return FALSE; + } + + if (calc > mCkRh_MAX_LOOK_NUM) { + CanLookGokiCount = mCkRh_MAX_LOOK_NUM; + return FALSE; + } + + CanLookGokiCount = calc; + + return TRUE; +} + +s32 mCkRh_GetCanLookGokiCount() { + return CanLookGokiCount; +} diff --git a/src/code/m_start_data_init.c b/src/code/m_start_data_init.c index 40a16f4..380a8d1 100644 --- a/src/code/m_start_data_init.c +++ b/src/code/m_start_data_init.c @@ -1,6 +1,6 @@ #include "m_start_data_init.h" #include "6792F0.h" -#include "68AB30.h" +#include "m_cockroach.h" #include "69CB30.h" #include "6A83A0.h" #include "6B81C0.h" @@ -255,7 +255,7 @@ s32 mSDI_StartInitNew(Game* game2, s32 player_no, s32 malloc_flag) { } mPr_SetPossessionItem(common_data.now_private, 0, ITM_MONEY_1000, mPr_ITEM_COND_QUEST); - mNW_InitMyOriginal(); + mCkRh_InitGokiSaveData_InitNewPlayer(); mEv_2nd_init(&game_play->event); famicom_emu_initial_common_data(); return TRUE; diff --git a/yamls/jp/code.yaml b/yamls/jp/code.yaml index f0b19d1..21ae7f6 100644 --- a/yamls/jp/code.yaml +++ b/yamls/jp/code.yaml @@ -17,7 +17,7 @@ - [0x683030, asm, code/683030] - [0x688CE0, asm, code/m_choice_main] - [0x68AAF0, asm, code/68AAF0] - - [0x68AB30, asm, code/68AB30] + - [0x68AB30, c, code/m_cockroach] - [0x68B0D0, asm, code/m_collision_bg] - [0x69A7E0, c, code/m_collision_obj] - [0x69C6B0, c, code/m_common_data] @@ -142,6 +142,7 @@ - [0x724930, .data, code/m_actor_dlftbls] - [0x726260, data, code/m_actor_shadow] - [0x7262C0, data, code/7262C0] + - [0x7279F0, data, code/7279F0] - [0x728340, .data, code/m_collision_obj] - [0x728430, data, code/728430] - [0x72AAC0, .data, code/m_game_dlftbls] |
