diff options
| author | Anghelo Carvajal <angheloalf95@gmail.com> | 2024-05-30 17:00:57 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-30 14:00:57 -0700 |
| commit | fd0581121366309a56c648eda7a299537e355b28 (patch) | |
| tree | 6fb8d8b167fecd8799748ccb1caab1a013c7e739 /src | |
| parent | 1f7fbf9b291d5685633e6e819b2579f36dc4ef2b (diff) | |
`m_trademark` OK (#192)
* C file
* trademark_init
* trademark_cancel, trademark_move, trademark_main
* trademark_draw
* trademark_goto_demo_scene and func_80805360_jp
* set_npc_4_title_demo
* func_80804C40_jp
* trademark_cleanup
* func_808052B8_jp
* func_80805104_jp
* func_80804F78_jp
* func_80804EE0_jp
* fix warnings
* small cleanup
* fix build
* some fixes
* stuff
* some cleanups
* Fix rebase
* Import data
* Migrate bss
* cleanup
* Save substruct
* format
* TrademarkState and some other stuff
* remove fake match
* stuff I missed
* whoops
* Stupid `-Wtype-limits`
* Update src/overlays/gamestates/ovl_trademark/m_trademark.c
Co-authored-by: Prakxo <87568477+Prakxo@users.noreply.github.com>
* Review
* Update src/overlays/gamestates/ovl_trademark/m_trademark.c
Co-authored-by: emilybrooks <emilybrooksemilybrooks@gmail.com>
* Update src/overlays/gamestates/ovl_trademark/m_trademark.c
Co-authored-by: Prakxo <87568477+Prakxo@users.noreply.github.com>
* clang-tidy changes???
* review
---------
Co-authored-by: Prakxo <87568477+Prakxo@users.noreply.github.com>
Co-authored-by: emilybrooks <emilybrooksemilybrooks@gmail.com>
Diffstat (limited to 'src')
29 files changed, 872 insertions, 277 deletions
diff --git a/src/code/game.c b/src/code/game.c index 02a7339..4edc1fb 100644 --- a/src/code/game.c +++ b/src/code/game.c @@ -7,7 +7,7 @@ #include "graph.h" #include "libu64/debug.h" #include "libc64/malloc.h" -#include "6EDD10.h" +#include "m_time.h" #include "padmgr.h" #include "69E2C0.h" #include "gfxalloc.h" diff --git a/src/code/m_actor_shadow.c b/src/code/m_actor_shadow.c index b8c993a..6ddc884 100644 --- a/src/code/m_actor_shadow.c +++ b/src/code/m_actor_shadow.c @@ -200,7 +200,7 @@ void mActorShadow_DrawActorShadow(Actor* actor, ShadowInfo* shadow, Game* game, u8 g; u8 b; f32 yAdjust; - s32 scene = common_data.sceneNo; + s32 scene = common_data.save.sceneNo; mActorShadow_GetLastAlphaScale(&scale, &alpha, actor, shadow); diff --git a/src/code/m_all_grow.c b/src/code/m_all_grow.c index 392aa57..8546837 100644 --- a/src/code/m_all_grow.c +++ b/src/code/m_all_grow.c @@ -87,8 +87,8 @@ void mAGrw_SetDebugDataBlock(u16* fgItems, u16* deposit, AllGrowBlock* fossilBlo } void mAGrw_SetDebugData() { - Foreground* fgItems = common_data.foreground[0]; - u16* deposit = common_data.deposit[0]; + Foreground* fgItems = common_data.save.foreground[0]; + u16* deposit = common_data.save.deposit[0]; s32 blockZ; mAGrw_ClearDebugData(); @@ -122,7 +122,7 @@ void mAGrw_PrintFossilHaniwa_debug(gfxprint* gfxprint) { s32 mAGrw_CheckKabuPeddler() { lbRTC_time_c* rtcTime = &common_data.time.rtcTime; - lbRTC_time_c* renewTime = &common_data.allGrowRenewTime; + lbRTC_time_c* renewTime = &common_data.save.allGrowRenewTime; lbRTC_time_c peddlerSpawnTime; s32 res = FALSE; @@ -142,7 +142,7 @@ s32 mAGrw_CheckKabuPeddler() { } void mAGrw_OrderSetHaniwa() { - common_data.haniwaScheduled = TRUE; + common_data.save.haniwaScheduled = TRUE; } u8 func_80055E34_jp(u16* items) { @@ -229,7 +229,7 @@ typedef void (*xmasProcFunc)(u16*); void mAGrw_XmasTreeField(s32 type) { static xmasProcFunc xmas_proc[] = { &mAGrw_ClearXmasTreeBlock, &mAGrw_SetXmasTreeBlock }; - Foreground* block = common_data.foreground[0]; + Foreground* block = common_data.save.foreground[0]; s32 i; for (i = 0; i < FG_BLOCK_TOTAL_NUM; i++) { @@ -239,7 +239,7 @@ void mAGrw_XmasTreeField(s32 type) { } void mAGrw_SetXmasTree() { - if (common_data.sceneNo == SCENE_FG) { + if (common_data.save.sceneNo == SCENE_FG) { s32 type = mAGrw_CheckPutXmasTree(&common_data.time.rtcTime); mAGrw_XmasTreeField(type); } @@ -249,16 +249,16 @@ void mAGrw_RenewalFgItem(lbRTC_time_c* time) { u32 ovlSize = SEGMENT_VRAM_SIZE(m_all_grow_ovl); allGrowOvlUnkFunc func; - if (common_data.sceneNo == SCENE_FG) { - s32 schedHaniwa = common_data.haniwaScheduled; + if (common_data.save.sceneNo == SCENE_FG) { + s32 schedHaniwa = common_data.save.haniwaScheduled; D_80100C5C_jp = zelda_malloc(ovlSize); if (D_80100C5C_jp != NULL) { ovlmgr_Load(SEGMENT_ROM_START(m_all_grow_ovl), SEGMENT_ROM_END(m_all_grow_ovl), SEGMENT_VRAM_START(m_all_grow_ovl), SEGMENT_VRAM_END(m_all_grow_ovl), D_80100C5C_jp); func = (allGrowOvlUnkFunc)SEGMENT_VRAM_RESOLVE_ADDR(m_all_grow_ovl, D_80100C5C_jp, mAGrw_RenewalFgItem_ovl); - (*func)(time, &schedHaniwa); - common_data.haniwaScheduled = schedHaniwa; + func(time, &schedHaniwa); + common_data.save.haniwaScheduled = schedHaniwa; zelda_free(D_80100C5C_jp); } @@ -290,12 +290,12 @@ void mAGrw_ChangeTree2FruitTreeLine(Foreground* fg, u16 fruitTree) { } void mAGrw_ChangeTree2FruitTree() { - s32 fruit = common_data.fruit - 0x2800; + s32 fruit = common_data.save.fruit - 0x2800; u16 fruitTree; s32 blockZ; fruitTree = l_tree_max_table[fruit]; for (blockZ = 0; blockZ < FG_BLOCK_Z_NUM; blockZ++) { - mAGrw_ChangeTree2FruitTreeLine(common_data.foreground[blockZ], fruitTree); + mAGrw_ChangeTree2FruitTreeLine(common_data.save.foreground[blockZ], fruitTree); } } diff --git a/src/code/m_cockroach.c b/src/code/m_cockroach.c index b774da9..00b83e2 100644 --- a/src/code/m_cockroach.c +++ b/src/code/m_cockroach.c @@ -19,11 +19,11 @@ s32 mCkRh_GokiFamilyCount2Good(s32 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; + common_data.save.homes[player & 3].goki.num = 0; + common_data.save.homes[player & 3].goki.pad = 0; + common_data.save.homes[player & 3].goki.time.year = common_data.time.rtcTime.year; + common_data.save.homes[player & 3].goki.time.month = common_data.time.rtcTime.month; + common_data.save.homes[player & 3].goki.time.day = common_data.time.rtcTime.day; } void mCkRh_InitGokiSaveData_1Room_ByHomeData(mHm_hs_c* home) { @@ -47,9 +47,9 @@ void mCkRh_SavePlayTime(s32 player) { 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; + common_data.save.homes[home].goki.time.year = common_data.time.rtcTime.year; + common_data.save.homes[home].goki.time.month = common_data.time.rtcTime.month; + common_data.save.homes[home].goki.time.day = common_data.time.rtcTime.day; } } @@ -61,9 +61,9 @@ s32 mCkRh_DaysGapCompareWithSaveTime(s32 player) { 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.year = common_data.save.homes[home].goki.time.year; + gokiTime.month = common_data.save.homes[home].goki.time.month; + gokiTime.day = common_data.save.homes[home].goki.time.day; gokiTime.weekday = lbRTC_Week(gokiTime.year, gokiTime.month, gokiTime.day); gokiTime.hour = 1; @@ -86,9 +86,9 @@ void mCkRh_DecideNowGokiFamilyCount(s32 player) { if (dayGap > 6) { s32 gokiNum; s32 count; - gokiNum = common_data.homes[home].goki.num; + gokiNum = common_data.save.homes[home].goki.num; count = gokiNum > 0 ? dayGap : dayGap - 6; - common_data.homes[home].goki.num = mCkRh_GokiFamilyCount2Good(count + gokiNum); + common_data.save.homes[home].goki.num = mCkRh_GokiFamilyCount2Good(count + gokiNum); } } } @@ -106,9 +106,9 @@ s32 mCkRh_PlussGokiN_NowRoom(s32 count) { 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; + num = common_data.save.homes[homeId].goki.num; - common_data.homes[homeId].goki.num = mCkRh_GokiFamilyCount2Good(count + num); + common_data.save.homes[homeId].goki.num = mCkRh_GokiFamilyCount2Good(count + num); return TRUE; } } @@ -128,8 +128,8 @@ s32 mCkRh_MinusGokiN_NowRoom(s32 count) { 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); + num = common_data.save.homes[homeId].goki.num; + common_data.save.homes[homeId].goki.num = mCkRh_GokiFamilyCount2Good(num - count); return TRUE; } } @@ -140,7 +140,7 @@ 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; + return common_data.save.homes[FI_GET_PLAYER_ROOM_NO(fieldid)].goki.num; } else { return 0; } diff --git a/src/code/m_mail.c b/src/code/m_mail.c index 540fd6c..7874f57 100644 --- a/src/code/m_mail.c +++ b/src/code/m_mail.c @@ -193,8 +193,8 @@ s32 mMl_hunt_for_send_address(Mail_c* mail) { return -1; } - for (i = 0; i < ARRAY_COUNT(common_data.homes); i++) { - if (mPr_CheckCmpPersonalID(&common_data.homes[i].ownerID, &mail->header.recipient.personalID) == 1) { + for (i = 0; i < ARRAY_COUNT(common_data.save.homes); i++) { + if (mPr_CheckCmpPersonalID(&common_data.save.homes[i].ownerID, &mail->header.recipient.personalID) == 1) { return i; } } diff --git a/src/code/m_npc.c b/src/code/m_npc.c index 1c85824..6e0ab8a 100644 --- a/src/code/m_npc.c +++ b/src/code/m_npc.c @@ -1,3 +1,5 @@ +#include "prevent_bss_reordering.h" + #include "m_npc.h" #include "macros.h" #include "m_lib.h" @@ -144,7 +146,7 @@ s32 mNpc_CheckCmpAnimalPersonalID(AnmPersonalID_c* id0, AnmPersonalID_c* id1) { } s32 mNpc_GetAnimalNum() { - Animal_c* animal = common_data.animals; + Animal_c* animal = common_data.save.animals; s32 num = 0; s32 i; @@ -189,7 +191,7 @@ void mNpc_SetParentName(Animal_c* animal, PersonalID_c* parentId) { } void mNpc_SetParentNameAllAnimal() { - Animal_c* animal = common_data.animals; + Animal_c* animal = common_data.save.animals; PrivateInfo* priv = common_data.privateInfo; s32 i; @@ -266,7 +268,7 @@ s32 mNpc_CheckFreeAnimalMemory(Anmmem_c* memory) { void mNpc_RenewalAnimalMemory() { PrivateInfo* priv; - Animal_c* animal = common_data.animals; + Animal_c* animal = common_data.save.animals; Anmmem_c* memory; s32 i; s32 j; @@ -278,7 +280,7 @@ void mNpc_RenewalAnimalMemory() { for (j = 0; j < ANIMAL_MEMORY_NUM; j++) { if (mNpc_CheckFreeAnimalMemory(memory) == FALSE && mLd_CheckThisLand(memory->memoryPlayerId.landName, memory->memoryPlayerId.landId) == TRUE) { - priv = common_data.saveFilePrivateInfo; + priv = common_data.save.saveFilePrivateInfo; for (k = 0; k < PLAYER_NUM; k++) { if (mPr_NullCheckPersonalID(&priv->playerId) == FALSE && @@ -425,9 +427,9 @@ void mNpc_SetAnimalLastTalk(Animal_c* animal) { if (memory != NULL) { lbRTC_TimeCopy(&memory->lastSpeakTime, &common_data.time.rtcTime); - mLd_CopyLandName(memory->land.name, common_data.landInfo.name); - memory->land.id = common_data.landInfo.id; - memory->savedTownTune = common_data.melody; + mLd_CopyLandName(memory->land.name, common_data.save.landInfo.name); + memory->land.id = common_data.save.landInfo.id; + memory->savedTownTune = common_data.save.melody; } } } @@ -441,7 +443,7 @@ void mNpc_SetAnimalPersonalID2Memory(AnmPersonalID_c* anmId) { id = mNpc_SearchAnimalPersonalID(anmId); if (id != -1) { - animal = &common_data.animals[id]; + animal = &common_data.save.animals[id]; id = mNpc_GetAnimalMemoryIdx(&priv->playerId, animal->memories, ANIMAL_MEMORY_NUM); if (id == -1) { @@ -539,7 +541,7 @@ s32 mNpc_GetAnimalMemoryFriend_Land_Sex(Anmmem_c* memory, s32 num, s32 sex) { if (mNpc_CheckFreeAnimalMemory(memory) == FALSE) { id = mPr_GetPrivateIdx(&memory->memoryPlayerId); - if (id != -1 && common_data.saveFilePrivateInfo[id].gender == sex && + if (id != -1 && common_data.save.saveFilePrivateInfo[id].gender == sex && mNpc_SelectBestFriend(&bestFriend, memory, &bestFriendship) == TRUE) { res = i; } @@ -702,17 +704,17 @@ s32 mNpc_SearchAnimalinfo(Animal_c* animal, u16 npcName, s32 count) { Animal_c* mNpc_GetAnimalInfoP(u16 id) { UNUSED s32 pad; Animal_c* animal = NULL; - s32 idx = mNpc_SearchAnimalinfo(common_data.animals, id, ANIMAL_NUM_MAX); + s32 idx = mNpc_SearchAnimalinfo(common_data.save.animals, id, ANIMAL_NUM_MAX); if (idx != -1) { - animal = common_data.animals + idx; + animal = common_data.save.animals + idx; } return animal; } s32 mNpc_SearchAnimalPersonalID(AnmPersonalID_c* id) { - Animal_c* animal = common_data.animals; + Animal_c* animal = common_data.save.animals; s32 res = -1; s32 i; @@ -741,14 +743,14 @@ AnmPersonalID_c* mNpc_GetOtherAnimalPersonalIDOtherBlock(AnmPersonalID_c* pids, s32 i; UNUSED s32 pad2[2]; s32 valid; - Animal_c* animal = common_data.animals; + Animal_c* animal = common_data.save.animals; s32 tempHome; s32 homesInBlock; otherId = NULL; homesInBlock = 0; ids = count; - npcMax = common_data.nowNpcMax; + npcMax = common_data.save.nowNpcMax; bitfield = 0xFFFF; if ((blockX == 0xFF) || (blockY == 0xFF)) { @@ -786,7 +788,7 @@ AnmPersonalID_c* mNpc_GetOtherAnimalPersonalIDOtherBlock(AnmPersonalID_c* pids, } } if (((ids + homesInBlock) < npcMax) && (count < ANIMAL_NUM_MAX)) { - animal = common_data.animals; + animal = common_data.save.animals; tempHome = fqrand() * ((npcMax - ids) - homesInBlock); for (j = 0; j < ANIMAL_NUM_MAX; j++) { @@ -832,7 +834,7 @@ AnmPersonalID_c* mNpc_GetOtherAnimalPersonalID(AnmPersonalID_c* pids, s32 count) } void mNpc_SetAnimalThisLand(Animal_c* animal, s32 count) { - LandInfo* landInfo = &common_data.landInfo; + LandInfo* landInfo = &common_data.save.landInfo; for (; count != 0; count--) { if (!mNpc_CheckFreeAnimalPersonalID(&animal->id)) { @@ -845,7 +847,7 @@ void mNpc_SetAnimalThisLand(Animal_c* animal, s32 count) { } s32 mNpc_GetSameLooksNum(u8 looks) { - Animal_c* animal = common_data.animals; + Animal_c* animal = common_data.save.animals; s32 i; s32 num = 0; @@ -1055,7 +1057,7 @@ s32 mNpc_SendMailtoNpc(Mail_c* mail) { Animal_c* anm; if (mMl_get_npcinfo_from_mail_name(&anmId, &mail->header.recipient) == TRUE) { - anm = common_data.animals; + anm = common_data.save.animals; anmIdx = mNpc_SearchAnimalPersonalID(&anmId); if (anmIdx != -1) { @@ -1307,7 +1309,7 @@ s32 mNpc_CheckLetterTime(lbRTC_ymd_t* letterDate, lbRTC_time_c* rtcTime) { } void mNpc_Remail() { - Animal_c* animal = common_data.animals; + Animal_c* animal = common_data.save.animals; Anmremail* remail; PrivateInfo* priv = common_data.privateInfo; Anmmem_c* memory; @@ -1411,7 +1413,7 @@ s32 mNpc_SendEventPresentMail(PersonalID_c* pid, s32 playerNo, AnmPersonalID_c* looks = anmId->looks; res = FALSE; - home = &common_data.homes[mHS_get_arrange_idx(playerNo)]; + home = &common_data.save.homes[mHS_get_arrange_idx(playerNo)]; if (mPr_CheckCmpPersonalID(pid, &home->ownerID) == TRUE) { @@ -1451,7 +1453,7 @@ void mNpc_SendEventPresentMailSex(s32* selected, u8* type, Animal_c* animal, Npc s32 mNpc_SendEventPresentMail_common(NpcSex sexType) { static NpcSex sex[] = { NPC_SEX_FEMALE, NPC_SEX_MALE }; - Animal_c* animal = common_data.animals; + Animal_c* animal = common_data.save.animals; PersonalID_c* pid; s32 otherSexBestFriends[ANIMAL_NUM_MAX]; u8 types[ANIMAL_NUM_MAX]; @@ -1474,7 +1476,7 @@ s32 mNpc_SendEventPresentMail_common(NpcSex sexType) { } for (i = 0; i < 3; i++) { - animal = common_data.animals; + animal = common_data.save.animals; for (j = 0; j < ANIMAL_NUM_MAX; j++) { if (otherSexBestFriends[j] >= 0 && types[j] == i) { @@ -1534,7 +1536,7 @@ s32 mNpc_SendBirthdayCard(PersonalID_c* pid, s32 playerNo, AnmPersonalID_c* anm_ s32 freeIdx; s32 res = FALSE; - home = &common_data.homes[mHS_get_arrange_idx(playerNo)]; + home = &common_data.save.homes[mHS_get_arrange_idx(playerNo)]; if (mPr_NullCheckPersonalID(pid) == FALSE && mPr_CheckCmpPersonalID(pid, &home->ownerID) == TRUE) { freeIdx = mMl_chk_mail_free_space(home->mailbox, 10); @@ -1557,7 +1559,7 @@ s32 mNpc_SendEventBirthdayCard(UNUSED PersonalID_c* pid) { } s32 mNpc_SendEventBirthdayCard2(PersonalID_c* pid, s32 playerNo) { - Animal_c* animal = common_data.animals; + Animal_c* animal = common_data.save.animals; s32 res = FALSE; s32 idx; s32 i; @@ -1602,7 +1604,7 @@ s32 mNpc_SendEventXmasCard(PersonalID_c* pid, s32 playerNo) { s32 res = FALSE; if (mPr_NullCheckPersonalID(pid) == FALSE) { - home = &common_data.homes[mHS_get_arrange_idx(playerNo)]; + home = &common_data.save.homes[mHS_get_arrange_idx(playerNo)]; if (mPr_CheckCmpPersonalID(pid, &home->ownerID) == TRUE) { freeSpace = mMl_chk_mail_free_space(home->mailbox, 10); @@ -1749,8 +1751,8 @@ void mNpc_SetDefAnimalInfo(Animal_c* animal, u16 npcId, u8 looks, NpcDefaultData animal->id.looks = looks; animal->cloth = defaultData->cloth; mString_Load_StringFromRom(animal->catchphrase, ANIMAL_CATCHPHRASE_LEN, defaultData->catchphraseIdx); - animal->id.landId = common_data.landInfo.id; - mLd_CopyLandName(animal->id.landName, common_data.landInfo.name); + animal->id.landId = common_data.save.landInfo.id; + mLd_CopyLandName(animal->id.landName, common_data.save.landInfo.name); } } @@ -1763,13 +1765,13 @@ void mNpc_SetDefAnimal(Animal_c* animal, u16 npcId, NpcDefaultData* defaultData) } void mNpc_SetHaveAppeared(u16 npcId) { - u8* usedTable = common_data.npcUsedTable; + u8* usedTable = common_data.save.npcUsedTable; if (ACTOR_FGNAME_GET_F000(npcId) == FGNAME_F000_E) { s32 idx = npcId & 0xFFF; s32 i = idx / 8; - if (i < ARRAY_COUNT(common_data.npcUsedTable)) { + if (i < ARRAY_COUNT(common_data.save.npcUsedTable)) { usedTable += i; idx &= 7; *usedTable |= 1 << idx; @@ -1779,10 +1781,10 @@ void mNpc_SetHaveAppeared(u16 npcId) { s32 mNpc_GetHaveAppeared_idx(s32 idx) { s32 res = TRUE; - u8* usedTable = common_data.npcUsedTable; + u8* usedTable = common_data.save.npcUsedTable; s32 i = idx / 8; - if (i < ARRAY_COUNT(common_data.npcUsedTable)) { + if (i < ARRAY_COUNT(common_data.save.npcUsedTable)) { usedTable += i; res = (*usedTable >> (idx & 7)) & 1; } @@ -1808,7 +1810,7 @@ s32 mNpc_GetLooks2NotHaveAppearedNum(u8 id) { void mNpc_ResetHaveAppeared_common(u8* npcUsedTable, Animal_c* animal) { s32 i; - bzero(npcUsedTable, sizeof(common_data.npcUsedTable)); + bzero(npcUsedTable, sizeof(common_data.save.npcUsedTable)); for (i = 0; i < ANIMAL_NUM_MAX; i++) { if (mNpc_CheckFreeAnimalInfo(animal) == FALSE) { mNpc_SetHaveAppeared(animal->id.npcId); @@ -1828,7 +1830,7 @@ void mNpc_ResetHaveAppeared() { } if (i == NPC_NUM) { - mNpc_ResetHaveAppeared_common(common_data.npcUsedTable, common_data.animals); + mNpc_ResetHaveAppeared_common(common_data.save.npcUsedTable, common_data.save.animals); } } @@ -1989,7 +1991,7 @@ s32 mNpc_BlockNum2ReservedUtNum(s32* utX, s32* utZ, s32 bx, s32 bz) { } void mNpc_MakeReservedListBeforeFieldct(Anmhome_c* reserved, s32 reservedNum, u8* reservedCount) { - Foreground* fg = &common_data.foreground[0][0]; + Foreground* fg = &common_data.save.foreground[0][0]; Anmhome_c* reservedp = reserved; u16* item; u8 num = 0; @@ -2104,7 +2106,7 @@ void mNpc_BuildHouseBeforeFieldct(u16 npcId, s32 bx, s32 bz, s32 utX, s32 utZ) { if (bx >= 0 && bx < FG_BLOCK_X_NUM && bz >= 0 && bz < FG_BLOCK_Z_NUM && utX > 0 && utX < (UT_X_NUM - 1) && utZ > 0 && utZ < (UT_Z_NUM - 1)) { set_fg[0] = house; - fg = &common_data.foreground[bz][bx]; + fg = &common_data.save.foreground[bz][bx]; deposit = mFI_GetDepositP(bx + 1, bz + 1); @@ -2132,15 +2134,15 @@ void mNpc_DestroyHouse(Anmhome_c* home) { utZ < (UT_Z_NUM - 1)) { u16 reserveNo = mFM_GetReseveName(home->blockX, home->blockZ); - common_data.foreground[bz][bx].items[utZ][utX] = reserveNo; - common_data.foreground[bz][bx].items[utZ + 1][utX - 1] = 0; - common_data.foreground[bz][bx].items[utZ + 1][utX] = 0; - common_data.foreground[bz][bx].items[utZ + 1][utX + 1] = 0; - common_data.foreground[bz][bx].items[utZ][utX - 1] = 0; - common_data.foreground[bz][bx].items[utZ][utX + 1] = 0; - common_data.foreground[bz][bx].items[utZ - 1][utX - 1] = 0; - common_data.foreground[bz][bx].items[utZ - 1][utX] = 0; - common_data.foreground[bz][bx].items[utZ - 1][utX + 1] = 0; + common_data.save.foreground[bz][bx].items[utZ][utX] = reserveNo; + common_data.save.foreground[bz][bx].items[utZ + 1][utX - 1] = 0; + common_data.save.foreground[bz][bx].items[utZ + 1][utX] = 0; + common_data.save.foreground[bz][bx].items[utZ + 1][utX + 1] = 0; + common_data.save.foreground[bz][bx].items[utZ][utX - 1] = 0; + common_data.save.foreground[bz][bx].items[utZ][utX + 1] = 0; + common_data.save.foreground[bz][bx].items[utZ - 1][utX - 1] = 0; + common_data.save.foreground[bz][bx].items[utZ - 1][utX] = 0; + common_data.save.foreground[bz][bx].items[utZ - 1][utX + 1] = 0; } } @@ -2182,7 +2184,7 @@ void mNpc_InitNpcData() { u8 reservedNum = 0; mNpc_MakeReservedListBeforeFieldct(reserved, ARRAY_COUNT(reserved), &reservedNum); - mNpc_SetNpcHome(common_data.animals, reserved, reservedNum); + mNpc_SetNpcHome(common_data.save.animals, reserved, reservedNum); } void mNpc_InitNpcList() { @@ -2282,12 +2284,12 @@ void mNpc_SetNpcinfo(Actor* actor, s8 npcInfoIdx) { NpcEvent* eventNpc = mNpc_GetSameEventNpc(npcId); if (eventNpc != NULL) { - npcInfoIdx = mNpc_SearchAnimalinfo(common_data.animals, eventNpc->npcId, ANIMAL_NUM_MAX); + npcInfoIdx = mNpc_SearchAnimalinfo(common_data.save.animals, eventNpc->npcId, ANIMAL_NUM_MAX); } } if (npcInfoIdx >= 0 && npcInfoIdx < ANIMAL_NUM_MAX) { - npc->npcInfo.animal = &common_data.animals[npcInfoIdx]; + npc->npcInfo.animal = &common_data.save.animals[npcInfoIdx]; npc->npcInfo.list = &common_data.npclist[npcInfoIdx]; } else { npc->npcInfo.animal = NULL; @@ -2315,7 +2317,7 @@ void mNpc_AddNpc_inNpcRoom(FieldMakeMoveActor* moveActor, u8 bx, u8 bz) { houseOwnerId = common_data.houseOwnerName; if ((idx < ANIMAL_NUM_MAX) && (houseOwnerId != 0xFFFF) && (houseOwnerId != 0)) { if (mEvNM_CheckJointEvent(houseOwnerId) != 1) { - animalId = mNpc_SearchAnimalinfo(common_data.animals, houseOwnerId, ANIMAL_NUM_MAX); + animalId = mNpc_SearchAnimalinfo(common_data.save.animals, houseOwnerId, ANIMAL_NUM_MAX); if (animalId != -1) { moveActor->nameId = houseOwnerId; moveActor->utX = 4; @@ -2330,7 +2332,7 @@ void mNpc_AddNpc_inNpcRoom(FieldMakeMoveActor* moveActor, u8 bx, u8 bz) { animalIdInField = func_8008033C_jp(0xE, 0xF); if (animalIdInField != NULL) { npcId = *animalIdInField; - currentNpc = common_data.animals[npcId].id.npcId; + currentNpc = common_data.save.animals[npcId].id.npcId; func_80082BD8_jp(¤tNpc, 0xE, npcId, 0); moveActor->nameId = currentNpc; moveActor->utX = 4; @@ -2353,7 +2355,7 @@ void mNpc_RenewalNpcRoom(s16* wallFloor) { if ((fieldId & 0xF000) == 0x4000) { if ((ownerName != 0) && (ownerName != 0xFFFF)) { - npcIdx = mNpc_SearchAnimalinfo(common_data.animals, ownerName, ANIMAL_NUM_MAX); + npcIdx = mNpc_SearchAnimalinfo(common_data.save.animals, ownerName, ANIMAL_NUM_MAX); wallId = common_data.npclist[npcIdx].houseData.wallId; floorId = common_data.npclist[npcIdx].houseData.floorId; *wallFloor = floorId | (wallId << 8); @@ -2381,7 +2383,7 @@ void mNpc_RenewalSetNpc(Actor* actor) { } s32 mNpc_GetFriendAnimalNum(PersonalID_c* pid) { - Animal_c* animal = common_data.animals; + Animal_c* animal = common_data.save.animals; s32 num = 0; s32 i; @@ -2400,7 +2402,7 @@ s32 mNpc_GetFriendAnimalNum(PersonalID_c* pid) { } s32 mNpc_CheckFriendAllAnimal(PersonalID_c* pid) { - s32 nowNpcMax = common_data.nowNpcMax; + s32 nowNpcMax = common_data.save.nowNpcMax; s32 friendNum = mNpc_GetFriendAnimalNum(pid); if (nowNpcMax <= friendNum) { @@ -2469,7 +2471,7 @@ u16 mNpc_DecideNpcFurniture(FieldMakeFGData** data, NpcList* npcList, s32 count) void mNpc_SetNpcFurnitureRandom(FieldMakeFGData** data, s32 base) { NpcList* npclist = common_data.npclist; - Animal_c* animal = common_data.animals; + Animal_c* animal = common_data.save.animals; s32 i; for (i = 0; i < ANIMAL_NUM_MAX; i++) { @@ -2501,7 +2503,7 @@ Animal_c* mNpc_GetInAnimalP() { } s32 mNpc_DecideRemoveAnimalNo_Friend(Animal_c* animal, s32 metFlag) { - PrivateInfo* priv = common_data.saveFilePrivateInfo; + PrivateInfo* priv = common_data.save.saveFilePrivateInfo; s32 res = -1; s32 playerNumber = 0; s32 possibleNum = 0; @@ -2520,7 +2522,7 @@ s32 mNpc_DecideRemoveAnimalNo_Friend(Animal_c* animal, s32 metFlag) { if (playerNumber > 0) { for (i = 0; i < ANIMAL_NUM_MAX; i++) { if (mNpc_CheckFreeAnimalInfo(animal) == FALSE) { - priv = common_data.saveFilePrivateInfo; + priv = common_data.save.saveFilePrivateInfo; met = 0; for (j = 0; j < PLAYER_NUM; j++) { @@ -2588,8 +2590,8 @@ u8 mNpc_DecideRemoveAnimalNo(Animal_c* animal, s32 max) { } void mNpc_SetRemoveAnimalNo(Animal_c* animal) { - u8* removalIdx = &common_data.removeAnimalIdx; - u8 nowMax = common_data.nowNpcMax; + u8* removalIdx = &common_data.save.removeAnimalIdx; + u8 nowMax = common_data.save.nowNpcMax; if ((nowMax >= 6) && (*removalIdx == 0xFF)) { s32 removeNo = mNpc_DecideRemoveAnimalNo_Friend(animal, TRUE); @@ -2649,7 +2651,7 @@ s32 mNpc_CheckGoodbyAnimalMemoryNum(Animal_c* a0, Animal_c* a1) { s32 mNpc_GetGoodbyAnimalIdx() { UNUSED s32 pad; - Animal_c* animal = common_data.animals; + Animal_c* animal = common_data.save.animals; Animal_c* otherAnimal = NULL; s32 res0; s32 res1; @@ -2659,7 +2661,7 @@ s32 mNpc_GetGoodbyAnimalIdx() { s32 i; for (i = 0; i < ANIMAL_NUM_MAX; i++, animal++) { - if ((i != (u32)&common_data.removeAnimalIdx) && (mNpc_CheckFreeAnimalInfo(animal) == FALSE)) { + if ((i != (u32)&common_data.save.removeAnimalIdx) && (mNpc_CheckFreeAnimalInfo(animal) == FALSE)) { if (otherAnimal != NULL) { if (mNpc_CheckRemoveExp(animal) == 0) { if (mNpc_CheckRemoveExp(otherAnimal) != 0) { @@ -2742,7 +2744,7 @@ void mNpc_FirstClearGoodbyMail() { } void mNpc_SetGoodbyAnimalMail(AnmGoodbyeMail* mail, Animal_c* animal) { - PrivateInfo* priv = common_data.saveFilePrivateInfo; + PrivateInfo* priv = common_data.save.saveFilePrivateInfo; s32 i; if ((animal != NULL) && (mNpc_CheckFreeAnimalPersonalID(&animal->id) == FALSE)) { @@ -2767,7 +2769,7 @@ s32 mNpc_SetGoodbyMailData(Mail_c* mail, PersonalID_c* pid, AnmPersonalID_c* anm mNpc_GetNpcWorldNameAnm(Goodby_animal_name, anm_id); mHandbill_Set_free_str(0, pid->playerName, PLAYER_NAME_LEN); mHandbill_Set_free_str(1, Goodby_animal_name, ANIMAL_NAME_LEN); - mHandbill_Set_free_str(3, common_data.landInfo.name, LAND_NAME_SIZE); + mHandbill_Set_free_str(3, common_data.save.landInfo.name, LAND_NAME_SIZE); mNpc_LoadMailDataCommon2(mail, pid, anm_id, 0, mNpc_GetPaperType(), mailNo); res = TRUE; } @@ -2780,7 +2782,7 @@ s32 mNpc_SendGoodbyAnimalMailOne(Mail_c* mail, PrivateInfo* priv, s32 playerNo, UNUSED s32 pad; s32 res = FALSE; - home = &common_data.homes[mHS_get_arrange_idx(playerNo)]; + home = &common_data.save.homes[mHS_get_arrange_idx(playerNo)]; if ((mPr_NullCheckPersonalID(&priv->playerId) == FALSE) && (mPr_CheckCmpPersonalID(&priv->playerId, &home->ownerID) == TRUE)) { @@ -2798,7 +2800,7 @@ s32 mNpc_SendGoodbyAnimalMailOne(Mail_c* mail, PrivateInfo* priv, s32 playerNo, } void mNpc_SendGoodbyAnimalMail(AnmGoodbyeMail* mail) { - PrivateInfo* priv = common_data.saveFilePrivateInfo; + PrivateInfo* priv = common_data.save.saveFilePrivateInfo; s32 i; if (mNpc_CheckFreeAnimalPersonalID(&mail->id) == FALSE) { @@ -2826,17 +2828,17 @@ void mNpc_GetRemoveAnimal(Animal_c* transferAnimal, s32 movingOut) { s32 newAnimal; Animal_c* animal; s32 freeAnimalIdx; - u8* removeAnimalIdx = &common_data.removeAnimalIdx; - u8* nowMax = &common_data.nowNpcMax; + u8* removeAnimalIdx = &common_data.save.removeAnimalIdx; + u8* nowMax = &common_data.save.nowNpcMax; s32 i; - animal = common_data.animals; + animal = common_data.save.animals; newAnimal = TRUE; priv = common_data.privateInfo; if (mLd_PlayerManKindCheck() == 0) { if (movingOut == 1) { if (*removeAnimalIdx != 0xFF) { - animal = &common_data.animals[*removeAnimalIdx]; + animal = &common_data.save.animals[*removeAnimalIdx]; animal->isMoving = FALSE; mNpc_CopyAnimalInfo(transferAnimal, animal); mNpc_DestroyHouse(&animal->homeInfo); @@ -2855,7 +2857,7 @@ void mNpc_GetRemoveAnimal(Animal_c* transferAnimal, s32 movingOut) { animal++; } - if (transferAnimal->id.npcId == common_data.lastRemovedAnimalId.npcId) { + if (transferAnimal->id.npcId == common_data.save.lastRemovedAnimalId.npcId) { newAnimal = FALSE; } } else { @@ -2863,8 +2865,8 @@ void mNpc_GetRemoveAnimal(Animal_c* transferAnimal, s32 movingOut) { } if (newAnimal == TRUE) { - animal = common_data.animals; - freeAnimalIdx = mNpc_GetFreeAnimalInfo(common_data.animals, ANIMAL_NUM_MAX); + animal = common_data.save.animals; + freeAnimalIdx = mNpc_GetFreeAnimalInfo(common_data.save.animals, ANIMAL_NUM_MAX); if (freeAnimalIdx == -1) { animal += mNpc_GetGoodbyAnimalIdx(); mNpc_DestroyHouse(&animal->homeInfo); @@ -2872,7 +2874,7 @@ void mNpc_GetRemoveAnimal(Animal_c* transferAnimal, s32 movingOut) { mNpc_SendRegisteredGoodbyMail(); } else { animal += freeAnimalIdx; - mNpc_AddNowNpcMax(&common_data.nowNpcMax); + mNpc_AddNowNpcMax(&common_data.save.nowNpcMax); } mNpc_ClearAnimalInfo(animal); mNpc_CopyAnimalInfo(animal, transferAnimal); @@ -2895,7 +2897,7 @@ s32 mNpc_CheckBuildHouse(s32 blockX, s32 blockZ, u8 utX, u8 utZ) { s32 res = FALSE; if ((blockX >= 0) && (blockX < 5) && (blockZ >= 0) && (blockZ < 6) && (utX < 0x10) && (utZ < 0x10)) { - u16 item = common_data.foreground[blockZ][blockX].items[utZ][utX]; + u16 item = common_data.save.foreground[blockZ][blockX].items[utZ][utX]; if ((item >= 0x5810) && (item < 0x5825)) { res = TRUE; @@ -2907,20 +2909,20 @@ s32 mNpc_CheckBuildHouse(s32 blockX, s32 blockZ, u8 utX, u8 utZ) { void mNpc_SetReturnAnimal(Animal_c* returnAnimal) { Anmhome_c* homeInfo; Animal_c* foundAnimal = NULL; - u8* nowMax = &common_data.nowNpcMax; + u8* nowMax = &common_data.save.nowNpcMax; Animal_c* animal; s32 foundAnimalIdx; if (mLd_PlayerManKindCheck() == FALSE && mNpc_CheckFreeAnimalInfo(returnAnimal) == FALSE) { if (returnAnimal->isMoving == 0) { - animal = common_data.animals; + animal = common_data.save.animals; foundAnimalIdx = mNpc_SearchAnimalinfo(animal, returnAnimal->id.npcId, ANIMAL_NUM_MAX); if (foundAnimalIdx != -1) { foundAnimal = &animal[foundAnimalIdx]; mNpc_DestroyHouse(&foundAnimal->homeInfo); (*nowMax)--; - if (common_data.removeAnimalIdx == foundAnimalIdx) { - common_data.removeAnimalIdx = 0xFF; + if (common_data.save.removeAnimalIdx == foundAnimalIdx) { + common_data.save.removeAnimalIdx = 0xFF; } } else if ((*nowMax) >= ANIMAL_NUM_MAX) { foundAnimalIdx = mNpc_GetGoodbyAnimalIdx(); @@ -2928,8 +2930,8 @@ void mNpc_SetReturnAnimal(Animal_c* returnAnimal) { mNpc_SetGoodbyAnimalMail(&l_mnpc_goodby_mail, foundAnimal); mNpc_DestroyHouse(&foundAnimal->homeInfo); (*nowMax)--; - if (foundAnimalIdx == common_data.removeAnimalIdx) { - common_data.removeAnimalIdx = 0xFF; + if (foundAnimalIdx == common_data.save.removeAnimalIdx) { + common_data.save.removeAnimalIdx = 0xFF; } } else { foundAnimalIdx = mNpc_GetFreeAnimalInfo(animal, ANIMAL_NUM_MAX); @@ -2958,7 +2960,7 @@ void mNpc_SetReturnAnimal(Animal_c* returnAnimal) { } } } else { - mNpc_CopyAnimalPersonalID(&common_data.lastRemovedAnimalId, &returnAnimal->id); + mNpc_CopyAnimalPersonalID(&common_data.save.lastRemovedAnimalId, &returnAnimal->id); } mNpc_ClearAnimalInfo(returnAnimal); } @@ -3056,7 +3058,7 @@ void mNpc_GetNpcWorldName(char* name, Npc* npc) { } void mNpc_GetRandomAnimalName(char* dst) { - Animal_c* animal = common_data.animals; + Animal_c* animal = common_data.save.animals; u16 bitfield = 0; s32 num = 0; s32 select; @@ -3073,7 +3075,7 @@ void mNpc_GetRandomAnimalName(char* dst) { } if (num > 0) { - animal = common_data.animals; + animal = common_data.save.animals; select = RANDOM(num); for (i = 0; i < ANIMAL_NUM_MAX; i++) { @@ -3093,7 +3095,7 @@ void mNpc_GetRandomAnimalName(char* dst) { void mNpc_GetAnimalPlateName(char* dst, xyz_t wpos) { UNUSED s32 pad; - Animal_c* animal = common_data.animals; + Animal_c* animal = common_data.save.animals; s32 bx; s32 bz; s32 utX; @@ -3237,12 +3239,12 @@ void mNpc_GetMsg(UNUSED s32 arg) { } void mNpc_InitNpcAllInfo(s32 mallocFlag) { - common_data.nowNpcMax = NPC_LOOKS_NUM; - common_data.removeAnimalIdx = 0xFF; - mNpc_ClearAnimalPersonalID(&common_data.lastRemovedAnimalId); - mNpc_ClearAnyAnimalInfo(common_data.animals, ANIMAL_NUM_MAX); - mNpc_DecideLivingNpcMax(common_data.animals, NPC_LOOKS_NUM, mallocFlag); - mNpc_SetNpcNameID(common_data.animals, ANIMAL_NUM_MAX); + common_data.save.nowNpcMax = NPC_LOOKS_NUM; + common_data.save.removeAnimalIdx = 0xFF; + mNpc_ClearAnimalPersonalID(&common_data.save.lastRemovedAnimalId); + mNpc_ClearAnyAnimalInfo(common_data.save.animals, ANIMAL_NUM_MAX); + mNpc_DecideLivingNpcMax(common_data.save.animals, NPC_LOOKS_NUM, mallocFlag); + mNpc_SetNpcNameID(common_data.save.animals, ANIMAL_NUM_MAX); } s32 mNpc_CheckGrowFieldRank() { @@ -3264,10 +3266,10 @@ s32 mNpc_CheckGrowFieldRank() { s32 mNpc_CheckGrow() { UNUSED s32 pad; lbRTC_time_c* rtcTime = &common_data.time.rtcTime; - lbRTC_time_c* lastGrowTime = &common_data.lastGrowTime; + lbRTC_time_c* lastGrowTime = &common_data.save.lastGrowTime; s32 res = FALSE; - if (common_data.nowNpcMax < ANIMAL_NUM_MAX) { + if (common_data.save.nowNpcMax < ANIMAL_NUM_MAX) { if (lbRTC_IsEqualTime(&mTM_rtcTime_clear_code, lastGrowTime, lbRTC_CHECK_ALL) == TRUE) { lbRTC_TimeCopy(lastGrowTime, rtcTime); } else if (mNpc_CheckGrowFieldRank() == TRUE) { @@ -3317,7 +3319,7 @@ u8 mNpc_GetMinLooks(u8* bitfield, s32* minLooksNum) { } if (bitfield[0] == 0 && minLooksNum[0] == 0) { - mNpc_ResetHaveAppeared_common(common_data.npcUsedTable, common_data.animals); + mNpc_ResetHaveAppeared_common(common_data.save.npcUsedTable, common_data.save.animals); for (i = 0; i < NPC_LOOKS_NUM; i++) { bitfield[0] |= (1 << i); @@ -3333,7 +3335,7 @@ u8 mNpc_GetMinLooks(u8* bitfield, s32* minLooksNum) { } NpcSex mNpc_GetMinSex() { - Animal_c* animal = common_data.animals; + Animal_c* animal = common_data.save.animals; s32 males = 0; s32 females = 0; NpcSex res; @@ -3384,7 +3386,8 @@ s32 mNpc_GrowLooksNpcIdx(u8 looks) { for (i = 0; i < ARRAY_COUNT(candidate_table); i++) { for (j = 0; j < 8; j++) { if (looks == *looks_table) { - if ((mNpc_SearchAnimalinfo(common_data.animals, ((i * 8) + j) | 0xE000, ANIMAL_NUM_MAX) == -1) && + if ((mNpc_SearchAnimalinfo(common_data.save.animals, ((i * 8) + j) | 0xE000, ANIMAL_NUM_MAX) == + -1) && (mNpc_GetHaveAppeared_idx(npc_idx) == FALSE)) { candidates++; candidate_table[i] |= 1 << j; @@ -3451,7 +3454,7 @@ void mNpc_SetAnimalInfoNpcIdx(Animal_c* animal, s32 idx) { } s32 mNpc_SetGrowNpc(u8 looks) { - Animal_c* animal = common_data.animals; + Animal_c* animal = common_data.save.animals; UNUSED s32 pad; s32 idx; s32 npcIdx; @@ -3485,7 +3488,7 @@ void mNpc_Grow() { if (mNpc_CheckGrow() == TRUE) { mNpc_ResetHaveAppeared(); - lbRTC_TimeCopy(&common_data.lastGrowTime, &common_data.time.rtcTime); + lbRTC_TimeCopy(&common_data.save.lastGrowTime, &common_data.time.rtcTime); minLooks = mNpc_GetMinLooks(&minLooksBitfield, &minLooksNum); @@ -3528,8 +3531,8 @@ void mNpc_Grow() { growIdx = mNpc_SetGrowNpc(minLooks); if (growIdx >= 0 && growIdx < ANIMAL_NUM_MAX) { - mNpc_SetNpcNameID(&common_data.animals[growIdx], 1); - mNpc_AddNowNpcMax(&common_data.nowNpcMax); + mNpc_SetNpcNameID(&common_data.save.animals[growIdx], 1); + mNpc_AddNowNpcMax(&common_data.save.nowNpcMax); } } } @@ -3835,7 +3838,7 @@ s32 mNpc_GetNpcFloorNo() { s32 floor_no = -1; if (((field_id & 0xF000) == 0x4000) && (owner_name != 0) && (owner_name != 0xFFFF)) { - s32 idx = mNpc_SearchAnimalinfo(common_data.animals, owner_name, ANIMAL_NUM_MAX); + s32 idx = mNpc_SearchAnimalinfo(common_data.save.animals, owner_name, ANIMAL_NUM_MAX); floor_no = common_data.npclist[idx].houseData.floorId; } @@ -3845,7 +3848,7 @@ s32 mNpc_GetNpcFloorNo() { void mNpc_SetTalkBee() { if (common_data.beeStingFlag != TRUE) { - Animal_c* animal = common_data.animals; + Animal_c* animal = common_data.save.animals; NpcList* npclist = common_data.npclist; s32 i; @@ -3893,7 +3896,7 @@ void mNpc_SetInsectCompleteTalk(NpcList* npclist) { } void mNpc_SetNpcHomeYpos() { - Animal_c* animal = common_data.animals; + Animal_c* animal = common_data.save.animals; NpcList* npclist = common_data.npclist; s32 i; @@ -3910,13 +3913,13 @@ void mNpc_SetNpcHomeYpos() { void mNpc_PrintRemoveInfo(gfxprint* gfxprint) { Animal_c* remove_anm = NULL; Animal_c* in_anm = mNpc_GetInAnimalP(); - u8 removeAnimalIdx = common_data.removeAnimalIdx; + u8 removeAnimalIdx = common_data.save.removeAnimalIdx; gfxprint_color(gfxprint, 200, 150, 50, 255); gfxprint_locate8x8(gfxprint, 3, 10); if (removeAnimalIdx < ANIMAL_NUM_MAX) { - remove_anm = &common_data.animals[removeAnimalIdx]; + remove_anm = &common_data.save.animals[removeAnimalIdx]; } if (remove_anm != NULL) { @@ -3948,7 +3951,7 @@ void mNpc_PrintFriendship_fdebug(gfxprint* gfxprint) { int i; if (l_mnpc_animal_idx >= 0 && l_mnpc_animal_idx < ANIMAL_NUM_MAX) { - memory = common_data.animals[l_mnpc_animal_idx].memories; + memory = common_data.save.animals[l_mnpc_animal_idx].memories; if (memory != NULL) { gfxprint_color(gfxprint, 250, 100, 170, 255); diff --git a/src/code/m_npc_schedule.c b/src/code/m_npc_schedule.c index 20510f6..6630dcb 100644 --- a/src/code/m_npc_schedule.c +++ b/src/code/m_npc_schedule.c @@ -154,7 +154,7 @@ void mNPS_schedule_manager(void) { } void mNPS_set_all_schedule_area(void) { - Animal_c* animal = common_data.animals; + Animal_c* animal = common_data.save.animals; s32 i; for (i = 0; i < ANIMAL_NUM_MAX; i++) { diff --git a/src/code/m_npc_walk.c b/src/code/m_npc_walk.c index 40ee911..9a0cbd6 100644 --- a/src/code/m_npc_walk.c +++ b/src/code/m_npc_walk.c @@ -278,7 +278,7 @@ s32 mNpcW_ChangeNpcWalk(NpcWalking* walk, NpcWalkInfo* info) { NpcWalkInfo* free_info = &walk->info[free_idx]; mNpcW_ClearNpcWalkInfo(free_info, 1); - idx = mNpcW_DecideNpc(common_data.animals, walk->idxUse); + idx = mNpcW_DecideNpc(common_data.save.animals, walk->idxUse); if (idx == -1) { walk->idxUse = 0; @@ -288,10 +288,10 @@ s32 mNpcW_ChangeNpcWalk(NpcWalking* walk, NpcWalkInfo* info) { } } - idx = mNpcW_DecideNpc(common_data.animals, walk->idxUse); + idx = mNpcW_DecideNpc(common_data.save.animals, walk->idxUse); } - mNpcW_SetNpcWalkInfo(free_info, &common_data.animals[idx], idx); + mNpcW_SetNpcWalkInfo(free_info, &common_data.save.animals[idx], idx); walk->idxUse |= (1 << idx); mNpcW_SetGoalBlock(free_info); } @@ -300,7 +300,7 @@ s32 mNpcW_ChangeNpcWalk(NpcWalking* walk, NpcWalkInfo* info) { } s32 mNpcW_GetAloneBlock(u8* goalBlockX, u8* goalBlockZ) { - Animal_c* animal = common_data.animals; + Animal_c* animal = common_data.save.animals; NpcList* npcList = common_data.npclist; u8 block_field[FG_BLOCK_Z_NUM + 2]; u8 count = 0; @@ -415,7 +415,7 @@ s32 mNpcW_CheckDiffBlockWalkNpcHome(s32 blockX, s32 blockZ, NpcWalkInfo* info) { for (i = 0; i < NPCW_MAX; i++) { idx = info->idx; if (idx != -1) { - home = &common_data.animals[idx].homeInfo; + home = &common_data.save.animals[idx].homeInfo; if (home->blockX == blockX && home->blockZ == blockZ) { break; @@ -515,8 +515,8 @@ void mNpcW_SetGoalBlock(NpcWalkInfo* info) { case NPCW_GOAL_MY_HOME: idx = info->idx; - info->goalX = common_data.animals[idx].homeInfo.blockX; - info->goalZ = common_data.animals[idx].homeInfo.blockZ; + info->goalX = common_data.save.animals[idx].homeInfo.blockX; + info->goalZ = common_data.save.animals[idx].homeInfo.blockZ; break; default: @@ -536,13 +536,13 @@ void mNpcW_InitNpcWalk(NpcWalking* walk) { bzero(l_goal_block, sizeof(l_goal_block)); bzero(l_arrive_stay_count, sizeof(l_arrive_stay_count)); - animals = common_data.animals; - walk->infoMax = NPCW_GET_WALK_NUM(common_data.nowNpcMax); + animals = common_data.save.animals; + walk->infoMax = NPCW_GET_WALK_NUM(common_data.save.nowNpcMax); for (i = 0; i < walk->infoMax; i++) { idx = mNpcW_DecideNpc(animals, walk->idxUse); - mNpcW_SetNpcWalkInfo(info, &common_data.animals[idx], idx); + mNpcW_SetNpcWalkInfo(info, &common_data.save.animals[idx], idx); walk->idxUse |= (1 << idx); info++; } @@ -588,7 +588,7 @@ s32 mNpcW_GetWalkInfoStatusGoalAnimalIdx(s32* status, s32* goal, s32 idx) { if (idx >= 0 && idx < ANIMAL_NUM_MAX) { NpcWalking* walk = &common_data.npcWalk; - s32 info_idx = mNpcW_GetNpcWalkInfoIdx(walk->info, NPCW_MAX, &common_data.animals[idx].id); + s32 info_idx = mNpcW_GetNpcWalkInfoIdx(walk->info, NPCW_MAX, &common_data.save.animals[idx].id); if (info_idx >= 0) { res = TRUE; diff --git a/src/code/m_private.c b/src/code/m_private.c index 3c816d4..35a1801 100644 --- a/src/code/m_private.c +++ b/src/code/m_private.c @@ -11,7 +11,6 @@ #include "m_handbill.h" #include "m_house.h" #include "6DA460.h" -#include "6EDD10.h" PrivateInfo g_foreigner_private; Mail_c l_mpr_mail; @@ -57,8 +56,8 @@ s32 mPr_GetPlayerName(char* buf, s32 playerNumber) { s32 res = FALSE; if (mLd_PlayerManKindCheckNo(playerNumber) == FALSE) { - if (mPr_NullCheckPersonalID(&common_data.saveFilePrivateInfo[playerNumber].playerId) == FALSE) { - mPr_CopyPlayerName(buf, common_data.saveFilePrivateInfo[playerNumber].playerId.playerName); + if (mPr_NullCheckPersonalID(&common_data.save.saveFilePrivateInfo[playerNumber].playerId) == FALSE) { + mPr_CopyPlayerName(buf, common_data.save.saveFilePrivateInfo[playerNumber].playerId.playerName); res = TRUE; } } else if (mLd_PlayerManKindCheckNo(common_data.playerNumber) == TRUE) { @@ -146,7 +145,7 @@ s32 mPr_GetRandomFace() { } s32 mPr_GetRandomOriginalFace() { - PrivateInfo* priv = common_data.saveFilePrivateInfo; + PrivateInfo* priv = common_data.save.saveFilePrivateInfo; PrivateInfo* pr2; s32 j; PrivateInfo* pr = priv; @@ -225,11 +224,11 @@ void mPr_InitPrivateInfo(PrivateInfo* priv) { exists = FALSE; face = mPr_GetRandomOriginalFace(); - priv->playerId.landId = common_data.landInfo.id; - mLd_CopyLandName(priv->playerId.landName, common_data.landInfo.name); + priv->playerId.landId = common_data.save.landInfo.id; + mLd_CopyLandName(priv->playerId.landName, common_data.save.landInfo.name); pid = RANDOM_F(253); - ogPriv = common_data.saveFilePrivateInfo; + ogPriv = common_data.save.saveFilePrivateInfo; for (i = 0; i < PLAYER_NUM - 1; i++, exists = FALSE) { s32 j; @@ -287,7 +286,7 @@ s32 mPr_CheckCmpPrivate(PrivateInfo* priv0, PrivateInfo* priv1) { } s32 mPr_GetPrivateIdx(PersonalID_c* pid) { - PrivateInfo* priv = common_data.saveFilePrivateInfo; + PrivateInfo* priv = common_data.save.saveFilePrivateInfo; s32 res = -1; s32 i; @@ -670,7 +669,7 @@ s32 mPr_LoadPak_and_SetPrivateInfo2(u8 player, PakInfo* pak) { if (save == TRUE) { if (player < 4) { - priv = &common_data.saveFilePrivateInfo[player]; + priv = &common_data.save.saveFilePrivateInfo[player]; if (mPr_CheckCmpPrivate(priv, &g_foreigner_private) == TRUE) { mPr_CopyPrivateInfo(priv, &g_foreigner_private); common_data.privateInfo = priv; @@ -680,7 +679,7 @@ s32 mPr_LoadPak_and_SetPrivateInfo2(u8 player, PakInfo* pak) { } else { s32 i; s32 exists; - priv = common_data.saveFilePrivateInfo; + priv = common_data.save.saveFilePrivateInfo; for (i = 0; i < PLAYER_NUM; i++, priv++) { exists = mPr_CheckCmpPrivate(priv, &g_foreigner_private); @@ -753,7 +752,7 @@ s32 mPr_SendMotherMailPost(PersonalID_c* pid, s32 playerNumber, u16 present, s32 UNUSED s32 pad; mail = &l_mpr_mail; - home = &common_data.homes[mHS_get_arrange_idx(playerNumber)]; + home = &common_data.save.homes[mHS_get_arrange_idx(playerNumber)]; if (mPr_CheckCmpPersonalID(pid, &home->ownerID) == TRUE) { mailboxIdx = mMl_chk_mail_free_space(home->mailbox, HOME_MAILBOX_SIZE); @@ -1095,12 +1094,12 @@ void mPr_SendMailFromMother() { if (mLd_PlayerManKindCheckNo(playerNumber) == FALSE && priv != NULL && mPr_NullCheckPersonalID(&priv->playerId) == FALSE) { - mailDate = &common_data.motherMailInfo[playerNumber].date; + mailDate = &common_data.save.motherMailInfo[playerNumber].date; if (mailDate->year != mTM_rtcTime_ymd_clear_code.year && mailDate->month != mTM_rtcTime_ymd_clear_code.month && mailDate->day != mTM_rtcTime_ymd_clear_code.day) { if (mailDate->year != rtcTime->year || mailDate->month != rtcTime->month || mailDate->day != rtcTime->day) { - mPr_SendMotherMail(&common_data.motherMailInfo[playerNumber], rtcTime); + mPr_SendMotherMail(&common_data.save.motherMailInfo[playerNumber], rtcTime); } } else { mTM_set_renew_time(mailDate, rtcTime); @@ -1192,7 +1191,7 @@ s32 mPr_CheckFishCompleteTalk(u8 playerNumber) { s32 res = FALSE; if (playerNumber < PLAYER_NUM && - mPr_GetCompleteTalk(common_data.saveFilePrivateInfo[playerNumber].completeFishInsectFlags, 0) == TRUE) { + mPr_GetCompleteTalk(common_data.save.saveFilePrivateInfo[playerNumber].completeFishInsectFlags, 0) == TRUE) { res = TRUE; } @@ -1207,7 +1206,7 @@ s32 mPr_CheckInsectCompleteTalk(u8 playerNumber) { s32 res = FALSE; if (playerNumber < PLAYER_NUM && - mPr_GetCompleteTalk(common_data.saveFilePrivateInfo[playerNumber].completeFishInsectFlags, 1) == TRUE) { + mPr_GetCompleteTalk(common_data.save.saveFilePrivateInfo[playerNumber].completeFishInsectFlags, 1) == TRUE) { res = TRUE; } @@ -1260,8 +1259,8 @@ void mPr_CopyMapInfo(mPr_map_info_c* dst, mPr_map_info_c* src) { void mPr_SetMapThisLand(mPr_map_info_c* mapInfo) { if (mapInfo != NULL) { - mLd_CopyLandName(mapInfo->landName, common_data.landInfo.name); - mapInfo->landId = common_data.landInfo.id; + mLd_CopyLandName(mapInfo->landName, common_data.save.landInfo.name); + mapInfo->landId = common_data.save.landInfo.id; } } @@ -1301,7 +1300,7 @@ s32 mPr_GetLandMapIdx(mPr_map_info_c* mapInfo, s32 max, LandInfo* landInfo) { } s32 mPr_GetThisLandMapIdx(mPr_map_info_c* map_info, s32 max) { - return mPr_GetLandMapIdx(map_info, max, &common_data.landInfo); + return mPr_GetLandMapIdx(map_info, max, &common_data.save.landInfo); } void mPr_PushMapInfo(mPr_map_info_c* map_info, s32 max) { @@ -1375,7 +1374,7 @@ void mPr_PrintMapInfo_debug(gfxprint* gfxprint) { mapInfo = priv->maps; gfxprint_color(gfxprint, 30, 100, 100, 255); gfxprint_locate8x8(gfxprint, 3, 21); - gfxprint_printf(gfxprint, "%04x ", common_data.landInfo.id); + gfxprint_printf(gfxprint, "%04x ", common_data.save.landInfo.id); gfxprint_locate8x8(gfxprint, 3, 22); gfxprint_color(gfxprint, 30, 200, 70, 255); diff --git a/src/code/m_scene.c b/src/code/m_scene.c index d3be1c9..80bc5c2 100644 --- a/src/code/m_scene.c +++ b/src/code/m_scene.c @@ -14,7 +14,6 @@ #include "m_std_dma.h" #include "m_scene_table.h" #include "m_scene_ftr.h" -#include "m_player_lib.h" #include "overlays/actors/player_actor/m_player.h" s32 func_800C59B0_jp(ObjectExchangeBank* objectExchangeBank) { @@ -468,8 +467,8 @@ void Scene_player_select(s32 sceneNo, s32 npcActor) { s32 selected; metVillagersBitfield = 0; - animal = common_data.animals; - if (sceneNo != common_data.sceneNo) { + animal = common_data.save.animals; + if (sceneNo != common_data.save.sceneNo) { return; } @@ -481,8 +480,8 @@ void Scene_player_select(s32 sceneNo, s32 npcActor) { Anmmem_c* memory = animal->memories; for (j = 0; j < ANIMAL_MEMORY_NUM; j++) { - if (memory->memoryPlayerId.landId == common_data.landInfo.id && - mLd_CheckCmpLandName(memory->memoryPlayerId.landName, common_data.landInfo.name) == TRUE) { + if (memory->memoryPlayerId.landId == common_data.save.landInfo.id && + mLd_CheckCmpLandName(memory->memoryPlayerId.landName, common_data.save.landInfo.name) == TRUE) { metVillagersBitfield |= 1 << i; metVillagersNum++; break; @@ -499,10 +498,10 @@ void Scene_player_select(s32 sceneNo, s32 npcActor) { if (metVillagersNum == 0) { do { selected = RANDOM(ANIMAL_NUM_MAX); - } while (mNpc_CheckFreeAnimalPersonalID(&common_data.animals[selected].id)); + } while (mNpc_CheckFreeAnimalPersonalID(&common_data.save.animals[selected].id)); if (1) {}; - npcId = common_data.animals[selected].id.npcId; - found = mNpc_SearchAnimalinfo(common_data.animals, npcId, ANIMAL_NUM_MAX); + npcId = common_data.save.animals[selected].id.npcId; + found = mNpc_SearchAnimalinfo(common_data.save.animals, npcId, ANIMAL_NUM_MAX); } else { /* Pick a random villager which has met a player in town */ @@ -517,37 +516,30 @@ void Scene_player_select(s32 sceneNo, s32 npcActor) { } metVillagersBitfield >>= 1; } - npcId = common_data.animals[found].id.npcId; + npcId = common_data.save.animals[found].id.npcId; } - mNpc_RegistEventNpc(npcActor, npcId, npcId, common_data.animals[found].cloth); + mNpc_RegistEventNpc(npcActor, npcId, npcId, common_data.save.animals[found].cloth); } -void Scene_Proc_Player_Ptr(Game_Play* play, SceneData* data); -void Scene_Proc_Ctrl_Actor_Ptr(Game_Play* play, SceneData* data); -void Scene_Proc_Actor_Ptr(Game_Play* play, SceneData* data); -void Scene_Proc_Object_Exchange_Bank_Ptr(Game_Play* play, SceneData* data); -void Scene_Proc_Door_Data_Ptr(Game_Play* play, SceneData* data); -void Scene_Proc_Field_ct(Game_Play* play, SceneData* data); +void Scene_Proc_Ctrl_Actor_Ptr(Game_Play* play, SceneData* scene_data); + void Scene_Proc_MyRoom_ct(Game_Play* play, SceneData* data); -void Scene_Proc_ArrangeRoom_ct(Game_Play* play, SceneData* data); -void Scene_Proc_ArrangeFurniture_ct(Game_Play* play, SceneData* data); -void Scene_Proc_Sound(Game_Play* play, SceneData* data); typedef void (*SceneDataProc)(Game_Play*, SceneData*); void Scene_ct(Game_Play* play, SceneData* sceneData) { static SceneDataProc Scene_Proc[] = { - &Scene_Proc_Player_Ptr, - &Scene_Proc_Ctrl_Actor_Ptr, - &Scene_Proc_Actor_Ptr, - &Scene_Proc_Object_Exchange_Bank_Ptr, - &Scene_Proc_Door_Data_Ptr, - &Scene_Proc_Field_ct, - &Scene_Proc_MyRoom_ct, - &Scene_Proc_ArrangeRoom_ct, - &Scene_Proc_ArrangeFurniture_ct, - &Scene_Proc_Sound, + Scene_Proc_Player_Ptr, + Scene_Proc_Ctrl_Actor_Ptr, + Scene_Proc_Actor_Ptr, + Scene_Proc_Object_Exchange_Bank_Ptr, + Scene_Proc_Door_Data_Ptr, + Scene_Proc_Field_ct, + Scene_Proc_MyRoom_ct, + Scene_Proc_ArrangeRoom_ct, + Scene_Proc_ArrangeFurniture_ct, + Scene_Proc_Sound, NULL, }; @@ -724,7 +716,7 @@ s32 goto_emu_game(Game_Play* play, s16 famicomRomId) { res = TRUE; door_data = &common_data.famicomEmuDoorData; - door_data->nextSceneId = common_data.sceneNo; + door_data->nextSceneId = common_data.save.sceneNo; door_data->exitOrientation = 0; door_data->exitType = 0; door_data->params = 0; @@ -743,5 +735,5 @@ void return_emu_game(Game* game) { common_data.doorData.nextSceneId = common_data.famicomEmuDoorData.nextSceneId + 1; game->unk_74 = FALSE; game_goto_next_game_play(game); - common_data.sceneNo = common_data.famicomEmuDoorData.nextSceneId; + common_data.save.sceneNo = common_data.famicomEmuDoorData.nextSceneId; } diff --git a/src/code/m_snowman.c b/src/code/m_snowman.c index 3075c24..e55229a 100644 --- a/src/code/m_snowman.c +++ b/src/code/m_snowman.c @@ -40,7 +40,7 @@ s32 mSN_check_life(u16* name, s32 daysElapsed) { } void mSN_ClearSnowmanData(u16* name, s32 snowmanIndex) { - bzero(&common_data.snowmanData[snowmanIndex], sizeof(SnowmanData)); + bzero(&common_data.save.snowmanData[snowmanIndex], sizeof(SnowmanData)); *name = 0; } @@ -70,17 +70,17 @@ s32 mSN_MeltSnowman(u16* name, s32 daysElapsed) { if (daysElapsed < 0) { daysElapsed = 1; - common_data.snowmanYear = 0; - common_data.snowmanMonth = 0; - common_data.snowmanDay = 0; - common_data.snowmanHour = 0; + common_data.save.snowmanYear = 0; + common_data.save.snowmanMonth = 0; + common_data.save.snowmanDay = 0; + common_data.save.snowmanHour = 0; } if (!mSN_check_life(name, daysElapsed)) { mSN_ClearSnowmanData(name, snowmanIndex); } else { - SnowmanData* snowmanData = &common_data.snowmanData[snowmanIndex]; + SnowmanData* snowmanData = &common_data.save.snowmanData[snowmanIndex]; *name += daysElapsed; @@ -103,7 +103,7 @@ s32 mSN_MeltSnowman(u16* name, s32 daysElapsed) { * @return the index of the first empty slot. If there are no empty slots, return -1. */ s32 mSN_get_free_space(void) { - SnowmanData* snowmanData = common_data.snowmanData; + SnowmanData* snowmanData = common_data.save.snowmanData; s32 snowmanIndex; for (snowmanIndex = 0; snowmanIndex < SNOWMAN_SAVE_COUNT; snowmanIndex++) { @@ -121,7 +121,7 @@ void mSN_regist_snowman_society(SnowmanInfo* snowmanInfo) { u16 name; if (snowmanIndex != -1) { - mem_copy((u8*)&common_data.snowmanData[snowmanIndex], (u8*)snowmanInfo, sizeof(SnowmanData)); + mem_copy((u8*)&common_data.save.snowmanData[snowmanIndex], (u8*)snowmanInfo, sizeof(SnowmanData)); if (sp2E) { mPB_keep_item(sp2E); @@ -138,6 +138,6 @@ void mSN_decide_msg(void) { } void mSN_snowman_init(void) { - bzero(common_data.snowmanData, sizeof(SnowmanData[SNOWMAN_SAVE_COUNT])); + bzero(common_data.save.snowmanData, sizeof(SnowmanData[SNOWMAN_SAVE_COUNT])); mSN_decide_msg(); } diff --git a/src/code/m_start_data_init.c b/src/code/m_start_data_init.c index 7dd776c..ca4c3dd 100644 --- a/src/code/m_start_data_init.c +++ b/src/code/m_start_data_init.c @@ -10,7 +10,7 @@ #include "6E3240.h" #include "m_string.h" #include "6ECD90.h" -#include "6EDD10.h" +#include "m_time.h" #include "global.h" #include "lb_rtc.h" #include "libc64/qrand.h" @@ -34,12 +34,11 @@ #include "m_quest.h" #include "m_scene_table.h" #include "m_snowman.h" -#include "m_time.h" #include "overlays/gamestates/ovl_play/m_play.h" #include "sys_math.h" void famicom_emu_initial_common_data(void) { - FamicomEmuCommonData* famicom = &common_data.famicomEmuCommonData; + FamicomEmuCommonData* famicom = &common_data.save.famicomEmuCommonData; famicom->unk00 = 0; famicom->unk02 = 0x3E8; @@ -80,9 +79,9 @@ void title_game_haniwa_data_init(void) { mString_Load_StringFromRom(haniwaBuf, HANIWA_MESSAGE_LEN, 0x55C); for (i = 0; i < mHS_HOUSE_NUM; i++) { - haniwa = &common_data.homes[i].haniwa; + haniwa = &common_data.save.homes[i].haniwa; - mem_copy(common_data.homes[i].haniwa.message, (u8*)haniwaBuf, HANIWA_MESSAGE_LEN); + mem_copy(common_data.save.homes[i].haniwa.message, (u8*)haniwaBuf, HANIWA_MESSAGE_LEN); for (j = 0; j < HANIWA_ITEM_HOLD_NUM; j++) { haniwa->items[j].item = EMPTY_NO; @@ -111,7 +110,7 @@ void mSDI_ClearMoneyPlayerHomeStationBlock(void) { blockX = block_num[i][0]; depositOffset = block_num[i][1] * FG_BLOCK_X_NUM + blockX; - items = common_data.foreground[blockZ][blockX].items[0]; + items = common_data.save.foreground[blockZ][blockX].items[0]; if (items != NULL) { for (utZ = 0; utZ < UT_Z_NUM; utZ++) { @@ -119,7 +118,7 @@ void mSDI_ClearMoneyPlayerHomeStationBlock(void) { item = *items; if (item >= ITM_MONEY_START && item <= ITM_MONEY_END) { - u16* deposit = common_data.deposit[depositOffset]; + u16* deposit = common_data.save.deposit[depositOffset]; mPB_keep_item(item); *items = EMPTY_NO; @@ -157,7 +156,7 @@ void mSDI_PullTree(void) { for (blockZ = 0; blockZ < FG_BLOCK_Z_NUM; blockZ++) { // Clear trees against the cliffs on the left and right town cliff borders - fgBlock = &common_data.foreground[blockZ][0]; + fgBlock = &common_data.save.foreground[blockZ][0]; mSDI_PullTreeBlock(fgBlock->items[0], 0); mSDI_PullTreeBlock((fgBlock + FG_BLOCK_X_NUM - 1)->items[0], UT_X_NUM - 1); } @@ -175,7 +174,7 @@ void mSDI_PullTreeUnderPlayerBlock(void) { * ... **/ - u16* items = &common_data.foreground[2][2].items[0][0]; + u16* items = &common_data.save.foreground[2][2].items[0][0]; mSDI_PullTreeUT(&items[7]); mSDI_PullTreeUT(&items[8]); @@ -194,18 +193,18 @@ s32 mSDI_StartInitNew(Game* game2, s32 playerNumber, s32 mallocFlag) { common_data.sceneFromTitleDemo = SCENE_START_DEMO; lbRTC_GetTime(&common_data.time.rtcTime); - privateInfo = &common_data.saveFilePrivateInfo[playerNumber]; + privateInfo = &common_data.save.saveFilePrivateInfo[playerNumber]; common_data.privateInfo = privateInfo; common_data.playerNumber = playerNumber; common_data.privateInfo->gender = mPr_SEX_MALE; - decide_fruit(&common_data.fruit); + decide_fruit(&common_data.save.fruit); if (mallocFlag == 0) { game = game2; } - bzero(&common_data.deposit, sizeof(common_data.deposit)); + bzero(&common_data.save.deposit, sizeof(common_data.save.deposit)); mFM_InitFgCombiSaveData(game); mSDI_PullTree(); @@ -213,11 +212,11 @@ s32 mSDI_StartInitNew(Game* game2, s32 playerNumber, s32 mallocFlag) { mFM_SetBlockKindLoadCombi(game); mAGrw_ChangeTree2FruitTree(); - privateInfoPointer = &common_data.saveFilePrivateInfo[0]; + privateInfoPointer = &common_data.save.saveFilePrivateInfo[0]; mMld_SetDefaultMelody(); mLd_LandDataInit(); - mEv_ClearEventSaveInfo(&common_data.eventSaveInfo); + mEv_ClearEventSaveInfo(&common_data.save.eventSaveInfo); mEv_init(&game_play->event); mNpc_InitNpcAllInfo(mallocFlag); @@ -229,27 +228,27 @@ s32 mSDI_StartInitNew(Game* game2, s32 playerNumber, s32 mallocFlag) { privateInfoPointer += playerNumber; privateInfoPointer -= PLAYER_NUM; mPr_InitPrivateInfo(privateInfoPointer); - mNpc_SetRemoveAnimalNo(common_data.animals); + mNpc_SetRemoveAnimalNo(common_data.save.animals); title_game_haniwa_data_init(); mPB_police_box_init(game); mSN_snowman_init(); mHS_house_init(); - lbRTC_TimeCopy(&common_data.lastGrowTime, &mTM_rtcTime_clear_code); - lbRTC_TimeCopy(&common_data.unk_0F89C, &mTM_rtcTime_clear_code); - lbRTC_TimeCopy(&common_data.unk_0F8A4, &mTM_rtcTime_clear_code); + lbRTC_TimeCopy(&common_data.save.lastGrowTime, &mTM_rtcTime_clear_code); + lbRTC_TimeCopy(&common_data.save.unk_0F89C, &mTM_rtcTime_clear_code); + lbRTC_TimeCopy(&common_data.save.unk_0F8A4, &mTM_rtcTime_clear_code); for (i = 0; i < PLAYER_NUM; i++) { - common_data.homes[i].unk_022.unk_22_0 = 0; - common_data.homes[i].unk_022.unk_22_2 = 0; - common_data.homes[i].unk_022.unk_22_4 = 0; - common_data.homes[i].unk_024 = i; + common_data.save.homes[i].unk_022.unk_22_0 = 0; + common_data.save.homes[i].unk_022.unk_22_2 = 0; + common_data.save.homes[i].unk_022.unk_22_4 = 0; + common_data.save.homes[i].unk_024 = i; } - common_data.stationType = RANDOM_F(15); + common_data.save.stationType = RANDOM_F(15); for (i = 0; i < PLAYER_NUM; i++) { - mPr_ClearMotherMailInfo(&common_data.motherMailInfo[i]); + mPr_ClearMotherMailInfo(&common_data.save.motherMailInfo[i]); } mPr_SetPossessionItem(common_data.privateInfo, 0, ITM_MONEY_1000, mPr_ITEM_COND_QUEST); @@ -273,7 +272,7 @@ s32 mSDI_StartInitFrom(Game* game2, s32 playerNumber, s32 mallocFlag) { lbRTC_GetTime(&common_data.time.rtcTime); if (mFRm_CheckSaveData() == TRUE) { - privateInfo = &common_data.saveFilePrivateInfo[playerNumber]; + privateInfo = &common_data.save.saveFilePrivateInfo[playerNumber]; if (mPr_CheckPrivate(privateInfo) == TRUE) { if (privateInfo->exists == TRUE) { common_data.privateInfo = privateInfo; @@ -282,7 +281,7 @@ s32 mSDI_StartInitFrom(Game* game2, s32 playerNumber, s32 mallocFlag) { mEv_init_force(&game_play->event); mHsRm_GetHuusuiRoom(game, playerNumber); mSP_ExchangeLineUp_InGame(game); - mNpc_SetRemoveAnimalNo(common_data.animals); + mNpc_SetRemoveAnimalNo(common_data.save.animals); mCkRh_DecideNowGokiFamilyCount(playerNumber); mMkRm_MarkRoom(game); res = TRUE; @@ -294,7 +293,7 @@ s32 mSDI_StartInitFrom(Game* game2, s32 playerNumber, s32 mallocFlag) { mFM_SetBlockKindLoadCombi(game); mHsRm_GetHuusuiRoom(game, playerNumber); mSP_ExchangeLineUp_InGame(game); - mNpc_SetRemoveAnimalNo(common_data.animals); + mNpc_SetRemoveAnimalNo(common_data.save.animals); bzero(privateInfo->inventory.pockets, sizeof(privateInfo->inventory.pockets)); privateInfo->inventory.lotto_ticket_expiry_month = 0; @@ -321,7 +320,7 @@ s32 mSDI_StartInitNewPlayer(Game* game, s32 playerNumber, s32 mallocFlag) { common_data.sceneFromTitleDemo = SCENE_START_DEMO2; lbRTC_GetTime(&common_data.time.rtcTime); - privateInfo = &common_data.saveFilePrivateInfo[playerNumber]; + privateInfo = &common_data.save.saveFilePrivateInfo[playerNumber]; if (mFRm_CheckSaveData() == TRUE) { if (mPr_CheckPrivate(privateInfo) != TRUE) { mPr_InitPrivateInfo(privateInfo); @@ -338,7 +337,7 @@ s32 mSDI_StartInitNewPlayer(Game* game, s32 playerNumber, s32 mallocFlag) { mEv_init_force(&game_play->event); mSP_ExchangeLineUp_InGame(NULL); } - mNpc_SetRemoveAnimalNo(common_data.animals); + mNpc_SetRemoveAnimalNo(common_data.save.animals); mSDI_ClearMoneyPlayerHomeStationBlock(); res = TRUE; } @@ -368,7 +367,7 @@ s32 mSDI_StartInitPak(Game* game2, s32 playerNumber, s32 mallocFlag) { mEv_init_force(&game_play->event); mHsRm_GetHuusuiRoom(game, playerNumber); mSP_ExchangeLineUp_InGame(game); - mNpc_SetRemoveAnimalNo(common_data.animals); + mNpc_SetRemoveAnimalNo(common_data.save.animals); mNpc_SetReturnAnimal(mNpc_GetInAnimalP()); mNpc_SendRegisteredGoodbyMail(); mCkRh_DecideNowGokiFamilyCount(playerNumber); @@ -403,7 +402,7 @@ void mSDI_StartInitAfter(Game* game, s32 renewalReserveFlag, s32 mallocFlag) { Kabu_manager(); mNpc_InitNpcData(); mNpc_InitNpcList(); - mNpc_SetNpcList(common_data.npclist, common_data.animals, ANIMAL_NUM_MAX, mallocFlag); + mNpc_SetNpcList(common_data.npclist, common_data.save.animals, ANIMAL_NUM_MAX, mallocFlag); mNpc_ClearTalkInfo(); if (renewalReserveFlag == 1) { mFM_RenewalReserve(); @@ -424,7 +423,7 @@ void mSDI_StartInitAfter(Game* game, s32 renewalReserveFlag, s32 mallocFlag) { func_8008DCF8_jp(); func_800A4D10_jp(); mSN_decide_msg(); - mPr_RenewalMapInfo(common_data.privateInfo->maps, mPr_FOREIGN_MAP_COUNT, &common_data.landInfo); + mPr_RenewalMapInfo(common_data.privateInfo->maps, mPr_FOREIGN_MAP_COUNT, &common_data.save.landInfo); } typedef s32 (*StartDataInitProcess)(Game*, s32, s32); diff --git a/src/code/m_time.c b/src/code/m_time.c index f4f4601..01d3a77 100644 --- a/src/code/m_time.c +++ b/src/code/m_time.c @@ -99,7 +99,7 @@ void mTM_set_renew_time(lbRTC_ymd_t* renewTime, lbRTC_time_c* time) { } void mTM_renewal_renew_time() { - lbRTC_ymd_t* renewTime = &common_data.renewTime; + lbRTC_ymd_t* renewTime = &common_data.save.renewTime; lbRTC_time_c* rtcTime = &common_data.time.rtcTime; if ((renewTime->year != rtcTime->year) || (renewTime->month != rtcTime->month) || diff --git a/src/overlays/actors/ovl_Bee/ac_bee.c b/src/overlays/actors/ovl_Bee/ac_bee.c index 1d8418e..6f05e28 100644 --- a/src/overlays/actors/ovl_Bee/ac_bee.c +++ b/src/overlays/actors/ovl_Bee/ac_bee.c @@ -33,7 +33,7 @@ ActorProfile Bee_Profile = { /* */ NULL, }; -void aBEE_setupAction(Bee*, s32, Game_Play*); +void aBEE_setupAction(Bee* this, s32 processIndex, Game_Play* game_play); void aBEE_actor_ct(Actor* thisx, Game_Play* game_play) { Bee* this = THIS; diff --git a/src/overlays/actors/ovl_Dump/ac_dump.c b/src/overlays/actors/ovl_Dump/ac_dump.c index fd6cfc0..2518f9e 100644 --- a/src/overlays/actors/ovl_Dump/ac_dump.c +++ b/src/overlays/actors/ovl_Dump/ac_dump.c @@ -47,8 +47,8 @@ ShadowData aDUM_shadow_data = { 48, aDUM_shadow_vtx_fix_flg_table, 60.0f, obj_dump_shadow_v, obj_dump_shadowT_model, }; -void aDUM_set_bgOffset(Dump*, s32); -void aDUM_setup_action(Dump*, s32); +void aDUM_set_bgOffset(Dump* this, s32 arg1); +void aDUM_setup_action(Dump* this, s32 processIndex); void aDUM_actor_ct(Actor* thisx, UNUSED Game_Play* game_play) { Dump* this = THIS; diff --git a/src/overlays/actors/ovl_Fuusen/ac_fuusen.c b/src/overlays/actors/ovl_Fuusen/ac_fuusen.c index 8af69ad..937a47b 100644 --- a/src/overlays/actors/ovl_Fuusen/ac_fuusen.c +++ b/src/overlays/actors/ovl_Fuusen/ac_fuusen.c @@ -24,7 +24,7 @@ void aFSN_actor_ct(Actor* thisx, Game_Play* game_play); void aFSN_actor_dt(Actor* thisx, Game_Play* game_play); void aFSN_actor_move(Actor* thisx, Game_Play* game_play); void aFSN_actor_draw(Actor* thisx, Game_Play* game_play); -void aFSN_setupAction(Fuusen*, s32, Game_Play*); +void aFSN_setupAction(Fuusen* this, s32 processIndex, Game_Play* game_play); ActorProfile Fuusen_Profile = { /* */ ACTOR_FUUSEN, diff --git a/src/overlays/actors/ovl_Kago/ac_kago.c b/src/overlays/actors/ovl_Kago/ac_kago.c index db62006..3a61245 100644 --- a/src/overlays/actors/ovl_Kago/ac_kago.c +++ b/src/overlays/actors/ovl_Kago/ac_kago.c @@ -20,8 +20,8 @@ void aKAG_actor_dt(Actor* thisx, Game_Play* game_play); void aKAG_actor_init(Actor* thisx, Game_Play* game_play); void aKAG_actor_draw(Actor* thisx, Game_Play* game_play); -void aKAG_set_bgOffset(Kago*, s32); -void aKAG_setup_action(Kago*, s32); +void aKAG_set_bgOffset(Kago* this, s32 id); +void aKAG_setup_action(Kago* this, s32 processIndex); ActorProfile Kago_Profile = { /* */ ACTOR_KAGO, diff --git a/src/overlays/actors/ovl_Structure/ac_structure.c b/src/overlays/actors/ovl_Structure/ac_structure.c index f4501dd..635f06c 100644 --- a/src/overlays/actors/ovl_Structure/ac_structure.c +++ b/src/overlays/actors/ovl_Structure/ac_structure.c @@ -557,7 +557,7 @@ Actor* aSTR_setupActor_proc(Game_Play* game_play, u16 structureName, f32 posX, f s16 paletteType; if (structureName < 0x50DA) { - s32 index = mNpc_SearchAnimalinfo(common_data.animals, structureName + 0x9000, 0xF); + s32 index = mNpc_SearchAnimalinfo(common_data.save.animals, structureName + 0x9000, 0xF); profile = ACTOR_HOUSE; structureType = common_data.npclist[index].houseData.type; @@ -568,10 +568,10 @@ Actor* aSTR_setupActor_proc(Game_Play* game_play, u16 structureName, f32 posX, f StructureSetupInfo* info = &setupInfo_table[index]; profile = info->profile; - structureType = common_data.homes[index].unk_022.unk_22_0 + STRUCTURE_TYPE_MY_HOUSE_1; - paletteType = common_data.homes[index].unk_024 + STRUCTURE_PALETTE_MY_HOUSE_1; + structureType = common_data.save.homes[index].unk_022.unk_22_0 + STRUCTURE_TYPE_MY_HOUSE_1; + paletteType = common_data.save.homes[index].unk_024 + STRUCTURE_PALETTE_MY_HOUSE_1; } else if ((structureName >= 0x5809) && (structureName < 0x580A)) { - s32 stationType = common_data.stationType; + s32 stationType = common_data.save.stationType; profile = ACTOR_STATION; structureType = (stationType / 5) + STRUCTURE_TYPE_STATION_1; diff --git a/src/overlays/actors/ovl_Tama/ac_tama.c b/src/overlays/actors/ovl_Tama/ac_tama.c index f19ce93..59e3bfe 100644 --- a/src/overlays/actors/ovl_Tama/ac_tama.c +++ b/src/overlays/actors/ovl_Tama/ac_tama.c @@ -36,7 +36,7 @@ ActorProfile Tama_Profile = { /* */ NULL, }; -void aTAM_setup_action(Tama*, s32); +void aTAM_setup_action(Tama* this, s32 processIndex); void aTAM_actor_ct(Actor* thisx, UNUSED Game_Play* game_play) { Tama* this = THIS; diff --git a/src/overlays/actors/ovl_Train_Window/ac_train_window.c b/src/overlays/actors/ovl_Train_Window/ac_train_window.c index ee200d9..a714a8b 100644 --- a/src/overlays/actors/ovl_Train_Window/ac_train_window.c +++ b/src/overlays/actors/ovl_Train_Window/ac_train_window.c @@ -70,7 +70,7 @@ s32 aTrainWindow_GetTreePalletIdx(void) { void Train_Window_Actor_ct(Actor* thisx, UNUSED Game_Play* play) { Train_Window* this = (Train_Window*)thisx; - if (common_data.sceneNo == 15) { + if (common_data.save.sceneNo == 15) { this->drawType = aTrainWindow_NoDraw; this->singleScrollX = 0; this->singleScrollY = 0; diff --git a/src/overlays/actors/ovl_Weather/ac_weather.c b/src/overlays/actors/ovl_Weather/ac_weather.c index b918724..ebbc4d4 100644 --- a/src/overlays/actors/ovl_Weather/ac_weather.c +++ b/src/overlays/actors/ovl_Weather/ac_weather.c @@ -12,7 +12,7 @@ #include "m_rcp.h" #include "code_variables.h" #include "m_kankyo.h" -#include "6EDD10.h" +#include "m_time.h" #include "m_event.h" #include "m_all_grow.h" #include "683030.h" @@ -197,8 +197,8 @@ s32 aWeather_StartSysLevSE() { Weather* this = common_data.clip.weatherClip->actor; if (this->soundFlag == 1) { - if (ENV_SAVE_GET_WEATHER_TYPE(common_data.saveWeather) == 1) { - switch (ENV_SAVE_GET_WEATHER_INTENSITY(common_data.saveWeather)) { + if (ENV_SAVE_GET_WEATHER_TYPE(common_data.save.saveWeather) == 1) { + switch (ENV_SAVE_GET_WEATHER_INTENSITY(common_data.save.saveWeather)) { case 1: aWeather_SysLevStart(7); this->currentSoundEffect = 7; @@ -252,7 +252,7 @@ void aWeather_ChangeEnvSE(Weather* this, Game_Play* play, s16 status, s16 level) } if (mEv_CheckTitleDemo() <= 0) { - if (common_data.sceneNo == SCENE_START_DEMO || common_data.sceneNo == SCENE_START_DEMO2) { + if (common_data.save.sceneNo == SCENE_START_DEMO || common_data.save.sceneNo == SCENE_START_DEMO2) { return; } if ((status == 1) && (this->currentSoundEffect == -1000)) { @@ -632,7 +632,7 @@ void aWeather_ChangeWeatherTime0(Weather* this) { s16 saveRnd; if ((mEv_CheckTitleDemo() <= 0)) { - if ((common_data.sceneNo == 15) || (common_data.sceneNo == 16)) { + if ((common_data.save.sceneNo == 15) || (common_data.save.sceneNo == 16)) { return; } if ((mTM_check_renew_time(0) != 0)) { @@ -648,14 +648,14 @@ void aWeather_ChangeWeatherTime0(Weather* this) { } mTM_off_renew_time(0); - saveWeather = ENV_SAVE_GET_WEATHER_TYPE(common_data.saveWeather); + saveWeather = ENV_SAVE_GET_WEATHER_TYPE(common_data.save.saveWeather); if (rndWeather == 0 || rndWeather == 3) { if (saveWeather == 2 || saveWeather == 1) { mAGrw_OrderSetHaniwa(); } } saveRnd = rndIntensity | ((rndWeather ^ 0) * 16); - common_data.saveWeather = saveRnd; + common_data.save.saveWeather = saveRnd; if (((mEv_CheckTitleDemo() != -9) || (this->soundFlag != 1))) { aWeather_RequestChangeWeather(&this->actor, rndWeather, rndIntensity); @@ -670,7 +670,7 @@ void aWeather_MakeKaminari(Actor* thisx) { lbRTC_time_c time = common_data.time.rtcTime; u8 month = time.month; - if ((common_data.sceneNo != 15) && (common_data.sceneNo != 16)) { + if ((common_data.save.sceneNo != 15) && (common_data.save.sceneNo != 16)) { if ((month >= lbRTC_JUNE) && (month <= lbRTC_AUGUST) && (this->currentStatus == 1)) { s16* ptr = &this->lightningTimer; if (this->currentLevel == 3) { diff --git a/src/overlays/gamestates/ovl_cpedit/m_cpedit.h b/src/overlays/gamestates/ovl_cpedit/m_cpedit.h index 70ecd3c..749c8c4 100644 --- a/src/overlays/gamestates/ovl_cpedit/m_cpedit.h +++ b/src/overlays/gamestates/ovl_cpedit/m_cpedit.h @@ -18,7 +18,7 @@ struct Game_CPEdit { /* 0x2FC */ ObjectExchangeBank bank; }; // size = 0x1B20 -void cpedit_init(Game *thisx); -void cpedit_cleanup(Game *thisx); +void cpedit_init(Game* game); +void cpedit_cleanup(Game* game); #endif diff --git a/src/overlays/gamestates/ovl_play/m_play.c b/src/overlays/gamestates/ovl_play/m_play.c index 33a269f..add724a 100644 --- a/src/overlays/gamestates/ovl_play/m_play.c +++ b/src/overlays/gamestates/ovl_play/m_play.c @@ -10,7 +10,7 @@ #include "m_player_lib.h" #include "audio.h" #include "6EC9E0.h" -#include "6EDD10.h" +#include "m_time.h" #include "69E2C0.h" #include "683030.h" #include "6E3240.h" @@ -211,8 +211,8 @@ void Game_play_fbdemo_fade_out_game_end_move_end(Game_Play* game_play) { void Game_play_change_scene_move_end(Game_Play* game_play) { game_goto_next_game_play(&game_play->state); - common_data.unk_10004 = common_data.sceneNo; - common_data.sceneNo = game_play->unk_1E18; + common_data.unk_10004 = common_data.save.sceneNo; + common_data.save.sceneNo = game_play->unk_1E18; } void Game_play_fbdemo_wipe_move(Game_Play* game_play) { @@ -395,7 +395,7 @@ void play_init(Game* game) { func_8006BB64_jp(); func_8006C8D0_jp(); game_play->unk_1DAC = -1; - Gameplay_Scene_Read(game_play, common_data.sceneNo); + Gameplay_Scene_Read(game_play, common_data.save.sceneNo); mSM_submenu_ct(&game_play->submenu); game_play->submenu.unk_00 = 0; PreRender_init(&game_play->unk_1DC0); @@ -867,5 +867,5 @@ void Gameplay_Scene_Read(Game_Play* game_play, s16 arg1) { sp1C->unk_13 = 0; gSegments[2] = (uintptr_t)OS_K0_TO_PHYSICAL(game_play->unk_010C); Gameplay_Scene_Init(game_play); - sAdo_RoomType(mPl_SceneNo2SoundRoomType(common_data.sceneNo)); + sAdo_RoomType(mPl_SceneNo2SoundRoomType(common_data.save.sceneNo)); } diff --git a/src/overlays/gamestates/ovl_save_menu/save_menu.c b/src/overlays/gamestates/ovl_save_menu/save_menu.c index 5593b55..e29aeac 100644 --- a/src/overlays/gamestates/ovl_save_menu/save_menu.c +++ b/src/overlays/gamestates/ovl_save_menu/save_menu.c @@ -66,7 +66,7 @@ void save_menu_data_save_pak(Game_SaveMenu* saveMenu) { } mCPk_PakOpen(mCPk_get_pkinfo(), 0); - if (mCPk_SavePak(common_data.saveFilePrivateInfo, common_data.animals, mCPk_get_pkinfo()) == TRUE) { + if (mCPk_SavePak(common_data.save.saveFilePrivateInfo, common_data.save.animals, mCPk_get_pkinfo()) == TRUE) { if (mLd_PlayerManKindCheck() == FALSE) { common_data.privateInfo->exists = FALSE; } diff --git a/src/overlays/gamestates/ovl_save_menu/save_menu.h b/src/overlays/gamestates/ovl_save_menu/save_menu.h index e4a18d7..395283c 100644 --- a/src/overlays/gamestates/ovl_save_menu/save_menu.h +++ b/src/overlays/gamestates/ovl_save_menu/save_menu.h @@ -28,8 +28,7 @@ typedef enum SaveMenuSaveMode { /* 2 */ SAVE_MODE_MAX }SaveMenuSaveMode; - -void save_menu_init(Game *thisx); +void save_menu_init(Game* game); void save_menu_cleanup(Game *thisx); #endif diff --git a/src/overlays/gamestates/ovl_second_game/second_game.h b/src/overlays/gamestates/ovl_second_game/second_game.h index dd70975..6e0c838 100644 --- a/src/overlays/gamestates/ovl_second_game/second_game.h +++ b/src/overlays/gamestates/ovl_second_game/second_game.h @@ -9,7 +9,7 @@ typedef struct Game_SecondGame { /* 0x00 */ Game state; } Game_SecondGame; // size = 0xE0 -void second_game_init(Game *thisx); +void second_game_init(Game* game); void second_game_cleanup(Game *thisx); #endif diff --git a/src/overlays/gamestates/ovl_select/m_select.c b/src/overlays/gamestates/ovl_select/m_select.c index 163c2ef..061d070 100644 --- a/src/overlays/gamestates/ovl_select/m_select.c +++ b/src/overlays/gamestates/ovl_select/m_select.c @@ -50,7 +50,7 @@ NameFunction nf_tbl[SCENE_NUM] = { }; void game_next_play(Game* game, s32 scene) { - common_data.sceneNo = scene; + common_data.save.sceneNo = scene; STOP_GAMESTATE(game); SET_NEXT_GAMESTATE(game, play_init, sizeof(Game_Play)); mHm_SetNowHome(); @@ -155,7 +155,7 @@ s32 select_check_A_button_weather(UNUSED Game_Select* select) { u8 saved; saved = weather; saved = weather << 4; - common_data.saveWeather = saved | 3; + common_data.save.saveWeather = saved | 3; } return 0; @@ -954,7 +954,7 @@ void select_init(Game* game) { SetGameFrame(1); - common_data.unk_10004 = common_data.sceneNo; + common_data.unk_10004 = common_data.save.sceneNo; common_data.unk_104AD = 0; common_data.privateInfo->inventory.loan = 1000; diff --git a/src/overlays/gamestates/ovl_trademark/m_trademark.c b/src/overlays/gamestates/ovl_trademark/m_trademark.c new file mode 100644 index 0000000..8a1300c --- /dev/null +++ b/src/overlays/gamestates/ovl_trademark/m_trademark.c @@ -0,0 +1,584 @@ +#include "m_trademark.h" + +#include "audio.h" +#include "m_actor.h" +#include "m_common_data.h" +#include "m_event.h" +#include "m_field_info.h" +#include "m_flashrom.h" +#include "m_mail.h" +#include "m_npc.h" +#include "m_scene_table.h" +#include "m_time.h" +#include "m_rcp.h" +#include "m_view.h" +#include "sys_math.h" +#include "sys_matrix.h" +#include "libc64/qrand.h" +#include "m_std_dma.h" +#include "67E840.h" +#include "69CB30.h" +#include "6B3DC0.h" +#include "6B8F20.h" +#include "6EC9E0.h" +#include "segment_symbols.h" +#include "macros.h" + +#include "overlays/gamestates/ovl_play/m_play.h" + +typedef enum TrademarkState { + /* 0 */ TRADEMARK_STATE_0, + /* 1 */ TRADEMARK_STATE_1, + /* 2 */ TRADEMARK_STATE_2, + /* 3 */ TRADEMARK_STATE_3, + /* 4 */ TRADEMARK_STATE_4, + /* 5 */ TRADEMARK_STATE_5, +} TrademarkState; + +DoorData demo_1_door_data = { SCENE_TITLE_DEMO, 4, 0, 0, { 0x884, 0xC8, 0x338 }, 0, 3, { 0, 0, 0 } }; +DoorData demo_2_door_data = { SCENE_TITLE_DEMO, 4, 0, 0, { 0xC92, 0x28, 0xC02 }, 0, 3, { 0, 0, 0 } }; +DoorData demo_3_door_data = { SCENE_TITLE_DEMO, 4, 0, 0, { 0x845, 0xA0, 0x5D0 }, 0, 3, { 0, 0, 0 } }; +DoorData demo_4_door_data = { SCENE_TITLE_DEMO, 4, 0, 0, { 0xB53, 0xA0, 0x44D }, 0, 3, { 0, 0, 0 } }; +DoorData demo_5_door_data = { SCENE_TITLE_DEMO, 4, 0, 0, { 0x62A, 0x28, 0x9A8 }, 0, 3, { 0, 0, 0 } }; + +DoorData* l_demo_door_data_table[] = { + &demo_1_door_data, &demo_2_door_data, &demo_3_door_data, &demo_4_door_data, &demo_5_door_data, +}; + +u8 B_80808560_jp[0x10000]; +u8 B_80818560_jp[0x10000]; +u8 B_80828560_jp[0xC0]; +OSMesgQueue B_80828620_jp[6]; +u8 B_808286B0_jp[0x20]; + +s32 func_80804C40_jp(void) { + OSMesgQueue* mq = B_80828620_jp; + s32 i; + + if (func_80090120_jp() != 0) { + return true; + } + + for (i = 0; i < ARRAY_COUNT(B_80828620_jp); i++, mq++) { + if (osRecvMesg(mq, NULL, OS_MESG_NOBLOCK) == 0) { + return false; + } + } + + func_80090130_jp(1); + return true; +} + +DemoNpc demo_npc_list[] = { + { 0xE000, 1, 2, 3, 7 }, { 0xE04C, 1, 2, 8, 0xB }, { 0xE0AD, 1, 4, 0xC, 0xB }, { 0xE048, 2, 3, 5, 6 }, + { 0xE0B9, 2, 3, 4, 0xC }, { 0xE06F, 3, 5, 0xB, 5 }, { 0xE0AA, 4, 3, 3, 0xC }, { 0xE08C, 4, 4, 3, 4 }, + { 0xE09B, 4, 4, 0xC, 0xD }, { 0xE0C2, 4, 6, 5, 6 }, { 0xE07D, 5, 2, 0xC, 4 }, { 0xE061, 5, 2, 9, 0xB }, + { 0xE0B6, 5, 4, 0xB, 4 }, { 0xE093, 5, 5, 5, 0xB }, +}; +s32 demo_npc_num = ARRAY_COUNT(demo_npc_list); + +s32 set_npc_4_title_demo(Game_Trademark* this) { + mNpc_SetAnimalTitleDemo(demo_npc_list, common_data.save.animals, &this->state); + mNpc_SetNpcList(common_data.npclist, common_data.save.animals, demo_npc_num, 0); + + return demo_npc_num; +} + +typedef struct TradeDayEntry { + /* 0x0 */ u8 month; + /* 0x1 */ u8 day; + /* 0x2 */ u8 hour; + /* 0x4 */ s16 weather; +} TradeDayEntry; // size = 0x6 + +void mTM_demotime_set(s32 arg0) { + common_data.time.rtcEnabled = 0; + common_data.time.rtcTime.year = mTM_MIN_YEAR; + common_data.time.rtcTime.min = 0; + + if (arg0 != 0) { + static TradeDayEntry tradeday_table[] = { + { lbRTC_APRIL, 6, 13, 3 }, { lbRTC_JUNE, 16, 13, 1 }, { lbRTC_AUGUST, 1, 6, 0 }, + { lbRTC_NOVEMBER, 1, 16, 0 }, { lbRTC_FEBRUARY, 1, 2, 2 }, { 0, 0, 0, 0 }, + }; + + TradeDayEntry* temp_v0 = &tradeday_table[arg0 - 1]; + + common_data.time.rtcTime.month = temp_v0->month; + common_data.time.rtcTime.day = temp_v0->day; + common_data.time.rtcTime.hour = temp_v0->hour; + common_data.weather = temp_v0->weather; + } +} + +void trademark_goto_demo_scene(Game_Trademark* this) { + s32 temp_v0; + + mCPk_InitPak(0); + common_data.privateInfo = &common_data.save.saveFilePrivateInfo[0]; + + if (mFRm_CheckSaveData() == 0) { + PrivateInfo* privateInfo; + s32 i; + + bzero(&common_data.save, sizeof(Save)); + mFRm_ClearSaveCheckData(&common_data); + + privateInfo = &common_data.save.saveFilePrivateInfo[0]; + for (i = 0; i < ARRAY_COUNT(common_data.save.saveFilePrivateInfo); i++) { + mPr_ClearPrivateInfo(privateInfo); + privateInfo++; + } + + common_data.save.landInfo.exists = true; + common_data.houseOwnerName = 0xFFFF; + common_data.lastFieldId = 0xFFFF; + } + + mEv_ClearEventInfo(); + temp_v0 = mEv_CheckTitleDemo(); + if (temp_v0 > 0) { + DoorData* doorData = l_demo_door_data_table[temp_v0 - 1]; + + common_data.doorData = *doorData; + common_data.doorData.nextSceneId = doorData->nextSceneId + 1; + + mTM_demotime_set(temp_v0); + mPr_RandomSetPlayerData_title_demo(); + set_npc_4_title_demo(this); + common_data.unk_1014B = 3; + } + + common_data.save.sceneNo = SCENE_TITLE_DEMO; + mTM_set_season(); + common_data.unk_104AD = 1; + + STOP_GAMESTATE(&this->state); + SET_NEXT_GAMESTATE(&this->state, play_init, sizeof(Game_Play)); +} + +void func_80804EE0_jp(Game_Trademark* this, f32 eyeX, f32 eyeY, f32 eyeZ) { + xyz_t eye; + xyz_t at; + xyz_t up; + + eye.x = eyeX; + eye.y = eyeY; + eye.z = eyeZ; + up.z = 0.0f; + up.y = 1.0f; + up.x = 0.0f; + at.z = 0.0f; + at.y = 0.0f; + at.x = 0.0f; + setPerspectiveView(&this->view, 15.0f, 10.0f, 12800.0f); + setLookAtView(&this->view, &eye, &at, &up); + showView(&this->view, 0xF); +} + +void func_80804F78_jp(Game_Trademark* this) { + f32 temp_fv1; + f32 var_fa0; + f32 var_fv0; + s16 temp_a2; + s16 temp_a1; + + temp_a2 = this->unk_25A6A; + this->unk_25A6A += this->unk_25A6C; + temp_a1 = this->unk_25A6A; + + temp_fv1 = sinf_table(BINANG_TO_RAD(temp_a1)) * this->unk_00214; + + if (this->unk_25A6F == 0) { + var_fa0 = temp_fv1 * 3.0f; + var_fv0 = temp_fv1; + } else { + var_fv0 = 1.0f - temp_fv1; + var_fa0 = 1.0f + temp_fv1; + } + + this->unk_00208 = var_fv0; + this->unk_0020C = var_fa0; + this->unk_00210 = var_fv0; + + if ((this->unk_25A6F == 0) && (temp_a1 >= 0x4000)) { + this->unk_25A6F = 1; + } + + if (((temp_a2 < 0) && (temp_a1 >= 0)) || ((temp_a2 < -0x8000) && (temp_a1 >= -0x8000))) { + this->unk_00214 *= 0.3f; + this->unk_25A6C += 0xC00; + } + + if (ABS(this->unk_00214) < 0.02f) { + if (this->curState == TRADEMARK_STATE_1) { + this->curState = TRADEMARK_STATE_2; + } + this->unk_00208 = 1.0f; + this->unk_0020C = 1.0f; + this->unk_00210 = 1.0f; + } +} + +Vtx D_80805CD8_jp[] = { +#include "assets/jp/overlays/gamestates/ovl_trademark/m_trademark/D_80805CD8_jp.vtx.inc.c" +}; +Vtx D_80805ED8_jp[] = { +#include "assets/jp/overlays/gamestates/ovl_trademark/m_trademark/D_80805ED8_jp.vtx.inc.c" +}; +Vtx D_808060D8_jp[] = { +#include "assets/jp/overlays/gamestates/ovl_trademark/m_trademark/D_808060D8_jp.vtx.inc.c" +}; +Vtx D_80806158_jp[] = { +#include "assets/jp/overlays/gamestates/ovl_trademark/m_trademark/D_80806158_jp.vtx.inc.c" +}; +Vtx D_80806338_jp[] = { +#include "assets/jp/overlays/gamestates/ovl_trademark/m_trademark/D_80806338_jp.vtx.inc.c" +}; +Vtx D_80806458_jp[] = { +#include "assets/jp/overlays/gamestates/ovl_trademark/m_trademark/D_80806458_jp.vtx.inc.c" +}; + +u8 D_808065D8_jp[] = { +#include "assets/jp/overlays/gamestates/ovl_trademark/m_trademark/D_808065D8_jp.i8.inc.c" +}; + +Gfx D_808075D8_jp[] = { + gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON), + gsDPPipeSync(), + gsDPSetCombineLERP(PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, 0, 0, 0, 0, 0, 0, 0, COMBINED, 0, 0, 0, COMBINED), + gsDPSetPrimColor(0, 0xFF, 255, 220, 90, 255), + gsDPSetEnvColor(230, 180, 0, 255), + gsDPSetRenderMode(G_RM_FOG_SHADE_A, G_RM_AA_ZB_OPA_SURF2), + gsDPPipeSync(), + gsDPSetTextureLUT(G_TT_NONE), + gsDPLoadTextureBlock(D_808065D8_jp, G_IM_FMT_I, G_IM_SIZ_8b, 64, 64, 0, G_TX_MIRROR | G_TX_CLAMP, + G_TX_MIRROR | G_TX_CLAMP, 6, 6, G_TX_NOLOD, G_TX_NOLOD), + gsSPLoadGeometryMode(G_ZBUFFER | G_SHADE | G_CULL_BACK | G_FOG | G_LIGHTING | G_SHADING_SMOOTH), + gsSPVertex(D_80805CD8_jp, 32, 0), + gsSP2Triangles(0, 1, 2, 0, 1, 3, 2, 0), + gsSP2Triangles(4, 5, 6, 0, 5, 7, 6, 0), + gsSP2Triangles(8, 9, 10, 0, 8, 10, 11, 0), + gsSP2Triangles(12, 13, 14, 0, 12, 14, 15, 0), + gsSP2Triangles(16, 17, 18, 0, 16, 19, 17, 0), + gsSP2Triangles(20, 21, 22, 0, 21, 23, 22, 0), + gsSP2Triangles(24, 25, 26, 0, 24, 27, 25, 0), + gsSP2Triangles(28, 29, 30, 0, 29, 31, 30, 0), + gsDPPipeSync(), + gsDPSetPrimColor(0, 0xFF, 60, 90, 220, 255), + gsDPSetEnvColor(0, 0, 160, 255), + gsDPPipeSync(), + gsDPLoadTextureBlock(D_808065D8_jp, G_IM_FMT_I, G_IM_SIZ_8b, 64, 64, 0, G_TX_MIRROR | G_TX_CLAMP, + G_TX_MIRROR | G_TX_CLAMP, 6, 6, G_TX_NOLOD, G_TX_NOLOD), + gsSPVertex(D_80805ED8_jp, 32, 0), + gsSP2Triangles(0, 1, 2, 0, 3, 4, 5, 0), + gsSP2Triangles(6, 3, 5, 0, 2, 5, 7, 0), + gsSP2Triangles(0, 2, 7, 0, 8, 9, 10, 0), + gsSP2Triangles(8, 10, 11, 0, 12, 13, 14, 0), + gsSP2Triangles(12, 14, 15, 0, 11, 16, 8, 0), + gsSP2Triangles(15, 17, 12, 0, 18, 8, 16, 0), + gsSP2Triangles(19, 12, 17, 0, 16, 20, 21, 0), + gsSP2Triangles(16, 21, 18, 0, 17, 22, 23, 0), + gsSP2Triangles(17, 23, 19, 0, 24, 25, 26, 0), + gsSP2Triangles(25, 27, 26, 0, 28, 29, 27, 0), + gsSP2Triangles(1, 30, 2, 0, 5, 2, 31, 0), + gsSP1Triangle(6, 5, 31, 0), + gsSPVertex(D_808060D8_jp, 8, 0), + gsSP2Triangles(0, 1, 2, 0, 1, 3, 2, 0), + gsSP2Triangles(4, 5, 3, 0, 5, 6, 3, 0), + gsSP1Triangle(0, 7, 1, 0), + gsDPPipeSync(), + gsDPSetPrimColor(0, 0xFF, 30, 210, 90, 255), + gsDPSetEnvColor(0, 160, 0, 255), + gsDPPipeSync(), + gsDPLoadTextureBlock(D_808065D8_jp, G_IM_FMT_I, G_IM_SIZ_8b, 64, 64, 0, G_TX_MIRROR | G_TX_CLAMP, + G_TX_MIRROR | G_TX_CLAMP, 6, 6, G_TX_NOLOD, G_TX_NOLOD), + gsSPVertex(D_80806158_jp, 32, 0), + gsSP2Triangles(0, 1, 2, 0, 0, 2, 3, 0), + gsSP2Triangles(4, 5, 6, 0, 4, 6, 7, 0), + gsSP2Triangles(4, 8, 5, 0, 0, 9, 1, 0), + gsSP2Triangles(10, 1, 9, 0, 11, 5, 8, 0), + gsSP2Triangles(12, 13, 14, 0, 12, 14, 15, 0), + gsSP2Triangles(16, 17, 18, 0, 16, 18, 19, 0), + gsSP2Triangles(11, 8, 20, 0, 11, 20, 21, 0), + gsSP2Triangles(10, 9, 22, 0, 10, 22, 23, 0), + gsSP2Triangles(24, 25, 26, 0, 27, 26, 28, 0), + gsSP1Triangle(29, 27, 28, 0), + gsSPVertex(D_80806338_jp, 18, 0), + gsSP2Triangles(0, 1, 2, 0, 1, 3, 2, 0), + gsSP2Triangles(4, 5, 3, 0, 6, 4, 3, 0), + gsSP2Triangles(7, 8, 1, 0, 0, 7, 1, 0), + gsSP2Triangles(3, 1, 9, 0, 6, 3, 9, 0), + gsSP2Triangles(10, 11, 12, 0, 11, 13, 12, 0), + gsSP2Triangles(14, 15, 13, 0, 15, 16, 13, 0), + gsSP1Triangle(10, 17, 11, 0), + gsDPPipeSync(), + gsDPSetPrimColor(0, 0xFF, 255, 100, 80, 255), + gsDPSetEnvColor(180, 0, 0, 255), + gsDPPipeSync(), + gsDPLoadTextureBlock(D_808065D8_jp, G_IM_FMT_I, G_IM_SIZ_8b, 64, 64, 0, G_TX_MIRROR | G_TX_CLAMP, + G_TX_MIRROR | G_TX_CLAMP, 6, 6, G_TX_NOLOD, G_TX_NOLOD), + gsSPVertex(D_80806458_jp, 24, 0), + gsSP2Triangles(0, 1, 2, 0, 0, 2, 3, 0), + gsSP2Triangles(4, 5, 6, 0, 4, 6, 7, 0), + gsSP2Triangles(8, 9, 10, 0, 8, 10, 11, 0), + gsSP2Triangles(12, 13, 14, 0, 12, 14, 15, 0), + gsSP2Triangles(16, 17, 18, 0, 16, 18, 19, 0), + gsSP2Triangles(20, 21, 22, 0, 20, 22, 23, 0), + gsSPEndDisplayList(), +}; + +u8 D_80807908_jp[] = { +#include "assets/jp/overlays/gamestates/ovl_trademark/m_trademark/D_80807908_jp.i8.inc.c" +}; + +Lights1 D_80808508_jp = { + { { { 0x64, 0x64, 0x64 }, 0, { 0x64, 0x64, 0x64 }, 0 } }, + { + { + { { 0xFF, 0xFF, 0xFF }, 0, { 0xFF, 0xFF, 0xFF }, 0, { 0x45, 0x45, 0x45 }, 0 }, + }, + }, +}; + +void func_80805104_jp(Game_Trademark* this) { + UNUSED s32 pad[2]; + xyz_t lightDir; + xyz_t object; + xyz_t eye; + GraphicsContext* gfxCtx; + f32 y; + f32 xz; + + gfxCtx = this->state.gfxCtx; + OPEN_DISPS(gfxCtx); + + func_80804F78_jp(this); + + lightDir.x = 69.0f; + lightDir.y = 69.0f; + lightDir.z = 69.0f; + + eye.x = -4949.148f; + eye.y = 4002.5417f; + eye.z = 1119.0837f; + + object.x = 0.0f; + object.y = 0.0f; + object.z = 0.0f; + HiliteReflect_init(&object, &eye, &lightDir, gfxCtx); + + gSPSetLights1(POLY_OPA_DISP++, D_80808508_jp); + + func_80804EE0_jp(this, 0.0f, 500.0f, 1000.0f); + _texture_z_light_fog_prim(gfxCtx); + + do { + xz = this->unk_00208 * 0.006f; + y = this->unk_0020C * 0.006f; + Matrix_translate(0.0f, -15.0f, 0.0f, MTXMODE_NEW); + + Matrix_scale(xz, y, xz, MTXMODE_APPLY); + Matrix_RotateY(0x2000, MTXMODE_APPLY); + } while (0); + + gSPMatrix(POLY_OPA_DISP++, _Matrix_to_Mtx_new(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_OPA_DISP++, D_808075D8_jp); + + CLOSE_DISPS(gfxCtx); +} + +void nintendo_logo_move(Game_Trademark* this) { + if (this->curState == TRADEMARK_STATE_2) { + this->alpha += 16; + if (this->alpha >= 255) { + this->alpha = 255; + this->curState = TRADEMARK_STATE_4; + } + } else if (this->curState == TRADEMARK_STATE_4) { + if (DECR(this->unk_25A64) == 0) { + this->curState = TRADEMARK_STATE_3; + } + } +} + +void nintendo_logo_draw(Game_Trademark* this) { + UNUSED s32 pad; + GraphicsContext* gfxCtx = this->state.gfxCtx; + + OPEN_DISPS(gfxCtx); + + nintendo_logo_move(this); + + gDPPipeSync(POLY_OPA_DISP++); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0xFF, 255, 255, 255, this->alpha); + gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, 0); + gDPSetRenderMode(POLY_OPA_DISP++, G_RM_XLU_SURF, G_RM_XLU_SURF2); + gDPSetAlphaCompare(POLY_OPA_DISP++, G_AC_THRESHOLD); + gDPSetTextureFilter(POLY_OPA_DISP++, G_TF_POINT); + gDPSetCycleType(POLY_OPA_DISP++, G_CYC_1CYCLE); + gSPClearGeometryMode(POLY_OPA_DISP++, G_ZBUFFER | G_SHADE | G_CULL_BOTH | G_FOG | G_LIGHTING | G_TEXTURE_GEN | + G_TEXTURE_GEN_LINEAR | G_LOD | G_SHADING_SMOOTH); + gDPSetCombineLERP(POLY_OPA_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, PRIMITIVE, ENVIRONMENT, TEXEL0, + ENVIRONMENT, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, PRIMITIVE, ENVIRONMENT, TEXEL0, + ENVIRONMENT); + gDPSetTexturePersp(POLY_OPA_DISP++, G_TP_NONE); + gDPSetTextureLUT(POLY_OPA_DISP++, G_TT_NONE); + + gDPLoadTextureTile(POLY_OPA_DISP++, D_80807908_jp, G_IM_FMT_I, G_IM_SIZ_8b, 128, 24, 0, 0, 0x7F, 0x18, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, + G_TX_NOLOD); + + POLY_OPA_DISP = gfx_gSPTextureRectangle1(POLY_OPA_DISP, 0x19C, 0x288, 0x398, 0x2E8, 0, 0, 0, 0x400, 0x400); + + CLOSE_DISPS(gfxCtx); +} + +void trademark_cancel(Game_Trademark* this) { + if (!this->unk_25A70 && (this->curState == TRADEMARK_STATE_4)) { + if (common_data.unk_10AB0 != 0) { + if (CHECK_FLAG_ALL(CONTROLLER1(gamePT)->press.button, START_BUTTON)) { + this->unk_25A70 = true; + } + } + } +} + +u8 s_titlebgm[] = { + 0x53, 0x54, 0x55, 0x56, 0x57, +}; + +void trademark_move(Game_Trademark* this) { + if (this->curState == TRADEMARK_STATE_0) { + if (DECR(this->unk_25A68) == 0) { + mBGMPsComp_make_ps_lost_fanfare(s_titlebgm[mTD_get_titledemo_no()], 0x168); + sAdo_SysTrgStart(0x105); + this->fadeColor = 0; + this->curState = TRADEMARK_STATE_1; + } + } + + if (func_80804C40_jp() && ((this->curState == TRADEMARK_STATE_3) || this->unk_25A70)) { + if (this->fadeColor < 255) { + this->fadeColor += 8; + } + + if (this->unk_25A71 != 1) { + if (func_8008F768_jp(&B_80808560_jp, &B_80818560_jp) == 1) { + this->unk_25A71 = 1; + } + } + + if ((this->fadeColor >= 255) && (this->unk_25A71 == 1)) { + this->fadeColor = 255; + this->curState = TRADEMARK_STATE_5; + } + } +} + +void trademark_draw(Game_Trademark* this) { + GraphicsContext* gfxCtx = this->state.gfxCtx; + UNUSED s32 pad; + + OPEN_DISPS(gfxCtx); + + gSPSegment(POLY_OPA_DISP++, 0x00, NULL); + + DisplayList_initialize(gfxCtx, 0, 0, 0, NULL); + + if (this->curState >= TRADEMARK_STATE_1) { + func_80805104_jp(this); + } + + if (this->curState >= TRADEMARK_STATE_2) { + nintendo_logo_draw(this); + } + + { + Gfx* gfx = POLY_XLU_DISP; + + fade_black_draw(&gfx, this->fadeColor); + POLY_XLU_DISP = gfx; + } + + CLOSE_DISPS(gfxCtx); +} + +void trademark_main(Game* thisx) { + Game_Trademark* this = (Game_Trademark*)thisx; + GraphicsContext* gfxCtx; + + fqrand(); + + trademark_cancel(this); + trademark_move(this); + trademark_draw(this); + + gfxCtx = this->state.gfxCtx; + game_debug_draw_last(&this->state, gfxCtx); + game_draw_last(gfxCtx); + + if (this->curState == TRADEMARK_STATE_5) { + this->curState = TRADEMARK_STATE_0; + trademark_goto_demo_scene(this); + } +} + +void trademark_cleanup(UNUSED Game* thisx) { + mHm_hs_c* homes = common_data.save.homes; + s32 i; + + for (i = 0; i != ARRAY_COUNT(common_data.save.homes); i++, homes++) { + homes->unk_024 = i; + mMl_clear_mail_box(homes->mailbox, ARRAY_COUNT(homes->mailbox)); + } +} + +void trademark_init(Game* thisx) { + UNUSED s32 pad; + Game_Trademark* this = (Game_Trademark*)thisx; + GraphicsContext* gfxCtx = this->state.gfxCtx; + + common_data_reinit(); + + this->state.main = trademark_main; + this->state.destroy = trademark_cleanup; + + initView(&this->view, gfxCtx); + new_Matrix(&this->state); + + this->fadeColor = 255; + this->alpha = 0; + this->unk_25A64 = 60; + this->unk_25A68 = 0; + this->unk_0025C = 0; + this->unk_00218 = 0; + this->curState = TRADEMARK_STATE_0; + this->unk_00208 = 0.0f; + this->unk_0020C = 0.0f; + this->unk_00210 = 0.0f; + this->unk_00214 = 0.5f; + this->unk_25A6A = 0; + this->unk_25A6C = 0x13D0; + this->unk_25A6F = 0; + this->unk_25A70 = false; + this->unk_25A71 = 0; + + SetGameFrame(1); + common_data.playerNumber = 0; + common_data.unk_10008 = 0; + common_data.sceneFromTitleDemo = -1; + func_80095414_jp(); + mNpc_ClearInAnimal(); + mNpc_FirstClearGoodbyMail(); + func_800BB0E8_jp(); + func_8008FA50_jp(); + func_8008F210_jp(); + + DmaMgr_RequestSyncDebug(&this->unk_00260, SEGMENT_ROM_START(segment_01136000), SEGMENT_ROM_SIZE(segment_01136000), + "../m_trademark.c", 1081); + func_800924CC_jp(&B_80828560_jp, B_80828620_jp, &B_808286B0_jp); + + mBGMPsComp_scene_mode(0); + mEv_SetTitleDemo(mTD_demono_get()); +} diff --git a/src/overlays/gamestates/ovl_trademark/m_trademark.h b/src/overlays/gamestates/ovl_trademark/m_trademark.h index 5bce862..8d88fcd 100644 --- a/src/overlays/gamestates/ovl_trademark/m_trademark.h +++ b/src/overlays/gamestates/ovl_trademark/m_trademark.h @@ -3,11 +3,30 @@ #include "ultra64.h" #include "game.h" +#include "m_view.h" #include "unk.h" typedef struct Game_Trademark { - /* 0x00 */ Game state; - /* 0xE0 */ UNK_TYPE1 unk_00[0x25A78-0xE0]; + /* 0x00000 */ Game state; + /* 0x000E0 */ View view; + /* 0x00208 */ f32 unk_00208; + /* 0x0020C */ f32 unk_0020C; + /* 0x00210 */ f32 unk_00210; + /* 0x00214 */ f32 unk_00214; + /* 0x00218 */ UNK_TYPE4 unk_00218; // unused + /* 0x0021C */ UNK_TYPE1 unk_0021C[0x40]; // unused + /* 0x0025C */ UNK_TYPE4 unk_0025C; // unused + /* 0x00260 */ UNK_TYPE1 unk_00260[0x25800]; // unused + /* 0x25A60 */ u32 fadeColor; + /* 0x25A64 */ s16 unk_25A64; // timer? + /* 0x25A66 */ s16 alpha; + /* 0x25A68 */ s16 unk_25A68; + /* 0x25A6A */ s16 unk_25A6A; + /* 0x25A6C */ s16 unk_25A6C; + /* 0x25A6E */ u8 curState; + /* 0x25A6F */ u8 unk_25A6F; + /* 0x25A70 */ u8 unk_25A70; + /* 0x25A71 */ u8 unk_25A71; } Game_Trademark; // size = 0x25A78 void trademark_init(Game *thisx); |
