Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

d_wood (bushes) matching #682

Merged
merged 43 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
737e92a
d_wood (bushes) 73% matching
themikelester Oct 22, 2024
a9fce50
d_wood::Unit_c::set_ground 100% match
themikelester Oct 22, 2024
2de04ab
Replace some bitshifts with multiplies based on PR feedback
themikelester Oct 22, 2024
5399a91
Remove all instances of "this->" from d_wood
themikelester Oct 22, 2024
e459bb4
Add missing struct offset comment for mTevStr
themikelester Oct 22, 2024
eeef0e9
Cleaned up d_tree externs
themikelester Oct 22, 2024
4b11e10
Use MTXIdentity instead of PSMTXIdentity
themikelester Oct 22, 2024
d8087df
Remove incorrect TODO rearding cCcD_ObjAtType enum
themikelester Oct 22, 2024
197461d
Use the mDoAud_seStart inline function
themikelester Oct 22, 2024
23e62e5
Remove unnecessary parenthesis
themikelester Oct 22, 2024
338fde4
Fix incorrect branching logic in d_wood::cc_hit_before_cut()
themikelester Oct 22, 2024
fe9aa69
d_wood data sections fixup
themikelester Oct 22, 2024
3d29ab3
Re-add "Nonmatching" comments to all nonmatching functions
themikelester Oct 22, 2024
bb1df4a
Merge branch 'zeldaret:main' into main
themikelester Oct 22, 2024
017eae7
Formatting: reformat from 2 to 4 space indentation
themikelester Oct 22, 2024
8e118f6
100% match for d_wood::Anm_c::mode_norm()
themikelester Oct 22, 2024
0384622
Use cLib_*Bit() functions for flag checking and setting
themikelester Oct 22, 2024
bbed25f
d_wood: Use AnmID_e according to the .map file
themikelester Oct 23, 2024
b49504a
d_wood: add a couple AnmID_e related inlines from the .map
themikelester Oct 23, 2024
882ee40
d_wood: Name remaining unknowns related to animation
themikelester Oct 23, 2024
7fac3f5
d_wood: Match cc_hit_before_cut()
themikelester Oct 23, 2024
abd202b
d_wood: Match calc_cc() by using the dComIfGp_roomControl_getStayNo()…
themikelester Oct 23, 2024
eb4be33
d_wood: Match string table and search_anm() by using a constant in as…
themikelester Oct 23, 2024
87e7988
d_wood: Match mode_to_norm()
themikelester Oct 23, 2024
c0c7b74
d_wood: 100% match for L_attr and the .rodata section
themikelester Oct 23, 2024
1467663
d_wood: Fill in .data section. Still some extra data from vtables
themikelester Oct 23, 2024
cc24ab3
d_wood: Match .sbss section
themikelester Oct 23, 2024
4be77a1
d_wood: Match .sdata section
themikelester Oct 23, 2024
fe13bf9
d_wood: 98% match for Packet_c::draw()
themikelester Oct 24, 2024
e4c6956
d_wood: Various small formatting changes
themikelester Oct 28, 2024
ae8db62
d_wood: More formatting fixes
themikelester Oct 28, 2024
516de34
d_tree: 100% match of data which is used by d_wood
themikelester Oct 28, 2024
0fd7024
d_wood: Removed unnecessary comment now that draw() matches
themikelester Oct 28, 2024
58966c1
d_wood: 100% match for mode_cut()
themikelester Oct 28, 2024
470af6a
d_wood: Match mode_push_into()
themikelester Oct 29, 2024
513b52a
d_wood: Match mode_push_back
themikelester Oct 29, 2024
8013192
d_wood: Match __sinit_d_wood_cpp
themikelester Oct 29, 2024
4e3103e
d_wood: Fix incorrect constant in set_ground()
themikelester Oct 29, 2024
a261786
d_wood: Simplify dummy data at the top of .data section
themikelester Oct 29, 2024
fd9cb51
d_wood: Mark as matching in configure.py
themikelester Oct 29, 2024
0018671
d_wood: Add `d/d_cc_d.h` include as some enums have moved
themikelester Oct 29, 2024
f296b48
d_wood: Clean up some types at the top
themikelester Oct 29, 2024
b9d23a6
Mark d_wood as non-matching for the Japanese version
themikelester Oct 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/d/d_cc_mass_s.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ class dCcMassS_HitInf {
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;
mpAtObj = NULL;
mpCoObj = NULL;
mCoHitLen = 0.0f;
}
void GetCoHitLen() const {}
void GetCoHitObj() const {}
};

