diff options
| author | Maide <34639600+Kelebek1@users.noreply.github.com> | 2023-08-18 04:44:08 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-08-17 20:44:08 -0700 |
| commit | c863d781327c1d371cb81ad31a4fd06b53e1b953 (patch) | |
| tree | 27d282e78cfe134623a000394dace56d03eb261a /src/code | |
| parent | ae5aa8db7c07a162cf140a30e9af772c57e4b16b (diff) | |
m_start_data_init (#61)
* m_start_data_init
* Fix NPC, m,atch last func
* Rebased
* Rebased
* Update struct names
* PR
---------
Co-authored-by: Maide <you@example.com>
Diffstat (limited to 'src/code')
| -rw-r--r-- | src/code/game.c | 122 | ||||
| -rw-r--r-- | src/code/m_actor.c | 2 | ||||
| -rw-r--r-- | src/code/m_start_data_init.c | 458 | ||||
| -rw-r--r-- | src/code/sys_matrix.c | 4 |
4 files changed, 522 insertions, 64 deletions
diff --git a/src/code/game.c b/src/code/game.c index a9a37ed..0f657ac 100644 --- a/src/code/game.c +++ b/src/code/game.c @@ -27,9 +27,9 @@ f32 game_GameFrameF; f32 game_GameFrame_2F; f32 game_GameFrame__1F; -void func_800D2E00_jp(Game* gameState) { +void func_800D2E00_jp(Game* game) { if (zurumode_flag >= 2) { - Debug_mode_input(CONTROLLER2(gameState)); + Debug_mode_input(CONTROLLER2(game)); } if (SREG(0) != 0) { @@ -82,7 +82,7 @@ void func_800D2E58_jp(u16 button, Gfx** gfxP) { *gfxP = gfx; } -void game_debug_draw_last(Game* gameState, GraphicsContext* gfxCtx) { +void game_debug_draw_last(Game* game, GraphicsContext* gfxCtx) { Gfx* gfx; Gfx* gfxHead; @@ -98,7 +98,7 @@ void game_debug_draw_last(Game* gameState, GraphicsContext* gfxCtx) { gSPDisplayList(OVERLAY_DISP++, gfx); } - B_80145040_jp = CONTROLLER1(gameState)->press.button | CONTROLLER1(gameState)->cur.button; + B_80145040_jp = CONTROLLER1(game)->press.button | CONTROLLER1(game)->cur.button; func_800D2E58_jp(B_80145040_jp, &gfx); @@ -119,7 +119,7 @@ void game_debug_draw_last(Game* gameState, GraphicsContext* gfxCtx) { if (SREG(0) != 0) { func_800D8A54_jp(&B_80145020_jp, gfxCtx); - func_800D9018_jp(&B_80145020_jp, gfxCtx, gameState); + func_800D9018_jp(&B_80145020_jp, gfxCtx, game); } } @@ -172,11 +172,11 @@ void game_draw_last(GraphicsContext* gfxCtx) { CLOSE_DISPS(gfxCtx); } -void game_get_controller(Game* gameState) { - if (gameState->unk_74 == 1) { - padmgr_RequestPadData(gameState->input, 1); +void game_get_controller(Game* game) { + if (game->unk_74 == 1) { + padmgr_RequestPadData(game->input, 1); } else { - padmgr_ClearPadData(gameState->input); + padmgr_ClearPadData(game->input); } } @@ -190,8 +190,8 @@ void SetGameFrame(s32 divisor) { } } -void game_main(Game* gameState) { - GraphicsContext* gfxCtx = gameState->gfxCtx; +void game_main(Game* game) { + GraphicsContext* gfxCtx = game->gfxCtx; u8 gameframe = game_GameFrame; if (SREG(30) != gameframe) { @@ -203,37 +203,37 @@ void game_main(Game* gameState) { mTM_time(); gfxCtx->unk_2F0 = 7; - gameState->main(gameState); + game->main(game); gfxCtx->unk_2F0 = 9; - mBGM_main(gameState); + mBGM_main(game); gfxCtx->unk_2F0 = 0xA; - func_800D2E00_jp(gameState); + func_800D2E00_jp(game); - gameState->unk_A0++; + game->unk_A0++; } -void game_init_hyral(Game* gameState, size_t size) { - void* buf = gamealloc_malloc(&gameState->alloc, size); +void game_init_hyral(Game* game, size_t size) { + void* buf = gamealloc_malloc(&game->alloc, size); if (buf != NULL) { - THA_ct(&gameState->heap, buf, size); + THA_ct(&game->heap, buf, size); return; } - THA_ct(&gameState->heap, NULL, 0); + THA_ct(&game->heap, NULL, 0); _dbg_hungup("../game.c", 462); } -void game_resize_hyral(Game* gameState, size_t size) { - GameAlloc* alloc = &gameState->alloc; +void game_resize_hyral(Game* game, size_t size) { + GameAlloc* alloc = &game->alloc; void* gameArena; size_t maxFree; size_t bytesFree; size_t bytesAllocated; - void* heapStart = gameState->heap.start; + void* heapStart = game->heap.start; - THA_dt(&gameState->heap); + THA_dt(&game->heap); gamealloc_free(alloc, heapStart); @@ -246,16 +246,16 @@ void game_resize_hyral(Game* gameState, size_t size) { gameArena = gamealloc_malloc(alloc, size); if (gameArena != NULL) { - THA_ct(&gameState->heap, gameArena, size); + THA_ct(&game->heap, gameArena, size); return; } - THA_ct(&gameState->heap, NULL, 0); + THA_ct(&game->heap, NULL, 0); _dbg_hungup("../game.c", 508); } -void game_ct(Game* gameState, GameStateFunc init, GraphicsContext* gfxCtx) { - gamePT = gameState; +void game_ct(Game* game, GameStateFunc init, GraphicsContext* gfxCtx) { + gamePT = game; gfxCtx->unk_2F2 = 1; gfxCtx->unk_25C = &osViModeNtscLan1; @@ -263,71 +263,71 @@ void game_ct(Game* gameState, GameStateFunc init, GraphicsContext* gfxCtx) { gfxCtx->unk_2FC = 1.0f; gfxCtx->unk_300 = 1.0f; - mCon_ct(gameState); + mCon_ct(game); - gameState->unk_A0 = 0; - gameState->main = NULL; - gameState->destroy = NULL; - gameState->running = true; - gameState->unk_74 = 1; + game->unk_A0 = 0; + game->main = NULL; + game->destroy = NULL; + game->running = true; + game->unk_74 = 1; { s32 requiredScopeTemp UNUSED; - gameState->gfxCtx = gfxCtx; - gameState->init = NULL; - gameState->size = 0; + game->gfxCtx = gfxCtx; + game->init = NULL; + game->size = 0; } - gamealloc_init(&gameState->alloc); + gamealloc_init(&game->alloc); - game_init_hyral(gameState, 0x100000); // 1 MiB + game_init_hyral(game, 0x100000); // 1 MiB SetGameFrame(2); - init(gameState); + init(game); func_8005F020_jp(); func_800D88B0_jp(&B_80145020_jp); - func_800D3E14_jp(gameState->gfxCtx); + func_800D3E14_jp(game->gfxCtx); } -void game_dt(Game* gameState) { - mCon_dt(gameState); - func_800D3E40_jp(gameState->gfxCtx); +void game_dt(Game* game) { + mCon_dt(game); + func_800D3E40_jp(game->gfxCtx); mBGM_cleanup(); - if (gameState->destroy != NULL) { - gameState->destroy(gameState); + if (game->destroy != NULL) { + game->destroy(game); } func_800D88D4_jp(&B_80145020_jp); - THA_dt(&gameState->heap); - gamealloc_cleanup(&gameState->alloc); + THA_dt(&game->heap); + gamealloc_cleanup(&game->alloc); gamePT = NULL; } -GameStateFunc game_get_next_game_init(Game* gameState) { - return gameState->init; +GameStateFunc game_get_next_game_init(Game* game) { + return game->init; } -size_t game_get_next_game_class_size(Game* gameState) { - return gameState->size; +size_t game_get_next_game_class_size(Game* game) { + return game->size; } -s32 game_is_doing(Game* gameState) { - return gameState->running; +s32 game_is_doing(Game* game) { + return game->running; } -s32 game_getFreeBytes(Game* gameState) { - return THA_getFreeBytes(&gameState->heap); +s32 game_getFreeBytes(Game* game) { + return THA_getFreeBytes(&game->heap); } -void game_goto_next_game_play(Game* gameState) { - STOP_GAMESTATE(gameState); - SET_NEXT_GAMESTATE(gameState, play_init, sizeof(Game_Play)); +void game_goto_next_game_play(Game* game) { + STOP_GAMESTATE(game); + SET_NEXT_GAMESTATE(game, play_init, sizeof(Game_Play)); } -void game_goto_next_game_name_famicom_emu(Game* gameState) { - STOP_GAMESTATE(gameState); - SET_NEXT_GAMESTATE(gameState, famicom_emu_init, sizeof(Game_FamicomEmu)); +void game_goto_next_game_name_famicom_emu(Game* game) { + STOP_GAMESTATE(game); + SET_NEXT_GAMESTATE(game, famicom_emu_init, sizeof(Game_FamicomEmu)); } diff --git a/src/code/m_actor.c b/src/code/m_actor.c index 21fc868..809a754 100644 --- a/src/code/m_actor.c +++ b/src/code/m_actor.c @@ -11,7 +11,6 @@ #include "m_lib.h" #include "m_skin_matrix.h" #include "m_player_lib.h" -#include "m_npc.h" #include "m_scene.h" #include "libc/math.h" #include "fault.h" @@ -24,6 +23,7 @@ #include "macros.h" #include "overlays/gamestates/ovl_play/m_play.h" #include "overlays/actors/player_actor/m_player.h" +#include "overlays/actors/ovl_Npc/ac_npc.h" void func_80056380_jp(void* arg0, void* arg1 UNUSED) { Actor* actor = arg0; diff --git a/src/code/m_start_data_init.c b/src/code/m_start_data_init.c new file mode 100644 index 0000000..86ed5b3 --- /dev/null +++ b/src/code/m_start_data_init.c @@ -0,0 +1,458 @@ +#include "m_start_data_init.h" +#include "6792F0.h" +#include "68AB30.h" +#include "69CB30.h" +#include "6A83A0.h" +#include "6B81C0.h" +#include "6B8A70.h" +#include "6BA500.h" +#include "6C0690.h" +#include "6C97F0.h" +#include "6D2720.h" +#include "6D9D80.h" +#include "6DA460.h" +#include "6DB420.h" +#include "6DE300.h" +#include "6E30B0.h" +#include "6E7AD0.h" +#include "6ECD90.h" +#include "6EDD10.h" +#include "6F8A60.h" +#include "global.h" +#include "libc64/qrand.h" +#include "m_all_grow.h" +#include "m_common_data.h" +#include "m_event.h" +#include "m_field_info.h" +#include "m_field_make.h" +#include "m_handbill.h" +#include "m_home.h" +#include "m_house.h" +#include "m_kankyo.h" +#include "m_lib.h" +#include "m_msg_main.h" +#include "m_name_table.h" +#include "m_npc.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.famicom_emu_common_data; + + famicom->unk_00 = 0; + famicom->unk_02 = 0x3E8; + famicom->unk_04 = 0x3E8; + famicom->unk_06 = 0x9C4; + famicom->unk_08 = 0; + famicom->unk_0A = 0; + famicom->unk_0C = 0; + famicom->unk_0E = 0; + famicom->unk_10 = 0x64; + famicom->unk_14 = 0; + famicom->unk_16 = 0; + famicom->unk_18 = 0; + famicom->unk_1A = 0; + famicom->unk_1C = 0; + famicom->unk_1E = 0; + famicom->unk_20 = 0; + famicom->unk_22 = 0; + famicom->unk_24 = 0; +} + +void decide_fruit(u16* fruit) { + u16 n = mAGrw_FRUIT_NUM; + + *fruit = ITM_FOOD_START | (u16)RANDOM_F(n); +} + +void decide_fish_location(u8* fish_location) { + *fish_location = RANDOM_F(3); +} + +void title_game_haniwa_data_init(void) { + s32 i; + u8 haniwa_buf[HANIWA_MESSAGE_LEN]; + s32 j; + Haniwa_c* haniwa; + + func_800C3F70_jp(haniwa_buf, HANIWA_MESSAGE_LEN, 0x55C); + + for (i = 0; i < mHS_HOUSE_NUM; i++) { + haniwa = &common_data.homes[i].haniwa; + + mem_copy(common_data.homes[i].haniwa.message, haniwa_buf, HANIWA_MESSAGE_LEN); + + for (j = 0; j < HANIWA_ITEM_HOLD_NUM; j++) { + haniwa->items[j].item = EMPTY_NO; + } + haniwa->bells = 0; + } +} + +void mSDI_ClearMoneyPlayerHomeStationBlock(void) { + static s32 block_num[2][2] = { + { 2, 1 }, /* Player home */ + { 2, 0 } /* Station */ + }; + + s32 block_z; + s32 block_x; + u16* items; + s32 ut_x; + s32 ut_z; + u16 item; + s32 i; + s32 depositOffset; + + for (i = 0; i < 2; i++) { + block_z = block_num[i][1]; + block_x = block_num[i][0]; + + depositOffset = block_num[i][1] * FG_BLOCK_X_NUM + block_x; + items = common_data.fg[block_z][block_x].items[0]; + + if (items != NULL) { + for (ut_z = 0; ut_z < UT_Z_NUM; ut_z++) { + for (ut_x = 0; ut_x < UT_X_NUM; ut_x++) { + item = *items; + + if (item >= ITM_MONEY_START && item <= ITM_MONEY_END) { + u16* deposit = common_data.deposit[depositOffset]; + + mPB_keep_item(item); + *items = EMPTY_NO; + + if (deposit != NULL) { + func_8008C478_jp(deposit, ut_x, ut_z); + } + } + + items++; + } + } + } + } +} + +void mSDI_PullTreeUT(u16* item_p) { + if ((*item_p >= TREE_SAPLING && *item_p <= TREE_30000BELLS) || + (*item_p >= TREE_100BELLS_SAPLING && *item_p <= TREE_100BELLS)) { + *item_p = EMPTY_NO; + } +} + +void mSDI_PullTreeBlock(u16* items_p, s32 ut) { + s32 i; + + for (i = ut; i < UT_TOTAL_NUM; i += UT_X_NUM) { + mSDI_PullTreeUT(&items_p[i]); + } +} + +void mSDI_PullTree(void) { + mFM_fg_c* fg_block; + s32 block_z; + + for (block_z = 0; block_z < FG_BLOCK_Z_NUM; block_z++) { + /* Clear trees against the cliffs on the left and right town cliff borders */ + fg_block = &common_data.fg[block_z][0]; + mSDI_PullTreeBlock(fg_block->items[0], 0); + mSDI_PullTreeBlock((fg_block + FG_BLOCK_X_NUM - 1)->items[0], UT_X_NUM - 1); + } + + if (fg_block) {} +} + +void mSDI_PullTreeUnderPlayerBlock(void) { + /** + * Cleared tree diagram + * + * -------xx------- + * -------xx------- + * ---------------- + * ... + **/ + + u16* items = &common_data.fg[2][2].items[0][0]; + + mSDI_PullTreeUT(&items[7]); + mSDI_PullTreeUT(&items[8]); + mSDI_PullTreeUT(&items[16 + 7]); + mSDI_PullTreeUT(&items[16 + 8]); +} + +s32 mSDI_StartInitNew(Game* game2, s32 player_no, s32 malloc_flag) { + Game_Play* game_play = (Game_Play*)game2; + Private_c* priv; + Private_c* priv_p; + Game* game = NULL; + s32 i; + UNUSED s32 pad[2]; + + common_data.scene_from_title_demo = SCENE_START_DEMO; + lbRTC_GetTime(&common_data.time.rtc_time); + + priv = &common_data.private[player_no]; + common_data.now_private = priv; + common_data.player_no = player_no; + + common_data.now_private->gender = mPr_SEX_MALE; + + decide_fruit(&common_data.fruit); + if (malloc_flag == 0) { + game = game2; + } + + bzero(&common_data.deposit, sizeof(common_data.deposit)); + + mFM_InitFgCombiSaveData(game); + mSDI_PullTree(); + mSDI_PullTreeUnderPlayerBlock(); + mFM_SetBlockKindLoadCombi(game); + mAGrw_ChangeTree2FruitTree(); + + priv_p = &common_data.private[0]; + + mMld_SetDefaultMelody(); + mLd_LandDataInit(); + mEv_ClearEventSaveInfo(&common_data.event_save_data); + mEv_init(&game_play->event); + mNpc_InitNpcAllInfo(malloc_flag); + + for (i = 0; i < PLAYER_NUM; i++) { + mPr_ClearPrivateInfo(priv_p); + priv_p++; + } + + priv_p += player_no; + priv_p -= PLAYER_NUM; + mPr_InitPrivateInfo(priv_p); + mNpc_SetRemoveAnimalNo(common_data.animals); + title_game_haniwa_data_init(); + mPB_police_box_init(game); + mSN_snowman_init(); + mHS_house_init(); + + lbRTC_TimeCopy(&common_data.unk_0F7FC, &mTM_rtcTime_clear_code); + lbRTC_TimeCopy(&common_data.unk_0F89C, &mTM_rtcTime_clear_code); + lbRTC_TimeCopy(&common_data.unk_0F8A4, &mTM_rtcTime_clear_code); + + for (i = 0; i < PLAYER_NUM; i++) { + common_data.homes[i].unk_022 &= (u16)~0xC0; + common_data.homes[i].unk_022 &= 0xCF; + common_data.homes[i].unk_022 &= 0xF7; + common_data.homes[i].unk_024 = i; + } + + common_data.station_type = RANDOM_F(15); + + for (i = 0; i < PLAYER_NUM; i++) { + mPr_ClearMotherMailInfo(&common_data.mother_mail[i]); + } + + mPr_SetPossessionItem(common_data.now_private, 0, ITM_MONEY_1000, mPr_ITEM_COND_QUEST); + mNW_InitMyOriginal(); + mEv_2nd_init(&game_play->event); + famicom_emu_initial_common_data(); + return TRUE; +} + +s32 mSDI_StartInitFrom(Game* game2, s32 player_no, s32 malloc_flag) { + Game_Play* game_play = (Game_Play*)game2; + Private_c* priv; + Game* game = game2; + s32 res = FALSE; + + if (malloc_flag != 0) { + game = NULL; + } + + common_data.scene_from_title_demo = SCENE_FG; + lbRTC_GetTime(&common_data.time.rtc_time); + + if (mFRm_CheckSaveData() == TRUE) { + priv = &common_data.private[player_no]; + if (mPr_CheckPrivate(priv) == TRUE) { + if (priv->exists == TRUE) { + common_data.now_private = priv; + common_data.player_no = player_no; + mFM_SetBlockKindLoadCombi(game); + mEv_init_force(&game_play->event); + mHsRm_GetHuusuiRoom(game, player_no); + mSP_ExchangeLineUp_InGame(game); + mNpc_SetRemoveAnimalNo(common_data.animals); + mCkRh_DecideNowGokiFamilyCount(player_no); + mMkRm_MarkRoom(game); + res = TRUE; + } else { + common_data.player_decoy_flag = TRUE; + priv->exists = TRUE; + common_data.now_private = priv; + common_data.player_no = player_no; + mFM_SetBlockKindLoadCombi(game); + mHsRm_GetHuusuiRoom(game, player_no); + mSP_ExchangeLineUp_InGame(game); + mNpc_SetRemoveAnimalNo(common_data.animals); + + bzero(priv->inventory.pockets, sizeof(priv->inventory.pockets)); + priv->inventory.lotto_ticket_expiry_month = 0; + priv->inventory.lotto_ticket_mail_storage = 0; + priv->inventory.item_conditions = 0; + priv->inventory.wallet = 0; + mQst_ClearDelivery(priv->deliveries, mPr_DELIVERY_QUEST_NUM); + mQst_ClearErrand(priv->errands, mPr_ERRAND_QUEST_NUM); + mCkRh_DecideNowGokiFamilyCount(player_no); + mMkRm_MarkRoom(game); + res = TRUE; + } + } + } + return res; +} + +s32 mSDI_StartInitNewPlayer(Game* game, s32 player_no, s32 malloc_flag) { + Game_Play* game_play = (Game_Play*)game; + Private_c* priv; + s32 res = FALSE; + UNUSED s32 pad; + + common_data.scene_from_title_demo = SCENE_START_DEMO2; + lbRTC_GetTime(&common_data.time.rtc_time); + + priv = &common_data.private[player_no]; + if (mFRm_CheckSaveData() == TRUE) { + if (mPr_CheckPrivate(priv) != TRUE) { + mPr_InitPrivateInfo(priv); + common_data.now_private = priv; + mPr_SetPossessionItem(common_data.now_private, 0, ITM_MONEY_1000, mPr_ITEM_COND_QUEST); + common_data.player_no = player_no; + common_data.now_private->gender = mPr_SEX_MALE; + if (malloc_flag == 0) { + mFM_SetBlockKindLoadCombi(game); + mEv_init_force(&game_play->event); + mSP_ExchangeLineUp_InGame(game); + } else { + mFM_SetBlockKindLoadCombi(NULL); + mEv_init_force(&game_play->event); + mSP_ExchangeLineUp_InGame(NULL); + } + mNpc_SetRemoveAnimalNo(common_data.animals); + mSDI_ClearMoneyPlayerHomeStationBlock(); + res = TRUE; + } + } + return res; +} + +s32 mSDI_StartInitPak(Game* game2, s32 player_no, s32 malloc_flag) { + Game* game = game2; + Game_Play* game_play = (Game_Play*)game; + UNUSED s32 pad; + s32 res = FALSE; + s32 sp1C; + + if (malloc_flag == 1) { + game = NULL; + } + + if (player_no < 5) { + common_data.scene_from_title_demo = SCENE_FG; + } + + if (mFRm_CheckSaveData() == TRUE) { + sp1C = mCPk_get_pkinfo(); + if ((func_80078E90_jp(sp1C, 0) == TRUE) && (func_800B8D64_jp(player_no, sp1C) == TRUE)) { + mFM_SetBlockKindLoadCombi(game); + mEv_init_force(&game_play->event); + mHsRm_GetHuusuiRoom(game, player_no); + mSP_ExchangeLineUp_InGame(game); + mNpc_SetRemoveAnimalNo(common_data.animals); + mNpc_SetReturnAnimal(mNpc_GetInAnimalP()); + mNpc_SendRegisteredGoodbyMail(); + mCkRh_DecideNowGokiFamilyCount(player_no); + mMkRm_MarkRoom(game); + mEv_SetGateway(); + res = TRUE; + } + } + return res; +} + +s32 mSDI_StartInitErr(UNUSED Game* game, UNUSED s32 player_no, UNUSED s32 malloc_flag) { + return TRUE; +} + +void mSDI_StartInitAfter(Game* game, s32 renewal_reserve_flag, s32 malloc_flag) { + Game_Play* game_play = (Game_Play*)game; + + common_data.house_owner_name = -1; + common_data.last_field_id = -1; + + mHm_SetNowHome(); + mNpc_RenewalAnimalMemory(); + mTM_renewal_renew_time(); + mEv_ClearEventInfo(); + mEnv_DecideWeather_NormalGameStart(); + func_800B7680_jp(game_play); + mTM_set_season(); + func_80084DA4_jp(); + mEv_2nd_init(&game_play->event); + func_800AD9FC_jp(); + func_80096B64_jp(); + func_800AB054_jp(); + func_800AB09C_jp(); + mNpc_SetNpcList(common_data.npclist, common_data.animals, ANIMAL_NUM_MAX, malloc_flag); + mNpc_ClearTalkInfo(); + if (renewal_reserve_flag == 1) { + mFM_RenewalReserve(); + } + mQst_ClearNotSaveQuest(&common_data.quest); + mNPS_set_all_schedule_area(); + mNpcW_InitNpcWalk(&common_data.npc_walk); + mHm_CheckRehouseOrder(); + decide_fish_location(&common_data.fish_location); + mTRC_init(game_play); + common_data.goki_shocked_flag = FALSE; + func_800A6548_jp(); + func_800B9B2C_jp(); + func_800A91DC_jp(); + mPr_SendForeingerAnimalMail(common_data.now_private); + mPr_StartSetCompleteTalkInfo(); + mMsm_SendInformationMail(); + func_8008DCF8_jp(); + func_800A4D10_jp(); + mSN_decide_msg(); + mPr_RenewalMapInfo(common_data.now_private->maps, mPr_FOREIGN_MAP_COUNT, &common_data.land_info); +} + +typedef s32 (*mSDI_INIT_PROC)(Game*, s32, s32); + +s32 mSDI_StartInitBefore(Game* game, s32 player_no, s32 init_mode, s32 malloc_flag) { + static mSDI_INIT_PROC init_proc[mSDI_INIT_MODE_NUM] = { + mSDI_StartInitNew, mSDI_StartInitNewPlayer, mSDI_StartInitFrom, mSDI_StartInitPak, mSDI_StartInitErr, + }; + + mEv_UnSetGateway(); + return init_proc[init_mode](game, player_no, malloc_flag); +} + +s32 mSDI_StartDataInit(Game* game, s32 player_no, s32 init_mode) { + static int renew_reserve_mode_table[mSDI_INIT_MODE_NUM] = { + TRUE, FALSE, FALSE, FALSE, FALSE, + }; + s32 res; + + if ((init_mode < mSDI_INIT_MODE_NEW) || (init_mode >= mSDI_INIT_MODE_NUM)) { + init_mode = mSDI_INIT_MODE_NEW; + } + + res = mSDI_StartInitBefore(game, player_no, init_mode, mSDI_MALLOC_FLAG_ZELDA); + if (res == TRUE) { + mSDI_StartInitAfter(game, renew_reserve_mode_table[init_mode], mSDI_MALLOC_FLAG_ZELDA); + } + + return res; +} diff --git a/src/code/sys_matrix.c b/src/code/sys_matrix.c index 1661c13..ab7d1cf 100644 --- a/src/code/sys_matrix.c +++ b/src/code/sys_matrix.c @@ -75,8 +75,8 @@ MtxF* Matrix_now; // Top of the stack. /** * Create the matrix stack and set the pointer to the top of it. */ -void new_Matrix(Game* gameState) { - Matrix_now = THA_alloc16(&gameState->heap, MATRIX_STACK_SIZE * sizeof(MtxF)); +void new_Matrix(Game* game) { + Matrix_now = THA_alloc16(&game->heap, MATRIX_STACK_SIZE * sizeof(MtxF)); Matrix_stack = Matrix_now; } |
