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_demo mostly matched #2242

Merged
merged 1 commit into from
Nov 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
34 changes: 33 additions & 1 deletion include/JSystem/JGadget/binary.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,26 @@ struct TValueIterator {
mBegin = begin;
}

const void* get() const { return mBegin; }

typename Parser::ParseType operator*() {
return *(typename Parser::ParseType*)mBegin;
return *(typename Parser::ParseType*)get();
}

TValueIterator& operator++() {
const_cast<u32*>(mBegin)++;
return *this;
}

const TValueIterator operator++(int) {
TValueIterator old(*this);
++(*this);
return old;
}

TValueIterator& operator+=(s32 v) {
const_cast<u32*>(mBegin) += v;
return *this;
}

const void* mBegin;
Expand All @@ -102,6 +120,20 @@ struct TValueIterator_raw : public TValueIterator<TParseValue_raw_<u8>, 1> {
TValueIterator_raw(const void* begin) : TValueIterator<TParseValue_raw_<u8>, 1>(begin) {}
};

template <typename T>
struct TParseValue_misaligned : TParseValue_raw_<T> {
static T parse(const void* data) { return TParseValue_raw_::parse(data); }
};

template<typename T>
struct TValueIterator_misaligned : public TValueIterator<TParseValue_misaligned<T>, sizeof(T)> {
TValueIterator_misaligned(const TValueIterator_misaligned<T>& other) : TValueIterator<TParseValue_misaligned<T>, sizeof(T)>(other) {}
TValueIterator_misaligned(const void* begin) : TValueIterator<TParseValue_misaligned<T>, sizeof(T)>(begin) {}
};


inline bool operator==(TValueIterator<TParseValue_misaligned<u32>, 4> a, TValueIterator<TParseValue_misaligned<u32>, 4> b) { return a.mBegin == b.mBegin; }

} // namespace binary
} // namespace JGadget

Expand Down
25 changes: 21 additions & 4 deletions include/JSystem/JStudio/JStudio/stb.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,16 +172,20 @@ struct TParseData : public data::TParse_TParagraph_data::TData {
}

bool isEnd() const {
return _0 == 0;
return status == 0;
}

bool empty() const {
return _c == NULL;
return fileCount == NULL;
}

bool isValid() const {
return !empty() && _0 == 50;
return !empty() && status == 50;
}

const void* getContent() const { return fileCount; }

u32 size() const { return dataSize; }
};

