Work on JPAEmitterManager

This commit is contained in:
Tal Hayon 2023-07-07 21:04:10 +03:00
parent a368ff7a6d
commit b9383052a3
16 changed files with 81 additions and 140 deletions

View File

@ -7,22 +7,22 @@ Section | Percentage | Decompiled (bytes) | Total (bytes)
.init | 97.972973% | 9280 | 9472
.extab | 100.000000% | 96 | 96
.extabindex | 100.000000% | 96 | 96
.text | 28.029130% | 1008080 | 3596544
.text | 28.037360% | 1008376 | 3596544
.ctors | 100.000000% | 448 | 448
.dtors | 100.000000% | 32 | 32
.rodata | 100.000000% | 193856 | 193856
.data | 100.000000% | 197632 | 197632
.sdata | 100.000000% | 1408 | 1408
.sdata2 | 100.000000% | 20832 | 20832
Total | 35.616335% | 1432016 | 4020672
Total | 35.623697% | 1432312 | 4020672
## Total
Section | Percentage | Decompiled (bytes) | Total (bytes)
---|---|---|---
main.dol | 35.616335% | 1432016 | 4020672
main.dol | 35.623697% | 1432312 | 4020672
RELs | 33.810282% | 3888292 | 11500324
Total | 34.278135% | 5320308 | 15520996
Total | 34.280042% | 5320604 | 15520996
## RELs

View File

