d_insect first pass (#219)

* dInsect_c::dInsect_c

* dInsect_c::Insect_GetDemoMain attempt

* dInsect_c::CalcZBuffer attempt

* remove asm

* convert clib inlines to template functions
This commit is contained in:
Pheenoh 2022-12-26 10:55:53 -07:00 committed by GitHub
parent 8516f01f79
commit 8b0ee4d50b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 148 additions and 86 deletions

View File

@ -1,27 +0,0 @@
lbl_8015E010:
/* 8015E010 94 21 FF F0 */ stwu r1, -0x10(r1)
/* 8015E014 7C 08 02 A6 */ mflr r0
/* 8015E018 90 01 00 14 */ stw r0, 0x14(r1)
/* 8015E01C 93 E1 00 0C */ stw r31, 0xc(r1)
/* 8015E020 7C 7F 1B 78 */ mr r31, r3
/* 8015E024 4B EB AB 41 */ bl __ct__10fopAc_ac_cFv
/* 8015E028 3C 60 80 3C */ lis r3, __vt__9dInsect_c@ha /* 0x803BA078@ha */
/* 8015E02C 38 03 A0 78 */ addi r0, r3, __vt__9dInsect_c@l /* 0x803BA078@l */
/* 8015E030 90 1F 05 68 */ stw r0, 0x568(r31)
/* 8015E034 38 00 FF FF */ li r0, -1
/* 8015E038 90 1F 05 88 */ stw r0, 0x588(r31)
/* 8015E03C 38 60 00 00 */ li r3, 0
/* 8015E040 98 7F 05 6C */ stb r3, 0x56c(r31)
/* 8015E044 38 00 00 01 */ li r0, 1
/* 8015E048 98 1F 05 6D */ stb r0, 0x56d(r31)
/* 8015E04C 90 7F 05 8C */ stw r3, 0x58c(r31)
/* 8015E050 38 00 00 D6 */ li r0, 0xd6
/* 8015E054 98 1F 05 80 */ stb r0, 0x580(r31)
/* 8015E058 98 7F 05 84 */ stb r3, 0x584(r31)
/* 8015E05C 98 7F 05 85 */ stb r3, 0x585(r31)
/* 8015E060 7F E3 FB 78 */ mr r3, r31
/* 8015E064 83 E1 00 0C */ lwz r31, 0xc(r1)
/* 8015E068 80 01 00 14 */ lwz r0, 0x14(r1)
/* 8015E06C 7C 08 03 A6 */ mtlr r0
/* 8015E070 38 21 00 10 */ addi r1, r1, 0x10
/* 8015E074 4E 80 00 20 */ blr

View File

@ -36,13 +36,18 @@ s16 cLib_targetAngleX(const cXyz*, const cXyz*);
void cLib_offsetPos(cXyz* pDest, cXyz const* pSrc, s16 angle, cXyz const* vec);
s32 cLib_distanceAngleS(s16 x, s16 y);
inline void cLib_offBit(u8& value, u8 bit) {
template <typename T>
inline void cLib_offBit(T& value, u8 bit) {
value &= ~bit;
}
inline void cLib_onBit(u8& value, u8 bit) {
template <typename T>
inline void cLib_onBit(T& value, u8 bit) {
value |= bit;
}
inline u8 cLib_checkBit(u8& value, u8 bit) {
template <typename T>
inline T cLib_checkBit(T& value, u8 bit) {
return value & bit;
}

View File

@ -2769,6 +2769,10 @@ inline void dComIfGd_init() {
g_dComIfG_gameInfo.drawlist.init();
}
inline void dComIfGd_peekZ(s16 param_0, s16 param_1, u32* param_2) {
g_dComIfG_gameInfo.drawlist.newPeekZdata(param_0, param_1, param_2);
}
inline void dComIfGd_peekZdata() {
g_dComIfG_gameInfo.drawlist.peekZdata();
}

View File

@ -515,7 +515,9 @@ public:
/* 0x920 */ f32 mTrimHeight;
/* 0x924 */ int mTrimSize;
/* 0x928 */ int mTrimTypeForce;
/* 0x92C */ u8 field_0x92c[0x970 - 0x92c];
/* 0x92C */ u8 field_0x92c[0x93C - 0x92c];
/* 0x93C */ f32 field_0x93c;
/* 0x940 */ u8 field_0x940[0x970 - 0x940];
/* 0x970 */ dCamSetup_c mCamSetup;
/* 0xAEC */ dCamParam_c mCamParam;
/* 0xB0C */

View File

@ -326,6 +326,10 @@ public:
param_6);
}
void newPeekZdata(s16 param_0, s16 param_1, u32* param_2) {
mPeekZ.newData(param_0, param_1, param_2);
}
static void offWipe() { mWipe = 0; }
static f32 getWipeRate() { return mWipeRate; }

View File

@ -2,5 +2,29 @@
#define D_D_INSECT_H
#include "dolphin/types.h"
#include "f_op/f_op_actor.h"
class dInsect_c : public fopAc_ac_c {
public:
/* 80110648 */ virtual void Insect_Release();
/* 8015E010 */ dInsect_c();
/* 8015E078 */ virtual void Insect_GetDemoMain();
/* 8015E26C */ virtual void CalcZBuffer(f32);
private:
/* 0x56C */ u8 field_0x56C;
/* 0x56D */ u8 field_0x56D;
/* 0x56E */ u8 field_0x56E[10];
/* 0x578 */ u32 field_0x578;
/* 0x57C */ f32 field_0x57C;
/* 0x580 */ u8 field_0x580;
/* 0x581 */ u8 field_0x581;
/* 0x582 */ s16 field_0x582;
/* 0x584 */ u8 field_0x584;
/* 0x585 */ u8 field_0x585;
/* 0x586 */ u8 field_0x586[2];
/* 0x588 */ u32 field_0x588;
/* 0x58C */ int field_0x58C;
};
#endif /* D_D_INSECT_H */

View File

@ -38,7 +38,7 @@ public:
/* 801D9E20 */ void isGiveInsect(int, int);
/* 801D9ED4 */ void isGiveInsect(u8);
/* 801D9E7C */ void isCatchInsect(u8);
/* 801D9F3C */ void isCatchNotGiveInsect(u8);
/* 801D9F3C */ static u8 isCatchNotGiveInsect(u8);
/* 801D9F8C */ void cursorMove();
/* 801DA1EC */ void setCursorPos();
/* 801DA2FC */ bool dpdMove();

View File

@ -136,6 +136,8 @@ public:
s8 getRoomNo() const { return current.mRoomNo; }
}; // Size: 0x568
STATIC_ASSERT(sizeof(fopAc_ac_c) == 0x568);
class fopEn_enemy_c : public fopAc_ac_c {
public:
/* 80019404 */ void initBallModel();

View File

@ -16,5 +16,6 @@ struct mDoLib_clipper {
void mDoLib_project(Vec* param_0, Vec* param_1);
bool mDoLib_setResTimgObj(ResTIMG const* res, GXTexObj* o_texObj, u32 param_2,
GXTlutObj* o_tlutObj);
void mDoLib_pos2camera(Vec* param_0, Vec* param_1);
#endif /* M_DO_M_DO_LIB_H */

View File

@ -6,51 +6,10 @@
#include "d/d_insect.h"
#include "dol2asm.h"
#include "dolphin/types.h"
//
// Types:
//
struct fopAc_ac_c {
/* 80018B64 */ fopAc_ac_c();
};
struct dSv_event_flag_c {
static u8 saveBitLabels[1644 + 4 /* padding */];
};
struct dSv_event_c {
/* 800349BC */ void isEventBit(u16) const;
};
struct dMenu_Insect_c {
/* 801D9F3C */ void isCatchNotGiveInsect(u8);
};
struct dInsect_c {
/* 80110648 */ void Insect_Release();
/* 8015E010 */ dInsect_c();
/* 8015E078 */ void Insect_GetDemoMain();
/* 8015E26C */ void CalcZBuffer(f32);
};
struct dEvt_control_c {
/* 80042468 */ void reset();
};
struct dEvent_manager_c {
/* 80047ADC */ void endCheckOld(char const*);
};
struct dDlst_peekZ_c {
/* 80056018 */ void newData(s16, s16, u32*);
};
struct csXyz {};
struct cXyz {};
struct Vec {};
#include "f_op/f_op_actor_mng.h"
#include "d/com/d_com_inf_game.h"
#include "d/menu/d_menu_insect.h"
#include "m_Do/m_Do_lib.h"
//
// Forward References:
@ -81,7 +40,6 @@ extern "C" void newData__13dDlst_peekZ_cFssPUl();
extern "C" void Insect_Release__9dInsect_cFv();
extern "C" void isCatchNotGiveInsect__14dMenu_Insect_cFUc();
extern "C" u8 saveBitLabels__16dSv_event_flag_c[1644 + 4 /* padding */];
extern "C" extern u8 g_dComIfG_gameInfo[122384];
//
// Declarations:
@ -98,14 +56,15 @@ SECTION_DATA extern void* __vt__9dInsect_c[3 + 1 /* padding */] = {
};
/* 8015E010-8015E078 158950 0068+00 0/0 0/0 13/13 .text __ct__9dInsect_cFv */
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
asm dInsect_c::dInsect_c() {
nofralloc
#include "asm/d/d_insect/__ct__9dInsect_cFv.s"
dInsect_c::dInsect_c() {
field_0x588 = -1;
field_0x56C = 0;
field_0x56D = 1;
field_0x58C = 0;
field_0x580 = 0xD6;
field_0x584 = 0;
field_0x585 = 0;
}
#pragma pop
/* ############################################################################################## */
/* 80393D98-80393D98 0203F8 0000+00 0/0 0/0 0/0 .rodata @stringBase0 */
@ -116,6 +75,54 @@ SECTION_DEAD static char const* const stringBase_80393D98 = "DEFAULT_GETITEM";
/* 8015E078-8015E26C 1589B8 01F4+00 0/0 0/0 24/24 .text Insect_GetDemoMain__9dInsect_cFv
*/
#ifdef NONMATCHING
void dInsect_c::Insect_GetDemoMain() {
if (field_0x58C != 1) {
if (fopAcM_checkCarryNow(this)) {
cLib_offBit(mAttentionInfo.mFlags,0x10);
fopAcM_cancelCarryNow(this);
fopAcM_orderItemEvent(this,0,0);
mEvtInfo.i_onCondition(8);
field_0x588 = fopAcM_createItemForTrBoxDemo(&current.pos,field_0x580,-1,fopAcM_GetRoomNo(this),0,0);
field_0x58C = 1;
if (dMenu_Insect_c::isCatchNotGiveInsect(field_0x580) != 0) {
field_0x585 = 1;
}
} else {
cLib_onBit(mAttentionInfo.mFlags,0x10);
}
} else {
if (mEvtInfo.checkCommandItem()) {
if (field_0x588 != -1) {
dComIfGp_event_setItemPartnerId(field_0x588);
}
field_0x56D = 0;
field_0x58C = 2;
} else {
fopAcM_orderItemEvent(this,0,0);
mEvtInfo.i_onCondition(8);
}
}
if (dComIfGp_evmng_endCheck("DEFAULT_GETITEM")) {
i_dComIfGp_event_reset();
if (dComIfGs_isEventBit(dSv_event_flag_c::saveBitLabels[field_0x582]) || field_0x585 != 0) {
field_0x56D = 1;
field_0x58C = 0;
if (field_0x584 == 0) {
fopAcM_createItem(&current.pos,0,-1,-1,0,0,0);
field_0x584 = 1;
}
} else {
fopAcM_delete(this);
}
}
}
#else
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
@ -124,6 +131,7 @@ asm void dInsect_c::Insect_GetDemoMain() {
#include "asm/d/d_insect/Insect_GetDemoMain__9dInsect_cFv.s"
}
#pragma pop
#endif
/* ############################################################################################## */
/* 804535E0-804535E4 001BE0 0004+00 1/1 0/0 0/0 .sdata2 @3871 */
@ -157,6 +165,44 @@ SECTION_SDATA2 static f32 lit_3877[1 + 1 /* padding */] = {
};
/* 8015E26C-8015E3F8 158BAC 018C+00 0/0 0/0 3/3 .text CalcZBuffer__9dInsect_cFf */
#ifdef NONMATCHING
void dInsect_c::CalcZBuffer(f32 param_0) {
f32 camera_trim_height;
cXyz pos;
cXyz pos_projected;
pos = current.pos;
pos.y += FLOAT_LABEL(lit_3871);
mDoLib_project(&pos_projected,&pos);
if (dComIfGp_getCamera(0)) {
camera_trim_height = dComIfGp_getCamera(0)->mCamera.field_0x93c;
} else {
camera_trim_height = FLOAT_LABEL(lit_3872);
}
if (pos_projected.x < FLOAT_LABEL(lit_3872) ||
pos_projected.x > FLOAT_LABEL(lit_3873) ||
pos_projected.y < camera_trim_height ||
pos_projected.y < FLOAT_LABEL(lit_3874) - camera_trim_height) {
dComIfGd_peekZ(pos_projected.x,pos_projected.y,&field_0x578);
} else {
field_0x578 = 0;
}
f32 view_near = dComIfGd_getView()->mNear;
f32 view_far = dComIfGd_getView()->mFar;
mDoLib_pos2camera(&pos_projected,&pos);
pos_projected.z += param_0;
if (pos_projected.z == FLOAT_LABEL(lit_3872)) {
pos_projected.z = FLOAT_LABEL(lit_3875);
}
field_0x57C = view_near + ((view_far * view_near) / pos_projected.z) / (view_far - view_near);
}
#else
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
@ -165,5 +211,6 @@ asm void dInsect_c::CalcZBuffer(f32 param_0) {
#include "asm/d/d_insect/CalcZBuffer__9dInsect_cFf.s"
}
#pragma pop
#endif
/* 80393D98-80393D98 0203F8 0000+00 0/0 0/0 0/0 .rodata @stringBase0 */

View File

@ -792,7 +792,7 @@ asm void dMenu_Insect_c::isGiveInsect(u8 param_0) {
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
asm void dMenu_Insect_c::isCatchNotGiveInsect(u8 param_0) {
asm u8 dMenu_Insect_c::isCatchNotGiveInsect(u8 param_0) {
nofralloc
#include "asm/d/menu/d_menu_insect/isCatchNotGiveInsect__14dMenu_Insect_cFUc.s"
}