mirror of
https://github.com/zeldaret/tww.git
synced 2026-08-22 06:20:02 -04:00
d_wood (bushes) matching (#682)
* d_wood (bushes) 73% matching * d_wood::Unit_c::set_ground 100% match Jasper pointed me to the fact that the complicated inv_sqrt function I wrote was indeed just std::sqrtf(), which unlocked the rest of the match * Replace some bitshifts with multiplies based on PR feedback * Remove all instances of "this->" from d_wood * Add missing struct offset comment for mTevStr * Cleaned up d_tree externs * Use MTXIdentity instead of PSMTXIdentity * Remove incorrect TODO rearding cCcD_ObjAtType enum * Use the mDoAud_seStart inline function * Remove unnecessary parenthesis * Fix incorrect branching logic in d_wood::cc_hit_before_cut() * d_wood data sections fixup * Re-add "Nonmatching" comments to all nonmatching functions * Formatting: reformat from 2 to 4 space indentation This was a local system problem which slipped by me in a previous commit * 100% match for d_wood::Anm_c::mode_norm() Thanks Chippy! https://discord.com/channels/727908905392275526/873250400483024976/1298360716964790294 * Use cLib_*Bit() functions for flag checking and setting Based on the inline functions from the .map * d_wood: Use AnmID_e according to the .map file * d_wood: add a couple AnmID_e related inlines from the .map * d_wood: Name remaining unknowns related to animation * d_wood: Match cc_hit_before_cut() * d_wood: Match calc_cc() by using the dComIfGp_roomControl_getStayNo() inline * d_wood: Match string table and search_anm() by using a constant in assert string * d_wood: Match mode_to_norm() Switching normAnim to a const* did most of the work * d_wood: 100% match for L_attr and the .rodata section * d_wood: Fill in .data section. Still some extra data from vtables * d_wood: Match .sbss section * d_wood: Match .sdata section * d_wood: 98% match for Packet_c::draw() The only error is that g_dTree_shadowTexCoord is still using a 32-bit load instead of 16. the only way I know of to fix that is to define the data in this compilation unit. But that can't be right * d_wood: Various small formatting changes - No one line function implementations - Replaced instances of (SomeType*)0x0 (copy/pasted from Ghidra) with NULL - Replaced a few instances of 0.0 with 0.0f - Replaced one instance where a number was used instead of an enum value * d_wood: More formatting fixes - Removed unused variables from functions - Removed unnecessary iVar1 loop variables (leftover Ghidra detritus) - Fixed dtk function comments being wrapped by autoformatter. They now always appear on one line * d_tree: 100% match of data which is used by d_wood This moves g_dTree_shadowTexCoord into .sdata which allows d_wood::Packet_c::draw() to load its address with a single instruction. This makes a 100% match for draw() * d_wood: Removed unnecessary comment now that draw() matches g_dTree_shadowTexCoord now lives in the d_tree .sdata section, so its instruction can be loaded with a single instruction. This makes a 100% match with draw(). * d_wood: 100% match for mode_cut() * d_wood: Match mode_push_into() Also renamed mWindDir to mForceDir as it represents both wind and an actor pushing from a vector * d_wood: Match mode_push_back * d_wood: Match __sinit_d_wood_cpp The l_matDL display list is dynamically patched to reference the l_Txa_swood_bTEX texture at static initialization time. Is there a better way to represent this? * d_wood: Fix incorrect constant in set_ground() * d_wood: Simplify dummy data at the top of .data section * d_wood: Mark as matching in configure.py Had to move Packet_c destructor to get the functions in the right order. See discussion: https://discord.com/channels/727908905392275526/873250400483024976/1300680009458913280 * d_wood: Add `d/d_cc_d.h` include as some enums have moved * d_wood: Clean up some types at the top * Mark d_wood as non-matching for the Japanese version
This commit is contained in:
+1
-1
@@ -496,7 +496,7 @@ config.libs = [
|
||||
Object(NonMatching, "d/d_cam_style.cpp"),
|
||||
Object(NonMatching, "d/d_cam_type2.cpp"),
|
||||
Object(NonMatching, "d/d_ev_camera.cpp"),
|
||||
Object(NonMatching, "d/d_wood.cpp"),
|
||||
Object(MatchingFor("GZLE01", "GZLP01"), "d/d_wood.cpp", extra_cflags=["-sym off"]),
|
||||
Object(NonMatching, "d/d_flower.cpp"),
|
||||
Object(Matching, "d/d_item_data.cpp"),
|
||||
Object(Matching, "d/d_seafightgame.cpp"),
|
||||
|
||||
@@ -52,6 +52,8 @@ public:
|
||||
void SetAtHitObj(cCcD_Obj* obj) { mpAtObj = obj; }
|
||||
void SetCoHitLen(f32 len) { mCoHitLen = len; }
|
||||
cCcD_Obj* GetAtHitObj() const { return mpAtObj; }
|
||||
cCcD_Obj* GetCoHitObj() const { return mpCoObj; }
|
||||
f32 GetCoHitLen() const { return mCoHitLen; }
|
||||
|
||||
void ClearPointer() {
|
||||
mpArea = NULL;
|
||||
@@ -59,8 +61,6 @@ public:
|
||||
mpCoObj = NULL;
|
||||
mCoHitLen = 0.0f;
|
||||
}
|
||||
void GetCoHitLen() const {}
|
||||
void GetCoHitObj() const {}
|
||||
};
|
||||
|
||||
class dCcMassS_Mng {
|
||||
|
||||
@@ -3012,6 +3012,10 @@ inline void dComIfGd_setList() {
|
||||
g_dComIfG_gameInfo.drawlist.setXluList();
|
||||
}
|
||||
|
||||
inline void dComIfGd_setXluList() {
|
||||
g_dComIfG_gameInfo.drawlist.setXluList();
|
||||
}
|
||||
|
||||
inline void dComIfGd_setListInvisisble() {
|
||||
g_dComIfG_gameInfo.drawlist.setOpaListInvisible();
|
||||
g_dComIfG_gameInfo.drawlist.setXluListInvisible();
|
||||
|
||||
@@ -16,6 +16,7 @@ namespace dPa_name {
|
||||
ID_COMMON_LIGHT_EXPLOSION = 0x272,
|
||||
ID_COMMON_STARS_SPIN = 0x27A,
|
||||
ID_COMMON_STARS_BLOW = 0x27B,
|
||||
ID_CUT_L_TREE_DOWN = 0x3E0,
|
||||
ID_PEDESTAL_OCTAGON_GLOW = 0x826D,
|
||||
ID_WARPFOUT_WARP4 = 0x830e,
|
||||
};
|
||||
|
||||
@@ -9,6 +9,13 @@ class cCcD_Obj;
|
||||
class dCcMassS_HitInf;
|
||||
class fopAc_ac_c;
|
||||
|
||||
extern const u32 g_dTree_shadowMatDL_SIZE;
|
||||
extern const u32 g_dTree_Oba_kage_32DL_SIZE;
|
||||
extern u8 g_dTree_shadowMatDL[];
|
||||
extern u8 g_dTree_Oba_kage_32DL[];
|
||||
extern u8 g_dTree_shadowPos[12];
|
||||
extern u8 g_dTree_shadowTexCoord[8];
|
||||
|
||||
class dTree_data_c {
|
||||
public:
|
||||
~dTree_data_c();
|
||||
|
||||
+85
-22
@@ -2,23 +2,44 @@
|
||||
#define D_WOOD_H
|
||||
|
||||
#include "JSystem/J3DGraphBase/J3DPacket.h"
|
||||
#include "JSystem/J3DGraphBase/J3DStruct.h"
|
||||
#include "SSystem/SComponent/c_xyz.h"
|
||||
#include "dolphin/mtx/mtx.h"
|
||||
#include "d/d_kankyo.h"
|
||||
|
||||
class dCcMassS_HitInf;
|
||||
class cCcD_Obj;
|
||||
class fopAc_ac_c;
|
||||
|
||||
namespace dWood {
|
||||
enum AnmID_e {};
|
||||
|
||||
enum AnmID_e {
|
||||
AnmID_Norm0,
|
||||
AnmID_Norm1,
|
||||
AnmID_Norm2,
|
||||
AnmID_Norm3,
|
||||
AnmID_Norm4,
|
||||
AnmID_Norm5,
|
||||
AnmID_Norm6,
|
||||
AnmID_Norm7,
|
||||
|
||||
AnmID_Norm_Max = 8,
|
||||
AnmID_Norm_Invalid = -1
|
||||
};
|
||||
|
||||
class Anm_c;
|
||||
class Packet_c;
|
||||
class Unit_c {
|
||||
public:
|
||||
Unit_c();
|
||||
~Unit_c();
|
||||
|
||||
void set_ground();
|
||||
enum State_e {
|
||||
STATE_ACTIVE = 1 << 0,
|
||||
STATE_FRUSTUM_CULLED = 1 << 1,
|
||||
STATE_CUT = 1 << 2,
|
||||
};
|
||||
|
||||
bool set_ground();
|
||||
void set_mtx(Anm_c*);
|
||||
void clear();
|
||||
void cc_hit_before_cut(Packet_c*);
|
||||
@@ -26,26 +47,44 @@ public:
|
||||
void proc(Packet_c*);
|
||||
|
||||
/* 0x000 */ cXyz mPos;
|
||||
/* 0x00C */ u8 field_0x00C[0x010 - 0x00C];
|
||||
/* 0x010 */ u32 mFlags;
|
||||
/* 0x014 */ int mAnmIdx;
|
||||
/* 0x018 */ Mtx field_0x018;
|
||||
/* 0x048 */ Mtx field_0x048;
|
||||
/* 0x078 */ Mtx field_0x078;
|
||||
/* 0x0A8 */ Mtx field_0x0a8;
|
||||
/* 0x00C */ s16 mAnimCooldown; // In frames. Animations will not change unless this is 0.
|
||||
/* 0x00E */ u8 field_0x00C[0x010 - 0x00E];
|
||||
/* 0x010 */ State_e mFlags;
|
||||
/* 0x014 */ AnmID_e mAnmIdx;
|
||||
/* 0x018 */ Mtx mModelViewMtx;
|
||||
/* 0x048 */ Mtx mTrunkModelViewMtx;
|
||||
/* 0x078 */ Mtx mShadowModelMtx;
|
||||
/* 0x0A8 */ Mtx mShadowModelViewMtx;
|
||||
/* 0x0D8 */ Unit_c* mpNext;
|
||||
/* 0x0DC */ u8 field_0xdc[0x18C - 0xDC];
|
||||
|
||||
/* 0x0DC */ dKy_tevstr_c mTevStr;
|
||||
};
|
||||
|
||||
STATIC_ASSERT(sizeof(Unit_c) == 0x18C);
|
||||
|
||||
class Anm_c {
|
||||
public:
|
||||
enum Mode_e {};
|
||||
enum Mode_e {
|
||||
Mode_Cut = 0, // Chopping down
|
||||
Mode_PushInto = 1, // Attacked or collided with, but not chopped
|
||||
Mode_PushBack = 2, // Second half of PushInto, returning to normal
|
||||
Mode_Fan = 3, // When hit with fan (does nothing)
|
||||
Mode_Norm = 4, // Idle animation
|
||||
Mode_ToNorm = 5, // Transition to idle from any other animation
|
||||
|
||||
Mode_Max
|
||||
};
|
||||
|
||||
Anm_c();
|
||||
void play(Packet_c*);
|
||||
|
||||
// Copies the "angle" and "amplitude" from another animation
|
||||
void copy_angamp(const Anm_c*);
|
||||
|
||||
// Animations are assigned from the Packet to specific Wood instances (Bushes) when a new animation starts
|
||||
// Each animation mode has an mode_*_init() function which is called when the animation is started
|
||||
// The mode_*() function is called to update the animation each frame, until finished
|
||||
// Their are 8 pre-allocated "normal" animations. When not animating, each unit is assigned one of the 8.
|
||||
|
||||
void mode_cut_init(const Anm_c*, short);
|
||||
void mode_cut(Packet_c*);
|
||||
void mode_push_into_init(const Anm_c*, short);
|
||||
@@ -59,11 +98,33 @@ public:
|
||||
void mode_to_norm_init(AnmID_e);
|
||||
void mode_to_norm(Packet_c*);
|
||||
|
||||
/* 0x00 */ u8 field_0x00[0x60 - 0x00];
|
||||
/* 0x60 */ int field_0x60;
|
||||
/* 0x64 */ s16 field_0x64;
|
||||
/* 0x66 */ u8 field_0x66[0x8A - 0x66];
|
||||
/* 0x8A */ u8 field_0x8a;
|
||||
inline AnmID_e mode_to_norm_get_AnmID() { return (AnmID_e)mNormAnimIdx; }
|
||||
inline void mode_to_norm_set_AnmID(AnmID_e anmID) { mNormAnimIdx = anmID; }
|
||||
|
||||
Mode_e get_mode() { return mMode; }
|
||||
|
||||
/* 0x00 */ Mtx mModelMtx;
|
||||
/* 0x30 */ Mtx mTrunkModelMtx;
|
||||
|
||||
/* 0x60 */ Mode_e mMode;
|
||||
|
||||
/* 0x64 */ s16 mCountdown;
|
||||
/* 0x66 */ s16 mForceDir; // The direction from the wind or actor who instigated this animation
|
||||
/* 0x68 */ float mWindPow; // 0.0 - 1.0
|
||||
/* 0x6c */ float mPosOffsetY;
|
||||
/* 0x70 */ float mPosOffsetZ;
|
||||
/* 0x74 */ float mVelY;
|
||||
|
||||
/* 0x78 */ s16 mPhaseY[2];
|
||||
/* 0x7c */ s16 mPhaseX[2];
|
||||
/* 0x80 */ s16 mAmpY[2];
|
||||
/* 0x84 */ s16 mAmpX[2];
|
||||
|
||||
/* 0x88 */ s16 mNormAnimIdx;
|
||||
|
||||
/* 0x8A */ u8 mAlphaScale;
|
||||
|
||||
static s32 M_init_num;
|
||||
};
|
||||
|
||||
STATIC_ASSERT(sizeof(Anm_c) == 0x8C);
|
||||
@@ -81,13 +142,15 @@ class Packet_c : public J3DPacket {
|
||||
public:
|
||||
Packet_c();
|
||||
|
||||
void delete_room(int);
|
||||
void put_unit(const cXyz&, int);
|
||||
void delete_room(int room_no);
|
||||
s32 put_unit(const cXyz& pos, int room_no);
|
||||
void calc_cc();
|
||||
void calc();
|
||||
void update();
|
||||
void search_empty_UnitID() const;
|
||||
void search_anm(Anm_c::Mode_e);
|
||||
s32 search_empty_UnitID() const;
|
||||
AnmID_e search_anm(Anm_c::Mode_e mode);
|
||||
|
||||
inline Anm_c* get_anm_p(AnmID_e idx) { return &mAnm[idx]; }
|
||||
|
||||
virtual void draw();
|
||||
virtual ~Packet_c();
|
||||
|
||||
@@ -5,6 +5,14 @@
|
||||
|
||||
#include "d/d_tree.h"
|
||||
#include "dolphin/types.h"
|
||||
#include "dolphin/mtx/mtx.h"
|
||||
|
||||
u8 g_dTree_shadowPos[12] = { 0xb5, 0x00, 0x4b, 0x4b, 0x00, 0x4b, 0xb5, 0x00, 0xb5, 0x4b, 0x00, 0xb5 };
|
||||
u8 g_dTree_shadowTexCoord[8] = { 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01 };
|
||||
const u32 g_dTree_Oba_kage_32DL_SIZE = 0x2b;
|
||||
const u32 g_dTree_shadowMatDL_SIZE = 0x90;
|
||||
u8 g_dTree_Oba_kage_32DL[g_dTree_Oba_kage_32DL_SIZE] = { 0x98, 0x00, 0x04, 0x01, 0x02, 0x00, 0x03, 0x03, 0x01, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
u8 g_dTree_shadowMatDL[g_dTree_shadowMatDL_SIZE] = { 0x61, 0x80, 0x00, 0x01, 0x35, 0x61, 0x84, 0x00, 0x00, 0x00, 0x61, 0x88, 0x00, 0x7c, 0x1f, 0x61, 0x94, 0x00, 0x00, 0x00, 0x61, 0x30, 0x00, 0x00, 0x20, 0x61, 0x31, 0x00, 0x00, 0x20, 0x10, 0x00, 0x00, 0x10, 0x40, 0xff, 0xff, 0x42, 0x80, 0x08, 0x30, 0x3c, 0xf3, 0xcf, 0x00, 0x10, 0x00, 0x00, 0x10, 0x18, 0x3c, 0xf3, 0xcf, 0x00, 0x61, 0x28, 0x38, 0x03, 0xc0, 0x61, 0xc0, 0x08, 0xff, 0xff, 0x61, 0xc1, 0x08, 0xe6, 0x70, 0x61, 0x43, 0x00, 0x00, 0x01, 0x61, 0x40, 0x00, 0x00, 0x07, 0x61, 0x41, 0x00, 0x04, 0xad, 0x61, 0xf3, 0x64, 0x00, 0x00, 0x10, 0x00, 0x00, 0x10, 0x3f, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x10, 0x09, 0x00, 0x00, 0x00, 0x00, 0x61, 0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
|
||||
/* 800787BC-80078960 .text WorkCo__12dTree_data_cFP10fopAc_ac_cUli */
|
||||
void dTree_data_c::WorkCo(fopAc_ac_c*, u32, int) {
|
||||
|
||||
+883
-72
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user