m_cockroach OK (#106)

* m_cockroach OK

* fixes

* fixes

* fix

* forgor which change was mine lol

* space

---------

Co-authored-by: emilybrooks <emilybrooksemilybrooks@gmail.com>
This commit is contained in:
Prakxo
2023-10-05 20:39:15 +02:00
committed by GitHub
parent 41c63f5f4d
commit eba2c4cb0f
10 changed files with 257 additions and 40 deletions
-20
View File
@@ -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
+2 -1
View File
@@ -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;
+24
View File
@@ -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
+28 -1
View File
@@ -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();
+10 -1
View File
@@ -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
+2
View File
@@ -27,4 +27,6 @@ typedef enum mHS_HOUSE {
/* 4 */ mHS_HOUSE_NUM
} mHS_HOUSE;
s32 mHS_get_arrange_idx(s32 player);
#endif
+14 -14
View File
@@ -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; //
+173
View File
@@ -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;
}
+2 -2
View File
@@ -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;
+2 -1
View File
@@ -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]