summaryrefslogtreecommitdiff
path: root/src/JSystem/JParticle/JPAResourceLoader.cpp
diff options
context:
space:
mode:
authorrobojumper <robojumper@gmail.com>2026-05-07 21:13:24 +0200
committerrobojumper <robojumper@gmail.com>2026-05-07 21:13:24 +0200
commitf4d163797f3c21e5a705b75043e0a8fbe7dc2460 (patch)
tree9cddc9fa36ec13e7dac76c54d74257c61fe20b47 /src/JSystem/JParticle/JPAResourceLoader.cpp
parentd8744e1f34e9955d55a5605f939bdf0bf9d8a729 (diff)
Re-import JParticle
Diffstat (limited to 'src/JSystem/JParticle/JPAResourceLoader.cpp')
-rw-r--r--src/JSystem/JParticle/JPAResourceLoader.cpp91
1 files changed, 50 insertions, 41 deletions
diff --git a/src/JSystem/JParticle/JPAResourceLoader.cpp b/src/JSystem/JParticle/JPAResourceLoader.cpp
index c43c70ab..8928a575 100644
--- a/src/JSystem/JParticle/JPAResourceLoader.cpp
+++ b/src/JSystem/JParticle/JPAResourceLoader.cpp
@@ -1,8 +1,3 @@
-//
-// Generated By: dol2asm
-// Translation Unit: JPAResourceLoader
-//
-
#include "egg/core/eggHeap.h"
#include "JSystem/JParticle/JPAResourceLoader.h"
#include "JSystem/JParticle/JPABaseShape.h"
@@ -14,12 +9,13 @@
#include "JSystem/JParticle/JPAKeyBlock.h"
#include "JSystem/JParticle/JPAResource.h"
#include "JSystem/JParticle/JPAResourceManager.h"
+#include "JSystem/JUtility/JUTAssert.h"
-/* 8027D8A0-8027D8E0 2781E0 0040+00 0/0 1/1 0/0 .text
- * __ct__17JPAResourceLoaderFPCUcP18JPAResourceManager */
JPAResourceLoader::JPAResourceLoader(u8 const* data, JPAResourceManager* mgr) {
if (*(u32*)(data + 4) == '2-11') {
load_jpc(data, mgr);
+ } else {
+ JUT_WARN(48, "JPA : wrong version file\n");
}
}
@@ -31,76 +27,89 @@ struct JPAResourceHeader {
/* 0x6 */ u8 mTDB1Num;
};
-/* 8027D8E0-8027DCA0 278220 03C0+00 1/1 0/0 0/0 .text
- * load_jpc__17JPAResourceLoaderFPCUcP18JPAResourceManager */
-void JPAResourceLoader::load_jpc(u8 const* data, JPAResourceManager* mgr) {
- EGG::Heap* heap = mgr->mpHeap;
- mgr->mResMax = *(u16*)(data + 8);
- mgr->mTexMax = *(u16*)(data + 0xA);
- mgr->mpResArr = new (heap, 4) JPAResource*[mgr->mResMax];
- mgr->mpTexArr = new (heap, 4) JPATexture*[mgr->mTexMax];
+void JPAResourceLoader::load_jpc(u8 const* data, JPAResourceManager* p_res_mgr) {
+ EGG::Heap* heap = p_res_mgr->mpHeap;
+ p_res_mgr->resMaxNum = *(u16*)(data + 8);
+ p_res_mgr->texMaxNum = *(u16*)(data + 0xA);
+ p_res_mgr->pResAry = new (heap) JPAResource*[p_res_mgr->resMaxNum];
+ p_res_mgr->pTexAry = new (heap) JPATexture*[p_res_mgr->texMaxNum];
+ JUT_ASSERT(199, (p_res_mgr->pResAry != NULL) && (p_res_mgr->pTexAry != 0));
u32 offset = 0x10;
for (int i = 0; i < *(u16*)(data + 8); i++) {
JPAResourceHeader* header = (JPAResourceHeader*)(data + offset);
- JPAResource* res = new (heap, 4) JPAResource();
- res->mFieldBlockNum = header->mFieldBlockNum;
- res->mpFieldBlocks = res->mFieldBlockNum != 0 ?
- new (heap, 4) JPAFieldBlock*[res->mFieldBlockNum] : NULL;
- res->mKeyBlockNum = header->mKeyBlockNum;
- res->mpKeyBlocks = res->mKeyBlockNum != 0 ?
- new (heap, 4) JPAKeyBlock*[res->mKeyBlockNum] : NULL;
- res->mTDB1Num = header->mTDB1Num;
- res->mpTDB1 = NULL;
- res->mUsrIdx = header->mUsrIdx;
+ JPAResource* p_res = new (heap) JPAResource();
+ JUT_ASSERT(211, p_res != NULL);
+ p_res->fldNum = header->mFieldBlockNum;
+ p_res->ppFld = p_res->fldNum != 0 ?
+ new (heap) JPAFieldBlock*[p_res->fldNum] : NULL;
+ JUT_ASSERT(216, (p_res->ppFld != NULL) || (p_res->fldNum == 0));
+ p_res->keyNum = header->mKeyBlockNum;
+ p_res->ppKey = p_res->keyNum != 0 ?
+ new (heap) JPAKeyBlock*[p_res->keyNum] : NULL;
+ JUT_ASSERT(221, (p_res->ppKey != NULL) || (p_res->keyNum == 0));
+ p_res->texNum = header->mTDB1Num;
+ p_res->mpTDB1 = NULL;
+ p_res->mUsrIdx = header->mUsrIdx;
offset += 8;
- u32 field_idx = 0;
- u32 key_idx = 0;
+ u32 fld_no = 0;
+ u32 key_no = 0;
for (int j = 0; j < header->mBlockNum; j++) {
u32 magic = *(u32*)(data + offset);
u32 size = *(u32*)(data + offset + 4);
switch (magic) {
case 'FLD1':
- res->mpFieldBlocks[field_idx] = new (heap, 4) JPAFieldBlock(data + offset, heap);
- field_idx++;
+ p_res->ppFld[fld_no] = new (heap) JPAFieldBlock(data + offset, heap);
+ JUT_ASSERT(244, p_res->ppFld[fld_no] != NULL);
+ fld_no++;
break;
case 'KFA1':
- res->mpKeyBlocks[key_idx] = new (heap, 4) JPAKeyBlock(data + offset);
- key_idx++;
+ p_res->ppKey[key_no] = new (heap) JPAKeyBlock(data + offset);
+ JUT_ASSERT(249, p_res->ppKey[key_no] != NULL);
+ key_no++;
break;
case 'BEM1':
- res->mpDynamicsBlock = new (heap, 4) JPADynamicsBlock(data + offset);
+ p_res->pDyn = new (heap) JPADynamicsBlock(data + offset);
+ JUT_ASSERT(254, p_res->pDyn != NULL);
break;
case 'BSP1':
- res->mpBaseShape = new (heap, 4) JPABaseShape(data + offset, heap);
+ p_res->pBsp = new (heap) JPABaseShape(data + offset, heap);
+ JUT_ASSERT(258, p_res->pBsp != NULL);
break;
case 'ESP1':
- res->mpExtraShape = new (heap, 4) JPAExtraShape(data + offset);
+ p_res->pEsp = new (heap) JPAExtraShape(data + offset);
+ JUT_ASSERT(262, p_res->pEsp != NULL);
break;
case 'SSP1':
- res->mpChildShape = new (heap, 4) JPAChildShape(data + offset);
+ p_res->pCsp = new (heap) JPAChildShape(data + offset);
+ JUT_ASSERT(266, p_res->pCsp != NULL);
break;
case 'ETX1':
- res->mpExTexShape = new (heap, 4) JPAExTexShape(data + offset);
+ p_res->pEts = new (heap) JPAExTexShape(data + offset);
+ JUT_ASSERT(270, p_res->pEts != NULL);
break;
case 'TDB1':
- res->mpTDB1 = (const u16*)(data + offset + 8);
+ p_res->mpTDB1 = (const u16*)(data + offset + 8);
+ break;
+ default:
+ JUT_WARN(275, "JPA : wrong type block in jpc file %d %x\n", header->mBlockNum, offset);
break;
}
offset += size;
}
- res->init(heap);
- mgr->registRes(res);
+ p_res->init(heap);
+ p_res_mgr->registRes(p_res);
}
offset = *(u32*)(data + 0xC);
for (int i = 0; i < *(u16*)(data + 0xA); i++) {
u32 size = *(u32*)(data + offset + 4);
- JPATexture* tex = new (heap, 4) JPATexture(data + offset);
- mgr->registTex(tex);
+ JPATexture* p_tex = new (heap) JPATexture(data + offset);
+ JUT_ASSERT(298, p_tex != NULL);
+ p_res_mgr->registTex(p_tex);
offset += size;
}
}