diff --git a/include/d/actor/d_a_npc_md.h b/include/d/actor/d_a_npc_md.h index da85d4ccc..17f69c2f4 100644 --- a/include/d/actor/d_a_npc_md.h +++ b/include/d/actor/d_a_npc_md.h @@ -87,7 +87,7 @@ public: /* 0x16 */ s16 m16; }; -class daNpc_Md_HIO_c { +class daNpc_Md_HIO_c : public JORReflexible { public: daNpc_Md_HIO_c(); virtual ~daNpc_Md_HIO_c() {} @@ -101,7 +101,7 @@ public: /* 0x068 */ daNpc_Md_HIO5_c m068; /* 0x074 */ daNpc_Md_HIO6_c m074; /* 0x08C */ dNpc_HIO_c m08C; - /* 0x0B4 */ int m0B4; + /* 0x0B4 */ fopAc_ac_c* mpActor; /* 0x0B8 */ f32 m0B8; /* 0x0BC */ f32 m0BC; /* 0x0C0 */ f32 m0C0; @@ -188,6 +188,10 @@ public: void setup(JPABaseEmitter*, const cXyz*, const csXyz*, s8); void end(); + JPABaseEmitter* getEmitter() { return mpEmitter; } + cXyz& getPos() { return mPos; } + void setAngle(s16 x, s16 y, s16 z) { mAngle.set(x, y, z); } + public: /* 0x04 */ JPABaseEmitter* mpEmitter; /* 0x08 */ cXyz mPos; @@ -206,11 +210,95 @@ public: bool chkPlayerAction(ActionFunc func) { return mCurrPlayerActionFunc == func; } bool chkNpcAction(ActionFunc func) { return mCurrNpcActionFunc == func; } + bool isOldLightBodyHit() { return cLib_checkBit(m30F0, 0x00008000UL); } void onDefaultTalkXY() { cLib_onBit(m30F0, 0x00010000UL); } void offDefaultTalkXY() { cLib_offBit(m30F0, 0x00010000UL); } bool isDefaultTalkXY() { return cLib_checkBit(m30F0, 0x00010000UL); } + void setTypeEdaichi() { m3138 = 4; } + void setTypeM_Dai() { m3138 = 5; } + void setTypeM_DaiB() { m3138 = 6; } + void setTypeShipRide() { m3138 = 7; } + + void calcFlyingTimer() {} + void checkBitEffectStatus(u8) {} + void checkBitHairMode(u8) {} + void checkStatus(u32) {} + void checkStatusCamTagIn() {} + void checkStatusFly() {} + void clearJntAng() {} + void clearStatus() {} + void clearStatus(u32) {} + void countPiyo2TalkCNT() {} + void getArmLJntNum() {} + void getArmLlocJntNum() {} + void getArmRJntNum() {} + void getArmRlocJntNum() {} + void getAttentionBasePos() {} + void getBackbone_x() {} + void getBackbone_y() {} + void getEyePos() {} + void getFlyingTimer() {} + void getHairJntNum(int) {} + void getHead_x() {} + void getHead_y() {} + void getModel() {} + void getPHairDist(int) {} + void getPHairPos(int) {} + void getPHairVec(int) {} + void getPHairWall() {} + void getPiyo2TalkCNT() {} + void getTalkType() {} + void getWaistRotX() {} + void getWaistRotY() {} + void incAttnSetCount() {} + void isLightBodyHit() {} + void isLightHit() {} + void isMirror() {} + void isNoCarryAction() {} + void isSeaTalk() {} + void isShipRide() {} + void isTypeAdanmae() {} + void isTypeAtorizk() {} + void isTypeEdaichi() {} + void isTypeM_Dai() {} + void isTypeM_DaiB() {} + void isTypeM_Dra09() {} + void isTypeSea() {} + void isTypeShipRide() {} + void isXYTalk() {} + void noCarryAction() {} + void offBitCamTagIn() {} + void offFlying() {} + void offLightBodyHit() {} + void offLightHit() {} + void offMirror() {} + void offNoCarryAction() {} + void offPlayerRoom() {} + void offSeaTalk() {} + void offShipRide() {} + void offXYTalk() {} + void onBitCamTagIn() {} + void onFlying() {} + void onLightBodyHit() {} + void onLightHit() {} + void onMirror() {} + void onPlayerRoom() {} + void onSeaTalk() {} + void onShipRide() {} + void onXYTalk() {} + void setBitEffectStatus(u8) {} + void setBitHairMode(u8) {} + void setBitStatus(u32) {} + void setEffectStatus(u8) {} + void setFlyingTimer(s16) {} + void setOldLightBodyHit() {} + void setPiyo2TalkCNT(u8) {} + void setRunRate(f32) {} + void setStatus(u32) {} + void setTalkType(u8) {} + daNpc_Md_c() {} ~daNpc_Md_c(); @@ -350,7 +438,7 @@ public: void lookBackWaist(s16, f32); void setBaseMtx(); void deletePiyoPiyo(); - void init(); + BOOL init(); BOOL draw(); void animationPlay(); void checkPlayerRoom(); @@ -383,7 +471,7 @@ public: /* 0x04FC */ mDoExt_McaMorf2* mpMorf; /* 0x0500 */ mDoExt_McaMorf2* mpArmMorf; /* 0x0504 */ mDoExt_McaMorf* mpWingMorf; - /* 0x0508 */ u8 m0508[0x0520 - 0x0508]; + /* 0x0508 */ JPABaseEmitter* m0508[6]; /* 0x0520 */ mDoExt_btpAnm m0520; /* 0x0534 */ mDoExt_btkAnm mLightBtkAnm; /* 0x0548 */ u8 m0548[0x054C - 0x0548]; @@ -437,7 +525,9 @@ public: /* 0x3138 */ u8 m3138; /* 0x3139 */ u8 mCurEvent; /* 0x313A */ u8 m313A; - /* 0x313B */ u8 m313B[0x3140 - 0x313B]; + /* 0x313B */ u8 m313B[0x313D - 0x313B]; + /* 0x313D */ u8 m313D; + /* 0x313E */ u8 m313E[0x3140 - 0x313E]; /* 0x3140 */ bool m3140; /* 0x3141 */ u8 m3141[0x3144 - 0x3141]; /* 0x3144 */ s16 m3144; diff --git a/include/d/actor/d_a_player_main.h b/include/d/actor/d_a_player_main.h index 71405107a..c7999bbee 100644 --- a/include/d/actor/d_a_player_main.h +++ b/include/d/actor/d_a_player_main.h @@ -2458,9 +2458,9 @@ public: /* 0x3DB8 */ daPy_footData_c mFootData[2]; /* 0x3FE8 */ dCcD_Stts mStts; /* 0x4024 */ dCcD_Cyl mCyl; - /* 0x4154 */ dCcD_Cyl mWindCyl1; + /* 0x4154 */ dCcD_Cyl mWindCyl; /* 0x4284 */ dCcD_Cyl mAtCyl; - /* 0x43B4 */ dCcD_Cyl mWindCyl2; + /* 0x43B4 */ dCcD_Cyl mLightCyl; /* 0x44E4 */ dCcD_Cps mAtCps[3]; /* 0x488C */ dCcD_Cps mFanWindCps1; /* 0x49C4 */ dCcD_Sph mFanWindSph; diff --git a/include/d/d_com_inf_game.h b/include/d/d_com_inf_game.h index c04dfc10f..e0046a047 100644 --- a/include/d/d_com_inf_game.h +++ b/include/d/d_com_inf_game.h @@ -853,7 +853,7 @@ inline u8 dComIfGs_getReserveNum(int i_idx) { return g_dComIfG_gameInfo.save.getPlayer().getBagItemRecord().getReserveNum(i_idx); } -inline bool dComIfGs_checkReserveItemEmpty() { +inline u8 dComIfGs_checkReserveItemEmpty() { return g_dComIfG_gameInfo.save.getPlayer().getBagItem().checkReserveItemEmpty(); } @@ -977,6 +977,22 @@ inline void dComIfGs_setTurnRestart(const cXyz& i_pos, s16 i_angle, s8 i_roomNo, g_dComIfG_gameInfo.save.getTurnRestart().set(i_pos, i_angle, i_roomNo, i_param, i_pos, i_angle, 0); } +inline u8 dComIfGs_getPlayerPriestFlag() { + return g_dComIfG_gameInfo.save.getPlayer().getPriest().getFlag(); +} + +inline cXyz& dComIfGs_getPlayerPriestPos() { + return g_dComIfG_gameInfo.save.getPlayer().getPriest().getPos(); +} + +inline s16 dComIfGs_getPlayerPriestRotate() { + return g_dComIfG_gameInfo.save.getPlayer().getPriest().getRotate(); +} + +inline s8 dComIfGs_getPlayerPriestRoomNo() { + return g_dComIfG_gameInfo.save.getPlayer().getPriest().getRoomNo(); +} + inline void dComIfGs_setPlayerPriest(u8 i_option, cXyz& i_pos, s16 i_angle, s8 i_roomNo) { g_dComIfG_gameInfo.save.getPlayer().getPriest().set(i_option, i_pos, i_angle, i_roomNo); } diff --git a/include/d/d_npc.h b/include/d/d_npc.h index ed283b4d6..c9bdc4233 100644 --- a/include/d/d_npc.h +++ b/include/d/d_npc.h @@ -256,7 +256,7 @@ void dNpc_setShadowModel(J3DModel*, J3DModelData*, J3DModel*); cXyz dNpc_playerEyePos(f32); void dNpc_calc_DisXZ_AngY(cXyz, cXyz, float*, short*); bool dNpc_chkArasoi(); -BOOL dNpc_chkLetterPassed(); +bool dNpc_chkLetterPassed(); bool dNpc_setAnm_2(mDoExt_McaMorf* pMorf, int loopMode, f32 morf, f32 speed, int animFileIdx, int soundFileIdx, const char* arcName); #endif /* D_NPC_H */ diff --git a/include/d/d_particle.h b/include/d/d_particle.h index 8915f362a..2bd41d7e1 100644 --- a/include/d/d_particle.h +++ b/include/d/d_particle.h @@ -173,6 +173,11 @@ public: void execute(JPABaseEmitter*); void draw(JPABaseEmitter*); + JPABaseEmitter* getEmitter() { return mpBaseEmitter; } + void isStatus(u8) {} + void offStatus(int) {} + void onStatus(int) {} + void remove() { end(); } void setRate(f32 rate) { mRate = rate; } /* 0x04 */ JPABaseEmitter* mpBaseEmitter; diff --git a/include/d/d_save.h b/include/d/d_save.h index 746b4ce6a..1c7da0f23 100644 --- a/include/d/d_save.h +++ b/include/d/d_save.h @@ -316,6 +316,11 @@ public: void init(); void set(u8, cXyz&, s16, s8); + u8 getFlag() { return field_0xf; } + cXyz& getPos() { return field_0x0; } + s16 getRotate() { return field_0xc; } + s8 getRoomNo() { return field_0xe; } + /* 0x0 */ cXyz field_0x0; /* 0xC */ s16 field_0xc; /* 0xE */ s8 field_0xe; diff --git a/include/f_op/f_op_actor_mng.h b/include/f_op/f_op_actor_mng.h index 1c03be360..bda6eff81 100644 --- a/include/f_op/f_op_actor_mng.h +++ b/include/f_op/f_op_actor_mng.h @@ -384,8 +384,6 @@ void fopAcM_DeleteHeap(fopAc_ac_c* p_actor); s32 fopAcM_callCallback(fopAc_ac_c* p_actor, heapCallbackFunc p_callbackFunc, JKRHeap* p_heap); -bool fopAcM_entrySolidHeap_(fopAc_ac_c* p_actor, heapCallbackFunc p_heapCallback, u32 size); - bool fopAcM_entrySolidHeap(fopAc_ac_c* p_actor, heapCallbackFunc p_heapCallback, u32 size); inline void fopAcM_SetMin(fopAc_ac_c* p_actor, f32 minX, f32 minY, f32 minZ) { diff --git a/src/d/actor/d_a_agbsw0.cpp b/src/d/actor/d_a_agbsw0.cpp index 590ee46d3..ad52217e0 100644 --- a/src/d/actor/d_a_agbsw0.cpp +++ b/src/d/actor/d_a_agbsw0.cpp @@ -818,7 +818,7 @@ u32 daAgbsw0_c::TriforceCheck(daAgb_c* agb) { return agb->field_0x66d == 0x21 ? 0x30A : 0x30B; } else { - u8 num = dComIfGs_checkGetItemNum(0x1F); + u8 num = dComIfGs_checkGetItemNum(PENDANT); return num >= 0x14 ? 0x30C : 0x30D; } } diff --git a/src/d/actor/d_a_npc_md.cpp b/src/d/actor/d_a_npc_md.cpp index c71246c28..1f18a3c1a 100644 --- a/src/d/actor/d_a_npc_md.cpp +++ b/src/d/actor/d_a_npc_md.cpp @@ -9,6 +9,7 @@ #include "JSystem/JKernel/JKRHeap.h" #include "d/d_item_data.h" #include "m_Do/m_Do_controller_pad.h" +#include "m_Do/m_Do_mtx.h" // Needed for the .data section to match. static f32 dummy1[3] = {1.0f, 1.0f, 1.0f}; @@ -16,6 +17,8 @@ static f32 dummy2[3] = {1.0f, 1.0f, 1.0f}; static u8 dummy3[4] = {0x02, 0x00, 0x02, 0x01}; static f64 dummy4[2] = {3.0, 0.5}; +static daNpc_Md_HIO_c l_HIO; + static char* l_arc_name = "Md"; static char* l_arc_name_ship = "Md_ship"; static char* l_staff_name = "Md1"; @@ -153,16 +156,6 @@ static dCcD_SrcCyl l_wind_cyl_src = { }, }; -static char* hairName[] = { - "hair1", - "hair2", - "hair3", - "hair4", - "hair5", - "hair6", - "hair7", -}; - /* 000000EC-0000013C .text __ct__15daNpc_Md_HIO6_cFv */ daNpc_Md_HIO6_c::daNpc_Md_HIO6_c() { @@ -240,7 +233,7 @@ daNpc_Md_HIO_c::daNpc_Md_HIO_c() { m08C.m20 = 0x4000; m08C.m22 = 0x0; m08C.m24 = 150.0f; - m0B4 = 0x0; + mpActor = NULL; m0B8 = 770.0f; m0BC = 250.0f; m0C0 = -450.0f; @@ -371,22 +364,119 @@ static BOOL CheckCreateHeap(fopAc_ac_c* i_this) { /* 00000884-00000D80 .text create__10daNpc_Md_cFv */ s32 daNpc_Md_c::create() { - /* Nonmatching */ + m313D = 0; + strcpy(mModelArcName, l_arc_name); + int heapSizeIdx = 0; + fopAcM_SetupActor(this, daNpc_Md_c); + + m3138 = fopAcM_GetParam(this) >> 0x08; + if (m3138 == -2) { + dComIfGs_onEventBit(0x1620); + } else { + if (dComIfGs_isCollect(0, 2)) { + if (strcmp(dComIfGp_getStartStageName(), "M_DaiB") != 0) { + return cPhs_ERROR_e; + } else { + setTypeM_DaiB(); + } + } else if (strcmp(dComIfGp_getStartStageName(), "sea") == 0) { + if (dComIfGs_isEventBit(0x2E04) || !dComIfGs_isEventBit(0x1820) || !dComIfGs_isStageBossEnemy(3)) { + return cPhs_ERROR_e; + } + } else if (strcmp(dComIfGp_getStartStageName(), "Atorizk") == 0) { + if (dComIfGs_isEventBit(0x2E04) || dNpc_chkLetterPassed()) { + return cPhs_ERROR_e; + } + } else if (strcmp(dComIfGp_getStartStageName(), "Adanmae") == 0) { + if (dComIfGs_isEventBit(0x2E04) || !dNpc_chkLetterPassed()) { + return cPhs_ERROR_e; + } + } else if (strcmp(dComIfGp_getStartStageName(), "M_Dra09") == 0) { + if (dComIfGs_isEventBit(0x2E04) || dComIfGs_isEventBit(0x1101)) { + return cPhs_ERROR_e; + } + } else if (strcmp(dComIfGp_getStartStageName(), "Edaichi") == 0) { + if (!dComIfGs_isEventBit(0x2E04) || dComIfGs_isEventBit(0x2920)) { + return cPhs_ERROR_e; + } + setTypeEdaichi(); + } else if (strcmp(dComIfGp_getStartStageName(), "M_Dai") == 0) { + if (!dComIfGs_isEventBit(0x2E04) || !dComIfGs_isEventBit(0x2920)) { + return cPhs_ERROR_e; + } + setTypeM_Dai(); + } else if (strcmp(dComIfGp_getStartStageName(), "M_DaiB") == 0) { + return cPhs_ERROR_e; + } + } + + if (!dComIfGs_isEventBit(0x2E04) && dComIfGs_isEventBit(0x1608)) { + setTypeShipRide(); + strcpy(mModelArcName, l_arc_name_ship); + heapSizeIdx = 1; + } + + s32 phase_state = dComIfG_resLoad(&mPhs, mModelArcName); + m313D = 1; + if (phase_state == cPhs_COMPLEATE_e) { + if (dComIfGp_getCb1Player() != NULL) { + return cPhs_ERROR_e; + } + + static int l_heep_size[] = { + 0x7660, + 0x61C0, + }; + if (!fopAcM_entrySolidHeap(this, CheckCreateHeap, l_heep_size[heapSizeIdx])) { + mpMorf = NULL; + mpArmMorf = NULL; + mpWingMorf = NULL; + return cPhs_ERROR_e; + } + + if (m3138 == 5) { + u8 flag = dComIfGs_getPlayerPriestFlag(); + if (flag == 2) { + s8 roomNo = dComIfGs_getPlayerPriestRoomNo(); + s16 angle = dComIfGs_getPlayerPriestRotate(); + cXyz& pos = dComIfGs_getPlayerPriestPos(); + dComIfGs_setRestartOption(&pos, angle, roomNo, 2); + dComIfGs_setPlayerPriest(2, pos, angle, roomNo); + } + checkRestart(2); + } + + fopAcM_SetMtx(this, mpMorf->getModel()->getBaseTRMtx()); + + if (l_HIO.mChildID < 0) { + l_HIO.mChildID = mDoHIO_root.mDoHIO_createChild("リト族(メドリ)", &l_HIO); + l_HIO.mpActor = this; + } + + if (!init()) { + return cPhs_ERROR_e; + } + + setBaseMtx(); + fopAcM_setStageLayer(this); + } + + return phase_state; } /* 000012C0-00001444 .text nodeCallBack__FP7J3DNodei */ -static int nodeCallBack(J3DNode*, int) { +static BOOL nodeCallBack(J3DNode* node, int param_1) { /* Nonmatching */ } /* 00001444-0000154C .text waistNodeCallBack__FP7J3DNodei */ -static int waistNodeCallBack(J3DNode*, int) { +static BOOL waistNodeCallBack(J3DNode* node, int param_1) { /* Nonmatching */ } /* 0000154C-0000160C .text armNodeCallBack__FP7J3DNodei */ -static int armNodeCallBack(J3DNode*, int) { +static BOOL armNodeCallBack(J3DNode* node, int param_1) { /* Nonmatching */ } @@ -396,8 +486,18 @@ static void hairCross(cXyz*, cXyz*, cXyz*) { } /* 00001CBC-00001D0C .text hairTopNodeCallBack__FP7J3DNodei */ -static int hairTopNodeCallBack(J3DNode*, int) { - /* Nonmatching */ +static BOOL hairTopNodeCallBack(J3DNode* node, int param_1) { + if (!param_1) { + J3DModel* model = j3dSys.getModel(); + daNpc_Md_c* i_this = (daNpc_Md_c*)model->getUserArea(); + if (i_this) { + J3DJoint* joint = (J3DJoint*)node; + s32 jntNo = joint->getJntNo(); + MtxP mtx = model->getAnmMtx(jntNo); + i_this->m3174[0].set(mtx[0][3], mtx[1][3], mtx[2][3]); + } + } + return TRUE; } /* 00001D0C-00001F5C .text vecChange__FP4cXyzP4cXyzs */ @@ -406,10 +506,21 @@ static void vecChange(cXyz*, cXyz*, s16) { } /* 00001F5C-0000240C .text hairNodeCallBack__FP7J3DNodei */ -static int hairNodeCallBack(J3DNode*, int) { +static BOOL hairNodeCallBack(J3DNode* node, int param_1) { /* Nonmatching */ } +static char* hairName[] = { + "hair1", + "hair2", + "hair3", + "hair4", + "hair5", + "hair6", + "hair7", + "hair8", +}; + /* 0000240C-00002F80 .text createHeap__10daNpc_Md_cFv */ BOOL daNpc_Md_c::createHeap() { /* Nonmatching */ @@ -460,7 +571,7 @@ BOOL daNpc_Md_c::createHeap() { if (m_hair_jnt_nums[0] >= 0) { modelData->getJointNodePointer(m_hair_jnt_nums[0])->setCallBack(hairTopNodeCallBack); } - for (int i = 1; i < 8; i++) { + for (int i = 1; i < (int)ARRAY_SIZE(hairName); i++) { m_hair_jnt_nums[i] = modelData->getJointName()->getIndex(hairName[i]); if (m_hair_jnt_nums[i] >= 0) { modelData->getJointNodePointer(m_hair_jnt_nums[i])->setCallBack(hairNodeCallBack); @@ -1298,7 +1409,7 @@ void daNpc_Md_c::deletePiyoPiyo() { } /* 0000F160-0000F4E0 .text init__10daNpc_Md_cFv */ -void daNpc_Md_c::init() { +BOOL daNpc_Md_c::init() { /* Nonmatching */ } @@ -1339,7 +1450,24 @@ void daNpc_Md_c::emitterDelete(JPABaseEmitter**) { /* 000109DC-000110BC .text __dt__10daNpc_Md_cFv */ daNpc_Md_c::~daNpc_Md_c() { - /* Nonmatching */ + dComIfG_resDelete(&mPhs, mModelArcName); + if (heap) { + mpMorf->stopZelAnime(); + } + deletePiyoPiyo(); + emitterDelete(m0508); + deleteHane02Emitter(); + deleteHane03Emitter(); + m3058.end(); + m304C.end(); + m3074.remove(); + if (l_HIO.mChildID >= 0) { + mDoHIO_root.mDoHIO_deleteChild(l_HIO.mChildID); + l_HIO.mChildID = -1; + } + m_flying = false; + m_mirror = false; + m_playerRoom = false; } /* 000110BC-000110DC .text daNpc_Md_Create__FP10fopAc_ac_c */ @@ -1369,18 +1497,23 @@ static BOOL daNpc_Md_IsDelete(daNpc_Md_c* i_this) { } /* 0001114C-0001119C .text execute__26daNpc_Md_followEcallBack_cFP14JPABaseEmitter */ -void daNpc_Md_followEcallBack_c::execute(JPABaseEmitter*) { - /* Nonmatching */ +void daNpc_Md_followEcallBack_c::execute(JPABaseEmitter* emitter) { + emitter->setGlobalTranslation(mPos.x, mPos.y, mPos.z); + JPAGetXYZRotateMtx(mAngle.x, mAngle.y, mAngle.z, emitter->mGlobalRotation); } /* 0001119C-000111A4 .text setup__26daNpc_Md_followEcallBack_cFP14JPABaseEmitterPC4cXyzPC5csXyzSc */ -void daNpc_Md_followEcallBack_c::setup(JPABaseEmitter*, const cXyz*, const csXyz*, s8) { - /* Nonmatching */ +void daNpc_Md_followEcallBack_c::setup(JPABaseEmitter* emitter, const cXyz*, const csXyz*, s8) { + mpEmitter = emitter; } /* 000111A4-000111D8 .text end__26daNpc_Md_followEcallBack_cFv */ void daNpc_Md_followEcallBack_c::end() { - /* Nonmatching */ + if (mpEmitter) { + mpEmitter->becomeInvalidEmitter(); + mpEmitter->setEmitterCallBackPtr(NULL); + mpEmitter = NULL; + } } static actor_method_class l_daNpc_Md_Method = { diff --git a/src/d/actor/d_a_player_main.cpp b/src/d/actor/d_a_player_main.cpp index 192cb6a24..d63936a17 100644 --- a/src/d/actor/d_a_player_main.cpp +++ b/src/d/actor/d_a_player_main.cpp @@ -4604,11 +4604,11 @@ void daPy_lk_c::playerInit() { mCyl.OnTgShieldFrontRange(); mShieldFrontRangeYAngle = shape_angle.y + mBodyAngle.y; mCyl.SetTgShieldFrontRangeYAngle(&mShieldFrontRangeYAngle); - mWindCyl1.Set(l_wind_cyl_src); - mWindCyl1.SetStts(&mStts); - mWindCyl2.Set(l_wind_cyl_src); - mWindCyl2.SetStts(&mStts); - mWindCyl2.SetTgType(AT_TYPE_LIGHT); + mWindCyl.Set(l_wind_cyl_src); + mWindCyl.SetStts(&mStts); + mLightCyl.Set(l_wind_cyl_src); + mLightCyl.SetStts(&mStts); + mLightCyl.SetTgType(AT_TYPE_LIGHT); mAtCps[0].Set(l_at_cps_src); mAtCps[0].SetStts(&mStts); mAtCps[1].Set(l_at_cps_src); diff --git a/src/d/d_kankyo_dayproc.inc b/src/d/d_kankyo_dayproc.inc index 318f952bf..dea09c45b 100644 --- a/src/d/d_kankyo_dayproc.inc +++ b/src/d/d_kankyo_dayproc.inc @@ -2,6 +2,7 @@ #include "d/d_com_inf_game.h" #include "d/d_letter.h" #include "SSystem/SComponent/c_lib.h" +#include "d/d_item_data.h" /* 80197AB8-80197FE4 .text dKankyo_DayProc__Fv */ static void dKankyo_DayProc() { @@ -17,11 +18,15 @@ static void dKankyo_DayProc() { dLetter_delivery(0xaf03); dLetter_delivery(0x9d03); - dComIfGs_setEventReg(0xcf03, cLib_maxLimit(dComIfGs_getEventReg(0xcf03) + 1, 3)); - dComIfGs_setEventReg(0xab03, cLib_maxLimit(dComIfGs_getEventReg(0xab03) + 1, 3)); + u8 clamped = cLib_maxLimit(dComIfGs_getEventReg(0xcf03) + 1, 3); + dComIfGs_setEventReg(0xcf03, clamped); + clamped = cLib_maxLimit(dComIfGs_getEventReg(0xab03) + 1, 3); + dComIfGs_setEventReg(0xab03, clamped); - if (dComIfGs_isGetItemReserve(0x0F) && !dComIfGs_checkReserveItem(0x9B)) - dComIfGs_setEventReg(0xccff, cLib_maxLimit(dComIfGs_getEventReg(0xccff) + 1, 2)); + if (dComIfGs_isGetItemReserve(0x0F) && dComIfGs_checkReserveItem(MO_LETTER) == 0) { + clamped = cLib_maxLimit(dComIfGs_getEventReg(0xccff) + 1, 2); + dComIfGs_setEventReg(0xccff, clamped); + } dComIfGs_setEventReg(0xbcff, 0); dComIfGs_setEventReg(0xcb03, 0); @@ -51,7 +56,8 @@ static void dKankyo_DayProc() { if (reg == 7) { dComIfGs_onEventBit(0x1f08); } else { - dComIfGs_setEventReg(0xbb07, cLib_maxLimit(reg + 1, 7)); + clamped = cLib_maxLimit(reg + 1, 7); + dComIfGs_setEventReg(0xbb07, clamped); } } @@ -64,8 +70,10 @@ static void dKankyo_DayProc() { dComIfGs_offEventBit(0x2680); - if (dComIfGs_isEventBit(0x2a20)) - dComIfGs_setEventReg(0xa60f, cLib_maxLimit(dComIfGs_getEventReg(0xa60f) + 1, 3)); + if (dComIfGs_isEventBit(0x2a20)) { + clamped = cLib_maxLimit(dComIfGs_getEventReg(0xa60f) + 1, 3); + dComIfGs_setEventReg(0xa60f, clamped); + } if (dKy_get_dayofweek() == 5) { dComIfGs_offEventBit(0x2080); diff --git a/src/d/d_npc.cpp b/src/d/d_npc.cpp index 980953705..b17dd3776 100644 --- a/src/d/d_npc.cpp +++ b/src/d/d_npc.cpp @@ -11,6 +11,7 @@ #include "SSystem/SComponent/c_math.h" #include "JSystem/JGeometry.h" #include "m_Do/m_Do_mtx.h" +#include "d/d_item_data.h" // Needed for the .data section to match. static Vec dummy_2100 = {1.0f, 1.0f, 1.0f}; @@ -628,12 +629,12 @@ bool dNpc_chkArasoi() { return dComIfGs_isEventBit(0x1220) && !dComIfGs_isEventBit(0x1808); } -BOOL dNpc_chkLetterPassed() { - BOOL ret = false; +/* 8021BF30-8021BF98 .text dNpc_chkLetterPassed__Fv */ +bool dNpc_chkLetterPassed() { + bool ret = false; if(dComIfGs_isGetItemReserve(0xC)) { - ret = dComIfGs_checkReserveItem(0x98) ? 0 : 1; + ret = dComIfGs_checkReserveItem(LETTER00) == 0; } - return ret; } diff --git a/src/d/d_shop.cpp b/src/d/d_shop.cpp index bea516211..a6786fff3 100644 --- a/src/d/d_shop.cpp +++ b/src/d/d_shop.cpp @@ -1321,7 +1321,7 @@ BOOL dShop_maxCheck(int itemNo, int) { } // Bug: This check is probably supposed to be (itemNo >= FLOWER_1 && itemNo <= PRESIDENT_STATUE) } else if (itemNo == FLOWER_1 && itemNo == PRESIDENT_STATUE) { - if (!dComIfGs_checkReserveItemEmpty()) { + if (dComIfGs_checkReserveItemEmpty() == 0) { return TRUE; } } else if (itemNo >= ARROW_10 && itemNo <= ARROW_30) {