diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index 6dc4a363..74cf3f0c 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -94,6 +94,7 @@ toBeSorted/d_emitter.cpp: .rodata start:0x804DBD18 end:0x804DBE80 .data start:0x80500E98 end:0x805014C0 .sdata start:0x805718A8 end:0x80571920 + .sbss start:0x80575070 end:0x80575080 .sdata2 start:0x80576C18 end:0x80576C68 .bss start:0x80594FA0 end:0x80597020 diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index 4b2bcdc7..2e99d88e 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -974,8 +974,8 @@ loadColors__14dEmitterBase_cFP14JPABaseEmitterPC8_GXColorPC8_GXColorll = .text:0 removeFromActiveEmittersList__13EffectsStructFv = .text:0x8002A020; // type:function size:0xA4 createEffect__13EffectsStructFbUsRC7mVec3_cPC7mAng3_cPC7mVec3_cPC8_GXColorPC8_GXColor = .text:0x8002A0D0; // type:function size:0x15C createEffect__13EffectsStructFbUsRC6mMtx_cPC8_GXColorPC8_GXColor = .text:0x8002A230; // type:function size:0x150 -fn_8002A380 = .text:0x8002A380; // type:function size:0xCC -fn_8002A450 = .text:0x8002A450; // type:function size:0x1C0 +polyAttrsToGroundEffectIdx__14dJEffManager_cFll = .text:0x8002A380; // type:function size:0xCC +spawnGroundEffect__14dJEffManager_cFRC7mVec3_cUcUcRC7mVec3_clff = .text:0x8002A450; // type:function size:0x1C0 fn_8002A610 = .text:0x8002A610; // type:function size:0x678 fn_8002AC90 = .text:0x8002AC90; // type:function size:0x460 fn_8002B0F0 = .text:0x8002B0F0; // type:function size:0x8 @@ -17851,7 +17851,7 @@ mMtx__XYZrotS = .text:0x802F1AA0; // type:function size:0x60 mMtx__ZYXrotM = .text:0x802F1B00; // type:function size:0x60 toRot__6mMtx_cCFR7mAng3_c = .text:0x802F1B60; // type:function size:0xDC fn_802F1C40__6mMtx_cFll = .text:0x802F1C40; // type:function size:0x220 -mMtx_c__makeRotationFromVecs = .text:0x802F1E60; // type:function size:0x58 +makeRotationFromVecs__6mMtx_cFRC7mVec3_cRC7mVec3_cf = .text:0x802F1E60; // type:function size:0x58 __sinit_\m_mtx_cpp = .text:0x802F1EC0; // type:function size:0x58 scope:local create__4mPadFv = .text:0x802F1F20; // type:function size:0x30 beginPad__4mPadFv = .text:0x802F1F50; // type:function size:0x1E4 @@ -39895,7 +39895,7 @@ sPInstance__21BlurAndPaletteManager = .sbss:0x80575068; // type:object size:0x8 sMassObjEmitters__14dJEffManager_c = .sbss:0x80575070; // type:object size:0x4 data:4byte CURRENT_EFFECT_MANAGER_INIT = .sbss:0x80575074; // type:object size:0x4 data:4byte ms_allocator__14dJEffManager_c = .sbss:0x80575078; // type:object size:0x4 data:4byte -lbl_8057507C = .sbss:0x8057507C; // type:object size:0x1 data:byte +@GUARD@spawnGroundEffect__14dJEffManager_cFRC7mVec3_cUcUcRC7mVec3_clff@sEffArray = .sbss:0x8057507C; // type:object size:0x1 data:byte lbl_8057507D = .sbss:0x8057507D; // type:object size:0x1 data:byte s_Create_Position__9dAcBase_c = .sbss:0x80575080; // type:object size:0x4 data:4byte s_Create_Rotation__9dAcBase_c = .sbss:0x80575084; // type:object size:0x4 data:4byte @@ -48466,7 +48466,7 @@ lbl_8058F210 = .bss:0x8058F210; // type:object size:0x10 sInstance__21BlurAndPaletteManager = .bss:0x8058F220; // type:object size:0x5D70 lbl_80594F90 = .bss:0x80594F90; // type:object size:0x10 data:4byte sPlayingEffectsList__14dJEffManager_c = .bss:0x80594FA0; // type:object size:0x18 data:4byte -lbl_80594FB8 = .bss:0x80594FB8; // type:object size:0x1C +sCommonEmitterCallbacks__14dJEffManager_c = .bss:0x80594FB8; // type:object size:0x1C sShpEmitters__14dJEffManager_c = .bss:0x80594FD4; // type:object size:0x1E2C sEmitter__14dJEffManager_c = .bss:0x80596E00; // type:object size:0x30 data:4byte sFogProcs__14dJEffManager_c = .bss:0x80596E30; // type:object size:0x18C diff --git a/include/m/m_mtx.h b/include/m/m_mtx.h index 4a9eac54..668cfe5f 100644 --- a/include/m/m_mtx.h +++ b/include/m/m_mtx.h @@ -88,6 +88,7 @@ public: } void fn_802F1C40(s32, s32); + void makeRotationFromVecs(const mVec3_c&, const mVec3_c&, f32); public: static mMtx_c Identity; diff --git a/include/toBeSorted/d_emitter.h b/include/toBeSorted/d_emitter.h index 3102c3b9..5baefaee 100644 --- a/include/toBeSorted/d_emitter.h +++ b/include/toBeSorted/d_emitter.h @@ -420,6 +420,7 @@ public: static dEmitterBase_c *spawnEffect( u16 effectResourceId, const mMtx_c &transform, const GXColor *c1, const GXColor *c2, s32 idx1, s32 idx2 ); + static dEmitterBase_c *spawnGroundEffect(const mVec3_c &pos, u8 polyAttr0, u8 polyAttr1, const mVec3_c &, s32 unk, f32 scale, f32 groundHeightMaybe); // "mass obj" = grass, fire static bool createMassObjEffect(u16 effectResourceId, const mVec3_c &v1, dAcObjBase_c *owner, const mColor *color); @@ -494,6 +495,8 @@ private: u16 effectResourceId, const mMtx_c &transform, const GXColor *c1, const GXColor *c2, s32 idx1, s32 idx2 ); + static s32 polyAttrsToGroundEffectIdx(s32 polyAttr0, s32 polyAttr1); + static mHeapAllocator_c *ms_allocator; static dMassObjEmitter_c *sMassObjEmitters; static u32 sInts[]; diff --git a/src/REL/d/a/obj/d_a_obj_tubo.cpp b/src/REL/d/a/obj/d_a_obj_tubo.cpp index a21885eb..8b6481de 100644 --- a/src/REL/d/a/obj/d_a_obj_tubo.cpp +++ b/src/REL/d/a/obj/d_a_obj_tubo.cpp @@ -213,14 +213,12 @@ int dAcOtubo_c::draw() { return SUCCEEDED; } -extern "C" void fn_8002A450(const mVec3_c &, u8, u8, const mVec3_c &, int, f32, f32); - void dAcOtubo_c::initializeState_Wait() {} void dAcOtubo_c::executeState_Wait() { if (mObjAcch.ChkGroundLanding()) { if (!mbField_0x9EF || !EventManager::isInEvent()) { if (mField_0x9F6 == 2) { - fn_8002A450(position, polyAttr0, polyAttr1, mField_0x1B4, 0, 1.0f, mField_0x1B0); + dJEffManager_c::spawnGroundEffect(position, polyAttr0, polyAttr1, mField_0x1B4, 0, 1.0f, mField_0x1B0); } if (mbField_0x9F3) { playSound(SE_Tubo_PUT); @@ -228,7 +226,9 @@ void dAcOtubo_c::executeState_Wait() { } if (checkOnLava()) { if (mField_0x9F6 != 2) { - fn_8002A450(position, polyAttr0, polyAttr1, mField_0x1B4, 0, 1.0f, mField_0x1B0); + dJEffManager_c::spawnGroundEffect( + position, polyAttr0, polyAttr1, mField_0x1B4, 0, 1.0f, mField_0x1B0 + ); } playSound(SE_O_FALL_LAVA_S); } @@ -366,7 +366,7 @@ void dAcOtubo_c::initializeState_Slope() { } void dAcOtubo_c::executeState_Slope() { if (mObjAcch.ChkGroundLanding()) { - fn_8002A450(position, polyAttr0, polyAttr1, mField_0x1B4, 0, 1.0f, mField_0x1B0); + dJEffManager_c::spawnGroundEffect(position, polyAttr0, polyAttr1, mField_0x1B4, 0, 1.0f, mField_0x1B0); } else if (mObjAcch.ChkGndHit()) { mField_0x9DC = 0.f; addPickupTarget(); @@ -464,11 +464,15 @@ void dAcOtubo_c::destroy() { fn_80022BE0(BlurAndPaletteManager::GetPInstance(), position); mActorCarryInfo.fn_80050EA0(this); - dEmitterBase_c *fx_thing = dJEffManager_c::spawnEffect(PARTICLE_RESOURCE_ID_MAPPING_209_, poscopy2, nullptr, nullptr, nullptr, nullptr, 0, 0); + dEmitterBase_c *fx_thing = dJEffManager_c::spawnEffect( + PARTICLE_RESOURCE_ID_MAPPING_209_, poscopy2, nullptr, nullptr, nullptr, nullptr, 0, 0 + ); if (fx_thing) { fx_thing->attachEmitterCallbackId(mSubtype != 0 ? dJEffManager_c::TsuboB : dJEffManager_c::TsuboA); } - fx_thing = dJEffManager_c::spawnEffect(PARTICLE_RESOURCE_ID_MAPPING_109_, position, nullptr, nullptr, nullptr, nullptr, 0, 0); + fx_thing = dJEffManager_c::spawnEffect( + PARTICLE_RESOURCE_ID_MAPPING_109_, position, nullptr, nullptr, nullptr, nullptr, 0, 0 + ); if (fx_thing) { fx_thing->bindShpEmitter(mSubtype != 0 ? dJEffManager_c::TsuboB : dJEffManager_c::TsuboA, false); } diff --git a/src/toBeSorted/d_emitter.cpp b/src/toBeSorted/d_emitter.cpp index 92cfea9a..0fe2d8ce 100644 --- a/src/toBeSorted/d_emitter.cpp +++ b/src/toBeSorted/d_emitter.cpp @@ -1186,6 +1186,77 @@ bool EffectsStruct::createEffect( return hasEmitters(); } +s32 dJEffManager_c::polyAttrsToGroundEffectIdx(s32 polyAttr0, s32 polyAttr1) { + if (polyAttr0 == 0 || (polyAttr0 == 4 && polyAttr1 == 1) || (polyAttr0 == 9) || + (polyAttr0 == 10 && polyAttr1 == 1) || (polyAttr0 == 12) || (polyAttr0 == 17 && polyAttr1 != 1) || + (polyAttr0 == 13 && (polyAttr1 == 1 || polyAttr1 == 3)) || polyAttr0 == 18) { + return 6; + } else if (polyAttr0 == 17) { + return 5; + } else if (polyAttr0 == 6) { + return 2; + } else if (polyAttr0 == 4) { + return 1; + } else if (polyAttr0 == 3 || polyAttr0 == 15) { + return 3; + } + // ??? + s32 result = 0; + if (polyAttr0 == 11) { + result = 4; + } + return result; +} + +extern "C" const u16 PARTICLE_RESOURCE_ID_MAPPING_89_; +extern "C" const u16 PARTICLE_RESOURCE_ID_MAPPING_90_; +extern "C" const u16 PARTICLE_RESOURCE_ID_MAPPING_87_; +extern "C" const u16 PARTICLE_RESOURCE_ID_MAPPING_88_; +extern "C" const u16 PARTICLE_RESOURCE_ID_MAPPING_429_; +extern "C" const u16 PARTICLE_RESOURCE_ID_MAPPING_416_; +extern "C" const u16 PARTICLE_RESOURCE_ID_MAPPING_417_; +extern "C" const u16 PARTICLE_RESOURCE_ID_MAPPING_418_; +extern "C" const u16 PARTICLE_RESOURCE_ID_MAPPING_419_; +extern "C" const u16 PARTICLE_RESOURCE_ID_MAPPING_893_; +extern "C" const u16 PARTICLE_RESOURCE_ID_MAPPING_894_; + +dEmitterBase_c *dJEffManager_c::spawnGroundEffect( + const mVec3_c &pos, u8 polyAttr0, u8 polyAttr1, const mVec3_c &v1, s32 unk, f32 scale, f32 groundHeightMaybe +) { + static const u16 sEffArray[6][2] = { + { PARTICLE_RESOURCE_ID_MAPPING_89_, PARTICLE_RESOURCE_ID_MAPPING_90_}, + { PARTICLE_RESOURCE_ID_MAPPING_87_, PARTICLE_RESOURCE_ID_MAPPING_88_}, + {PARTICLE_RESOURCE_ID_MAPPING_429_, PARTICLE_RESOURCE_ID_MAPPING_429_}, + {PARTICLE_RESOURCE_ID_MAPPING_416_, PARTICLE_RESOURCE_ID_MAPPING_417_}, + {PARTICLE_RESOURCE_ID_MAPPING_418_, PARTICLE_RESOURCE_ID_MAPPING_419_}, + {PARTICLE_RESOURCE_ID_MAPPING_893_, PARTICLE_RESOURCE_ID_MAPPING_894_}, + }; + + if (pos.y < groundHeightMaybe) { + return nullptr; + } + + s32 idx = polyAttrsToGroundEffectIdx(polyAttr0, polyAttr1); + if (idx == 6) { + return nullptr; + } + if (idx == 2 && unk == 0) { + scale *= 1.5f; + } + mMtx_c mtx; + mtx.makeRotationFromVecs(mVec3_c::Ey, v1, 1.0f); + mAng rot(cM::rndF(65536.0f)); + mtx.YrotM(rot); + mtx.m[0][3] = pos.x; + mtx.m[1][3] = pos.y; + mtx.m[2][3] = pos.z; + mMtx_c scaleMtx; + MTXScale(scaleMtx, scale, scale, scale); + MTXConcat(mtx, scaleMtx, mtx); + u16 eff = sEffArray[idx][unk]; + return spawnEffect(eff, mtx, nullptr, nullptr, polyAttr0, polyAttr1); +} + void dWaterEffect_c::init(dAcObjBase_c *base, f32 height, f32 scale, f32 f3) { mEff.init(base); mHeight = height;