Pjb dev 3 (#48)

* Undo array allocation changes from #43

Doesn't work

* Expand dmeter heap sizes, give names

* Fix manual operator delete call in resource.cpp

* Disable map rendering for now

Aurora can't handle lines

* Re-enable assert heap on DVD thread

Should be fine?

* Some basic debug groups with the new Aurora API

* Allow Aurora backend to be set via CLI

* Give materials debug groups

* More debug groups

* JKRHeap separation: array edition

Pain
This commit is contained in:
Pieter-Jan Briers
2026-03-11 21:40:21 +01:00
committed by GitHub
parent 9e303b063f
commit 15732e241c
93 changed files with 440 additions and 313 deletions
+1 -1
View File
@@ -586,7 +586,7 @@ void J2DAnmTexPattern::searchUpdateMaterialID(J2DScreen* pScreen) {
}
}
JKR_DELETE_ARRAY(mTIMGPtrArray);
mTIMGPtrArray = JKR_NEW J2DAnmTexPatternTIMGPointer[pScreen->mTexRes->mCount];
mTIMGPtrArray = JKR_NEW_ARRAY(J2DAnmTexPatternTIMGPointer, pScreen->mTexRes->mCount);
if (mTIMGPtrArray != NULL) {
JUTResReference resRef;
for (u16 i = 0; i < pScreen->mTexRes->mCount; i++) {
+1 -1
View File
@@ -93,7 +93,7 @@ u8* J2DPrint::setBuffer(size_t size) {
JKR_DELETE(mStrBuff);
}
mStrBuff = JKR_NEW_ARGS (JKRGetSystemHeap(), 0) char[size];
mStrBuff = JKR_NEW_ARRAY_ARGS(char, size, JKRGetSystemHeap(), 0);
mStrBuffSize = size;
sStrBufInitialized = true;
return u8Buff;
+6 -6
View File
@@ -321,9 +321,9 @@ J2DResReference* J2DScreen::getResReference(JSURandomInputStream* p_stream, u32
char* buffer;
if (param_1 & 0x1F0000) {
buffer = JKR_NEW char[size1];
buffer = JKR_NEW_ARRAY(char, size1);
} else {
buffer = JKR_NEW_ARGS (-4) char[size1];
buffer = JKR_NEW_ARRAY_ARGS(char, size1, -4);
}
if (buffer != NULL) {
@@ -343,12 +343,12 @@ bool J2DScreen::createMaterial(JSURandomInputStream* p_stream, u32 param_1, JKRA
p_stream->skip(2);
if (param_1 & 0x1F0000) {
mMaterials = JKR_NEW J2DMaterial[mMaterialNum];
mMaterials = JKR_NEW_ARRAY(J2DMaterial, mMaterialNum);
} else {
mMaterials = JKR_NEW_ARGS (-4) J2DMaterial[mMaterialNum];
mMaterials = JKR_NEW_ARRAY_ARGS(J2DMaterial, mMaterialNum, -4);
}
u8* buffer = JKR_NEW_ARGS (-4) u8[header.mSize];
u8* buffer = JKR_NEW_ARRAY_ARGS(u8, header.mSize, -4);
if (mMaterials != NULL && buffer != NULL) {
J2DMaterialBlock* pBlock = (J2DMaterialBlock*)buffer;
p_stream->seek(position, JSUStreamSeekFrom_SET);
@@ -372,7 +372,7 @@ bool J2DScreen::createMaterial(JSURandomInputStream* p_stream, u32 param_1, JKRA
}
size++;
u8* nametab = JKR_NEW u8[size];
u8* nametab = JKR_NEW_ARRAY(u8, size);
if (nametab == NULL) {
goto failure;
}
+5 -5
View File
@@ -74,7 +74,7 @@ J2DTextBox::J2DTextBox(J2DPane* p_pane, JSURandomInputStream* p_stream, u32 para
mStringPtr = NULL;
if (strLength != 0) {
mStringPtr = JKR_NEW char[strLength];
mStringPtr = JKR_NEW_ARRAY(char, strLength);
}
if (mStringPtr != NULL) {
@@ -144,7 +144,7 @@ void J2DTextBox::initiate(ResFONT const* p_font, char const* string, s16 length,
stringLen = len + 1;
}
mStringPtr = JKR_NEW char[stringLen];
mStringPtr = JKR_NEW_ARRAY(char, stringLen);
if (stringLen != 0 && mStringPtr != NULL) {
strncpy(mStringPtr, string, stringLen - 1);
@@ -198,7 +198,7 @@ void J2DTextBox::private_readStream(J2DPane* p_pane, JSURandomInputStream* p_str
mFontSizeY = p_stream->read16b();
s16 stringLen = p_stream->read16b();
mStringPtr = JKR_NEW char[stringLen + 1];
mStringPtr = JKR_NEW_ARRAY(char, stringLen + 1);
if (mStringPtr != NULL) {
p_stream->read(mStringPtr, stringLen);
@@ -326,7 +326,7 @@ s32 J2DTextBox::setString(char const* string, ...) {
}
mStringLength = 0;
mStringPtr = JKR_NEW char[len + 1];
mStringPtr = JKR_NEW_ARRAY(char, len + 1);
if (mStringPtr) {
mStringLength = len + 1;
@@ -357,7 +357,7 @@ s32 J2DTextBox::setString(s16 length, char const* string, ...) {
mStringLength = 0;
if (stringLen != 0) {
mStringPtr = JKR_NEW char[stringLen];
mStringPtr = JKR_NEW_ARRAY(char, stringLen);
}
if (mStringPtr != NULL) {
+1 -1
View File
@@ -65,7 +65,7 @@ J2DTextBoxEx::J2DTextBoxEx(J2DPane* p_pane, JSURandomInputStream* p_stream, u32
mStringPtr = NULL;
if (strLength != 0) {
mStringPtr = JKR_NEW char[strLength];
mStringPtr = JKR_NEW_ARRAY(char, strLength);
}
if (mStringPtr != NULL) {
@@ -100,7 +100,7 @@ s32 J3DModel::createShapePacket(J3DModelData* pModelData) {
J3D_ASSERTMSG(173, pModelData != NULL, "Error : null pointer.");
if (pModelData->getShapeNum() != 0) {
mShapePacket = JKR_NEW J3DShapePacket[pModelData->getShapeNum()];
mShapePacket = JKR_NEW_ARRAY(J3DShapePacket, pModelData->getShapeNum());
if (mShapePacket == NULL) {
return kJ3DError_Alloc;
@@ -120,7 +120,7 @@ s32 J3DModel::createMatPacket(J3DModelData* pModelData, u32 mdlFlags) {
s32 ret = 0;
if (pModelData->getMaterialNum() != 0) {
mMatPacket = JKR_NEW J3DMatPacket[pModelData->getMaterialNum()];
mMatPacket = JKR_NEW_ARRAY(J3DMatPacket, pModelData->getMaterialNum());
if (mMatPacket == NULL) {
return kJ3DError_Alloc;
@@ -93,8 +93,8 @@ s32 J3DMtxBuffer::create(J3DModelData* pModelData, u32 mtxNum) {
J3DError J3DMtxBuffer::createAnmMtx(J3DModelData* pModelData) {
if (pModelData->getJointNum() != 0) {
mpScaleFlagArr = JKR_NEW u8[pModelData->getJointNum()];
mpAnmMtx = JKR_NEW Mtx[pModelData->getJointNum()];
mpScaleFlagArr = JKR_NEW_ARRAY(u8, pModelData->getJointNum());
mpAnmMtx = JKR_NEW_ARRAY(Mtx, pModelData->getJointNum());
mpUserAnmMtx = mpAnmMtx;
}
@@ -110,8 +110,8 @@ J3DError J3DMtxBuffer::createAnmMtx(J3DModelData* pModelData) {
s32 J3DMtxBuffer::createWeightEnvelopeMtx(J3DModelData* pModelData) {
if (pModelData->getWEvlpMtxNum() != 0) {
mpEvlpScaleFlagArr = JKR_NEW u8[pModelData->getWEvlpMtxNum()];
mpWeightEvlpMtx = JKR_NEW Mtx[pModelData->getWEvlpMtxNum()];
mpEvlpScaleFlagArr = JKR_NEW_ARRAY(u8, pModelData->getWEvlpMtxNum());
mpWeightEvlpMtx = JKR_NEW_ARRAY(Mtx, pModelData->getWEvlpMtxNum());
}
if (pModelData->getWEvlpMtxNum() != 0 && mpEvlpScaleFlagArr == NULL)
@@ -132,8 +132,8 @@ s32 J3DMtxBuffer::setNoUseDrawMtx() {
s32 J3DMtxBuffer::createDoubleDrawMtx(J3DModelData* pModelData, u32 mtxNum) {
if (mtxNum != 0) {
for (s32 i = 0; i < 2; i++) {
mpDrawMtxArr[i] = JKR_NEW Mtx*[mtxNum];
mpNrmMtxArr[i] = JKR_NEW Mtx33*[mtxNum];
mpDrawMtxArr[i] = JKR_NEW_ARRAY(Mtx*, mtxNum);
mpNrmMtxArr[i] = JKR_NEW_ARRAY(Mtx33*, mtxNum);
mpBumpMtxArr[i] = NULL;
}
}
@@ -150,8 +150,8 @@ s32 J3DMtxBuffer::createDoubleDrawMtx(J3DModelData* pModelData, u32 mtxNum) {
for (s32 i = 0; i < 2; i++) {
for (u32 j = 0; j < mtxNum; j++) {
if (pModelData->getDrawMtxNum() != 0) {
mpDrawMtxArr[i][j] = JKR_NEW_ARGS (0x20) Mtx[pModelData->getDrawMtxNum()];
mpNrmMtxArr[i][j] = JKR_NEW_ARGS (0x20) Mtx33[pModelData->getDrawMtxNum()];
mpDrawMtxArr[i][j] = JKR_NEW_ARRAY_ARGS(Mtx, pModelData->getDrawMtxNum(), 0x20);
mpNrmMtxArr[i][j] = JKR_NEW_ARRAY_ARGS(Mtx33, pModelData->getDrawMtxNum(), 0x20);
}
}
}
@@ -187,7 +187,7 @@ s32 J3DMtxBuffer::createBumpMtxArray(J3DModelData* i_modelData, u32 mtxNum) {
if (bumpMtxNum != 0 && mtxNum != 0) {
for (int i = 0; i < 2; i++) {
mpBumpMtxArr[i] = JKR_NEW Mtx33**[(u16)materialCount];
mpBumpMtxArr[i] = JKR_NEW_ARRAY(Mtx33**, (u16)materialCount);
if (mpBumpMtxArr[i] == NULL) {
return kJ3DError_Alloc;
}
@@ -200,7 +200,7 @@ s32 J3DMtxBuffer::createBumpMtxArray(J3DModelData* i_modelData, u32 mtxNum) {
for (u16 j = 0; j < materialNum; j++) {
J3DMaterial* material = i_modelData->getMaterialNodePointer(j);
if (material->getNBTScale()->mbHasScale == true) {
mpBumpMtxArr[i][offset] = JKR_NEW Mtx33*[mtxNum];
mpBumpMtxArr[i][offset] = JKR_NEW_ARRAY(Mtx33*, mtxNum);
if (mpBumpMtxArr[i][offset] == NULL) {
return kJ3DError_Alloc;
}
@@ -217,7 +217,7 @@ s32 J3DMtxBuffer::createBumpMtxArray(J3DModelData* i_modelData, u32 mtxNum) {
J3DMaterial* material = i_modelData->getMaterialNodePointer((u16)j);
if (material->getNBTScale()->mbHasScale == true) {
for (int k = 0; k < mtxNum; k++) {
mpBumpMtxArr[i][offset][k] = JKR_NEW_ARGS (0x20) Mtx33[i_modelData->getDrawMtxNum()];
mpBumpMtxArr[i][offset][k] = JKR_NEW_ARRAY_ARGS(Mtx33, i_modelData->getDrawMtxNum(), 0x20);
if (mpBumpMtxArr[i][offset][k] == NULL) {
return kJ3DError_Alloc;
}
@@ -99,7 +99,7 @@ void J3DSkinDeform::initSkinInfo(J3DModelData* pModelData) {
}
if (pModelData->getJointNum() != 0) {
mSkinNList = JKR_NEW J3DSkinNList[pModelData->getJointNum()];
mSkinNList = JKR_NEW_ARRAY(J3DSkinNList, pModelData->getJointNum());
}
for (int i = 0; i < pModelData->getVtxNum(); i++) {
@@ -138,13 +138,13 @@ void J3DSkinDeform::initSkinInfo(J3DModelData* pModelData) {
for (u16 i = 0; i < pModelData->getJointNum(); i++) {
if (mSkinNList[i].field_0x10) {
mSkinNList[i].field_0x0 = JKR_NEW u16[mSkinNList[i].field_0x10];
mSkinNList[i].field_0x8 = JKR_NEW f32[mSkinNList[i].field_0x10];
mSkinNList[i].field_0x0 = JKR_NEW_ARRAY(u16, mSkinNList[i].field_0x10);
mSkinNList[i].field_0x8 = JKR_NEW_ARRAY(f32, mSkinNList[i].field_0x10);
mSkinNList[i].field_0x10 = 0;
}
if (mSkinNList[i].field_0x12) {
mSkinNList[i].field_0x4 = JKR_NEW u16[mSkinNList[i].field_0x12];
mSkinNList[i].field_0xc = JKR_NEW f32[mSkinNList[i].field_0x12];
mSkinNList[i].field_0x4 = JKR_NEW_ARRAY(u16, mSkinNList[i].field_0x12);
mSkinNList[i].field_0xc = JKR_NEW_ARRAY(f32, mSkinNList[i].field_0x12);
mSkinNList[i].field_0x12 = 0;
}
}
@@ -202,7 +202,7 @@ int J3DSkinDeform::initMtxIndexArray(J3DModelData* pModelData) {
return kJ3DError_Success;
}
mPosData = JKR_NEW u16[pModelData->getVtxNum()];
mPosData = JKR_NEW_ARRAY(u16, pModelData->getVtxNum());
if (mPosData == NULL) {
return kJ3DError_Alloc;
}
@@ -212,7 +212,7 @@ int J3DSkinDeform::initMtxIndexArray(J3DModelData* pModelData) {
}
if (pModelData->getNrmNum()) {
mNrmData = JKR_NEW u16[pModelData->getNrmNum()];
mNrmData = JKR_NEW_ARRAY(u16, pModelData->getNrmNum());
if (mNrmData == NULL) {
return kJ3DError_Alloc;
}
@@ -223,8 +223,8 @@ int J3DSkinDeform::initMtxIndexArray(J3DModelData* pModelData) {
mNrmData = NULL;
}
mPosMtx = JKR_NEW Mtx[pModelData->getJointNum()];
mNrmMtx = JKR_NEW_ARGS (32) Mtx33[pModelData->getDrawMtxNum()];
mPosMtx = JKR_NEW_ARRAY(Mtx, pModelData->getJointNum());
mNrmMtx = JKR_NEW_ARRAY_ARGS(Mtx33, pModelData->getDrawMtxNum(), 32);
if (mPosMtx == NULL) {
return kJ3DError_Alloc;
}
@@ -25,7 +25,7 @@ void J3DDrawBuffer::initialize() {
}
int J3DDrawBuffer::allocBuffer(u32 size) {
mpBuffer = JKR_NEW_ARGS (0x20) J3DPacket*[size];
mpBuffer = JKR_NEW_ARRAY_ARGS(J3DPacket*, size, 0x20);
if (mpBuffer == NULL)
return kJ3DError_Alloc;
+19 -4
View File
@@ -12,8 +12,8 @@
J3DError J3DDisplayListObj::newDisplayList(u32 maxSize) {
mMaxSize = ALIGN_NEXT(maxSize, 0x20);
mpDisplayList[0] = JKR_NEW_ARGS (0x20) char[mMaxSize];
mpDisplayList[1] = JKR_NEW_ARGS (0x20) char[mMaxSize];
mpDisplayList[0] = JKR_NEW_ARRAY_ARGS(char, mMaxSize, 0x20);
mpDisplayList[1] = JKR_NEW_ARRAY_ARGS(char, mMaxSize, 0x20);
mSize = 0;
if (mpDisplayList[0] == NULL || mpDisplayList[1] == NULL)
@@ -24,7 +24,7 @@ J3DError J3DDisplayListObj::newDisplayList(u32 maxSize) {
J3DError J3DDisplayListObj::newSingleDisplayList(u32 maxSize) {
mMaxSize = ALIGN_NEXT(maxSize, 0x20);
mpDisplayList[0] = JKR_NEW_ARGS (0x20) char[mMaxSize];
mpDisplayList[0] = JKR_NEW_ARRAY_ARGS(char, mMaxSize, 0x20);
mpDisplayList[1] = mpDisplayList[0];
mSize = 0;
@@ -36,7 +36,7 @@ J3DError J3DDisplayListObj::newSingleDisplayList(u32 maxSize) {
int J3DDisplayListObj::single_To_Double() {
if (mpDisplayList[0] == mpDisplayList[1]) {
mpDisplayList[1] = JKR_NEW_ARGS (0x20) char[mMaxSize];
mpDisplayList[1] = JKR_NEW_ARRAY_ARGS(char, mMaxSize, 0x20);
if (mpDisplayList[1] == NULL)
return kJ3DError_Alloc;
@@ -211,6 +211,15 @@ void J3DMatPacket::draw() {
j3dSys.setTexture(mpTexture);
#endif
mpMaterial->load();
#if TARGET_PC
if (mpMaterial->mMaterialName != nullptr) {
char buf[64];
snprintf(buf, sizeof(buf), "Mat: %s", mpMaterial->mMaterialName);
GXPushDebugGroup(buf);
}
#endif
callDL();
J3DShapePacket* packet = getShapePacket();
@@ -229,6 +238,12 @@ void J3DMatPacket::draw() {
}
J3DShape::resetVcdVatCache();
#if TARGET_PC
if (mpMaterial->mMaterialName != nullptr) {
GXPopDebugGroup();
}
#endif
}
J3DShapePacket::J3DShapePacket() {
+1 -1
View File
@@ -87,7 +87,7 @@ void J3DShape::addTexMtxIndexInVcd(GXAttr attr) {
if (attrIdx == -1)
return;
GXVtxDescList* newVtxDesc = JKR_NEW GXVtxDescList[attrCount + 2];
GXVtxDescList* newVtxDesc = JKR_NEW_ARRAY(GXVtxDescList, attrCount + 2);
bool inserted = false;
vtxDesc = getVtxDesc();
@@ -28,7 +28,7 @@ void J3DShapeDraw::addTexMtxIndexInDL(u32 stride, u32 attrOffs, u32 valueBase) {
u32 byteNum = countVertex(stride);
u32 oldSize = mDisplayListSize;
u32 newSize = ALIGN_NEXT(oldSize + byteNum, 0x20);
u8* newDLStart = JKR_NEW_ARGS (0x20) u8[newSize];
u8* newDLStart = JKR_NEW_ARRAY_ARGS(u8, newSize, 0x20);
u8* oldDLStart = (u8*)mDisplayList;
u8* oldDL = oldDLStart;
u8* newDL = newDLStart;
+1 -1
View File
@@ -81,7 +81,7 @@ void J3DTexture::entryNum(u16 num) {
J3D_ASSERT_NONZEROARG(79, num != 0);
mNum = num;
mpRes = JKR_NEW ResTIMG[num];
mpRes = JKR_NEW_ARRAY(ResTIMG, num);
J3D_ASSERT_ALLOCMEM(83, mpRes != NULL);
delete[] mpTexObj;
+6 -6
View File
@@ -76,7 +76,7 @@ void J3DVertexBuffer::setArray() const {
s32 J3DVertexBuffer::copyLocalVtxPosArray(u32 flag) {
if (flag & 1) {
for (int i = 0; i < 2; i++) {
mVtxPosArray[i] = JKR_NEW_ARGS (0x20) char[mVtxData->getVtxNum() * 3 * 4];
mVtxPosArray[i] = JKR_NEW_ARRAY_ARGS(char, mVtxData->getVtxNum() * 3 * 4, 0x20);
if (mVtxPosArray[i] == NULL) {
return kJ3DError_Alloc;
}
@@ -88,7 +88,7 @@ s32 J3DVertexBuffer::copyLocalVtxPosArray(u32 flag) {
mVtxPosArray[0] = mVtxData->getVtxPosArray();
if (mVtxPosArray[1] == NULL) {
mVtxPosArray[1] = JKR_NEW_ARGS (0x20) char[mVtxData->getVtxNum() * 3 * 4];
mVtxPosArray[1] = JKR_NEW_ARRAY_ARGS(char, mVtxData->getVtxNum() * 3 * 4, 0x20);
if (mVtxPosArray[1] == NULL) {
return kJ3DError_Alloc;
}
@@ -104,7 +104,7 @@ s32 J3DVertexBuffer::copyLocalVtxPosArray(u32 flag) {
s32 J3DVertexBuffer::copyLocalVtxNrmArray(u32 flag) {
if (flag & 1) {
for (int i = 0; i < 2; i++) {
mVtxNrmArray[i] = JKR_NEW_ARGS (0x20) char[mVtxData->getNrmNum() * 3 * 4];
mVtxNrmArray[i] = JKR_NEW_ARRAY_ARGS(char, mVtxData->getNrmNum() * 3 * 4, 0x20);
if (mVtxNrmArray[i] == NULL) {
return kJ3DError_Alloc;
}
@@ -116,7 +116,7 @@ s32 J3DVertexBuffer::copyLocalVtxNrmArray(u32 flag) {
mVtxNrmArray[0] = mVtxData->getVtxNrmArray();
if (mVtxNrmArray[1] == NULL) {
mVtxNrmArray[1] = JKR_NEW_ARGS (0x20) char[mVtxData->getNrmNum() * 3 * 4];
mVtxNrmArray[1] = JKR_NEW_ARRAY_ARGS(char, mVtxData->getNrmNum() * 3 * 4, 0x20);
if (mVtxNrmArray[1] == NULL) {
return kJ3DError_Alloc;
}
@@ -186,7 +186,7 @@ s32 J3DVertexBuffer::allocTransformedVtxPosArray() {
for (int i = 0; i < 2; i++) {
if (i == 0 || mTransformedVtxPosArray[i] == NULL) {
mTransformedVtxPosArray[i] = JKR_NEW_ARGS (0x20) char[mVtxData->getVtxNum() * 3 * 4];
mTransformedVtxPosArray[i] = JKR_NEW_ARRAY_ARGS(char, mVtxData->getVtxNum() * 3 * 4, 0x20);
if (mTransformedVtxPosArray[i] == NULL)
return kJ3DError_Alloc;
}
@@ -201,7 +201,7 @@ s32 J3DVertexBuffer::allocTransformedVtxNrmArray() {
for (int i = 0; i < 2; i++) {
if (i == 0 || mTransformedVtxNrmArray[i] == NULL) {
mTransformedVtxNrmArray[i] = JKR_NEW_ARGS (0x20) char[mVtxData->getNrmNum() * 3 * 4];
mTransformedVtxNrmArray[i] = JKR_NEW_ARRAY_ARGS(char, mVtxData->getNrmNum() * 3 * 4, 0x20);
if (mTransformedVtxNrmArray[i] == NULL)
return kJ3DError_Alloc;
}
@@ -76,14 +76,14 @@ void J3DClusterLoader_v15::readCluster(const J3DClusterBlock* block) {
int clusterKeyPointerSize = (intptr_t)block->mClusterKeyPointer - (intptr_t)block->mClusterPointer;
int clusterVertexPointerSize = (intptr_t)block->mClusterVertex - (intptr_t)block->mClusterPointer;
int vtxPosSize = (intptr_t)block->mVtxPos - (intptr_t)block->mClusterPointer;
u8* arr = JKR_NEW_ARGS (0x20) u8[vtxPosSize];
u8* arr = JKR_NEW_ARRAY_ARGS(u8, vtxPosSize, 0x20);
memcpy(arr, JSUConvertOffsetToPtr<J3DCluster>(block, block->mClusterPointer), vtxPosSize);
mpDeformData->mClusterPointer = (J3DCluster*)arr;
mpDeformData->mClusterKeyPointer = (J3DClusterKey*)&arr[clusterKeyPointerSize];
mpDeformData->mClusterVertex = (J3DClusterVertex*)&arr[clusterVertexPointerSize];
#if TARGET_PC
mpDeformData->mDeformers = JKR_NEW J3DDeformer*[mpDeformData->getClusterNum()];
mpDeformData->mDeformers = JKR_NEW_ARRAY(J3DDeformer*, mpDeformData->getClusterNum());
#endif
for (int i = 0; i < mpDeformData->getClusterNum(); i++) {
@@ -96,12 +96,12 @@ void J3DClusterLoader_v15::readCluster(const J3DClusterBlock* block) {
#endif
J3DDeformer* deformer = JKR_NEW J3DDeformer(mpDeformData);
if (cluster->field_0x14 != 0) {
deformer->field_0xc = JKR_NEW f32[cluster->field_0x14 * 3];
deformer->field_0xc = JKR_NEW_ARRAY(f32, cluster->field_0x14 * 3);
} else {
deformer->field_0xc = NULL;
}
deformer->mFlags = cluster->mFlags;
deformer->field_0x8 = JKR_NEW f32[cluster->mKeyNum];
deformer->field_0x8 = JKR_NEW_ARRAY(f32, cluster->mKeyNum);
#if TARGET_PC
deformer->mArrayBase = arr - clusterPointer;
deformer->mBlockBase = block;
@@ -17,6 +17,17 @@
#include "SSystem/SComponent/c_xyz.h"
#include <utility>
#if TARGET_PC
static void AssignMaterialNames(const J3DModelLoader& loader) {
auto table = loader.mpMaterialTable;
auto materialName = table->getMaterialName();
for (int i = 0; i < table->getMaterialNum(); i++) {
auto mat = table->getMaterialNodePointer(i);
mat->mMaterialName = materialName->getName(i);
}
}
#endif
J3DModelLoader::J3DModelLoader() :
mpModelData(NULL),
mpMaterialTable(NULL),
@@ -119,6 +130,9 @@ J3DModelData* J3DModelLoader::load(void const* i_data, u32 i_flags) {
mpModelData->getShapeNodePointer(shape_no)->onFlag(0x200);
}
}
#if TARGET_PC
AssignMaterialNames(*this);
#endif
return mpModelData;
}
@@ -581,7 +595,7 @@ void J3DModelLoader::readDraw(J3DDrawBlock const* i_block) {
}
}
drawMtxData->mDrawFullWgtMtxNum = i;
mpModelData->getJointTree().mWEvlpImportantMtxIdx = JKR_NEW u16[drawMtxData->mEntryNum];
mpModelData->getJointTree().mWEvlpImportantMtxIdx = JKR_NEW_ARRAY(u16, drawMtxData->mEntryNum);
J3D_ASSERT_ALLOCMEM(767, mpModelData->getJointTree().mWEvlpImportantMtxIdx);
}
@@ -597,7 +611,7 @@ void J3DModelLoader::readJoint(J3DJointBlock const* i_block) {
mpModelData->getJointTree().mJointName = NULL;
}
mpModelData->getJointTree().mJointNodePointer =
JKR_NEW J3DJoint*[mpModelData->getJointTree().mJointNum];
JKR_NEW_ARRAY(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);
@@ -616,10 +630,10 @@ void J3DModelLoader_v26::readMaterial(J3DMaterialBlock const* i_block, u32 i_fla
} else {
mpMaterialTable->mMaterialName = NULL;
}
mpMaterialTable->mMaterialNodePointer = JKR_NEW J3DMaterial*[mpMaterialTable->mMaterialNum];
mpMaterialTable->mMaterialNodePointer = JKR_NEW_ARRAY(J3DMaterial*, mpMaterialTable->mMaterialNum);
J3D_ASSERT_ALLOCMEM(841, mpMaterialTable->mMaterialNodePointer);
if (i_flags & 0x200000) {
mpMaterialTable->field_0x10 = JKR_NEW_ARGS (0x20) J3DMaterial[mpMaterialTable->mUniqueMatNum];
mpMaterialTable->field_0x10 = JKR_NEW_ARRAY_ARGS(J3DMaterial, mpMaterialTable->mUniqueMatNum, 0x20);
J3D_ASSERT_ALLOCMEM(846, mpMaterialTable->field_0x10);
} else {
mpMaterialTable->field_0x10 = NULL;
@@ -662,10 +676,10 @@ void J3DModelLoader_v21::readMaterial_v21(J3DMaterialBlock_v21 const* i_block, u
} else {
mpMaterialTable->mMaterialName = NULL;
}
mpMaterialTable->mMaterialNodePointer = JKR_NEW J3DMaterial*[mpMaterialTable->mMaterialNum];
mpMaterialTable->mMaterialNodePointer = JKR_NEW_ARRAY(J3DMaterial*, mpMaterialTable->mMaterialNum);
J3D_ASSERT_ALLOCMEM(940, mpMaterialTable->mMaterialNodePointer);
if (i_flags & 0x200000) {
mpMaterialTable->field_0x10 = JKR_NEW_ARGS (0x20) J3DMaterial[mpMaterialTable->mUniqueMatNum];
mpMaterialTable->field_0x10 = JKR_NEW_ARRAY_ARGS(J3DMaterial, mpMaterialTable->mUniqueMatNum, 0x20);
J3D_ASSERT_ALLOCMEM(945, mpMaterialTable->field_0x10);
} else {
mpMaterialTable->field_0x10 = NULL;
@@ -706,7 +720,7 @@ void J3DModelLoader::readShape(J3DShapeBlock const* i_block, u32 i_flags) {
} else {
shape_table->mShapeName = NULL;
}
shape_table->mShapeNodePointer = JKR_NEW J3DShape*[shape_table->mShapeNum];
shape_table->mShapeNodePointer = JKR_NEW_ARRAY(J3DShape*, shape_table->mShapeNum);
J3D_ASSERT_ALLOCMEM(1034, shape_table->mShapeNodePointer);
factory.allocVcdVatCmdBuffer(shape_table->mShapeNum);
J3DModelHierarchy const* hierarchy_entry = mpModelData->getHierarchy();
@@ -746,7 +760,7 @@ void J3DModelLoader_v26::readMaterialTable(J3DMaterialBlock const* i_block, u32
} else {
mpMaterialTable->mMaterialName = NULL;
}
mpMaterialTable->mMaterialNodePointer = JKR_NEW J3DMaterial*[mpMaterialTable->mMaterialNum];
mpMaterialTable->mMaterialNodePointer = JKR_NEW_ARRAY(J3DMaterial*, mpMaterialTable->mMaterialNum);
J3D_ASSERT_ALLOCMEM(1121, mpMaterialTable->mMaterialNodePointer);
for (u16 i = 0; i < mpMaterialTable->mMaterialNum; i++) {
mpMaterialTable->mMaterialNodePointer[i] =
@@ -769,7 +783,7 @@ void J3DModelLoader_v21::readMaterialTable_v21(J3DMaterialBlock_v21 const* i_blo
} else {
mpMaterialTable->mMaterialName = NULL;
}
mpMaterialTable->mMaterialNodePointer = JKR_NEW J3DMaterial*[mpMaterialTable->mMaterialNum];
mpMaterialTable->mMaterialNodePointer = JKR_NEW_ARRAY(J3DMaterial*, mpMaterialTable->mMaterialNum);
J3D_ASSERT_ALLOCMEM(1172, mpMaterialTable->mMaterialNodePointer);
for (u16 i = 0; i < mpMaterialTable->mMaterialNum; i++) {
mpMaterialTable->mMaterialNodePointer[i] =
@@ -808,7 +822,7 @@ void J3DModelLoader::readPatchedMaterial(J3DMaterialBlock const* i_block, u32 i_
} else {
mpMaterialTable->mMaterialName = NULL;
}
mpMaterialTable->mMaterialNodePointer = JKR_NEW J3DMaterial*[mpMaterialTable->mMaterialNum];
mpMaterialTable->mMaterialNodePointer = JKR_NEW_ARRAY(J3DMaterial*, mpMaterialTable->mMaterialNum);
J3D_ASSERT_ALLOCMEM(1260, mpMaterialTable->mMaterialNodePointer);
mpMaterialTable->field_0x10 = NULL;
for (u16 i = 0; i < mpMaterialTable->mMaterialNum; i++) {
@@ -834,7 +848,7 @@ void J3DModelLoader::readMaterialDL(J3DMaterialDLBlock const* i_block, u32 i_fla
} else {
mpMaterialTable->mMaterialName = NULL;
}
mpMaterialTable->mMaterialNodePointer = JKR_NEW J3DMaterial*[mpMaterialTable->mMaterialNum];
mpMaterialTable->mMaterialNodePointer = JKR_NEW_ARRAY(J3DMaterial*, mpMaterialTable->mMaterialNum);
J3D_ASSERT_ALLOCMEM(1320, mpMaterialTable->mMaterialNodePointer);
mpMaterialTable->field_0x10 = NULL;
for (u16 i = 0; i < mpMaterialTable->mMaterialNum; i++) {
@@ -46,9 +46,9 @@ J3DShape* J3DShapeFactory::create(int no, u32 flag, GXVtxDescList* vtxDesc) {
shape->mMtxGroupNum = getMtxGroupNum(no);
shape->mRadius = getRadius(no);
shape->mVtxDesc = getVtxDescList(no);
shape->mShapeMtx = JKR_NEW J3DShapeMtx*[shape->mMtxGroupNum];
shape->mShapeMtx = JKR_NEW_ARRAY(J3DShapeMtx*, shape->mMtxGroupNum);
J3D_ASSERT_ALLOCMEM(74, shape->mShapeMtx);
shape->mShapeDraw = JKR_NEW J3DShapeDraw*[shape->mMtxGroupNum];
shape->mShapeDraw = JKR_NEW_ARRAY(J3DShapeDraw*, shape->mMtxGroupNum);
J3D_ASSERT_ALLOCMEM(76, shape->mShapeDraw);
shape->mMin = getMin(no);
shape->mMax = getMax(no);
@@ -138,7 +138,7 @@ J3DShapeDraw* J3DShapeFactory::newShapeDraw(int shapeNo, int mtxGroupNo) const {
}
void J3DShapeFactory::allocVcdVatCmdBuffer(u32 count) {
mVcdVatCmdBuffer = JKR_NEW_ARGS (0x20) u8[J3DShape::kVcdVatDLSize * count];
mVcdVatCmdBuffer = JKR_NEW_ARRAY_ARGS(u8, J3DShape::kVcdVatDLSize * count, 0x20);
J3D_ASSERT_ALLOCMEM(211, mVcdVatCmdBuffer);
for (u32 i = 0; i < (J3DShape::kVcdVatDLSize * count) / 4; i++)
((u32*)mVcdVatCmdBuffer)[i] = 0;
+3 -3
View File
@@ -51,15 +51,15 @@ void JASDriver::initAI(void (*param_0)(void)) {
u32 dacSize = getDacSize();
const u32 size = dacSize * 2;
for (int i = 0; i < 3; i++) {
sDmaDacBuffer[i] = JKR_NEW_ARGS(JASDram, 0x20) s16[dacSize];
sDmaDacBuffer[i] = JKR_NEW_ARRAY_ARGS(s16, dacSize, JASDram, 0x20);
JUT_ASSERT(102, sDmaDacBuffer[i])
JASCalc::bzero(sDmaDacBuffer[i], size);
DCStoreRange(sDmaDacBuffer[i], size);
}
sDspDacBuffer = JKR_NEW_ARGS(JASDram, 0) s16*[data_804507A8];
sDspDacBuffer = JKR_NEW_ARRAY_ARGS(s16*, data_804507A8, JASDram, 0);
JUT_ASSERT(113, sDspDacBuffer);
for (int i = 0; i < data_804507A8; i++) {
sDspDacBuffer[i] = JKR_NEW_ARGS(JASDram, 0x20) s16[getDacSize()];
sDspDacBuffer[i] = JKR_NEW_ARRAY_ARGS(s16, getDacSize(), JASDram, 0x20);
JUT_ASSERT(119, sDspDacBuffer[i]);
JASCalc::bzero(sDspDacBuffer[i], size);
DCStoreRange(sDspDacBuffer[i], size);
+1 -1
View File
@@ -33,7 +33,7 @@ void JASAramStream::initSystem(u32 block_size, u32 channel_max) {
if (sLoadThread == NULL) {
sLoadThread = JASDvd::getThreadPointer();
}
sReadBuffer = JKR_NEW_ARGS (JASDram, 0x20) u8[(block_size + 0x20) * channel_max];
sReadBuffer = JKR_NEW_ARRAY_ARGS(u8, (block_size + 0x20) * channel_max, JASDram, 0x20);
JUT_ASSERT(79, sReadBuffer);
sBlockSize = block_size;
sChannelMax = channel_max;
+4 -4
View File
@@ -68,12 +68,12 @@ JASBasicBank* JASBNKParser::Ver1::createBasicBank(void const* stream, JKRHeap* h
TListChunk* list_chunk = (TListChunk*)findChunk(stream, 'LIST');
JUT_ASSERT(145, list_chunk);
u8* envt = JKR_NEW_ARGS (heap, 2) u8[envt_chunk->mSize];
u8* envt = JKR_NEW_ARRAY_ARGS(u8, envt_chunk->mSize, heap, 2);
JASCalc::bcopy(envt_chunk->mData, envt, envt_chunk->mSize);
BE(u32)* ptr = &osc_chunk->mCount;
u32 count = *ptr++;
JASOscillator::Data* osc_data = JKR_NEW_ARGS (heap, 0) JASOscillator::Data[count];
JASOscillator::Data* osc_data = JKR_NEW_ARRAY_ARGS(JASOscillator::Data, count, heap, 0);
for (int i = 0; i < count; i++, ptr += sizeof(TOsc) >> 2) {
TOsc* op = (TOsc*)ptr;
JUT_ASSERT(155, op->id == 'Osci');
@@ -209,7 +209,7 @@ JASBasicBank* JASBNKParser::Ver0::createBasicBank(void const* stream, JKRHeap* h
if (points != NULL) {
const JASOscillator::Point* endPtr = getOscTableEndPtr(points);
int size = endPtr - points;
JASOscillator::Point* table = JKR_NEW_ARGS (heap, 0) JASOscillator::Point[size];
JASOscillator::Point* table = JKR_NEW_ARRAY_ARGS(JASOscillator::Point, size, heap, 0);
JUT_ASSERT(396, table != NULL);
JASCalc::bcopy(points, table, size * sizeof(JASOscillator::Point));
osc->mTable = table;
@@ -221,7 +221,7 @@ JASBasicBank* JASBNKParser::Ver0::createBasicBank(void const* stream, JKRHeap* h
if (points != NULL) {
const JASOscillator::Point* endPtr = getOscTableEndPtr(points);
int size = endPtr - points;
JASOscillator::Point* table = JKR_NEW_ARGS (heap, 0) JASOscillator::Point[size];
JASOscillator::Point* table = JKR_NEW_ARRAY_ARGS(JASOscillator::Point, size, heap, 0);
JUT_ASSERT(409, table != NULL);
JASCalc::bcopy(points, table, size * sizeof(JASOscillator::Point));
osc->rel_table = table;
+1 -1
View File
@@ -12,7 +12,7 @@ void JASBasicBank::newInstTable(u8 num, JKRHeap* heap) {
if (num != 0) {
JUT_ASSERT(31, num <= JASBank::PRG_OSC);
mInstNumMax = num;
mInstTable = JKR_NEW_ARGS (heap, 0) JASInst*[mInstNumMax];
mInstTable = JKR_NEW_ARRAY_ARGS(JASInst*, mInstNumMax, heap, 0);
JASCalc::bzero(mInstTable, mInstNumMax * 4);
}
}
+1 -1
View File
@@ -49,7 +49,7 @@ bool JASBasicInst::getParam(int param_0, int param_1, JASInstParam* param_2) con
void JASBasicInst::setKeyRegionCount(u32 count, JKRHeap* param_1) {
JKR_DELETE_ARRAY(mKeymap);
mKeymap = JKR_NEW_ARGS (param_1, 0) TKeymap[count];
mKeymap = JKR_NEW_ARRAY_ARGS(TKeymap, count, param_1, 0);
JUT_ASSERT(114, mKeymap != NULL);
mKeymapCount = count;
}
@@ -29,7 +29,7 @@ JASBasicWaveBank::TWaveGroup* JASBasicWaveBank::getWaveGroup(u32 param_0) {
void JASBasicWaveBank::setGroupCount(u32 param_0, JKRHeap* param_1) {
JKR_DELETE_ARRAY(mWaveGroupArray);
mGroupCount = param_0;
mWaveGroupArray = JKR_NEW_ARGS(param_1, 0) TWaveGroup[param_0];
mWaveGroupArray = JKR_NEW_ARRAY_ARGS(TWaveGroup, param_0, param_1, 0);
JUT_ASSERT(62, mWaveGroupArray != NULL);
for (int i = 0; i < mGroupCount; i++) {
mWaveGroupArray[i].mBank = this;
@@ -38,7 +38,7 @@ void JASBasicWaveBank::setGroupCount(u32 param_0, JKRHeap* param_1) {
void JASBasicWaveBank::setWaveTableSize(u32 param_0, JKRHeap* param_1) {
JKR_DELETE_ARRAY(mWaveTable);
mWaveTable = JKR_NEW_ARGS(param_1, 0) TWaveHandle[param_0];
mWaveTable = JKR_NEW_ARRAY_ARGS(TWaveHandle, param_0, param_1, 0);
JUT_ASSERT(92, mWaveTable != NULL);
mHandleCount = param_0;
}
@@ -104,7 +104,7 @@ JASBasicWaveBank::TWaveGroup::~TWaveGroup() {
void JASBasicWaveBank::TWaveGroup::setWaveCount(u32 param_0, JKRHeap* param_1) {
JKR_DELETE_ARRAY(mCtrlWaveArray);
mWaveCount = param_0;
mCtrlWaveArray = JKR_NEW_ARGS(param_1, 0) TGroupWaveInfo[param_0];
mCtrlWaveArray = JKR_NEW_ARRAY_ARGS(TGroupWaveInfo, param_0, param_1, 0);
JUT_ASSERT(255, mCtrlWaveArray != NULL);
}
+1 -1
View File
@@ -42,7 +42,7 @@ void JASDSPChannel::drop() {
}
void JASDSPChannel::initAll() {
sDspChannels = JKR_NEW_ARGS (JASDram, 0x20) JASDSPChannel[0x40];
sDspChannels = JKR_NEW_ARRAY_ARGS(JASDSPChannel, 0x40, JASDram, 0x20);
JUT_ASSERT(102, sDspChannels);
for (int i = 0; i < 0x40; i++) {
sDspChannels[i].mChannel = JASDsp::getDSPHandle(i);
+2 -2
View File
@@ -426,9 +426,9 @@ u32 const ATTRIBUTE_ALIGN(32) JASDsp::DSPRES_FILTER[320] = {
};
void JASDsp::initBuffer() {
CH_BUF = JKR_NEW_ARGS(JASDram, 0x20) TChannel[64];
CH_BUF = JKR_NEW_ARRAY_ARGS(TChannel, 64, JASDram, 0x20);
JUT_ASSERT(354, CH_BUF);
FX_BUF = JKR_NEW_ARGS(JASDram, 0x20) FxBuf[4];
FX_BUF = JKR_NEW_ARRAY_ARGS(FxBuf, 4, JASDram, 0x20);
JUT_ASSERT(356, FX_BUF);
JASCalc::bzero(CH_BUF, 0x6000);
JASCalc::bzero(FX_BUF, sizeof(FxBuf) * 4);
+1 -1
View File
@@ -17,7 +17,7 @@ void JASDrumSet::newPercArray(u8 num, JKRHeap* heap) {
if (num) {
JUT_ASSERT(39, num <= 128);
mPercNumMax = num;
mPercArray = JKR_NEW_ARGS (heap, 0) TPerc*[mPercNumMax];
mPercArray = JKR_NEW_ARRAY_ARGS(TPerc*, mPercNumMax, heap, 0);
JASCalc::bzero(mPercArray, mPercNumMax * sizeof(TPerc*));
}
}
+1 -1
View File
@@ -258,7 +258,7 @@ void JASGenericMemPool::newMemPool(u32 n, int param_1) {
JUT_ASSERT(734, n >= sizeof(TNextOnFreeList));
void* runner;
for (int i = 0; i < param_1; i++) {
runner = JKR_NEW_ARGS (JASDram, 0) u8[n];
runner = JKR_NEW_ARRAY_ARGS(u8, n, JASDram, 0);
JUT_ASSERT(739, runner);
*(void**)runner = field_0x0;
field_0x0 = runner;
+1 -1
View File
@@ -28,7 +28,7 @@ void JASReportInit(JKRHeap* heap, int lineMax) {
JUT_ASSERT(35, heap != NULL);
OSInitMutex(&sMutex);
sLineMax = lineMax;
sBuffer = JKR_NEW_ARGS (heap, 0) char[sLineMax * 64];
sBuffer = JKR_NEW_ARRAY_ARGS(char, sLineMax * 64, heap, 0);
JUT_ASSERT(41, sBuffer);
}
@@ -14,7 +14,7 @@ JASSimpleWaveBank::~JASSimpleWaveBank() {
void JASSimpleWaveBank::setWaveTableSize(u32 size, JKRHeap* heap) {
JKR_DELETE_ARRAY(mWaveTable);
mWaveTable = JKR_NEW_ARGS (heap, 0) TWaveHandle[size];
mWaveTable = JKR_NEW_ARRAY_ARGS(TWaveHandle, size, heap, 0);
JUT_ASSERT(29, mWaveTable != NULL);
mWaveTableSize = size;
}
@@ -168,7 +168,7 @@ void JASWaveArc::setFileName(char const* fileName) {
char* currentDir = JASWaveArcLoader::getCurrentDir();
size_t length = strlen(currentDir);
length = length + strlen(fileName);
char* path = JKR_NEW_ARGS (JASKernel::getSystemHeap(), -4) char[length + 1];
char* path = JKR_NEW_ARRAY_ARGS(char, length + 1, JASKernel::getSystemHeap(), -4);
JUT_ASSERT(322, path);
strcpy(path, currentDir);
strcat(path, fileName);
+5 -5
View File
@@ -38,7 +38,7 @@ namespace {
return;
}
mNumStreamFiles = stack_14.getNumFiles();
mStreamFileDVDEntryNums = JKR_NEW s32[mNumStreamFiles];
mStreamFileDVDEntryNums = JKR_NEW_ARRAY(s32, mNumStreamFiles);
if (!mStreamFileDVDEntryNums) {
mNumStreamFiles = 0;
return;
@@ -228,7 +228,7 @@ u8* JAUSection::newStaticSeqDataBlock_(JAISoundID param_0, u32 size) {
JUT_WARN(432, "%s", "created UNUSED object in Heap\n");
return NULL;
}
u8* r28 = JKR_NEW_ARGS(0x20) u8[size];
u8* r28 = JKR_NEW_ARRAY_ARGS(u8, size, 0x20);
if (!r28) {
JUT_WARN(438, "%s", "created UNUSED object in Heap\n");
return NULL;
@@ -277,7 +277,7 @@ bool JAUSection::newStaticSeqData(JAISoundID param_0) {
void* JAUSection::newCopy(void const* param_0, u32 param_1, s32 param_2) {
JUT_ASSERT(516, isOpen());
JUT_ASSERT(517, isBuilding());
u8* r31 = JKR_NEW_ARGS(getHeap_(), param_2) u8[param_1];
u8* r31 = JKR_NEW_ARRAY_ARGS(u8, param_1, getHeap_(), param_2);
if (r31) {
memcpy(r31, param_0, param_1);
}
@@ -382,7 +382,7 @@ bool JAUSection::beginNewBankTable(u32 param_0, u32 param_1) {
JAUBankTableLink* bankTableLink = NULL;
{
TPushCurrentHeap push(getHeap_());
JASBank** r26 = JKR_NEW JASBank*[param_1];
JASBank** r26 = JKR_NEW_ARRAY(JASBank*, param_1);
if (r26) {
bankTableLink = JKR_NEW JAUBankTableLink(param_0, r26, param_1);
if (bankTableLink) {
@@ -489,7 +489,7 @@ bool JAUSectionHeap::newDynamicSeqBlock(u32 size) {
JUT_WARN(950, "%s", "created UNUSED object in Heap\n");
return false;
}
u8* r25 = JKR_NEW_ARGS(0x20) u8[size];
u8* r25 = JKR_NEW_ARRAY_ARGS(u8, size, 0x20);
if (!r25) {
JUT_WARN(956, "%s", "created UNUSED object in Heap\n");
return false;
+1 -1
View File
@@ -40,7 +40,7 @@ void JHIMccBuf::init() {
if (mTempBuf != NULL) {
initBuf();
} else {
mTempBuf = JKR_NEW_ARGS (32) u8[0x18000];
mTempBuf = JKR_NEW_ARRAY_ARGS(u8, 0x18000, 32);
if (mTempBuf == NULL) {
JHIHalt("ERROR: JHIMccBuf cannot alloc temp buf.\n");
} else {
+1 -1
View File
@@ -11,7 +11,7 @@
int JHIMemBuf::create() {
int rt = 1;
if (mp_buffer == NULL) {
mp_buffer = JKR_NEW_ARGS (32) u8[0x20000];
mp_buffer = JKR_NEW_ARRAY_ARGS(u8, 0x20000, 32);
if (mp_buffer == NULL) {
rt = 0;
+2 -2
View File
@@ -35,8 +35,8 @@ BOOL JHIInit(u32 enabled) {
OS_REPORT("INFO: *** Disable JHostIO ***\n");
}
gsReadBuf = JKR_NEW_ARGS (32) u8[0xC000];
gsWriteBuf = JKR_NEW_ARGS (32) u8[0xC000];
gsReadBuf = JKR_NEW_ARRAY_ARGS(u8, 0xC000, 32);
gsWriteBuf = JKR_NEW_ARRAY_ARGS(u8, 0xC000, 32);
if (gsReadBuf == NULL || gsWriteBuf == NULL) {
gsEnableInterface = FALSE;
+6 -14
View File
@@ -593,12 +593,8 @@ void* operator new[](size_t size) {
return JKRHeap::alloc(size, 4, NULL);
}
#else
void* operator new[](size_t size JKR_HEAP_TOKEN_PARAM) {
void* mem = JKRHeap::alloc(size, alignof(max_align_t), NULL);
if (mem == NULL) {
return fallback_alloc(size, 0, true);
}
return mem;
void* operator new[](size_t JKR_HEAP_TOKEN_PARAM) {
OSPanic(__FILE__, __LINE__, "Allocation should go through JKR_NEW_ARRAY instead");
}
#endif
@@ -607,17 +603,13 @@ void* operator new[](size_t size, int alignment) {
return JKRHeap::alloc(size, alignment, NULL);
}
#else
void* operator new[](size_t size JKR_HEAP_TOKEN_PARAM, int alignment) {
void* mem = JKRHeap::alloc(size, alignment, nullptr);
if (mem == nullptr) {
return fallback_alloc(size, 0, true);
}
return mem;
void* operator new[](size_t JKR_HEAP_TOKEN_PARAM, int) {
OSPanic(__FILE__, __LINE__, "Allocation should go through JKR_NEW_ARRAY instead");
}
#endif
void* operator new[](size_t size JKR_HEAP_TOKEN_PARAM, JKRHeap* heap, int alignment) {
return JKRHeap::alloc(size, alignment, heap);
void* operator new[](size_t JKR_HEAP_TOKEN_PARAM, JKRHeap*, int) {
OSPanic(__FILE__, __LINE__, "Allocation should go through JKR_NEW_ARRAY instead");
}
#if !TARGET_PC
+1 -1
View File
@@ -121,7 +121,7 @@ void JMessage::TResourceContainer::TCResource::Do_destroy(JMessage::TResource* p
#if DEBUG
JKR_DELETE(pResource);
#else
operator delete(pResource);
operator delete(pResource JKR_HEAP_TOKEN);
#endif
}
@@ -17,19 +17,19 @@ JPAEmitterManager::JPAEmitterManager(u32 i_ptclNum, u32 i_emtrNum, JKRHeap* pHea
JUT_ASSERT(40, emtrNum && ptclNum && gidMax && ridMax);
JPABaseEmitter* p_emtr_link = JKR_NEW_ARGS (pHeap, 0) JPABaseEmitter[emtrNum];
JPABaseEmitter* p_emtr_link = JKR_NEW_ARRAY_ARGS(JPABaseEmitter, emtrNum, pHeap, 0);
JUT_ASSERT(44, p_emtr_link);
for (u32 i = 0; i < emtrNum; i++)
mFreeEmtrList.prepend(&p_emtr_link[i].mLink);
JPANode<JPABaseParticle>* p_ptcl_node = JKR_NEW_ARGS (pHeap, 0) JPANode<JPABaseParticle>[ptclNum];
JPANode<JPABaseParticle>* p_ptcl_node = JKR_NEW_ARRAY_ARGS(JPANode<JPABaseParticle>, ptclNum, pHeap, 0);
JUT_ASSERT(51, p_ptcl_node);
for (u32 i = 0; i < ptclNum; i++)
mPtclPool.push_back(&p_ptcl_node[i]);
pEmtrUseList = JKR_NEW_ARGS (pHeap, 0) JSUList<JPABaseEmitter>[gidMax];
pEmtrUseList = JKR_NEW_ARRAY_ARGS(JSUList<JPABaseEmitter>, gidMax, pHeap, 0);
JUT_ASSERT(58, pEmtrUseList);
pResMgrAry = JKR_NEW_ARGS (pHeap, 0) JPAResourceManager*[ridMax];
pResMgrAry = JKR_NEW_ARRAY_ARGS(JPAResourceManager*, ridMax, pHeap, 0);
JUT_ASSERT(62, pResMgrAry)
for (int i = 0; i < ridMax; i++) {
pResMgrAry[i] = NULL;
@@ -54,8 +54,8 @@ void JPAResourceLoader::load_jpc(u8 const* data, JPAResourceManager* p_res_mgr)
JKRHeap* heap = p_res_mgr->mpHeap;
p_res_mgr->resMaxNum = *(BE(u16)*)(data + 8);
p_res_mgr->texMaxNum = *(BE(u16)*)(data + 0xA);
p_res_mgr->pResAry = JKR_NEW_ARGS (heap, 0) JPAResource*[p_res_mgr->resMaxNum];
p_res_mgr->pTexAry = JKR_NEW_ARGS (heap, 0) JPATexture*[p_res_mgr->texMaxNum];
p_res_mgr->pResAry = JKR_NEW_ARRAY_ARGS(JPAResource*, p_res_mgr->resMaxNum, heap, 0);
p_res_mgr->pTexAry = JKR_NEW_ARRAY_ARGS(JPATexture*, p_res_mgr->texMaxNum, heap, 0);
JUT_ASSERT(199, (p_res_mgr->pResAry != NULL) && (p_res_mgr->pTexAry != 0));
u32 offset = 0x10;
@@ -65,11 +65,11 @@ void JPAResourceLoader::load_jpc(u8 const* data, JPAResourceManager* p_res_mgr)
JUT_ASSERT(211, p_res != NULL);
p_res->fldNum = header->mFieldBlockNum;
p_res->ppFld = p_res->fldNum != 0 ?
JKR_NEW_ARGS (heap, 0) JPAFieldBlock*[p_res->fldNum] : NULL;
JKR_NEW_ARRAY_ARGS(JPAFieldBlock*, p_res->fldNum, heap, 0) : NULL;
JUT_ASSERT(216, (p_res->ppFld != NULL) || (p_res->fldNum == 0));
p_res->keyNum = header->mKeyBlockNum;
p_res->ppKey = p_res->keyNum != 0 ?
JKR_NEW_ARGS (heap, 0) JPAKeyBlock*[p_res->keyNum] : NULL;
JKR_NEW_ARRAY_ARGS(JPAKeyBlock*, p_res->keyNum, heap, 0) : NULL;
JUT_ASSERT(221, (p_res->ppKey != NULL) || (p_res->keyNum == 0));
p_res->texNum = header->mTDB1Num;
p_res->mpTDB1 = NULL;
+8 -8
View File
@@ -178,14 +178,14 @@ bool JUTCacheFont::allocArea(void* cacheBuffer, u32 param_1, JKRHeap* heap) {
}
if (mTotalWidSize != 0) {
field_0x7c = JKR_NEW_ARGS (heap, 0) u8[mTotalWidSize];
field_0x7c = JKR_NEW_ARRAY_ARGS(u8, mTotalWidSize, heap, 0);
if (field_0x7c == NULL) {
return false;
}
}
if (mGly1BlockNum != 0) {
field_0x80 = JKR_NEW_ARGS (heap, 0) u8[mGly1BlockNum * sizeof(ResFONT::GLY1)];
field_0x80 = JKR_NEW_ARRAY_ARGS(u8, mGly1BlockNum * sizeof(ResFONT::GLY1), heap, 0);
if (field_0x80 == NULL) {
return false;
}
@@ -197,7 +197,7 @@ bool JUTCacheFont::allocArea(void* cacheBuffer, u32 param_1, JKRHeap* heap) {
}
if (mTotalMapSize != 0) {
field_0x84 = JKR_NEW_ARGS (heap, 0) u8[mTotalMapSize];
field_0x84 = JKR_NEW_ARRAY_ARGS(u8, mTotalMapSize, heap, 0);
if (field_0x84 == NULL) {
return false;
}
@@ -215,7 +215,7 @@ bool JUTCacheFont::allocArea(void* cacheBuffer, u32 param_1, JKRHeap* heap) {
mCacheBuffer = cacheBuffer;
field_0xb0 = 0;
} else {
mCacheBuffer = JKR_NEW_ARGS (heap, 0x20) u8[v1];
mCacheBuffer = JKR_NEW_ARRAY_ARGS(u8, v1, heap, 0x20);
if (mCacheBuffer == NULL) {
return false;
}
@@ -227,25 +227,25 @@ bool JUTCacheFont::allocArea(void* cacheBuffer, u32 param_1, JKRHeap* heap) {
}
bool JUTCacheFont::allocArray(JKRHeap* param_0) {
mMemBlocks = (void**)JKR_NEW_ARGS (param_0, 0) uintptr_t[mWid1BlockNum + mGly1BlockNum + mMap1BlockNum];
mMemBlocks = (void**)JKR_NEW_ARRAY_ARGS(uintptr_t, mWid1BlockNum + mGly1BlockNum + mMap1BlockNum, param_0, 0);
if (mMemBlocks == NULL) {
return false;
}
void** blocks = mMemBlocks;
if (mWid1BlockNum) {
mpWidthBlocks = JKR_NEW_ARGS (blocks) ResFONT::WID1*[mWid1BlockNum];
mpWidthBlocks = JKR_NEW_ARRAY_ARGS(ResFONT::WID1*, mWid1BlockNum, blocks);
blocks = blocks + mWid1BlockNum;
}
if (mGly1BlockNum) {
mpGlyphBlocks = JKR_NEW_ARGS (blocks) ResFONT::GLY1*[mGly1BlockNum];
mpGlyphBlocks = JKR_NEW_ARRAY_ARGS(ResFONT::GLY1*, mGly1BlockNum, blocks);
blocks = blocks + mGly1BlockNum;
for (int i = 0; i < mGly1BlockNum; i++) {
mpGlyphBlocks[i] = (ResFONT::GLY1*)((u8*)mCacheBuffer + (field_0x94 * i));
}
}
if (mMap1BlockNum) {
mpMapBlocks = JKR_NEW_ARGS (blocks) ResFONT::MAP1*[mMap1BlockNum];
mpMapBlocks = JKR_NEW_ARRAY_ARGS(ResFONT::MAP1*, mMap1BlockNum, blocks);
}
return true;
}
+4 -4
View File
@@ -62,22 +62,22 @@ bool JUTResFont::protected_initiate(const ResFONT* pFont, JKRHeap* pHeap) {
mValid = true;
countBlock();
mMemBlocks = JKR_NEW_ARGS (pHeap, 0) void*[mWid1BlockNum + mGly1BlockNum + mMap1BlockNum];
mMemBlocks = JKR_NEW_ARRAY_ARGS(void*, mWid1BlockNum + mGly1BlockNum + mMap1BlockNum, pHeap, 0);
if (!mMemBlocks) {
return false;
}
p = mMemBlocks;
if (mWid1BlockNum != 0) {
mpWidthBlocks = JKR_NEW_ARGS (p) ResFONT::WID1*[mWid1BlockNum];
mpWidthBlocks = JKR_NEW_ARRAY_ARGS(ResFONT::WID1*, mWid1BlockNum, p);
p += mWid1BlockNum;
}
if (mGly1BlockNum != 0) {
mpGlyphBlocks = JKR_NEW_ARGS (p) ResFONT::GLY1*[mGly1BlockNum];
mpGlyphBlocks = JKR_NEW_ARRAY_ARGS(ResFONT::GLY1*, mGly1BlockNum, p);
p += mGly1BlockNum;
}
if (mMap1BlockNum != 0) {
mpMapBlocks = JKR_NEW_ARGS (p) ResFONT::MAP1*[mMap1BlockNum];
mpMapBlocks = JKR_NEW_ARRAY_ARGS(ResFONT::MAP1*, mMap1BlockNum, p);
}
setBlock();
return true;
+3 -3
View File
@@ -69,11 +69,11 @@ void JUTXfb::initiate(u16 width, u16 height, JKRHeap* pHeap, JUTXfb::EXfbNumber
int size = (u16)((u16)width + 0xf & ~0xf) * height * 2;
mBuffer[0] = JKR_NEW_ARGS (pHeap, 0x20) u8[size];
mBuffer[0] = JKR_NEW_ARRAY_ARGS(u8, size, pHeap, 0x20);
mXfbAllocated[0] = true;
if (xfbNum >= 2) {
mBuffer[1] = JKR_NEW_ARGS (pHeap, 0x20) u8[size];
mBuffer[1] = JKR_NEW_ARRAY_ARGS(u8, size, pHeap, 0x20);
mXfbAllocated[1] = true;
} else {
mBuffer[1] = NULL;
@@ -81,7 +81,7 @@ void JUTXfb::initiate(u16 width, u16 height, JKRHeap* pHeap, JUTXfb::EXfbNumber
}
if (xfbNum >= 3) {
mBuffer[2] = JKR_NEW_ARGS (pHeap, 0x20) u8[size];
mBuffer[2] = JKR_NEW_ARRAY_ARGS(u8, size, pHeap, 0x20);
mXfbAllocated[2] = true;
} else {
mBuffer[2] = NULL;