From 54c8c9c4e99fa643950cecf35150c5245f2c9165 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Fri, 22 Sep 2023 02:11:26 -0700 Subject: [PATCH] d_point_wind match, d_path start --- configure.py | 2 +- include/d/actor/d_a_player_link.h | 5 -- include/d/d_kankyo.h | 2 +- include/d/d_kankyo_wether.h | 1 + include/d/d_path.h | 2 +- include/d/d_point_wind.h | 17 +++++++ include/d/d_stage.h | 5 +- src/d/d_path.cpp | 54 +++++++++++++++++--- src/d/d_point_wind.cpp | 49 +++++++++++++++--- src/d/d_stage.cpp | 83 ++++++++++++++++++++++++------- 10 files changed, 179 insertions(+), 41 deletions(-) create mode 100644 include/d/d_point_wind.h diff --git a/configure.py b/configure.py index 98dd063d0..8ee0a6702 100644 --- a/configure.py +++ b/configure.py @@ -404,7 +404,7 @@ config.libs = [ Object(NonMatching, "d/d_a_npc_mk_static.cpp"), Object(NonMatching, "d/d_salvage.cpp"), Object(NonMatching, "d/d_snap.cpp"), - Object(NonMatching, "d/d_point_wind.cpp"), + Object(Matching, "d/d_point_wind.cpp"), Object(NonMatching, "d/actor/d_a_agb.cpp"), Object(NonMatching, "d/actor/d_a_arrow.cpp"), Object(NonMatching, "d/actor/d_a_bg.cpp"), diff --git a/include/d/actor/d_a_player_link.h b/include/d/actor/d_a_player_link.h index 05fa50c6f..1be6bde25 100644 --- a/include/d/actor/d_a_player_link.h +++ b/include/d/actor/d_a_player_link.h @@ -97,11 +97,6 @@ public: /* 0x0 */ u8 field_0x0[0x28]; }; -class dPa_smokeEcallBack { -public: - /* 0x0 */ u8 field_0x0[0x20]; -}; - class dPa_cutTurnEcallBack_c { public: /* 0x0 */ u8 field_0x0[0x10]; diff --git a/include/d/d_kankyo.h b/include/d/d_kankyo.h index c97a8b4c2..575c20ece 100644 --- a/include/d/d_kankyo.h +++ b/include/d/d_kankyo.h @@ -35,7 +35,7 @@ struct WIND_INFLUENCE { /* 0x18 */ f32 mRadius; /* 0x1C */ f32 mStrength; /* 0x20 */ f32 field_0x20; - /* 0x24 */ int field_0x24; + /* 0x24 */ f32 field_0x24; /* 0x28 */ u8 mbConstant; }; diff --git a/include/d/d_kankyo_wether.h b/include/d/d_kankyo_wether.h index 6fd6189b8..4aab0ff48 100644 --- a/include/d/d_kankyo_wether.h +++ b/include/d/d_kankyo_wether.h @@ -337,5 +337,6 @@ f32* dKyw_get_wind_power(); void squal_proc(); void dKyw_pntwind_set(WIND_INFLUENCE*); void dKyw_pntwind_cut(WIND_INFLUENCE*); +void dKyw_pwind_cylinder_set(WIND_INFLUENCE*); #endif /* D_KANKYO_WETHER_H */ \ No newline at end of file diff --git a/include/d/d_path.h b/include/d/d_path.h index 459609fd6..3902fea8b 100644 --- a/include/d/d_path.h +++ b/include/d/d_path.h @@ -13,7 +13,7 @@ struct dPath__Point { }; struct dPath { - /* 0x00 */ u16 mNum; + /* 0x00 */ u16 m_num; /* 0x02 */ u16 mNextPathId; /* 0x04 */ u8 mArg0; /* 0x05 */ u8 mLoops; diff --git a/include/d/d_point_wind.h b/include/d/d_point_wind.h new file mode 100644 index 000000000..310887cbe --- /dev/null +++ b/include/d/d_point_wind.h @@ -0,0 +1,17 @@ +#ifndef D_POINT_WIND_H +#define D_POINT_WIND_H + +#include "SSystem/SComponent/c_m3d_g_cps.h" +#include "d/d_kankyo.h" + +class dPointWind_c { +public: + cM3dGCpsS * mpCps; + WIND_INFLUENCE mWind; + + void set_pwind_init(cM3dGCpsS * pCps); + void set_pwind_move(); + void set_pwind_delete(); +}; + +#endif /* D_POINT_WIND_H */ \ No newline at end of file diff --git a/include/d/d_stage.h b/include/d/d_stage.h index 341661a52..322e03da0 100644 --- a/include/d/d_stage.h +++ b/include/d/d_stage.h @@ -770,9 +770,8 @@ public: }; class dBgW_base; -class dStage_roomStatus_c { +class dStage_roomStatus_c : public dStage_roomDt_c { public: - /* 0x000 */ dStage_roomDt_c mRoomDt; /* 0x054 */ dKy_tevstr_c mTevStr; /* 0x104 */ u8 mFlags; /* 0x105 */ bool mDraw; @@ -800,7 +799,7 @@ public: void zoneCountCheck(int) const; void checkDrawArea() const; dStage_darkStatus_c* getDarkStatus(); - void getDarkMode(); + u32 getDarkMode(); void getBgW(int); static JKRExpHeap* createMemoryBlock(int, u32); diff --git a/src/d/d_path.cpp b/src/d/d_path.cpp index 8e46db926..59c429b0d 100644 --- a/src/d/d_path.cpp +++ b/src/d/d_path.cpp @@ -4,21 +4,61 @@ // #include "d/d_path.h" -#include "dolphin/types.h" +#include "d/d_com_inf_game.h" +#include "JSystem/JUtility/JUTAssert.h" /* 80080018-8008010C .text dPath_GetPnt__FP5dPathi */ -dPath__Point* dPath_GetPnt(dPath*, int) { - /* Nonmatching */ +dPath__Point* dPath_GetPnt(dPath* path, int pnt_index) { + JUT_ASSERT(14, path != 0); + JUT_ASSERT(15, 0 <= pnt_index && pnt_index < path->m_num); + + if (path == NULL || path->mpPnt == NULL || 0 > pnt_index || pnt_index >= path->m_num) + return NULL; + else + return &path->mpPnt[pnt_index]; } /* 8008010C-80080218 .text dPath_GetRoomPath__Fii */ -dPath* dPath_GetRoomPath(int, int) { - /* Nonmatching */ +dPath* dPath_GetRoomPath(int path_index, int room_no) { + dStage_dPath_c * pd; + if (room_no == -1) { + pd = dComIfGp_getStage().getPath2Inf(); + } else { + JUT_ASSERT(0x3d, 0 <= room_no && room_no < 64); + dStage_roomStatus_c * pRoom = dComIfGp_roomControl_getStatusRoomDt(room_no); + if (pRoom == NULL) + return NULL; + pd = pRoom->getPath2Inf(); + } + + if (pd == NULL || 0 > path_index || path_index >= pd->num) + return NULL; + else + return &pd->m_path[path_index]; } /* 80080218-80080340 .text dPath_GetNextRoomPath__FP5dPathi */ -void dPath_GetNextRoomPath(dPath*, int) { - /* Nonmatching */ +dPath* dPath_GetNextRoomPath(dPath* path, int room_no) { + dStage_dPath_c * pd; + if (room_no == -1) { + pd = dComIfGp_getStage().getPath2Inf(); + } else { + dStage_roomStatus_c * pRoom = dComIfGp_roomControl_getStatusRoomDt(room_no); + if (pRoom == NULL) + return NULL; + pd = pRoom->getPath2Inf(); + } + + s32 next_id = path->mNextPathId; + if (pd == NULL || (next_id & 0xFFFF) == 0xFFFF) { + return NULL; + } else { + JUT_ASSERT(0x72, 0 <= next_id && next_id < pd->num); + if (0 > next_id || next_id >= pd->num) + return NULL; + else + return &pd->m_path[next_id]; + } } /* 80080340-800804A4 .text dPath_GetPolyRoomPathVec__FR13cBgS_PolyInfoP4cXyzPi */ diff --git a/src/d/d_point_wind.cpp b/src/d/d_point_wind.cpp index 3882720dd..b9f930356 100644 --- a/src/d/d_point_wind.cpp +++ b/src/d/d_point_wind.cpp @@ -3,21 +3,58 @@ // Translation Unit: d_point_wind.cpp // -#include "d_point_wind.h" -#include "dolphin/types.h" +#include "d/d_point_wind.h" +#include "d/d_com_inf_game.h" +#include "d/d_kankyo_rain.h" +#include "d/d_kankyo_wether.h" +#include "SSystem/SComponent/c_lib.h" /* 800CF31C-800CF398 .text set_pwind_init__12dPointWind_cFP9cM3dGCpsS */ -void dPointWind_c::set_pwind_init(cM3dGCpsS*) { - /* Nonmatching */ +void dPointWind_c::set_pwind_init(cM3dGCpsS* pCps) { + mpCps = pCps; + mWind.mPos = mpCps->mStart; + mWind.mDir = mpCps->mEnd; + mWind.mRadius = mpCps->mRadius; + mWind.field_0x20 = 0.0f; + mWind.mStrength = 1.0f; + dKyw_pwind_cylinder_set(&mWind); } /* 800CF398-800CF5C8 .text set_pwind_move__12dPointWind_cFv */ void dPointWind_c::set_pwind_move() { - /* Nonmatching */ + f32 radScale = 1.8f; + BOOL animate = TRUE; + + cXyz p0 = mpCps->mStart; + cXyz p1 = mpCps->mEnd; + cXyz dir; + dKyr_get_vectle_calc(&p0, &p1, &dir); + + if (strcmp(dComIfGp_getStartStageName(), "sea") == 0 && dComIfGp_roomControl_getStayNo() == 4) { + radScale = 11.0f; + animate = false; + mWind.mPos = p0 + (dir * -100.0f); + } + + mWind.mDir = dir; + mWind.mRadius = mpCps->mRadius * radScale; + mWind.field_0x20 = 0.0f; + + if (animate) { + cLib_addCalc(&mWind.mPos.x, mpCps->mEnd.x, 0.1f, mWind.mRadius, mWind.mRadius * 0.5f); + cLib_addCalc(&mWind.mPos.y, mpCps->mEnd.y, 0.1f, mWind.mRadius, mWind.mRadius * 0.5f); + cLib_addCalc(&mWind.mPos.z, mpCps->mEnd.z, 0.1f, mWind.mRadius, mWind.mRadius * 0.5f); + + if (mWind.mPos.abs(p1) < mWind.mRadius) { + mWind.mPos.x = mpCps->mStart.x; + mWind.mPos.y = mpCps->mStart.y; + mWind.mPos.z = mpCps->mStart.z; + } + } } /* 800CF5C8-800CF5EC .text set_pwind_delete__12dPointWind_cFv */ void dPointWind_c::set_pwind_delete() { - /* Nonmatching */ + dKyw_pntwind_cut(&mWind); } diff --git a/src/d/d_stage.cpp b/src/d/d_stage.cpp index d8adae160..3c9d97e15 100644 --- a/src/d/d_stage.cpp +++ b/src/d/d_stage.cpp @@ -35,14 +35,25 @@ void dStage_SetErrorRoom() {} /* 8004093C-80040940 .text dStage_SetErrorStage__Fv */ void dStage_SetErrorStage() {} +class dStage_KeepTresureInfo { + u8 unk[0x404]; +}; + +class dStage_KeepDoorInfo { + u8 unk[0x904]; +}; + +dStage_KeepTresureInfo TresureInfo; +dStage_KeepDoorInfo DoorInfo; + /* 80040940-8004094C .text dStage_GetKeepTresureInfo__Fv */ -void dStage_GetKeepTresureInfo() { - /* Nonmatching */ +dStage_KeepTresureInfo * dStage_GetKeepTresureInfo() { + return &TresureInfo; } /* 8004094C-80040958 .text dStage_GetKeepDoorInfo__Fv */ -void dStage_GetKeepDoorInfo() { - /* Nonmatching */ +dStage_KeepDoorInfo * dStage_GetKeepDoorInfo() { + return &DoorInfo; } /* 80040958-80040A78 .text dStage_KeepTresureInfoProc__FP11dStage_dt_cP19stage_tresure_class @@ -86,7 +97,7 @@ void dStage_roomControl_c::init() { dStage_roomStatus_c* status = mStatus; for (int i = 0; i < 64; i++) { - status->mRoomDt.init(); + status->init(); setStatusFlag(i, 0); status->mDraw = false; @@ -202,17 +213,25 @@ void dStage_roomControl_c::checkDrawArea() const { /* 800412EC-80041330 .text getDarkStatus__20dStage_roomControl_cFv */ // NONMATCHING dStage_darkStatus_c* dStage_roomControl_c::getDarkStatus() { - dStage_FileList_dt_c* plist_p = mStatus[mStayNo].mRoomDt.mpFileList; - if (plist_p == NULL) { - return NULL; - } + dStage_roomStatus_c * pRoomStatus = &mStatus[mStayNo]; + dStage_FileList_dt_c* plist_p = pRoomStatus->mpFileList; + if (plist_p == NULL) + return NULL; + + // pointer math here seems wrong... return &mDarkStatus[plist_p->mParam & 0x78]; } /* 80041330-80041370 .text getDarkMode__20dStage_roomControl_cFv */ -void dStage_roomControl_c::getDarkMode() { - /* Nonmatching */ +u32 dStage_roomControl_c::getDarkMode() { + dStage_roomStatus_c * pRoomStatus = &mStatus[mStayNo]; + dStage_FileList_dt_c* plist_p = pRoomStatus->mpFileList; + + u8 mode = 0; + if (plist_p != NULL && (plist_p->mParam & 1) != 0) + mode = 1; + return mode; } /* 80041370-800413D4 .text createMemoryBlock__20dStage_roomControl_cFiUl */ @@ -1201,8 +1220,25 @@ void dStage_playerInitIkada(fopAcM_prm_class*, void*) { } /* 800419D0-80041AEC .text dStage_chkPlayerId__Fii */ -void dStage_chkPlayerId(int, int) { - /* Nonmatching */ +u32 dStage_chkPlayerId(int playerId, int room_no) { + stage_actor_class * player; + + if (room_no == -1) { + player = dComIfGp_getStage().getPlayer(); + } else { + JUT_ASSERT(0x689, 0 <= room_no && room_no < 64); + player = dComIfGp_roomControl_getStatusRoomDt(room_no)->getPlayer(); + } + + if (player == NULL) + return FALSE; + + stage_actor_data_class * actor = player->m_entries; + for (int i = 0; i < player->num; i++, actor++) + if ((u8)actor->mAngle.z == playerId) + return TRUE; + + return FALSE; } /* 80041AF4-80041E84 .text dStage_playerInit__FP11dStage_dt_cPviPv */ @@ -1509,8 +1545,20 @@ int dStage_tgscInfoInit(dStage_dt_c* i_stage, void* i_data, int i_num, void*) { } /* 8004259C-80042628 .text dStage_roomReadInit__FP11dStage_dt_cPviPv */ -int dStage_roomReadInit(dStage_dt_c* i_stage, void* i_data, int i_num, void*) { - /* Nonmatching */ +int dStage_roomReadInit(dStage_dt_c* i_stage, void* i_data, int i_num, void* i_file) { + // logic is bad + dStage_nodeHeader* room_info = (dStage_nodeHeader*)(i_data); + roomRead_class* pRoom = (roomRead_class*)room_info->m_offset; + i_stage->setRoom(pRoom); + + roomRead_data_class ** ppEntry = pRoom->m_entries; + for (s32 i = 0; i < room_info->m_entryNum; i++, ppEntry++) { + (u8*)(*ppEntry) = (u8*)(i_file) + (u32)ppEntry; + roomRead_data_class * pEntry = *ppEntry; + pEntry->field_0x4 = (u8*)(i_file) + ((u32)pEntry->field_0x4); + } + + return 1; } /* 80042628-80042658 .text dStage_roomRead_dt_c_GetReverbStage__FR14roomRead_classi */ @@ -1552,7 +1600,8 @@ int dStage_soundInfoInit(dStage_dt_c* i_stage, void* i_data, int i_num, void*) { /* 80042814-80042848 .text dStage_eventInfoInit__FP11dStage_dt_cPviPv */ int dStage_eventInfoInit(dStage_dt_c* i_stage, void* i_data, int i_num, void*) { - /* Nonmatching */ + i_stage->setEventInfo((dStage_EventInfo_c*)((char*)i_data + 4)); + return 1; } /* 80042848-8004287C .text dStage_floorInfoInit__FP11dStage_dt_cPviPv */ @@ -2075,7 +2124,7 @@ int dStage_changeScene(int i_exitId, f32 speed, u32 mode, s8 room_no) { scls = dComIfGp_getStageSclsInfo(); } else { JUT_ASSERT(4192, 0 <= room_no && room_no < 64); - scls = dComIfGp_roomControl_getStatusRoomDt(room_no)->mRoomDt.getSclsInfo(); + scls = dComIfGp_roomControl_getStatusRoomDt(room_no)->getSclsInfo(); } if (scls == NULL) {