class dCcMassS_Mng {
Expand Down
4 changes: 4 additions & 0 deletions include/d/d_com_inf_game.h
Original file line number Diff line number Diff line change
Expand Up @@ -3008,6 +3008,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();
Expand Down
1 change: 1 addition & 0 deletions include/d/d_particle_name.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
16 changes: 16 additions & 0 deletions include/d/d_tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,22 @@ class cCcD_Obj;
class dCcMassS_HitInf;
class fopAc_ac_c;

namespace d_tree {
extern u8 g_dTree_shadowPos[];
extern u8 g_dTree_shadowTexCoord[];

extern Vec l_pos[];
extern GXColor l_color[];
extern cXy l_texCoord[];

extern const u32 g_dTree_shadowMatDL_SIZE;
extern const u32 g_dTree_Oba_kage_32DL_SIZE;

extern u8 l_matDL[];
extern u8 g_dTree_shadowMatDL[];
extern u8 g_dTree_Oba_kage_32DL[];
};

themikelester marked this conversation as resolved.
Show resolved Hide resolved
class dTree_data_c {
public:
~dTree_data_c();
Expand Down
93 changes: 71 additions & 22 deletions include/d/d_wood.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,80 @@
#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
};

class Anm_c;
class Packet_c;
class Unit_c {
public:
Unit_c();
~Unit_c();

void set_ground();
bool set_ground();
void set_mtx(Anm_c*);
void clear();
void cc_hit_before_cut(Packet_c*);
void cc_hit_after_cut(Packet_c*);
void proc(Packet_c*);

/* 0x000 */ cXyz mPos;
/* 0x00C */ u8 field_0x00C[0x010 - 0x00C];
/* 0x00C */ s16 mAnimCooldown; // In frames. Animations will not change unless this is 0.
/* 0x00E */ u8 field_0x00C[0x010 - 0x00E];
/* 0x010 */ u32 mFlags;
/* 0x014 */ int mAnmIdx;
/* 0x018 */ Mtx field_0x018;
/* 0x048 */ Mtx field_0x048;
/* 0x078 */ Mtx field_0x078;
/* 0x0A8 */ Mtx field_0x0a8;
/* 0x014 */ s32 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*);
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);
Expand All @@ -59,11 +89,28 @@ class Anm_c {
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;
Mode_e get_mode() { return mMode; }

/* 0x00 */ Mtx mModelMtx;
/* 0x30 */ Mtx mTrunkModelMtx;

/* 0x60 */ Mode_e mMode;

/* 0x64 */ s16 mCountdown;
/* 0x66 */ s16 mWindDir; // 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 mRotY[2];
/* 0x7c */ s16 mRotX[2];
/* 0x80 */ s16 mUnkArr2[2];
/* 0x84 */ s16 mUnkArr3[2];

/* 0x88 */ s16 mNextAnimIdx; // Corresponds to the index in Packet_c::mAnm;

/* 0x8A */ u8 mAlphaScale;
};

STATIC_ASSERT(sizeof(Anm_c) == 0x8C);
Expand All @@ -81,16 +128,18 @@ 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;
s32 search_anm(Anm_c::Mode_e mode);

Anm_c* get_anm(u32 idx) { return &mAnm[idx]; }

virtual void draw();
virtual ~Packet_c();
virtual ~Packet_c() {};

/* 0x00010 */ Unit_c mUnit[200];
/* 0x13570 */ Anm_c mAnm[72];
Expand Down
11 changes: 11 additions & 0 deletions src/d/d_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@

#include "d/d_tree.h"
#include "dolphin/types.h"
#include "dolphin/mtx/mtx.h"

u8 d_tree::g_dTree_shadowPos[] = {}; // Supposed to be 3 byte position, but I can't find a matching type
u8 d_tree::g_dTree_shadowTexCoord[] = {}; // Supposed to be 2 byte UV, but I can't find a matching type

const u32 d_tree::g_dTree_shadowMatDL_SIZE = 0x80;
const u32 d_tree:: g_dTree_Oba_kage_32DL_SIZE = 0x20;

Vec d_tree::l_pos[];
GXColor d_tree::l_color[];
cXy d_tree::l_texCoord[];

/* 800787BC-80078960 .text WorkCo__12dTree_data_cFP10fopAc_ac_cUli */
void dTree_data_c::WorkCo(fopAc_ac_c*, u32, int) {
Expand Down
Loading