diff options
| author | hatal175 <hatal175@users.noreply.github.com> | 2024-02-05 07:21:05 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-05 07:21:05 +0200 |
| commit | e98d9c845c3476b3060a4bada25ced6a736835de (patch) | |
| tree | aaf7910e6632ef5d7be7629e74f883014eb577c3 /libs/JSystem/J3DGraphLoader/J3DClusterLoader.cpp | |
| parent | f260221f4300df6f72aecc80b6140e4454ff57a8 (diff) | |
Fix some JSUConvertOffsetToPtr issues (#2063)
* Fix some JSUConvertOffsetToPtr issues
* Match some J3DAnmLoader functions
Diffstat (limited to 'libs/JSystem/J3DGraphLoader/J3DClusterLoader.cpp')
| -rw-r--r-- | libs/JSystem/J3DGraphLoader/J3DClusterLoader.cpp | 130 |
1 files changed, 20 insertions, 110 deletions
diff --git a/libs/JSystem/J3DGraphLoader/J3DClusterLoader.cpp b/libs/JSystem/J3DGraphLoader/J3DClusterLoader.cpp index b7408f61f0..451097dd5d 100644 --- a/libs/JSystem/J3DGraphLoader/J3DClusterLoader.cpp +++ b/libs/JSystem/J3DGraphLoader/J3DClusterLoader.cpp @@ -4,50 +4,14 @@ // #include "JSystem/J3DGraphLoader/J3DClusterLoader.h" -#include "JSystem/J3DGraphAnimator/J3DAnimation.h" #include "JSystem/J3DGraphAnimator/J3DCluster.h" #include "JSystem/J3DGraphAnimator/J3DSkinDeform.h" #include "JSystem/JSupport/JSupport.h" #include "JSystem/JUtility/JUTNameTab.h" +#include "JSystem/JKernel/JKRHeap.h" #include "dol2asm.h" #include "dolphin/os.h" - -// -// Types: -// - -class J3DClusterBlock : public JUTDataBlockHeader { -public: - /* 0x08 */ u16 mClusterNum; - /* 0x0A */ u16 mClusterKeyNum; - /* 0x0C */ u16 mClusterVertexNum; - /* 0x0E */ u16 mVtxPosNum; - /* 0x10 */ u16 mVtxNrmNum; - /* 0x14 */ void* mClusterPointer; - /* 0x18 */ void* mClusterKeyPointer; - /* 0x1C */ void* mClusterVertex; - /* 0x20 */ void* mVtxPos; - /* 0x24 */ void* mVtxNrm; - /* 0x28 */ void* mClusterName; - /* 0x2C */ void* mClusterKeyName; -}; - -class J3DClusterLoader { -public: - virtual void* load(const void*) = 0; - /* 803345FC */ virtual ~J3DClusterLoader(); -}; - -class J3DClusterLoader_v15 : public J3DClusterLoader { -public: - /* 803341CC */ J3DClusterLoader_v15(); - /* 803342F8 */ void readCluster(J3DClusterBlock const*); - - /* 80334244 */ virtual void* load(void const*); - /* 803341E8 */ virtual ~J3DClusterLoader_v15(); - - /* 0x04 */ J3DDeformData* mpDeformData; -}; +#include "string.h" // // Forward References: @@ -68,7 +32,6 @@ extern "C" extern char const* const J3DClusterLoader__stringBase0; // External References: // -SECTION_INIT void memcpy(); extern "C" void* __nw__FUl(); extern "C" void* __nwa__FUl(); extern "C" void* __nwa__FUli(); @@ -118,47 +81,12 @@ SECTION_DATA extern void* __vt__16J3DClusterLoader[4] = { }; /* 803341CC-803341E8 32EB0C 001C+00 1/1 0/0 0/0 .text __ct__20J3DClusterLoader_v15Fv */ -// matches with weak order -#ifdef NONMATCHING J3DClusterLoader_v15::J3DClusterLoader_v15() {} -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm J3DClusterLoader_v15::J3DClusterLoader_v15() { - nofralloc -#include "asm/JSystem/J3DGraphLoader/J3DClusterLoader/__ct__20J3DClusterLoader_v15Fv.s" -} -#pragma pop -#endif /* 803341E8-80334244 32EB28 005C+00 2/1 0/0 0/0 .text __dt__20J3DClusterLoader_v15Fv */ -// matches with weak order -#ifdef NONMATCHING J3DClusterLoader_v15::~J3DClusterLoader_v15() {} -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm J3DClusterLoader_v15::~J3DClusterLoader_v15() { - nofralloc -#include "asm/JSystem/J3DGraphLoader/J3DClusterLoader/__dt__20J3DClusterLoader_v15Fv.s" -} -#pragma pop -#endif - -/* ############################################################################################## */ -/* 803A2098-803A2098 02E6F8 0000+00 0/0 0/0 0/0 .rodata @stringBase0 */ -#pragma push -#pragma force_active on -SECTION_DEAD static char const* const stringBase_803A2098 = "Unknown data block\n"; -/* @stringBase0 padding */ -SECTION_DEAD static char const* const pad_803A20AC = "\0\0\0"; -#pragma pop /* 80334244-803342F8 32EB84 00B4+00 2/1 0/0 0/0 .text load__20J3DClusterLoader_v15FPCv */ -// matches with vtable data -#ifdef NONMATCHING void* J3DClusterLoader_v15::load(const void* i_data) { mpDeformData = new J3DDeformData(); @@ -178,20 +106,10 @@ void* J3DClusterLoader_v15::load(const void* i_data) { return mpDeformData; } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -// asm void* J3DClusterLoader_v15::load(void const* param_0) { -extern "C" asm void load__20J3DClusterLoader_v15FPCv() { - nofralloc -#include "asm/JSystem/J3DGraphLoader/J3DClusterLoader/load__20J3DClusterLoader_v15FPCv.s" -} -#pragma pop -#endif /* 803342F8-803345FC 32EC38 0304+00 1/1 0/0 0/0 .text * readCluster__20J3DClusterLoader_v15FPC15J3DClusterBlock */ +// Matches with some weak JSUConvertOffsetToPtr in other files #ifdef NONMATCHING void J3DClusterLoader_v15::readCluster(const J3DClusterBlock* block) { mpDeformData->mClusterNum = block->mClusterNum; @@ -216,34 +134,22 @@ void J3DClusterLoader_v15::readCluster(const J3DClusterBlock* block) { mpDeformData->mVtxPos = JSUConvertOffsetToPtr<f32>(block, block->mVtxPos); mpDeformData->mVtxNrm = JSUConvertOffsetToPtr<f32>(block, block->mVtxNrm); - mpDeformData->mClusterPointer = new J3DCluster[mpDeformData->getClusterNum()]; - J3DCluster* blockCluster = JSUConvertOffsetToPtr<J3DCluster>(block, block->mClusterPointer); - for (int i = 0; i < mpDeformData->getClusterNum(); i++) { - mpDeformData->mClusterPointer[i] = blockCluster[i]; - } - - mpDeformData->mClusterKeyPointer = new J3DClusterKey[mpDeformData->getClusterKeyNum()]; - J3DClusterKey* blockClusterKey = - JSUConvertOffsetToPtr<J3DClusterKey>(block, block->mClusterKeyPointer); - for (int i = 0; i < mpDeformData->getClusterKeyNum(); i++) { - mpDeformData->mClusterKeyPointer[i] = blockClusterKey[i]; - } - - mpDeformData->mClusterVertex = new J3DClusterVertex[mpDeformData->mClusterVertexNum]; - J3DClusterVertex* blockClusterVertex = - JSUConvertOffsetToPtr<J3DClusterVertex>(block, block->mClusterVertex); - for (int i = 0; i < mpDeformData->mClusterVertexNum; i++) { - mpDeformData->mClusterVertex[i] = blockClusterVertex[i]; - } + void* clusterPointer = block->mClusterPointer; + int clusterKeyPointerSize = (int)block->mClusterKeyPointer - (int)clusterPointer; + int clusterVertexPointerSize = (int)block->mClusterVertex - (int)clusterPointer; + int vtxPosSize = (int)block->mVtxPos - (int)clusterPointer; + u8* arr = new (0x20) u8[vtxPosSize]; + memcpy(arr, JSUConvertOffsetToPtr<J3DCluster>(block, clusterPointer), vtxPosSize); + mpDeformData->mClusterPointer = (J3DCluster*)arr; + mpDeformData->mClusterKeyPointer = (J3DClusterKey*)&arr[clusterKeyPointerSize]; + mpDeformData->mClusterVertex = (J3DClusterVertex*)&arr[clusterVertexPointerSize]; for (int i = 0; i < mpDeformData->getClusterNum(); i++) { J3DCluster* cluster = &mpDeformData->mClusterPointer[i]; - cluster->mClusterKey = JSUConvertOffsetToPtr<J3DClusterKey>(block, cluster->mClusterKey); + cluster->mClusterKey = JSUConvertOffsetToPtr<J3DClusterKey>(arr - (int)clusterPointer, cluster->mClusterKey); cluster->field_0x18 = JSUConvertOffsetToPtr<u16>(block, cluster->field_0x18); - J3DClusterVertex* clusterVertex = - JSUConvertOffsetToPtr<J3DClusterVertex>(block, cluster->mClusterVertex); - u32 vertexIdx = (clusterVertex - blockClusterVertex) / sizeof(J3DClusterVertex); - cluster->mClusterVertex = &mpDeformData->mClusterVertex[vertexIdx]; + cluster->mClusterVertex = + JSUConvertOffsetToPtr<J3DClusterVertex>(arr - (int)clusterPointer, cluster->mClusterVertex); J3DDeformer* deformer = new J3DDeformer(mpDeformData); if (cluster->field_0x14 != 0) { deformer->field_0xc = new f32[cluster->field_0x14 * 3]; @@ -266,6 +172,8 @@ void J3DClusterLoader_v15::readCluster(const J3DClusterBlock* block) { clusterVertex->field_0x4 = JSUConvertOffsetToPtr<u16>(block, clusterVertex->field_0x4); clusterVertex->field_0x8 = JSUConvertOffsetToPtr<u16>(block, clusterVertex->field_0x8); } + + DCStoreRange(arr, vtxPosSize); } #else #pragma push @@ -279,10 +187,12 @@ asm void J3DClusterLoader_v15::readCluster(J3DClusterBlock const* param_0) { #endif /* 803345FC-80334644 32EF3C 0048+00 1/0 0/0 0/0 .text __dt__16J3DClusterLoaderFv */ +// Remove when JSUConvertOffsetToPtr is ok #pragma push #pragma optimization_level 0 #pragma optimizewithasm off -asm J3DClusterLoader::~J3DClusterLoader() { +asm void __dt__16J3DClusterLoaderFv() { +//asm J3DClusterLoader::~J3DClusterLoader() { nofralloc #include "asm/JSystem/J3DGraphLoader/J3DClusterLoader/__dt__16J3DClusterLoaderFv.s" } |
