d_ky_thunder start

This commit is contained in:
Jasper St. Pierre
2023-10-13 13:53:30 -07:00
parent 8c92f794b9
commit 99c72d0371
4 changed files with 184 additions and 39 deletions
+2 -2
View File
@@ -473,7 +473,7 @@ public:
class mDoExt_invisibleModel {
public:
bool create(J3DModel*);
BOOL create(J3DModel*);
void entry();
void entryMaskOff();
@@ -554,7 +554,7 @@ s32 mDoExt_resIDToIndex(JKRArchive*, u16);
JKRSolidHeap * mDoExt_createSolidHeapFromGameToCurrent(u32 size, u32 align);
JKRSolidHeap * mDoExt_createSolidHeapToCurrent(u32, JKRHeap *, u32 align);
void mDoExt_restoreCurrentHeap();
u32 mDoExt_adjustSolidHeap(JKRSolidHeap * pHeap);
s32 mDoExt_adjustSolidHeap(JKRSolidHeap * pHeap);
void mDoExt_destroySolidHeap(JKRSolidHeap * pHeap);
JKRHeap* mDoExt_setCurrentHeap(JKRHeap*);
+12 -12
View File
@@ -275,18 +275,6 @@ public:
*/
static void ZXYrotM(s16 x, s16 y, s16 z) { mDoMtx_ZXYrotM(now, x, y, z); }
/**
* Rotates a new matrix on the Y-axis then concatenates it with the `now` matrix
* @param y The rotation value
*/
static void YrotM(s16 y) { mDoMtx_YrotM(now, y); }
/**
* Rotates the `now` matrix on the Y-axis
* @param y The rotation value
*/
static void YrotS(s16 y) { mDoMtx_YrotS(now, y); }
/**
* Rotates the `now` matrix on the X-axis
* @param x The rotation value
@@ -299,6 +287,18 @@ public:
*/
static void XrotM(s16 x) { mDoMtx_XrotM(now, x); }
/**
* Rotates a new matrix on the Y-axis then concatenates it with the `now` matrix
* @param y The rotation value
*/
static void YrotM(s16 y) { mDoMtx_YrotM(now, y); }
/**
* Rotates the `now` matrix on the Y-axis
* @param y The rotation value
*/
static void YrotS(s16 y) { mDoMtx_YrotS(now, y); }
/**
* Rotates a new matrix on the z-axis then concatenates it with the `now` matrix
* @param z The rotation value
+166 -18
View File
@@ -3,46 +3,194 @@
// Translation Unit: d_ky_thunder.cpp
//
#include "d_ky_thunder.h"
#include "dolphin/types.h"
#include "f_op/f_op_kankyo.h"
#include "f_op/f_op_kankyo_mng.h"
#include "f_op/f_op_camera.h"
#include "d/d_com_inf_game.h"
#include "d/d_kankyo_rain.h"
#include "JSystem/JKernel/JKRSolidHeap.h"
#include "JSystem/J3DGraphAnimator/J3DModel.h"
#include "SSystem/SComponent/c_phase.h"
#include "m_Do/m_Do_audio.h"
#include "m_Do/m_Do_ext.h"
#include "m_Do/m_Do_mtx.h"
class dThunder_c : public kankyo_class {
public:
inline ~dThunder_c();
BOOL createHeap();
void adjustHeap();
s32 create();
inline BOOL draw();
inline BOOL execute();
public:
/* 0x0F8 */ JKRSolidHeap * solid_heap;
/* 0x0FC */ J3DModel * mpModel;
/* 0x100 */ mDoExt_invisibleModel mInvisModel;
/* 0x108 */ mDoExt_btkAnm mBtk;
/* 0x11C */ mDoExt_brkAnm mBrk;
/* 0x134 */ cXyz mScale;
/* 0x140 */ cXyz mPos;
/* 0x14C */ cXyz mPosNeg;
/* 0x150 */ f32 mRot;
/* 0x154 */ f32 mBtkTime;
};
dThunder_c::~dThunder_c() {
mDoAud_seDeleteObject(&mPos);
mDoAud_seDeleteObject(&mPosNeg);
if (solid_heap != NULL)
mDoExt_destroySolidHeap(solid_heap);
}
BOOL dThunder_c::execute() {
mBrk.setPlaySpeed(1.0f);
if (mBrk.play()) {
mDoAud_seStart(0x69f6, &mPos, 0, 0);
fopKyM_Delete(this);
}
return TRUE;
}
BOOL dThunder_c::draw() {
static cXyz l_offsetPos(0.0f, 40.0f, -250.0f);
mDoMtx_stack_c::transS(mPos);
mDoMtx_stack_c::ZrotM(mRot);
mDoMtx_stack_c::XrotM(mRot);
Mtx m;
MTXCopy(mDoMtx_stack_c::get(), m);
mpModel->setBaseScale(mScale);
mpModel->setBaseTRMtx(m);
mBtk.entry(mpModel->getModelData(), mBtkTime);
mBrk.entry(mpModel->getModelData());
dComIfGd_setList();
mDoExt_modelUpdateDL(mpModel);
mInvisModel.entryMaskOff();
mBtk.remove(mpModel->getModelData());
mBrk.remove(mpModel->getModelData());
return TRUE;
}
/* 80198810-8019886C .text createHeap__10dThunder_cFv */
void dThunder_c::createHeap() {
/* Nonmatching */
BOOL dThunder_c::createHeap() {
if (solid_heap == NULL) {
solid_heap = mDoExt_createSolidHeapFromGameToCurrent(0x4a0, 0x20);
if (solid_heap == NULL)
return FALSE;
}
return TRUE;
}
/* 8019886C-801988B8 .text adjustHeap__10dThunder_cFv */
void dThunder_c::adjustHeap() {
/* Nonmatching */
mDoExt_restoreCurrentHeap();
if (mDoExt_adjustSolidHeap(solid_heap) >= 0)
DCStoreRangeNoSync(solid_heap->getStartAddr(), solid_heap->getHeapSize());
}
/* 801988B8-80198A38 .text dThunder_Draw__FP10dThunder_c */
void dThunder_Draw(dThunder_c*) {
/* Nonmatching */
BOOL dThunder_Draw(dThunder_c* i_this) {
return i_this->draw();
}
/* 80198A38-80198AB4 .text dThunder_Execute__FP10dThunder_c */
void dThunder_Execute(dThunder_c*) {
/* Nonmatching */
BOOL dThunder_Execute(dThunder_c* i_this) {
return i_this->execute();
}
/* 80198AB4-80198ABC .text dThunder_IsDelete__FP10dThunder_c */
void dThunder_IsDelete(dThunder_c*) {
/* Nonmatching */
BOOL dThunder_IsDelete(dThunder_c* i_this) {
return TRUE;
}
/* 80198ABC-80198B68 .text dThunder_Delete__FP10dThunder_c */
void dThunder_Delete(dThunder_c*) {
/* Nonmatching */
BOOL dThunder_Delete(dThunder_c* i_this) {
i_this->~dThunder_c();
return TRUE;
}
/* 80198B68-80198BC4 .text dThunder_Create__FP12kankyo_class */
void dThunder_Create(kankyo_class*) {
/* Nonmatching */
s32 dThunder_Create(kankyo_class* i_ky) {
dThunder_c * i_this = (dThunder_c *)i_ky;
if (!i_this->createHeap())
return cPhs_ERROR_e;
s32 ret = i_this->create();
i_this->adjustHeap();
return ret;
}
/* 80198BC4-801990CC .text create__10dThunder_cFv */
void dThunder_c::create() {
/* Nonmatching */
}
s32 dThunder_c::create() {
s32 ret;
camera_class *pCamera = dComIfGp_getCamera(0);
new(this) dThunder_c();
J3DModelData *modelData = (J3DModelData *)dComIfG_getObjectRes("Always", ALWAYS_BDL_YTHDR00);
JUT_ASSERT(0x6e, modelData != 0);
mpModel = mDoExt_J3DModel__create(modelData, 0x80000, 0x01000200);
if (mpModel == NULL)
return cPhs_ERROR_e;
if (!mInvisModel.create(mpModel))
return cPhs_ERROR_e;
J3DAnmTextureSRTKey * anm = (J3DAnmTextureSRTKey *)dComIfG_getObjectRes("Always", ALWAYS_BTK_YTHDR00);
JUT_ASSERT(0x7d, anm != 0);
if (!mBtk.init(mpModel->getModelData(), anm, false, J3DFrameCtrl::LOOP_REPEAT_e, 1.0f, 0, -1, false, 0))
return cPhs_ERROR_e;
J3DAnmTevRegKey * canm = (J3DAnmTevRegKey *)dComIfG_getObjectRes("Always", ALWAYS_BRK_YTHDR00);
JUT_ASSERT(0x8c, canm != 0);
if (!mBrk.init(mpModel->getModelData(), canm, true, J3DFrameCtrl::LOOP_ONCE_e, 1.0f, 0, -1, false, 0))
return cPhs_ERROR_e;
mBtkTime = cM_rndF(1.0f);
f32 size = g_env_light.mThunderEff.mStateTimer < 10 ? 1.0f : 0.5f;
mRot = 4000.0f;
mRot = size * cM_rndFX(mRot);
mScale.x = size * (cM_rndF(15.0f) + 5.0f);
if (cM_rndFX(1.0) >= 0.5f)
mScale.x *= -1.0f;
mScale.y = size * (cM_rndF(60.0f) + 20.0f);
mScale.z = 1.0f;
cXyz fwd;
dKyr_get_vectle_calc(&pCamera->mLookat.mEye, &pCamera->mLookat.mCenter, &fwd);
f32 distXZ = fwd.absXZ();
s16 rotX = cM_atan2s(fwd.x, fwd.z);
s16 rotY = cM_atan2s(fwd.y, distXZ);
if (cM_rndFX(1.0f) >= 0.0f) {
rotX += 0x4000;
} else {
rotX -= 0x4000;
}
f32 y = cM_scos(rotY);
f32 x = cM_ssin(rotX);
f32 z = cM_scos(rotX);
f32 baseXZ = cM_rndF(120000.f);
f32 baseY = cM_rndFX(2000.0f);
mPos.x = pCamera->mLookat.mEye.x + fwd.x * 100000.0f + y * x * baseXZ;
mPos.x = pCamera->mLookat.mEye.x + baseY;
mPos.z = pCamera->mLookat.mEye.z + fwd.z * 100000.0f + y * z * baseXZ;
if (cM_rndF(1.0f) < 0.3) {
mPosNeg.x = -mPos.x;
mPosNeg.y = -mPos.y;
mPosNeg.z = -mPos.z;
mDoAud_seStart(0x69f6, &mPosNeg, 0, 0);
}
return cPhs_COMPLEATE_e;
}
+4 -7
View File
@@ -725,7 +725,7 @@ void mDoExt_backupMaterial_c::restore(J3DModelData* i_modelData) {
}
/* 80011380-80011434 .text create__21mDoExt_invisibleModelFP8J3DModel */
bool mDoExt_invisibleModel::create(J3DModel* model) {
BOOL mDoExt_invisibleModel::create(J3DModel* model) {
J3DModelData* modelData = model->getModelData();
mpPackets = new mDoExt_invJntPacket[modelData->getJointNum()];
@@ -965,16 +965,13 @@ JKRSolidHeap* mDoExt_createSolidHeapFromGameToCurrent(u32 i_size, u32 i_alignmen
}
/* 80011D0C-80011D48 .text mDoExt_adjustSolidHeap__FP12JKRSolidHeap */
u32 mDoExt_adjustSolidHeap(JKRSolidHeap* i_heap) {
if (i_heap == NULL) {
s32 mDoExt_adjustSolidHeap(JKRSolidHeap* i_heap) {
if (i_heap == NULL)
return 0;
}
s32 result = i_heap->adjustSize();
if (result >= (u32)0x80) {
if (result >= 0x80u)
result -= 0x80;
}
return result;
}