@ -1,78 +0,0 @@
lbl_8027E3F4:
/* 8027E3F4 94 21 FF E0 */ stwu r1, -0x20(r1)
/* 8027E3F8 80 83 00 20 */ lwz r4, 0x20(r3)
/* 8027E3FC C0 24 01 A8 */ lfs f1, 0x1a8(r4)
/* 8027E400 C0 04 01 98 */ lfs f0, 0x198(r4)
/* 8027E404 C0 42 B9 58 */ lfs f2, lit_2632(r2)
/* 8027E408 D0 41 00 08 */ stfs f2, 8(r1)
/* 8027E40C D0 01 00 0C */ stfs f0, 0xc(r1)
/* 8027E410 D0 21 00 10 */ stfs f1, 0x10(r1)
/* 8027E414 E0 01 00 08 */ psq_l f0, 8(r1), 0, 0 /* qr0 */
/* 8027E418 10 00 00 32 */ ps_mul f0, f0, f0
/* 8027E41C 10 A1 00 7A */ ps_madd f5, f1, f1, f0
/* 8027E420 10 A5 00 14 */ ps_sum0 f5, f5, f0, f0
/* 8027E424 C0 22 B9 5C */ lfs f1, lit_2633(r2)
/* 8027E428 3C 80 80 45 */ lis r4, __float_epsilon@ha /* 0x80450AEC@ha */
/* 8027E42C C0 04 0A EC */ lfs f0, __float_epsilon@l(r4) /* 0x80450AEC@l */
/* 8027E430 EC 01 00 32 */ fmuls f0, f1, f0
/* 8027E434 FC 05 00 40 */ fcmpo cr0, f5, f0
/* 8027E438 4C 40 13 82 */ cror 2, 0, 2
/* 8027E43C 41 82 00 58 */ beq lbl_8027E494
/* 8027E440 FC 05 10 40 */ fcmpo cr0, f5, f2
/* 8027E444 4C 40 13 82 */ cror 2, 0, 2
/* 8027E448 40 82 00 0C */ bne lbl_8027E454
/* 8027E44C FC 60 28 90 */ fmr f3, f5
/* 8027E450 48 00 00 2C */ b lbl_8027E47C
lbl_8027E454:
/* 8027E454 FC 80 28 34 */ frsqrte f4, f5
/* 8027E458 FC 80 20 18 */ frsp f4, f4
/* 8027E45C C0 02 B9 60 */ lfs f0, lit_2634(r2)
/* 8027E460 EC 40 01 32 */ fmuls f2, f0, f4
/* 8027E464 C0 22 B9 64 */ lfs f1, lit_2635(r2)
/* 8027E468 EC 04 01 32 */ fmuls f0, f4, f4
/* 8027E46C EC 05 00 32 */ fmuls f0, f5, f0
/* 8027E470 EC 01 00 28 */ fsubs f0, f1, f0
/* 8027E474 EC 02 00 32 */ fmuls f0, f2, f0
/* 8027E478 FC 60 00 90 */ fmr f3, f0
lbl_8027E47C:
/* 8027E47C E0 01 00 08 */ psq_l f0, 8(r1), 0, 0 /* qr0 */
/* 8027E480 E0 21 80 10 */ psq_l f1, 16(r1), 1, 0 /* qr0 */
/* 8027E484 10 00 00 D8 */ ps_muls0 f0, f0, f3
/* 8027E488 F0 01 00 08 */ psq_st f0, 8(r1), 0, 0 /* qr0 */
/* 8027E48C 10 01 00 D8 */ ps_muls0 f0, f1, f3
/* 8027E490 F0 01 80 10 */ psq_st f0, 16(r1), 1, 0 /* qr0 */
lbl_8027E494:
/* 8027E494 C0 02 B9 68 */ lfs f0, lit_2636(r2)
/* 8027E498 80 83 00 20 */ lwz r4, 0x20(r3)
/* 8027E49C D0 04 01 54 */ stfs f0, 0x154(r4)
/* 8027E4A0 C0 62 B9 58 */ lfs f3, lit_2632(r2)
/* 8027E4A4 80 83 00 20 */ lwz r4, 0x20(r3)
/* 8027E4A8 D0 64 01 58 */ stfs f3, 0x158(r4)
/* 8027E4AC 80 83 00 20 */ lwz r4, 0x20(r3)
/* 8027E4B0 D0 64 01 5C */ stfs f3, 0x15c(r4)
/* 8027E4B4 80 83 00 20 */ lwz r4, 0x20(r3)
/* 8027E4B8 C0 04 01 90 */ lfs f0, 0x190(r4)
/* 8027E4BC D0 04 01 60 */ stfs f0, 0x160(r4)
/* 8027E4C0 80 83 00 20 */ lwz r4, 0x20(r3)
/* 8027E4C4 D0 64 01 64 */ stfs f3, 0x164(r4)
/* 8027E4C8 C0 41 00 0C */ lfs f2, 0xc(r1)
/* 8027E4CC 80 83 00 20 */ lwz r4, 0x20(r3)
/* 8027E4D0 D0 44 01 68 */ stfs f2, 0x168(r4)
/* 8027E4D4 C0 21 00 10 */ lfs f1, 0x10(r1)
/* 8027E4D8 FC 00 08 50 */ fneg f0, f1
/* 8027E4DC 80 83 00 20 */ lwz r4, 0x20(r3)
/* 8027E4E0 D0 04 01 6C */ stfs f0, 0x16c(r4)
/* 8027E4E4 80 83 00 20 */ lwz r4, 0x20(r3)
/* 8027E4E8 C0 04 01 A0 */ lfs f0, 0x1a0(r4)
/* 8027E4EC D0 04 01 70 */ stfs f0, 0x170(r4)
/* 8027E4F0 80 83 00 20 */ lwz r4, 0x20(r3)
/* 8027E4F4 D0 64 01 74 */ stfs f3, 0x174(r4)
/* 8027E4F8 80 83 00 20 */ lwz r4, 0x20(r3)
/* 8027E4FC D0 24 01 78 */ stfs f1, 0x178(r4)
/* 8027E500 80 83 00 20 */ lwz r4, 0x20(r3)
/* 8027E504 D0 44 01 7C */ stfs f2, 0x17c(r4)
/* 8027E508 80 63 00 20 */ lwz r3, 0x20(r3)
/* 8027E50C C0 03 01 B0 */ lfs f0, 0x1b0(r3)
/* 8027E510 D0 03 01 80 */ stfs f0, 0x180(r3)
/* 8027E514 38 21 00 20 */ addi r1, r1, 0x20
/* 8027E518 4E 80 00 20 */ blr

