26 02 27 pjb dev 2 (#41)

* fix kankyo UB

* Fix TEV Stage DL writing

BE issue

* BE Fixes in materials/shapes

* Move to Aurora GD impl

* JUTDataFileHeader

* j3d: load vertex and texture not through GD

* Endian swap vertex data (mostly)

* Just exit(0) when closing the game

Fix crashes :godo:

* fix fopAcM_ct_placement and remove memcpy

* J3D: track vertex arrays correctly, swap work

* fix visibility, turn off overridden new/delete when we call into aurora

* event: cut name be

* Default window improvements

Double size, allow OS to decide position

* survive TParse::parseHeader_next

* color swap fix

* swap endian/fixes oob function pointer

* Remove GXGetViewportv stub

Aurora has it now

* Set array pointers via GD again

Relies on https://github.com/encounter/aurora/pull/35

* Let Aurora decide graphics backend

* disable procbar drawing

* Fix TColor endianness conversion issues

Fixes the wrong color for the flashing logo

* cam param swap

* simplify vtx loading, mat/amb color fix

* endian swap stb/fvb data

* aurora stat changes

* fix storage buffer crash

dont unnecessarily reassign vertex buffers in a way that forces aurora to recache things

* set bgobj spec fix

* add camera debug, endian swap more stb data, d_a_bg_obj::spec_data_c swapped

* JKRExpHeap: fix bad allocator slowdown

* solid tex

* texture caching

* log level

* fix window aspect ratio, disable bloom, endian swap camera type data

camera is now actually playing opening cutscene!!!!

* add GXDestroyTexObj to a couple stack init'd GXTexObjs, remove some diag printfs

* endian swap joint weight envelope data

* move to dusk config

* verbose arg errors

* better stub logging (for now)

* less logging, more BE

* more stubbing, move logging stuff around

* move all logging to aurora logging

* fix STUB_LOG, __FUNCTION__ isn't a string literal, wasn't building as it
was.

* update aurora

* fix heap alignment mismatch and always head align for now

* prevent them from fucking up my shit

* forward jut warning to DuskLog

* remove report logging

* maybe and i must emphasize maybe fix JMessage parsing

* this was a dumb idea

* preserve negative alignment for JKRHeap

* use normal free on macos and linux

* ^

* fix JMAHermiteInterpolation c impl

* endian swap J2DScreen mColor (oops)

* swap more J3D anim data, remove weird pointer addr check in J3DMaterial getMaterialAnm

* typo fix

* Fix aligned_alloc() size issues on POSIX

aligned_alloc() requires its input size to be a multiple of alignment. This wasn't being upheld so there were allocation failures in init code that made the game fail to start outside Windows.

Also just cleaned up some of this code a bit and removed fallback cases that *shouldn't* get hit.

* _Exit instead of exit()

Seriously I don't want destructors to run. Let the OS reclaim that shit.

* Reapply "Isolate JKRHeap operator overloads" (#39)

This reverts commit 3623b27f37.

* Fix some oopsies

* Fix hardcoded pointer size in JUTCacheFont::allocArray

* More operator overload fixes

Add void template specialization for jkrDelete

Add new[] placement overload. Apparently.

* Fix delete macros on nullptr

TIL C++ allows that.

* fix delete[]

* fix new(std::nothrow) overload

* fix avoid ub

* swap remaining anim data needed for title logo

* get rid of op 7

* move aurora_end_frame to correct spot

* juttexture destroy tex

* j2d animation be

* shutdown crash

* link warp material fix

* mDoExt_3DlineMat1_c fix

* hacky keyboard controls

* endian swap J2DResReference, add kb_pad to files.cmake

* fix some missing endian swaps in J2D, remove addr alignment check

* Remove heap unsetting in aurora calls

Never worked properly and not the right solution even if it did

* Don't print in DC stubs

They're fine to never implement

* Fix alignment stuff again

* Compile GF from dolphin lib

Doesn't seem to break anything and shuts up some stub warnings

* j3dtexture tlut obj fix

* addTexMtxIndexInDL fix

* don't recreate null tex data every frame

* the actual fix i wanted to push

* its kinda fakematch city over here

* insert hte efb copy

* limited window size / viewport support

* IsDelete FIX

---------

Co-authored-by: madeline <qwertytrogi@gmail.com>
Co-authored-by: Jasper St. Pierre <jstpierre@mecheye.net>
Co-authored-by: Jeffrey Crowell <jeff@crowell.biz>
Co-authored-by: TakaRikka <takarikka@outlook.com>
Co-authored-by: CraftyBoss <talibabdulmaalik@gmail.com>
Co-authored-by: Lurs <2795933+Lurs@users.noreply.github.com>
This commit is contained in:
Pieter-Jan Briers
2026-03-08 23:27:15 +01:00
committed by GitHub
parent 820e2e3df6
commit b289dece80
726 changed files with 5289 additions and 4237 deletions
@@ -1,19 +1,21 @@
#include "JSystem/JSystem.h" // IWYU pragma: keep
#include "JSystem/J3DGraphLoader/J3DModelLoader.h"
#include "JSystem/J3DGraphAnimator/J3DAnimation.h"
#include "JSystem/J3DGraphAnimator/J3DShapeTable.h"
#include "JSystem/J3DGraphAnimator/J3DJointTree.h"
#include "JSystem/J3DGraphAnimator/J3DJoint.h"
#include "JSystem/J3DGraphAnimator/J3DJointTree.h"
#include "JSystem/J3DGraphAnimator/J3DModelData.h"
#include "JSystem/J3DGraphAnimator/J3DShapeTable.h"
#include "JSystem/J3DGraphBase/J3DMaterial.h"
#include "JSystem/J3DGraphLoader/J3DJointFactory.h"
#include "JSystem/J3DGraphLoader/J3DMaterialFactory.h"
#include "JSystem/J3DGraphLoader/J3DMaterialFactory_v21.h"
#include "JSystem/J3DGraphLoader/J3DModelLoader.h"
#include "JSystem/J3DGraphLoader/J3DShapeFactory.h"
#include "JSystem/J3DGraphAnimator/J3DModelData.h"
#include "JSystem/J3DGraphBase/J3DMaterial.h"
#include "JSystem/JUtility/JUTNameTab.h"
#include "JSystem/JKernel/JKRHeap.h"
#include "JSystem/JSupport/JSupport.h"
#include "JSystem/JUtility/JUTNameTab.h"
#include "SSystem/SComponent/c_xyz.h"
#include <utility>
J3DModelLoader::J3DModelLoader() :
mpModelData(NULL),
@@ -64,7 +66,7 @@ J3DModelData* J3DModelLoaderDataBase::loadBinaryDisplayList(const void* i_data,
J3DModelData* J3DModelLoader::load(void const* i_data, u32 i_flags) {
s32 freeSize = JKRGetCurrentHeap()->getTotalFreeSize();
mpModelData = new J3DModelData();
mpModelData = JKR_NEW J3DModelData();
J3D_ASSERT_ALLOCMEM(177, mpModelData);
mpModelData->clear();
mpModelData->mpRawData = i_data;
@@ -123,7 +125,7 @@ J3DModelData* J3DModelLoader::load(void const* i_data, u32 i_flags) {
J3DMaterialTable* J3DModelLoader::loadMaterialTable(void const* i_data) {
int flags = 0x51100000;
mpMaterialTable = new J3DMaterialTable();
mpMaterialTable = JKR_NEW J3DMaterialTable();
J3D_ASSERT_ALLOCMEM(279, mpMaterialTable);
mpMaterialTable->clear();
J3DModelFileData const* data = (J3DModelFileData*)i_data;
@@ -146,7 +148,7 @@ J3DMaterialTable* J3DModelLoader::loadMaterialTable(void const* i_data) {
block = (J3DModelBlock*)((uintptr_t)block + block->mBlockSize);
}
if (mpMaterialTable->mTexture == NULL) {
mpMaterialTable->mTexture = new J3DTexture(0, NULL);
mpMaterialTable->mTexture = JKR_NEW J3DTexture(0, NULL);
J3D_ASSERT_ALLOCMEM(319, mpMaterialTable->mTexture);
}
return mpMaterialTable;
@@ -157,7 +159,7 @@ inline u32 getBdlFlag_MaterialType(u32 flags) {
}
J3DModelData* J3DModelLoader::loadBinaryDisplayList(void const* i_data, u32 i_flags) {
mpModelData = new J3DModelData();
mpModelData = JKR_NEW J3DModelData();
J3D_ASSERT_ALLOCMEM(338, mpModelData);
mpModelData->clear();
mpModelData->mpRawData = i_data;
@@ -262,13 +264,13 @@ void J3DModelLoader::readInformation(J3DModelInfoBlock const* i_block, u32 i_fla
J3DMtxCalc* mtx_calc = NULL;
switch (mpModelData->mFlags & 0xf) {
case 0:
mtx_calc = new J3DMtxCalcNoAnm<J3DMtxCalcCalcTransformBasic,J3DMtxCalcJ3DSysInitBasic>();
mtx_calc = JKR_NEW J3DMtxCalcNoAnm<J3DMtxCalcCalcTransformBasic,J3DMtxCalcJ3DSysInitBasic>();
break;
case 1:
mtx_calc = new J3DMtxCalcNoAnm<J3DMtxCalcCalcTransformSoftimage,J3DMtxCalcJ3DSysInitSoftimage>();
mtx_calc = JKR_NEW J3DMtxCalcNoAnm<J3DMtxCalcCalcTransformSoftimage,J3DMtxCalcJ3DSysInitSoftimage>();
break;
case 2:
mtx_calc = new J3DMtxCalcNoAnm<J3DMtxCalcCalcTransformMaya,J3DMtxCalcJ3DSysInitMaya>();
mtx_calc = JKR_NEW J3DMtxCalcNoAnm<J3DMtxCalcCalcTransformMaya,J3DMtxCalcJ3DSysInitMaya>();
break;
default:
JUT_PANIC(529, "Error : Invalid MtxCalcType.");
@@ -279,8 +281,24 @@ void J3DModelLoader::readInformation(J3DModelInfoBlock const* i_block, u32 i_fla
mpModelData->getVertexData().mPacketNum = i_block->mPacketNum;
mpModelData->getVertexData().mVtxNum = i_block->mVtxNum;
mpModelData->setHierarchy(JSUConvertOffsetToPtr<J3DModelHierarchy>(i_block, i_block->mpHierarchy));
#if TARGET_PC
mpModelData->getVertexData().mHasReadInformation = true;
#endif
}
#if TARGET_PC
static GXVtxAttrFmtList getFmt(GXVtxAttrFmtList* i_fmtList, GXAttr i_attr) {
for (; i_fmtList->attr != GX_VA_NULL; i_fmtList++) {
if (i_fmtList->attr == i_attr) {
return *i_fmtList;
}
}
OSPanic(__FILE__, __LINE__, "Unable to find vertex attribute format!");
}
#endif
static GXCompType getFmtType(GXVtxAttrFmtList* i_fmtList, GXAttr i_attr) {
for (; i_fmtList->attr != GX_VA_NULL; i_fmtList++) {
if (i_fmtList->attr == i_attr) {
@@ -336,9 +354,11 @@ void J3DModelLoader::readVertex(J3DVertexBlock const* i_block) {
if (vertex_data.mVtxNrmArray == NULL) {
vertex_data.mNrmNum = 0;
} else if (nrm_end != NULL) {
vertex_data.mNrmNum = ((uintptr_t)nrm_end - (uintptr_t)vertex_data.mVtxNrmArray) / nrm_size + 1;
vertex_data.mNrmNum =
((uintptr_t)nrm_end - (uintptr_t)vertex_data.mVtxNrmArray) / nrm_size + 1;
} else {
vertex_data.mNrmNum = (i_block->mBlockSize - (uintptr_t)i_block->mpVtxNrmArray) / nrm_size + 1;
vertex_data.mNrmNum =
(i_block->mBlockSize - (uintptr_t)i_block->mpVtxNrmArray) / nrm_size + 1;
}
void* color0_end = NULL;
@@ -351,9 +371,11 @@ void J3DModelLoader::readVertex(J3DVertexBlock const* i_block) {
if (vertex_data.mVtxColorArray[0] == NULL) {
vertex_data.mColNum = 0;
} else if (color0_end != NULL) {
vertex_data.mColNum = ((uintptr_t)color0_end - (uintptr_t)vertex_data.mVtxColorArray[0]) / 4 + 1;
vertex_data.mColNum =
((uintptr_t)color0_end - (uintptr_t)vertex_data.mVtxColorArray[0]) / 4 + 1;
} else {
vertex_data.mColNum = (i_block->mBlockSize - (uintptr_t)i_block->mpVtxColorArray[0]) / 4 + 1;
vertex_data.mColNum =
(i_block->mBlockSize - (uintptr_t)i_block->mpVtxColorArray[0]) / 4 + 1;
}
int local_28 = 0;
@@ -368,21 +390,182 @@ void J3DModelLoader::readVertex(J3DVertexBlock const* i_block) {
if (local_28) {
vertex_data.mTexCoordNum = (local_28 - (uintptr_t)vertex_data.mVtxTexCoordArray[0]) / 8 + 1;
} else {
vertex_data.mTexCoordNum = (i_block->mBlockSize - (uintptr_t)i_block->mpVtxTexCoordArray[0]) / 8 + 1;
vertex_data.mTexCoordNum =
(i_block->mBlockSize - (uintptr_t)i_block->mpVtxTexCoordArray[0]) / 8 + 1;
}
#if TARGET_PC
readVertexData(*i_block, vertex_data);
#endif
}
#if TARGET_PC
// Approach taken from here:
// https://github.com/zeldaret/tp/blob/6c72b91f8e477ee94ccdc56b94605140e9f2abd6/libs/JSystem/src/J3DGraphBase/J3DShape.cpp#L156-L211
template <typename T>
static void FixArrayEndian(void* arrayStart, void* arrayEnd) {
#if TARGET_LITTLE_ENDIAN
u32 itemCount = ((u8*)arrayEnd - (u8*)arrayStart) / sizeof(T);
be_swap((T*)arrayStart, itemCount);
#endif
}
static void FixArrayEndian_24(void* arrayStart, void* arrayEnd) {
#if TARGET_LITTLE_ENDIAN
for (u8* work = (u8*)arrayStart; work != (u8*)arrayEnd; work += 3)
std::swap(work[0], work[2]);
#endif
}
static void FixArrayEndian(void* arrayStart, void* arrayEnd, u32 stride) {
switch (stride) {
case 1:
// Nothing needs to happen here!
break;
case 2:
FixArrayEndian<u16>(arrayStart, arrayEnd);
break;
case 3:
FixArrayEndian_24(arrayStart, arrayEnd);
break;
case 4:
FixArrayEndian<u32>(arrayStart, arrayEnd);
break;
default:
OSPanic(__FILE__, __LINE__, "Unknown component type?");
}
}
static GXAttr VertexBlockAttrOrder[13] = {
GX_VA_POS,
GX_VA_NRM,
GX_VA_NBT,
GX_VA_CLR0,
GX_VA_CLR1,
GX_VA_TEX0,
GX_VA_TEX1,
GX_VA_TEX2,
GX_VA_TEX3,
GX_VA_TEX4,
GX_VA_TEX5,
GX_VA_TEX6,
GX_VA_TEX7,
};
static void* GetDataEnd(const J3DVertexBlock& block, int start) {
const BE(u32)* attrPtrBase = &block.mpVtxPosArray;
for (int i = start + 1; i < ARRAY_SIZEU(VertexBlockAttrOrder); i++) {
if (attrPtrBase[i] != 0) {
return JSUConvertOffsetToPtr<void>(&block, attrPtrBase[i]);
}
}
return JSUConvertOffsetToPtr<void>(&block, block.mBlockSize);
}
auto StrideForData(GXAttr attr, GXCompType type, GXCompCnt cnt) -> std::pair<u32, u32> {
auto CompTypeStrideRaw = [&] {
if (type == GX_F32)
return 4;
else if (type == GX_U16 || type == GX_S16)
return 2;
else
return 1;
};
auto HandleColor = [&]() -> std::pair<u32, u32> {
if (type == GX_RGB565)
return {1, 2}; // u16[1]
else if (type == GX_RGB8)
return {3, 1}; // u8[3]
else if (type == GX_RGBX8)
return {4, 1}; // u8[4]
else if (type == GX_RGBA4)
return {1, 2}; // u16[1]
else if (type == GX_RGBA6)
return {3, 1}; // u8[3]
else if (type == GX_RGBA8)
return {4, 1}; // u8[4]
};
auto CompCnt = [&] {
if (attr == GX_VA_POS) {
return cnt == GX_POS_XY ? 2 : 3;
} else if (attr == GX_VA_NRM) {
return cnt == GX_NRM_XYZ ? 3 : 9; // NBT3 is lies
} else if (attr >= GX_VA_CLR0 && attr <= GX_VA_CLR1) {
return cnt == GX_CLR_RGB ? 3 : 4; // clr is special anyway
} else if (attr >= GX_VA_TEX0 && attr <= GX_VA_TEX7) {
return cnt == GX_TEX_S ? 1 : 2;
} else {
JUT_ASSERT(1234, false);
}
};
if (attr >= GX_VA_CLR0 && attr <= GX_VA_CLR1) {
return HandleColor();
} else {
int compCnt = CompCnt();
int compStride = CompTypeStrideRaw();
return {compCnt, compStride};
}
}
void J3DModelLoader::readVertexData(const J3DVertexBlock& block, J3DVertexData& data) {
if (!data.mHasReadInformation) {
OSPanic(__FILE__, __LINE__, "Model has VTX1 before INF1?");
}
const BE(u32)* attrPtrBase = &block.mpVtxPosArray;
for (int i = 0; i < ARRAY_SIZEU(VertexBlockAttrOrder); i++) {
GXAttr attr = VertexBlockAttrOrder[i];
if (attrPtrBase[i] == 0) {
continue;
}
GXVtxAttrFmtList fmt = getFmt(data.mVtxAttrFmtList, attr);
void* startAddr = JSUConvertOffsetToPtr<void>(&block, attrPtrBase[i]);
void* endAddr = GetDataEnd(block, i);
auto [compCnt, compStride] = StrideForData(attr, fmt.type, fmt.cnt);
u32 vertStride = compStride * compCnt;
data.mVtxArrStride[attr - GX_VA_POS] = vertStride;
u32 addrDiff = u32((u8*)endAddr - (u8*)startAddr);
u32 num = addrDiff / vertStride;
data.mVtxArrNum[attr - GX_VA_POS] = num;
FixArrayEndian(startAddr, endAddr, compStride);
if (attr == GX_VA_POS) {
// can be a little off due to 0x20 alignment, account for that
u32 expect = ((data.mVtxNum * vertStride) + 0x1F) & ~0x1F;
JUT_ASSERT(1234, expect == addrDiff);
} else if (attr == GX_VA_NRM) {
data.mNrmNum = num;
} else if (attr == GX_VA_CLR0) {
data.mColNum = num;
} else if (attr == GX_VA_TEX0) {
data.mTexCoordNum = num;
}
}
}
#endif
void J3DModelLoader::readEnvelop(J3DEnvelopeBlock const* i_block) {
J3D_ASSERT_NULLPTR(724, i_block);
mpModelData->getJointTree().mWEvlpMtxNum = i_block->mWEvlpMtxNum;
mpModelData->getJointTree().mWEvlpMixMtxNum =
JSUConvertOffsetToPtr<u8>(i_block, i_block->mpWEvlpMixMtxNum);
mpModelData->getJointTree().mWEvlpMixMtxIndex =
JSUConvertOffsetToPtr<u16>(i_block, i_block->mpWEvlpMixIndex);
JSUConvertOffsetToPtr<BE(u16)>(i_block, i_block->mpWEvlpMixIndex);
mpModelData->getJointTree().mWEvlpMixWeight =
JSUConvertOffsetToPtr<f32>(i_block, i_block->mpWEvlpMixWeight);
JSUConvertOffsetToPtr<BE(f32)>(i_block, i_block->mpWEvlpMixWeight);
mpModelData->getJointTree().mInvJointMtx =
JSUConvertOffsetToPtr<Mtx>(i_block, i_block->mpInvJointMtx);
JSUConvertOffsetToPtr<BE(Mtx)>(i_block, i_block->mpInvJointMtx);
}
void J3DModelLoader::readDraw(J3DDrawBlock const* i_block) {
@@ -390,7 +573,7 @@ void J3DModelLoader::readDraw(J3DDrawBlock const* i_block) {
J3DDrawMtxData* drawMtxData = mpModelData->getDrawMtxData();
drawMtxData->mEntryNum = i_block->mMtxNum - mpModelData->getWEvlpMtxNum();
drawMtxData->mDrawMtxFlag = JSUConvertOffsetToPtr<u8>(i_block, i_block->mpDrawMtxFlag);
drawMtxData->mDrawMtxIndex = JSUConvertOffsetToPtr<u16>(i_block, i_block->mpDrawMtxIndex);
drawMtxData->mDrawMtxIndex = JSUConvertOffsetToPtr<BE(u16)>(i_block, i_block->mpDrawMtxIndex);
u16 i;
for (i = 0; i < drawMtxData->mEntryNum; i++) {
if (drawMtxData->mDrawMtxFlag[i] == 1) {
@@ -398,7 +581,7 @@ void J3DModelLoader::readDraw(J3DDrawBlock const* i_block) {
}
}
drawMtxData->mDrawFullWgtMtxNum = i;
mpModelData->getJointTree().mWEvlpImportantMtxIdx = new u16[drawMtxData->mEntryNum];
mpModelData->getJointTree().mWEvlpImportantMtxIdx = JKR_NEW u16[drawMtxData->mEntryNum];
J3D_ASSERT_ALLOCMEM(767, mpModelData->getJointTree().mWEvlpImportantMtxIdx);
}
@@ -408,13 +591,13 @@ void J3DModelLoader::readJoint(J3DJointBlock const* i_block) {
mpModelData->getJointTree().mJointNum = i_block->mJointNum;
if (i_block->mpNameTable != NULL) {
mpModelData->getJointTree().mJointName =
new JUTNameTab(JSUConvertOffsetToPtr<ResNTAB>(i_block, i_block->mpNameTable));
JKR_NEW JUTNameTab(JSUConvertOffsetToPtr<ResNTAB>(i_block, i_block->mpNameTable));
J3D_ASSERT_ALLOCMEM(791, mpModelData->getJointTree().mJointName);
} else {
mpModelData->getJointTree().mJointName = NULL;
}
mpModelData->getJointTree().mJointNodePointer =
new J3DJoint*[mpModelData->getJointTree().mJointNum];
JKR_NEW J3DJoint*[mpModelData->getJointTree().mJointNum];
J3D_ASSERT_ALLOCMEM(797, mpModelData->getJointTree().mJointNodePointer);
for (u16 i = 0; i < mpModelData->getJointNum(); i++) {
mpModelData->getJointTree().mJointNodePointer[i] = factory.create(i);
@@ -428,15 +611,15 @@ void J3DModelLoader_v26::readMaterial(J3DMaterialBlock const* i_block, u32 i_fla
mpMaterialTable->mUniqueMatNum = factory.countUniqueMaterials();
if (i_block->mpNameTable != NULL) {
mpMaterialTable->mMaterialName =
new JUTNameTab(JSUConvertOffsetToPtr<ResNTAB>(i_block, i_block->mpNameTable));
JKR_NEW JUTNameTab(JSUConvertOffsetToPtr<ResNTAB>(i_block, i_block->mpNameTable));
J3D_ASSERT_ALLOCMEM(832, mpMaterialTable->mMaterialName);
} else {
mpMaterialTable->mMaterialName = NULL;
}
mpMaterialTable->mMaterialNodePointer = new J3DMaterial*[mpMaterialTable->mMaterialNum];
mpMaterialTable->mMaterialNodePointer = JKR_NEW J3DMaterial*[mpMaterialTable->mMaterialNum];
J3D_ASSERT_ALLOCMEM(841, mpMaterialTable->mMaterialNodePointer);
if (i_flags & 0x200000) {
mpMaterialTable->field_0x10 = new (0x20) J3DMaterial[mpMaterialTable->mUniqueMatNum];
mpMaterialTable->field_0x10 = JKR_NEW_ARGS (0x20) J3DMaterial[mpMaterialTable->mUniqueMatNum];
J3D_ASSERT_ALLOCMEM(846, mpMaterialTable->field_0x10);
} else {
mpMaterialTable->field_0x10 = NULL;
@@ -474,15 +657,15 @@ void J3DModelLoader_v21::readMaterial_v21(J3DMaterialBlock_v21 const* i_block, u
mpMaterialTable->mUniqueMatNum = factory.countUniqueMaterials();
if (i_block->mpNameTable != NULL) {
mpMaterialTable->mMaterialName =
new JUTNameTab(JSUConvertOffsetToPtr<ResNTAB>(i_block, i_block->mpNameTable));
JKR_NEW JUTNameTab(JSUConvertOffsetToPtr<ResNTAB>(i_block, i_block->mpNameTable));
J3D_ASSERT_ALLOCMEM(930, mpMaterialTable->mMaterialName);
} else {
mpMaterialTable->mMaterialName = NULL;
}
mpMaterialTable->mMaterialNodePointer = new J3DMaterial*[mpMaterialTable->mMaterialNum];
mpMaterialTable->mMaterialNodePointer = JKR_NEW J3DMaterial*[mpMaterialTable->mMaterialNum];
J3D_ASSERT_ALLOCMEM(940, mpMaterialTable->mMaterialNodePointer);
if (i_flags & 0x200000) {
mpMaterialTable->field_0x10 = new (0x20) J3DMaterial[mpMaterialTable->mUniqueMatNum];
mpMaterialTable->field_0x10 = JKR_NEW_ARGS (0x20) J3DMaterial[mpMaterialTable->mUniqueMatNum];
J3D_ASSERT_ALLOCMEM(945, mpMaterialTable->field_0x10);
} else {
mpMaterialTable->field_0x10 = NULL;
@@ -518,12 +701,12 @@ void J3DModelLoader::readShape(J3DShapeBlock const* i_block, u32 i_flags) {
shape_table->mShapeNum = i_block->mShapeNum;
if (i_block->mpNameTable != NULL) {
shape_table->mShapeName =
new JUTNameTab(JSUConvertOffsetToPtr<ResNTAB>(i_block, i_block->mpNameTable));
JKR_NEW JUTNameTab(JSUConvertOffsetToPtr<ResNTAB>(i_block, i_block->mpNameTable));
J3D_ASSERT_ALLOCMEM(1026, shape_table->mShapeName);
} else {
shape_table->mShapeName = NULL;
}
shape_table->mShapeNodePointer = new J3DShape*[shape_table->mShapeNum];
shape_table->mShapeNodePointer = JKR_NEW J3DShape*[shape_table->mShapeNum];
J3D_ASSERT_ALLOCMEM(1034, shape_table->mShapeNodePointer);
factory.allocVcdVatCmdBuffer(shape_table->mShapeNum);
J3DModelHierarchy const* hierarchy_entry = mpModelData->getHierarchy();
@@ -543,12 +726,12 @@ void J3DModelLoader::readTexture(J3DTextureBlock const* i_block) {
ResTIMG* texture_res = JSUConvertOffsetToPtr<ResTIMG>(i_block, i_block->mpTextureRes);
if (i_block->mpNameTable != NULL) {
mpMaterialTable->mTextureName =
new JUTNameTab(JSUConvertOffsetToPtr<ResNTAB>(i_block, i_block->mpNameTable));
JKR_NEW JUTNameTab(JSUConvertOffsetToPtr<ResNTAB>(i_block, i_block->mpNameTable));
J3D_ASSERT_ALLOCMEM(1077, mpMaterialTable->mTextureName);
} else {
mpMaterialTable->mTextureName = NULL;
}
mpMaterialTable->mTexture = new J3DTexture(texture_num, texture_res);
mpMaterialTable->mTexture = JKR_NEW J3DTexture(texture_num, texture_res);
J3D_ASSERT_ALLOCMEM(1084, mpMaterialTable->mTexture);
}
@@ -558,12 +741,12 @@ void J3DModelLoader_v26::readMaterialTable(J3DMaterialBlock const* i_block, u32
mpMaterialTable->mMaterialNum = i_block->mMaterialNum;
if (i_block->mpNameTable != NULL) {
mpMaterialTable->mMaterialName =
new JUTNameTab(JSUConvertOffsetToPtr<ResNTAB>(i_block, i_block->mpNameTable));
JKR_NEW JUTNameTab(JSUConvertOffsetToPtr<ResNTAB>(i_block, i_block->mpNameTable));
J3D_ASSERT_ALLOCMEM(1114, mpMaterialTable->mMaterialName);
} else {
mpMaterialTable->mMaterialName = NULL;
}
mpMaterialTable->mMaterialNodePointer = new J3DMaterial*[mpMaterialTable->mMaterialNum];
mpMaterialTable->mMaterialNodePointer = JKR_NEW J3DMaterial*[mpMaterialTable->mMaterialNum];
J3D_ASSERT_ALLOCMEM(1121, mpMaterialTable->mMaterialNodePointer);
for (u16 i = 0; i < mpMaterialTable->mMaterialNum; i++) {
mpMaterialTable->mMaterialNodePointer[i] =
@@ -581,12 +764,12 @@ void J3DModelLoader_v21::readMaterialTable_v21(J3DMaterialBlock_v21 const* i_blo
mpMaterialTable->mMaterialNum = i_block->mMaterialNum;
if (i_block->mpNameTable != NULL) {
mpMaterialTable->mMaterialName =
new JUTNameTab(JSUConvertOffsetToPtr<ResNTAB>(i_block, i_block->mpNameTable));
JKR_NEW JUTNameTab(JSUConvertOffsetToPtr<ResNTAB>(i_block, i_block->mpNameTable));
J3D_ASSERT_ALLOCMEM(1165, mpMaterialTable->mMaterialName);
} else {
mpMaterialTable->mMaterialName = NULL;
}
mpMaterialTable->mMaterialNodePointer = new J3DMaterial*[mpMaterialTable->mMaterialNum];
mpMaterialTable->mMaterialNodePointer = JKR_NEW J3DMaterial*[mpMaterialTable->mMaterialNum];
J3D_ASSERT_ALLOCMEM(1172, mpMaterialTable->mMaterialNodePointer);
for (u16 i = 0; i < mpMaterialTable->mMaterialNum; i++) {
mpMaterialTable->mMaterialNodePointer[i] =
@@ -604,12 +787,12 @@ void J3DModelLoader::readTextureTable(J3DTextureBlock const* i_block) {
ResTIMG* texture_res = JSUConvertOffsetToPtr<ResTIMG>(i_block, i_block->mpTextureRes);
if (i_block->mpNameTable != NULL) {
mpMaterialTable->mTextureName =
new JUTNameTab(JSUConvertOffsetToPtr<ResNTAB>(i_block, i_block->mpNameTable));
JKR_NEW JUTNameTab(JSUConvertOffsetToPtr<ResNTAB>(i_block, i_block->mpNameTable));
J3D_ASSERT_ALLOCMEM(1211, mpMaterialTable->mTextureName);
} else {
mpMaterialTable->mTextureName = NULL;
}
mpMaterialTable->mTexture = new J3DTexture(texture_num, texture_res);
mpMaterialTable->mTexture = JKR_NEW J3DTexture(texture_num, texture_res);
J3D_ASSERT_ALLOCMEM(1218, mpMaterialTable->mTexture);
}
@@ -620,12 +803,12 @@ void J3DModelLoader::readPatchedMaterial(J3DMaterialBlock const* i_block, u32 i_
mpMaterialTable->mUniqueMatNum = factory.countUniqueMaterials();
if (i_block->mpNameTable != NULL) {
mpMaterialTable->mMaterialName =
new JUTNameTab(JSUConvertOffsetToPtr<ResNTAB>(i_block, i_block->mpNameTable));
JKR_NEW JUTNameTab(JSUConvertOffsetToPtr<ResNTAB>(i_block, i_block->mpNameTable));
J3D_ASSERT_ALLOCMEM(1251, mpMaterialTable->mMaterialName);
} else {
mpMaterialTable->mMaterialName = NULL;
}
mpMaterialTable->mMaterialNodePointer = new J3DMaterial*[mpMaterialTable->mMaterialNum];
mpMaterialTable->mMaterialNodePointer = JKR_NEW J3DMaterial*[mpMaterialTable->mMaterialNum];
J3D_ASSERT_ALLOCMEM(1260, mpMaterialTable->mMaterialNodePointer);
mpMaterialTable->field_0x10 = NULL;
for (u16 i = 0; i < mpMaterialTable->mMaterialNum; i++) {
@@ -646,12 +829,12 @@ void J3DModelLoader::readMaterialDL(J3DMaterialDLBlock const* i_block, u32 i_fla
mpMaterialTable->mUniqueMatNum = i_block->mMaterialNum;
if (i_block->mpNameTable != NULL) {
mpMaterialTable->mMaterialName =
new JUTNameTab(JSUConvertOffsetToPtr<ResNTAB>(i_block, i_block->mpNameTable));
JKR_NEW JUTNameTab(JSUConvertOffsetToPtr<ResNTAB>(i_block, i_block->mpNameTable));
J3D_ASSERT_ALLOCMEM(1312, mpMaterialTable->mMaterialName);
} else {
mpMaterialTable->mMaterialName = NULL;
}
mpMaterialTable->mMaterialNodePointer = new J3DMaterial*[mpMaterialTable->mMaterialNum];
mpMaterialTable->mMaterialNodePointer = JKR_NEW J3DMaterial*[mpMaterialTable->mMaterialNum];
J3D_ASSERT_ALLOCMEM(1320, mpMaterialTable->mMaterialNodePointer);
mpMaterialTable->field_0x10 = NULL;
for (u16 i = 0; i < mpMaterialTable->mMaterialNum; i++) {