mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-06-05 02:37:50 -04:00
b289dece80
* fix kankyo UB
* Fix TEV Stage DL writing
BE issue
* BE Fixes in materials/shapes
* Move to Aurora GD impl
* JUTDataFileHeader
* j3d: load vertex and texture not through GD
* Endian swap vertex data (mostly)
* Just exit(0) when closing the game
Fix crashes :godo:
* fix fopAcM_ct_placement and remove memcpy
* J3D: track vertex arrays correctly, swap work
* fix visibility, turn off overridden new/delete when we call into aurora
* event: cut name be
* Default window improvements
Double size, allow OS to decide position
* survive TParse::parseHeader_next
* color swap fix
* swap endian/fixes oob function pointer
* Remove GXGetViewportv stub
Aurora has it now
* Set array pointers via GD again
Relies on https://github.com/encounter/aurora/pull/35
* Let Aurora decide graphics backend
* disable procbar drawing
* Fix TColor endianness conversion issues
Fixes the wrong color for the flashing logo
* cam param swap
* simplify vtx loading, mat/amb color fix
* endian swap stb/fvb data
* aurora stat changes
* fix storage buffer crash
dont unnecessarily reassign vertex buffers in a way that forces aurora to recache things
* set bgobj spec fix
* add camera debug, endian swap more stb data, d_a_bg_obj::spec_data_c swapped
* JKRExpHeap: fix bad allocator slowdown
* solid tex
* texture caching
* log level
* fix window aspect ratio, disable bloom, endian swap camera type data
camera is now actually playing opening cutscene!!!!
* add GXDestroyTexObj to a couple stack init'd GXTexObjs, remove some diag printfs
* endian swap joint weight envelope data
* move to dusk config
* verbose arg errors
* better stub logging (for now)
* less logging, more BE
* more stubbing, move logging stuff around
* move all logging to aurora logging
* fix STUB_LOG, __FUNCTION__ isn't a string literal, wasn't building as it
was.
* update aurora
* fix heap alignment mismatch and always head align for now
* prevent them from fucking up my shit
* forward jut warning to DuskLog
* remove report logging
* maybe and i must emphasize maybe fix JMessage parsing
* this was a dumb idea
* preserve negative alignment for JKRHeap
* use normal free on macos and linux
* ^
* fix JMAHermiteInterpolation c impl
* endian swap J2DScreen mColor (oops)
* swap more J3D anim data, remove weird pointer addr check in J3DMaterial getMaterialAnm
* typo fix
* Fix aligned_alloc() size issues on POSIX
aligned_alloc() requires its input size to be a multiple of alignment. This wasn't being upheld so there were allocation failures in init code that made the game fail to start outside Windows.
Also just cleaned up some of this code a bit and removed fallback cases that *shouldn't* get hit.
* _Exit instead of exit()
Seriously I don't want destructors to run. Let the OS reclaim that shit.
* Reapply "Isolate JKRHeap operator overloads" (#39)
This reverts commit 3623b27f37.
* Fix some oopsies
* Fix hardcoded pointer size in JUTCacheFont::allocArray
* More operator overload fixes
Add void template specialization for jkrDelete
Add new[] placement overload. Apparently.
* Fix delete macros on nullptr
TIL C++ allows that.
* fix delete[]
* fix new(std::nothrow) overload
* fix avoid ub
* swap remaining anim data needed for title logo
* get rid of op 7
* move aurora_end_frame to correct spot
* juttexture destroy tex
* j2d animation be
* shutdown crash
* link warp material fix
* mDoExt_3DlineMat1_c fix
* hacky keyboard controls
* endian swap J2DResReference, add kb_pad to files.cmake
* fix some missing endian swaps in J2D, remove addr alignment check
* Remove heap unsetting in aurora calls
Never worked properly and not the right solution even if it did
* Don't print in DC stubs
They're fine to never implement
* Fix alignment stuff again
* Compile GF from dolphin lib
Doesn't seem to break anything and shuts up some stub warnings
* j3dtexture tlut obj fix
* addTexMtxIndexInDL fix
* don't recreate null tex data every frame
* the actual fix i wanted to push
* its kinda fakematch city over here
* insert hte efb copy
* limited window size / viewport support
* IsDelete FIX
---------
Co-authored-by: madeline <qwertytrogi@gmail.com>
Co-authored-by: Jasper St. Pierre <jstpierre@mecheye.net>
Co-authored-by: Jeffrey Crowell <jeff@crowell.biz>
Co-authored-by: TakaRikka <takarikka@outlook.com>
Co-authored-by: CraftyBoss <talibabdulmaalik@gmail.com>
Co-authored-by: Lurs <2795933+Lurs@users.noreply.github.com>
324 lines
9.1 KiB
C++
324 lines
9.1 KiB
C++
/**
|
|
* @file d_a_obj_fw.cpp
|
|
*
|
|
*/
|
|
|
|
#include "d/dolzel_rel.h" // IWYU pragma: keep
|
|
|
|
#include "d/actor/d_a_obj_fw.h"
|
|
#include "d/d_com_inf_game.h"
|
|
#include "d/d_bg_w.h"
|
|
#include "d/d_s_play.h"
|
|
|
|
enum RYUW00_RES_File_ID {
|
|
/* BMDR */
|
|
/* 0x4 */ BMDR_K_RYUWOOD00 = 0x4,
|
|
/* 0x5 */ BMDR_K_RYUWOOD01,
|
|
|
|
/* DZB */
|
|
/* 0x8 */ DZB_K_RYUWOOD00 = 0x8,
|
|
/* 0x9 */ DZB_K_RYUWOOD01,
|
|
};
|
|
|
|
enum Action {
|
|
/* 0x0 */ ACTION_FLOAT,
|
|
};
|
|
|
|
daObj_Fw_HIO_c::daObj_Fw_HIO_c() {
|
|
field_0x4 = -1;
|
|
size = 1.0f;
|
|
}
|
|
|
|
static u8 hio_set;
|
|
|
|
static daObj_Fw_HIO_c l_HIO;
|
|
|
|
static void ride_call_back(dBgW* i_bgw, fopAc_ac_c* a_this, fopAc_ac_c* param_3) {
|
|
if (fopAcM_GetName(param_3) == PROC_ALINK) {
|
|
obj_fw_class* i_this = (obj_fw_class*)a_this;
|
|
|
|
if (i_this->field_0x592 == 0) {
|
|
i_this->field_0x598 = AREG_F(0) + -50.0f;
|
|
}
|
|
|
|
i_this->field_0x592 = 10;
|
|
f32 fVar1 = param_3->current.pos.x - a_this->current.pos.x;
|
|
f32 fVar2 = param_3->current.pos.z - a_this->current.pos.z;
|
|
|
|
cLib_addCalcAngleS2(&i_this->field_0x5a0, cM_atan2s(fVar1, fVar2), 4, 0x80);
|
|
s16 sVar1 = JMAFastSqrt(fVar1 * fVar1 + fVar2 * fVar2) * (AREG_F(3) + 10.0f) * l_HIO.size;
|
|
if (sVar1 > 0x800) {
|
|
sVar1 = 0x800;
|
|
} else if (sVar1 < -0x800) {
|
|
sVar1 = -0x800;
|
|
}
|
|
|
|
cLib_addCalcAngleS2(&i_this->field_0x5a2, sVar1, 4, 0x20);
|
|
}
|
|
}
|
|
|
|
static int daObj_Fw_Draw(obj_fw_class* i_this) {
|
|
fopAc_ac_c* a_this = &i_this->actor;
|
|
|
|
g_env_light.settingTevStruct(16, &a_this->current.pos, &a_this->tevStr);
|
|
g_env_light.setLightTevColorType_MAJI(i_this->mpModel, &a_this->tevStr);
|
|
mDoExt_modelUpdateDL(i_this->mpModel);
|
|
return 1;
|
|
}
|
|
|
|
static BOOL water_check(obj_fw_class* i_this) {
|
|
fopAc_ac_c* a_this = &i_this->actor;
|
|
Vec sp78;
|
|
dBgS_ObjGndChk_Spl obj_gnd_chk_spl;
|
|
|
|
sp78.x = a_this->current.pos.x;
|
|
sp78.y = a_this->current.pos.y + 500.0f;
|
|
sp78.z = a_this->current.pos.z;
|
|
obj_gnd_chk_spl.SetPos(&sp78);
|
|
i_this->field_0x584 = dComIfG_Bgsp().GroundCross(&obj_gnd_chk_spl);
|
|
|
|
if (i_this->field_0x584 > a_this->current.pos.y + TREG_F(11)) {
|
|
return TRUE;
|
|
}
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
static void fw_float(obj_fw_class* i_this) {
|
|
fopAc_ac_c* a_this = &i_this->actor;
|
|
|
|
cLib_addCalc0(&a_this->speed.y, 1.0f, TREG_F(6) + 0.25f);
|
|
cXyz sp78(a_this->current.pos);
|
|
sp78.y = i_this->field_0x584;
|
|
fopAcM_effHamonSet(&i_this->field_0x61c, &sp78, 3.5f, 0.05f);
|
|
|
|
f32 fVar1 = (i_this->field_0x58c * (JREG_F(3) + 0.03f)) * cM_ssin(i_this->field_0x578 * (JREG_S(2) + 500));
|
|
f32 fVar2 = i_this->field_0x584 + JREG_F(8) + -(TREG_F(11) + 300.0f) * cM_ssin(i_this->field_0x5a4 / 2);
|
|
cLib_addCalc2(&a_this->current.pos.y, fVar2 + fVar1, 0.1f, JREG_F(4) + 10.0f);
|
|
i_this->field_0x590++;
|
|
|
|
if (a_this->field_0x567 == 1) {
|
|
i_this->field_0x590 += 5;
|
|
cLib_addCalc2(&i_this->field_0x58c, 300.0f, 0.1f, JREG_F(18) + 2.0f);
|
|
a_this->current.pos += a_this->speed;
|
|
} else if (a_this->field_0x567 == 2) {
|
|
if (i_this->field_0x57e[0] == 0) {
|
|
cLib_addCalcAngleS2(&i_this->field_0x5a4, 0x7F80, 0x20, 0x200);
|
|
a_this->current.pos += a_this->speed;
|
|
}
|
|
} else {
|
|
cLib_addCalc2(&i_this->field_0x58c, 300.0f, 0.1f, 20.0f);
|
|
}
|
|
|
|
a_this->shape_angle.x = i_this->field_0x58c * cM_ssin(i_this->field_0x590 * (TREG_S(3) + 500));
|
|
a_this->shape_angle.z = i_this->field_0x58c * cM_ssin(i_this->field_0x590 * (TREG_S(4) + 600));
|
|
cLib_addCalc2(&i_this->field_0x594, i_this->field_0x598, 0.2f, 20.0f);
|
|
|
|
f32 fVar3;
|
|
if (i_this->field_0x592 != 0) {
|
|
fVar3 = -20.0f;
|
|
} else {
|
|
fVar3 = 0.0f;
|
|
}
|
|
|
|
cLib_addCalc2(&i_this->field_0x598, fVar3, 1.0f, 3.0f);
|
|
}
|
|
|
|
static void action(obj_fw_class* i_this) {
|
|
fopAc_ac_c* a_this = &i_this->actor;
|
|
cXyz sp30, sp3c;
|
|
|
|
switch (i_this->field_0x57a) {
|
|
case ACTION_FLOAT:
|
|
fw_float(i_this);
|
|
break;
|
|
}
|
|
|
|
mDoMtx_stack_c::transS(a_this->current.pos.x, a_this->current.pos.y + i_this->field_0x594 + i_this->field_0x588, a_this->current.pos.z);
|
|
mDoMtx_stack_c::YrotM(i_this->field_0x5a0);
|
|
mDoMtx_stack_c::XrotM(i_this->field_0x5a2);
|
|
mDoMtx_stack_c::YrotM(-i_this->field_0x5a0);
|
|
mDoMtx_stack_c::XrotM(a_this->shape_angle.x + i_this->field_0x5a4);
|
|
mDoMtx_stack_c::YrotM(a_this->shape_angle.y);
|
|
mDoMtx_stack_c::ZrotM(a_this->shape_angle.z);
|
|
mDoMtx_stack_c::scaleM(l_HIO.size, 1.0f, l_HIO.size);
|
|
|
|
i_this->mpModel->setBaseTRMtx(mDoMtx_stack_c::get());
|
|
sp30.set(0.0f, 0.0f, 0.0f);
|
|
mDoMtx_stack_c::multVec(&sp30, &i_this->field_0x5a8);
|
|
|
|
cXyz sp48(i_this->field_0x5a8);
|
|
sp48.y += TREG_F(0) + 15.0f;
|
|
a_this->eyePos = sp48;
|
|
a_this->attention_info.position = sp48;
|
|
|
|
MTXCopy(mDoMtx_stack_c::get(), i_this->mMtx);
|
|
i_this->mpBgW->Move();
|
|
|
|
if (i_this->field_0x592 == 0) {
|
|
cLib_addCalcAngleS2(&i_this->field_0x5a2, 0, 4, 0x10);
|
|
}
|
|
}
|
|
|
|
static int daObj_Fw_Execute(obj_fw_class* i_this) {
|
|
fopAc_ac_c* a_this = &i_this->actor;
|
|
|
|
i_this->field_0x578++;
|
|
|
|
for (int i = 0; i < 2; i++) {
|
|
if (i_this->field_0x57e[i] != 0) {
|
|
i_this->field_0x57e[i]--;
|
|
}
|
|
}
|
|
|
|
if (i_this->field_0x592 != 0) {
|
|
i_this->field_0x592--;
|
|
}
|
|
|
|
action(i_this);
|
|
|
|
i_this->mSound.framework(0, dComIfGp_getReverb(fopAcM_GetRoomNo(a_this)));
|
|
|
|
return 1;
|
|
}
|
|
|
|
static int daObj_Fw_IsDelete(obj_fw_class* i_this) {
|
|
return 1;
|
|
}
|
|
|
|
static int daObj_Fw_Delete(obj_fw_class* i_this) {
|
|
fopAc_ac_c* a_this = &i_this->actor;
|
|
|
|
dComIfG_resDelete(&i_this->mPhase, "RYUW00");
|
|
|
|
if (i_this->field_0x624 != 0) {
|
|
hio_set = 0;
|
|
}
|
|
|
|
dComIfG_Bgsp().Release(i_this->mpBgW);
|
|
|
|
if (a_this->heap != NULL) {
|
|
i_this->mSound.deleteObject();
|
|
}
|
|
|
|
return 1;
|
|
}
|
|
|
|
static int useHeapInit(fopAc_ac_c* a_this) {
|
|
obj_fw_class* i_this = (obj_fw_class*)a_this;
|
|
|
|
static int bmdd[2] = {
|
|
BMDR_K_RYUWOOD00, BMDR_K_RYUWOOD01,
|
|
};
|
|
|
|
J3DModelData* modelData = (J3DModelData*)dComIfG_getObjectRes("RYUW00", bmdd[i_this->field_0x570]);
|
|
|
|
JUT_ASSERT(543, modelData != NULL);
|
|
|
|
i_this->mpModel = mDoExt_J3DModel__create(modelData, 0x80000, 0x11000084);
|
|
if (i_this->mpModel == NULL) {
|
|
return 0;
|
|
}
|
|
|
|
i_this->mpBgW = JKR_NEW dBgW();
|
|
if (i_this->mpBgW == NULL) {
|
|
return 0;
|
|
}
|
|
|
|
static int dzbd[2] = {
|
|
DZB_K_RYUWOOD00, DZB_K_RYUWOOD01,
|
|
};
|
|
|
|
if (i_this->mpBgW->Set((cBgD_t*)dComIfG_getObjectRes("RYUW00", dzbd[i_this->field_0x570]), 1, &i_this->mMtx) == true) {
|
|
return 0;
|
|
}
|
|
|
|
i_this->mpBgW->SetCrrFunc(dBgS_MoveBGProc_Typical);
|
|
i_this->mpBgW->SetRideCallback(ride_call_back);
|
|
return 1;
|
|
}
|
|
|
|
static cPhs_Step daObj_Fw_Create(fopAc_ac_c* a_this) {
|
|
fopAcM_ct(a_this, obj_fw_class);
|
|
obj_fw_class* i_this = (obj_fw_class*)a_this;
|
|
|
|
cPhs_Step phase = dComIfG_resLoad(&i_this->mPhase, "RYUW00");
|
|
if (phase == cPhs_COMPLEATE_e) {
|
|
if (dComIfGs_isStageBossEnemy()) {
|
|
return cPhs_ERROR_e;
|
|
}
|
|
|
|
OS_REPORT("OBJ_FW PARAM %x\n", fopAcM_GetParam(a_this));
|
|
|
|
i_this->field_0x570 = fopAcM_GetParam(a_this);
|
|
|
|
if (i_this->field_0x570 == 0xFF) {
|
|
i_this->field_0x570 = 0;
|
|
}
|
|
|
|
u32 i_size;
|
|
if (i_this->field_0x570 == 1) {
|
|
i_size = 0x1400;
|
|
} else {
|
|
i_size = 0x1940;
|
|
}
|
|
|
|
OS_REPORT("OBJ_FW//////////////OBJ_FW SET 1 !!\n");
|
|
|
|
if (!fopAcM_entrySolidHeap(a_this, useHeapInit, i_size)) {
|
|
OS_REPORT("//////////////OBJ_FW SET NON !!\n");
|
|
|
|
return cPhs_ERROR_e;
|
|
}
|
|
|
|
OS_REPORT("//////////////OBJ_FW SET 2 !!\n");
|
|
|
|
if (dComIfG_Bgsp().Regist(i_this->mpBgW, a_this)) {
|
|
return cPhs_ERROR_e;
|
|
}
|
|
|
|
if (hio_set == 0) {
|
|
i_this->field_0x624 = 1;
|
|
hio_set = 1;
|
|
l_HIO.field_0x4 = -1;
|
|
}
|
|
|
|
fopAcM_SetMtx(a_this, i_this->mpModel->getBaseTRMtx());
|
|
fopAcM_SetMin(a_this, -1000.0f, -600.0f, -1000.0f);
|
|
fopAcM_SetMax(a_this, 1000.0f, 600.0f, 1000.0f);
|
|
i_this->mSound.init(&a_this->current.pos, 2);
|
|
i_this->field_0x578 = cM_rndF(65536.0f);
|
|
i_this->field_0x590 = cM_rndF(65536.0f);
|
|
|
|
water_check(i_this);
|
|
daObj_Fw_Execute(i_this);
|
|
}
|
|
|
|
return phase;
|
|
}
|
|
|
|
static actor_method_class l_daObj_Fw_Method = {
|
|
(process_method_func)daObj_Fw_Create,
|
|
(process_method_func)daObj_Fw_Delete,
|
|
(process_method_func)daObj_Fw_Execute,
|
|
(process_method_func)daObj_Fw_IsDelete,
|
|
(process_method_func)daObj_Fw_Draw,
|
|
};
|
|
|
|
actor_process_profile_definition g_profile_OBJ_FW = {
|
|
fpcLy_CURRENT_e, // mLayerID
|
|
8, // mListID
|
|
fpcPi_CURRENT_e, // mListPrio
|
|
PROC_OBJ_FW, // mProcName
|
|
&g_fpcLf_Method.base, // sub_method
|
|
sizeof(obj_fw_class), // mSize
|
|
0, // mSizeOther
|
|
0, // mParameters
|
|
&g_fopAc_Method.base, // sub_method
|
|
42, // mPriority
|
|
&l_daObj_Fw_Method, // sub_method
|
|
0x00044100, // mStatus
|
|
fopAc_ACTOR_e, // mActorType
|
|
fopAc_CULLBOX_CUSTOM_e, // cullType
|
|
};
|