View File

@ -3,6 +3,8 @@
#include "dolphin/mtx/vec.h"
#include "dolphin/types.h"
#include "MSL_C/float.h"
#include "MSL_C/math.h"
namespace JGeometry {
@ -46,6 +48,11 @@ inline void setTVec3f(const f32* vec_a, f32* vec_b) {
};
}
inline float fsqrt_step(float mag) {
f32 root = __frsqrte(mag);
return 0.5f * root * (3.0f - mag * (root * root));
}
template <>
struct TVec3<f32> {
f32 x;
@ -110,6 +117,38 @@ struct TVec3<f32> {
};
return *this;
}
f32 squared() {
return C_VECSquareMag((Vec*)&x);
}
void normalize() {
f32 sq = squared();
if (sq <= FLT_EPSILON * 32.0f) {
return;
}
f32 norm;
if (sq <= 0.0f) {
norm = sq;
} else {
norm = fsqrt_step(sq);
}
scale(norm);
}
void scale(register f32 sc) {
register f32 z;
register f32 x_y;
register f32* dst = &x;
asm {
psq_l x_y, 0(dst), 0, 0
psq_l z, 8(dst), 1, 0
ps_muls0 x_y, x_y, sc
psq_st x_y, 0(dst), 0, 0
ps_muls0 x_y, z, sc
psq_st x_y, 8(dst), 1, 0
};
}
};
template <typename T>

View File

@ -75,6 +75,11 @@ public:
template <class T>
struct JPANode {
JPANode() {
mpPrev = NULL;
mpNext = NULL;
}
~JPANode() {}
JPANode<T>* mpPrev;
JPANode<T>* mpNext;
T mData;

View File

@ -33,6 +33,20 @@ f32 PSVECDistance(const Vec* a, const Vec* b);
void C_VECHalfAngle(const Vec* a, const Vec* b, Vec* half);
void C_VECReflect(const Vec* src, const Vec* normal, Vec* dst);
inline f32 C_VECSquareMag(const Vec* v) {
register f32 x_y;
register f32 z;
register const f32* src = &v->x;
asm {
psq_l x_y, 0(src), 0, 0
ps_mul x_y, x_y, x_y
lfs z, 8(src)
ps_madd z, z, z, x_y
ps_sum0 z, z, x_y, x_y
};
return z;
}
#ifdef __cplusplus
};
#endif

View File

@ -11,10 +11,6 @@
// Types:
//
struct JMath {
static u8 sincosTable_[65536];
};
struct J3DTextureSRTInfo {};
//

View File

@ -22,10 +22,6 @@ struct JKRHeap {
/* 802CE474 */ void alloc(u32, int, JKRHeap*);
};
struct JMath {
static u8 sincosTable_[65536];
};
//
// Forward References:
//
@ -125,7 +121,6 @@ extern "C" void _restgpr_24();
extern "C" void _restgpr_28();
extern "C" void _restgpr_29();
extern "C" u8 sincosTable___5JMath[65536];
extern "C" extern u32 __float_epsilon;
//
// Declarations:

View File

@ -42,7 +42,6 @@ extern "C" void init_c__15JPABaseParticleFP18JPAEmitterWorkDataP15JPABaseParticl
extern "C" void __dl__FPv();
extern "C" void load__10JUTTextureF11_GXTexMapID();
extern "C" extern void* __vt__18JPAEmitterCallBack[7];
extern "C" extern u32 __float_epsilon;
//
// Declarations:

View File

