From 4c4370b03caf504926a444e4fc68f3a8ba07bba8 Mon Sep 17 00:00:00 2001 From: Carco_21 <144170194+carter-ktb21@users.noreply.github.com> Date: Sat, 31 May 2025 05:12:03 -0400 Subject: [PATCH] d_a_obj_sw work (#2465) * Initial work * Work on ori2 and others * Work on npc_ks_home * Work on npc_ks_demo_022 * Chugging through * Started on demo_camera * More demo_camera work * 51% equivalent * General cleanup * Fixed compile error in d_a_e_mk * Small d_a_e_mk fix * d_a_e_fs fix * PR cleanup * Started work on d_a_obj_sw * d_a_obj_sw work * Small fixes --- include/d/actor/d_a_obj_sw.h | 53 +- src/d/actor/d_a_obj_sw.cpp | 1078 +++++++++++++++++----------------- 2 files changed, 579 insertions(+), 552 deletions(-) diff --git a/include/d/actor/d_a_obj_sw.h b/include/d/actor/d_a_obj_sw.h index 77108c57b3c..42da7664633 100644 --- a/include/d/actor/d_a_obj_sw.h +++ b/include/d/actor/d_a_obj_sw.h @@ -14,17 +14,15 @@ struct obj_sc_s { public: - /* 80CF2F3C */ ~obj_sc_s(); - /* 80CF2FA8 */ obj_sc_s(); + /* 80CF2F3C */ ~obj_sc_s() {}; + /* 80CF2FA8 */ obj_sc_s() {}; /* 0x00 */ s8 field_0x0; /* 0x01 */ u8 field_0x1[0x4 - 0x1]; /* 0x04 */ cXyz field_0x4; /* 0x10 */ cXyz field_0x10; /* 0x1C */ cXyz field_0x1c; - /* 0x28 */ s16 field_0x28; - /* 0x2A */ s16 field_0x2a; - /* 0x2C */ s16 field_0x2c; + /* 0x28 */ csXyz field_0x28; /* 0x2E */ u8 field_0x2e[0x30 - 0x2e]; /* 0x30 */ f32 field_0x30; /* 0x34 */ s8 field_0x34; @@ -34,36 +32,49 @@ public: /* 0x3C */ int field_0x3c; /* 0x40 */ mDoExt_McaMorf* mpModelMorf; /* 0x44 */ Z2SoundObjSimple mSound; - /* 0x64 */ J3DModel* mpModel; - /* 0x68 */ s16 field_0x68; - // + 2 bytes of padding }; +STATIC_ASSERT(sizeof(obj_sc_s) == 0x64); + class obj_sw_class { public: /* 0x000 */ fopAc_ac_c actor; - /* 0x568 */ u8 field_0x568[0x570 - 0x568]; + /* 0x568 */ request_of_phase_process_class mPhase; /* 0x570 */ u8 field_0x570; - /* 0x571 */ u8 field_0x571[0x576 - 0x571]; + /* 0x571 */ u8 field_0x571; + /* 0x572 */ u8 field_0x572[0x574 - 0x572]; + /* 0x574 */ s16 field_0x574; /* 0x576 */ s16 field_0x576; /* 0x578 */ u8 field_0x578[0x57a - 0x578]; - /* 0x57A */ s16 field_0x57a; - /* 0x57C */ s16 field_0x57c; - /* 0x57E */ s16 field_0x57e; + /* 0x57A */ s16 field_0x57a[3]; /* 0x580 */ s16 field_0x580; /* 0x582 */ s16 field_0x582; - /* 0x584 */ u8 field_0x584[0x5a8 - 0x584]; - /* 0x5A8 */ obj_sc_s field_0x5a8; - /* 0x614 */ cXyz field_0x614; - /* 0x620 */ u8 field_0x620[0x864 - 0x620]; - /* 0x864 */ obj_sc_s field_0x864; - /* 0x8D0 */ u8 field_0x8d0[0x8fc - 0x8d0]; + /* 0x584 */ f32 field_0x584; + /* 0x588 */ f32 field_0x588; + /* 0x58C */ f32 field_0x58c; + /* 0x590 */ f32 field_0x590; + /* 0x594 */ s16 field_0x594; + /* 0x596 */ s16 field_0x596; + /* 0x598 */ cXyz field_0x598; + /* 0x5A4 */ f32 field_0x5a4; + /* 0x5A8 */ obj_sc_s field_0x5a8[8]; + /* 0x8C8 */ J3DModel* field_0x8c8; + /* 0x8CC */ s16 mDemoMode; + /* 0x8CE */ s16 field_0x8ce; + /* 0x8D0 */ cXyz mDemoCamEye; + /* 0x8DC */ cXyz mDemoCamCenter; + /* 0x8E8 */ cXyz field_0x8e8; + /* 0x8F4 */ f32 mDemoCamFovy; + /* 0x8F8 */ u8 field_0x8f8[0x8fc - 0x8f8]; /* 0x8FC */ f32 field_0x8fc; /* 0x900 */ f32 field_0x900; /* 0x904 */ cXyz field_0x904[2]; /* 0x91C */ int field_0x91c; - /* 0x920 */ cXyz field_0x920[12]; - /* 0x9B0 */ u8 field_0x9b0[0xd50 - 0x9b0]; + /* 0x920 */ cXyz field_0x920[63]; + /* 0xC14 */ f32 field_0xc14[4]; + /* 0xC24 */ u8 field_0xc24[0xd10 - 0xc24]; + /* 0xD10 */ s8 field_0xd10[4]; + /* 0xD14 */ u8 field_0xd14[0xd50 - 0xd14]; /* 0xD50 */ mDoExt_3DlineMat1_c field_0xd50; /* 0xD8C */ int field_0xd8c; }; diff --git a/src/d/actor/d_a_obj_sw.cpp b/src/d/actor/d_a_obj_sw.cpp index 1f037f4cada..b2c35995f36 100644 --- a/src/d/actor/d_a_obj_sw.cpp +++ b/src/d/actor/d_a_obj_sw.cpp @@ -4,125 +4,15 @@ */ //#define VIRTUAL_3DLINEMAT +#include "d/actor/d_a_player.h" #include "m_Do/m_Do_ext.h" #include "d/d_camera.h" #include "d/actor/d_a_obj_sw.h" #include "d/d_com_inf_game.h" -#include "dol2asm.h" - - - - - - - - -// -// Forward References: -// - -extern "C" static void daObj_Sw_Draw__FP12obj_sw_class(); -extern "C" static void s_ks_sub__FPvPv(); -extern "C" static void s_ksdel_sub__FPvPv(); -extern "C" static void anm_init__FP8obj_sc_sifUcf(); -extern "C" static void sc_build__FP12obj_sw_class(); -extern "C" void __dt__4cXyzFv(); -extern "C" static void sc_move__FP12obj_sw_class(); -extern "C" static void demo_camera__FP12obj_sw_class(); -extern "C" static void sc_action__FP12obj_sw_class(); -extern "C" static void sw_action__FP12obj_sw_class(); -extern "C" static void daObj_Sw_Execute__FP12obj_sw_class(); -extern "C" static bool daObj_Sw_IsDelete__FP12obj_sw_class(); -extern "C" static void daObj_Sw_Delete__FP12obj_sw_class(); -extern "C" static void useHeapInit__FP10fopAc_ac_c(); -extern "C" static void daObj_Sw_Create__FP10fopAc_ac_c(); -extern "C" void __ct__4cXyzFv(); -extern "C" void __dt__8obj_sc_sFv(); -extern "C" void __ct__8obj_sc_sFv(); -extern "C" void getLeftHandPos__9daPy_py_cCFv(); -extern "C" extern char const* const d_a_obj_sw__stringBase0; - -// -// External References: -// - -extern "C" void mDoMtx_XrotM__FPA4_fs(); -extern "C" void mDoMtx_YrotS__FPA4_fs(); -extern "C" void mDoMtx_YrotM__FPA4_fs(); -extern "C" void mDoMtx_ZrotM__FPA4_fs(); -extern "C" void push__14mDoMtx_stack_cFv(); -extern "C" void pop__14mDoMtx_stack_cFv(); -extern "C" void transM__14mDoMtx_stack_cFfff(); -extern "C" void mDoExt_modelUpdateDL__FP8J3DModel(); -extern "C" void -__ct__14mDoExt_McaMorfFP12J3DModelDataP25mDoExt_McaMorfCallBack1_cP25mDoExt_McaMorfCallBack2_cP15J3DAnmTransformifiiiPvUlUl(); -extern "C" void setAnm__14mDoExt_McaMorfFP15J3DAnmTransformiffffPv(); -extern "C" void play__14mDoExt_McaMorfFP3VecUlSc(); -extern "C" void entryDL__14mDoExt_McaMorfFv(); -extern "C" void modelCalc__14mDoExt_McaMorfFv(); -extern "C" void init__19mDoExt_3DlineMat1_cFUsUsP7ResTIMGi(); -extern "C" void update__19mDoExt_3DlineMat1_cFiR8_GXColorP12dKy_tevstr_c(); -extern "C" void setMat__26mDoExt_3DlineMatSortPacketFP18mDoExt_3DlineMat_c(); -extern "C" void mDoExt_J3DModel__create__FP12J3DModelDataUlUl(); -extern "C" void __ct__10fopAc_ac_cFv(); -extern "C" void fopAc_IsActor__FPv(); -extern "C" void fopAcM_delete__FP10fopAc_ac_c(); -extern "C" void fopAcM_createChild__FsUiUlPC4cXyziPC5csXyzPC4cXyzScPFPv_i(); -extern "C" void fopAcM_entrySolidHeap__FP10fopAc_ac_cPFP10fopAc_ac_c_iUl(); -extern "C" void fopAcM_orderPotentialEvent__FP10fopAc_ac_cUsUsUs(); -extern "C" void fpcEx_Search__FPFPvPv_PvPv(); -extern "C" void dComIfG_resLoad__FP30request_of_phase_process_classPCc(); -extern "C" void dComIfG_resDelete__FP30request_of_phase_process_classPCc(); -extern "C" void dComIfGp_getReverb__Fi(); -extern "C" void onSwitch__10dSv_info_cFii(); -extern "C" void isSwitch__10dSv_info_cCFii(); -extern "C" void getRes__14dRes_control_cFPCclP11dRes_info_ci(); -extern "C" void reset__14dEvt_control_cFv(); -extern "C" void dPath_GetRoomPath__Fii(); -extern "C" void dKyw_get_AllWind_vec__FP4cXyzP4cXyzPf(); -extern "C" void StartShock__12dVibration_cFii4cXyz(); -extern "C" void Start__9dCamera_cFv(); -extern "C" void Stop__9dCamera_cFv(); -extern "C" void SetTrimSize__9dCamera_cFl(); -extern "C" void Set__9dCamera_cF4cXyz4cXyzfs(); -extern "C" void Reset__9dCamera_cF4cXyz4cXyzfs(); -extern "C" void settingTevStruct__18dScnKy_env_light_cFiP4cXyzP12dKy_tevstr_c(); -extern "C" void setLightTevColorType_MAJI__18dScnKy_env_light_cFP12J3DModelDataP12dKy_tevstr_c(); -extern "C" void __pl__4cXyzCFRC3Vec(); -extern "C" void __mi__4cXyzCFRC3Vec(); -extern "C" void __ml__4cXyzCFf(); -extern "C" void __dv__4cXyzCFf(); -extern "C" void cM_atan2s__Fff(); -extern "C" void cM_rndF__Ff(); -extern "C" void cLib_addCalc2__FPffff(); -extern "C" void cLib_addCalc0__FPfff(); -extern "C" void cLib_addCalcAngleS2__FPssss(); -extern "C" void MtxPosition__FP4cXyzP4cXyz(); -extern "C" void __dt__14Z2SoundObjBaseFv(); -extern "C" void deleteObject__14Z2SoundObjBaseFv(); -extern "C" void __ct__16Z2SoundObjSimpleFv(); -extern "C" void* __nw__FUl(); -extern "C" void __dl__FPv(); -extern "C" void __construct_array(); -extern "C" void _savegpr_24(); -extern "C" void _savegpr_25(); -extern "C" void _savegpr_27(); -extern "C" void _savegpr_28(); -extern "C" void _savegpr_29(); -extern "C" void _restgpr_24(); -extern "C" void _restgpr_25(); -extern "C" void _restgpr_27(); -extern "C" void _restgpr_28(); -extern "C" void _restgpr_29(); -extern "C" extern void* __vt__19mDoExt_3DlineMat1_c[5]; -extern "C" extern void* __vt__16Z2SoundObjSimple[8]; -extern "C" u8 m_cpadInfo__8mDoCPd_c[256]; -extern "C" u8 now__14mDoMtx_stack_c[48]; -extern "C" u8 sincosTable___5JMath[65536]; +#include "d/d_path.h" /* 80CF0638-80CF0774 000078 013C+00 1/0 0/0 0/0 .text daObj_Sw_Draw__FP12obj_sw_class */ static int daObj_Sw_Draw(obj_sw_class* i_this) { - // NONMATCHING static _GXColor l_color = { 0x14, 0x0F, @@ -133,15 +23,15 @@ static int daObj_Sw_Draw(obj_sw_class* i_this) { fopAc_ac_c* a_this = &i_this->actor; if (i_this->field_0x570 == 8) { g_env_light.settingTevStruct(0, &a_this->current.pos, &a_this->tevStr); - obj_sc_s* sc_p = &i_this->field_0x5a8; + obj_sc_s* sc_p = i_this->field_0x5a8; for (int i = 0; i < 8; i++) { if (sc_p->field_0x0 != 0) { g_env_light.setLightTevColorType_MAJI(sc_p->mpModelMorf->getModel(), &a_this->tevStr); sc_p->mpModelMorf->entryDL(); - if (i == 2 && i_this->field_0x864.mpModel != NULL) { - g_env_light.setLightTevColorType_MAJI(i_this->field_0x864.mpModel, &a_this->tevStr); - mDoExt_modelUpdateDL(i_this->field_0x864.mpModel); + if (i == 2 && i_this->field_0x8c8 != NULL) { + g_env_light.setLightTevColorType_MAJI(i_this->field_0x8c8, &a_this->tevStr); + mDoExt_modelUpdateDL(i_this->field_0x8c8); } } sc_p = (obj_sc_s *)((s8*)sc_p + 100); @@ -177,7 +67,7 @@ struct path { f32 field_0x8; f32 field_0xc; }; -/* ############################################################################################## */ + /* 80CF3100-80CF3210 000004 0110+00 3/3 0/0 0/0 .data sc_path */ static path sc_path[17] = { {1, 8172.0f, 3380.0f, -10887.0f}, @@ -197,23 +87,6 @@ static path sc_path[17] = { {0, 7851.0f, 5460.0f, -11269.0f}, {0, 7599.0f, 5537.0f, -11186.0f}, {0, 0.0f, 0.0f, 0.0f}, - // 0x00000001, 0x45FF6000, 0x45534000, 0xC62A1C00, - // 0x00000001, 0x4601C400, 0x455C4000, 0xC6302C00, - // 0x00000001, 0x46091800, 0x4565D000, 0xC627A000, - // 0x00000001, 0x46096800, 0x4565D000, 0xC6328000, - // 0x00000001, 0x4610CC00, 0x4572F000, 0xC6256800, - // 0x00000001, 0x460CD400, 0x4573E000, 0xC6375C00, - // 0x00000001, 0x460F8000, 0x4579D000, 0xC62F7800, - // 0x00000001, 0x46105800, 0x4580F800, 0xC639B800, - // 0x00000001, 0x46166000, 0x458FD000, 0xC6360000, - // 0x00000000, 0x4614A400, 0x4597B000, 0xC63EC400, - // 0x00000000, 0x460D6400, 0x459D5800, 0xC63C4800, - // 0x00000000, 0x46082C00, 0x459ED800, 0xC6382400, - // 0x00000000, 0x4603B000, 0x45A2B000, 0xC631F000, - // 0x00000000, 0x46007C00, 0x45A74800, 0xC62FC800, - // 0x00000000, 0x45F55800, 0x45AAA000, 0xC6301400, - // 0x00000000, 0x45ED7800, 0x45AD0800, 0xC62EC800, - // 0x00000000, 0x00000000, 0x00000000, 0x00000000, }; /* 80CF07F8-80CF08F8 000238 0100+00 1/1 0/0 0/0 .text s_ksdel_sub__FPvPv */ @@ -238,7 +111,7 @@ static void anm_init(obj_sc_s* i_this, int param_2, f32 i_morf, u8 i_mode, f32 i static void sc_build(obj_sw_class* i_this) { // NONMATCHING fopAc_ac_c* a_this = &i_this->actor; - obj_sc_s* sc_p = &i_this->field_0x5a8; + obj_sc_s* sc_p = i_this->field_0x5a8; cXyz sp24, sp30; for (int i = 0; i < 8; i++) { @@ -259,7 +132,7 @@ static void sc_build(obj_sw_class* i_this) { case 1: sp24 = sc_p->field_0x1c - sc_p->field_0x4; - cLib_addCalcAngleS2(&sc_p->field_0x2a, cM_atan2s(sp24.x, sp24.z), 1, 0x2000); + cLib_addCalcAngleS2(&sc_p->field_0x28.y, cM_atan2s(sp24.x, sp24.z), 1, 0x2000); if (sc_p->field_0x34 == 0) { sc_p->field_0x0 = 2; anm_init(sc_p, 11, 2.0f, 0, 1.0f); @@ -283,7 +156,7 @@ static void sc_build(obj_sw_class* i_this) { sp24 = sc_p->field_0x1c - sc_p->field_0x4; sVar1 = cM_atan2s(sp24.x, sp24.z); - cLib_addCalcAngleS2(&sc_p->field_0x2a, sVar1, 1, 0x2000); + cLib_addCalcAngleS2(&sc_p->field_0x28.y, sVar1, 1, 0x2000); cMtx_YrotS(*calc_mtx, sVar1); cMtx_XrotM(*calc_mtx, -cM_atan2s(sp24.y, JMAFastSqrt(sp24.x * sp24.x + sp24.z * sp24.z))); sp24.x = 0.0f; @@ -318,8 +191,8 @@ static void sc_build(obj_sw_class* i_this) { break; case 3: - cLib_addCalcAngleS2(&sc_p->field_0x2a, a_this->current.angle.y + 0x8000, 2, 0x1000); - cMtx_YrotS(*calc_mtx, sc_p->field_0x2a); + cLib_addCalcAngleS2(&sc_p->field_0x28.y, a_this->current.angle.y + 0x8000, 2, 0x1000); + cMtx_YrotS(*calc_mtx, sc_p->field_0x28.y); sp24.x = 0.0f; sp24.y = 0.0f; sp24.z = -35.0f; @@ -336,7 +209,7 @@ static void sc_build(obj_sw_class* i_this) { if (i == 7) { i_this->field_0x576 = 2; - i_this->field_0x57c = 120; + i_this->field_0x57a[1] = 120; int swBit = fopAcM_GetParam(a_this) >> 24; if (swBit != 0xFF) { dComIfGs_onSwitch(swBit, fopAcM_GetRoomNo(a_this)); @@ -353,402 +226,579 @@ static void sc_build(obj_sw_class* i_this) { } } -/* ############################################################################################## */ -/* 80CF3028-80CF302C 000028 0004+00 0/1 0/0 0/0 .rodata @4056 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4056 = 1.0f / 5.0f; -COMPILER_STRIP_GATE(0x80CF3028, &lit_4056); -#pragma pop - -/* 80CF302C-80CF3030 00002C 0004+00 0/1 0/0 0/0 .rodata @4057 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4057 = 33.0f / 100.0f; -COMPILER_STRIP_GATE(0x80CF302C, &lit_4057); -#pragma pop - -/* 80CF3030-80CF3034 000030 0004+00 0/2 0/0 0/0 .rodata @4058 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4058 = 0.5f; -COMPILER_STRIP_GATE(0x80CF3030, &lit_4058); -#pragma pop - -/* 80CF3034-80CF3038 000034 0004+00 0/1 0/0 0/0 .rodata @4059 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4059 = 60.0f; -COMPILER_STRIP_GATE(0x80CF3034, &lit_4059); -#pragma pop - -/* 80CF3038-80CF303C 000038 0004+00 0/1 0/0 0/0 .rodata @4060 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4060 = 500.0f; -COMPILER_STRIP_GATE(0x80CF3038, &lit_4060); -#pragma pop - -/* 80CF303C-80CF3040 00003C 0004+00 0/2 0/0 0/0 .rodata @4061 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4061 = 2.0f / 5.0f; -COMPILER_STRIP_GATE(0x80CF303C, &lit_4061); -#pragma pop - -/* 80CF3040-80CF3048 000040 0008+00 0/3 0/0 0/0 .rodata @4062 */ -#pragma push -#pragma force_active on -SECTION_RODATA static u8 const lit_4062[8] = { - 0x3F, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; -COMPILER_STRIP_GATE(0x80CF3040, &lit_4062); -#pragma pop - -/* 80CF3048-80CF3050 000048 0008+00 0/3 0/0 0/0 .rodata @4063 */ -#pragma push -#pragma force_active on -SECTION_RODATA static u8 const lit_4063[8] = { - 0x40, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; -COMPILER_STRIP_GATE(0x80CF3048, &lit_4063); -#pragma pop - -/* 80CF3050-80CF3058 000050 0008+00 0/3 0/0 0/0 .rodata @4064 */ -#pragma push -#pragma force_active on -SECTION_RODATA static u8 const lit_4064[8] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; -COMPILER_STRIP_GATE(0x80CF3050, &lit_4064); -#pragma pop - -/* 80CF3058-80CF305C 000058 0004+00 0/1 0/0 0/0 .rodata @4065 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4065 = 250.0f; -COMPILER_STRIP_GATE(0x80CF3058, &lit_4065); -#pragma pop - -/* 80CF305C-80CF3060 00005C 0004+00 0/2 0/0 0/0 .rodata @4066 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4066 = 1400.0f; -COMPILER_STRIP_GATE(0x80CF305C, &lit_4066); -#pragma pop - -/* 80CF3060-80CF3064 000060 0004+00 0/2 0/0 0/0 .rodata @4067 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4067 = 4.0f; -COMPILER_STRIP_GATE(0x80CF3060, &lit_4067); -#pragma pop - /* 80CF1044-80CF1384 000A84 0340+00 1/1 0/0 0/0 .text sc_move__FP12obj_sw_class */ static void sc_move(obj_sw_class* i_this) { - // NONMATCHING + fopAc_ac_c* a_this = &i_this->actor; cXyz sp24, sp30; - if (i_this->field_0x864.field_0x68 == 0) { - if (i_this->field_0x57a == 0) { - if (cM_rndF(1.0f) >= 0.2f) { - if (cM_rndF(1.0f) >= 0.33f) { - if (cM_rndF(1.0f) >= 0.5f) { - - } - } + if (i_this->mDemoMode == 0) { + if (i_this->field_0x57a[0] == 0) { + if (cM_rndF(1.0f) < 0.2f) { + anm_init(&i_this->field_0x5a8[7], 5, 5.0f, 2, 1.0f); + } else if (cM_rndF(1.0f) < 0.33f) { + anm_init(&i_this->field_0x5a8[7], 6, 5.0f, 2, 1.0f); + } else if (cM_rndF(1.0f) < 0.5f) { + anm_init(&i_this->field_0x5a8[7], 7, 5.0f, 2, 1.0f); + } else { + anm_init(&i_this->field_0x5a8[7], 8, 5.0f, 2, 1.0f); } + + i_this->field_0x57a[0] = cM_rndF(60.0f) + 40.0f; + i_this->field_0x5a8[7].mSound.startSound(Z2SE_KOSARU_V_WAIT, 0, -1); + } + + if (i_this->field_0x57a[2] == 0 && i_this->field_0x584 > 500.0f) { + sp24 = a_this->eyePos - daPy_getPlayerActorClass()->getLeftHandPos(); + sp24.y *= 0.4f; + if (sp24.abs() < 250.0f) { + i_this->mDemoMode = 1; + anm_init(&i_this->field_0x5a8[7], 13, 2.0f, 0, 1.0f); + i_this->field_0x580 = -0x1E9B; + i_this->field_0x588 = 1400.0f; + i_this->field_0x594 = 0; + i_this->field_0x590 = 0.0f; + dComIfGp_getVibration().StartShock(3, 31, cXyz(0.0f, 1.0f, 0.0f)); + } + } + } + + if (i_this->field_0x57a[1] == 1) { + i_this->field_0x588 = 0.0f; + i_this->field_0x584 = 1400.0f; + i_this->field_0x590 = 4.0f; + i_this->field_0x594 = 5000; + i_this->field_0x580 = 0x4000; + } +} + +/* 80CF1384-80CF1970 000DC4 05EC+00 1/1 0/0 0/0 .text demo_camera__FP12obj_sw_class */ +static void demo_camera(obj_sw_class* i_this) { + // NONMATCHING + fopAc_ac_c* a_this = &i_this->actor; + daPy_py_c* player = (daPy_py_c*)dComIfGp_getPlayer(0); + camera_class* camera = dComIfGp_getCamera(dComIfGp_getPlayerCameraID(0)); + cXyz sp24, sp30; + + switch (i_this->mDemoMode) { + case 1: + if (!a_this->eventInfo.checkCommandDemoAccrpt()) { + fopAcM_orderPotentialEvent(a_this, 2, 0xFFFF, 0); + a_this->eventInfo.onCondition(dEvtCnd_CANDEMO_e); + return; + } + + i_this->mDemoMode = 2; + camera->mCamera.Stop(); + i_this->field_0x8ce = 0; + player->changeOriginalDemo(); + player->changeDemoMode(19, 0, 0, 0); + player->changeDemoParam0(0); + + cMtx_YrotS(*calc_mtx, a_this->current.angle.y); + sp24.x = 0.0f; + sp24.y = 0.0f; + sp24.z = 400.0f; + MtxPosition(&sp24, &sp30); + i_this->field_0x598 = a_this->eyePos + sp30; + dComIfGp_event_offHindFlag(15); + break; + + case 2: + dComIfGp_setDoStatusForce(1, 0); + if (i_this->field_0x8ce < 10) { + cLib_addCalc2(&i_this->field_0x598.x, a_this->eyePos.x, 1.0f, 40.0f); + cLib_addCalc2(&i_this->field_0x598.y, a_this->eyePos.y, 1.0f, 40.0f); + cLib_addCalc2(&i_this->field_0x598.z, a_this->eyePos.z, 1.0f, 40.0f); + } else { + i_this->field_0x598 = a_this->eyePos; + } + + player->setPlayerPosAndAngle(&i_this->field_0x598, a_this->current.angle.y + 0x8000, 0); + i_this->mDemoCamFovy = 55.0f; + i_this->field_0x8e8.z = -800.0f; + i_this->field_0x8e8.x = 300.0f; + i_this->field_0x8e8.y = -200.0f; + cLib_addCalc2(&i_this->mDemoCamCenter.x, player->current.pos.x, 0.4f, 200.0f); + cLib_addCalc2(&i_this->mDemoCamCenter.y, player->current.pos.y + 100.0f, 0.4f, 200.0f); + cLib_addCalc2(&i_this->mDemoCamCenter.z, player->current.pos.z, 0.4f, 200.0f); + + cMtx_YrotS(*calc_mtx, player->shape_angle.y); + sp24.x = i_this->field_0x8e8.x; + sp24.y = i_this->field_0x8e8.y; + sp24.z = i_this->field_0x8e8.z; + MtxPosition(&sp24, &sp30); + sp30.x += player->current.pos.x; + sp30.y += player->current.pos.y; + sp30.z += player->current.pos.z; + + if (i_this->field_0x8ce == 0) { + i_this->mDemoCamEye = sp30; + i_this->mDemoCamCenter = player->current.pos; + i_this->mDemoCamCenter.y += 100.0f; + } else { + cLib_addCalc2(&i_this->mDemoCamEye.x, sp30.x, 0.1f, 200.0f); + cLib_addCalc2(&i_this->mDemoCamEye.y, sp30.y, 0.1f, 200.0f); + cLib_addCalc2(&i_this->mDemoCamEye.z, sp30.z, 0.1f, 200.0f); + } + + player->changeDemoParam1(i_this->field_0x596 * 10); + if (mDoCPd_c::getTrigA(0) != 0) { + i_this->field_0x5a8[7].mSound.startSound(Z2SE_KOSARU_V_THROW, 0, -1); + player->changeDemoMode(24, 0, 0, 0); + anm_init(i_this->field_0x5a8, 9, 2.0f, 0, 1.0f); + i_this->mDemoMode = 3; + i_this->field_0x8ce = 0; + i_this->field_0x57a[2] = 50; + } + break; + + case 3: + cLib_addCalc2(&i_this->mDemoCamCenter.x, player->current.pos.x, 0.4f, 100.0f); + cLib_addCalc2(&i_this->mDemoCamCenter.y, player->current.pos.y, 0.4f, 100.0f); + cLib_addCalc2(&i_this->mDemoCamCenter.z, player->current.pos.z, 0.4f, 100.0f); + + cMtx_YrotS(*calc_mtx, player->shape_angle.y); + sp24.x = 0.0f; + sp24.y = 0.0f; + sp24.z = -400.0f; + MtxPosition(&sp24, &sp30); + sp30.x += player->current.pos.x; + sp30.y += player->current.pos.y; + sp30.z += player->current.pos.z; + + cLib_addCalc2(&i_this->mDemoCamEye.x, sp30.x, 0.1f, 50.0f); + cLib_addCalc2(&i_this->mDemoCamEye.y, sp30.y, 0.1f, 50.0f); + cLib_addCalc2(&i_this->mDemoCamEye.z, sp30.z, 0.1f, 50.0f); + + if (i_this->field_0x8ce == 15) { + i_this->mDemoMode = 100; + a_this->current.angle.y += -0x8000; + } + break; + + case 100: + camera->mCamera.Reset(i_this->mDemoCamCenter, i_this->mDemoCamEye, i_this->mDemoCamFovy, 0); + camera->mCamera.Start(); + camera->mCamera.SetTrimSize(0); + dComIfGp_event_reset(); + daPy_getPlayerActorClass()->cancelOriginalDemo(); + i_this->mDemoMode = 0; + } + + if (i_this->mDemoMode != 0) { + camera->mCamera.Set(i_this->mDemoCamCenter, i_this->mDemoCamEye, i_this->mDemoCamFovy, 0); + i_this->field_0x8ce++; + if (i_this->field_0x8ce > 10000) { + i_this->field_0x8ce = 10000; } } } -/* ############################################################################################## */ -/* 80CF3064-80CF3068 000064 0004+00 0/1 0/0 0/0 .rodata @4194 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4194 = 400.0f; -COMPILER_STRIP_GATE(0x80CF3064, &lit_4194); -#pragma pop - -/* 80CF3068-80CF306C 000068 0004+00 0/1 0/0 0/0 .rodata @4195 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4195 = 55.0f; -COMPILER_STRIP_GATE(0x80CF3068, &lit_4195); -#pragma pop - -/* 80CF306C-80CF3070 00006C 0004+00 0/1 0/0 0/0 .rodata @4196 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4196 = -800.0f; -COMPILER_STRIP_GATE(0x80CF306C, &lit_4196); -#pragma pop - -/* 80CF3070-80CF3074 000070 0004+00 0/1 0/0 0/0 .rodata @4197 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4197 = 300.0f; -COMPILER_STRIP_GATE(0x80CF3070, &lit_4197); -#pragma pop - -/* 80CF3074-80CF3078 000074 0004+00 0/2 0/0 0/0 .rodata @4198 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4198 = -200.0f; -COMPILER_STRIP_GATE(0x80CF3074, &lit_4198); -#pragma pop - -/* 80CF3078-80CF307C 000078 0004+00 0/2 0/0 0/0 .rodata @4199 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4199 = 200.0f; -COMPILER_STRIP_GATE(0x80CF3078, &lit_4199); -#pragma pop - -/* 80CF307C-80CF3080 00007C 0004+00 0/1 0/0 0/0 .rodata @4200 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4200 = 100.0f; -COMPILER_STRIP_GATE(0x80CF307C, &lit_4200); -#pragma pop - -/* 80CF3080-80CF3084 000080 0004+00 0/3 0/0 0/0 .rodata @4201 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4201 = 1.0f / 10.0f; -COMPILER_STRIP_GATE(0x80CF3080, &lit_4201); -#pragma pop - -/* 80CF3084-80CF3088 000084 0004+00 0/1 0/0 0/0 .rodata @4202 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4202 = -400.0f; -COMPILER_STRIP_GATE(0x80CF3084, &lit_4202); -#pragma pop - -/* 80CF3088-80CF308C 000088 0004+00 0/2 0/0 0/0 .rodata @4203 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4203 = 50.0f; -COMPILER_STRIP_GATE(0x80CF3088, &lit_4203); -#pragma pop - -/* 80CF1384-80CF1970 000DC4 05EC+00 1/1 0/0 0/0 .text demo_camera__FP12obj_sw_class */ -static void demo_camera(obj_sw_class* param_0) { - // NONMATCHING -} - -/* ############################################################################################## */ -/* 80CF308C-80CF3090 00008C 0004+00 0/2 0/0 0/0 .rodata @4442 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4442 = 10.0f; -COMPILER_STRIP_GATE(0x80CF308C, &lit_4442); -#pragma pop - -/* 80CF3090-80CF3094 000090 0004+00 0/1 0/0 0/0 .rodata @4443 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4443 = 1.0f / 20.0f; -COMPILER_STRIP_GATE(0x80CF3090, &lit_4443); -#pragma pop - -/* 80CF3094-80CF3098 000094 0004+00 0/1 0/0 0/0 .rodata @4444 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4444 = -230.0f; -COMPILER_STRIP_GATE(0x80CF3094, &lit_4444); -#pragma pop - -/* 80CF3098-80CF309C 000098 0004+00 0/1 0/0 0/0 .rodata @4445 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4445 = 3.0f / 10.0f; -COMPILER_STRIP_GATE(0x80CF3098, &lit_4445); -#pragma pop - -/* 80CF309C-80CF30A0 00009C 0004+00 0/2 0/0 0/0 .rodata @4446 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4446 = 1000.0f; -COMPILER_STRIP_GATE(0x80CF309C, &lit_4446); -#pragma pop - -/* 80CF30A0-80CF30A4 0000A0 0004+00 0/2 0/0 0/0 .rodata @4447 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4447 = 32768.0f; -COMPILER_STRIP_GATE(0x80CF30A0, &lit_4447); -#pragma pop - /* 80CF1970-80CF2160 0013B0 07F0+00 1/1 0/0 0/0 .text sc_action__FP12obj_sw_class */ -static void sc_action(obj_sw_class* param_0) { +static void sc_action(obj_sw_class* i_this) { // NONMATCHING + fopAc_ac_c* a_this = &i_this->actor; + cXyz sp90; + int swBit = fopAcM_GetParam(a_this) >> 24; + + switch (i_this->field_0x576) { + case 0: + saru_ct = 0; + fpcM_Search(s_ks_sub, i_this); + if (saru_ct == 8 && swBit != 0xFF) { + if (!dComIfGs_isSwitch(swBit, fopAcM_GetRoomNo(a_this))) { + if (!dComIfGp_event_runCheck()) { + if (dComIfGs_isSwitch(83, fopAcM_GetRoomNo(a_this))) { + saru_ct = 0; + fpcM_Search(s_ksdel_sub, i_this); + a_this->eyePos = a_this->home.pos; + if (swBit != 0xFF) { + if (dComIfGs_isSwitch(swBit, fopAcM_GetRoomNo(a_this))) { + i_this->field_0x576 = 2; + i_this->field_0x57a[1] = 120; + for (int i = 0; i < 8; i++) { + i_this->field_0x5a8[i].field_0x0 = 10; + i_this->field_0x5a8[i].field_0x28.x = -0x8000; + } + break; + } + } + + dComIfGs_onSwitch(121, fopAcM_GetRoomNo(a_this)); + i_this->field_0x576 = 1; + sc_path[16].field_0x4 = a_this->home.pos.x; + sc_path[16].field_0x8 = a_this->home.pos.y; + sc_path[16].field_0xc = a_this->home.pos.z; + } + } + } + } + break; + + case 1: + sc_build(i_this); + break; + + case 2: + sc_move(i_this); + break; + } + + cLib_addCalc2(&i_this->field_0x588, i_this->field_0x584, 0.1f, 10.0f); + i_this->field_0x58c = (1400.0f - i_this->field_0x588) / 5.0f; + cLib_addCalc0(&i_this->field_0x590, 0.1f, 0.05f); + cLib_addCalcAngleS2(&i_this->field_0x594, 00, 1, 5); + + obj_sc_s* sc_p = i_this->field_0x5a8; + mDoMtx_stack_c::transS(a_this->current.pos.x, a_this->current.pos.y, a_this->current.pos.z); + mDoMtx_stack_c::YrotM(a_this->current.angle.y + 0x8000); + + f32 fVar1 = 1.0f; + for (int i = 0; i < 8; i++) { + s16 sVar1 = i_this->field_0x588 * (fVar1 * cM_ssin((i_this->field_0x580 * 800) - i * i_this->field_0x594)); + s16 sVar2 = i_this->field_0x58c * cM_ssin((i_this->field_0x582 * 1000) - i * -10000); + sc_p->field_0x28.z = sVar2; + if (i == 7) { + i_this->field_0x596 = sVar1; + } + + mDoMtx_stack_c::XrotM(sVar1); + mDoMtx_stack_c::ZrotM(sc_p->field_0x28.z); + + if (sc_p->field_0x0 == 10) { + cLib_addCalcAngleS2(&sc_p->field_0x28.y, a_this->current.angle.y + 0x8000, 2, 0x1000); + cLib_addCalcAngleS2(&sc_p->field_0x28.x, -0x8000, 2, 0x1000); + mDoMtx_stack_c::push(); + mDoMtx_stack_c::XrotM(sc_p->field_0x28.x); + + sc_p->mpModelMorf->getModel()->setBaseTRMtx(mDoMtx_stack_c::get()); + sc_p->mpModelMorf->play(NULL, 0, 0); + sc_p->mpModelMorf->modelCalc(); + + if (i == 2 && i_this->field_0x8c8 != NULL) { + i_this->field_0x8c8->setBaseTRMtx(sc_p->mpModelMorf->getModel()->getAnmMtx(4)); + } + + sc_p->mSound.framework(0, dComIfGp_getReverb(fopAcM_GetRoomNo(a_this))); + mDoMtx_stack_c::pop(); + } + + mDoMtx_stack_c::transM(0.0f, -230.0f, 0.0f); + fVar1 += i_this->field_0x590; + if (sc_p->field_0x0 == 10) { + sp90.set(0.0f, 0.0f, 0.0f); + mDoMtx_stack_c::multVec(&sp90, &a_this->eyePos); + a_this->attention_info.position = a_this->eyePos; + a_this->attention_info.position.y += 40.0f; + } + + sc_p = (obj_sc_s *)((s8*)sc_p + 100); + } + + i_this->field_0x580--; + i_this->field_0x582++; + sc_p = i_this->field_0x5a8; + for (int i = 0; i < 8; i++) { + if (sc_p->field_0x0 < 10) { + f32 fVar2 = 0.0f; + f32 fVar3; + if (sc_p->field_0x35 != 0) { + sp90 = sc_p->field_0x1c - sc_p->field_0x10; + fVar3 = sp90.abs(); + sp90 = sc_p->field_0x1c - sc_p->field_0x4; + fVar2 = sp90.abs(); + f32 fVar4 = fVar2 * 0.3f; + if (fVar4 > 1000.0f) { + fVar4 = 1000.0f; + } + fVar2 = fVar4 * cM_ssin((fVar2 / fVar3) * 32768.0f); + sc_p->field_0x35 = 0; + } + + mDoMtx_stack_c::transS(sc_p->field_0x4.x, sc_p->field_0x4.y + fVar2, sc_p->field_0x4.z); + mDoMtx_stack_c::YrotM(sc_p->field_0x28.y); + mDoMtx_stack_c::XrotM(sc_p->field_0x28.x); + mDoMtx_stack_c::ZrotM(sc_p->field_0x28.z); + sc_p->mpModelMorf->getModel()->setBaseTRMtx(mDoMtx_stack_c::get()); + sc_p->mpModelMorf->play(NULL, 0, 0); + sc_p->mpModelMorf->modelCalc(); + sc_p->mSound.framework(0, dComIfGp_getReverb(fopAcM_GetRoomNo(a_this))); + } + + sc_p = (obj_sc_s *)((s8*)sc_p + 100); + } + + demo_camera(i_this); } -/* ############################################################################################## */ -/* 80CF30A4-80CF30A8 0000A4 0004+00 0/1 0/0 0/0 .rodata @4549 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4549 = 3.0f / 100.0f; -COMPILER_STRIP_GATE(0x80CF30A4, &lit_4549); -#pragma pop - -/* 80CF30A8-80CF30AC 0000A8 0004+00 0/1 0/0 0/0 .rodata @4550 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4550 = 70.0f; -COMPILER_STRIP_GATE(0x80CF30A8, &lit_4550); -#pragma pop - -/* 80CF30AC-80CF30B0 0000AC 0004+00 0/1 0/0 0/0 .rodata @4551 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4551 = 8.0f; -COMPILER_STRIP_GATE(0x80CF30AC, &lit_4551); -#pragma pop - -/* 80CF30B0-80CF30B8 0000B0 0004+04 0/1 0/0 0/0 .rodata @4552 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4552[1 + 1 /* padding */] = { - 3.0f / 40.0f, - /* padding */ - 0.0f, -}; -COMPILER_STRIP_GATE(0x80CF30B0, &lit_4552); -#pragma pop - -/* 80CF30B8-80CF30C0 0000B8 0008+00 0/1 0/0 0/0 .rodata @4554 */ -#pragma push -#pragma force_active on -SECTION_RODATA static u8 const lit_4554[8] = { - 0x43, 0x30, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, -}; -COMPILER_STRIP_GATE(0x80CF30B8, &lit_4554); -#pragma pop - /* 80CF2160-80CF2604 001BA0 04A4+00 1/1 0/0 0/0 .text sw_action__FP12obj_sw_class */ -static void sw_action(obj_sw_class* param_0) { +static void sw_action(obj_sw_class* i_this) { // NONMATCHING + cXyz sp98, spa4; + cXyz spb0 = i_this->field_0x904[1] - i_this->field_0x904[0]; + cXyz i_position = i_this->field_0x904[0] + (spb0 * 0.5f); + cXyz spc8; + f32 fVar1 = -(i_this->field_0x91c * 4.0f + 50.0f); + cXyz i_direction; + f32 i_power; + dKyw_get_AllWind_vec(&i_position, &i_direction, &i_power); + i_power *= i_power; + cLib_addCalc2(&i_this->field_0x5a4, i_power, 0.1f, 0.03f); + cMtx_YrotS(*calc_mtx, cM_atan2s(i_direction.x, i_direction.z)); + for (int i = 0; i < i_this->field_0xd8c; i++) { + spc8 = (spb0 / (i_this->field_0xd8c - 1)) * i; + f32 fVar2 = cM_ssin(((f32)i / (i_this->field_0xd8c - 1)) * 32768.0f); + spc8.y += (fVar2 * fVar1) + (fVar2 * (i_this->field_0x8fc * cM_ssin(i_this->field_0x574 * 0x9C4 + i * 2000))); + sp98.x = 0.0f; + sp98.y = 0.0f; + sp98.z = (fVar2 * 70.0f) * i_this->field_0x5a4; + MtxPosition(&sp98, &spa4); + spc8.x += spa4.x; + spc8.z += spa4.z; + i_this->field_0x904[i] = i_this->field_0x904[0] + spc8; + } + + for (int i = 0; i field_0xd8c; i++) { + f32 fVar3; + if (i_this->field_0xd10[i] != 0) { + i_this->field_0xd10[i]--; + fVar3 = -(i_this->field_0x91c * 8.0f + 30.0f); + fVar1 = 10.0f; + } else { + fVar3 = 0.0f; + fVar1 = 5.0f; + } + + cLib_addCalc2(&i_this->field_0xc14[i], fVar3, 0.5f, fVar1); + if (i_this->field_0xc14[i] != 0.0f) { + for (int j = i; j < i_this->field_0xd8c; j++) { + i_this->field_0x904[i].z += ((i_this->field_0xd8c--) - (f32)j) / ((i_this->field_0xd8c--) - i) * i_this->field_0xc14[i]; + } + } + } + + if (i_this->field_0x900 > 5.0f) { + i_this->field_0x900 = 5.0f; + } + + cLib_addCalc2(&i_this->field_0x8fc, i_this->field_0x900, 0.1f, 0.075f); + i_this->field_0x900 = 0.0f; } -/* 80CF2604-80CF26F0 002044 00EC+00 2/1 0/0 0/0 .text daObj_Sw_Execute__FP12obj_sw_class - */ -static void daObj_Sw_Execute(obj_sw_class* param_0) { - // NONMATCHING +/* 80CF2604-80CF26F0 002044 00EC+00 2/1 0/0 0/0 .text daObj_Sw_Execute__FP12obj_sw_class */ +static int daObj_Sw_Execute(obj_sw_class* i_this) { + for (int i = 0; i < 3; i++) { + if (i_this->field_0x57a[i] != 0) { + i_this->field_0x57a[i]--; + } + } + + i_this->field_0x574++; + if (i_this->field_0x570 == 8) { + sc_action(i_this); + } else { + sw_action(i_this); + cXyz* other = i_this->field_0x920; + cXyz* c_this = i_this->field_0xd50.getPos(0); + for (int i = 0; i < 63; i++, c_this++, other++) { + if (i < i_this->field_0xd8c) { + *c_this = *other; + } else { + *c_this = i_this->field_0x904[1]; + } + } + } + + return 1; } -/* 80CF26F0-80CF26F8 002130 0008+00 1/0 0/0 0/0 .text daObj_Sw_IsDelete__FP12obj_sw_class - */ -static bool daObj_Sw_IsDelete(obj_sw_class* param_0) { - return true; +/* 80CF26F0-80CF26F8 002130 0008+00 1/0 0/0 0/0 .text daObj_Sw_IsDelete__FP12obj_sw_class */ +static int daObj_Sw_IsDelete(obj_sw_class* i_this) { + return 1; } -/* ############################################################################################## */ -/* 80CF30EC-80CF30EC 0000EC 0000+00 0/0 0/0 0/0 .rodata @stringBase0 */ -#pragma push -#pragma force_active on -SECTION_DEAD static char const* const stringBase_80CF30F4 = "Obj_sw"; -#pragma pop +/* 80CF26F8-80CF2790 002138 0098+00 1/0 0/0 0/0 .text daObj_Sw_Delete__FP12obj_sw_class */ +static int daObj_Sw_Delete(obj_sw_class* i_this) { + fopAc_ac_c* a_this = &i_this->actor; + fopAcM_GetID(a_this); + if (i_this->field_0x570 == 8) { + dComIfG_resDelete(&i_this->mPhase, "Npc_ksw"); + } else { + dComIfG_resDelete(&i_this->mPhase, "Obj_sw"); + } -/* 80CF26F8-80CF2790 002138 0098+00 1/0 0/0 0/0 .text daObj_Sw_Delete__FP12obj_sw_class - */ -static void daObj_Sw_Delete(obj_sw_class* param_0) { - // NONMATCHING + if (a_this->heap != NULL) { + for (int i = 0; i < 8; i++) { + i_this->field_0x5a8[i].mSound.deleteObject(); + } + } + + return 1; } -/* ############################################################################################## */ -/* 80CF30C0-80CF30C4 0000C0 0004+00 0/1 0/0 0/0 .rodata @4659 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4659 = 6.0f; -COMPILER_STRIP_GATE(0x80CF30C0, &lit_4659); -#pragma pop - /* 80CF2790-80CF29D4 0021D0 0244+00 1/1 0/0 0/0 .text useHeapInit__FP10fopAc_ac_c */ -static void useHeapInit(fopAc_ac_c* param_0) { - // NONMATCHING +static int useHeapInit(fopAc_ac_c* a_this) { + obj_sw_class* i_this = (obj_sw_class*)a_this; + + if (i_this->field_0x570 == 8) { + for (int i = 0; i < 8; i++) { + i_this->field_0x5a8[i].mpModelMorf = new mDoExt_McaMorf((J3DModelData*)dComIfG_getObjectRes("Npc_ksw", 17), NULL, NULL, + (J3DAnmTransform*)dComIfG_getObjectRes("Npc_ksw", 13), 2, 1.0f, + 0, -1, 1, NULL, 0x80000, 0x11000084); + + if (i_this->field_0x5a8[i].mpModelMorf == NULL || i_this->field_0x5a8[i].mpModelMorf->getModel() == NULL) { + return 0; + } + + mDoMtx_stack_c::scaleS(0.0f, 0.0f, 0.0f); + i_this->field_0x5a8[i].mpModelMorf->getModel()->setBaseTRMtx(mDoMtx_stack_c::get()); + + if (i == 2) { + J3DModelData* modelData = (J3DModelData*)dComIfG_getObjectRes("Npc_ksw", 18); + JUT_ASSERT(1220, modelData != 0); + i_this->field_0x8c8 = mDoExt_J3DModel__create(modelData, 0x80000, 0x11000084); + if (i_this->field_0x8c8 == NULL) { + return 0; + } + i_this->field_0x8c8->setBaseTRMtx(mDoMtx_stack_c::get()); + } + + i_this->field_0x5a8[i].mSound.init(&i_this->field_0x5a8[i].field_0x4, 1); + } + } else { + if (i_this->field_0xd50.init(1, 63, (ResTIMG*)dComIfG_getObjectRes("Obj_sw", 3), 1) == 0) { + return 0; + } + + f32* size_p = i_this->field_0xd50.getSize(0); + for (int i = 0; i < 63; i++) { + *size_p = 6.0f; + size_p++; + } + } + + return 1; } -/* ############################################################################################## */ -/* 80CF30C4-80CF30C8 0000C4 0004+00 0/1 0/0 0/0 .rodata @4856 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4856 = -70.0f; -COMPILER_STRIP_GATE(0x80CF30C4, &lit_4856); -#pragma pop +/* 80CF29D4-80CF2F38 002414 0564+00 1/0 0/0 0/0 .text daObj_Sw_Create__FP10fopAc_ac_c */ +static int daObj_Sw_Create(fopAc_ac_c* a_this) { + // NONMATCHING + obj_sw_class* i_this = (obj_sw_class*)a_this; + int phase; + u32 i_size; + fopAcM_SetupActor(a_this, obj_sw_class); -/* 80CF30C8-80CF30CC 0000C8 0004+00 0/1 0/0 0/0 .rodata @4857 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4857 = -14000.0f; -COMPILER_STRIP_GATE(0x80CF30C8, &lit_4857); -#pragma pop + i_this->field_0x570 = fopAcM_GetParam(a_this); + if (i_this->field_0x570 == 0xFF) { + i_this->field_0x570 = 0; + } + OS_REPORT("OBJ_SW//////////////OBJ_SW SET 0 !!\n"); -/* 80CF30CC-80CF30D0 0000CC 0004+00 0/1 0/0 0/0 .rodata @4858 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4858 = 3450.0f; -COMPILER_STRIP_GATE(0x80CF30CC, &lit_4858); -#pragma pop + if (i_this->field_0x570 == 8) { + phase = dComIfG_resLoad(&i_this->mPhase, "Npc_ksw"); + i_size = 0x10140; + } else { + phase = dComIfG_resLoad(&i_this->mPhase, "Obj_sw"); + i_size = 0x1B00; + } -/* 80CF30D0-80CF30D4 0000D0 0004+00 0/1 0/0 0/0 .rodata @4859 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4859 = 12670.0f; -COMPILER_STRIP_GATE(0x80CF30D0, &lit_4859); -#pragma pop + if (phase == cPhs_COMPLEATE_e) { + OS_REPORT("OBJ_SW PARAM %x\n", fopAcM_GetParam(a_this)); + OS_REPORT("OBJ_SW//////////////OBJ_SW SET 1 !!\n"); -/* 80CF30D4-80CF30D8 0000D4 0004+00 0/1 0/0 0/0 .rodata @4860 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4860 = -1000.0f; -COMPILER_STRIP_GATE(0x80CF30D4, &lit_4860); -#pragma pop + if (!fopAcM_entrySolidHeap(a_this, useHeapInit, i_size)) { + OS_REPORT("//////////////OBJ_SW SET NON !!\n"); + return cPhs_ERROR_e; + } -/* 80CF30D8-80CF30DC 0000D8 0004+00 0/1 0/0 0/0 .rodata @4861 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4861 = -100.0f; -COMPILER_STRIP_GATE(0x80CF30D8, &lit_4861); -#pragma pop + OS_REPORT("//////////////OBJ_SW SET 2 !!\n"); + if (i_this->field_0x570 == 8) { + a_this->attention_info.distances[2] = 22; + a_this->home.pos.y += -70.0f; + a_this->current.pos.y = a_this->home.pos.y; -/* 80CF30DC-80CF30E0 0000DC 0004+00 0/1 0/0 0/0 .rodata @4862 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4862 = 3380.0f; -COMPILER_STRIP_GATE(0x80CF30DC, &lit_4862); -#pragma pop + fopAc_ac_c* player = dComIfGp_getPlayer(0); + if (player != NULL && player->current.pos.z < -14000.0f) { + a_this->current.angle.y += -0x8000; + } + } -/* 80CF30E0-80CF30E4 0000E0 0004+00 0/1 0/0 0/0 .rodata @4863 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4863 = 6280.0f; -COMPILER_STRIP_GATE(0x80CF30E0, &lit_4863); -#pragma pop + i_this->field_0x571 = fopAcM_GetParam(a_this) >> 8; + u8 path_index = fopAcM_GetParam(a_this) >> 16; + int swBit = fopAcM_GetParam(a_this) >> 24; + if (path_index == 0xFF) { + if (fopAcM_GetRoomNo(a_this) == 0) { + if (i_this->field_0x570 == 0) { + i_this->field_0x904[0].set(1000.0f, 3450.0f, 12670.0f); + i_this->field_0x904[1].set(200.0f, 3450.0f, 12670.0f); + } else { + i_this->field_0x904[0].set(-200.0f, 3450.0f, 12670.0f); + i_this->field_0x904[1].set(-1000.0f, 3450.0f, 12670.0f); + } + } else { + i_this->field_0x904[0].set(-100.0f, 3380.0f, 6280.0f); + i_this->field_0x904[1].set(-100.0f, 3380.0f, 3780.0f); + } + } else { + dPath* path_p = dPath_GetRoomPath(path_index, fopAcM_GetRoomNo(a_this)); + if (path_p != NULL) { + dPnt* pnt_p = path_p->m_points; + i_this->field_0x904[0] = pnt_p->m_position; + i_this->field_0x904[1] = (pnt_p + 1)->m_position; + } else { + OS_REPORT("OJBSW NON PATH !!!!!!!!! %d!\n"); + return cPhs_ERROR_e; + } + } -/* 80CF30E4-80CF30E8 0000E4 0004+00 0/1 0/0 0/0 .rodata @4864 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4864 = 3780.0f; -COMPILER_STRIP_GATE(0x80CF30E4, &lit_4864); -#pragma pop + daObj_Sw_Execute(i_this); + cXyz sp34 = i_this->field_0x904[1] - i_this->field_0x904[0]; + a_this->current.pos = i_this->field_0x904[0]; + a_this->current.angle.y = cM_atan2s(sp34.x, sp34.z); -/* 80CF30E8-80CF30EC 0000E8 0004+00 0/1 0/0 0/0 .rodata @4865 */ -#pragma push -#pragma force_active on -SECTION_RODATA static f32 const lit_4865 = 5600.0f; -COMPILER_STRIP_GATE(0x80CF30E8, &lit_4865); -#pragma pop + OS_REPORT("OBJ_SW DIS %f\n"); + if (sp34.abs() > 5600.0f) { + OS_REPORT("OBJ_SW TOO LONG !!!!!!!\n"); + return cPhs_ERROR_e; + } + + if (fopAcM_GetRoomNo(a_this) == 0) { + i_this->field_0x91c = 1; + } else if (fopAcM_GetRoomNo(a_this) == 2) { + i_this->field_0x91c = 2; + } else if (fopAcM_GetRoomNo(a_this) == 4) { + i_this->field_0x91c = 4; + } else { + return cPhs_ERROR_e; + } + + i_this->field_0xd8c = (i_this->field_0x91c * 63) / 2; + if (fopAcM_GetRoomNo(a_this) == 2 || fopAcM_GetRoomNo(a_this) == 4) { + fopAcM_createChild(PROC_OBJ_BRG, fopAcM_GetID(a_this), swBit << 24 | 0xFFFFFF, &a_this->current.pos, + fopAcM_GetRoomNo(a_this), &a_this->current.angle, NULL, -1, NULL); + } + + if (fopAcM_GetRoomNo(a_this) == 4 && swBit != 0xFF) { + if (!dComIfGs_isSwitch(swBit, fopAcM_GetRoomNo(a_this))) { + fopAcM_createChild(PROC_E_MK, fopAcM_GetID(a_this), swBit << 16 | 1, &a_this->current.pos, + fopAcM_GetRoomNo(a_this), &a_this->current.angle, NULL, -1, NULL); + return cPhs_ERROR_e; + } + } + } + + return phase; +} + +/* 80CF30EC-80CF30EC 0000EC 0000+00 0/0 0/0 0/0 .rodata @stringBase0 */ /* 80CF3210-80CF3230 -00001 0020+00 1/0 0/0 0/0 .data l_daObj_Sw_Method */ static actor_method_class l_daObj_Sw_Method = { - (process_method_func)daObj_Sw_Create__FP10fopAc_ac_c, - (process_method_func)daObj_Sw_Delete__FP12obj_sw_class, - (process_method_func)daObj_Sw_Execute__FP12obj_sw_class, - (process_method_func)daObj_Sw_IsDelete__FP12obj_sw_class, - (process_method_func)daObj_Sw_Draw__FP12obj_sw_class, + (process_method_func)daObj_Sw_Create, + (process_method_func)daObj_Sw_Delete, + (process_method_func)daObj_Sw_Execute, + (process_method_func)daObj_Sw_IsDelete, + (process_method_func)daObj_Sw_Draw, }; /* 80CF3230-80CF3260 -00001 0030+00 0/0 0/0 1/0 .data g_profile_OBJ_SW */ @@ -768,37 +818,3 @@ extern actor_process_profile_definition g_profile_OBJ_SW = { fopAc_ACTOR_e, // mActorType fopAc_CULLBOX_0_e, // cullType }; - -/* 80CF3260-80CF3274 000164 0014+00 1/1 0/0 0/0 .data __vt__18mDoExt_3DlineMat_c */ -SECTION_DATA extern void* __vt__18mDoExt_3DlineMat_c[5] = { - (void*)NULL /* RTTI */, (void*)NULL, (void*)NULL, (void*)NULL, (void*)NULL, -}; - -/* 80CF29D4-80CF2F38 002414 0564+00 1/0 0/0 0/0 .text daObj_Sw_Create__FP10fopAc_ac_c */ -static void daObj_Sw_Create(fopAc_ac_c* param_0) { - // NONMATCHING -} - -/* 80CF2F38-80CF2F3C 002978 0004+00 1/1 0/0 0/0 .text __ct__4cXyzFv */ -//cXyz::cXyz() { -void __ct__4cXyzFv() { - /* empty function */ -} - -/* 80CF2F3C-80CF2FA8 00297C 006C+00 1/1 0/0 0/0 .text __dt__8obj_sc_sFv */ -obj_sc_s::~obj_sc_s() { - // NONMATCHING -} - -/* 80CF2FA8-80CF2FDC 0029E8 0034+00 1/1 0/0 0/0 .text __ct__8obj_sc_sFv */ -obj_sc_s::obj_sc_s() { - // NONMATCHING -} - -/* 80CF2FDC-80CF2FF8 002A1C 001C+00 1/1 0/0 0/0 .text getLeftHandPos__9daPy_py_cCFv */ -// void daPy_py_c::getLeftHandPos() const { -extern "C" void getLeftHandPos__9daPy_py_cCFv() { - // NONMATCHING -} - -/* 80CF30EC-80CF30EC 0000EC 0000+00 0/0 0/0 0/0 .rodata @stringBase0 */