Skip to content

Commit

Permalink
Mostly matched ModelUtil.cpp + other stuff
Browse files Browse the repository at this point in the history
Sorry, uber commit.
- Mostly matched ModelUtil.cpp, vtable offsets
  are wrong for now and one function is functionally
  equivalent but not totally matched because of my
  skill issues.
- Recovered a TON of various classes and methods,
  mostly JSystem stuff, some stolen from mkdd/smg,
  but some turned out to be quite different so I was
  pretty careful about not stealing too much stuff
- Clang-formatted everything because it bugged me
  • Loading branch information
Mrkol committed Dec 20, 2024
1 parent 82bfb05 commit 392f1c4
Show file tree
Hide file tree
Showing 69 changed files with 1,650 additions and 998 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# IDE folders
.idea/
.vs/
.vscode/

# Caches
__pycache__
Expand Down
1 change: 1 addition & 0 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ def MatchingFor(*versions):
Object(Matching, "MarioUtil/MapUtil.cpp"),
Object(Matching, "MarioUtil/RumbleType.cpp"),
Object(Matching, "MarioUtil/EffectUtil.cpp"),
Object(Matching, "MarioUtil/ModelUtil.cpp"),
],
},
{
Expand Down
4 changes: 2 additions & 2 deletions include/GC2D/GCConsole2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#include <dolphin/types.h>

class TGCConsole2 {
public:
void startAppearBalloon(u32, bool);
public:
void startAppearBalloon(u32, bool);
};

#endif
51 changes: 51 additions & 0 deletions include/JSystem/J3DAnimation.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#ifndef J3D_ANIMATION_HPP
#define J3D_ANIMATION_HPP

#include <dolphin/types.h>

class J3DFrameCtrl {
public:
J3DFrameCtrl() { init(0); };
virtual ~J3DFrameCtrl() {};

typedef void IDK;

void setSpeed(f32 speed) { mSpeed = speed; }
void setEndFrame(s16 end_frame) { mEndFrame = end_frame; }
f32 getCurrentFrame() const { return mCurrentFrame; }

void init(s16);
bool checkPass(float);
void update();

// TODO: probably private and always accessed via getters/setters judging by
// stack frame padding
// TODO: Stolen from SMG, might be wrong
u8 mLoopMode; // 0x4
u8 mFlags; // 0x5
s16 mStartFrame; // 0x6
s16 mEndFrame; // 0x8
s16 mLoopFrame; // 0xA
f32 mSpeed; // 0xC
f32 mCurrentFrame; // 0x10
};

class J3DAnmBase {
public:
J3DAnmBase();
J3DAnmBase(s16);

u16 getMaxFrame() { return mMaxFrame; }

char unk0[2];
u16 mMaxFrame;
float unk4;
char padding[4];
// NOTE: vtable is at 0xc
virtual ~J3DAnmBase();

typedef void IDK;
IDK isLegal(char*) const;
};

#endif
20 changes: 20 additions & 0 deletions include/JSystem/J3DAnmLoader.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#ifndef J3D_ANM_LOADER_HPP
#define J3D_ANM_LOADER_HPP

#include <JSystem/J3DModel.hpp>
#include <JSystem/J3DAnimation.hpp>

// NOTE: seems to be a plain struct w/ no methods
struct J3DTextureSRTInfo;

class J3DAnmTextureSRTKey : public J3DAnmBase {
public:
typedef void IDK;
IDK searchUpdateMaterialID(J3DModelData*);
IDK calcTransform(float, u16, J3DTextureSRTInfo*) const;
IDK calcPostTransform(float, u16, J3DTextureSRTInfo*) const;

virtual ~J3DAnmTextureSRTKey();
};

#endif
31 changes: 31 additions & 0 deletions include/JSystem/J3DMaterial.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#ifndef J3D_MATERIAL_HPP
#define J3D_MATERIAL_HPP

#include <dolphin/types.h>

class J3DMaterialAnm;

class J3DMaterial {
public:
typedef void IDK;
IDK makeDisplayList();
IDK load();
IDK patch();
IDK safeMakeDisplayList();
IDK safeLoad();
IDK calc(float (*)[4]);
IDK setCurrentMtx();
IDK copy(J3DMaterial*);
IDK reset();
IDK change();
IDK newSharedDisplayList(u32);

void setMaterialAnm(J3DMaterialAnm* v) { unk38 = v; }

~J3DMaterial();

char padding[0x38];
J3DMaterialAnm* unk38;
};

#endif
19 changes: 19 additions & 0 deletions include/JSystem/J3DMaterialAnm.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#ifndef J3D_MATERIAL_ANM
#define J3D_MATERIAL_ANM

struct J3DMaterial;

class J3DMaterialAnm // size 0x6c
{
public:
J3DMaterialAnm() { initialize(); }

virtual ~J3DMaterialAnm() { }
virtual void calc(J3DMaterial*) const;

void initialize();

char padding[0x68];
};

#endif
25 changes: 25 additions & 0 deletions include/JSystem/J3DMaterialAttach.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#ifndef J3D_MATERIAL_ATTACH_HPP
#define J3D_MATERIAL_ATTACH_HPP

#include <dolphin/types.h>

class J3DMaterial;

class J3DMaterialTable {
public:
J3DMaterialTable();
virtual ~J3DMaterialTable();

void clear();

J3DMaterial* getMaterial(u16 idx) const { return mMaterials[idx]; }
u16 getMaterialNum() const { return mMaterialNum; }

// TODO: stolen from mkdd, may be wrong
u16 mMaterialNum;
u16 mMaterialInitNum;
J3DMaterial** mMaterials;
// ...more stuff
};

#endif
103 changes: 103 additions & 0 deletions include/JSystem/J3DModel.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
#ifndef J3D_MODEL_HPP
#define J3D_MODEL_HPP

#include <dolphin/types.h>
#include <JSystem/J3DVertex.hpp>
#include <JSystem/J3DMaterialAttach.hpp>

struct J3DNode;
struct J3DModelHierarchy;
struct J3DAnmColor;
struct J3DAnmTexPattern;
struct J3DAnmTextureSRTKey;
struct J3DAnmTevRegKey;
struct J3DMatColorAnm;
struct J3DTexNoAnm;
struct J3DTexMtxAnm;
struct J3DTevColorAnm;
struct J3DTevKColorAnm;
class J3DMaterial;

// TODO: this could be an enum
struct J3DMaterialCopyFlag {
u32 unk0b : 1;
u32 unk1b : 1;
};

class J3DModelData : public J3DDrawMtxData, public J3DVertexData {
public:
typedef void IDK;
IDK clear();
J3DModelData();
virtual ~J3DModelData();

IDK makeHierarchy(J3DNode*, const J3DModelHierarchy**);
IDK newSharedDisplayList();
IDK isDeformableVertexFormat() const;
IDK setMaterialTable(J3DMaterialTable*, J3DMaterialCopyFlag);
IDK entryMatColorAnimator(J3DAnmColor*);
IDK entryTexNoAnimator(J3DAnmTexPattern*);
IDK entryTexMtxAnimator(J3DAnmTextureSRTKey*);
IDK entryTevRegAnimator(J3DAnmTevRegKey*);
IDK removeMatColorAnimator(J3DAnmColor*);
IDK removeTexNoAnimator(J3DAnmTexPattern*);
IDK removeTexMtxAnimator(J3DAnmTextureSRTKey*);
IDK removeTevRegAnimator(J3DAnmTevRegKey*);
IDK setMatColorAnimator(J3DAnmColor*, J3DMatColorAnm*);
IDK setTexNoAnimator(J3DAnmTexPattern*, J3DTexNoAnm*);
IDK setTexMtxAnimator(J3DAnmTextureSRTKey*, J3DTexMtxAnm*, J3DTexMtxAnm*);
IDK setTevRegAnimator(J3DAnmTevRegKey*, J3DTevColorAnm*, J3DTevKColorAnm*);

char padding[0x18];
J3DMaterialTable mMaterialTable;
};

struct J3DDeformData;
struct J3DSkinDeform;
struct J3DVtxColorCalc;
struct J3DVtxShader;

// TODO: is this an enum? Probably
enum J3DDeformAttachFlag {};

// size should be 0xa0
class J3DModel {
public:
J3DModel();
J3DModel(J3DModelData*, u32, u32);

typedef void IDK;
IDK initialize();
IDK entryModelData(J3DModelData*, u32, u32);
IDK lock();
IDK unlock();
IDK makeDL();
IDK patch();
IDK setDeformData(J3DDeformData*, J3DDeformAttachFlag);
IDK setSkinDeform(J3DSkinDeform*, J3DDeformAttachFlag);
IDK setVtxColorCalc(J3DVtxColorCalc*, J3DDeformAttachFlag);
IDK setVtxShader(J3DVtxShader*, J3DDeformAttachFlag);
IDK calcWeightEnvelopeMtx();
IDK calcBaseMtx();
virtual IDK update();
virtual IDK entry();
virtual IDK calc();
virtual IDK viewCalc();
IDK calcNrmMtx();
IDK calcBumpMtx();
IDK calcBBoard();
IDK prepareShapePackets();

virtual ~J3DModel();

struct UnknownStruct {
char padding[0x14];
float unk14;
};

char padding0[0x58];
UnknownStruct* unk58;
char padding5c[0x40];
};

#endif
14 changes: 14 additions & 0 deletions include/JSystem/J3DModelLoader.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#ifndef J3D_MODEL_LOADER_HPP
#define J3D_MODEL_LOADER_HPP

#include <dolphin/types.h>
#include <JSystem/J3DModel.hpp>

struct J3DModelLoaderDataBase {
// NOTE: I have no idea why, but it seems like they pass in the
// J3DModelLoaderDataBase through a void* pointer here?!
static J3DModelData* load(const void*, u32);
static void* loadMaterialTable(const void*);
};

#endif
8 changes: 4 additions & 4 deletions include/JSystem/J3DSys.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
#include "types.h"

class J3DSys {
public:
void setTexCacheRegion(GXTexCacheSize);
char pad_000[0x34];
s32 _034;
public:
void setTexCacheRegion(GXTexCacheSize);
char pad_000[0x34];
s32 _034;
};

extern J3DSys j3dSys;
Expand Down
16 changes: 16 additions & 0 deletions include/JSystem/J3DVertex.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifndef J3D_VERTEX_HPP
#define J3D_VERTEX_HPP

class J3DVertexData {
public:
J3DVertexData();
~J3DVertexData();
};

class J3DDrawMtxData {
public:
J3DDrawMtxData();
~J3DDrawMtxData();
};

#endif
45 changes: 45 additions & 0 deletions include/JSystem/JDRActor.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#ifndef JDR_ACTOR_HPP
#define JDR_ACTOR_HPP

#include <JSystem/JDRPlacement.hpp>
#include <JSystem/JDRGraphics.hpp>
#include <JSystem/JSGActor.hpp>

namespace JDrama {

class TActor : public TPlacement, public JStage::TActor {
public:
// TActor
char _020[0x10];
f32 unk34;
char unk40[0x8];

f32 getUnk34() { return unk34; }

TActor(const char*);

typedef void IDK;

virtual IDK getType();
virtual IDK load(JSUMemoryInputStream&);

virtual IDK perform(u32, TGraphics*);

virtual void JSGGetTranslation(Vec*) const;
virtual void JSGSetTranslation(const Vec&);
virtual void JSGGetScaling(Vec*) const;
virtual void JSGSetScaling(const Vec&);
virtual void JSGGetRotation(Vec*) const;
virtual void JSGSetRotation(const Vec&);
virtual u32 JSGGetShape() const;
virtual void JSGSetShape(u32);
virtual u32 JSGGetAnimation() const;
virtual void JSGSetAnimation(u32);
virtual float JSGGetAnimationFrame() const;
virtual void JSGSetAnimationFrame(float);
virtual float JSGGetAnimationFrameMax() const;
};

} // namespace JDrama

#endif
10 changes: 10 additions & 0 deletions include/JSystem/JDRGraphics.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef JDR_GRAPHICS_HPP
#define JDR_GRAPHICS_HPP

namespace JDrama {

struct TGraphics;

}

#endif
Loading

0 comments on commit 392f1c4

Please sign in to comment.