From 06709dad7ff78794ac56d941f24f2a8d3d992432 Mon Sep 17 00:00:00 2001 From: LagoLunatic Date: Sat, 28 Dec 2024 18:58:57 -0500 Subject: [PATCH] d_a_obj_toripost documentation, d_a_rd wrong name fixes --- include/d/actor/d_a_obj_toripost.h | 39 +++++++-- include/d/actor/d_a_rd.h | 2 +- src/d/actor/d_a_obj_toripost.cpp | 125 +++++++++++++++-------------- src/d/actor/d_a_rd.cpp | 24 +++--- 4 files changed, 109 insertions(+), 81 deletions(-) diff --git a/include/d/actor/d_a_obj_toripost.h b/include/d/actor/d_a_obj_toripost.h index 91d9bfd84..cb5638805 100644 --- a/include/d/actor/d_a_obj_toripost.h +++ b/include/d/actor/d_a_obj_toripost.h @@ -18,10 +18,33 @@ class daObjTpost_c : public fopNpc_npc_c { PROC_EXEC = 1 }; - void eventSet(s8) {} + enum Mode { + MODE_WAIT = 0x0, + MODE_TALK = 0x1, + MODE_TALK_XY = 0x2, + MODE_RECEIVE = 0x3, + MODE_RECEIVE_DEMO = 0x4, + MODE_NULL, + }; + + enum BckIdx { + BckIdx_POST_GET = 0x0, + BckIdx_POST_PUTOUT = 0x1, + BckIdx_POST_WAIT = 0x2, + }; + + enum AnmPrm { + AnmPrm_POST_GET0 = 0x1, + AnmPrm_POST_GET1 = 0x2, + AnmPrm_POST_PUTOUT = 0x3, + AnmPrm_POST_WAIT = 0x4, + AnmPrm_NULL, + }; + + void eventSet(s8 eventIdx) { mEventIdx = eventIdx; } s32 getSendPrice() { return m_send_price[mPayType]; } - void isAnm(s8) {} - void modeProcInit(int) {} + bool isAnm(s8 idx) { return mAnmPrmIdx == idx; } + void modeProcInit(int newMode) { modeProc(PROC_INIT, newMode); } BOOL _createHeap(); void cutProc(); @@ -72,9 +95,9 @@ class daObjTpost_c : public fopNpc_npc_c { static const s32 m_send_price[]; /* 0x6C4 */ u32 mCurMode; - /* 0x6C8 */ s8 field_0x6C8; - /* 0x6C9 */ s8 field_0x6C9; - /* 0x6CA */ s8 field_0x6CA; + /* 0x6C8 */ s8 mBckIdx; + /* 0x6C9 */ s8 mAnmPrmIdx; + /* 0x6CA */ s8 mOldAnmPrmIdx; /* 0x6CC */ request_of_phase_process_class mPhs; /* 0x6D4 */ mDoExt_McaMorf* mMorf; /* 0x6D8 */ dBgS_ObjAcch mAcch; @@ -86,12 +109,12 @@ class daObjTpost_c : public fopNpc_npc_c { /* 0x8E9 */ u8 field_0x8E9; /* 0x8EA */ u8 field_0x8EA; /* 0x8EB */ u8 field_0x8EB; - /* 0x8EC */ s32 mNumReadable; + /* 0x8EC */ int mNumReadable; /* 0x8F0 */ u32 field_0x8F0; /* 0x8F4 */ u8 field_0x8F4; /* 0x8F5 */ u8 field_0x8F5; /* 0x8F6 */ u8 mPreItemNo; - /* 0x8F7 */ s8 field_0x8F7; + /* 0x8F7 */ s8 mEventIdx; }; class daObjTpost_HIO_c { diff --git a/include/d/actor/d_a_rd.h b/include/d/actor/d_a_rd.h index bd94f0126..8f72254f8 100644 --- a/include/d/actor/d_a_rd.h +++ b/include/d/actor/d_a_rd.h @@ -197,7 +197,7 @@ class daRd_c : public fopEn_enemy_c { /* 0x6D4 */ int m6D4; /* 0x6D8 */ s8 mBckIdx; /* 0x6D9 */ s8 mAnmPrmIdx; - /* 0x6DA */ s8 m6DA; + /* 0x6DA */ s8 mOldAnmPrmIdx; /* 0x6DB */ s8 m6DB; /* 0x6DC */ s8 m6DC; /* 0x6DD */ u8 m6DD[0x6E0 - 0x6DD]; diff --git a/src/d/actor/d_a_obj_toripost.cpp b/src/d/actor/d_a_obj_toripost.cpp index a5dc57dd0..d31c8f8d3 100644 --- a/src/d/actor/d_a_obj_toripost.cpp +++ b/src/d/actor/d_a_obj_toripost.cpp @@ -185,10 +185,10 @@ void daObjTpost_c::cutPresentProc(int staffIdx) { void daObjTpost_c::cutSetAnmStart(int staffIdx) { const char* name = dComIfGp_evmng_getMyStringP(staffIdx, "Name"); if(name != 0 && strcmp(name, "HAKIDASU") == 0) { - setAnm(3, false); + setAnm(AnmPrm_POST_PUTOUT, false); } else { - setAnm(1, false); + setAnm(AnmPrm_POST_GET0, false); } } @@ -230,7 +230,7 @@ void daObjTpost_c::deliverLetter() { /* 00000650-000006C0 .text getReceiveLetterNum__12daObjTpost_cFv */ s16 daObjTpost_c::getReceiveLetterNum() { s16 num = 0; - for(int i = 1; i < 0xD; i++) { + for(int i = 1; i < (int)ARRAY_SIZE(m_letter); i++) { if(dLetter_isStock(m_letter[i].mEventReg)) { num = num + 1; } @@ -242,12 +242,12 @@ s16 daObjTpost_c::getReceiveLetterNum() { /* 000006C0-00000750 .text getReadableLetterNum__12daObjTpost_cFv */ s32 daObjTpost_c::getReadableLetterNum() { s32 num = 0; - s32 startIdx = mNumReadable ? mNumReadable : 1; + s32 startIdx = mNumReadable != 0 ? mNumReadable : 1; s32 readable = mNumReadable; - if(readable < 0xD) { - for(int i = startIdx; i < 0xD; i++) { - if(dLetter_isStock(m_letter[i].mEventReg) == 0) { + if(readable < (int)ARRAY_SIZE(m_letter)) { + for(int i = startIdx; i < (int)ARRAY_SIZE(m_letter); i++) { + if(!dLetter_isStock(m_letter[i].mEventReg)) { continue; } @@ -342,13 +342,13 @@ int daObjTpost_c::getMsgXY() { break; case dItem_FATHER_LETTER_e: case MO_LETTER: - setAnm(3, false); + setAnm(AnmPrm_POST_PUTOUT, false); field_0x8EA = 1; msgId = 0xCEA; break; default: - setAnm(3, false); + setAnm(AnmPrm_POST_PUTOUT, false); field_0x8EA = 1; msgId = 0xCE9; @@ -400,7 +400,7 @@ u16 daObjTpost_c::next_msgStatus(u32* pMsgNo) { switch(*pMsgNo) { case 0xCE5: case 0xCE6: - if(mNumReadable) { + if(mNumReadable != 0) { dComIfGp_setMessageCountNumber(getReceiveLetterNum()); *pMsgNo = 0xCEB; } @@ -408,13 +408,13 @@ u16 daObjTpost_c::next_msgStatus(u32* pMsgNo) { *pMsgNo = 0xCE7; } - break; + break; case 0xCEB: dComIfGp_setMessageCountNumber(field_0x8F0); *pMsgNo = 0xCF7; break; case 0xCF7: - if(l_HIO.field_0x07 != 0 || m_letter[mNumReadable].field_0x00 != 0) { + if(l_HIO.field_0x07 != 0 || m_letter[mNumReadable].field_0x00) { *pMsgNo = 0xCF3; } else { @@ -442,13 +442,13 @@ u16 daObjTpost_c::next_msgStatus(u32* pMsgNo) { *pMsgNo = 0xCF2; } else { - setAnm(3, false); + setAnm(AnmPrm_POST_PUTOUT, false); field_0x8EA = 1; *pMsgNo = 0xCF1; } } else { - setAnm(3, false); + setAnm(AnmPrm_POST_PUTOUT, false); field_0x8EA = 1; *pMsgNo = 0xCF0; } @@ -489,7 +489,7 @@ u16 daObjTpost_c::next_msgStatus(u32* pMsgNo) { mNumReadable += 1; field_0x8F0 += 1; mNumReadable = getReadableLetterNum(); - if(mNumReadable) { + if(mNumReadable != 0) { dComIfGp_setMessageCountNumber(field_0x8F0); *pMsgNo = 0xCF7; } @@ -521,29 +521,29 @@ void daObjTpost_c::eventOrder() { "DEFAULT_POST" }; - if(field_0x8F7 == 1 || field_0x8F7 == 2) { + if(mEventIdx == 1 || mEventIdx == 2) { eventInfo.onCondition(dEvtCnd_CANTALK_e); eventInfo.onCondition(dEvtCnd_CANTALKITEM_e); - if(field_0x8F7 == 1) { + if(mEventIdx == 1) { fopAcM_orderSpeakEvent(this); } } - else if(field_0x8F7 >= 3) { - fopAcM_orderOtherEvent(this, a_demo_name_tbl[field_0x8F7 - 3], 0x14F); + else if(mEventIdx >= 3) { + fopAcM_orderOtherEvent(this, a_demo_name_tbl[mEventIdx - 3], 0x14F); } } /* 00000DC0-00000E48 .text checkOrder__12daObjTpost_cFv */ void daObjTpost_c::checkOrder() { if(eventInfo.checkCommandDemoAccrpt()) { - field_0x8F7 = 0; + eventSet(0); return; } if(eventInfo.checkCommandTalk()) { - if(field_0x8F7 == 1 || field_0x8F7 == 2) { - field_0x8F7 = 0; + if(mEventIdx == 1 || mEventIdx == 2) { + eventSet(0); if(dComIfGp_event_chkTalkXY()) { field_0x8F5 = 1; } @@ -565,7 +565,7 @@ void daObjTpost_c::setAttention() { } /* 00000EA4-0000100C .text setAnm__12daObjTpost_cFScb */ -void daObjTpost_c::setAnm(s8 param_1, bool param_2) { +void daObjTpost_c::setAnm(s8 anmPrmIdx, bool param_2) { static const int a_anm_bcks_tbl[] = { TORIPOST_BCK_POST_GET, TORIPOST_BCK_POST_PUTOUT, @@ -573,6 +573,7 @@ void daObjTpost_c::setAnm(s8 param_1, bool param_2) { }; static const dLib_anm_prm_c a_anm_prm_tbl[] = { { + // Unused entry /* mBckIdx */ -1, /* mNextPrmIdx */ -1, /* field_0x02 */ 0, @@ -581,7 +582,8 @@ void daObjTpost_c::setAnm(s8 param_1, bool param_2) { /* mLoopMode */ J3DFrameCtrl::LOOP_REPEAT_e }, { - /* mBckIdx */ 0, + // AnmPrm_POST_GET0 + /* mBckIdx */ BckIdx_POST_GET, /* mNextPrmIdx */ -1, /* field_0x02 */ 0, /* mMorf */ 8.0f, @@ -589,7 +591,8 @@ void daObjTpost_c::setAnm(s8 param_1, bool param_2) { /* mLoopMode */ J3DFrameCtrl::LOOP_ONCE_e }, { - /* mBckIdx */ 0, + // AnmPrm_POST_GET1 + /* mBckIdx */ BckIdx_POST_GET, /* mNextPrmIdx */ -1, /* field_0x02 */ 0, /* mMorf */ 8.0f, @@ -597,7 +600,8 @@ void daObjTpost_c::setAnm(s8 param_1, bool param_2) { /* mLoopMode */ J3DFrameCtrl::LOOP_ONCE_e }, { - /* mBckIdx */ 1, + // AnmPrm_POST_PUTOUT + /* mBckIdx */ BckIdx_POST_PUTOUT, /* mNextPrmIdx */ -1, /* field_0x02 */ 0, /* mMorf */ 8.0f, @@ -605,7 +609,8 @@ void daObjTpost_c::setAnm(s8 param_1, bool param_2) { /* mLoopMode */ J3DFrameCtrl::LOOP_ONCE_e }, { - /* mBckIdx */ 2, + // AnmPrm_POST_WAIT + /* mBckIdx */ BckIdx_POST_WAIT, /* mNextPrmIdx */ -1, /* field_0x02 */ 0, /* mMorf */ 8.0f, @@ -614,15 +619,15 @@ void daObjTpost_c::setAnm(s8 param_1, bool param_2) { }, }; - if(param_1 != 5) { - field_0x6C9 = param_1; + if(anmPrmIdx != AnmPrm_NULL) { + mAnmPrmIdx = anmPrmIdx; } - if(field_0x6C8 == 0 && mMorf->getFrame() == 1.0f) { + if(mBckIdx == BckIdx_POST_GET && mMorf->getFrame() == 1.0f) { mDoAud_seStart(JA_SE_OBJ_POST_EAT_LUGGAGE); } - if(field_0x6C8 == 1) { + if(mBckIdx == BckIdx_POST_PUTOUT) { cXyz scale; scale.setall(1.0f); if(mMorf->getFrame() == 1.0f) { @@ -631,7 +636,7 @@ void daObjTpost_c::setAnm(s8 param_1, bool param_2) { } } - dLib_bcks_setAnm(m_arc_name, mMorf, &field_0x6C8, &field_0x6C9, &field_0x6CA, a_anm_bcks_tbl, a_anm_prm_tbl, param_2); + dLib_bcks_setAnm(m_arc_name, mMorf, &mBckIdx, &mAnmPrmIdx, &mOldAnmPrmIdx, a_anm_bcks_tbl, a_anm_prm_tbl, param_2); } /* 0000100C-00001094 .text setMtx__12daObjTpost_cFv */ @@ -647,33 +652,33 @@ void daObjTpost_c::setMtx() { /* 00001094-000010E0 .text modeWaitInit__12daObjTpost_cFv */ void daObjTpost_c::modeWaitInit() { field_0x8F0 = 1; - if(mNumReadable) { - setAnm(4, false); + if(mNumReadable != 0) { + setAnm(AnmPrm_POST_WAIT, false); } else { - setAnm(1, false); + setAnm(AnmPrm_POST_GET0, false); } } /* 000010E0-00001188 .text modeWait__12daObjTpost_cFv */ void daObjTpost_c::modeWait() { - if(mNumReadable) { - setAnm(4, false); + if(mNumReadable != 0) { + setAnm(AnmPrm_POST_WAIT, false); } else { - setAnm(1, false); + setAnm(AnmPrm_POST_GET0, false); } if(field_0x8F4) { - modeProc(PROC_INIT, 1); + modeProcInit(MODE_TALK); } else { if(field_0x8F5) { - modeProc(PROC_INIT, 2); + modeProcInit(MODE_TALK_XY); } else { if(checkTalk()) { - field_0x8F7 = 2; + eventSet(2); } } } @@ -681,18 +686,18 @@ void daObjTpost_c::modeWait() { /* 00001188-000011B0 .text modeTalkInit__12daObjTpost_cFv */ void daObjTpost_c::modeTalkInit() { - setAnm(1, false); + setAnm(AnmPrm_POST_GET0, false); } /* 000011B0-00001240 .text modeTalk__12daObjTpost_cFv */ void daObjTpost_c::modeTalk() { if(talk(1) == fopMsgStts_BOX_CLOSED_e) { if(field_0x8E9) { - modeProc(PROC_INIT, 3); + modeProcInit(MODE_RECEIVE); field_0x8E9 = 0; } else { - modeProc(PROC_INIT, 0); + modeProcInit(MODE_WAIT); } dComIfGp_event_reset(); @@ -702,7 +707,7 @@ void daObjTpost_c::modeTalk() { /* 00001240-0000129C .text modeTalkXYInit__12daObjTpost_cFv */ void daObjTpost_c::modeTalkXYInit() { - setAnm(1, false); + setAnm(AnmPrm_POST_GET0, false); mPreItemNo = dComIfGp_event_getPreItemNo(); field_0x8DC = l_HIO.field_0x14; field_0x8E0 = l_HIO.field_0x16; @@ -711,7 +716,7 @@ void daObjTpost_c::modeTalkXYInit() { /* 0000129C-00001490 .text modeTalkXY__12daObjTpost_cFv */ void daObjTpost_c::modeTalkXY() { daPy_py_c* player = daPy_getPlayerActorClass(); - if(field_0x6C9 == 3) { + if(isAnm(AnmPrm_POST_PUTOUT)) { if(field_0x8EA != 0) { field_0x8E4 = 10; field_0x8EA = 0; @@ -740,15 +745,15 @@ void daObjTpost_c::modeTalkXY() { } } - if(field_0x6C9 == 1 && dComIfGp_evmng_ChkPresentEnd() && cLib_calcTimer(&field_0x8E0) == 0) { + if(isAnm(AnmPrm_POST_GET0) && dComIfGp_evmng_ChkPresentEnd() && cLib_calcTimer(&field_0x8E0) == 0) { dComIfGp_evmng_CancelPresent(); - setAnm(2, false); + setAnm(AnmPrm_POST_GET1, false); } - if(field_0x6C9 == 2 || field_0x6C9 == 3) { + if(isAnm(AnmPrm_POST_GET1) || isAnm(AnmPrm_POST_PUTOUT)) { if(mMorf->isStop()) { if(cLib_calcTimer(&field_0x8DC) == 0 && talk(1) == fopMsgStts_BOX_CLOSED_e) { - modeProc(PROC_INIT, 0); + modeProcInit(MODE_WAIT); dComIfGp_event_reset(); field_0x8F5 = 0; } @@ -759,13 +764,13 @@ void daObjTpost_c::modeTalkXY() { /* 00001490-000014D4 .text modeReceiveInit__12daObjTpost_cFv */ void daObjTpost_c::modeReceiveInit() { dComIfGp_event_reset(); - field_0x8F7 = 3; - setAnm(1, false); + eventSet(3); + setAnm(AnmPrm_POST_GET0, false); } /* 000014D4-000014FC .text modeReceive__12daObjTpost_cFv */ void daObjTpost_c::modeReceive() { - modeProc(PROC_INIT, 4); + modeProcInit(MODE_RECEIVE_DEMO); } /* 000014FC-00001500 .text modeReceiveDemoInit__12daObjTpost_cFv */ @@ -781,13 +786,13 @@ void daObjTpost_c::modeReceiveDemo() { dComIfGp_event_reset(); if(mNumReadable != 0) { - modeProc(PROC_INIT, 1); - field_0x8F7 = 1; + modeProcInit(MODE_TALK); + eventSet(1); field_0x8EB = 1; field_0x8F0 += 1; } else { - modeProc(PROC_INIT, 0); + modeProcInit(MODE_WAIT); field_0x8F0 = 1; } } @@ -851,7 +856,7 @@ bool daObjTpost_c::_execute() { checkOrder(); setAttention(); setCollision(40.0f, 140.0f); - modeProc(PROC_EXEC, 5); + modeProc(PROC_EXEC, MODE_NULL); if(dComIfGp_event_runCheck() && !mEventCut.cutProc()) { cutProc(); @@ -870,7 +875,7 @@ bool daObjTpost_c::_execute() { mMorf->play(0, 0, 0); mMorf->calc(); setMtx(); - setAnm(5, false); + setAnm(AnmPrm_NULL, false); return 0; } @@ -925,7 +930,7 @@ void daObjTpost_c::createInit() { attention_info.distances[fopAc_Attn_TYPE_SPEAK_e] = 6; attention_info.flags = fopAc_Attn_LOCKON_TALK_e | fopAc_Attn_ACTION_SPEAK_e | fopAc_Attn_TALKFLAG_CHECK_e; - setAnm(1, false); + setAnm(AnmPrm_POST_GET0, false); setMtx(); mMorf->calc(); @@ -938,7 +943,7 @@ void daObjTpost_c::createInit() { mCyl.SetStts(&mStts); mPayType = checkSendPrice(); - modeProc(PROC_INIT, 0); + modeProcInit(MODE_WAIT); mAcchCir.SetWall(30.0f, 30.0f); mAcch.Set(¤t.pos, &old.pos, this, 1, &mAcchCir, &speed); diff --git a/src/d/actor/d_a_rd.cpp b/src/d/actor/d_a_rd.cpp index 2eb669814..bb8e51b0a 100644 --- a/src/d/actor/d_a_rd.cpp +++ b/src/d/actor/d_a_rd.cpp @@ -1348,12 +1348,12 @@ void daRd_c::setBtkAnm(s8 idx) { RD_BTK_RD_OPEN, RD_BTK_RD_CLOSE, }; - struct play_prm_struct { + struct anm_prm_struct { s8 m00; s8 m01; int loopMode; }; - static const play_prm_struct a_play_prm_tbl[] = { + static const anm_prm_struct a_anm_prm_tbl[] = { {0x01, -1, J3DFrameCtrl::LOOP_ONCE_e}, {0x00, -1, J3DFrameCtrl::LOOP_REPEAT_e}, {0x01, -1, J3DFrameCtrl::LOOP_REPEAT_e}, @@ -1365,16 +1365,16 @@ void daRd_c::setBtkAnm(s8 idx) { m6DB = idx; } - int r5 = a_play_prm_tbl[m6DB].m00; + int r5 = a_anm_prm_tbl[m6DB].m00; if (m6DC != m6DB && r5 != -1) { J3DAnmTextureSRTKey* btk = static_cast(dComIfG_getObjectRes(m_arc_name, a_anm_idx_tbl[r5])); JUT_ASSERT(1930, btk != NULL); J3DModelData* modelData = mpMorf->getModel()->getModelData(); - mBtkAnm.init(modelData, btk, true, a_play_prm_tbl[m6DB].loopMode, 1.0f, 0, -1, true, 0); + mBtkAnm.init(modelData, btk, true, a_anm_prm_tbl[m6DB].loopMode, 1.0f, 0, -1, true, 0); if (mBtkAnm.isStop()) { - if (a_play_prm_tbl[m6DB].m01 != -1 && a_play_prm_tbl[m6DB].loopMode == J3DFrameCtrl::LOOP_ONCE_e) { - m6DB = a_play_prm_tbl[m6DB].m01; + if (a_anm_prm_tbl[m6DB].m01 != -1 && a_anm_prm_tbl[m6DB].loopMode == J3DFrameCtrl::LOOP_ONCE_e) { + m6DB = a_anm_prm_tbl[m6DB].m01; } } } @@ -1383,7 +1383,7 @@ void daRd_c::setBtkAnm(s8 idx) { } /* 00003B3C-00003C48 .text setAnm__6daRd_cFScb */ -void daRd_c::setAnm(s8 anmIdx, bool param_2) { +void daRd_c::setAnm(s8 anmPrmIdx, bool param_2) { static const int a_anm_bcks_tbl[] = { RD_BCK_TACHIP, RD_BCK_SUWARIP, @@ -1538,11 +1538,11 @@ void daRd_c::setAnm(s8 anmIdx, bool param_2) { }, }; - if (anmIdx != AnmPrm_NULL) { - mAnmPrmIdx = anmIdx; + if (anmPrmIdx != AnmPrm_NULL) { + mAnmPrmIdx = anmPrmIdx; } - if (m6DA != mAnmPrmIdx) { + if (mOldAnmPrmIdx != mAnmPrmIdx) { if (isAnm(AnmPrm_BEAM_HIT)) { setBrkAnm(0x1); } else if (isAnm(AnmPrm_BEAM)) { @@ -1554,11 +1554,11 @@ void daRd_c::setAnm(s8 anmIdx, bool param_2) { } } - if (mBckIdx == RD_BCK_DAMAGE || mBckIdx == RD_BCK_DEAD || mBckIdx == RD_BCK_IKARI_SAMPLE) { + if (mBckIdx == BckIdx_BEAM_HIT || mBckIdx == BckIdx_BEAM || mBckIdx == BckIdx_BEAM_END) { mBrkAnm.setFrame(mpMorf->getFrame()); } - dLib_bcks_setAnm(m_arc_name, mpMorf, &mBckIdx, &mAnmPrmIdx, &m6DA, a_anm_bcks_tbl, a_anm_prm_tbl, param_2); + dLib_bcks_setAnm(m_arc_name, mpMorf, &mBckIdx, &mAnmPrmIdx, &mOldAnmPrmIdx, a_anm_bcks_tbl, a_anm_prm_tbl, param_2); } /* 00003C48-000040A8 .text _execute__6daRd_cFv */