J3D setup (#155)

* setup j3d classes

* remove asm

* fixes

* fix newDifferedDisplayList
This commit is contained in:
TakaRikka
2021-10-11 09:38:53 -07:00
committed by GitHub
parent f51c495cf4
commit f51935c034
134 changed files with 3399 additions and 4786 deletions
+93 -91
View File
@@ -4,40 +4,11 @@
//
#include "JSystem/J3DGraphAnimator/J3DModelData.h"
#include "JSystem/J3DGraphAnimator/J3DMaterialAnm.h"
#include "dol2asm.h"
#include "dolphin/os/OS.h"
#include "dolphin/types.h"
//
// Types:
//
struct J3DVertexData {
/* 80310EF8 */ J3DVertexData();
};
struct J3DShapeTable {
/* 80326134 */ ~J3DShapeTable();
};
struct J3DMaterialTable {
/* 8032F5D0 */ J3DMaterialTable();
/* 8032F604 */ ~J3DMaterialTable();
};
struct J3DMaterial {
/* 80316290 */ void countDLSize();
/* 80316E90 */ void newSharedDisplayList(u32);
/* 80316F24 */ void newSingleSharedDisplayList(u32);
};
struct J3DJointTree {
/* 80325A18 */ J3DJointTree();
};
struct J3DDrawMtxData {
/* 803115F4 */ ~J3DDrawMtxData();
};
//
// Forward References:
//
@@ -66,32 +37,23 @@ extern "C" void newSingleSharedDisplayList__11J3DMaterialFUl();
extern "C" void __ct__12J3DJointTreeFv();
extern "C" void __ct__16J3DMaterialTableFv();
extern "C" void __dt__16J3DMaterialTableFv();
extern "C" void OSDisableInterrupts();
extern "C" void OSRestoreInterrupts();
extern "C" void OSDisableScheduler();
extern "C" void OSEnableScheduler();
extern "C" void GDInitGDLObj();
extern "C" void _savegpr_27();
extern "C" void _savegpr_29();
extern "C" void _restgpr_27();
extern "C" void _restgpr_29();
extern "C" extern void* __vt__12J3DJointTree[4 + 1 /* padding */];
extern "C" extern u8 j3dSys[284];
extern "C" extern u8 __GDCurrentDL[4];
//
// Declarations:
//
/* 80325D88-80325DA0 3206C8 0018+00 1/1 2/2 0/0 .text clear__12J3DModelDataFv */
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
asm void J3DModelData::clear() {
nofralloc
#include "asm/JSystem/J3DGraphAnimator/J3DModelData/clear__12J3DModelDataFv.s"
void J3DModelData::clear() {
field_0x4 = 0;
mFlags = 0;
field_0xc = 0;
field_0xe = 0;
}
#pragma pop
/* ############################################################################################## */
/* 803CED08-803CED14 02BE28 000C+00 3/3 0/0 0/0 .data __vt__13J3DShapeTable */
@@ -109,89 +71,129 @@ SECTION_DATA extern void* __vt__12J3DModelData[3] = {
};
/* 80325DA0-80325E14 3206E0 0074+00 0/0 2/2 0/0 .text __ct__12J3DModelDataFv */
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
asm J3DModelData::J3DModelData() {
nofralloc
#include "asm/JSystem/J3DGraphAnimator/J3DModelData/__ct__12J3DModelDataFv.s"
J3DModelData::J3DModelData() {
clear();
}
#pragma pop
/* 80325E14-80325EC8 320754 00B4+00 0/0 2/2 0/0 .text newSharedDisplayList__12J3DModelDataFUl */
#ifdef NONMATCHING
s32 J3DModelData::newSharedDisplayList(u32 param_0) {
u16 matNum = getMaterialNum();
for (u16 i = 0; i < matNum; i++) {
if ((param_0 & 0x40000)) {
J3DMaterial* matNode = getMaterialNodePointer(i);
u32 dl_size = matNode->countDLSize();
switch (matNode->newSingleSharedDisplayList(dl_size)) {
case 0:
continue;
}
break;
} else {
J3DMaterial* matNode = getMaterialNodePointer(i);
u32 dl_size = matNode->countDLSize();
switch (matNode->newSharedDisplayList(dl_size)) {
case 0:
continue;
}
break;
}
}
return 0;
}
#else
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
asm void J3DModelData::newSharedDisplayList(u32 param_0) {
asm s32 J3DModelData::newSharedDisplayList(u32 param_0) {
nofralloc
#include "asm/JSystem/J3DGraphAnimator/J3DModelData/newSharedDisplayList__12J3DModelDataFUl.s"
}
#pragma pop
#endif
/* ############################################################################################## */
/* 804515E8-804515EC 000AE8 0004+00 1/1 0/0 0/0 .sbss sInterruptFlag$965 */
static u8 sInterruptFlag[4];
static s32 sInterruptFlag;
/* 804515EC-804515F0 000AEC 0004+00 1/1 0/0 0/0 .sbss None */
static u8 data_804515EC[4];
static s8 sInitInterruptFlag;
/* 80325EC8-80325F94 320808 00CC+00 0/0 1/1 0/0 .text indexToPtr__12J3DModelDataFv */
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
asm void J3DModelData::indexToPtr() {
nofralloc
#include "asm/JSystem/J3DGraphAnimator/J3DModelData/indexToPtr__12J3DModelDataFv.s"
void J3DModelData::indexToPtr() {
J3DTexture* tex = getTexture();
j3dSys.setTexture(tex);
if (!sInitInterruptFlag) {
sInterruptFlag = OSDisableInterrupts();
sInitInterruptFlag = true;
}
OSDisableScheduler();
GDLObj gdl_obj;
u16 matNum = getMaterialNum();
for (u16 i = 0; i < matNum; i++) {
J3DMaterial* matNode = getMaterialNodePointer(i);
J3DDisplayListObj* dl_obj = matNode->getSharedDisplayListObj();
GDInitGDLObj(&gdl_obj, dl_obj->getDisplayList(0), dl_obj->getDisplayListSize());
GDSetCurrent(&gdl_obj);
matNode->getTevBlock()->indexToPtr();
}
GDSetCurrent(NULL);
OSEnableScheduler();
OSRestoreInterrupts(sInterruptFlag);
}
#pragma pop
/* 80325F94-8032600C 3208D4 0078+00 0/0 2/2 0/0 .text makeSharedDL__12J3DModelDataFv */
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
asm void J3DModelData::makeSharedDL() {
nofralloc
#include "asm/JSystem/J3DGraphAnimator/J3DModelData/makeSharedDL__12J3DModelDataFv.s"
void J3DModelData::makeSharedDL() {
J3DTexture* tex = getTexture();
j3dSys.setTexture(tex);
u16 matNum = getMaterialNum();
for (u16 i = 0; i < matNum; i++) {
getMaterialNodePointer(i)->makeSharedDisplayList();
}
}
#pragma pop
/* 8032600C-803260CC 32094C 00C0+00 0/0 3/3 7/7 .text simpleCalcMaterial__12J3DModelDataFUsPA4_f
*/
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
asm void J3DModelData::simpleCalcMaterial(u16 param_0, f32 (*param_1)[4]) {
nofralloc
#include "asm/JSystem/J3DGraphAnimator/J3DModelData/simpleCalcMaterial__12J3DModelDataFUsPA4_f.s"
void J3DModelData::simpleCalcMaterial(u16 idx, Mtx param_1) {
syncJ3DSysFlags();
J3DJoint* jointNode = getJointNodePointer(idx);
for (J3DMaterial* mat = jointNode->getMesh(); mat != NULL; mat = mat->getNext()) {
if (mat->getMaterialAnm() != NULL) {
mat->getMaterialAnm()->calc(mat);
}
mat->calc(param_1);
}
}
#pragma pop
/* 803260CC-803260F8 320A0C 002C+00 0/0 1/1 0/0 .text syncJ3DSysPointers__12J3DModelDataCFv */
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
asm void J3DModelData::syncJ3DSysPointers() const {
nofralloc
#include "asm/JSystem/J3DGraphAnimator/J3DModelData/syncJ3DSysPointers__12J3DModelDataCFv.s"
void J3DModelData::syncJ3DSysPointers() const {
j3dSys.setTexture(getTexture());
j3dSys.setVtxPos(getVtxPosArray());
j3dSys.setVtxNrm(getVtxNrmArray());
j3dSys.setVtxCol(getVtxColorArray(0));
}
#pragma pop
/* 803260F8-80326134 320A38 003C+00 1/1 5/5 0/0 .text syncJ3DSysFlags__12J3DModelDataCFv
*/
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
asm void J3DModelData::syncJ3DSysFlags() const {
nofralloc
#include "asm/JSystem/J3DGraphAnimator/J3DModelData/syncJ3DSysFlags__12J3DModelDataCFv.s"
void J3DModelData::syncJ3DSysFlags() const {
if (checkFlag(0x20)) {
j3dSys.onFlag(0x40000000);
} else {
j3dSys.offFlag(0x40000000);
}
}
#pragma pop
/* 80326134-8032617C 320A74 0048+00 1/0 0/0 0/0 .text __dt__13J3DShapeTableFv */
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
asm J3DShapeTable::~J3DShapeTable() {
extern "C" asm void __dt__13J3DShapeTableFv() {
// asm J3DShapeTable::~J3DShapeTable() {
nofralloc
#include "asm/JSystem/J3DGraphAnimator/J3DModelData/__dt__13J3DShapeTableFv.s"
}