template <int T, class Iterator=JGadget::binary::TValueIterator_raw<u8> >
Expand All @@ -190,7 +194,7 @@ struct TParseData_fixed : public TParseData<T> {
TParseData_fixed() : TParseData<T>() {}

const void* getNext() const {
return fileCount;
return _10;
}

bool isValid() const {
Expand All @@ -200,6 +204,19 @@ struct TParseData_fixed : public TParseData<T> {
Iterator begin() {
return Iterator(fileCount);
}

Iterator end() {
Iterator i(fileCount);
i += size();
return i;
}
};

struct TParseData_string : public TParseData<0x60> {
TParseData_string(const void* pContent) : TParseData<0x60>(pContent) {}
TParseData_string() : TParseData<0x60>() {}

const char* getData() const { return (const char*)getContent(); }
};

} // namespace stb
Expand Down
100 changes: 89 additions & 11 deletions include/d/d_demo.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "SSystem/SComponent/c_sxyz.h"
#include "SSystem/SComponent/c_xyz.h"
#include "Z2AudioLib/Z2SoundStarter.h"
#include "f_op/f_op_actor_mng.h"

class J3DModel;
class dDemo_actor_c;
Expand Down Expand Up @@ -39,17 +40,42 @@ class dDemo_object_c {
/* 0xAC */ dDemo_fog_c* mpFog;
};

// TODO: made up, figure out what this is
struct dDemo_prm_data {
/* 0x0 */ u8 field_0x0[0x4 - 0x0];
/* 0x4 */ s8 field_0x4;
/* 0x5 */ u8 field_0x5[0x6 - 0x5];
/* 0x6 */ s8 field_0x6;
/* 0x7 */ s8 field_0x7;
/* 0x8 */ u8 field_0x8[0xB - 0x8];
/* 0xB */ s8 field_0xb;
/* 0xC */ u8 field_0xc[0xF - 0xC];
/* 0xF */ s8 field_0xf;
};

class dDemo_prm_c {
public:
dDemo_prm_c() { mData = 0; }
u32 getData() { return mData; }
dDemo_prm_c() { mData = NULL; }
dDemo_prm_data* getData() { return mData; }

/* 0x0 */ u32 field_0x0;
/* 0x4 */ u32 mData;
/* 0x4 */ dDemo_prm_data* mData;
};

class dDemo_actor_c : public JStage::TActor {
public:
enum Enable_e {
ENABLE_TRANS_e = (1 << 1),
ENABLE_SCALE_e = (1 << 2),
ENABLE_ROTATE_e = (1 << 3),
ENABLE_SHAPE_e = (1 << 4),
ENABLE_ANM_e = (1 << 5),
ENABLE_ANM_FRAME_e = (1 << 6),
ENABLE_ANM_TRANSITION_e = (1 << 7),
ENABLE_TEX_ANM = (1 << 8),
ENABLE_TEX_ANM_FRAME_e = (1 << 9),
};

/* 80038020 */ dDemo_actor_c();
/* 80038128 */ fopAc_ac_c* getActor();
/* 8003815C */ void setActor(fopAc_ac_c*);
Expand All @@ -58,22 +84,41 @@ class dDemo_actor_c : public JStage::TActor {

/* 80038098 */ virtual ~dDemo_actor_c();
/* 800387EC */ virtual void JSGSetData(u32, void const*, u32);
/* 8003A05C */ virtual s32 JSGFindNodeID(char const*) const;
/* 8003A088 */ virtual bool JSGGetNodeTransformation(u32, f32 (*)[4]) const;
/* 8003A0D8 */ virtual void JSGGetTranslation(Vec*) const;
/* 8003A05C */ virtual s32 JSGFindNodeID(char const* param_0) const {
JUT_ASSERT(mModel != 0);
return mModel->getModelData()->getJointName()->getIndex(param_0);
}
/* 8003A088 */ virtual bool JSGGetNodeTransformation(u32 param_0, Mtx param_1) const {
JUT_ASSERT(mModel != 0);
cMtx_copy(mModel->getAnmMtx((u16)param_0), param_1);
return true;
}
/* 8003A0D8 */ virtual void JSGGetTranslation(Vec* o_trans) const {
*o_trans = mTrans;
}
/* 80038920 */ virtual void JSGSetTranslation(Vec const&);
/* 8003A0F4 */ virtual void JSGGetScaling(Vec*) const;
/* 8003A0F4 */ virtual void JSGGetScaling(Vec* o_scale) const {
*o_scale = mScale;
}
/* 80038980 */ virtual void JSGSetScaling(Vec const&);
/* 8003A110 */ virtual void JSGGetRotation(Vec*) const;
/* 8003A110 */ virtual void JSGGetRotation(Vec* param_0) const {
param_0->x = mRotate.x * 0.005493164f;
param_0->y = mRotate.y * 0.005493164f;
param_0->z = mRotate.z * 0.005493164f;
}
/* 800389A8 */ virtual void JSGSetRotation(Vec const&);
/* 80038A0C */ virtual void JSGSetShape(u32);
/* 80038A20 */ virtual void JSGSetAnimation(u32);
/* 80038A40 */ virtual void JSGSetAnimationFrame(f32);
/* 8003A0C8 */ virtual f32 JSGGetAnimationFrameMax() const;
/* 8003A0C8 */ virtual f32 JSGGetAnimationFrameMax() const {
return mAnmFrameMax;
}
/* 80038A54 */ virtual void JSGSetAnimationTransition(f32);
/* 80038A68 */ virtual void JSGSetTextureAnimation(u32);
/* 80038A7C */ virtual void JSGSetTextureAnimationFrame(f32);
/* 8003A0D0 */ virtual f32 JSGGetTextureAnimationFrameMax() const;
/* 8003A0D0 */ virtual f32 JSGGetTextureAnimationFrameMax() const {
return mTexAnmFrameMax;
}

void setModel(J3DModel* p_model) { mModel = p_model; }
u8 checkEnable(u16 flag) { return mFlags & flag; }
Expand Down Expand Up @@ -104,7 +149,7 @@ class dDemo_actor_c : public JStage::TActor {
/* 0x48 */ J3DModel* mModel;
/* 0x4C */ dDemo_prm_c mPrm;
/* 0x54 */ u32 field_0x54;
/* 0x58 */ u32 mActorId;
/* 0x58 */ fpc_ProcID mActorId;
/* 0x5C */ u32 mOldAnmId;
/* 0x60 */ u32 mBtpId;
/* 0x64 */ u32 mBtkId;
Expand Down Expand Up @@ -136,6 +181,15 @@ class dDemo_particle_c : public JStudio_JParticle::TCreateObject {

class dDemo_light_c : public JStage::TLight {
public:
enum Enable_e {
ENABLE_LIGHT_TYPE_e = (1 << 0),
ENABLE_POSITION_e = (1 << 1),
ENABLE_COLOR_e = (1 << 2),
ENABLE_DIST_ATTEN_e = (1 << 3),
ENABLE_ANGLE_ATTEN_e = (1 << 4),
ENABLE_DIRECTION_e = (1 << 5),
};

dDemo_light_c() {
mFlags = 0;
}
Expand Down Expand Up @@ -165,6 +219,13 @@ class dDemo_light_c : public JStage::TLight {

class dDemo_fog_c : public JStage::TFog {
public:
enum Enable_e {
ENABLE_FOG_FN_e = (1 << 0),
ENABLE_START_Z_e = (1 << 1),
ENABLE_END_Z_e = (1 << 2),
ENABLE_COLOR_e = (1 << 3),
};

dDemo_fog_c() {
mFlags = 0;
}
Expand All @@ -187,6 +248,17 @@ class dDemo_fog_c : public JStage::TFog {

class dDemo_camera_c : public JStage::TCamera {
public:
enum Enable_e {
ENABLE_PROJ_NEAR_e = (1 << 0),
ENABLE_PROJ_FAR_e = (1 << 1),
ENABLE_PROJ_FOVY_e = (1 << 2),
ENABLE_PROJ_ASPECT_e = (1 << 3),
ENABLE_VIEW_POS_e = (1 << 4),
ENABLE_VIEW_UP_VEC_e = (1 << 5),
ENABLE_VIEW_TARG_POS_e = (1 << 6),
ENABLE_VIEW_ROLL_e = (1 << 7),
};

dDemo_camera_c() {
mFlags = 0;
}
Expand Down Expand Up @@ -232,6 +304,10 @@ class dDemo_camera_c : public JStage::TCamera {

class dDemo_ambient_c : public JStage::TAmbientLight {
public:
enum Enable_e {
ENABLE_COLOR_e = (1 << 0),
};

dDemo_ambient_c() {
mFlags = 0;
}
Expand All @@ -257,6 +333,8 @@ class jstudio_tCreateObject_message : public JStudio::TCreateObject {

class jstudio_tAdaptor_message : public JStudio::TAdaptor_message {
public:
typedef JStudio::TObject_message ObjectType;

jstudio_tAdaptor_message() {}

virtual ~jstudio_tAdaptor_message();
Expand Down
2 changes: 1 addition & 1 deletion src/JSystem/JStage/JSGSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ bool JStage::TSystem::JSGGetSystemData(u32) {
}

/* 80280F14-80280F18 27B854 0004+00 1/0 1/0 0/0 .text JSGSetSystemData__Q26JStage7TSystemFUlUl */
void JStage::TSystem::JSGSetSystemData(u32, u32) {}
void JStage::TSystem::JSGSetSystemData(u32, u32) {}
28 changes: 22 additions & 6 deletions src/d/actor/d_a_alink_demo.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1427,17 +1427,33 @@ f32 daAlink_c::setStickAnmData(J3DAnmBase* i_anm, int param_1, int param_2, u16

/* 80119464-801195C0 113DA4 015C+00 1/1 0/0 0/0 .text
* daAlink_c_getDemoIDData__FP13dDemo_actor_cPiPiPiPUsPiPi */
// NONMATCHING - some stack issues
static int daAlink_c_getDemoIDData(dDemo_actor_c* param_0, int* param_1, int* param_2,
int* param_3, u16* param_4, int* param_5, int* param_6) {
// NONMATCHING
static u8 dummy[20];
JStudio::stb::TParseData_fixed<51, TValueIterator_misaligned<u32> > sp30(param_0->getPrm()->getData());

/* JStudio::stb::TParseData_fixed<51> sp50((void*)param_0->getPrm()->getData());
static JStudio::stb::TParseData_fixed<51, TValueIterator_misaligned<u32> > dummy;
static JGadget::binary::TValueIterator_misaligned<u32> it(dummy.begin());

static JStudio::stb::TParseData_fixed<51> dummy;
static JGadget::binary::TValueIterator_raw<u32> it(sp50); */
if (it == sp30.end()) {
it = dummy.begin();
return 0;
}

return 0;
if (it == dummy.begin()) {
it = sp30.begin();
}

u32 var_r31 = *it;
*param_1 = var_r31 >> 0x1E;
*param_2 = (var_r31 >> 0x18) & 0xF;
*param_6 = (var_r31 >> 0x17) & 1;
*param_3 = (var_r31 >> 0x10) & 0xF;
*param_4 = var_r31 & 0xFFFF;
*param_5 = (var_r31 >> 0x14) & 7;

it++;
return 1;
}

/* 801195C0-801195F8 113F00 0038+00 7/0 0/0 0/0 .text procDemoCommon__9daAlink_cFv */
Expand Down
Loading