Skip to content

Commit

Permalink
Match TexUtil.s up to regswap & stack frame size
Browse files Browse the repository at this point in the history
Figuring out the precise set of inlines which will result in the correct
stack size and register allocation will have to wait until we figure out
more details about J3DModelData
  • Loading branch information
Mrkol committed Dec 21, 2024
1 parent 321dfb6 commit 7d383da
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 1 deletion.
1 change: 1 addition & 0 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ def MatchingFor(*versions):
Object(Matching, "MarioUtil/RumbleType.cpp"),
Object(Matching, "MarioUtil/EffectUtil.cpp"),
Object(Matching, "MarioUtil/ModelUtil.cpp"),
Object(Matching, "MarioUtil/TexUtil.cpp"),
],
},
{
Expand Down
19 changes: 18 additions & 1 deletion include/JSystem/J3DModel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <dolphin/types.h>
#include <JSystem/J3DVertex.hpp>
#include <JSystem/J3DMaterialAttach.hpp>
#include <JSystem/ResTIMG.hpp>

struct J3DNode;
struct J3DModelHierarchy;
Expand All @@ -24,6 +25,9 @@ struct J3DMaterialCopyFlag {
u32 unk1b : 1;
};

class JUTNameTab;

// Should be 0xbc bytes
class J3DModelData : public J3DDrawMtxData, public J3DVertexData {
public:
typedef void IDK;
Expand All @@ -48,8 +52,21 @@ class J3DModelData : public J3DDrawMtxData, public J3DVertexData {
IDK setTexMtxAnimator(J3DAnmTextureSRTKey*, J3DTexMtxAnm*, J3DTexMtxAnm*);
IDK setTevRegAnimator(J3DAnmTevRegKey*, J3DTevColorAnm*, J3DTevKColorAnm*);

char padding[0x18];
char padding0[0x18];
J3DMaterialTable mMaterialTable;
char padding1[0x7c];
JUTNameTab* unkA8;

struct UnknownStruct
{
u16 unk0;
char unk2[2];
ResTIMG* unk4;
};

UnknownStruct* unkAC;
char padding2[0x10];

};

struct J3DDeformData;
Expand Down
14 changes: 14 additions & 0 deletions include/JSystem/ResTIMG.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#ifndef RESTIMG_HPP
#define RESTIMG_HPP

#include <dolphin/types.h>

struct ResTIMG
{
char unk0[0xc];
u32 mPaletteOffset;
char unk10[0xc];
u32 mImageDataOffset;
};

#endif
32 changes: 32 additions & 0 deletions src/MarioUtil/TexUtil.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include <JSystem/J3DModel.hpp>
#include <JSystem/JUTNameTab.hpp>
#include <dolphin/os.h>
#include <functions.h>


void SMS_ChangeTextureAll(
J3DModelData *param_1,
const char *param_2,
const ResTIMG &param_3)

{
char trash[0x18];
for (u16 i = 0; i < param_1->unkAC->unk0; i = i + 1) {
if (strcmp((char*)param_2,(char*)param_1->unkA8->getName(i)) == 0) {
J3DModelData::UnknownStruct* us = param_1->unkAC;
us->unk4[i] = param_3;

// TODO: these are most likely an inlined call, figure it out
{
ResTIMG* ptr = us->unk4 + i;
ptr->mImageDataOffset = ptr->mImageDataOffset + (u32)&param_3 - (u32)ptr;
}
{
ResTIMG* ptr = us->unk4 + i;
ptr->mPaletteOffset = ptr->mPaletteOffset + (u32)&param_3 - (u32)ptr;
}
DCFlushRange(param_1->unkAC->unk4 + i, 0x20);
}
}
}

0 comments on commit 7d383da

Please sign in to comment.