@ -64,7 +64,6 @@ extern "C" void _restgpr_24();
extern "C" void _restgpr_26();
extern "C" void _restgpr_27();
extern "C" void _restgpr_29();
extern "C" extern u32 __float_epsilon;
//
// Declarations:
@ -72,6 +71,7 @@ extern "C" extern u32 __float_epsilon;
/* 8027DCA0-8027DEBC 2785E0 021C+00 0/0 1/1 0/0 .text __ct__17JPAEmitterManagerFUlUlP7JKRHeapUcUc
*/
// template ctors are at the end of the TU for some reason
#ifdef NONMATCHING
JPAEmitterManager::JPAEmitterManager(u32 ptclMax, u32 emtrMax, JKRHeap* pHeap, u8 grpMax,
u8 resMax) {
@ -88,11 +88,11 @@ JPAEmitterManager::JPAEmitterManager(u32 ptclMax, u32 emtrMax, JKRHeap* pHeap, u
for (u32 i = 0; i < mPtclMax; i++)
mPtclPool.push_back(&ptcl[i]);
// can't get __construct_new_array to call the correct constructor within.
mpGrpEmtr = new (pHeap, 0) JSUList<JPABaseEmitter>[mGrpMax];
mpResMgrAry = new (pHeap, 0) JPAResourceManager*[mResMax];
for (u8 i = 0; i < mResMax; i++)
for (int i = 0; i < mResMax; i++) {
mpResMgrAry[i] = NULL;
}
mpWorkData = new (pHeap, 0) JPAEmitterWorkData();
}
@ -231,40 +231,26 @@ void JPAEmitterManager::clearResourceManager(u8 resMgrID) {
}
/* ############################################################################################## */
/* 80455358-8045535C 003958 0004+00 1/1 0/0 0/0 .sdata2 @2632 */
SECTION_SDATA2 static u8 lit_2632[4] = {
0x00,
0x00,
0x00,
0x00,
};
/* 8045535C-80455360 00395C 0004+00 1/1 0/0 0/0 .sdata2 @2633 */
SECTION_SDATA2 static f32 lit_2633 = 32.0f;
/* 80455360-80455364 003960 0004+00 1/1 0/0 0/0 .sdata2 @2634 */
SECTION_SDATA2 static f32 lit_2634 = 0.5f;
/* 80455364-80455368 003964 0004+00 1/1 0/0 0/0 .sdata2 @2635 */
SECTION_SDATA2 static f32 lit_2635 = 3.0f;
/* 80455368-80455370 003968 0004+04 1/1 0/0 0/0 .sdata2 @2636 */
SECTION_SDATA2 static f32 lit_2636[1 + 1 /* padding */] = {
1.0f,
/* padding */
0.0f,
};
/* 8027E3F4-8027E51C 278D34 0128+00 1/1 0/0 0/0 .text calcYBBCam__17JPAEmitterManagerFv
*/
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
asm void JPAEmitterManager::calcYBBCam() {
nofralloc
#include "asm/JSystem/JParticle/JPAEmitterManager/calcYBBCam__17JPAEmitterManagerFv.s"
void JPAEmitterManager::calcYBBCam() {
JGeometry::TVec3<float> v;
v.set(0.0f, mpWorkData->mPosCamMtx[1][1], mpWorkData->mPosCamMtx[2][1]);
v.normalize();
mpWorkData->mYBBCamMtx[0][0] = 1.0f;
mpWorkData->mYBBCamMtx[0][1] = 0.0f;
mpWorkData->mYBBCamMtx[0][2] = 0.0f;
mpWorkData->mYBBCamMtx[0][3] = mpWorkData->mPosCamMtx[0][3];
mpWorkData->mYBBCamMtx[1][0] = 0.0f;
mpWorkData->mYBBCamMtx[1][1] = v.y;
mpWorkData->mYBBCamMtx[1][2] = -v.z;
mpWorkData->mYBBCamMtx[1][3] = mpWorkData->mPosCamMtx[1][3];
mpWorkData->mYBBCamMtx[2][0] = 0.0f;
mpWorkData->mYBBCamMtx[2][1] = v.z;
mpWorkData->mYBBCamMtx[2][2] = v.y;
mpWorkData->mYBBCamMtx[2][3] = mpWorkData->mPosCamMtx[2][3];
}
#pragma pop
/* 8027E51C-8027E54C 278E5C 0030+00 1/1 0/0 0/0 .text __ct__25JSUList<14JPABaseEmitter>Fv
*/

View File

@ -11,10 +11,6 @@
// Types:
//
struct JMath {
static u8 sincosTable_[65536];
};
//
// Forward References:
//
@ -33,7 +29,6 @@ extern "C" void JPACalcKeyAnmValue__FfUsPCf();
extern "C" void _savegpr_28();
extern "C" void _restgpr_28();
extern "C" u8 sincosTable___5JMath[65536];
extern "C" extern u32 __float_epsilon;
//
// Declarations:

View File

@ -37,7 +37,6 @@ extern "C" void _savegpr_29();
extern "C" void _restgpr_26();
extern "C" void _restgpr_29();
extern "C" extern void* __vt__19JPAParticleCallBack[5];
extern "C" extern u32 __float_epsilon;
//
// Declarations:

View File

@ -86,7 +86,6 @@ extern "C" u8 const sauVariableValue_3_POSITION_XYZ__Q27JStudio14TAdaptor_sound[
extern "C" extern void* __vt__Q27JStudio14TAdaptor_sound[20];
extern "C" extern void* __vt__Q27JStudio8TAdaptor[8];
extern "C" extern void* __vt__Q37JStudio14TVariableValue7TOutput[4];
extern "C" extern u32 __float_nan;
extern "C" u8 soOutput_none___Q27JStudio14TVariableValue[4 + 4 /* padding */];
extern "C" extern u8 data_804511F8[8];

View File

@ -90,7 +90,6 @@ extern "C" u8 const sauVariableValue_4_COLOR_RGBA__Q27JStudio17TAdaptor_particle
extern "C" extern void* __vt__18JPAEmitterCallBack[7];
extern "C" extern void* __vt__Q27JStudio17TAdaptor_particle[19];
extern "C" extern void* __vt__Q27JStudio8TAdaptor[8];
extern "C" extern u32 __float_nan;
extern "C" extern u8 data_80451200[8];
//

View File

@ -50,10 +50,6 @@ struct Z2AudibleAbsPos {
JGeometry::TVec3<f32> const*);
};
struct JMath {
static u8 sincosTable_[65536];
};
template <typename A0>
struct JASMemPool {};
/* JASMemPool<Z2Audible> */
@ -164,7 +160,6 @@ extern "C" f32 DOLBY_FLONT_DISTANCE_MAX__7Z2Param;
extern "C" f32 DOLBY_BEHIND_DISTANCE_MAX__7Z2Param;
extern "C" f32 DISTANCE_FX_PARAM__7Z2Param;
extern "C" f32 SONIC_SPEED__7Z2Param;
extern "C" extern u32 __float_epsilon;
extern "C" extern u8 data_80450B4C[4];
extern "C" f32 MIN_DISTANCE_VOLUME__7Z2Param;
extern "C" extern u8 __OSReport_disable;

View File

@ -178,7 +178,6 @@ extern "C" f32 VOL_SE_CHAR_VOICE_PAUSING__7Z2Param;
extern "C" f32 VOL_SE_CHAR_MOVE_PAUSING__7Z2Param;
extern "C" f32 VOL_SE_OBJECT_PAUSING__7Z2Param;
extern "C" f32 VOL_SE_ATMOSPHERE_PAUSING__7Z2Param;
extern "C" extern u32 __float_nan;
extern "C" extern u8 data_80450B44[4];
extern "C" extern u8 data_80450B60[4];
extern "C" extern u8 data_80450B70[4];

View File

@ -101,7 +101,6 @@ extern "C" void _savegpr_29();
extern "C" void _restgpr_23();
extern "C" void _restgpr_28();
extern "C" void _restgpr_29();
extern "C" extern u32 __float_max;
extern "C" extern Z2SoundInfo* data_80450B4C;
extern "C" extern u8 data_80450B60[4];
extern "C" extern Z2SoundStarter* data_80450B74;