Merge remote-tracking branch 'origin/main' into presets

# Conflicts:
#	files.cmake
#	src/d/actor/d_a_title.cpp
#	src/dusk/config.cpp
#	src/dusk/imgui/ImGuiConsole.cpp
#	src/dusk/imgui/ImGuiEngine.cpp
This commit is contained in:
MelonSpeedruns
2026-04-11 16:53:04 -04:00
15380 changed files with 4960 additions and 1354842 deletions
+5
View File
@@ -14,6 +14,7 @@
#include "os_report.h"
#include "dusk/logging.h"
#if !TARGET_PC
DynamicModuleControlBase* DynamicModuleControlBase::mFirst;
DynamicModuleControlBase* DynamicModuleControlBase::mLast;
@@ -139,6 +140,7 @@ DynamicModuleControl::DynamicModuleControl(char const* name) {
mSize = 0;
mAsyncLoadCallback = NULL;
}
#endif
u32 DynamicModuleControl::sAllocBytes;
@@ -169,6 +171,7 @@ bool DynamicModuleControl::initialize() {
return true;
}
#if !TARGET_PC
bool DynamicModuleControl::callback(void* moduleControlPtr) {
DynamicModuleControl* moduleControl = (DynamicModuleControl*)moduleControlPtr;
return moduleControl->do_load();
@@ -484,3 +487,5 @@ extern "C" void ModuleDestructorsX(void (*const *dtors)()) {
dtors++;
}
}
#endif
+8
View File
@@ -898,6 +898,9 @@ BOOL cDyl_IsLinked(s16 i_ProfName) {
}
BOOL cDyl_Unlink(s16 i_ProfName) {
#if TARGET_PC
return FALSE;
#else
#if DEBUG
cCc_Check();
#endif
@@ -911,9 +914,13 @@ BOOL cDyl_Unlink(s16 i_ProfName) {
}
return FALSE;
#endif
}
int cDyl_LinkASync(s16 i_ProfName) {
#if TARGET_PC
return cPhs_COMPLEATE_e;
#else
#if DEBUG
cCc_Check();
#endif
@@ -953,6 +960,7 @@ int cDyl_LinkASync(s16 i_ProfName) {
}
return cPhs_COMPLEATE_e;
#endif
}
static int cDyl_InitCallback(void* param_0) {
+24 -10
View File
@@ -850,7 +850,7 @@ daAlink_FaceTexData const daAlink_c::m_faceTexDataTable[] = {
{dRes_ID_ALANM_BTP_FDAM01_e, dRes_ID_ALANM_BTK_FFINISHA_e},
{dRes_ID_ALANM_BTP_FFINISHA_e, dRes_ID_ALANM_BTK_FFINISHED_e},
{dRes_ID_ALANM_BTP_FARELORD_e, dRes_ID_ALANM_BTK_FARELORD_e},
{dRes_ID_ALANM_BTP_FARELORDTAME_e, dRes_ID_ALANM_BTK_FARELORDTAME_e},
{dRes_ID_ALANM_BTP_FARELORDTAME_e, dRes_ID_ALANM_BTK_FARELORDTAME_e},
{dRes_ID_ALANM_BTP_FPUSHW_e, dRes_ID_ALANM_BTK_FPUSHW_e},
{dRes_ID_ALANM_BTP_FPULLW_e, dRes_ID_ALANM_BTK_FPULLW_e},
{dRes_ID_ALANM_BTP_FWAITST_e, dRes_ID_ALANM_BTK_FWAITST_e},
@@ -1001,7 +1001,7 @@ daAlink_FaceTexData const daAlink_c::m_faceTexDataTable[] = {
{dRes_ID_ALANM_BTP_WL_FSWIMDIEA_e, dRes_ID_ALANM_BTK_WL_FA_e},
{dRes_ID_ALANM_BTP_WL_FSWIMDIEP_e, dRes_ID_ALANM_BTK_WL_FA_e},
{dRes_ID_ALANM_BTP_WL_FMDSHOCK_e, dRes_ID_ALANM_BTK_WL_FMDSHOCK_e},
{dRes_ID_ALANM_BTP_WL_FENTRANCE_e, dRes_ID_ALANM_BTK_WL_FENTRANCE_e},
{dRes_ID_ALANM_BTP_WL_FENTRANCE_e, dRes_ID_ALANM_BTK_WL_FENTRANCE_e},
{dRes_ID_ALANM_BTP_WL_FHOWLC_e, dRes_ID_ALANM_BTK_WL_FA_e},
{dRes_ID_ALANM_BTP_WL_FC_e, dRes_ID_ALANM_BTK_WL_FA_e},
};
@@ -4943,7 +4943,7 @@ int daAlink_c::create() {
if (dComIfG_resLoad(&mShieldPhaseReq, mShieldArcName, mpShieldArcHeap) != cPhs_COMPLEATE_e) {
return cPhs_INIT_e;
}
u32 heapSize = 0x3E930;
heapSize |= 0x80000000;
heapSize |= 0x40000000;
@@ -5885,7 +5885,7 @@ void daAlink_c::setItemMatrix(int param_0) {
|| (mProcID == PROC_CUT_REVERSE && mProcVar2.field_0x300c != 0)
|| mProcID == PROC_GUARD_BREAK
|| (mEquipItem == 0x103 && !checkEndResetFlg1(ERFLG1_SHIELD_BACKBONE) && !checkModeFlg(0x400))
)
)
{
mShieldModel->setBaseTRMtx(mpLinkModel->getAnmMtx(mRightItemJntNo));
@@ -5949,9 +5949,23 @@ void daAlink_c::setItemMatrix(int param_0) {
mpLinkBootModels[0]->setAnmMtx(3, mpLinkModel->getAnmMtx(0x15));
mDoMtx_stack_c::XrotS(-0x8000);
mDoMtx_concat(mpLinkModel->getAnmMtx(0x18), mDoMtx_stack_c::get(), mpLinkBootModels[1]->getAnmMtx(1));
mDoMtx_concat(mpLinkModel->getAnmMtx(0x19), mDoMtx_stack_c::get(), mpLinkBootModels[1]->getAnmMtx(2));
mDoMtx_concat(mpLinkModel->getAnmMtx(0x1A), mDoMtx_stack_c::get(), mpLinkBootModels[1]->getAnmMtx(3));
#ifdef TARGET_PC
if (dusk::getSettings().game.enableFrameInterpolation) {
Mtx boot_mtx;
mDoMtx_concat(mpLinkModel->getAnmMtx(0x18), mDoMtx_stack_c::get(), boot_mtx);
mpLinkBootModels[1]->setAnmMtx(1, boot_mtx);
mDoMtx_concat(mpLinkModel->getAnmMtx(0x19), mDoMtx_stack_c::get(), boot_mtx);
mpLinkBootModels[1]->setAnmMtx(2, boot_mtx);
mDoMtx_concat(mpLinkModel->getAnmMtx(0x1A), mDoMtx_stack_c::get(), boot_mtx);
mpLinkBootModels[1]->setAnmMtx(3, boot_mtx);
} else {
#endif
mDoMtx_concat(mpLinkModel->getAnmMtx(0x18), mDoMtx_stack_c::get(), mpLinkBootModels[1]->getAnmMtx(1));
mDoMtx_concat(mpLinkModel->getAnmMtx(0x19), mDoMtx_stack_c::get(), mpLinkBootModels[1]->getAnmMtx(2));
mDoMtx_concat(mpLinkModel->getAnmMtx(0x1A), mDoMtx_stack_c::get(), mpLinkBootModels[1]->getAnmMtx(3));
#ifdef TARGET_PC
}
#endif
}
if (!checkNoResetFlg2(FLG2_STATUS_WINDOW_DRAW)) {
@@ -6279,7 +6293,7 @@ void daAlink_c::setWolfAtCollision() {
void daAlink_c::resetAtCollision(BOOL param_0) {
if (checkNoResetFlg0(FLG0_CUT_AT_FLG)) {
if (param_0
if (param_0
&& !setSwordHitVibration(&mAtCps[0])
&& !setSwordHitVibration(&mAtCps[1])
&& !setSwordHitVibration(&mAtCps[2])
@@ -14055,7 +14069,7 @@ void daAlink_c::setMetamorphoseModel(BOOL i_isChangeToWolf) {
JKRHeap* heap = setItemHeap();
mHeldItemModel = initModel(loadAramBmd(dRes_ID_ALANM_BMD_AL_WF_e, 0x6000), 0);
if (!mItemBck.init(bck, FALSE, 2, 1.0f, 0, -1, false)) {
JUT_ASSERT(20842, FALSE);
}
@@ -16727,7 +16741,7 @@ int daAlink_c::procAutoJump() {
#if VERSION == VERSION_SHIELD_DEBUG
if (!checkStageName("F_SP115") && mGrabItemAcKeep.getActor() != NULL) {
if ((fopAcM_GetName(mGrabItemAcKeep.getActor()) == fpcNm_NI_e && ((ni_class*)mGrabItemAcKeep.getActor())->checkGold() != TRUE) ||
(fopAcM_GetName(mGrabItemAcKeep.getActor()) == fpcNm_NPC_TKJ2_e))
(fopAcM_GetName(mGrabItemAcKeep.getActor()) == fpcNm_NPC_TKJ2_e))
{
mMaxSpeed = mpHIO->mAutoJump.m.mCuccoJumpMaxSpeed;
field_0x3478 = mpHIO->mAutoJump.m.mCuccoFallMaxSpeed;
+12 -5
View File
@@ -9,11 +9,6 @@ void daAlink_c::handleQuickTransform() {
return;
}
// Ensure that link is not in a cutscene.
if (checkEventRun()) {
return;
}
// Check to see if Link has the ability to transform.
if (!dComIfGs_isEventBit(dSv_event_flag_c::M_077)) {
return;
@@ -30,8 +25,20 @@ void daAlink_c::handleQuickTransform() {
return;
}
// Ensure that link is not in a cutscene.
if (checkEventRun()) {
Z2GetAudioMgr()->seStart(Z2SE_SYS_ERROR, NULL, 0, 0, 1.0f, 1.0f, -1.0f, -1.0f, 0);
return;
}
mDoCPd_c::getCpadInfo(PAD_1).mPressedButtonFlags = 0;
// Don't allow quick transform while in the STAR tent.
if (checkStageName("R_SP161")) {
Z2GetAudioMgr()->seStart(Z2SE_SYS_ERROR, NULL, 0, 0, 1.0f, 1.0f, -1.0f, -1.0f, 0);
return;
}
// Ensure that the Z Button is not dimmed
if (meterDrawPtr->getButtonZAlpha() != 1.f) {
Z2GetAudioMgr()->seStart(Z2SE_SYS_ERROR, NULL, 0, 0, 1.0f, 1.0f, -1.0f, -1.0f, 0);
+42 -42
View File
@@ -1444,11 +1444,11 @@ static void demo_camera(b_bq_class* i_this) {
i_this->mDemoCamEyeTarget.set(240.0f, 274.0f, 2075.0f);
i_this->field_0x1288.x =
std::fabsf(i_this->mDemoCamCenterTarget.x - i_this->mDemoCamCenter.x);
fabsf(i_this->mDemoCamCenterTarget.x - i_this->mDemoCamCenter.x);
i_this->field_0x1288.y =
std::fabsf(i_this->mDemoCamCenterTarget.y - i_this->mDemoCamCenter.y);
fabsf(i_this->mDemoCamCenterTarget.y - i_this->mDemoCamCenter.y);
i_this->field_0x1288.z =
std::fabsf(i_this->mDemoCamCenterTarget.z - i_this->mDemoCamCenter.z);
fabsf(i_this->mDemoCamCenterTarget.z - i_this->mDemoCamCenter.z);
}
spFC.set(0.0f, 0.0f, 1700.0f);
@@ -1478,16 +1478,16 @@ static void demo_camera(b_bq_class* i_this) {
i_this->mDemoCamCenterTarget.set(76.0f, 204.0f, 1782.0f);
i_this->mDemoCamEyeTarget.set(-41.0f, 261.0f, 2095.0f);
i_this->field_0x127c.x = std::fabsf(i_this->mDemoCamEyeTarget.x - i_this->mDemoCamEye.x);
i_this->field_0x127c.y = std::fabsf(i_this->mDemoCamEyeTarget.y - i_this->mDemoCamEye.y);
i_this->field_0x127c.z = std::fabsf(i_this->mDemoCamEyeTarget.z - i_this->mDemoCamEye.z);
i_this->field_0x127c.x = fabsf(i_this->mDemoCamEyeTarget.x - i_this->mDemoCamEye.x);
i_this->field_0x127c.y = fabsf(i_this->mDemoCamEyeTarget.y - i_this->mDemoCamEye.y);
i_this->field_0x127c.z = fabsf(i_this->mDemoCamEyeTarget.z - i_this->mDemoCamEye.z);
i_this->field_0x1288.x =
std::fabsf(i_this->mDemoCamCenterTarget.x - i_this->mDemoCamCenter.x);
fabsf(i_this->mDemoCamCenterTarget.x - i_this->mDemoCamCenter.x);
i_this->field_0x1288.y =
std::fabsf(i_this->mDemoCamCenterTarget.y - i_this->mDemoCamCenter.y);
fabsf(i_this->mDemoCamCenterTarget.y - i_this->mDemoCamCenter.y);
i_this->field_0x1288.z =
std::fabsf(i_this->mDemoCamCenterTarget.z - i_this->mDemoCamCenter.z);
fabsf(i_this->mDemoCamCenterTarget.z - i_this->mDemoCamCenter.z);
i_this->field_0x129c = 0.0f;
i_this->mDemoMode = 12;
@@ -1584,16 +1584,16 @@ static void demo_camera(b_bq_class* i_this) {
i_this->mDemoCamCenterTarget.set(0.0f, 278.0f, 1252.0f);
i_this->mDemoCamEyeTarget.set(0.0f, 86.0f, 2167.0f);
i_this->field_0x127c.x = std::fabsf(i_this->mDemoCamEyeTarget.x - i_this->mDemoCamEye.x);
i_this->field_0x127c.y = std::fabsf(i_this->mDemoCamEyeTarget.y - i_this->mDemoCamEye.y);
i_this->field_0x127c.z = std::fabsf(i_this->mDemoCamEyeTarget.z - i_this->mDemoCamEye.z);
i_this->field_0x127c.x = fabsf(i_this->mDemoCamEyeTarget.x - i_this->mDemoCamEye.x);
i_this->field_0x127c.y = fabsf(i_this->mDemoCamEyeTarget.y - i_this->mDemoCamEye.y);
i_this->field_0x127c.z = fabsf(i_this->mDemoCamEyeTarget.z - i_this->mDemoCamEye.z);
i_this->field_0x1288.x =
std::fabsf(i_this->mDemoCamCenterTarget.x - i_this->mDemoCamCenter.x);
fabsf(i_this->mDemoCamCenterTarget.x - i_this->mDemoCamCenter.x);
i_this->field_0x1288.y =
std::fabsf(i_this->mDemoCamCenterTarget.y - i_this->mDemoCamCenter.y);
fabsf(i_this->mDemoCamCenterTarget.y - i_this->mDemoCamCenter.y);
i_this->field_0x1288.z =
std::fabsf(i_this->mDemoCamCenterTarget.z - i_this->mDemoCamCenter.z);
fabsf(i_this->mDemoCamCenterTarget.z - i_this->mDemoCamCenter.z);
i_this->field_0x129c = 0.0f;
i_this->mDemoMode = 14;
@@ -1741,16 +1741,16 @@ static void demo_camera(b_bq_class* i_this) {
i_this->mDemoCamCenterTarget.set(-2243.0f, 1340.0f, 977.0f);
i_this->mDemoCamEyeTarget.set(-1226.0f, 980.0f, 1350.0f);
i_this->field_0x127c.x = std::fabsf(i_this->mDemoCamEyeTarget.x - i_this->mDemoCamEye.x);
i_this->field_0x127c.y = std::fabsf(i_this->mDemoCamEyeTarget.y - i_this->mDemoCamEye.y);
i_this->field_0x127c.z = std::fabsf(i_this->mDemoCamEyeTarget.z - i_this->mDemoCamEye.z);
i_this->field_0x127c.x = fabsf(i_this->mDemoCamEyeTarget.x - i_this->mDemoCamEye.x);
i_this->field_0x127c.y = fabsf(i_this->mDemoCamEyeTarget.y - i_this->mDemoCamEye.y);
i_this->field_0x127c.z = fabsf(i_this->mDemoCamEyeTarget.z - i_this->mDemoCamEye.z);
i_this->field_0x1288.x =
std::fabsf(i_this->mDemoCamCenterTarget.x - i_this->mDemoCamCenter.x);
fabsf(i_this->mDemoCamCenterTarget.x - i_this->mDemoCamCenter.x);
i_this->field_0x1288.y =
std::fabsf(i_this->mDemoCamCenterTarget.y - i_this->mDemoCamCenter.y);
fabsf(i_this->mDemoCamCenterTarget.y - i_this->mDemoCamCenter.y);
i_this->field_0x1288.z =
std::fabsf(i_this->mDemoCamCenterTarget.z - i_this->mDemoCamCenter.z);
fabsf(i_this->mDemoCamCenterTarget.z - i_this->mDemoCamCenter.z);
i_this->field_0x129c = 0.0f;
i_this->mDemoMode = 34;
@@ -1814,9 +1814,9 @@ static void demo_camera(b_bq_class* i_this) {
i_this->mDemoCamEye.set(95.0f, 50.0f, 2800.0f);
i_this->mDemoCamEyeTarget.set(72.0f, 52.0f, 2153.0f);
i_this->field_0x127c.x = std::fabsf(i_this->mDemoCamEyeTarget.x - i_this->mDemoCamEye.x);
i_this->field_0x127c.y = std::fabsf(i_this->mDemoCamEyeTarget.y - i_this->mDemoCamEye.y);
i_this->field_0x127c.z = std::fabsf(i_this->mDemoCamEyeTarget.z - i_this->mDemoCamEye.z);
i_this->field_0x127c.x = fabsf(i_this->mDemoCamEyeTarget.x - i_this->mDemoCamEye.x);
i_this->field_0x127c.y = fabsf(i_this->mDemoCamEyeTarget.y - i_this->mDemoCamEye.y);
i_this->field_0x127c.z = fabsf(i_this->mDemoCamEyeTarget.z - i_this->mDemoCamEye.z);
i_this->field_0x1288.set(0.0f, 0.0f, 0.0f);
i_this->field_0x129c = 0.0f;
@@ -1973,18 +1973,18 @@ static void demo_camera(b_bq_class* i_this) {
i_this->mDemoCamEyeTarget.set(1214.0f, 350.0f, 2696.0f);
i_this->field_0x127c.x =
std::fabsf(i_this->mDemoCamEyeTarget.x - i_this->mDemoCamEye.x);
fabsf(i_this->mDemoCamEyeTarget.x - i_this->mDemoCamEye.x);
i_this->field_0x127c.y =
std::fabsf(i_this->mDemoCamEyeTarget.y - i_this->mDemoCamEye.y);
fabsf(i_this->mDemoCamEyeTarget.y - i_this->mDemoCamEye.y);
i_this->field_0x127c.z =
std::fabsf(i_this->mDemoCamEyeTarget.z - i_this->mDemoCamEye.z);
fabsf(i_this->mDemoCamEyeTarget.z - i_this->mDemoCamEye.z);
i_this->field_0x1288.x =
std::fabsf(i_this->mDemoCamCenterTarget.x - i_this->mDemoCamCenter.x);
fabsf(i_this->mDemoCamCenterTarget.x - i_this->mDemoCamCenter.x);
i_this->field_0x1288.y =
std::fabsf(i_this->mDemoCamCenterTarget.y - i_this->mDemoCamCenter.y);
fabsf(i_this->mDemoCamCenterTarget.y - i_this->mDemoCamCenter.y);
i_this->field_0x1288.z =
std::fabsf(i_this->mDemoCamCenterTarget.z - i_this->mDemoCamCenter.z);
fabsf(i_this->mDemoCamCenterTarget.z - i_this->mDemoCamCenter.z);
i_this->field_0x129c = 0.0f;
} else if (i_this->mDemoModeTimer < 140) {
@@ -1993,18 +1993,18 @@ static void demo_camera(b_bq_class* i_this) {
i_this->mDemoCamEyeTarget.set(23.0f, 108.0f, 2155.0f);
i_this->field_0x127c.x =
std::fabsf(i_this->mDemoCamEyeTarget.x - i_this->mDemoCamEye.x);
fabsf(i_this->mDemoCamEyeTarget.x - i_this->mDemoCamEye.x);
i_this->field_0x127c.y =
std::fabsf(i_this->mDemoCamEyeTarget.y - i_this->mDemoCamEye.y);
fabsf(i_this->mDemoCamEyeTarget.y - i_this->mDemoCamEye.y);
i_this->field_0x127c.z =
std::fabsf(i_this->mDemoCamEyeTarget.z - i_this->mDemoCamEye.z);
fabsf(i_this->mDemoCamEyeTarget.z - i_this->mDemoCamEye.z);
i_this->field_0x1288.x =
std::fabsf(i_this->mDemoCamCenterTarget.x - i_this->mDemoCamCenter.x);
fabsf(i_this->mDemoCamCenterTarget.x - i_this->mDemoCamCenter.x);
i_this->field_0x1288.y =
std::fabsf(i_this->mDemoCamCenterTarget.y - i_this->mDemoCamCenter.y);
fabsf(i_this->mDemoCamCenterTarget.y - i_this->mDemoCamCenter.y);
i_this->field_0x1288.z =
std::fabsf(i_this->mDemoCamCenterTarget.z - i_this->mDemoCamCenter.z);
fabsf(i_this->mDemoCamCenterTarget.z - i_this->mDemoCamCenter.z);
}
cam_3d_morf(i_this, 0.1f);
@@ -2042,18 +2042,18 @@ static void demo_camera(b_bq_class* i_this) {
i_this->mDemoCamEyeTarget.set(953.0f, 997.0f, -36.0f);
i_this->field_0x127c.x =
std::fabsf(i_this->mDemoCamEyeTarget.x - i_this->mDemoCamEye.x);
fabsf(i_this->mDemoCamEyeTarget.x - i_this->mDemoCamEye.x);
i_this->field_0x127c.y =
std::fabsf(i_this->mDemoCamEyeTarget.y - i_this->mDemoCamEye.y);
fabsf(i_this->mDemoCamEyeTarget.y - i_this->mDemoCamEye.y);
i_this->field_0x127c.z =
std::fabsf(i_this->mDemoCamEyeTarget.z - i_this->mDemoCamEye.z);
fabsf(i_this->mDemoCamEyeTarget.z - i_this->mDemoCamEye.z);
i_this->field_0x1288.x =
std::fabsf(i_this->mDemoCamCenterTarget.x - i_this->mDemoCamCenter.x);
fabsf(i_this->mDemoCamCenterTarget.x - i_this->mDemoCamCenter.x);
i_this->field_0x1288.y =
std::fabsf(i_this->mDemoCamCenterTarget.y - i_this->mDemoCamCenter.y);
fabsf(i_this->mDemoCamCenterTarget.y - i_this->mDemoCamCenter.y);
i_this->field_0x1288.z =
std::fabsf(i_this->mDemoCamCenterTarget.z - i_this->mDemoCamCenter.z);
fabsf(i_this->mDemoCamCenterTarget.z - i_this->mDemoCamCenter.z);
cXyz pos(0.0f, 0.0f, 0.0f);
for (int i = 0; i < 5; i++) {
+18 -18
View File
@@ -2462,12 +2462,12 @@ static void demo_camera(b_ob_class* i_this) {
i_this->mDemoCamCenterTarget.set(80.0f, -24093.0f, 160.0f);
i_this->mDemoCamEyeTarget.set(-447.0f, -22850.0f, -718.0f);
i_this->field_0x5cb4 = std::fabsf(i_this->mDemoCamEyeTarget.x - i_this->mDemoCamEye.x);
i_this->field_0x5cb8 = std::fabsf(i_this->mDemoCamEyeTarget.y - i_this->mDemoCamEye.y);
i_this->field_0x5cbc = std::fabsf(i_this->mDemoCamEyeTarget.z - i_this->mDemoCamEye.z);
i_this->field_0x5cc0 = std::fabsf(i_this->mDemoCamCenterTarget.x - i_this->mDemoCamCenter.x);
i_this->field_0x5cc4 = std::fabsf(i_this->mDemoCamCenterTarget.y - i_this->mDemoCamCenter.y);
i_this->field_0x5cc8 = std::fabsf(i_this->mDemoCamCenterTarget.z - i_this->mDemoCamCenter.z);
i_this->field_0x5cb4 = fabsf(i_this->mDemoCamEyeTarget.x - i_this->mDemoCamEye.x);
i_this->field_0x5cb8 = fabsf(i_this->mDemoCamEyeTarget.y - i_this->mDemoCamEye.y);
i_this->field_0x5cbc = fabsf(i_this->mDemoCamEyeTarget.z - i_this->mDemoCamEye.z);
i_this->field_0x5cc0 = fabsf(i_this->mDemoCamCenterTarget.x - i_this->mDemoCamCenter.x);
i_this->field_0x5cc4 = fabsf(i_this->mDemoCamCenterTarget.y - i_this->mDemoCamCenter.y);
i_this->field_0x5cc8 = fabsf(i_this->mDemoCamCenterTarget.z - i_this->mDemoCamCenter.z);
i_this->field_0x5cd0 = 0.0f;
daPy_getPlayerActorClass()->changeDemoMode(0x17, 0, 0, 0);
@@ -2590,12 +2590,12 @@ static void demo_camera(b_ob_class* i_this) {
i_this->mDemoCamCenterTarget.set(-6378.0f, -21886.0f, 7150.0f);
i_this->mDemoCamEyeTarget.set(-6961.0f, -21727.0f, 7278.0f);
i_this->field_0x5cb4 = std::fabsf(i_this->mDemoCamEyeTarget.x - i_this->mDemoCamEye.x);
i_this->field_0x5cb8 = std::fabsf(i_this->mDemoCamEyeTarget.y - i_this->mDemoCamEye.y);
i_this->field_0x5cbc = std::fabsf(i_this->mDemoCamEyeTarget.z - i_this->mDemoCamEye.z);
i_this->field_0x5cc0 = std::fabsf(i_this->mDemoCamCenterTarget.x - i_this->mDemoCamCenter.x);
i_this->field_0x5cc4 = std::fabsf(i_this->mDemoCamCenterTarget.y - i_this->mDemoCamCenter.y);
i_this->field_0x5cc8 = std::fabsf(i_this->mDemoCamCenterTarget.z - i_this->mDemoCamCenter.z);
i_this->field_0x5cb4 = fabsf(i_this->mDemoCamEyeTarget.x - i_this->mDemoCamEye.x);
i_this->field_0x5cb8 = fabsf(i_this->mDemoCamEyeTarget.y - i_this->mDemoCamEye.y);
i_this->field_0x5cbc = fabsf(i_this->mDemoCamEyeTarget.z - i_this->mDemoCamEye.z);
i_this->field_0x5cc0 = fabsf(i_this->mDemoCamCenterTarget.x - i_this->mDemoCamCenter.x);
i_this->field_0x5cc4 = fabsf(i_this->mDemoCamCenterTarget.y - i_this->mDemoCamCenter.y);
i_this->field_0x5cc8 = fabsf(i_this->mDemoCamCenterTarget.z - i_this->mDemoCamCenter.z);
i_this->field_0x5cd0 = 0.0f;
i_this->mDemoAction = 46;
@@ -2656,12 +2656,12 @@ static void demo_camera(b_ob_class* i_this) {
i_this->mDemoCamCenterTarget.set(-2933.0f, -22626.0f, 6829.0f);
i_this->mDemoCamEyeTarget.set(-3295.0f, -22459.0f, 7307.0f);
i_this->field_0x5cb4 = std::fabsf(i_this->mDemoCamEyeTarget.x - i_this->mDemoCamEye.x);
i_this->field_0x5cb8 = std::fabsf(i_this->mDemoCamEyeTarget.y - i_this->mDemoCamEye.y);
i_this->field_0x5cbc = std::fabsf(i_this->mDemoCamEyeTarget.z - i_this->mDemoCamEye.z);
i_this->field_0x5cc0 = std::fabsf(i_this->mDemoCamCenterTarget.x - i_this->mDemoCamCenter.x);
i_this->field_0x5cc4 = std::fabsf(i_this->mDemoCamCenterTarget.y - i_this->mDemoCamCenter.y);
i_this->field_0x5cc8 = std::fabsf(i_this->mDemoCamCenterTarget.z - i_this->mDemoCamCenter.z);
i_this->field_0x5cb4 = fabsf(i_this->mDemoCamEyeTarget.x - i_this->mDemoCamEye.x);
i_this->field_0x5cb8 = fabsf(i_this->mDemoCamEyeTarget.y - i_this->mDemoCamEye.y);
i_this->field_0x5cbc = fabsf(i_this->mDemoCamEyeTarget.z - i_this->mDemoCamEye.z);
i_this->field_0x5cc0 = fabsf(i_this->mDemoCamCenterTarget.x - i_this->mDemoCamCenter.x);
i_this->field_0x5cc4 = fabsf(i_this->mDemoCamCenterTarget.y - i_this->mDemoCamCenter.y);
i_this->field_0x5cc8 = fabsf(i_this->mDemoCamCenterTarget.z - i_this->mDemoCamCenter.z);
i_this->field_0x5cd0 = 0.0f;
i_this->mDemoAction = 48;
+2 -2
View File
@@ -398,7 +398,7 @@ static int daE_TK2_Execute(e_tk2_class* i_this) {
cXyz cStack_94;
cXyz cStack_a0;
if (i_this->mExecuteState == 0x00) {
if (i_this->mActionTimer[3] == 0x00) {
dBgS_ObjGndChk_Spl ground_check;
cStack_94 = actor->current.pos;
cStack_94.y += 200.0f;
@@ -602,7 +602,7 @@ static int daE_TK2_Create(fopAc_ac_c* actor) {
i_this->mSound.init(&actor->current.pos, &actor->eyePos, 0x3, 0x1);
i_this->mSound.setEnemyName("E_tk2");
i_this->mAtInfo.mpSound = &i_this->mSound;
i_this->mExecuteState = 0x14;
i_this->mActionTimer[3] = 0x14;
daE_TK2_Execute(i_this);
}
return phase;
+25
View File
@@ -167,6 +167,30 @@ static dCcD_SrcSph cc_vt_magic_src = {
} // mSphAttr
};
// !@bug The i<40 loops that index these arrays read one element past the end; on
// GC/Wii the OOB reads land on adjacent rodata instead of a defined value.
#if AVOID_UB
static u8 va_tag_set_size[40] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02,
0x00,
};
static u8 va_tag_set_num[40] = {
0x01, 0x0C, 0x16, 0x1F, 0x21, 0x2A, 0x2B, 0x02, 0x04, 0x0D, 0x0F, 0x15, 0x18,
0x20, 0x2C, 0x03, 0x05, 0x06, 0x0B, 0x10, 0x17, 0x19, 0x1A, 0x22, 0x24, 0x29,
0x2D, 0x34, 0x49, 0x52, 0x36, 0x3E, 0x54, 0x5C, 0x39, 0x41, 0x4C, 0x56, 0x5E,
0x00,
};
static f32 va_tag_offset[40] = {
20.0f, 20.0f, 20.0f, 20.0f, 20.0f, 0.0f, 40.0f, 0.0f, 30.0f, 10.0f, 0.0f, 0.0f, 20.0f,
0.0f, 10.0f, 20.0f, 40.0f, 0.0f, 20.0f, 0.0f, 0.0f, 20.0f, 0.0f, 10.0f, 0.0f, 0.0f,
20.0f, 10.0f, 20.0f, 30.0f, 0.0f, 10.0f, 20.0f, 0.0f, 0.0f, 10.0f, 20.0f, 30.0f, 0.0f,
0.0f,
};
#else
static u8 va_tag_set_size[39] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
@@ -184,6 +208,7 @@ static f32 va_tag_offset[39] = {
0.0f, 10.0f, 20.0f, 40.0f, 0.0f, 20.0f, 0.0f, 0.0f, 20.0f, 0.0f, 10.0f, 0.0f, 0.0f,
20.0f, 10.0f, 20.0f, 30.0f, 0.0f, 10.0f, 20.0f, 0.0f, 0.0f, 10.0f, 20.0f, 30.0f, 0.0f,
};
#endif
} // namespace
+1 -1
View File
@@ -516,7 +516,7 @@ void daE_YMB_c::checkWaterPos() {
field_0x6cc = wtr_pos;
field_0x69c.y = wtr_pos + 1000.0f + l_HIO.fly_height_adjust;
UNUSED(std::fabsf(field_0x6cc - current.pos.y));
UNUSED(fabsf(field_0x6cc - current.pos.y));
if (current.pos.y < (200.0f + field_0x6cc)) {
if (field_0x715 == 0) {
setWaterEffect1();
+7
View File
@@ -14,6 +14,7 @@
#include "d/d_msg_object.h"
#include "d/d_s_play.h"
#include "d/d_debug_viewer.h"
#include "dusk/frame_interpolation.h"
static f32 dummy_lit_3777(int idx, u8 foo) {
Vec dummy_vec = {0.0f, 0.0f, 0.0f};
@@ -1052,6 +1053,12 @@ void daMidna_c::setBodyPartMatrix() {
mpModel->setAnmMtx(i, mpShadowModel->getAnmMtx(i));
}
mpModel->calcWeightEnvelopeMtx();
#ifdef TARGET_PC
// Frame interpolation: Record weight envelopes for Midna here, as they are otherwise missed causing distortion
for (u16 i = 0; i < mpModel->getModelData()->getWEvlpMtxNum(); i++) {
dusk::frame_interp::record_final_mtx_raw(reinterpret_cast<const Mtx*>(mpModel->getWeightAnmMtx(i)), mpModel->getWeightAnmMtx(i));
}
#endif
}
mDoMtx_stack_c::transS(mpShadowModel->getAnmMtx(JNT_BACKBONE1)[0][3],
+2 -2
View File
@@ -411,7 +411,7 @@ void daObjTOMBO_c::BoomChk() {
speedF = 5.0f;
field_0x71c = 5.0f;
mIsHitByBoomerang = false;
field_0x718 = 100;
field_0x714[2] = 100;
mpMorf->setAnm((J3DAnmTransform*)dComIfG_getObjectRes("Tombo", 6), 2, 5.0f, 1.0f,
0.0f, -1.0f);
home.pos = current.pos;
@@ -422,7 +422,7 @@ void daObjTOMBO_c::BoomChk() {
mIsHitByBoomerang = false;
speedF = 5.0f;
field_0x71c = 5.0f;
field_0x718 = 100;
field_0x714[2] = 100;
mpMorf->setAnm((J3DAnmTransform*)dComIfG_getObjectRes("Tombo", 6), 2, 5.0f, 1.0f,
0.0f, -1.0f);
current.pos.y = old.pos.y = playerPos.y + 100.0f;
+1 -1
View File
@@ -650,7 +650,7 @@ void daTbox_c::dropProcInit() {
field_0x97c = false;
f32 delta_y = pos.y - pnt1.y;
f32 abs_gravity = std::fabsf(fopAcM_GetGravity(this));
f32 abs_gravity = fabsf(fopAcM_GetGravity(this));
var_f30 = JMAFastSqrt(2.0f * delta_y / abs_gravity);
speedF = pos.absXZ(pnt1) / var_f30;
+14 -8
View File
@@ -126,7 +126,7 @@ static procFunc daTitleProc[6] = {
int daTitle_c::create() {
fopAcM_ct(this, daTitle_c);
int phase_state = dComIfG_resLoad(&mPhaseReq, l_arcName);
if (phase_state != cPhs_COMPLEATE_e) {
return phase_state;
@@ -157,20 +157,26 @@ int daTitle_c::createHeapCallBack(fopAc_ac_c* actor) {
int daTitle_c::Execute() {
#if TARGET_PC
if (dusk::config::IsConfigFileMissing()) {
if (!dusk::getSettings().backend.wasPresetChosen) {
return 0;
}
#endif
#if PLATFORM_WII || PLATFORM_SHIELD
mDoGph_gInf_c::resetDimming();
#endif
#endif
if (fopOvlpM_IsPeek()) {
return 1;
}
dMenu_Collect3D_c::setViewPortOffsetY(0.0f);
#ifdef TARGET_PC
if (!dusk::getSettings().game.enableFrameInterpolation) {
#endif
dMenu_Collect3D_c::setViewPortOffsetY(0.0f);
#ifdef TARGET_PC
}
#endif
if (mDoRst::isReset()) {
return 1;
@@ -179,9 +185,9 @@ int daTitle_c::Execute() {
(this->*daTitleProc[mProcID])();
KeyWaitAnm();
#if VERSION == VERSION_SHIELD_DEBUG
#if VERSION == VERSION_SHIELD_DEBUG
KeyWaitPosMove();
#endif
#endif
return 1;
}
@@ -375,7 +381,7 @@ int daTitle_c::getDemoPrm() {
int daTitle_c::Draw() {
#if TARGET_PC
if (dusk::config::IsConfigFileMissing()) {
if (!dusk::getSettings().backend.wasPresetChosen) {
return 0;
}
#endif
@@ -406,7 +412,7 @@ int daTitle_c::Delete() {
dComIfG_resDelete(&mPhaseReq, l_arcName);
JKR_DELETE(mTitle.Scr);
JKR_DELETE(field_0x600);
mpMount->getArchive()->removeResourceAll();
JKRUnmountArchive(mpMount->getArchive());
mpMount->destroy();
+25 -2
View File
@@ -5,6 +5,8 @@
#include "JSystem/J3DGraphBase/J3DDrawBuffer.h"
#include "SSystem/SComponent/c_counter.h"
#include "dusk/frame_interpolation.h"
#if TARGET_PC
const u16 l_J_Ohana00_64TEX__width = 64;
const u16 l_J_Ohana00_64TEX__height = 64;
@@ -695,7 +697,16 @@ void dFlower_packet_c::draw() {
GXSetChanAmbColor(GX_COLOR0A0, sp64);
if (!cLib_checkBit<u8>(sp44->m_state, 4) && !cLib_checkBit<u8>(sp44->m_state, 0x40)) {
GXLoadPosMtxImm(sp44->m_modelMtx, 0);
#ifdef TARGET_PC
Mtx flower_mtx;
if (dusk::frame_interp::lookup_replacement(reinterpret_cast<const void*>(&sp44->m_modelMtx), flower_mtx)) {
GXLoadPosMtxImm(flower_mtx, 0);
} else {
#endif
GXLoadPosMtxImm(sp44->m_modelMtx, 0);
#ifdef TARGET_PC
}
#endif
GXLoadNrmMtxImm(j3dSys.getViewMtx(), 0);
#if TARGET_PC
@@ -841,7 +852,16 @@ void dFlower_packet_c::draw() {
sp30++;
if (!cLib_checkBit<u8>(sp34->m_state, 4) && cLib_checkBit<u8>(sp34->m_state, 0x40)) {
GXLoadPosMtxImm(sp34->m_modelMtx, 0);
#ifdef TARGET_PC
Mtx flower_mtx;
if (dusk::frame_interp::lookup_replacement(reinterpret_cast<const void*>(&sp34->m_modelMtx), flower_mtx)) {
GXLoadPosMtxImm(flower_mtx, 0);
} else {
#endif
GXLoadPosMtxImm(sp34->m_modelMtx, 0);
#ifdef TARGET_PC
}
#endif
GXLoadNrmMtxImm(j3dSys.getViewMtx(), 0);
#if TARGET_PC
@@ -973,6 +993,9 @@ void dFlower_packet_c::update() {
mDoMtx_stack_c::copy(temp_r28);
mDoMtx_stack_c::scaleM(temp_f31, temp_f31, temp_f31);
cMtx_concat(j3dSys.getViewMtx(), temp_r28, data_p->m_modelMtx);
#ifdef TARGET_PC
dusk::frame_interp::record_final_mtx_raw(reinterpret_cast<const Mtx*>(&data_p->m_modelMtx), data_p->m_modelMtx);
#endif
}
}
+15 -1
View File
@@ -11,6 +11,8 @@
#include "d/d_camera.h"
#include "f_op/f_op_camera_mng.h"
#include "dusk/frame_interpolation.h"
const u16 l_M_Hijiki00TEX__width = 31;
const u16 l_M_Hijiki00TEX__height = 31;
const u16 l_M_kusa05_RGBATEX__width = 31;
@@ -751,7 +753,16 @@ void dGrass_packet_c::draw() {
GXSetChanAmbColor(GX_COLOR0A0, sp38);
if (!cLib_checkBit<u8>(var_r29->field_0x01, 2)) {
GXLoadPosMtxImm(var_r29->m_modelMtx, 0);
#ifdef TARGET_PC
Mtx grass_mtx;
if (dusk::frame_interp::lookup_replacement(reinterpret_cast<const void*>(&var_r29->m_modelMtx), grass_mtx)) {
GXLoadPosMtxImm(grass_mtx, 0);
} else {
#endif
GXLoadPosMtxImm(var_r29->m_modelMtx, 0);
#ifdef TARGET_PC
}
#endif
GXLoadNrmMtxImm(j3dSys.getViewMtx(), 0);
if (var_r29->field_0x05 <= 3 || var_r29->field_0x05 >= 10) {
if (var_r29->field_0x02 < -1) {
@@ -1006,6 +1017,9 @@ void dGrass_packet_c::update() {
mDoMtx_stack_c::scaleM(scale, scale, scale);
cMtx_concat(j3dSys.getViewMtx(), mDoMtx_stack_c::get(), data_p->m_modelMtx);
}
#ifdef TARGET_PC
dusk::frame_interp::record_final_mtx_raw(reinterpret_cast<const Mtx*>(&data_p->m_modelMtx), data_p->m_modelMtx);
#endif
}
}
data_p++;
+58 -41
View File
@@ -20,6 +20,7 @@
#include "m_Do/m_Do_controller_pad.h"
#include "m_Do/m_Do_graphic.h"
#include "m_Do/m_Do_lib.h"
#include "dusk/frame_interpolation.h"
#include <cmath>
#include <cstring>
@@ -2179,9 +2180,9 @@ fopAc_ac_c* dCamera_c::getParamTargetActor(s32 param_0) {
daAlink_c* player = daAlink_getAlinkActorClass();
fopAc_ac_c* result;
u32* name = (u32*)(mCamTypeData[param_0].name + 16);
BE(u32)* name = (BE(u32)*)(mCamTypeData[param_0].name + 16);
//name += 16;
switch (*name) {
switch ((u32)*name) {
case '@LOC':
result = dComIfGp_getAttention()->LockonTarget(0);
break;
@@ -2417,10 +2418,18 @@ f32 dCamera_c::radiusActorInSight(fopAc_ac_c* i_actor1, fopAc_ac_c* i_actor2, cX
dDlst_window_c* window = get_window(field_0x0);
scissor_class* scissor = window->getScissor();
f32 var_f29 = cAngle::d2r(i_fovY) * 0.5f;
#if TARGET_PC
view_port_class* viewport = window->getViewPort();
f32 var_f28 = (scissor->height - mTrimHeight * 2.0f) / viewport->height;
f32 sp34 = var_f29 * var_f28 * (mTrimHeight < 0.01f ? 0.95f : 1.0f);
var_f29 *= mWindowAspect;
var_f28 = scissor->width / viewport->width;
#else
f32 var_f28 = (scissor->height - mTrimHeight * 2.0f) / FB_HEIGHT;
f32 sp34 = var_f29 * var_f28 * (mTrimHeight < 0.01f ? 0.95f : 1.0f);
var_f29 *= mWindowAspect;
var_f28 = scissor->width / FB_WIDTH;
#endif
f32 sp30 = var_f29 * var_f28 * 0.85f;
cXyz pos1 = attentionPos(i_actor1);
@@ -2450,8 +2459,8 @@ f32 dCamera_c::radiusActorInSight(fopAc_ac_c* i_actor1, fopAc_ac_c* i_actor2, cX
int bVar2 = 0;
var_f29 = std::fabsf(cM_atan2f(pos1.x, -pos1.z));
var_f28 = std::fabsf(cM_atan2f(pos1.y, -pos1.z));
var_f29 = fabsf(cM_atan2f(pos1.x, -pos1.z));
var_f28 = fabsf(cM_atan2f(pos1.y, -pos1.z));
if (var_f29 > sp30) {
bVar2 |= 1;
}
@@ -2459,8 +2468,8 @@ f32 dCamera_c::radiusActorInSight(fopAc_ac_c* i_actor1, fopAc_ac_c* i_actor2, cX
bVar2 |= 2;
}
var_f29 = std::fabsf(cM_atan2f(pos2.x, -pos2.z));
var_f28 = std::fabsf(cM_atan2f(pos2.y, -pos2.z));
var_f29 = fabsf(cM_atan2f(pos2.x, -pos2.z));
var_f28 = fabsf(cM_atan2f(pos2.y, -pos2.z));
if (var_f29 > sp30) {
bVar2 |= 4;
}
@@ -2485,25 +2494,25 @@ f32 dCamera_c::radiusActorInSight(fopAc_ac_c* i_actor1, fopAc_ac_c* i_actor2, cX
f32 var_f31;
if (bVar2 & 1) {
var_f31 = pos1.z + std::fabsf(pos1.x) / local_12c;
var_f31 = pos1.z + fabsf(pos1.x) / local_12c;
if (var_f31 > ret) {
ret = var_f31;
}
}
if (bVar2 & 2) {
var_f31 = pos1.z + std::fabsf(pos1.y) / local_130;
var_f31 = pos1.z + fabsf(pos1.y) / local_130;
if (var_f31 > ret) {
ret = var_f31;
}
}
if (bVar2 & 4) {
var_f31 = pos2.z + std::fabsf(pos2.x) / local_12c;
var_f31 = pos2.z + fabsf(pos2.x) / local_12c;
if (var_f31 > ret) {
ret = var_f31;
}
}
if (bVar2 & 8) {
var_f31 = pos2.z + std::fabsf(pos2.y) / local_130;
var_f31 = pos2.z + fabsf(pos2.y) / local_130;
if (var_f31 > ret) {
ret = var_f31;
}
@@ -2791,7 +2800,7 @@ bool dCamera_c::bumpCheck(u32 i_flags) {
}
wind_pow -= 0.3f;
cSAngle angle = wind_globe.U() - mViewCache.mDirection.U();
mFovy += mCamSetup.WindShakeGap4Fvy() * cM_rndFX(wind_pow / 0.7f) * (1.0f - std::fabsf(angle.Norm()));
mFovy += mCamSetup.WindShakeGap4Fvy() * cM_rndFX(wind_pow / 0.7f) * (1.0f - fabsf(angle.Norm()));
#if DEBUG
dDbVw_Report(300, 180, "wind %f %f", wind_pow, angle.Norm());
@@ -2935,7 +2944,7 @@ bool dCamera_c::bumpCheck(u32 i_flags) {
cXyz cross;
f32 dot = VECDotProduct(normal1, normal2);
VECCrossProduct(normal1, normal2, &cross);
if (chkCornerCos(dot) && std::fabsf(cross.y) > 0.5f
if (chkCornerCos(dot) && fabsf(cross.y) > 0.5f
&& cBgW_CheckBWall(normal2->y)) {
var_r27 = 5;
} else {
@@ -3048,7 +3057,7 @@ bool dCamera_c::bumpCheck(u32 i_flags) {
field_0x96c += (1.0f - field_0x96c) * 0.1f;
}
if (sp0C || !(mMonitor.field_0xc < 5.0f)
|| !(std::fabsf(mPadInfo.mCStick.mLastPosX) < 0.05f)) {
|| !(fabsf(mPadInfo.mCStick.mLastPosX) < 0.05f)) {
field_0x968 = 0.2f;
} else {
field_0x968 *= mMonitor.field_0xc / 5.0f;
@@ -3991,7 +4000,7 @@ bool dCamera_c::chaseCamera(s32 param_0) {
}
cSAngle ang;
if ((chkFlag(0x100000) || sp1C || bVar6) && std::fabsf(mPadInfo.mCStick.mLastPosX) < 0.05f) {
if ((chkFlag(0x100000) || sp1C || bVar6) && fabsf(mPadInfo.mCStick.mLastPosX) < 0.05f) {
ang.Val(directionOf(mpPlayerActor).Inv());
} else {
ang.Val(mViewCache.mDirection.U());
@@ -4006,13 +4015,13 @@ bool dCamera_c::chaseCamera(s32 param_0) {
pos3 = pos;
pos.y += dist;
sp1AC = cXyz(mCenter - pos3).abs() * 8.0f;
sp1BC = std::fabsf(dist1 > sp1AC ? dist1 : sp1AC);
sp1BC = fabsf(dist1 > sp1AC ? dist1 : sp1AC);
dist1 = val18 + (val17 - val18) * chase->field_0xa4;
sp1AC = std::fabsf(mFovy - dist1);
sp1AC = fabsf(mFovy - dist1);
f32 sin = cSAngle(mFovy > dist1 ? mFovy : dist1).Sin();
sp1AC = 100.0f * (sin * sin) * sp1AC;
sp1BC = std::fabsf(sp1BC > sp1AC ? sp1BC : sp1AC);
sp1BC = fabsf(sp1BC > sp1AC ? sp1BC : sp1AC);
sp1BC *= 1.2f;
sp1BC *= 0.00625f;
chase->field_0x4 = (int)(JMAFastSqrt(sp1BC) * 2.2f) + 1;
@@ -4120,7 +4129,7 @@ bool dCamera_c::chaseCamera(s32 param_0) {
mViewCache.mCenter += (pos - mViewCache.mCenter) * rate;
f32 dist = dCamMath::xyzHorizontalDistance(pos, chase->field_0x58);
if (dist < std::fabsf(vec.x > vec.z ? vec.x : vec.z) + 20.0f) {
if (dist < fabsf(vec.x > vec.z ? vec.x : vec.z) + 20.0f) {
cXyz attention_pos = attentionPos(mpPlayerActor);
attention_pos.y -= 15.0f;
dBgS_CamLinChk lin_chk;
@@ -4286,7 +4295,7 @@ bool dCamera_c::chaseCamera(s32 param_0) {
cSAngle ang = -mViewCache.mDirection.U();
delta = dCamMath::xyzRotateY(delta, ang);
cXyz vec5 = delta;
if (std::fabsf(vec5.y) < 200.0f) {
if (fabsf(vec5.y) < 200.0f) {
vec5.y = 0.0f;
vec5.x *= 0.5f;
f32 sp16C = vec5.abs();
@@ -4407,17 +4416,17 @@ bool dCamera_c::chaseCamera(s32 param_0) {
bool sp11 = false;
f32 sp140 = 0.05f;
f32 last_pos_x = mPadInfo.mCStick.mLastPosX;
f32 sp138 = std::fabsf(last_pos_x);
f32 sp138 = fabsf(last_pos_x);
f32 sp134 = mPadInfo.mCStick.mLastPosY;
f32 sp130 = std::fabsf(sp134);
f32 sp130 = fabsf(sp134);
f32 sp12C = 8.0f;
f32 sp128 = 12.0f;
chase->field_0x93 = false;
if (sp11 || (!mCamParam.Flag(param_0, 0x40) && std::fabsf(last_pos_x) > sp140)) {
if (sp11 || (!mCamParam.Flag(param_0, 0x40) && fabsf(last_pos_x) > sp140)) {
chase->field_0xac += (dCamMath::rationalBezierRatio(last_pos_x, 0.5f) * sp12C - chase->field_0xac) * chase->field_0x4c;
ang3 = globe.U() + cSAngle(chase->field_0xac);
sp148 = std::fabsf(last_pos_x) - 0.05f;
sp148 = fabsf(last_pos_x) - 0.05f;
if (mCamSetup.CheckFlag(0x1000) && mFakeAngleSys.field_0x0 == 0) {
setUSOAngle();
}
@@ -4914,7 +4923,7 @@ bool dCamera_c::lockonCamera(s32 param_0) {
sp0C = true;
}
f32 fVar43 = 1.0f - std::fabsf(mPadInfo.mCStick.mLastPosY);
f32 fVar43 = 1.0f - fabsf(mPadInfo.mCStick.mLastPosY);
f32 fVar44;
if (bVar1) {
@@ -4973,12 +4982,12 @@ bool dCamera_c::lockonCamera(s32 param_0) {
cSAngle u, v;
cSAngle ang5 = globe.V() - lockon->field_0x34.V();
if (sp0C) {
r = lockon->field_0x34.R() * 0.75f * std::fabsf(ang5.Cos());
r = lockon->field_0x34.R() * 0.75f * fabsf(ang5.Cos());
u.Val(lockon->field_0x34.U() + (ang4 - lockon->field_0x34.U()) * lockon->field_0x58);
v.Val(lockon->field_0x34.V() + ang5 * 0.05f);
} else {
r = lockon->field_0x34.R() + (sp184 - lockon->field_0x34.R()) *
lockon->field_0x54 * std::fabsf(ang5.Cos());
lockon->field_0x54 * fabsf(ang5.Cos());
u.Val(lockon->field_0x34.U() + (ang4 - lockon->field_0x34.U()) * lockon->field_0x58);
v.Val(lockon->field_0x34.V() + ang5 * lockon->field_0x58);
}
@@ -5014,7 +5023,11 @@ bool dCamera_c::lockonCamera(s32 param_0) {
f32 sp160;
cSAngle ang6 = ang3 - ang2;
curveWeight = mCamSetup.CurveWeight();
#if AVOID_UB
f32 sp15C = 0.0f;
#else
f32 sp15C;
#endif
f32 sp158 = mPadInfo.mCStick.mLastPosX;
if (mCamParam.Flag(param_0, 0x40)) {
sp158 = 0.0f;
@@ -5031,9 +5044,9 @@ bool dCamera_c::lockonCamera(s32 param_0) {
}
bool bVar3 = false;
if (std::fabsf(sp158) > 0.05f) {
if (fabsf(sp158) > 0.05f) {
cSAngle ang = globe2.U() + cSAngle(dCamMath::rationalBezierRatio(sp158, 0.5f) * 7.5f);
sp15C = std::fabsf(sp158) - 0.05f;
sp15C = fabsf(sp158) - 0.05f;
lockon->field_0x42 = ang;
lockon->field_0x4c = 0.0f;
bVar3 = true;
@@ -5097,7 +5110,7 @@ bool dCamera_c::lockonCamera(s32 param_0) {
}
ang6 = ang1.Inv() - mViewCache.mDirection.U();
if (std::fabsf(ang6.Degree()) < 2.0f && false) {
if (fabsf(ang6.Degree()) < 2.0f && false) {
lockon->field_0x2a = true;
}
u2 += ang6 * sp15C * lockon->field_0x4c;
@@ -5125,7 +5138,7 @@ bool dCamera_c::lockonCamera(s32 param_0) {
} else {
lockon->field_0xc = 0;
if (!mBG.field_0xc0.field_0x44 && !bVar1) {
v2 += (globe2.V() - v2) * fVar43 * std::fabsf(mViewCache.mDirection.V().Cos());
v2 += (globe2.V() - v2) * fVar43 * fabsf(mViewCache.mDirection.V().Cos());
} else {
cSAngle ang7 = lockon->field_0x34.V();
ang7 *= cSAngle(lockon->field_0x34.U() - mViewCache.mDirection.U()).Cos();
@@ -5457,7 +5470,7 @@ bool dCamera_c::talktoCamera(s32 param_0) {
if (talk->field_0x84 != 0) {
talk->field_0x48 = 1;
} else {
talk->field_0x48 = (int)(JMAFastSqrt(std::fabsf(mViewCache.mDirection.R() - talk->field_0x28.R())) / 2.0f);
talk->field_0x48 = (int)(JMAFastSqrt(fabsf(mViewCache.mDirection.R() - talk->field_0x28.R())) / 2.0f);
if (talk->field_0x48 < 2) {
talk->field_0x48 = 2;
}
@@ -5597,7 +5610,7 @@ bool dCamera_c::talktoCamera(s32 param_0) {
for (i = 0; i < 36; i++) {
sp26C = talk->field_0x28.U() - talk->field_0x30.U();
if (std::fabsf(sp26C.Degree()) < 10.0f) {
if (fabsf(sp26C.Degree()) < 10.0f) {
talk->field_0x28.U(talk->field_0x28.U() + sp270);
} else {
if (!sp5B) {
@@ -7160,7 +7173,7 @@ bool dCamera_c::subjectCamera(s32 param_0) {
f32 zoom_fovy = dCamMath::zoomFovy(val17 * 0.5f, tmp2) * 2.0f;
mViewCache.mFovy += (zoom_fovy - mViewCache.mFovy) * val22;
setComZoomScale(tmp2);
setComZoomForcus(1.0f - std::fabsf(sp88 - sp84) * -511.0f);
setComZoomForcus(1.0f - fabsf(sp88 - sp84) * -511.0f);
if (check_owner_action(mPadID, 0x200000)) {
setComStat(8);
}
@@ -7251,12 +7264,12 @@ bool dCamera_c::magneCamera(s32 param_0) {
cSAngle stack_238;
if (mCurMode == 1) {
stack_238 = sp54.Inv();
} else if (std::fabsf(cstick_x) > 0.05f) {
} else if (fabsf(cstick_x) > 0.05f) {
stack_238 = magne->field_0x1c.U() + cSAngle(dCamMath::rationalBezierRatio(cstick_x, 0.5f) * 10.0f);
} else {
cSAngle stack_23c = sp54.Inv() - stack_230.U();
f32 sin = stack_23c.Sin();
f32 tmp = std::fabsf(sin * mPadInfo.mMainStick.mLastValue);
f32 tmp = fabsf(sin * mPadInfo.mMainStick.mLastValue);
f32 tmp2 = stack_23c.Cos() > 0.0f ? 8.0f : 4.0f;
stack_238 = stack_230.U() + cSAngle(sin * tmp2 * dCamMath::rationalBezierRatio(tmp, 1.0f));
}
@@ -7572,7 +7585,7 @@ bool dCamera_c::towerCamera(s32 param_0) {
cXyz stack_21c = relationalPos(mpPlayerActor, &stack_210);
f32 sp1A8 = cXyz(mEye - stack_21c).abs() - val7;
f32 sp1A4 = cXyz(mCenter - stack_21c).abs() - val7;
f32 sp1A0 = std::fabsf(sp1A8 > sp1A4 ? sp1A8 : sp1A4);
f32 sp1A0 = fabsf(sp1A8 > sp1A4 ? sp1A8 : sp1A4);
sp1A8 = heightOf(mpPlayerActor);
sp1A0 /= (sp1A8 < 10.0f ? 10.0f : sp1A8);
tower->field_0x4 = (int)(JMAFastSqrt(sp1A0) * sp220) + 1;
@@ -7694,9 +7707,9 @@ bool dCamera_c::towerCamera(s32 param_0) {
cSAngle sp108;
cSAngle sp104 = stack_454 + (stack_454 - stack_458) * sp188;
if (!mCamParam.Flag(param_0, 0x40) && std::fabsf(sp18C) > sp184) {
if (!mCamParam.Flag(param_0, 0x40) && fabsf(sp18C) > sp184) {
cSAngle sp100 = mViewCache.mDirection.U() + cSAngle(dCamMath::rationalBezierRatio(sp18C, 0.5f) * sp180);
f32 sp17C = std::fabsf(sp18C) - sp184;
f32 sp17C = fabsf(sp18C) - sp184;
sp108.Val(mViewCache.mDirection.U() + (sp100 - mViewCache.mDirection.U()) * sp17C);
tower->field_0x6a = true;
tower->field_0x78 += (0.8f - tower->field_0x78) * 0.05f;
@@ -11018,16 +11031,20 @@ static int camera_draw(camera_process_class* i_this) {
int trim_height = body->TrimHeight();
#if TARGET_PC
#if TARGET_PC
trim_height *= viewport->height / FB_HEIGHT;
window->setScissor(0.0f, trim_height, viewport->width, viewport->height - trim_height * 2.0f);
#else
#else
window->setScissor(0.0f, trim_height, FB_WIDTH, FB_HEIGHT - trim_height * 2.0f);
#endif
#endif
C_MTXPerspective(process->view.projMtx, process->view.fovy, process->view.aspect, process->view.near_, process->view.far_);
mDoMtx_lookAt(process->view.viewMtx, &process->view.lookat.eye, &process->view.lookat.center,
&process->view.lookat.up, process->view.bank);
#ifdef TARGET_PC
dusk::frame_interp::record_final_mtx_raw(reinterpret_cast<const Mtx*>(process->view.viewMtx),
process->view.viewMtx);
#endif
#if WIDESCREEN_SUPPORT
mDoGph_gInf_c::setWideZoomProjection(process->view.projMtx);
+1 -1
View File
@@ -1018,7 +1018,7 @@ bool dComIfG_inf_c::baseCsr_c::navi_c::draw(f32 param_1, f32 param_2, u8 param_3
f32 f27 = f31 - field_0x5c;
field_0x58 = f29;
field_0x5c = f31;
cXyz spdc(param_1 - 304.0f, param_2 - 224.0f, 0.0f);
cXyz spdc(param_1 - FB_WIDTH_BASE / 2, param_2 - FB_HEIGHT_BASE / 2, 0.0f);
f32 target = param_3 != 0 ? 1.5f : 0.0f;
+76 -8
View File
@@ -10,7 +10,13 @@
#include "SSystem/SComponent/c_math.h"
#include "d/d_com_inf_game.h"
#include "d/d_drawlist.h"
#include <typeindex>
#include "absl/container/flat_hash_map.h"
#include "client/TracyScoped.hpp"
#include "d/d_s_play.h"
#include "dusk/frame_interpolation.h"
#include "dusk/gx_helper.h"
#include "dusk/logging.h"
#include "m_Do/m_Do_graphic.h"
@@ -1089,7 +1095,16 @@ void dDlst_shadowReal_c::draw() {
GXSetVtxDesc(GX_VA_POS, GX_DIRECT);
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0);
GXSetCurrentMtx(GX_PNMTX0);
GXLoadTexMtxImm(mReceiverProjMtx, GX_TEXMTX0, GX_MTX3x4);
#ifdef TARGET_PC
Mtx receiver_proj_mtx;
if (dusk::frame_interp::lookup_replacement(&mReceiverProjMtx, receiver_proj_mtx)) {
GXLoadTexMtxImm(receiver_proj_mtx, GX_TEXMTX0, GX_MTX3x4);
} else {
#endif
GXLoadTexMtxImm(mReceiverProjMtx, GX_TEXMTX0, GX_MTX3x4);
#ifdef TARGET_PC
}
#endif
mShadowRealPoly.draw();
}
@@ -1247,6 +1262,10 @@ u8 dDlst_shadowReal_c::setShadowRealMtx(cXyz* param_0, cXyz* param_1, f32 param_
C_MTXOrtho(mRenderProjMtx, param_2, -param_2, -param_2, param_2, 1.0f, 10000.0f);
C_MTXLightOrtho(mReceiverProjMtx, param_2, -param_2, -param_2, param_2, 0.5f, -0.5f, 0.5f, 0.5f);
cMtx_concat(mReceiverProjMtx, mViewMtx, mReceiverProjMtx);
#ifdef TARGET_PC
dusk::frame_interp::record_final_mtx_raw(&mViewMtx, mViewMtx);
dusk::frame_interp::record_final_mtx_raw(&mReceiverProjMtx, mReceiverProjMtx);
#endif
return r29;
}
@@ -1309,13 +1328,31 @@ void dDlst_shadowSimple_c::draw() {
GXSetTevColor(GX_TEVREG0, l_color);
GXClearVtxDesc();
GXSetVtxDesc(GX_VA_POS, GX_INDEX8);
GXLoadPosMtxImm(mVolumeMtx, GX_PNMTX0);
#ifdef TARGET_PC
Mtx volume_mtx;
if (dusk::frame_interp::lookup_replacement(&mVolumeMtx, volume_mtx)) {
GXLoadPosMtxImm(volume_mtx, GX_PNMTX0);
} else {
#endif
GXLoadPosMtxImm(mVolumeMtx, GX_PNMTX0);
#ifdef TARGET_PC
}
#endif
GXSetCurrentMtx(GX_PNMTX0);
GXCallDisplayList(l_frontMat, 0x40);
GXCallDisplayList(l_shadowVolumeDL, 0x40);
GXCallDisplayList(l_backSubMat, 0x20);
GXCallDisplayList(l_shadowVolumeDL, 0x40);
GXLoadPosMtxImm(mMtx, GX_PNMTX1);
#ifdef TARGET_PC
Mtx shadow_mtx;
if (dusk::frame_interp::lookup_replacement(&mMtx, shadow_mtx)) {
GXLoadPosMtxImm(shadow_mtx, GX_PNMTX1);
} else {
#endif
GXLoadPosMtxImm(mMtx, GX_PNMTX1);
#ifdef TARGET_PC
}
#endif
GXSetCurrentMtx(GX_PNMTX1);
if (mpTexObj != NULL) {
@@ -1394,6 +1431,10 @@ void dDlst_shadowSimple_c::set(cXyz* param_0, f32 param_1, f32 param_2, cXyz* pa
mDoMtx_stack_c::YrotM(param_4);
mDoMtx_stack_c::scaleM(param_2, 1.0f, param_2 * param_5);
cMtx_concat(j3dSys.getViewMtx(), mDoMtx_stack_c::get(), mMtx);
#ifdef TARGET_PC
dusk::frame_interp::record_final_mtx_raw(&mVolumeMtx, mVolumeMtx);
dusk::frame_interp::record_final_mtx_raw(&mMtx, mMtx);
#endif
mpTexObj = param_6;
}
@@ -1541,7 +1582,16 @@ void dDlst_shadowControl_c::draw(Mtx param_0) {
GXSetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX3x4, GX_TG_POS, GX_TEXMTX0);
GXSetNumTevStages(1);
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0);
GXLoadPosMtxImm(param_0, GX_PNMTX0);
#ifdef TARGET_PC
Mtx draw_mtx;
if (dusk::frame_interp::lookup_replacement(param_0, draw_mtx)) {
GXLoadPosMtxImm(draw_mtx, GX_PNMTX0);
} else {
#endif
GXLoadPosMtxImm(param_0, GX_PNMTX0);
#ifdef TARGET_PC
}
#endif
GXColor matColor = {0, 0, 0, 0x20};
GXSetChanMatColor(GX_ALPHA0, matColor);
@@ -1878,14 +1928,32 @@ int dDlst_list_c::set(dDlst_base_c**& p_start, dDlst_base_c**& p_end, dDlst_base
return 1;
}
#if TARGET_PC && (TRACY_ENABLE || PARTIAL_DEBUG)
static absl::flat_hash_map<std::type_index, const char*> typeDrawNames;
static const char* getTypeDrawName(dDlst_base_c* dlst) {
const auto& info = typeid(*dlst);
auto& elem = typeDrawNames[info];
if (elem) [[likely]] {
return elem;
}
const auto size = snprintf(nullptr, 0, "%s::draw()", info.name());
// Note: pointer is intentionally never freed, Tracy needs it.
const auto buf = static_cast<char*>(malloc(size+1));
snprintf(buf, size+1, "%s::draw()", info.name());
elem = buf;
return buf;
}
#endif
void dDlst_list_c::draw(dDlst_base_c** p_start, dDlst_base_c** p_end) {
for (; p_start < p_end; p_start++) {
dDlst_base_c* dlst = *p_start;
#if DEBUG && TARGET_PC
char buf[64];
snprintf(buf, sizeof(buf), "%s::draw()", typeid(dlst).name());
GXScopedDebugGroup scope(buf);
#if TARGET_PC && (TRACY_ENABLE || PARTIAL_DEBUG)
const auto name = getTypeDrawName(dlst);
GXScopedDebugGroup scope(name);
#endif
dlst->draw();
}
+1 -1
View File
@@ -5585,7 +5585,7 @@ void dFile_select3D_c::toItem3Dpos(f32 param_0, f32 param_1, f32 param_2, cXyz*
Mtx adStack_98;
Mtx auStack_c8;
param_0 = (2.0f * ((param_0 - mDoGph_gInf_c::getMinXF()) / mDoGph_gInf_c::getWidthF()) - 1.0f);
param_1 = (2.0f * ((param_1 - -100.0f) / 448.0f) - 1.0f);
param_1 = (2.0f * ((param_1 - -100.0f) / FB_HEIGHT_BASE) - 1.0f);
calcViewMtx(adStack_98);
cMtx_inverse(adStack_98, auStack_c8);
f32 tangent = std::tan(M_PI / 8.0f);
+2 -1
View File
@@ -1,11 +1,12 @@
#include "d/d_jcam_editor.h"
#include "m_Do/m_Do_graphic.h"
#include "m_Do/m_Do_hostIO.h"
#include "m_Do/m_Do_ext.h"
dJcame_c* dJcame_c::m_myObj;
dJcame_c::dJcame_c(const JStage::TSystem* i_system, f32 param_1, JUTGamePad& i_pad) {
mOrthoGraph = JKR_NEW J2DOrthoGraph(0.0f, 0.0f, 608.0f, 448.0f, -1.0f, 1.0f);
mOrthoGraph = JKR_NEW J2DOrthoGraph(0.0f, 0.0f, FB_WIDTH_BASE, FB_HEIGHT_BASE, -1.0f, 1.0f);
mFont = JKR_NEW JUTResFont((ResFONT*)JUTResFONT_Ascfont_fix12, NULL);
mHeap = JKRExpHeap::create(0x100000, JKRHeap::getRootHeap2(), false);
+2 -2
View File
@@ -10994,9 +10994,9 @@ void dKy_depth_dist_set(void* process_p) {
if ((sp30.x >= 0.0f && sp30.x < FB_WIDTH) && (sp30.y >= 0.0f &&
#if DEBUG
sp30.y < 608.0f
sp30.y < FB_WIDTH_BASE
#else
sp30.y < 600.0f
sp30.y < (FB_WIDTH_BASE - 8)
#endif
)) {
cXyz sp18;
+53 -4
View File
@@ -4041,6 +4041,7 @@ void dKyr_drawSnow(Mtx drawMtx, u8** tex) {
}
void dKyr_drawStar(Mtx drawMtx, u8** tex) {
ZoneScoped;
dScnKy_env_light_c* envlight = dKy_getEnvlight();
dKankyo_star_Packet* star_packet = g_env_light.mpStarPacket;
camera_class* camera = (camera_class*)dComIfGp_getCamera(0);
@@ -4085,6 +4086,8 @@ void dKyr_drawStar(Mtx drawMtx, u8** tex) {
#endif
if (star_packet->mEffectNum != 0) {
IF_DUSK(GXPushDebugGroup("dKyr_drawStar"));
if (strcmp(dComIfGp_getStartStageName(), "F_SP200") == 0 && dComIfG_play_c::getLayerNo(0) == 0) {
gwolf_howl_stage = true;
} else if (strcmp(dComIfGp_getStartStageName(), "F_SP127") == 0 ||
@@ -4127,23 +4130,27 @@ void dKyr_drawStar(Mtx drawMtx, u8** tex) {
mDoLib_project(&moon_pos, &moon_proj);
#endif
// Dusk optimization: we use vertex color rather than GX_TEVREG0 to set star color.
// This allows us to merge all the stars into a single draw.
GXSetNumChans(1);
GXSetChanCtrl(GX_COLOR0, GX_DISABLE, GX_SRC_REG, GX_SRC_REG, GX_LIGHT_NULL, GX_DF_CLAMP, GX_AF_NONE);
GXSetChanCtrl(GX_COLOR0, GX_DISABLE, GX_SRC_REG, DUSK_IF_ELSE(GX_SRC_VTX, GX_SRC_REG), GX_LIGHT_NULL, GX_DF_CLAMP, GX_AF_NONE);
GXSetNumTexGens(0);
GXSetNumTevStages(1);
GXSetTevColor(GX_TEVREG0, color_reg0);
GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR0A0);
GXSetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO, GX_CC_C0);
GXSetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO, DUSK_IF_ELSE(GX_CC_RASC, GX_CC_C0));
GXSetTevColorOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV);
GXSetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_A0);
GXSetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, DUSK_IF_ELSE(GX_CA_RASA, GX_CA_A0));
GXSetTevAlphaOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV);
GXSetZMode(GX_ENABLE, GX_LEQUAL, GX_DISABLE);
GXSetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR);
GXSetAlphaCompare(GX_GREATER, 0, GX_AOP_OR, GX_GREATER, 0);
GXSetNumIndStages(0);
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_CLR_RGBA, GX_F32, 0);
IF_DUSK(GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBA8, 0));
GXClearVtxDesc();
GXSetVtxDesc(GX_VA_POS, GX_DIRECT);
IF_DUSK(GXSetVtxDesc(GX_VA_CLR0, GX_DIRECT));
Mtx rotMtx;
MTXRotRad(rotMtx, 'Z', DEG_TO_RAD(rot));
@@ -4203,6 +4210,15 @@ void dKyr_drawStar(Mtx drawMtx, u8** tex) {
int sp44 = 0;
f32 var_f28 = 0.0f;
#if TARGET_PC
// Dusk optimization: we submit a single large draw call, rather than a thousand.
u32 vertCount = 3 * star_packet->mEffectNum;
if (draw_mirrored) {
vertCount *= 2;
}
GXBegin(GX_TRIANGLES, GX_VTXFMT0, vertCount);
#endif
for (int i = 0; i < star_packet->mEffectNum; i++) {
f32 var_f31;
cXyz star_pos;
@@ -4253,7 +4269,7 @@ void dKyr_drawStar(Mtx drawMtx, u8** tex) {
color_reg0.a = 70.0f + ((i & 63) * 2);
}
GXSetTevColor(GX_TEVREG0, color_reg0);
IF_NOT_DUSK(GXSetTevColor(GX_TEVREG0, color_reg0));
cXyz sp68;
cXyz sp5C;
@@ -4294,6 +4310,33 @@ void dKyr_drawStar(Mtx drawMtx, u8** tex) {
}
// if a star is too close to the moon then avoid drawing
#if TARGET_PC
// Dusk optimization change: since we submit one large draw, we don't know the count of moon-hidden stars in advance.
// So, just set those to have zero alpha.
if (moon_dist_to_star <= moon_threshold) {
color_reg0.a = 0;
}
GXPosition3f32(sp68.x + (var_f31 * (pos[0].x - spBC.x)), sp68.y + (var_f31 * (pos[0].y - spBC.y)), sp68.z + (var_f31 * (pos[0].z - spBC.z)));
GXColor4u8(color_reg0.r, color_reg0.g, color_reg0.b, color_reg0.a);
GXPosition3f32(sp68.x + (var_f31 * (pos[1].x - spBC.x)), sp68.y + (var_f31 * (pos[1].y - spBC.y)), sp68.z + (var_f31 * (pos[1].z - spBC.z)));
GXColor4u8(color_reg0.r, color_reg0.g, color_reg0.b, color_reg0.a);
GXPosition3f32(sp68.x + (var_f31 * (pos[2].x - spBC.x)), sp68.y + (var_f31 * (pos[2].y - spBC.y)), sp68.z + (var_f31 * (pos[2].z - spBC.z)));
GXColor4u8(color_reg0.r, color_reg0.g, color_reg0.b, color_reg0.a);
if (draw_mirrored) {
sp5C.x = spBC.x + star_pos.x;
sp5C.y = spBC.y - star_pos.y;
sp5C.z = spBC.z + star_pos.z;
GXPosition3f32(sp5C.x + (var_f31 * (pos[0].x - spBC.x)), sp5C.y + (var_f31 * (pos[0].y - spBC.y)), sp5C.z + (var_f31 * (pos[0].z - spBC.z)));
GXColor4u8(color_reg0.r, color_reg0.g, color_reg0.b, color_reg0.a);
GXPosition3f32(sp5C.x + (var_f31 * (pos[1].x - spBC.x)), sp5C.y + (var_f31 * (pos[1].y - spBC.y)), sp5C.z + (var_f31 * (pos[1].z - spBC.z)));
GXColor4u8(color_reg0.r, color_reg0.g, color_reg0.b, color_reg0.a);
GXPosition3f32(sp5C.x + (var_f31 * (pos[2].x - spBC.x)), sp5C.y + (var_f31 * (pos[2].y - spBC.y)), sp5C.z + (var_f31 * (pos[2].z - spBC.z)));
GXColor4u8(color_reg0.r, color_reg0.g, color_reg0.b, color_reg0.a);
}
#else
if (moon_dist_to_star > moon_threshold) {
GXBegin(GX_TRIANGLES, GX_VTXFMT0, 3);
GXPosition3f32(sp68.x + (var_f31 * (pos[0].x - spBC.x)), sp68.y + (var_f31 * (pos[0].y - spBC.y)), sp68.z + (var_f31 * (pos[0].z - spBC.z)));
@@ -4313,8 +4356,14 @@ void dKyr_drawStar(Mtx drawMtx, u8** tex) {
GXEnd();
}
}
#endif
}
#if TARGET_PC
GXEnd();
GXPopDebugGroup();
#endif
J3DShape::resetVcdVatCache();
}
}
+10
View File
@@ -539,9 +539,19 @@ void renderingAmap_c::rendering(dDrawPath_c::poly_class const* i_poly) {
}
}
/* Enabling the following definition will modify the following function to
* make the map look worse for extra speed in the emulator, especially in large
* areas such as hyrule field.
*/
#define HYRULE_FIELD_SPEEDHACK
bool renderingAmap_c::isDrawOutSideTrim() {
bool rt = false;
#ifdef HYRULE_FIELD_SPEEDHACK
return 0;
#endif
if (getDispType() == 0 || getDispType() == 4 || getDispType() == 3 || getDispType() == 2 ||
getDispType() == 5)
{
+1 -1
View File
@@ -2708,7 +2708,7 @@ void dMenu_Collect3D_c::toItem3Dpos(f32 param_0, f32 param_1, f32 param_2, cXyz*
Mtx auStack_c8;
param_0 =
(2.0f * ((param_0 - mDoGph_gInf_c::getMinXF()) / mDoGph_gInf_c::getWidthF()) - 1.0f);
param_1 = (2.0f * ((param_1 - -100.0f) / 448.0f) - 1.0f);
param_1 = (2.0f * ((param_1 - -100.0f) / FB_HEIGHT_BASE) - 1.0f);
calcViewMtx(adStack_98);
MTXInverse(adStack_98, auStack_c8);
f32 tangent = tan(0.39269909262657166);
+12 -12
View File
@@ -229,17 +229,17 @@ dMenu_Fmap_c::dMenu_Fmap_c(JKRExpHeap* i_heap, STControl* i_stick, CSTControl* i
}
if (i_panDirection == 1) {
mTransX = -608.0f;
mTransX = -FB_WIDTH_BASE;
mTransY = 0.0f;
} else if (i_panDirection == 3) {
mTransX = 608.0f;
mTransX = FB_WIDTH_BASE;
mTransY = 0.0f;
} else if (i_panDirection == 2) {
mTransX = 0.0f;
mTransY = -448.0f;
mTransY = -FB_HEIGHT_BASE;
} else if (i_panDirection == 0) {
mTransX = 0.0f;
mTransY = 448.0f;
mTransY = FB_HEIGHT_BASE;
} else {
mTransX = 0.0f;
mTransY = 0.0f;
@@ -1705,17 +1705,17 @@ bool dMenu_Fmap_c::isOpen() {
f32 ratio = (f32)mDisplayFrame / (f32)display_frame_num;
if (mPanDirection == 1) {
mTransX = (1.0f - ratio) * -608.0f;
mTransX = (1.0f - ratio) * -FB_WIDTH_BASE;
mTransY = 0.0f;
} else if (mPanDirection == 3) {
mTransX = (1.0f - ratio) * 608.0f;
mTransX = (1.0f - ratio) * FB_WIDTH_BASE;
mTransY = 0.0f;
} else if (mPanDirection == 2) {
mTransX = 0.0f;
mTransY = (1.0f - ratio) * -448.0f;
mTransY = (1.0f - ratio) * -FB_HEIGHT_BASE;
} else if (mPanDirection == 0) {
mTransX = 0.0f;
mTransY = (1.0f - ratio) * 448.0f;
mTransY = (1.0f - ratio) * FB_HEIGHT_BASE;
}
mAlphaRatio = ratio;
@@ -1755,17 +1755,17 @@ bool dMenu_Fmap_c::isClose() {
}
if (mPanDirection == 1) {
mTransX = (1.0f - ratio) * 608.0f;
mTransX = (1.0f - ratio) * FB_WIDTH_BASE;
mTransY = 0.0f;
} else if (mPanDirection == 3) {
mTransX = (1.0f - ratio) * -608.0f;
mTransX = (1.0f - ratio) * -FB_WIDTH_BASE;
mTransY = 0.0f;
} else if (mPanDirection == 2) {
mTransX = 0.0f;
mTransY = (1.0f - ratio) * 448.0f;
mTransY = (1.0f - ratio) * FB_HEIGHT_BASE;
} else if (mPanDirection == 0) {
mTransX = 0.0f;
mTransY = (1.0f - ratio) * -448.0f;
mTransY = (1.0f - ratio) * -FB_HEIGHT_BASE;
}
mAlphaRatio = ratio;
+10 -3
View File
@@ -17,6 +17,7 @@
#include "d/d_msg_scrn_explain.h"
#include "m_Do/m_Do_graphic.h"
#include "d/actor/d_a_midna.h"
#include "dusk/frame_interpolation.h"
#include <cstring>
dMenu_Fmap2DBack_c::dMenu_Fmap2DBack_c() {
@@ -390,11 +391,17 @@ void dMenu_Fmap2DBack_c::draw() {
(mArrowPos3DZ + control_ypos + fVar3) - fVar5, &mArrowPos2DX,
&mArrowPos2DY);
field_0x11e0 -= g_fmapHIO.mCursorSpeed;
#ifdef TARGET_PC
for (u32 i = 0; i < dusk::frame_interp::get_presentation_ui_advance_ticks(); ++i) {
#endif
field_0x11e0 -= g_fmapHIO.mCursorSpeed;
if (field_0x11e0 < 0.0f) {
field_0x11e0 += 360.0f;
if (field_0x11e0 < 0.0f) {
field_0x11e0 += 360.0f;
}
#ifdef TARGET_PC
}
#endif
mpPointParent->getPanePtr()->rotate(mpPointParent->getSizeX() / 2.0f,
mpPointParent->getSizeY() / 2.0f, ROTATE_Z,
+3
View File
@@ -183,6 +183,9 @@ void dMenu_Insect_c::_draw() {
mpExpScreen->draw(0.0f, 0.0f, grafPort);
mpSelect_c->setOffsetX(g_drawHIO.mInsectListScreen.mConfirmOptionPosX_4x3);
// the magic numbers here are correlated with the framebuffer size, but
// were likely either chosen by hand or had multiple arithmetic
// operations applied which cannot easily be reverse engineered
mpSelect_c->translate(g_drawHIO.mInsectListScreen.mConfirmOptionPosX_4x3 + 486.0f,
g_drawHIO.mInsectListScreen.mConfirmOptionPosY_4x3 + 209.0f);
mpSelect_c->draw(0.0f, 0.0f);
+3
View File
@@ -330,6 +330,9 @@ void dMenu_ItemExplain_c::draw(J2DOrthoGraph* i_graph) {
mpInfoString->drawOutFontLocal((J2DTextBox*)mpInfoText->getPanePtr(), -1.0f);
drawKantera();
if (mpSelect_c != NULL) {
// the magic numbers here are correlated with the framebuffer size, but
// were likely either chosen by hand or had multiple arithmetic
// operations applied which cannot easily be reverse engineered
mpSelect_c->translate(486.0f, 209.0f);
mpSelect_c->draw(0.0f, 0.0f);
}
+18 -18
View File
@@ -87,16 +87,16 @@ dMenu_Ring_c::dMenu_Ring_c(JKRExpHeap* i_heap, STControl* i_stick, CSTControl* i
mPikariFlashingSpeed = 0.0f;
if (mRingOrigin == 0) {
mCenterPosX = 0.0f;
mCenterPosY = 448.0f;
mCenterPosY = FB_HEIGHT_BASE;
} else if (mRingOrigin == 2) {
mCenterPosX = 0.0f;
mCenterPosY = -448.0f;
mCenterPosY = -FB_HEIGHT_BASE;
}
if (mRingOrigin == 3) {
mCenterPosX = 608.0f;
mCenterPosX = FB_WIDTH_BASE;
mCenterPosY = 0.0f;
} else if (mRingOrigin == 1) {
mCenterPosX = -608.0f;
mCenterPosX = -FB_WIDTH_BASE;
mCenterPosY = 0.0f;
} else {
mCenterPosX = 0.0f;
@@ -644,15 +644,15 @@ bool dMenu_Ring_c::isOpen() {
mAlphaRate = (f32)mOpenCloseFrames / (f32)g_ringHIO.mOpenFrames;
if (mRingOrigin == 0) {
mCenterPosX = 0.0f;
mCenterPosY = (1.0f - mAlphaRate) * 448.0f;
mCenterPosY = (1.0f - mAlphaRate) * FB_HEIGHT_BASE;
} else if (mRingOrigin == 2) {
mCenterPosX = 0.0f;
mCenterPosY = (1.0f - mAlphaRate) * -448.0f;
mCenterPosY = (1.0f - mAlphaRate) * -FB_HEIGHT_BASE;
} else if (mRingOrigin == 3) {
mCenterPosX = (1.0f - mAlphaRate) * 608.0f;
mCenterPosX = (1.0f - mAlphaRate) * FB_WIDTH_BASE;
mCenterPosY = 0.0f;
} else if (mRingOrigin == 1) {
mCenterPosX = (1.0f - mAlphaRate) * -608.0f;
mCenterPosX = (1.0f - mAlphaRate) * -FB_WIDTH_BASE;
mCenterPosY = 0.0f;
}
if (mOpenCloseFrames >= g_ringHIO.mOpenFrames) {
@@ -715,15 +715,15 @@ bool dMenu_Ring_c::isClose() {
}
if (mRingOrigin == 0) {
mCenterPosX = 0.0f;
mCenterPosY = (1.0f - mAlphaRate) * -448.0f;
mCenterPosY = (1.0f - mAlphaRate) * -FB_HEIGHT_BASE;
} else if (mRingOrigin == 2) {
mCenterPosX = 0.0f;
mCenterPosY = (1.0f - mAlphaRate) * 448.0f;
mCenterPosY = (1.0f - mAlphaRate) * FB_HEIGHT_BASE;
} else if (mRingOrigin == 3) {
mCenterPosX = (1.0f - mAlphaRate) * -608.0f;
mCenterPosX = (1.0f - mAlphaRate) * -FB_WIDTH_BASE;
mCenterPosY = 0.0f;
} else if (mRingOrigin == 1) {
mCenterPosX = (1.0f - mAlphaRate) * 608.0f;
mCenterPosX = (1.0f - mAlphaRate) * FB_WIDTH_BASE;
mCenterPosY = 0.0f;
}
mpDrawCursor->setPos(mItemSlotPosX[mCurrentSlot] + mCenterPosX,
@@ -855,11 +855,11 @@ s16 dMenu_Ring_c::calcStickAngle(STControl* i_stick, u8 param_1) {
}
void dMenu_Ring_c::setRotate() {
clacEllipsePlotAverage(mItemsTotal, g_ringHIO.mItemRingPosX + 304.0f,
g_ringHIO.mItemRingPosY + 224.0f);
clacEllipsePlotAverage(mItemsTotal, g_ringHIO.mItemRingPosX + FB_WIDTH_BASE / 2,
g_ringHIO.mItemRingPosY + FB_HEIGHT_BASE / 2);
for (int i = 0; i < mItemsTotal; i++) {
field_0x63e[i] = cM_atan2s(mItemSlotPosX[i] - (304.0f + g_ringHIO.mItemRingPosX),
mItemSlotPosY[i] - (224.0f + g_ringHIO.mItemRingPosY));
field_0x63e[i] = cM_atan2s(mItemSlotPosX[i] - (FB_WIDTH_BASE / 2 + g_ringHIO.mItemRingPosX),
mItemSlotPosY[i] - (FB_HEIGHT_BASE / 2 + g_ringHIO.mItemRingPosY));
}
}
@@ -1446,9 +1446,9 @@ void dMenu_Ring_c::stick_move_proc() {
setStatus(field_0x6b2);
} else {
f32 itemRingPosX =
g_ringHIO.mItemRingPosX + 304.0f + mRingRadiusH * cM_ssin(field_0x66e);
g_ringHIO.mItemRingPosX + FB_WIDTH_BASE / 2 + mRingRadiusH * cM_ssin(field_0x66e);
f32 itemRingPosY =
g_ringHIO.mItemRingPosY + 224.0f + mRingRadiusV * cM_scos(field_0x66e);
g_ringHIO.mItemRingPosY + FB_HEIGHT_BASE / 2 + mRingRadiusV * cM_scos(field_0x66e);
mpDrawCursor->setPos(itemRingPosX, itemRingPosY);
}
}
+54 -34
View File
@@ -20,6 +20,7 @@
#include "d/d_msg_class.h"
#include "d/d_msg_object.h"
#include "d/d_pane_class.h"
#include "dusk/frame_interpolation.h"
#include <cstring>
dMeter2Draw_c::dMeter2Draw_c(JKRExpHeap* mp_heap) {
@@ -636,38 +637,49 @@ void dMeter2Draw_c::draw() {
if (field_0x756 >= 0) {
var_f29 = g_drawHIO.mLightDrop.mDropPikariAnimSpeed_Completed;
int temp_r5_2 = g_drawHIO.mLightDrop.mPikariInterval * 15;
#ifdef TARGET_PC
// Set even if not advancing
var_f28 = g_drawHIO.mLightDrop.mPikariScaleComplete;
if (field_0x756 <= temp_r5_2) {
int temp_r4 = (field_0x756 % g_drawHIO.mLightDrop.mPikariInterval);
int temp_r3_5 = field_0x756 / g_drawHIO.mLightDrop.mPikariInterval;
const u32 ui_advance_ticks = dusk::frame_interp::get_presentation_ui_advance_ticks();
for (u32 tick = 0; tick < ui_advance_ticks; ++tick) {
#endif
if (field_0x756 <= temp_r5_2) {
int temp_r4 = (field_0x756 % g_drawHIO.mLightDrop.mPikariInterval);
int temp_r3_5 = field_0x756 / g_drawHIO.mLightDrop.mPikariInterval;
if (temp_r4 == 0 && field_0x62c[temp_r3_5] == 0.0f) {
field_0x62c[temp_r3_5] = 18.0f;
}
var_f28 = g_drawHIO.mLightDrop.mPikariScaleComplete;
field_0x756++;
} else {
int temp_r5_3 = temp_r5_2 + 1;
if (field_0x756 == temp_r5_3) {
if (field_0x62c[15] == 0.0f) {
field_0x756++;
if (temp_r4 == 0 && field_0x62c[temp_r3_5] == 0.0f) {
field_0x62c[temp_r3_5] = 18.0f;
}
var_f28 = g_drawHIO.mLightDrop.mPikariScaleComplete;
} else if (field_0x756 >= g_drawHIO.mLightDrop.field_0x54 + temp_r5_3) {
for (int i = 0; i < 16; i++) {
field_0x62c[i] = 18.0f - var_f29;
field_0x66c[i] = 18.0f - g_drawHIO.mLightDrop.mPikariLoopAnimSpeed;
}
field_0x756 = -1;
} else {
field_0x756++;
} else {
int temp_r5_3 = temp_r5_2 + 1;
if (field_0x756 == temp_r5_3) {
if (field_0x62c[15] == 0.0f) {
field_0x756++;
}
var_f28 = g_drawHIO.mLightDrop.mPikariScaleComplete;
} else if (field_0x756 >= g_drawHIO.mLightDrop.field_0x54 + temp_r5_3) {
for (int i = 0; i < 16; i++) {
field_0x62c[i] = 18.0f - var_f29;
field_0x66c[i] = 18.0f - g_drawHIO.mLightDrop.mPikariLoopAnimSpeed;
}
field_0x756 = -1;
#ifdef TARGET_PC
break;
#endif
} else {
field_0x756++;
}
}
}
#ifdef TARGET_PC
}
#endif
for (int i = 0; i < 16; i++) {
if (field_0x66c[i] > 0.0f) {
@@ -1336,20 +1348,27 @@ void dMeter2Draw_c::drawPikari(f32 i_posX, f32 i_posY, f32* i_framep, f32 i_scal
if (param_9 != 3 && param_9 != 4 && param_9 != 5 && dMsgObject_isTalkNowCheck()) {
*i_framep = 0.0f;
} else {
*i_framep += param_8;
if (*i_framep > var_f31) {
if (param_9 == 1 || param_9 == 2 || param_9 == 3) {
*i_framep = 18.0f;
} else {
*i_framep = 0.0f;
#ifdef TARGET_PC
const u32 ui_advance_ticks = dusk::frame_interp::get_presentation_ui_advance_ticks();
for (u32 i = 0; i < ui_advance_ticks; ++i) {
#endif
*i_framep += param_8;
if (*i_framep > var_f31) {
if (param_9 == 1 || param_9 == 2 || param_9 == 3) {
*i_framep = 18.0f;
} else {
*i_framep = 0.0f;
}
}
}
if (*i_framep == 18.0f && param_9 == 1) {
mDoAud_seStart(Z2SE_NAVI_BLINK, NULL, 0, 0);
} else if (*i_framep == 18.0f && param_9 == 2) {
mDoAud_seStart(Z2SE_SY_ITEM_COMBINE_ICON, NULL, 0, 0);
if (*i_framep == 18.0f && param_9 == 1) {
mDoAud_seStart(Z2SE_NAVI_BLINK, NULL, 0, 0);
} else if (*i_framep == 18.0f && param_9 == 2) {
mDoAud_seStart(Z2SE_SY_ITEM_COMBINE_ICON, NULL, 0, 0);
}
#ifdef TARGET_PC
}
#endif
playPikariBckAnimation(*i_framep);
playPikariBpkAnimation(*i_framep);
@@ -1543,6 +1562,7 @@ void dMeter2Draw_c::setAlphaLifeAnimeMax() {
}
void dMeter2Draw_c::drawKanteraScreen(u8 i_meterType) {
GX_AND_TRACY_SCOPED("drawKanteraScreen");
J2DGrafContext* graf_ctx = dComIfGp_getCurrentGrafPort();
mpMagicParent->setAlphaRate(mMeterAlphaRate[i_meterType]);
+4 -4
View File
@@ -205,11 +205,11 @@ void dMeter2Info_c::init() {
unk_0x5c = 0.0f;
unk_0x60 = 1.0f;
unk_0x64 = 30.0f;
unk_0x68 = 304.0f;
unk_0x6c = 224.0f;
unk_0x68 = FB_WIDTH_BASE / 2;
unk_0x6c = FB_HEIGHT_BASE / 2;
m2DWidth = 608.0f;
m2DHeight = 448.0f;
m2DWidth = FB_WIDTH_BASE;
m2DHeight = FB_HEIGHT_BASE;
m2DPosH = 0.0f;
m2DPosV = 0.0f;
unk_0x80 = 0.0f;
+9 -9
View File
@@ -197,11 +197,11 @@ void dMeter_drawOptionHIO_c::genMessage(JORMContext* mctx) {
mctx->genSlider("位置X", &mOptionTypeBGPosX[3], -300.0f, 300.0f);
mctx->genSlider("位置Y", &mOptionTypeBGPosY[3], -300.0f, 300.0f);
mctx->genLabel("*****テレビ画面の設定*****", 0);
mctx->genSlider("位置X", &mTVsettingPosX, -300.0f, 300.0f);
mctx->genSlider("位置Y", &mTVsettingPosY, -300.0f, 300.0f);
mctx->genSlider("位置X", &mOptionTypeBGPosX[4], -300.0f, 300.0f);
mctx->genSlider("位置Y", &mOptionTypeBGPosY[4], -300.0f, 300.0f);
mctx->genLabel("*****キャリブレーション*****", 0);
mctx->genSlider("位置X", &mPointerCalibrationPosX, -300.0f, 300.0f);
mctx->genSlider("位置Y", &mPointerCalibrationPosY, -300.0f, 300.0f);
mctx->genSlider("位置X", &mOptionTypeBGPosX[5], -300.0f, 300.0f);
mctx->genSlider("位置Y", &mOptionTypeBGPosY[5], -300.0f, 300.0f);
mctx->genLabel("*****設定確認*****", 0);
mctx->genSlider("背景アルファ", &mBackgroundAlpha, 0, 255);
mctx->genSlider("位置Y", &mBackgroundPosY, -300.0f, 300.0f);
@@ -1493,7 +1493,7 @@ dMeter_drawLightDropHIO_c::dMeter_drawLightDropHIO_c() {
mPikariInterval = 1;
field_0x54 = 0xFFF1;
mVesselAlpha[2] = 0.5f;
mDropAlpha = 1.0f;
mVesselAlpha[3] = 1.0f;
mDropOnColorBlack.set(30, 255, 255, 0);
mDropOnColorWhite.set(255, 255, 255, 255);
@@ -1554,7 +1554,7 @@ void dMeter_drawLightDropHIO_c::genMessage(JORMContext* mctx) {
mctx->genSlider("位置調整Y(会話)", &mVesselTalkPosY, -300.0f, 300.0f);
mctx->genSlider("アルファ(会話)", &mVesselAlpha[1], 0.0f, 1.0f);
mctx->genSlider("アルファ(器)", &mVesselAlpha[2], 0.0f, 1.0f);
mctx->genSlider("アルファ(雫)", &mDropAlpha, 0.0f, 1.0f);
mctx->genSlider("アルファ(雫)", &mVesselAlpha[3], 0.0f, 1.0f);
mctx->genLabel("***光の器ゲット後***", 0);
mctx->genSlider("拡大縮小", &mDropGetScale, 0.0f, 3.0f);
mctx->genSlider("拡縮アニメフレーム数", &mDropGetScaleAnimFrameNum, 0, 30);
@@ -4010,9 +4010,9 @@ void dMeter_fmapHIO_c::genMessage(JORMContext* mctx) {
mctx->genSlider("リージョン拡大表示範囲", &mRegionZoomRange, 1000.0, 1000000.0);
mctx->genCheckBox("表示基準領域枠表示", (u8*)&mDisplayReferenceArea, 0x1);
mctx->genCheckBox("スクロール範囲を表示基準", (u8*)&field_0x308, 0x1);
mctx->genSlider("左上座標X", &mMapTopLeftPosX, 0.0, 608.0);
mctx->genSlider("左上座標Y", &mMapTopLeftPosY, 0.0, 448.0);
mctx->genSlider("領域幅", &mMapScale, 0.0, 608.0);
mctx->genSlider("左上座標X", &mMapTopLeftPosX, 0.0, FB_WIDTH_BASE);
mctx->genSlider("左上座標Y", &mMapTopLeftPosY, 0.0, FB_HEIGHT_BASE);
mctx->genSlider("領域幅", &mMapScale, 0.0, FB_WIDTH_BASE);
mctx->genLabel("\n*** スクロール速度境界 ***", 0);
mctx->genSlider("0~遅", &mScrollSpeedSlowBound, 0.0, 1.0);
mctx->genSlider("遅~速", &mScrollSpeedFastBound, 0.0, 1.0);
+1 -1
View File
@@ -1035,7 +1035,7 @@ void dMeterButton_c::screenInitButton() {
}
field_0x4b0 = 0;
mParentCenterX = (608.0f / 2) - mpParent->getInitCenterPosX();
mParentCenterX = (FB_WIDTH_BASE / 2.0f) - mpParent->getInitCenterPosX();
paneTrans(mpParent, mParentCenterX, 0.0f, 0xFF);
mpButtonA = JKR_NEW CPaneMgr(mpButtonScreen, MULTI_CHAR('abtn_n'), 2, NULL);
+6 -6
View File
@@ -99,28 +99,28 @@ void dMeterHaihai_c::draw() {
}
if (direction & DIR_DOWN_e || i_forceDraw) {
mpParent->getPanePtr()->translate(x_pos[0] + 304.0f, y_pos[0] + 224.0f);
mpParent->getPanePtr()->translate(x_pos[0] + FB_WIDTH_BASE / 2, y_pos[0] + FB_HEIGHT_BASE / 2);
mpParent->getPanePtr()->rotate(mpParent->getPanePtr()->getWidth() / 2,
mpParent->getPanePtr()->getHeight() / 2, ROTATE_Z, 0.0f);
mpHaihaiScreen->draw(0.0f, 0.0f, dComIfGp_getCurrentGrafPort());
}
if (direction & DIR_RIGHT_e || i_forceDraw) {
mpParent->getPanePtr()->translate(x_pos[1] + 304.0f, y_pos[1] + 224.0f);
mpParent->getPanePtr()->translate(x_pos[1] + FB_WIDTH_BASE / 2, y_pos[1] + FB_HEIGHT_BASE / 2);
mpParent->getPanePtr()->rotate(mpParent->getPanePtr()->getWidth() / 2,
mpParent->getPanePtr()->getHeight() / 2, ROTATE_Z, 90.0f);
mpHaihaiScreen->draw(0.0f, 0.0f, dComIfGp_getCurrentGrafPort());
}
if (direction & DIR_UP_e || i_forceDraw) {
mpParent->getPanePtr()->translate(x_pos[0] + 304.0f, 224.0f - y_pos[0]);
mpParent->getPanePtr()->translate(x_pos[0] + FB_WIDTH_BASE / 2, FB_HEIGHT_BASE / 2 - y_pos[0]);
mpParent->getPanePtr()->rotate(mpParent->getPanePtr()->getWidth() / 2,
mpParent->getPanePtr()->getHeight() / 2, ROTATE_Z, 180.0f);
mpHaihaiScreen->draw(0.0f, 0.0f, dComIfGp_getCurrentGrafPort());
}
if (direction & DIR_LEFT_e || i_forceDraw) {
mpParent->getPanePtr()->translate(304.0f - x_pos[1], y_pos[1] + 224.0f);
mpParent->getPanePtr()->translate(FB_WIDTH_BASE / 2 - x_pos[1], y_pos[1] + FB_HEIGHT_BASE / 2);
mpParent->getPanePtr()->rotate(mpParent->getPanePtr()->getWidth() / 2,
mpParent->getPanePtr()->getHeight() / 2, ROTATE_Z, 270.0f);
mpHaihaiScreen->draw(0.0f, 0.0f, dComIfGp_getCurrentGrafPort());
@@ -128,8 +128,8 @@ void dMeterHaihai_c::draw() {
}
void dMeterHaihai_c::drawHaihai(u8 i_direction) {
f32 center_x = 304.0f;
f32 center_y = 224.0f;
f32 center_x = FB_WIDTH_BASE / 2;
f32 center_y = FB_HEIGHT_BASE / 2;
if (mType == 1) {
center_x += (3.0f + g_drawHIO.mScrollArrowCenterPosX);
-9
View File
@@ -593,15 +593,6 @@ void dMeterMap_c::_draw() {
dComIfGd_set2DOpa(this);
}
#else
#if TARGET_PC
// Optimization: don't draw map if it's off-screen/invisible.
// Especially useful in debug builds on Hyrule field etc., it's slow!
// That +3 is an arbitrary bias to avoid rounding issues causing this to fail.
if ((!mMapIsInside && mSlidePositionOffset <= getDispPosOutSide_OffsetX() + 3) || mMapAlpha == 0) {
return;
}
#endif
mMap->_draw();
dComIfGd_set2DOpa(this);
#endif
+6
View File
@@ -2234,7 +2234,13 @@ int dMsgFlow_c::event027(mesg_flow_node_event* i_flowNode_p, fopAc_ac_c* i_speak
u16 prm0;
getParam(&prm0, &prm1, i_flowNode_p->params);
// !@bug aParam8 is undersized; getParam always writes 4 bytes, stomping the
// 2 bytes past the buffer. Harmless on GC/Wii (MWCC stack layout absorbs it).
#if AVOID_UB
u8 aParam8[4];
#else
u8 aParam8[2];
#endif
getParam(aParam8, i_flowNode_p->params);
JUT_ASSERT(4509, (aParam8[0] >= 0 && aParam8[0] <= dSv_player_item_c::BOMB_BAG_MAX) || (aParam8[0] == 4));
+8 -5
View File
@@ -70,7 +70,7 @@ dMsgScrnExplain_c::dMsgScrnExplain_c(STControl* i_stick, u8 param_1, bool i_isUs
mpTxScreen = JKR_NEW J2DScreen();
JUT_ASSERT(102, mpTxScreen != NULL);
field_0x48 = 608.0f;
field_0x48 = FB_WIDTH_BASE;
if (param_1 == 1 || param_1 == 3) {
#if PLATFORM_GCN
@@ -309,7 +309,7 @@ void dMsgScrnExplain_c::draw(J2DOrthoGraph* i_graf) {
}
if (mpBackTex != NULL) {
mpBackTex->draw(0.0f, 0.0f, 608.0f, 448.0f, false, false, false);
mpBackTex->draw(0.0f, 0.0f, FB_WIDTH_BASE, FB_HEIGHT_BASE, false, false, false);
}
if (field_0x66 != 2 && field_0x66 != 3) {
@@ -330,6 +330,9 @@ void dMsgScrnExplain_c::draw(J2DOrthoGraph* i_graf) {
strcpy(((J2DTextBox*)mpTm_c[0]->getPanePtr())->getStringPtr(), string_buf);
if (mpSelect_c != NULL && (field_0x64 == 1 || field_0x64 == 2)) {
// the magic numbers here are relative to the framebuffer size, but were likely
// either chosen by hand or had multiple arithmetic operations applied which
// cannot easily be reverse engineered
f32 y_offset = 0.0f;
if (field_0x66 == 2) {
y_offset = -100.0f;
@@ -385,7 +388,7 @@ void dMsgScrnExplain_c::open_request_proc() {
void dMsgScrnExplain_c::open_init() {
field_0x5a = 0;
field_0x48 = 608.0f;
field_0x48 = FB_WIDTH_BASE;
for (int i = 0; i < 2; i++) {
mpRoot_c[i]->setAlphaRate(0.0f);
}
@@ -403,7 +406,7 @@ void dMsgScrnExplain_c::open_proc() {
}
}
field_0x48 = 608.0f * getAlphaRatio();
field_0x48 = FB_WIDTH_BASE * getAlphaRatio();
for (int i = 0; i < 2; i++) {
mpRoot_c[i]->setAlphaRate(1.0f - getAlphaRatio());
}
@@ -583,7 +586,7 @@ void dMsgScrnExplain_c::close_proc() {
}
}
field_0x48 = 608.0f * getAlphaRatio();
field_0x48 = FB_WIDTH_BASE * getAlphaRatio();
for (int i = 0; i < 2; i++) {
mpRoot_c[i]->setAlphaRate(1.0f - getAlphaRatio());
}
+3
View File
@@ -609,6 +609,9 @@ void dMsgScrnItem_c::fukiPosCalc(u8 param_1) {
field_0x180 = 0.0f;
field_0x19c = param_1;
f32 yOffset;
// the magic numbers here are correlated with the framebuffer size, but
// were likely either chosen by hand or had multiple arithmetic
// operations applied which cannot easily be reverse engineered
switch(field_0x19c) {
case 1:
yOffset = g_MsgObject_HIO_c.mBoxPos[2][3];
+21 -6
View File
@@ -6,6 +6,7 @@
#include "JSystem/J2DGraph/J2DScreen.h"
#include "d/d_com_inf_game.h"
#include "d/d_pane_class.h"
#include "dusk/frame_interpolation.h"
class dMsgScrnLight_HIO_c {
public:
@@ -202,10 +203,17 @@ void dMsgScrnLight_c::draw(f32* i_anmFrame, f32 i_posX, f32 i_posY, f32 i_scaleX
}
if (mPlayAnim) {
*i_anmFrame += 1.0f;
if (*i_anmFrame >= mpBck->getFrameMax()) {
*i_anmFrame = 0.0f;
#ifdef TARGET_PC
const u32 ui_advance_ticks = dusk::frame_interp::get_presentation_ui_advance_ticks();
for (u32 i = 0; i < ui_advance_ticks; ++i) {
#endif
*i_anmFrame += 1.0f;
if (*i_anmFrame >= mpBck->getFrameMax()) {
*i_anmFrame = 0.0f;
}
#ifdef TARGET_PC
}
#endif
mBckFrame = *i_anmFrame;
mBpkFrame = *i_anmFrame;
@@ -220,11 +228,18 @@ void dMsgScrnLight_c::draw(f32* i_anmFrame, f32 i_posX, f32 i_posY, f32 i_scaleX
mpParent_c->setBlackWhite(i_black, i_white);
if (mPlayAnim) {
*i_anmFrame += i_anmRate;
#ifdef TARGET_PC
const u32 ui_advance_ticks = dusk::frame_interp::get_presentation_ui_advance_ticks();
for (u32 i = 0; i < ui_advance_ticks; ++i) {
#endif
*i_anmFrame += i_anmRate;
if (*i_anmFrame >= mpBck->getFrameMax()) {
*i_anmFrame = 0.0f;
if (*i_anmFrame >= mpBck->getFrameMax()) {
*i_anmFrame = 0.0f;
}
#ifdef TARGET_PC
}
#endif
mBckFrame = *i_anmFrame;
mBpkFrame = *i_anmFrame;
+7 -4
View File
@@ -454,11 +454,11 @@ void dMsgScrnTalk_c::fukiPosCalc(u8 param_1) {
#if TARGET_PC
mDoLib_project(&msgActor->pos, &local_70, {0, 0, FB_WIDTH, FB_HEIGHT});
#else
mDoLib_project(&msgActor->pos, &local_70,);
mDoLib_project(&msgActor->pos, &local_70);
#endif
if (local_70.x >= 0.0f && local_70.x <= 608.0f && local_70.y >= 0.0f &&
local_70.y <= 448.0f)
if (local_70.x >= 0.0f && local_70.x <= FB_WIDTH_BASE && local_70.y >= 0.0f &&
local_70.y <= FB_HEIGHT_BASE)
{
f3y = 0.5f * (cStack_7c.y + local_70.y);
} else {
@@ -493,6 +493,9 @@ void dMsgScrnTalk_c::fukiPosCalc(u8 param_1) {
field_0xf0 = 0.0f;
field_0x488 = param_1;
f32 dVar15;
// the magic numbers here are correlated with the framebuffer size, but
// were likely either chosen by hand or had multiple arithmetic
// operations applied which cannot easily be reverse engineered
switch (field_0x488) {
case 1:
dVar15 = g_MsgObject_HIO_c.mBoxPos[2][0];
+15 -11
View File
@@ -8,22 +8,23 @@
// weak data from it (unlike here).
#include "d/d_particle.h"
#include "d/d_jnt_col.h"
#include <cstdio>
#include "JSystem/J3DGraphAnimator/J3DMaterialAnm.h"
#include "JSystem/J3DGraphBase/J3DMaterial.h"
#include "JSystem/JKernel/JKRExpHeap.h"
#include "JSystem/JKernel/JKRSolidHeap.h"
#include "JSystem/J3DGraphBase/J3DMaterial.h"
#include "JSystem/J3DGraphAnimator/J3DMaterialAnm.h"
#include "JSystem/JMath/JMATrigonometric.h"
#include "JSystem/JParticle/JPAEmitterManager.h"
#include "JSystem/JParticle/JPAResourceManager.h"
#include "JSystem/JMath/JMATrigonometric.h"
#include "d/d_s_play.h"
#include <cstdio>
#include "d/d_com_inf_game.h"
#include "m_Do/m_Do_lib.h"
#include "m_Do/m_Do_graphic.h"
#include "f_op/f_op_actor_mng.h"
#include "d/actor/d_a_player.h"
#include "SSystem/SComponent/c_math.h"
#include "d/actor/d_a_player.h"
#include "d/d_com_inf_game.h"
#include "d/d_jnt_col.h"
#include "d/d_s_play.h"
#include "f_op/f_op_actor_mng.h"
#include "m_Do/m_Do_graphic.h"
#include "m_Do/m_Do_lib.h"
#include "tracy/Tracy.hpp"
#ifndef __MWERKS__
#include "dusk/math.h"
@@ -1325,6 +1326,7 @@ void dPa_control_c::cleanup() {
}
void dPa_control_c::calc3D() {
ZoneScoped;
if (isStatus(2)) {
offStatus(2);
} else {
@@ -1336,12 +1338,14 @@ void dPa_control_c::calc3D() {
}
void dPa_control_c::calc2D() {
ZoneScoped;
for (u8 i = 14; i <= 16; i++) {
mEmitterMng->calc(i);
}
}
void dPa_control_c::calcMenu() {
ZoneScoped;
if (mEmitterMng != NULL) {
for (u8 i = 17; i <= 18; i++) {
mEmitterMng->calc(i);
+6 -5
View File
@@ -1176,19 +1176,20 @@ void dScnLogo_c::logoInitWii() {
break;
}
width = 608;
height = 456;
// this uses the standard width but the widescreen height?
width = FB_WIDTH_BASE;
height = FB_HEIGHT;
}
JUT_ASSERT(2309, timg != NULL);
mStrapImg = JKR_NEW dDlst_2D_c(timg, 304 - (width / 2), 224 - (height / 2), width, height, 255);
mStrapImg = JKR_NEW dDlst_2D_c(timg, (FB_WIDTH_BASE / 2) - (width / 2), (FB_HEIGHT_BASE / 2) - (height / 2), width, height, 255);
#if VERSION == VERSION_SHIELD
timg = (ResTIMG*)dComIfG_getObjectRes("LogoUsWii", 5);
mNvLogo = JKR_NEW dDlst_2D_c(timg, 304 - (width / 2), 224 - (height / 2), width, height, 255);
mNvLogo = JKR_NEW dDlst_2D_c(timg, (FB_WIDTH_BASE / 2) - (width / 2), (FB_HEIGHT_BASE / 2) - (height / 2), width, height, 255);
timg = (ResTIMG*)dComIfG_getObjectRes("LogoUsWii", 4);
mMocImg = JKR_NEW dDlst_2D_c(timg, 304 - (width / 2), 224 - (height / 2), width, height, 255);
mMocImg = JKR_NEW dDlst_2D_c(timg, (FB_WIDTH_BASE / 2) - (width / 2), (FB_HEIGHT_BASE / 2) - (height / 2), width, height, 255);
#endif
OS_REPORT("\x1b[32m%d archiveHeap->getTotalFreeSize %08x\n\x1b[m", 2316, archiveHeap->getTotalFreeSize());
-12
View File
@@ -785,19 +785,7 @@ static int dScnPly_Execute(dScnPly_c* i_this) {
dJprev_c::get()->update();
#endif
#if TARGET_PC
if (dusk::config::IsConfigFileMissing()) {
firstTime = true;
} else if (firstTime) {
mDoAud_seStart(Z2SE_TITLE_ENTER, NULL, 0, 0);
JUTGamePad::C3ButtonReset::sResetSwitchPushing = true;
firstTime = false;
} else {
dDemo_c::update();
}
#else
dDemo_c::update();
#endif
#if DEBUG
dJcame_c::get()->update();
+11 -11
View File
@@ -136,24 +136,24 @@ void dScope_c::draw() {
u8 alpha = mAlpha * 255.0f;
if (dComIfGp_checkPlayerStatus0(0, 0x1000)) {
J2DDrawLine(304.0f, mDoGph_gInf_c::getMinYF(), 304.0f, mDoGph_gInf_c::getMaxYF(),
JUtility::TColor(255, 0, 0, alpha), 6);
J2DDrawLine(mDoGph_gInf_c::getMinXF(), 224.0f, mDoGph_gInf_c::getMaxXF(), 224.0f,
JUtility::TColor(255, 0, 0, alpha), 6);
J2DDrawLine(FB_WIDTH_BASE / 2, mDoGph_gInf_c::getMinYF(), FB_WIDTH_BASE / 2,
mDoGph_gInf_c::getMaxYF(), JUtility::TColor(255, 0, 0, alpha), 6);
J2DDrawLine(mDoGph_gInf_c::getMinXF(), FB_HEIGHT_BASE / 2, mDoGph_gInf_c::getMaxXF(),
FB_HEIGHT_BASE / 2, JUtility::TColor(255, 0, 0, alpha), 6);
}
mpWipeTex->setAlpha(alpha);
mpBlackTex->setAlpha(alpha);
f32 temp_f29 = 304.0f - temp_f31;
f32 temp_f28 = 304.0f + temp_f31;
f32 temp_f27 = 224.0f - temp_f30;
f32 temp_f26 = 224.0f + temp_f30;
f32 temp_f29 = FB_WIDTH_BASE / 2 - temp_f31;
f32 temp_f28 = FB_WIDTH_BASE / 2 + temp_f31;
f32 temp_f27 = FB_HEIGHT_BASE / 2 - temp_f30;
f32 temp_f26 = FB_HEIGHT_BASE / 2 + temp_f30;
mpWipeTex->draw(temp_f29, temp_f27, temp_f31, temp_f30, false, false, false);
mpWipeTex->draw(304.0f, temp_f27, temp_f31, temp_f30, true, false, false);
mpWipeTex->draw(temp_f29, 224.0f, temp_f31, temp_f30, false, true, false);
mpWipeTex->draw(304.0f, 224.0f, temp_f31, temp_f30, true, true, false);
mpWipeTex->draw(FB_WIDTH_BASE / 2, temp_f27, temp_f31, temp_f30, true, false, false);
mpWipeTex->draw(temp_f29, FB_HEIGHT_BASE / 2, temp_f31, temp_f30, false, true, false);
mpWipeTex->draw(FB_WIDTH_BASE / 2, FB_HEIGHT_BASE / 2, temp_f31, temp_f30, true, true, false);
mpBlackTex->draw(mDoGph_gInf_c::getMinXF(), mDoGph_gInf_c::getMinYF(),
mDoGph_gInf_c::getWidthF(), temp_f27 - mDoGph_gInf_c::getMinYF(), false, false,
+48 -19
View File
@@ -5,6 +5,7 @@
#include "d/d_com_inf_game.h"
#include "JSystem/J2DGraph/J2DAnimation.h"
#include "JSystem/J2DGraph/J2DAnmLoader.h"
#include "dusk/frame_interpolation.h"
#include <cstring>
dSelect_cursorHIO_c::dSelect_cursorHIO_c() {
@@ -270,15 +271,22 @@ void dSelect_cursor_c::update() {
if (mUpdateFlag) {
if (field_0x30) {
if (chkPlayAnime(0)) {
if (mNameIdx == 1) {
field_0x44 += mpCursorHIO->field_0x8 * fVar1;
} else {
field_0x44 += fVar1;
}
#ifdef TARGET_PC
const u32 ui_advance_ticks = dusk::frame_interp::get_presentation_ui_advance_ticks();
for (u32 tick = 0; tick < ui_advance_ticks; ++tick) {
#endif
if (mNameIdx == 1) {
field_0x44 += mpCursorHIO->field_0x8 * fVar1;
} else {
field_0x44 += fVar1;
}
if (field_0x44 >= field_0x30->getFrameMax()) {
field_0x44 -= field_0x30->getFrameMax();
if (field_0x44 >= field_0x30->getFrameMax()) {
field_0x44 -= field_0x30->getFrameMax();
}
#ifdef TARGET_PC
}
#endif
field_0x30->setFrame(field_0x44);
setBpkAnimation(field_0x30);
@@ -294,14 +302,21 @@ void dSelect_cursor_c::update() {
for (int i = 0; i < 2; i++) {
if (field_0x34[i]) {
if ((i == 0 && chkPlayAnime(2)) || (i == 1 && chkPlayAnime(3))) {
if (mNameIdx == 1) {
field_0x48[i] += mpCursorHIO->field_0x8 * fVar1;
} else {
field_0x48[i] += fVar1;
}
if (field_0x48[i] >= field_0x34[i]->getFrameMax()) {
field_0x48[i] -= field_0x34[i]->getFrameMax();
#ifdef TARGET_PC
const u32 ui_advance_ticks = dusk::frame_interp::get_presentation_ui_advance_ticks();
for (u32 tick = 0; tick < ui_advance_ticks; ++tick) {
#endif
if (mNameIdx == 1) {
field_0x48[i] += mpCursorHIO->field_0x8 * fVar1;
} else {
field_0x48[i] += fVar1;
}
if (field_0x48[i] >= field_0x34[i]->getFrameMax()) {
field_0x48[i] -= field_0x34[i]->getFrameMax();
}
#ifdef TARGET_PC
}
#endif
field_0x34[i]->setFrame(field_0x48[i]);
}
@@ -310,7 +325,11 @@ void dSelect_cursor_c::update() {
}
if (field_0x2C && chkPlayAnime(1)) {
if (mNameIdx == 1) {
#ifdef TARGET_PC
const u32 ui_advance_ticks = dusk::frame_interp::get_presentation_ui_advance_ticks();
for (u32 tick = 0; tick < ui_advance_ticks; ++tick) {
#endif
if (mNameIdx == 1) {
field_0x40 += mpCursorHIO->field_0x8 * fVar1;
} else {
field_0x40 += fVar1;
@@ -318,14 +337,24 @@ void dSelect_cursor_c::update() {
if (field_0x40 >= field_0x2C->getFrameMax()) {
field_0x40 -= field_0x2C->getFrameMax();
}
field_0x2C->setFrame(field_0x40);
setBckAnimation(field_0x2C);
#ifdef TARGET_PC
}
#endif
field_0x2C->setFrame(field_0x40);
setBckAnimation(field_0x2C);
}
if (chkPlayAnime(1) && mNameIdx == 0) {
setCursorAnimation();
#ifdef TARGET_PC
const u32 ui_advance_ticks = dusk::frame_interp::get_presentation_ui_advance_ticks();
for (u32 tick = 0; tick < ui_advance_ticks; ++tick) {
#endif
setCursorAnimation();
#ifdef TARGET_PC
}
#endif
}
mpScreen->animation();
+18 -8
View File
@@ -2,21 +2,31 @@
#include "d/d_select_icon.h"
#include "JSystem/J2DGraph/J2DAnimation.h"
#include "dusk/frame_interpolation.h"
dSi_HIO_c::dSi_HIO_c() {}
void dSelect_icon_c::animation() {
if (field_0x10->getAlpha() != 0) {
field_0x20 += field_0x2c;
if (field_0x20 >= field_0x1c->getFrameMax()) {
field_0x20 = 0.0f;
}
field_0x1c->setFrame(field_0x20);
#ifdef TARGET_PC
const u32 ui_advance_ticks = dusk::frame_interp::get_presentation_ui_advance_ticks();
for (u32 i = 0; i < ui_advance_ticks; ++i) {
#endif
field_0x20 += field_0x2c;
if (field_0x20 >= field_0x1c->getFrameMax()) {
field_0x20 = 0.0f;
}
field_0x1c->setFrame(field_0x20);
field_0x28 += field_0x2c;
if (field_0x28 >= field_0x24->getFrameMax()) {
field_0x28 = 0.0f;
field_0x28 += field_0x2c;
if (field_0x28 >= field_0x24->getFrameMax()) {
field_0x28 = 0.0f;
}
#ifdef TARGET_PC
}
// Set even if not advancing
field_0x1c->setFrame(field_0x20);
#endif
field_0x24->setFrame(field_0x28);
field_0x8->animation();
+6 -1
View File
@@ -17,6 +17,7 @@
#include <memory>
#include "JSystem/JKernel/JKRHeap.h"
#include "common/TracySystem.hpp"
#include "dusk/main.h"
#include "dusk/os.h"
@@ -41,7 +42,7 @@ struct PCThreadData {
bool suspended = false;
~PCThreadData() {
if (dusk::IsShuttingDown) {
if (dusk::IsShuttingDown && nativeThread.joinable()) {
// Don't care about threads if we're shutting down.
nativeThread.detach();
}
@@ -667,6 +668,9 @@ void OSSetCurrentThreadName(const char* name) {
// "Why is this current thread only?", you might ask?
// Because macOS requires that. For some reason.
#if TRACY_ENABLE
tracy::SetThreadName(name);
#else
#if _WIN32
wchar_t buffer[256];
const auto converted = MultiByteToWideChar(
@@ -687,6 +691,7 @@ void OSSetCurrentThreadName(const char* name) {
#elif __APPLE__
pthread_setname_np(name);
#endif
#endif
}
#ifdef __cplusplus
+9
View File
@@ -14,6 +14,7 @@
#include "DuskDsp.hpp"
#include "JSystem/JAudio2/JASAudioThread.h"
#include "JSystem/JAudio2/JASDriverIF.h"
#include "tracy/Tracy.hpp"
using namespace dusk::audio;
@@ -82,18 +83,25 @@ void dusk::audio::SetEnableReverb(const bool value) {
EnableReverb = value;
}
#ifdef TRACY_ENABLE
static auto FrameName = "GetNewAudio";
#endif
void SDLCALL GetNewAudio(
void*,
SDL_AudioStream*,
int needed,
int) {
FrameMarkStart(FrameName);
while (needed > 0) {
const int rendered = RenderNewAudioFrame();
needed -= rendered;
}
FrameMarkEnd(FrameName);
}
int RenderNewAudioFrame() {
ZoneScoped;
JASCriticalSection section;
const u32 countSubframes = JASDriver::getSubFrames();
@@ -120,6 +128,7 @@ static void InterleaveOutputData(const OutputSubframe& data, std::span<f32> targ
}
void RenderAudioSubframe() {
ZoneScoped;
OutBuffer = {};
JASDriver::updateDSP();
+42
View File
@@ -14,6 +14,7 @@
#include "dusk/audio/DuskAudioSystem.h"
#include "dusk/endian.h"
#include "global.h"
#include "tracy/Tracy.hpp"
using namespace dusk::audio;
@@ -116,6 +117,14 @@ static void ResetChannel(JASDsp::TChannel& channel, ChannelAuxData& aux) {
aux.resamplePos = 0.0;
aux.resamplePrev = 0;
aux.prev_lp_out = 0.0f;
aux.prev_lp_in = 0.0f;
aux.biq_in1 = 0.0f;
aux.biq_in2 = 0.0f;
aux.biq_out1 = 0.0f;
aux.biq_out2 = 0.0f;
for (auto& volume : aux.prevVolume) {
volume = NAN;
}
@@ -133,6 +142,7 @@ static void MixSubframe(DspSubframe& dst, const DspSubframe& src) {
}
void dusk::audio::DspRender(OutputSubframe& subframe) {
ZoneScoped;
if (DumpAudio != sDumpWasActive) {
sDumpWasActive = DumpAudio;
if (DumpAudio) {
@@ -519,6 +529,38 @@ static void RenderChannel(
channelAux.resamplePos = pos;
channelAux.resamplePrev = prev;
// IIR FILTER
// IIR part 1, low-pass: out[n] = (in[n] - in[n-1]) * (coeff/128) + out[n-1]
if (s16 coeff = channel.iir_filter_params[4]; coeff != 0) {
for (f32& sample : audioLoadBuffer) {
f32 out = std::clamp(
(sample - channelAux.prev_lp_in) * ((f32)coeff / 128.0f) + channelAux.prev_lp_out, -1.0f, 1.0f
);
channelAux.prev_lp_in = sample; // in[n-1] = in[n]
sample = channelAux.prev_lp_out = out; // out[n-1] = out[n]
}
}
// IIR part 2, biquad: out[n] = (b1*in[n-1] + b2*in[n-2] + a1*out[n-1] + a2*out[n-2]) / 32768
if ((channel.mFilterMode & 0x20) != 0) {
for (f32& sample : audioLoadBuffer) {
f32 out = std::clamp((
channel.iir_filter_params[0] * channelAux.biq_in1 + // b1
channel.iir_filter_params[1] * channelAux.biq_in2 + // b2
channel.iir_filter_params[2] * channelAux.biq_out1 + // a1
channel.iir_filter_params[3] * channelAux.biq_out2 // a2
) / 32768.0f, -1.0f, 1.0f);
// shift history, then store new input and output
channelAux.biq_in2 = channelAux.biq_in1; // in[n-2] = in[n-1]
channelAux.biq_in1 = sample; // in[n-1] = in[n]
channelAux.biq_out2 = channelAux.biq_out1; // out[n-2] = out[n-1]
sample = channelAux.biq_out1 = out; // out[n-1] = out[n]
}
}
// move any remaining samples in the decode buf to the beginning
int remainingDecodeBuf = channelAux.decodeBufCount - srcIdx;
if (remainingDecodeBuf > 0) {
+10
View File
@@ -52,6 +52,16 @@ namespace dusk::audio {
f32 resamplePos;
// last consumed sample from decodeBuf
s16 resamplePrev;
// low pass previous state
f32 prev_lp_out; // out[n-1]
f32 prev_lp_in; // in[n-1]
// biquad state
f32 biq_in1; // in[n-1]
f32 biq_in2; // in[n-2]
f32 biq_out1; // out[n-1]
f32 biq_out2; // out[n-2]
};
extern ChannelAuxData ChannelAux[DSP_CHANNELS];
+3 -1
View File
@@ -2,7 +2,9 @@
#include <mutex>
static std::recursive_mutex gAudioThreadMutex;
#include "tracy/Tracy.hpp"
static TracyLockable(std::recursive_mutex, gAudioThreadMutex);
JASCriticalSection::JASCriticalSection() {
gAudioThreadMutex.lock();
+2 -10
View File
@@ -20,8 +20,7 @@ using json = nlohmann::json;
aurora::Module DuskConfigLog("dusk::config");
static absl::flat_hash_map<std::string_view, ConfigVarBase*> RegisteredConfigVars;
static bool RegistrationDone;
static bool s_configFileMissing = false;
static bool RegistrationDone = false;
static std::string GetConfigJsonPath() {
return fmt::format("{}{}", configPath, ConfigFileName);
@@ -188,7 +187,6 @@ void dusk::config::LoadFromFileName(const char* path) {
} catch (const std::system_error& e) {
if (e.code() == std::errc::no_such_file_or_directory) {
DuskConfigLog.info("Config file did not exist, staying with defaults");
s_configFileMissing = true;
} else {
DuskConfigLog.error("Failed to load from config! {}", e.what());
}
@@ -212,12 +210,6 @@ void dusk::config::Save() {
}
io::FileStream::WriteAllText(configJsonPath.c_str(), j.dump(4));
s_configFileMissing = false;
}
bool dusk::config::IsConfigFileMissing() {
return s_configFileMissing;
}
ConfigVarBase* dusk::config::GetConfigVar(std::string_view name) {
@@ -227,4 +219,4 @@ ConfigVarBase* dusk::config::GetConfigVar(std::string_view name) {
}
return nullptr;
}
}
+398
View File
@@ -0,0 +1,398 @@
#include "dusk/frame_interpolation.h"
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <memory>
#include <unordered_map>
#include <vector>
namespace {
enum class Op : uint8_t {
OpenChild,
FinalMtx,
};
struct Label {
const void* key = nullptr;
int32_t id = 0;
bool operator==(const Label& other) const {
return key == other.key && id == other.id;
}
};
struct Data {
Label child_label{};
size_t child_index = 0;
Mtx matrix{};
const Mtx* dest = nullptr;
};
struct Path;
struct ChildBucket {
Label label{};
std::vector<std::unique_ptr<Path>> nodes;
};
struct OpBucket {
Op op = Op::OpenChild;
std::vector<Data> values;
};
struct Path {
std::vector<ChildBucket> children;
std::vector<OpBucket> ops;
std::vector<std::pair<Op, size_t>> items;
};
struct Recording {
Path root;
};
struct MatrixValue {
Mtx value;
};
using FinalMtxLookup = std::unordered_map<const Mtx*, const Data*>;
bool s_initialized = false;
bool g_enabled = false;
bool g_recording = false;
bool g_interpolating = false;
float g_step = 0.0f;
uint32_t g_pending_presentation_ui_ticks = 0;
uint32_t g_current_presentation_ui_ticks = 0;
Recording g_current_recording;
Recording g_previous_recording;
std::vector<Path*> g_current_path;
std::unordered_map<const Mtx*, MatrixValue> g_replacements;
inline void copy_matrix(const Mtx src, Mtx dst) {
MTXCopy(src, dst);
}
inline void concat_matrix(const Mtx lhs, const Mtx rhs, Mtx out) {
MTXConcat(lhs, rhs, out);
}
inline void lerp_matrix(Mtx out, const Mtx lhs, const Mtx rhs, float step) {
const float old_weight = 1.0f - step;
for (size_t row = 0; row < 3; ++row) {
for (size_t col = 0; col < 4; ++col) {
out[row][col] = lhs[row][col] * old_weight + rhs[row][col] * step;
}
}
}
inline bool matrix_differs(const Mtx lhs, const Mtx rhs, float epsilon = 0.0001f) {
for (size_t row = 0; row < 3; ++row) {
for (size_t col = 0; col < 4; ++col) {
if (std::abs(lhs[row][col] - rhs[row][col]) > epsilon) {
return true;
}
}
}
return false;
}
Data& append_op(Op op) {
auto& items = g_current_path.back()->items;
auto& buckets = g_current_path.back()->ops;
auto it = std::find_if(buckets.begin(), buckets.end(),
[op](const OpBucket& bucket) { return bucket.op == op; });
if (it == buckets.end()) {
buckets.push_back({op, {}});
it = buckets.end() - 1;
}
items.emplace_back(op, it->values.size());
return it->values.emplace_back();
}
const Data* find_matching_data(const Path& path, Op op, size_t index) {
auto it = std::find_if(path.ops.begin(), path.ops.end(),
[op](const OpBucket& bucket) { return bucket.op == op; });
if (it == path.ops.end() || index >= it->values.size()) {
return nullptr;
}
return &it->values[index];
}
const OpBucket* find_op_bucket(const Path& path, Op op) {
auto it = std::find_if(path.ops.begin(), path.ops.end(),
[op](const OpBucket& bucket) { return bucket.op == op; });
if (it == path.ops.end()) {
return nullptr;
}
return &*it;
}
void build_final_mtx_lookup(const Path& path, FinalMtxLookup& lookup) {
lookup.clear();
const OpBucket* bucket = find_op_bucket(path, Op::FinalMtx);
if (bucket == nullptr) {
return;
}
for (const Data& data : bucket->values) {
if (data.dest == nullptr) {
continue;
}
lookup[data.dest] = &data;
}
}
const Data* find_matching_final_mtx(const FinalMtxLookup& lookup, const Data& new_data) {
if (new_data.dest == nullptr) {
return nullptr;
}
auto it = lookup.find(new_data.dest);
if (it == lookup.end()) {
return nullptr;
}
return it->second;
}
ChildBucket& get_child_bucket(Path& path, const Label& label) {
auto it = std::find_if(path.children.begin(), path.children.end(),
[&label](const ChildBucket& bucket) { return bucket.label == label; });
if (it == path.children.end()) {
path.children.push_back({});
it = path.children.end() - 1;
it->label = label;
}
return *it;
}
const ChildBucket* find_child_bucket(const Path& path, const Label& label) {
auto it = std::find_if(path.children.begin(), path.children.end(),
[&label](const ChildBucket& bucket) { return bucket.label == label; });
if (it == path.children.end()) {
return nullptr;
}
return &*it;
}
void store_replacement(const Data& old_data, const Data& new_data, float step) {
if (new_data.dest == nullptr) {
return;
}
auto& replacement = g_replacements[new_data.dest];
lerp_matrix(replacement.value, old_data.matrix, new_data.matrix, step);
}
void interpolate_branch(const Path& old_path, const Path& new_path, float step) {
FinalMtxLookup old_final_mtx_lookup;
build_final_mtx_lookup(old_path, old_final_mtx_lookup);
for (const auto& item : new_path.items) {
const Op op = item.first;
const size_t index = item.second;
const Data* new_data = find_matching_data(new_path, op, index);
if (new_data == nullptr) {
continue;
}
if (op == Op::OpenChild) {
const ChildBucket* new_children = find_child_bucket(new_path, new_data->child_label);
if (new_children == nullptr || new_data->child_index >= new_children->nodes.size())
{
continue;
}
const Path& new_child = *new_children->nodes[new_data->child_index];
const ChildBucket* old_children = find_child_bucket(old_path, new_data->child_label);
if (old_children != nullptr && new_data->child_index < old_children->nodes.size())
{
interpolate_branch(*old_children->nodes[new_data->child_index], new_child, step);
} else {
interpolate_branch(new_child, new_child, step);
}
continue;
}
const Data* indexed_old_data = find_matching_data(old_path, op, index);
const Data* old_data = op == Op::FinalMtx ? find_matching_final_mtx(old_final_mtx_lookup, *new_data) : indexed_old_data;
if (op == Op::FinalMtx) {
store_replacement(old_data != nullptr ? *old_data : *new_data, *new_data, step);
}
}
}
const Mtx* resolve_replacement(const Mtx* source, Mtx* scratch) {
if (!g_interpolating || source == nullptr) {
return source;
}
auto it = g_replacements.find(source);
if (it == g_replacements.end()) {
return source;
}
copy_matrix(it->second.value, *scratch);
return scratch;
}
bool has_recording_data(const Recording& recording) {
return !recording.root.items.empty() || !recording.root.children.empty();
}
void clear_replacements() {
g_replacements.clear();
}
} // namespace
namespace dusk {
namespace frame_interp {
void ensure_initialized() {
g_enabled = getSettings().game.enableFrameInterpolation;
s_initialized = true;
}
void begin_record() {
ensure_initialized();
if (!g_enabled) {
g_interpolating = false;
g_previous_recording = {};
g_current_recording = {};
g_current_path.clear();
clear_replacements();
return;
}
g_previous_recording = std::move(g_current_recording);
g_current_recording = {};
g_current_path.clear();
g_current_path.push_back(&g_current_recording.root);
g_recording = true;
g_interpolating = false;
clear_replacements();
}
void end_record() {
g_recording = false;
}
void interpolate(float step) {
ensure_initialized();
clear_replacements();
g_step = std::clamp(step, 0.0f, 1.0f);
g_interpolating = g_enabled && !g_recording && has_recording_data(g_current_recording);
if (!g_interpolating) {
return;
}
if (!has_recording_data(g_previous_recording)) {
interpolate_branch(g_current_recording.root, g_current_recording.root, g_step);
return;
}
interpolate_branch(g_previous_recording.root, g_current_recording.root, g_step);
}
void notify_sim_tick_complete() {
ensure_initialized();
g_pending_presentation_ui_ticks++;
}
uint32_t begin_presentation_ui_pass() {
ensure_initialized();
g_current_presentation_ui_ticks = g_pending_presentation_ui_ticks;
g_pending_presentation_ui_ticks = 0;
return g_current_presentation_ui_ticks;
}
uint32_t get_presentation_ui_advance_ticks() {
if (!s_initialized) {
return 0;
}
if (!g_enabled) {
return 1;
}
return g_current_presentation_ui_ticks;
}
void end_presentation_ui_pass() {
if (!s_initialized) {
return;
}
g_current_presentation_ui_ticks = 0;
}
void open_child(const void* key, int32_t id) {
if (!s_initialized || !g_recording) {
return;
}
Label label{key, id};
auto& siblings = get_child_bucket(*g_current_path.back(), label).nodes;
Data& data = append_op(Op::OpenChild);
data.child_label = label;
data.child_index = siblings.size();
siblings.emplace_back(std::make_unique<Path>());
g_current_path.push_back(siblings.back().get());
}
void close_child() {
if (!s_initialized || !g_recording || g_current_path.size() <= 1) {
return;
}
g_current_path.pop_back();
}
void record_final_mtx_raw(const Mtx* dest, const Mtx src) {
if (!s_initialized || !g_recording || dest == nullptr) {
return;
}
Data& data = append_op(Op::FinalMtx);
data.dest = dest;
copy_matrix(src, data.matrix);
}
bool lookup_replacement(const void* source, Mtx out) {
if (!s_initialized || !g_interpolating || source == nullptr) {
return false;
}
auto it = g_replacements.find(reinterpret_cast<const Mtx*>(source));
if (it == g_replacements.end()) {
return false;
}
copy_matrix(it->second.value, out);
return true;
}
bool lookup_concat_replacement(const void* lhs, const void* rhs, Mtx out) {
if (!s_initialized || !g_interpolating || lhs == nullptr || rhs == nullptr) {
return false;
}
Mtx lhs_scratch;
Mtx rhs_scratch;
const Mtx* resolved_lhs = resolve_replacement(reinterpret_cast<const Mtx*>(lhs), &lhs_scratch);
const Mtx* resolved_rhs = resolve_replacement(reinterpret_cast<const Mtx*>(rhs), &rhs_scratch);
if (resolved_lhs == reinterpret_cast<const Mtx*>(lhs) &&
resolved_rhs == reinterpret_cast<const Mtx*>(rhs))
{
return false;
}
concat_matrix(*resolved_lhs, *resolved_rhs, out);
return true;
}
} // namespace frame_interp
} // namespace dusk
+6
View File
@@ -253,3 +253,9 @@ void dusk::ImGuiMenuTools::ShowAudioDebug() {
ImGui::End();
}
void dusk::ImGuiMenuTools::ShowSaveEditor() {
if (m_showSaveEditor) {
m_saveEditor.draw(m_showSaveEditor);
}
}
+1 -1
View File
@@ -25,7 +25,7 @@ namespace dusk {
windowFlags |= ImGuiWindowFlags_NoMove;
}
ImGui::SetNextWindowBgAlpha(0.65f);
// ImGui::SetNextWindowBgAlpha(0.65f);
if (!ImGui::Begin("Camera Debug", nullptr, windowFlags)) {
ImGui::End();
+126 -40
View File
@@ -14,9 +14,11 @@
#include "JSystem/JUtility/JUTGamePad.h"
#include "SDL3/SDL_mouse.h"
#include "dusk/config.hpp"
#include "dusk/main.h"
#include "dusk/settings.h"
#include "dusk/audio/DuskAudioSystem.h"
#include "dusk/dusk.h"
#include "tracy/Tracy.hpp"
#if _WIN32
#define NOMINMAX
@@ -34,6 +36,21 @@ namespace dusk {
ImGui::TextUnformatted(text.data(), text.data() + text.size());
}
void ImGuiTextCenter(std::string_view text) {
ImGui::NewLine();
float fontSize = ImGui::CalcTextSize(text.data(), text.data() + text.size()).x;
ImGui::SameLine(ImGui::GetWindowSize().x / 2 - fontSize + fontSize / 2);
ImGuiStringViewText(text);
}
bool ImGuiButtonCenter(std::string_view text) {
ImGui::NewLine();
float fontSize = ImGui::CalcTextSize(text.data(), text.data() + text.size()).x;
fontSize += ImGui::GetStyle().FramePadding.x;
ImGui::SameLine(ImGui::GetWindowSize().x / 2 - fontSize + fontSize / 2);
return ImGui::Button(text.data());
}
std::string BytesToString(size_t bytes) {
constexpr std::array suffixes{ "B"sv, "KB"sv, "MB"sv, "GB"sv, "TB"sv, "PB"sv, "EB"sv };
uint32_t s = 0;
@@ -183,37 +200,15 @@ namespace dusk {
ImGuiConsole::ImGuiConsole() {}
void ImGuiConsole::InitSettings() {
bool lockAspect = getSettings().video.lockAspectRatio;
if (lockAspect) {
VILockAspectRatio(defaultAspectRatioW, defaultAspectRatioH);
} else {
VIUnlockAspectRatio();
}
dusk::audio::SetMasterVolume(getSettings().audio.masterVolume / 100.0f);
dusk::audio::SetEnableReverb(getSettings().audio.enableReverb);
}
void ImGuiConsole::UpdateSettings() {
getTransientSettings().skipFrameRateLimit = getSettings().game.enableTurboKeybind && ImGui::IsKeyDown(ImGuiKey_Tab);
}
void ImGuiConsole::PreDraw() {
if (config::IsConfigFileMissing()) {
m_firstRunPreset.draw();
return;
}
if (!m_isLaunchInitialized) {
InitSettings();
m_toasts.emplace_back("Press F1 to toggle menu"s, 5.f);
m_isLaunchInitialized = true;
}
ZoneScoped;
UpdateSettings();
if ((ImGui::IsKeyDown(ImGuiKey_LeftCtrl) || ImGui::IsKeyDown(ImGuiKey_RightCtrl)) &&
ImGui::IsKeyPressed(ImGuiKey_R))
{
@@ -224,24 +219,11 @@ namespace dusk {
ImGuiMenuGame::ToggleFullscreen();
}
if (CheckMenuViewToggle(ImGuiKey_F1, m_isHidden)) {
ShowToasts();
ImGui::GetIO().ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange;
SDL_HideCursor();
return;
}
bool showMenu = !dusk::IsGameLaunched || !CheckMenuViewToggle(ImGuiKey_F1, m_isHidden);
ImGui::GetIO().ConfigFlags &= ~ImGuiConfigFlags_NoMouseCursorChange;
// Imgui will re-show cursor.
// TODO: we need to be able to render the menu bar & any overlays separately
// The code currently ties them all together, so hiding the menu hides all windows
if (ImGui::BeginMainMenuBar()) {
if (showMenu && ImGui::BeginMainMenuBar()) {
m_menuGame.draw();
m_menuEnhancements.draw();
// Keep always last
m_menuTools.draw();
ImGui::SetCursorPosX(ImGui::GetWindowWidth() - 80.0f * ImGuiScale());
@@ -251,6 +233,46 @@ namespace dusk {
ImGui::EndMainMenuBar();
}
if (!dusk::IsGameLaunched) {
m_preLaunchWindow.draw();
}
if (!m_isLaunchInitialized && !getSettings().backend.wasPresetChosen) {
if (dusk::IsGameLaunched) {
m_firstRunPreset.draw();
}
return;
}
if (!m_isLaunchInitialized) {
m_toasts.emplace_back("Press F1 to toggle menu"s, 5.f);
m_isLaunchInitialized = true;
}
m_menuGame.windowControllerConfig();
m_menuGame.windowInputViewer();
if (dusk::IsGameLaunched) {
m_menuTools.ShowDebugOverlay();
m_menuTools.ShowCameraOverlay();
m_menuTools.ShowProcessManager();
m_menuTools.ShowHeapOverlay();
m_menuTools.ShowStubLog();
m_menuTools.ShowMapLoader();
m_menuTools.ShowPlayerInfo();
m_menuTools.ShowAudioDebug();
m_menuTools.ShowSaveEditor();
}
DuskDebugPad(); // temporary, remove later
// Only show cursor when menu or any windows are open
if (showMenu || ImGui::GetIO().MetricsRenderWindows > 0) {
ImGui::GetIO().ConfigFlags &= ~ImGuiConfigFlags_NoMouseCursorChange;
// Imgui will re-show cursor.
} else {
ImGui::GetIO().ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange;
SDL_HideCursor();
}
ShowToasts();
}
@@ -290,6 +312,70 @@ namespace dusk {
}
}
std::string_view backend_id(AuroraBackend backend) {
switch (backend) {
default:
return "auto"sv;
case BACKEND_D3D12:
return "d3d12"sv;
case BACKEND_D3D11:
return "d3d11"sv;
case BACKEND_METAL:
return "metal"sv;
case BACKEND_VULKAN:
return "vulkan"sv;
case BACKEND_OPENGL:
return "opengl"sv;
case BACKEND_OPENGLES:
return "opengles"sv;
case BACKEND_WEBGPU:
return "webgpu"sv;
case BACKEND_NULL:
return "null"sv;
}
}
bool try_parse_backend(std::string_view backend, AuroraBackend& outBackend) {
if (backend == "auto") {
outBackend = BACKEND_AUTO;
return true;
}
if (backend == "d3d11") {
outBackend = BACKEND_D3D11;
return true;
}
if (backend == "d3d12") {
outBackend = BACKEND_D3D12;
return true;
}
if (backend == "metal") {
outBackend = BACKEND_METAL;
return true;
}
if (backend == "vulkan") {
outBackend = BACKEND_VULKAN;
return true;
}
if (backend == "opengl") {
outBackend = BACKEND_OPENGL;
return true;
}
if (backend == "opengles") {
outBackend = BACKEND_OPENGLES;
return true;
}
if (backend == "webgpu") {
outBackend = BACKEND_WEBGPU;
return true;
}
if (backend == "null") {
outBackend = BACKEND_NULL;
return true;
}
return false;
}
void ImGuiConsole::ShowToasts() {
if (m_toasts.empty()) {
return;
@@ -333,7 +419,7 @@ namespace dusk {
void ImGuiConsole::ShowPipelineProgress() {
const auto* stats = aurora_get_stats();
const u32 queuedPipelines = stats->queuedPipelines;
if (queuedPipelines == 0) {
if (queuedPipelines == 0 || !getSettings().backend.showPipelineCompilation) {
return;
}
const u32 createdPipelines = stats->createdPipelines;
+7 -1
View File
@@ -4,18 +4,19 @@
#include <aurora/aurora.h>
#include <deque>
#include <string>
#include <string_view>
#include "ImGuiFirstRunPreset.hpp"
#include "ImGuiMenuEnhancements.hpp"
#include "ImGuiMenuGame.hpp"
#include "ImGuiMenuTools.hpp"
#include "ImGuiPreLaunchWindow.hpp"
#include "imgui.h"
namespace dusk {
class ImGuiConsole {
public:
ImGuiConsole();
void InitSettings();
void UpdateSettings();
void PreDraw();
void PostDraw();
@@ -38,6 +39,7 @@ private:
ImGuiFirstRunPreset m_firstRunPreset;
ImGuiMenuGame m_menuGame;
ImGuiMenuEnhancements m_menuEnhancements;
ImGuiPreLaunchWindow m_preLaunchWindow;
// Keep always last
ImGuiMenuTools m_menuTools;
@@ -49,12 +51,16 @@ private:
extern ImGuiConsole g_imguiConsole;
std::string_view backend_name(AuroraBackend backend);
std::string_view backend_id(AuroraBackend backend);
bool try_parse_backend(std::string_view backend, AuroraBackend& outBackend);
std::string BytesToString(size_t bytes);
void SetOverlayWindowLocation(int corner);
bool ShowCornerContextMenu(int& corner, int avoidCorner);
void ImGuiStringViewText(std::string_view text);
void ImGuiBeginGroupPanel(const char* name, const ImVec2& size);
void ImGuiEndGroupPanel();
void ImGuiTextCenter(std::string_view text);
bool ImGuiButtonCenter(std::string_view text);
float ImGuiScale();
} // namespace dusk
+1 -8
View File
@@ -6,13 +6,6 @@
#include "ImGuiMenuGame.hpp"
namespace dusk {
void TextCenter(const std::string& text) {
float font_size = ImGui::GetFontSize() * text.size() / 2;
ImGui::SameLine(ImGui::GetWindowSize().x / 2 - font_size + (font_size / 2));
ImGui::TextUnformatted(text.c_str());
}
void ImGuiMenuGame::windowInputViewer() {
if (!m_showInputViewer) {
return;
@@ -35,7 +28,7 @@ namespace dusk {
if (ImGui::Begin("Input Viewer", nullptr, windowFlags)) {
float scale = ImGuiScale();
if (!m_controllerName.empty()) {
TextCenter(m_controllerName);
ImGuiTextCenter(m_controllerName);
ImGui::Separator();
}
+52 -54
View File
@@ -6,6 +6,7 @@
#include <aurora/imgui.h>
#include <cmath>
#include <cstring>
#include <fmt/format.h>
#include <string>
#include "dusk/logging.h"
@@ -32,66 +33,64 @@ bool AssetExists(const std::string& path) {
ImFont* ImGuiEngine::fontNormal;
ImFont* ImGuiEngine::fontLarge;
ImTextureID ImGuiEngine::duskIcon;
ImFont* ImGuiEngine::fontExtraLarge;
ImFont* ImGuiEngine::fontMono;
ImTextureID ImGuiEngine::duskIcon = 0;
inline ImFont* CreateFont(float size, const std::string& fontPath, std::string_view fontName) {
bool fontFileExists = !fontPath.empty() && AssetExists(fontPath);
ImFontConfig fontConfig{};
fontConfig.SizePixels = size;
auto name = fmt::format_to_n(fontConfig.Name, sizeof(fontConfig.Name) - 1, "{}, {}px", fontName,
static_cast<int>(fontConfig.SizePixels));
*name.out = '\0';
const ImGuiIO& io = ImGui::GetIO();
ImFont* outFont =
fontFileExists ?
io.Fonts->AddFontFromFileTTF(fontPath.c_str(), fontConfig.SizePixels, &fontConfig) :
nullptr;
if (outFont == nullptr) {
if (fontFileExists) {
DuskLog.warn("Failed to load font '{}': {}", fontPath, SDL_GetError());
}
outFont = io.Fonts->AddFontDefault(&fontConfig);
}
return outFont;
}
void ImGuiEngine_Initialize(float scale) {
// Round font scale to nearest integer
scale = std::ceilf(scale);
ImGui::GetCurrentContext();
ImGuiIO& io = ImGui::GetIO();
io.Fonts->Clear();
io.FontGlobalScale = scale > 0.0f ? 1.0f / scale : 1.0f;
const std::string fontPath = GetAssetPath("NotoMono-Regular.ttf");
const bool hasFontFile = AssetExists(fontPath);
ImFontConfig fontConfig{};
fontConfig.SizePixels = std::floor(15.f * scale);
snprintf(static_cast<char*>(fontConfig.Name), sizeof(fontConfig.Name),
"Noto Mono Regular, %dpx", static_cast<int>(fontConfig.SizePixels));
ImGuiEngine::fontNormal =
hasFontFile ?
io.Fonts->AddFontFromFileTTF(fontPath.c_str(), fontConfig.SizePixels, &fontConfig) :
nullptr;
if (ImGuiEngine::fontNormal == nullptr) {
if (hasFontFile) {
DuskLog.warn("Failed to load font '{}': {}", fontPath, SDL_GetError());
}
ImGuiEngine::fontNormal = io.Fonts->AddFontDefault(&fontConfig);
}
fontConfig.SizePixels = std::floor(26.f * scale);
#ifdef IMGUI_ENABLE_FREETYPE
fontConfig.FontBuilderFlags |= ImGuiFreeTypeBuilderFlags_Bold;
snprintf(static_cast<char*>(fontConfig.Name), sizeof(fontConfig.Name), "Noto Mono Bold, %dpx",
static_cast<int>(fontConfig.SizePixels));
#else
snprintf(static_cast<char*>(fontConfig.Name), sizeof(fontConfig.Name),
"Noto Mono Regular, %dpx", static_cast<int>(fontConfig.SizePixels));
#endif
CreateFont(std::floor(18.f * scale), GetAssetPath("Inter-Regular.ttf"), "Inter Regular");
ImGuiEngine::fontLarge =
hasFontFile ?
io.Fonts->AddFontFromFileTTF(fontPath.c_str(), fontConfig.SizePixels, &fontConfig) :
nullptr;
if (ImGuiEngine::fontLarge == nullptr) {
if (hasFontFile) {
DuskLog.warn("Failed to load font '{}': {}", fontPath, SDL_GetError());
}
ImGuiEngine::fontLarge = io.Fonts->AddFontDefault(&fontConfig);
}
CreateFont(std::floor(26.f * scale), GetAssetPath("Inter-Regular.ttf"), "Inter Regular");
ImGuiEngine::fontExtraLarge =
CreateFont(std::floor(40.f * scale), GetAssetPath("Inter-Bold.ttf"), "Inter Bold");
ImGuiEngine::fontMono =
CreateFont(std::floor(16.f * scale), GetAssetPath("NotoMono-Regular.ttf"),
"Noto Mono Regular");
auto& style = ImGui::GetStyle();
style = {}; // Reset sizes
style.WindowPadding = ImVec2(15, 15);
style.WindowRounding = 5.0f;
style.FrameBorderSize = 1.f;
style.FramePadding = ImVec2(5, 5);
style.FramePadding = ImVec2(8, 5);
style.FrameRounding = 4.0f;
style.ItemSpacing = ImVec2(12, 8);
style.ItemInnerSpacing = ImVec2(8, 6);
style.IndentSpacing = 25.0f;
style.ScrollbarSize = 15.0f;
style.ScrollbarRounding = 9.0f;
style.GrabMinSize = 5.0f;
style.GrabRounding = 3.0f;
style.GrabMinSize = 20.0f;
style.GrabRounding = 5.0f;
style.PopupBorderSize = 1.f;
style.PopupRounding = 7.0;
style.TabBorderSize = 1.f;
@@ -145,26 +144,24 @@ void ImGuiEngine_Initialize(float scale) {
colors[ImGuiCol_NavHighlight] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
colors[ImGuiCol_NavWindowingHighlight] = ImVec4(1.00f, 1.00f, 1.00f, 0.70f);
colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.20f);
colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.60f);
colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.35f);
}
Icon GetIcon() {
const std::string iconPath = GetAssetPath("icon.png");
if (!AssetExists(iconPath)) {
Image GetImage(const std::string& path) {
if (!AssetExists(path)) {
return {};
}
SDL_Surface* loadedSurface = SDL_LoadPNG(iconPath.c_str());
SDL_Surface* loadedSurface = SDL_LoadPNG(path.c_str());
if (loadedSurface == nullptr) {
DuskLog.warn("Failed to load icon '{}': {}", iconPath, SDL_GetError());
DuskLog.warn("Failed to load image '{}': {}", path, SDL_GetError());
return {};
}
SDL_Surface* rgbaSurface = SDL_ConvertSurface(loadedSurface, SDL_PIXELFORMAT_RGBA32);
SDL_DestroySurface(loadedSurface);
if (rgbaSurface == nullptr) {
DuskLog.warn("Failed to convert icon '{}': {}", iconPath, SDL_GetError());
DuskLog.warn("Failed to convert image '{}': {}", path, SDL_GetError());
return {};
}
@@ -181,7 +178,7 @@ Icon GetIcon() {
}
SDL_DestroySurface(rgbaSurface);
return Icon{
return Image{
std::move(ptr),
size,
iconWidth,
@@ -190,12 +187,13 @@ Icon GetIcon() {
}
void ImGuiEngine_AddTextures() {
auto icon = GetIcon();
if (icon.data == nullptr || icon.width == 0 || icon.height == 0) {
ImGuiEngine::duskIcon = 0;
return;
if (ImGuiEngine::duskIcon == 0) {
auto icon = GetImage(GetAssetPath("icon.png"));
if (icon.data == nullptr || icon.width == 0 || icon.height == 0) {
ImGuiEngine::duskIcon = 0;
return;
}
ImGuiEngine::duskIcon = aurora_imgui_add_texture(icon.width, icon.height, icon.data.get());
}
ImGuiEngine::duskIcon = aurora_imgui_add_texture(icon.width, icon.height, icon.data.get());
}
} // namespace dusk
+4 -2
View File
@@ -9,17 +9,19 @@ class ImGuiEngine {
public:
static ImFont* fontNormal;
static ImFont* fontLarge;
static ImFont* fontExtraLarge;
static ImFont* fontMono;
static ImTextureID duskIcon;
};
void ImGuiEngine_Initialize(float scale);
void ImGuiEngine_AddTextures();
struct Icon {
struct Image {
std::unique_ptr<uint8_t[]> data;
size_t size;
uint32_t width;
uint32_t height;
};
Icon GetIcon();
Image GetImage(std::string_view path);
} // namespace dusk
+4
View File
@@ -118,8 +118,12 @@ void ImGuiFirstRunPreset::draw() {
if (chosen == 0) ApplyPresetVanilla();
if (chosen == 1) ApplyPresetDefault();
if (chosen == 2) ApplyPresetQoL();
getSettings().backend.wasPresetChosen.setValue(true);
config::Save();
m_done = true;
ImGui::CloseCurrentPopup();
}
+1 -1
View File
@@ -16,7 +16,7 @@ namespace dusk {
ImGuiWindowFlags windowFlags = ImGuiWindowFlags_AlwaysAutoResize |
ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav;
ImGui::SetNextWindowBgAlpha(0.65f);
// ImGui::SetNextWindowBgAlpha(0.65f);
if (!ImGui::Begin("Map Loader", &m_showMapLoader, windowFlags)) {
ImGui::End();
+29 -21
View File
@@ -14,48 +14,48 @@ namespace dusk {
config::ImGuiCheckbox("Bigger Wallets", getSettings().game.biggerWallets);
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("Wallet sizes are like in the HD version (500, 1000, 2000)");
ImGui::SetTooltip("Wallet sizes are like in the HD version. (500, 1000, 2000)");
}
config::ImGuiCheckbox("No Rupee Returns", getSettings().game.noReturnRupees);
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("Always collect Rupees even if your Wallet is too full");
ImGui::SetTooltip("Always collect Rupees even if your Wallet is too full.");
}
config::ImGuiCheckbox("Disable Rupee Cutscenes", getSettings().game.disableRupeeCutscenes);
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("Rupees won't play cutscenes after you've collected them the first time");
ImGui::SetTooltip("Rupees won't play cutscenes after you've collected them the first time.");
}
config::ImGuiCheckbox("No Sword Recoil", getSettings().game.noSwordRecoil);
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("Link won't recoil when his sword hits walls");
ImGui::SetTooltip("Link won't recoil when his sword hits walls.");
}
config::ImGuiCheckbox("Faster Climbing", getSettings().game.fastClimbing);
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("Quicker climbing on ladders and vines like the HD version");
ImGui::SetTooltip("Quicker climbing on ladders and vines like the HD version.");
}
config::ImGuiCheckbox("No Climbing Miss Animation", getSettings().game.noMissClimbing);
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("Prevents Link from playing a struggle animation\n"
"when using the Clawshot on vines at a weird angle");
"when grabbing ledges or climbing on vines.");
}
config::ImGuiCheckbox("Faster Tears of Light", getSettings().game.fastTears);
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("Tears of Light dropped by Shadow Insects pop out faster like the HD version");
ImGui::SetTooltip("Tears of Light dropped by Shadow Insects pop out faster like the HD version.");
}
config::ImGuiCheckbox("Hide TV Settings Screen", getSettings().game.hideTvSettingsScreen);
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("Hides the TV calibration screen shown when loading a save");
ImGui::SetTooltip("Hides the TV calibration screen shown when loading a save.");
}
config::ImGuiCheckbox("Instant Saves", getSettings().game.instantSaves);
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("Skip the delay when writing to the Memory Card");
ImGui::SetTooltip("Skip the delay when writing to the Memory Card.");
}
ImGui::EndMenu();
@@ -64,7 +64,7 @@ namespace dusk {
if (ImGui::BeginMenu("Preferences")) {
config::ImGuiCheckbox("Mirror Mode", getSettings().game.enableMirrorMode);
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("Mirrors the world, matching the Wii version of the game");
ImGui::SetTooltip("Mirrors the world, matching the Wii version of the game.");
}
config::ImGuiCheckbox("Invert Camera X Axis", getSettings().game.invertCameraXAxis);
@@ -73,12 +73,16 @@ namespace dusk {
}
if (ImGui::BeginMenu("Graphics")) {
config::ImGuiCheckbox("Native Bloom", getSettings().game.enableBloom);
config::ImGuiCheckbox("Unlock Framerate", getSettings().game.enableFrameInterpolation);
const bool frameInterpolationHovered = ImGui::IsItemHovered();
config::ImGuiCheckbox("Water Projection Offset", getSettings().game.useWaterProjectionOffset);
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("Adds GC-specific -0.01 transS offset\n"
"that causes ~6px ghost artifacts in water reflections");
ImGui::SameLine();
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1.0f, 0.72f, 0.2f, 1.0f));
ImGui::TextUnformatted("[EXPERIMENTAL]");
ImGui::PopStyleColor();
if (frameInterpolationHovered || ImGui::IsItemHovered()) {
ImGui::SetTooltip("Uses inter-frame interpolation to enable higher frame rates.\nVisual artifacts, animation glitches, or instability may occur.");
}
ImGui::EndMenu();
@@ -87,12 +91,12 @@ namespace dusk {
if (ImGui::BeginMenu("Audio")) {
config::ImGuiCheckbox("No Low HP Sound", getSettings().game.noLowHpSound);
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("Disable the beeping sound when having low health");
ImGui::SetTooltip("Disable the beeping sound when having low health.");
}
config::ImGuiCheckbox("Non-Stop Midna's Lament", getSettings().game.midnasLamentNonStop);
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("Prevents enemy music while Midna's Lament is playing");
ImGui::SetTooltip("Prevents enemy music while Midna's Lament is playing.");
}
ImGui::EndMenu();
@@ -103,7 +107,7 @@ namespace dusk {
config::ImGuiCheckbox("Can Transform Anywhere", getSettings().game.canTransformAnywhere);
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("Allows you to transform even if NPCs are looking");
ImGui::SetTooltip("Allows you to transform even if NPCs are looking.");
}
config::ImGuiCheckbox("Fast Spinner", getSettings().game.fastSpinner);
@@ -124,7 +128,7 @@ namespace dusk {
config::ImGuiCheckbox("Instant Death", getSettings().game.instantDeath);
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("Any hit will instantly kill you");
ImGui::SetTooltip("Any hit will instantly kill you.");
}
ImGui::EndMenu();
@@ -134,7 +138,7 @@ namespace dusk {
config::ImGuiCheckbox("Restore Wii 1.0 Glitches", getSettings().game.restoreWiiGlitches);
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("Restores patched glitches from Wii USA 1.0,\n"
"the first released version");
"the first released version.");
}
ImGui::EndMenu();
@@ -142,6 +146,10 @@ namespace dusk {
if (ImGui::BeginMenu("Tools")) {
config::ImGuiCheckbox("Enable Turbo Key", getSettings().game.enableTurboKeybind);
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("Holding TAB will speed up the game.\n"
"This will not work with the \"Unlock Framerate\" enhancement.");
}
ImGui::EndMenu();
}
+38 -15
View File
@@ -17,6 +17,8 @@
#include <aurora/gfx.h>
#include "dusk/main.h"
namespace dusk {
void ImGuiMenuGame::ToggleFullscreen() {
getSettings().video.enableFullscreen.setValue(!getSettings().video.enableFullscreen);
@@ -28,12 +30,6 @@ namespace dusk {
void ImGuiMenuGame::draw() {
if (ImGui::BeginMenu("Game")) {
if (ImGui::MenuItem("Reset", hotkeys::DO_RESET)) {
JUTGamePad::C3ButtonReset::sResetSwitchPushing = true;
}
ImGui::Separator();
if (ImGui::BeginMenu("Graphics")) {
if (ImGui::MenuItem("Toggle Fullscreen", hotkeys::TOGGLE_FULLSCREEN)) {
ToggleFullscreen();
@@ -66,6 +62,14 @@ namespace dusk {
config::Save();
}
config::ImGuiCheckbox("Native Bloom", getSettings().game.enableBloom);
config::ImGuiCheckbox("Water Projection Offset", getSettings().game.useWaterProjectionOffset);
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("Adds GC-specific -0.01 transS offset\n"
"that causes ~6px ghost artifacts in water reflections.");
}
ImGui::EndMenu();
}
@@ -107,11 +111,25 @@ namespace dusk {
ImGui::EndMenu();
}
if (ImGui::BeginMenu("Interface")) {
config::ImGuiCheckbox("Skip Pre-Launch UI", getSettings().backend.skipPreLaunchUI);
config::ImGuiCheckbox("Show Pipeline Compilation", getSettings().backend.showPipelineCompilation);
ImGui::EndMenu();
}
ImGui::Separator();
if (ImGui::MenuItem("Reset", hotkeys::DO_RESET)) {
JUTGamePad::C3ButtonReset::sResetSwitchPushing = true;
}
if (ImGui::MenuItem("Exit")) {
dusk::IsRunning = false;
}
ImGui::EndMenu();
}
windowInputViewer();
windowControllerConfig();
}
static void drawVirtualStick(const char* id, const ImVec2& stick) {
@@ -176,7 +194,7 @@ namespace dusk {
ImGuiWindowFlags_NoResize |
ImGuiWindowFlags_AlwaysAutoResize;
ImGui::SetNextWindowBgAlpha(0.65f);
// ImGui::SetNextWindowBgAlpha(0.65f);
if (!ImGui::Begin("Controller Config", &m_showControllerConfig, windowFlags)) {
ImGui::End();
@@ -259,6 +277,7 @@ namespace dusk {
// buttons panel
const float uiButtonSize = 40 * scale;
ImVec2 btnSize(110.0f * scale, 30.0f * scale);
ImGuiBeginGroupPanel("Buttons", ImVec2(150 * scale, 20 * scale));
@@ -281,10 +300,14 @@ namespace dusk {
if (m_controllerConfig.m_isReading && m_controllerConfig.m_pendingButtonMapping == &btnMappingList[i]) {
dispName = fmt::format("Press a Key...##{}", btnName);
} else {
dispName = fmt::format("{0}##-{1}", PADGetNativeButtonName(btnMappingList[i].nativeButton), i);
const char* nativeName = PADGetNativeButtonName(btnMappingList[i].nativeButton);
if (nativeName == nullptr) {
nativeName = "[unbound]";
}
dispName = fmt::format("{0}##-{1}", nativeName, i);
}
bool pressed = ImGui::Button(dispName.c_str(),
ImVec2(100.0f * scale, 20.0f * scale));
btnSize);
if (pressed) {
m_controllerConfig.m_isReading = true;
@@ -324,7 +347,7 @@ namespace dusk {
dispName = fmt::format("{0}##-{1}", PADGetNativeAxisName(axisMappingList[trigger].nativeAxis), trigger);
}
bool pressed = ImGui::Button(dispName.c_str(),
ImVec2(100.0f * scale, 20.0f * scale));
btnSize);
if (pressed) {
m_controllerConfig.m_isReading = true;
@@ -401,7 +424,7 @@ namespace dusk {
dispName = fmt::format("{0}##-{1}", PADGetNativeButtonName(axisMappingList[axis].nativeButton), axis);
}
}
bool pressed = ImGui::Button(dispName.c_str(), ImVec2(100.0f * scale, 20.0f * scale));
bool pressed = ImGui::Button(dispName.c_str(), btnSize);
if (pressed) {
m_controllerConfig.m_isReading = true;
@@ -463,7 +486,7 @@ namespace dusk {
dispName = fmt::format("{0}##-{1}", PADGetNativeButtonName(axisMappingList[axis].nativeButton), axis);
}
}
bool pressed = ImGui::Button(fmt::format("{0}##sub{1}", dispName, label).c_str(), ImVec2(100.0f * scale, 20.0f * scale));
bool pressed = ImGui::Button(fmt::format("{0}##sub{1}", dispName, label).c_str(), btnSize);
if (pressed) {
m_controllerConfig.m_isReading = true;
+34 -41
View File
@@ -7,21 +7,22 @@
#include "ImGuiConsole.hpp"
#include "ImGuiMenuTools.hpp"
#include "ImGuiEngine.hpp"
#include "d/actor/d_a_alink.h"
#include "d/actor/d_a_horse.h"
#include "d/d_com_inf_game.h"
#include "dusk/dusk.h"
#include "dusk/main.h"
#include "m_Do/m_Do_main.h"
namespace dusk {
ImGuiMenuTools::ImGuiMenuTools() {}
void ImGuiMenuTools::draw() {
bool isToggleDevelopmentMode = false;
if (ImGui::BeginMenu("Debug")) {
if (ImGui::Checkbox("Development Mode", &m_isDevelopmentMode)) {
isToggleDevelopmentMode = true;
bool developmentMode = mDoMain::developmentMode == 1;
if (ImGui::Checkbox("Development Mode", &developmentMode)) {
mDoMain::developmentMode = developmentMode ? 1 : -1;
}
ImGui::Separator();
@@ -40,6 +41,10 @@ namespace dusk {
ImGui::EndMenu();
}
if (!dusk::IsGameLaunched) {
ImGui::BeginDisabled();
}
ImGui::MenuItem("Process Management", hotkeys::SHOW_PROCESS_MANAGEMENT, &m_showProcessManagement);
ImGui::MenuItem("Debug Overlay", hotkeys::SHOW_DEBUG_OVERLAY, &m_showDebugOverlay);
ImGui::MenuItem("Heap Viewer", hotkeys::SHOW_HEAP_VIEWER, &m_showHeapOverlay);
@@ -49,28 +54,14 @@ namespace dusk {
ImGui::MenuItem("Player Info", nullptr, &m_showPlayerInfo);
ImGui::MenuItem("Save Editor", nullptr, &m_showSaveEditor);
ImGui::MenuItem("Audio Debug", hotkeys::SHOW_AUDIO_DEBUG, &m_showAudioDebug);
if (!dusk::IsGameLaunched) {
ImGui::EndDisabled();
}
ImGui::MenuItem("OSReport Force", nullptr, &OSReportReallyForceEnable);
ImGui::EndMenu();
}
if (isToggleDevelopmentMode) {
mDoMain::developmentMode = m_isDevelopmentMode ? 1 : -1;
}
ShowDebugOverlay();
ShowCameraOverlay();
ShowProcessManager();
ShowHeapOverlay();
ShowStubLog();
ShowMapLoader();
ShowPlayerInfo();
ShowAudioDebug();
if (m_showSaveEditor) {
m_saveEditor.draw(m_showSaveEditor);
}
DuskDebugPad(); // temporary, remove later
}
void ImGuiMenuTools::ShowDebugOverlay() {
@@ -78,6 +69,8 @@ namespace dusk {
return;
}
ImGui::PushFont(ImGuiEngine::fontMono);
ImGuiIO& io = ImGui::GetIO();
ImGuiWindowFlags windowFlags = ImGuiWindowFlags_NoDecoration |
ImGuiWindowFlags_AlwaysAutoResize |
@@ -90,26 +83,14 @@ namespace dusk {
ImGui::SetNextWindowBgAlpha(0.65f);
if (ImGui::Begin("Debug Overlay", nullptr, windowFlags)) {
bool hasPrevious = false;
if (hasPrevious) {
ImGui::Separator();
}
hasPrevious = true;
ImGuiStringViewText(fmt::format(FMT_STRING("FPS: {:.2f}\n"), io.Framerate));
ImGuiStringViewText(fmt::format(FMT_STRING("Frame usage: {:.1f}%\n"), frameUsagePct));
if (hasPrevious) {
ImGui::Separator();
}
hasPrevious = true;
ImGui::Separator();
ImGuiStringViewText(fmt::format(FMT_STRING("Backend: {}\n"), backend_name(aurora_get_backend())));
if (hasPrevious) {
ImGui::Separator();
}
hasPrevious = true;
ImGui::Separator();
const auto& stats = lastFrameAuroraStats;
@@ -141,6 +122,8 @@ namespace dusk {
ShowCornerContextMenu(m_debugOverlayCorner, m_cameraOverlayCorner);
}
ImGui::End();
ImGui::PopFont();
}
void ImGuiMenuTools::ShowPlayerInfo() {
@@ -148,13 +131,20 @@ namespace dusk {
return;
}
ImGuiIO& io = ImGui::GetIO();
ImGuiWindowFlags windowFlags =
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_AlwaysAutoResize;
ImGui::PushFont(ImGuiEngine::fontMono);
ImGuiWindowFlags windowFlags = ImGuiWindowFlags_NoDecoration |
ImGuiWindowFlags_AlwaysAutoResize |
ImGuiWindowFlags_NoFocusOnAppearing |
ImGuiWindowFlags_NoNav;
if (m_playerInfoOverlayCorner != -1) {
SetOverlayWindowLocation(m_playerInfoOverlayCorner);
windowFlags |= ImGuiWindowFlags_NoMove;
}
ImGui::SetNextWindowBgAlpha(0.65f);
if (ImGui::Begin("Player Info", &m_showPlayerInfo, windowFlags)) {
if (ImGui::Begin("Player Info", nullptr, windowFlags)) {
daAlink_c* player = (daAlink_c*)dComIfGp_getPlayer(0);
daHorse_c* horse = dComIfGp_getHorseActor();
@@ -196,8 +186,11 @@ namespace dusk {
? fmt::format("Speed: {0}\n", horse->speedF)
: "Speed: ?\n"
);
ShowCornerContextMenu(m_playerInfoOverlayCorner, m_debugOverlayCorner);
}
ImGui::End();
ImGui::PopFont();
}
}
+2 -1
View File
@@ -22,6 +22,7 @@ namespace dusk {
void ShowMapLoader();
void ShowPlayerInfo();
void ShowAudioDebug();
void ShowSaveEditor();
private:
bool m_showDebugOverlay = false;
@@ -51,8 +52,8 @@ namespace dusk {
bool showInternalNames = false;
} m_mapLoaderInfo;
bool m_isDevelopmentMode = false;
bool m_showPlayerInfo = false;
int m_playerInfoOverlayCorner = 1; // top-right
bool m_showSaveEditor = false;
ImGuiSaveEditor m_saveEditor;
+194
View File
@@ -0,0 +1,194 @@
#include "imgui.h"
#include "ImGuiConfig.hpp"
#include "ImGuiEngine.hpp"
#include "ImGuiPreLaunchWindow.hpp"
#include "ImGuiConsole.hpp"
#include "dusk/main.h"
#include "dusk/settings.h"
#include <SDL3/SDL_dialog.h>
#include <SDL3/SDL_error.h>
#include <SDL3/SDL_filesystem.h>
#include "aurora/lib/internal.hpp"
#include "aurora/lib/window.hpp"
namespace dusk {
typedef void (ImGuiPreLaunchWindow::*drawFunc)();
drawFunc drawTable[2] = {&ImGuiPreLaunchWindow::drawMainMenu, &ImGuiPreLaunchWindow::drawOptions};
static constexpr std::array<SDL_DialogFileFilter, 2> skGameDiscFileFilters{{
{"Game Disc Images", "iso;gcm;ciso;gcz;nfs;rvz;wbfs;wia;tgc"},
{"All Files", "*"},
}};
void fileDialogCallback(void* userdata, const char* const* filelist, [[maybe_unused]] int filter) {
auto* self = static_cast<ImGuiPreLaunchWindow*>(userdata);
if (filelist != nullptr) {
if (filelist[0] == nullptr) {
// Cancelled
self->m_selectedIsoPath.clear();
} else {
self->m_selectedIsoPath = filelist[0];
getSettings().backend.isoPath.setValue(self->m_selectedIsoPath);
config::Save();
}
} else {
// Error occurred
self->m_selectedIsoPath.clear();
self->m_errorString = fmt::format("File dialog error: {}", SDL_GetError());
}
}
ImGuiPreLaunchWindow::ImGuiPreLaunchWindow() = default;
bool ImGuiPreLaunchWindow::isSelectedPathValid() const {
return !m_selectedIsoPath.empty() && SDL_GetPathInfo(m_selectedIsoPath.c_str(), nullptr);
}
void ImGuiPreLaunchWindow::draw() {
if (m_IsFirstDraw) {
m_selectedIsoPath = getSettings().backend.isoPath;
m_initialGraphicsBackend = getSettings().backend.graphicsBackend;
m_IsFirstDraw = false;
}
if (isSelectedPathValid() && getSettings().backend.skipPreLaunchUI) {
dusk::IsGameLaunched = true;
return;
}
auto& io = ImGui::GetIO();
ImGui::SetNextWindowSize(ImVec2(io.DisplaySize.x, io.DisplaySize.y));
ImGui::SetNextWindowPos(ImVec2(0, 0));
ImGui::SetNextWindowBgAlpha(0.65f);
ImGui::Begin("Pre Launch Window", nullptr,
ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoResize |
ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing |
ImGuiWindowFlags_NoBringToFrontOnFocus);
const auto& windowSize = ImGui::GetWindowSize();
for (int i = 0; i < 5; i++)
ImGui::NewLine();
float iconSize = 150.f;
ImGui::SameLine(windowSize.x / 2 - iconSize + (iconSize / 2));
if (ImGuiEngine::duskIcon != 0)
ImGui::Image(ImGuiEngine::duskIcon, ImVec2{iconSize, iconSize});
ImGuiTextCenter("Twilit Realm presents");
ImGui::PushFont(ImGuiEngine::fontExtraLarge);
ImGuiTextCenter("Dusk");
ImGui::PopFont();
(this->*drawTable[m_CurMenu])();
ImGui::End();
}
void ImGuiPreLaunchWindow::drawMainMenu() {
const auto& windowSize = ImGui::GetWindowSize();
ImGui::SetCursorPosY(windowSize.y - 200);
ImGui::PushFont(ImGuiEngine::fontLarge);
if (m_selectedIsoPath.empty() || !SDL_GetPathInfo(m_selectedIsoPath.c_str(), nullptr)) {
if (ImGuiButtonCenter("Select disc image...")) {
SDL_ShowOpenFileDialog(&fileDialogCallback, this, aurora::window::get_sdl_window(),
skGameDiscFileFilters.data(), int(skGameDiscFileFilters.size()),
nullptr, false);
}
} else {
if (ImGuiButtonCenter("Start game")) {
dusk::IsGameLaunched = true;
}
}
if (ImGuiButtonCenter("Options")) {
m_CurMenu = 1;
}
ImGui::PopFont();
}
void ImGuiPreLaunchWindow::drawOptions() {
const auto& windowSize = ImGui::GetWindowSize();
ImGui::NewLine();
ImGui::PushFont(ImGuiEngine::fontLarge);
ImGuiTextCenter("Options");
ImGui::Separator();
ImGui::PopFont();
auto cursorY = ImGui::GetCursorPosY();
float endCursorY = windowSize.y - 100;
float childWidth = windowSize.x - 400;
ImGui::SetCursorPosX(windowSize.x / 2 - (childWidth / 2));
if (ImGui::BeginChild("OptionsChild", ImVec2(childWidth, endCursorY - cursorY),
ImGuiChildFlags_None, ImGuiWindowFlags_NoBackground))
{
ImGui::InputText("Game ISO Path", &m_selectedIsoPath, ImGuiInputTextFlags_ReadOnly);
ImGui::SameLine();
if (ImGui::Button("Set")) {
SDL_ShowOpenFileDialog(&fileDialogCallback, this, aurora::window::get_sdl_window(),
skGameDiscFileFilters.data(), int(skGameDiscFileFilters.size()),
nullptr, false);
}
AuroraBackend configuredBackend = BACKEND_AUTO;
const std::string& configuredBackendId = getSettings().backend.graphicsBackend;
if (!try_parse_backend(configuredBackendId, configuredBackend)) {
configuredBackend = BACKEND_AUTO;
}
if (ImGui::BeginCombo("Graphics Backend", backend_name(configuredBackend).data())) {
if (ImGui::Selectable("Auto", configuredBackend == BACKEND_AUTO)) {
getSettings().backend.graphicsBackend.setValue("auto");
config::Save();
}
size_t backendCount = 0;
const AuroraBackend* availableBackends = aurora_get_available_backends(&backendCount);
for (size_t i = 0; i < backendCount; ++i) {
const AuroraBackend backend = availableBackends[i];
const bool isSelected = configuredBackend == backend;
if (ImGui::Selectable(backend_name(backend).data(), isSelected)) {
getSettings().backend.graphicsBackend.setValue(
std::string(backend_id(backend)));
config::Save();
}
if (isSelected) {
ImGui::SetItemDefaultFocus();
}
}
ImGui::EndCombo();
}
if (configuredBackendId != m_initialGraphicsBackend) {
ImGui::TextDisabled("Restart Required");
}
ImGui::EndChild();
}
ImGui::SetCursorPosY(endCursorY);
ImGui::NewLine();
ImGui::Separator();
ImGui::PushFont(ImGuiEngine::fontLarge);
if (ImGuiButtonCenter("Back")) {
m_CurMenu = 0;
}
ImGui::PopFont();
}
} // namespace dusk
+22
View File
@@ -0,0 +1,22 @@
#pragma once
namespace dusk {
class ImGuiPreLaunchWindow {
private:
int m_CurMenu = 0;
bool m_IsFirstDraw = true;
std::string m_initialGraphicsBackend;
bool isSelectedPathValid() const;
public:
ImGuiPreLaunchWindow();
void draw();
void drawMainMenu();
void drawOptions();
std::string m_selectedIsoPath;
std::string m_errorString;
};
} // namespace dusk
+1 -1
View File
@@ -287,7 +287,7 @@ namespace dusk {
ImGuiWindowFlags windowFlags =
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_AlwaysAutoResize;
ImGui::SetNextWindowBgAlpha(0.65f);
// ImGui::SetNextWindowBgAlpha(0.65f);
if (ImGui::Begin("Save Editor", &open, windowFlags)) {
if (ImGui::BeginTabBar("SaveEditorTabBar", ImGuiTabBarFlags_NoCloseWithMiddleMouseButton)) {
+3
View File
@@ -2,6 +2,8 @@
#include <cstdio>
#include <cstdlib>
#include "tracy/Tracy.hpp"
bool StubLogEnabled = true;
using namespace std::literals::string_view_literals;
@@ -32,6 +34,7 @@ static bool IsForStubLog(const char* message) {
void aurora_log_callback(AuroraLogLevel level, const char* module, const char* message,
unsigned int len) {
ZoneScoped;
if (StubLogEnabled && level != LOG_FATAL && IsForStubLog(message)) {
dusk::SendToStubLog(level, module, message);
return;
+16
View File
@@ -41,6 +41,7 @@ UserSettings g_userSettings = {
// Graphics
.enableBloom {"game.enableBloom", true},
.useWaterProjectionOffset {"game.useWaterProjectionOffset", false},
.enableFrameInterpolation = {"game.enableFrameInterpolation", false},
// Audio
.noLowHpSound {"game.noLowHpSound", false},
@@ -58,6 +59,14 @@ UserSettings g_userSettings = {
// Controls
.enableTurboKeybind {"game.enableTurboKeybind", false},
},
.backend = {
.isoPath {"backend.isoPath", ""},
.graphicsBackend {"backend.graphicsBackend", "auto"},
.skipPreLaunchUI {"backend.skipPreLaunchUI", false},
.showPipelineCompilation{"backend.showPipelineCompilation", false},
.wasPresetChosen{"backend.wasPresetChosen", false}
}
};
UserSettings& getSettings() {
@@ -103,6 +112,13 @@ void registerSettings() {
Register(g_userSettings.game.midnasLamentNonStop);
Register(g_userSettings.game.enableTurboKeybind);
Register(g_userSettings.game.fastSpinner);
Register(g_userSettings.game.enableFrameInterpolation);
Register(g_userSettings.backend.isoPath);
Register(g_userSettings.backend.graphicsBackend);
Register(g_userSettings.backend.skipPreLaunchUI);
Register(g_userSettings.backend.showPipelineCompilation);
Register(g_userSettings.backend.wasPresetChosen);
}
// Transient settings
+3
View File
@@ -13,6 +13,8 @@
#include <dusk/logging.h>
#include <dusk/main.h>
#include "tracy/Tracy.hpp"
#ifndef _WIN32
#include <sys/time.h>
#include <time.h>
@@ -355,6 +357,7 @@ void VISetNextFrameBuffer(void* fb) {
}
void VIWaitForRetrace() {
ZoneScoped;
sRetraceCount++;
if (sVIPreRetraceCallback) {
sVIPreRetraceCallback(sRetraceCount);
+35 -17
View File
@@ -1,26 +1,28 @@
#include "f_ap/f_ap_game.h"
#include <cstring>
#include "DynamicLink.h"
#include "JSystem/J3DGraphLoader/J3DModelLoader.h"
#include "JSystem/J3DGraphLoader/J3DModelSaver.h"
#include "JSystem/JHostIO/JORFile.h"
#include "JSystem/JKernel/JKRAram.h"
#include "JSystem/JKernel/JKRAramArchive.h"
#include "JSystem/JKernel/JKRSolidHeap.h"
#include "JSystem/JUtility/JUTDbPrint.h"
#include "SSystem/SComponent/c_counter.h"
#include "d/actor/d_a_alink.h"
#include "d/actor/d_a_grass.h"
#include "d/actor/d_a_midna.h"
#include "d/d_model.h"
#include "d/d_tresure.h"
#include "dusk/frame_interpolation.h"
#include "dusk/logging.h"
#include "f_op/f_op_camera_mng.h"
#include "f_op/f_op_draw_tag.h"
#include "f_op/f_op_overlap_mng.h"
#include "f_op/f_op_scene_mng.h"
#include "m_Do/m_Do_main.h"
#include "m_Do/m_Do_graphic.h"
#include "DynamicLink.h"
#include "JSystem/JKernel/JKRSolidHeap.h"
#include "JSystem/JKernel/JKRAram.h"
#include "JSystem/JKernel/JKRAramArchive.h"
#include "JSystem/JUtility/JUTDbPrint.h"
#include "JSystem/JHostIO/JORFile.h"
#include "JSystem/J3DGraphLoader/J3DModelLoader.h"
#include "JSystem/J3DGraphLoader/J3DModelSaver.h"
#include "d/actor/d_a_alink.h"
#include "d/actor/d_a_midna.h"
#include "d/d_model.h"
#include "d/actor/d_a_grass.h"
#include "d/d_tresure.h"
#include <cstring>
#include "dusk/logging.h"
#include "m_Do/m_Do_main.h"
#include "tracy/Tracy.hpp"
fapGm_HIO_c::fapGm_HIO_c() {
mUsingHostIO = true;
@@ -721,7 +723,19 @@ void fapGm_After() {
fopCamM_Management();
}
#ifdef TARGET_PC
static void fapGm_Before() {
dusk::frame_interp::begin_record();
}
static void fapGm_AfterRecord() {
dusk::frame_interp::end_record();
fapGm_After();
}
#endif
void fapGm_Execute() {
ZoneScoped;
static u32 sExecCount = 0;
if (sExecCount < 10 || (sExecCount % 300 == 0)) {
DuskLog.debug("fapGm_Execute frame={}", sExecCount);
@@ -750,7 +764,11 @@ void fapGm_Execute() {
}
#endif
fpcM_Management(NULL, fapGm_After);
#ifdef TARGET_PC
fpcM_Management(fapGm_Before, fapGm_AfterRecord);
#else
fpcM_ManagementFunc(NULL, fapGm_After);
#endif
cCt_Counter(0);
}
+7
View File
@@ -8,6 +8,7 @@
#include "f_pc/f_pc_leaf.h"
#include "f_pc/f_pc_node.h"
#include "f_pc/f_pc_pause.h"
#include "dusk/frame_interpolation.h"
#include <cstdio>
#include "dusk/logging.h"
@@ -25,7 +26,13 @@ int fpcDw_Execute(base_process_class* i_proc) {
}
fpcLy_SetCurrentLayer(i_proc->layer_tag.layer);
#ifdef TARGET_PC
dusk::frame_interp::open_child(i_proc, 0);
#endif
ret = draw_func(i_proc);
#ifdef TARGET_PC
dusk::frame_interp::close_child();
#endif
fpcLy_SetCurrentLayer(save_layer);
return ret;
}
+11 -3
View File
@@ -20,7 +20,8 @@
#include "f_pc/f_pc_pause.h"
#include "f_pc/f_pc_priority.h"
#include "m_Do/m_Do_controller_pad.h"
#include <cstdio>
#include "tracy/Tracy.hpp"
void fpcM_Draw(void* i_proc) {
fpcDw_Execute((base_process_class*)i_proc);
@@ -43,6 +44,7 @@ BOOL fpcM_IsCreating(fpc_ProcID i_id) {
}
void fpcM_Management(fpcM_ManagementFunc i_preExecuteFn, fpcM_ManagementFunc i_postExecuteFn) {
ZoneScoped;
MtxInit();
if (!fapGm_HIO_c::isCaptureScreen()) {
dComIfGd_peekZdata();
@@ -61,7 +63,14 @@ void fpcM_Management(fpcM_ManagementFunc i_preExecuteFn, fpcM_ManagementFunc i_p
l_dvdError = false;
}
cAPIGph_Painter();
#ifdef TARGET_PC
// Frame interpolation: call moved to m_Do_main
if (!dusk::getSettings().game.enableFrameInterpolation) {
#endif
cAPIGph_Painter();
#ifdef TARGET_PC
}
#endif
if (!dPa_control_c::isStatus(1)) {
fpcDt_Handler();
@@ -150,4 +159,3 @@ void* fpcM_JudgeInLayer(fpc_ProcID i_layerID, fpcCtIt_JudgeFunc i_judgeFunc, voi
return NULL;
}
+2
View File
@@ -12,6 +12,7 @@
#include "d/d_debug_viewer.h"
#include "m_Do/m_Do_Reset.h"
#include "m_Do/m_Do_dvd_thread.h"
#include "tracy/Tracy.hpp"
#if PLATFORM_WII || PLATFORM_SHIELD
#include "Z2AudioCS/Z2AudioCS.h"
@@ -157,6 +158,7 @@ static void mDoAud_Create() {
void mDoAud_Execute() {
DUSK_AUDIO_SKIP()
ZoneScoped;
if (!mDoAud_zelAudio_c::isInitFlag()) {
if (!mDoRst::isShutdown() && !mDoRst::isReturnToMenu()) {
+2
View File
@@ -10,6 +10,7 @@
#include "f_ap/f_ap_game.h"
#include "m_Do/m_Do_Reset.h"
#include "m_Do/m_Do_main.h"
#include "tracy/Tracy.hpp"
JUTGamePad* mDoCPd_c::m_gamePad[4];
@@ -56,6 +57,7 @@ void mDoCPd_c::create() {
}
void mDoCPd_c::read() {
ZoneScoped;
JUTGamePad::read();
if (!mDoRst::isReset() && mDoRst::is3ButtonReset()) {
+138 -29
View File
@@ -7,6 +7,9 @@
#include "d/dolzel.h" // IWYU pragma: keep
#include <base/PPCArch.h>
#include <cstring>
#include "DynamicLink.h"
#include "JSystem/J2DGraph/J2DOrthoGraph.h"
#include "JSystem/J2DGraph/J2DPrint.h"
#include "JSystem/JAWExtSystem/JAWExtSystem.h"
@@ -19,24 +22,25 @@
#include "SSystem/SComponent/c_math.h"
#include "d/actor/d_a_player.h"
#include "d/d_com_inf_game.h"
#include "d/d_menu_collect.h"
#include "d/d_debug_viewer.h"
#include "d/d_jcam_editor.h"
#include "d/d_jpreviewer.h"
#include <base/PPCArch.h>
#include "d/d_menu_collect.h"
#include "d/d_meter2_info.h"
#include "d/d_s_play.h"
#include "dusk/endian.h"
#include "dusk/gx_helper.h"
#include "dusk/logging.h"
#include "f_ap/f_ap_game.h"
#include "f_op/f_op_actor_mng.h"
#include "f_op/f_op_camera_mng.h"
#include "f_pc/f_pc_name.h"
#include "m_Do/m_Do_controller_pad.h"
#include "m_Do/m_Do_graphic.h"
#include "m_Do/m_Do_machine.h"
#include "m_Do/m_Do_main.h"
#include "d/d_debug_viewer.h"
#include "d/d_meter2_info.h"
#include "d/d_s_play.h"
#include "DynamicLink.h"
#include <cstring>
#include "dusk/endian.h"
#include "dusk/logging.h"
#include "dusk/gx_helper.h"
#include "dusk/frame_interpolation.h"
#include "tracy/Tracy.hpp"
#if PLATFORM_WII || PLATFORM_SHIELD
#include <revolution/sc.h>
@@ -348,6 +352,8 @@ void mDoGph_gInf_c::create() {
static bool data_80450BE8;
void mDoGph_gInf_c::beginRender() {
ZoneScoped;
#if PLATFORM_WII || PLATFORM_SHIELD
VISetTrapFilter(fapGmHIO_getTrapFilter() ? 1 : 0);
VISetGamma((VIGamma)fapGmHIO_getGamma());
@@ -416,6 +422,7 @@ void mDoGph_gInf_c::fadeOut(f32 fadeSpeed) {
}
void darwFilter(GXColor matColor) {
ZoneScoped;
GXSetNumChans(1);
GXSetChanCtrl(GX_COLOR0A0, GX_FALSE, GX_SRC_REG, GX_SRC_REG, GX_LIGHT_NULL, GX_DF_NONE,
GX_AF_NONE);
@@ -461,6 +468,51 @@ void darwFilter(GXColor matColor) {
GXEnd();
}
#ifdef TARGET_PC
static void mDoGph_AdvanceFadeState() {
if (mDoGph_gInf_c::isFade() != 0) {
f32 fade_rate = mDoGph_gInf_c::getFadeRate() + mDoGph_gInf_c::getFadeSpeed();
if (fade_rate < 0.0f) {
fade_rate = 0.0f;
mDoGph_gInf_c::offFade();
} else if (fade_rate > 1.0f) {
fade_rate = 1.0f;
}
mDoGph_gInf_c::setFadeRate(fade_rate);
mDoGph_gInf_c::getFadeColor().a = 255.0f * fade_rate;
} else {
GXColor& fade_color = mDoGph_gInf_c::getFadeColor();
if (dComIfG_getBrightness() != 255) {
fade_color.r = 0;
fade_color.g = 0;
fade_color.b = 0;
fade_color.a = 255 - dComIfG_getBrightness();
} else {
fade_color.a = 0;
}
}
}
static void mDoGph_AdvanceFadeState(u32 tick_count) {
for (u32 i = 0; i < tick_count; ++i) {
mDoGph_AdvanceFadeState();
}
}
static void mDoGph_DrawStoredFade() {
GXColor& fade_color = mDoGph_gInf_c::getFadeColor();
if (fade_color.a != 0) {
darwFilter(fade_color);
}
}
void mDoGph_gInf_c::calcFade() {
mDoGph_AdvanceFadeState();
mDoGph_DrawStoredFade();
}
#else
void mDoGph_gInf_c::calcFade() {
if (mDoGph_gInf_c::mFade != 0) {
mFadeRate += mFadeSpeed;
@@ -489,6 +541,7 @@ void mDoGph_gInf_c::calcFade() {
darwFilter(mFadeColor);
}
}
#endif
#if PLATFORM_WII || PLATFORM_SHIELD
u32 mDoGph_gInf_c::csr_c::m_blurID;
@@ -527,29 +580,29 @@ f32 mDoGph_gInf_c::m_scale = 1.0f;
f32 mDoGph_gInf_c::m_invScale = 1.0f;
int mDoGph_gInf_c::m_maxX = 608 - 1;
int mDoGph_gInf_c::m_maxX = FB_WIDTH_BASE - 1;
int mDoGph_gInf_c::m_maxY = 448 - 1;
int mDoGph_gInf_c::m_maxY = FB_HEIGHT_BASE - 1;
int mDoGph_gInf_c::m_width = 608;
int mDoGph_gInf_c::m_width = FB_WIDTH_BASE;
int mDoGph_gInf_c::m_height = 448;
int mDoGph_gInf_c::m_height = FB_HEIGHT_BASE;
f32 mDoGph_gInf_c::m_maxXF = 608.0f - 1;
f32 mDoGph_gInf_c::m_maxXF = FB_WIDTH_BASE - 1;
f32 mDoGph_gInf_c::m_maxYF = 448.0f - 1;
f32 mDoGph_gInf_c::m_maxYF = FB_HEIGHT_BASE - 1;
f32 mDoGph_gInf_c::m_widthF = 608.0f;
f32 mDoGph_gInf_c::m_widthF = FB_WIDTH_BASE;
f32 mDoGph_gInf_c::m_heightF = 448.0f;
f32 mDoGph_gInf_c::m_heightF = FB_HEIGHT_BASE;
struct tvSize {
u16 width;
u16 height;
};
const tvSize l_tvSize[2] = {
{608, 448},
{808, 448},
{FB_WIDTH_BASE, FB_HEIGHT_BASE},
{808, FB_HEIGHT_BASE},
};
#if TARGET_PC
@@ -565,8 +618,8 @@ void mDoGph_gInf_c::setTvSize() {
m_width = tvsize->width;
m_height = tvsize->height;
m_minX = -((m_width - 608) / 2);
m_minY = -((m_height - 448) / 2);
m_minX = -((m_width - FB_WIDTH_BASE) / 2);
m_minY = -((m_height - FB_HEIGHT_BASE) / 2);
m_maxX = m_minX + m_width;
m_maxY = m_minY + m_height;
@@ -815,6 +868,9 @@ int mDoGph_AfterOfDraw() {
JUTVideo::getManager()->setRenderMode(mDoMch_render_c::getRenderModeObj());
mDoGph_gInf_c::endFrame();
#ifdef TARGET_PC
dusk::frame_interp::notify_sim_tick_complete();
#endif
return 1;
}
@@ -834,6 +890,7 @@ void mDoGph_drawFilterQuad(s8 param_0, s8 param_1) {
#endif
static void drawDepth2(view_class* param_0, view_port_class* param_1, int param_2) {
ZoneScoped;
static GXColorS10 l_tevColor0 = {0, 0, 0, 0};
if (daPy_getLinkPlayerActorClass() != NULL) {
@@ -1087,6 +1144,7 @@ static void drawDepth2(view_class* param_0, view_port_class* param_1, int param_
}
static void trimming(view_class* param_0, view_port_class* param_1) {
ZoneScoped;
UNUSED(param_0);
s16 y_orig = (int)param_1->y_orig & ~7;
@@ -1199,6 +1257,7 @@ void mDoGph_gInf_c::bloom_c::remove() {
void mDoGph_gInf_c::bloom_c::draw() {
#if TARGET_PC
ZoneScoped;
if (!dusk::getSettings().game.enableBloom) {
return;
}
@@ -1473,6 +1532,7 @@ static void retry_captue_frame(view_class* param_0, view_port_class* param_1, in
}
static void motionBlure(view_class* param_0) {
ZoneScoped;
if (g_env_light.is_blure) {
GXLoadTexObj(mDoGph_gInf_c::getFrameBufferTexObj(), GX_TEXMAP0);
GXColor local_60;
@@ -1652,6 +1712,16 @@ static void captureScreenPerspDrawInfo(JPADrawInfo& info) {
#endif
static void drawItem3D() {
ZoneScoped;
#ifdef TARGET_PC
// Frame interpolation: Title screen needs 0.0f while everything else that runs through this is -100.0f.
// Running presentation faster than logic revealed the problem. Thanks, Nintendo.
if (fopAcM_SearchByName(fpcNm_TITLE_e) != nullptr) {
dMenu_Collect3D_c::setViewPortOffsetY(0.0f);
} else {
dMenu_Collect3D_c::setViewPortOffsetY(-100.0f);
}
#endif
Mtx item_mtx;
dMenu_Collect3D_c::setupItem3D(item_mtx);
@@ -1668,6 +1738,7 @@ static void drawItem3D() {
}
int mDoGph_Painter() {
ZoneScoped;
// Diagnostic: log windowNum to track game state machine progress
static bool sDiagLoggedWindow = false;
if (!sDiagLoggedWindow) {
@@ -1678,13 +1749,21 @@ int mDoGph_Painter() {
#if TARGET_PC
dusk::g_imguiConsole.PreDraw();
const u32 pending_ui_ticks = dusk::frame_interp::begin_presentation_ui_pass();
#endif
#if DEBUG
drawHeapMap();
#endif
dComIfGp_particle_calcMenu();
#ifdef TARGET_PC
for (u32 i = 0; i < pending_ui_ticks; ++i) {
#endif
dComIfGp_particle_calcMenu();
#ifdef TARGET_PC
}
#endif
JFWDisplay::getManager()->setFader(mDoGph_gInf_c::getFader());
mDoGph_gInf_c::setClearColor(mDoGph_gInf_c::getBackColor());
@@ -1770,7 +1849,13 @@ int mDoGph_Painter() {
GXSetScissor(view_port->x_orig, view_port->y_orig, view_port->width,
view_port->height);
#ifdef TARGET_PC
// Frame interpolation: Call setViewMtx earlier so that it's interpolated in time for draw_info to use it
j3dSys.setViewMtx(camera_p->view.viewMtx);
JPADrawInfo draw_info(j3dSys.getViewMtx(), camera_p->view.fovy, camera_p->view.aspect);
#else
JPADrawInfo draw_info(camera_p->view.viewMtx, camera_p->view.fovy, camera_p->view.aspect);
#endif
#if WIDESCREEN_SUPPORT
if (mDoGph_gInf_c::isWideZoom()) {
@@ -1808,7 +1893,9 @@ int mDoGph_Painter() {
PPCSync();
#ifndef TARGET_PC
j3dSys.setViewMtx(camera_p->view.viewMtx);
#endif
dKy_setLight();
GX_DEBUG_GROUP(dComIfGd_drawOpaListSky);
GX_DEBUG_GROUP(dComIfGd_drawXluListSky);
@@ -2128,7 +2215,7 @@ int mDoGph_Painter() {
if (fapGmHIO_getParticle()) {
#if WIDESCREEN_SUPPORT
if (mDoGph_gInf_c::isWideZoom()) {
ortho.setOrtho(0.0f, 0.0f, 608.0f, 448.0f, 100000.0f, -100000.0f);
ortho.setOrtho(0.0f, 0.0f, FB_WIDTH_BASE, FB_HEIGHT_BASE, 100000.0f, -100000.0f);
} else
#endif
{
@@ -2139,8 +2226,8 @@ int mDoGph_Painter() {
ortho.setPort();
Mtx m3;
MTXTrans(m3, FB_WIDTH / 2, FB_HEIGHT / 2, 0.0f);
JPADrawInfo draw_info2(m3, 0.0f, FB_HEIGHT, 0.0f, FB_WIDTH);
MTXTrans(m3, FB_WIDTH_BASE / 2, FB_HEIGHT_BASE / 2, 0.0f);
JPADrawInfo draw_info2(m3, 0.0f, FB_HEIGHT_BASE, 0.0f, FB_WIDTH_BASE);
dComIfGp_particle_draw2Dgame(&draw_info2);
}
@@ -2149,7 +2236,12 @@ int mDoGph_Painter() {
if (strcmp(dComIfGp_getStartStageName(), "F_SP127") != 0 &&
(mDoGph_gInf_c::isFade() & 0x80) == 0)
{
#ifdef TARGET_PC
mDoGph_AdvanceFadeState(pending_ui_ticks);
mDoGph_DrawStoredFade();
#else
mDoGph_gInf_c::calcFade();
#endif
}
#if DEBUG
@@ -2214,7 +2306,13 @@ int mDoGph_Painter() {
#endif
GXSetClipMode(GX_CLIP_ENABLE);
dDlst_list_c::calcWipe();
#ifdef TARGET_PC
for (u32 i = 0; i < pending_ui_ticks; ++i) {
#endif
dDlst_list_c::calcWipe();
#ifdef TARGET_PC
}
#endif
j3dSys.reinitGX();
ortho.setOrtho(mDoGph_gInf_c::getMinXF(), mDoGph_gInf_c::getMinYF(),
@@ -2231,9 +2329,9 @@ int mDoGph_Painter() {
cMtx_copy(j3dSys.getViewMtx(), m4);
Mtx m5;
MTXTrans(m5, FB_WIDTH / 2, FB_HEIGHT / 2, 0.0f);
MTXTrans(m5, FB_WIDTH_BASE / 2, FB_HEIGHT_BASE / 2, 0.0f);
JPADrawInfo draw_info3(m5, 0.0f, FB_HEIGHT, 0.0f, FB_WIDTH);
JPADrawInfo draw_info3(m5, 0.0f, FB_HEIGHT_BASE, 0.0f, FB_WIDTH_BASE);
if (!dComIfGp_isPauseFlag()) {
GX_DEBUG_GROUP(dComIfGp_particle_draw2Dback, &draw_info3);
@@ -2264,7 +2362,12 @@ int mDoGph_Painter() {
if (strcmp(dComIfGp_getStartStageName(), "F_SP127") == 0 || (mDoGph_gInf_c::isFade() & 0x80) != 0)
{
#ifdef TARGET_PC
mDoGph_AdvanceFadeState(pending_ui_ticks);
mDoGph_DrawStoredFade();
#else
mDoGph_gInf_c::calcFade();
#endif
}
GX_DEBUG_GROUP(dComIfGp_particle_draw2DmenuFore, &draw_info3);
@@ -2297,10 +2400,16 @@ int mDoGph_Painter() {
#if TARGET_PC
dusk::g_imguiConsole.PostDraw();
JFWDisplay::getManager()->setFaderSimSteps(pending_ui_ticks);
#endif
mDoGph_gInf_c::endRender();
#ifdef TARGET_PC
dusk::frame_interp::end_presentation_ui_pass();
#endif
#if WIDESCREEN_SUPPORT
mDoGph_gInf_c::offWideZoom();
#endif
+5
View File
@@ -153,8 +153,13 @@ void mDoLib_project(Vec* src, Vec* dst, JGeometry::TBox2<f32> viewport) {
xOffset = (0.5f * ((2.0f * viewport.i.x) + viewport.f.x)) - (int)(FB_WIDTH / 2);
xSize = FB_WIDTH;
} else {
#if TARGET_PC
xOffset = mDoGph_gInf_c::getMinXF();
xSize = viewport.f.x * mDoGph_gInf_c::hudAspectScaleUp;
#else
xOffset = viewport.i.x;
xSize = viewport.f.x;
#endif
}
if (viewport.i.y != 0.0f) {
+211 -48
View File
@@ -20,6 +20,7 @@
#include "JSystem/JUtility/JUTProcBar.h"
#include "JSystem/JUtility/JUTReport.h"
#include "SSystem/SComponent/c_counter.h"
#include "SSystem/SComponent/c_API_graphic.h"
#include "Z2AudioLib/Z2WolfHowlMgr.h"
#include "c/c_dylink.h"
#include "d/d_com_inf_game.h"
@@ -46,9 +47,12 @@
#include "SSystem/SComponent/c_API.h"
#include "dusk/app_info.hpp"
#include "dusk/dusk.h"
#include "dusk/frame_interpolation.h"
#include "dusk/imgui/ImGuiEngine.hpp"
#include "dusk/logging.h"
#include "dusk/main.h"
#include "dusk/imgui/ImGuiConsole.hpp"
#include "version.h"
#include "dusk/time.h"
#include <aurora/aurora.h>
@@ -59,7 +63,10 @@
#include "SDL3/SDL_filesystem.h"
#include "cxxopts.hpp"
#include "dusk/audio/DuskAudioSystem.h"
#include "dusk/config.hpp"
#include "dusk/imgui/ImGuiConsole.hpp"
#include "tracy/Tracy.hpp"
// --- GLOBALS ---
s8 mDoMain::developmentMode = -1;
@@ -79,7 +86,9 @@ const int audioHeapSize = 0x14D800;
#define COPYDATE_PATH "/str/Final/Release/COPYDATE"
#if TARGET_PC
bool dusk::IsRunning = true;
bool dusk::IsShuttingDown = false;
bool dusk::IsGameLaunched = false;
#endif
s32 LOAD_COPYDATE(void*) {
@@ -114,6 +123,41 @@ AuroraStats dusk::lastFrameAuroraStats;
float dusk::frameUsagePct = 0.0f;
const char* configPath;
AuroraWindowSize preLaunchUIWindowSize;
bool launchUILoop() {
while (dusk::IsRunning && !dusk::IsGameLaunched) {
const AuroraEvent* event = aurora_update();
while (event != nullptr && event->type != AURORA_NONE) {
switch (event->type) {
case AURORA_WINDOW_RESIZED:
preLaunchUIWindowSize = event->windowSize;
break;
case AURORA_DISPLAY_SCALE_CHANGED:
dusk::ImGuiEngine_Initialize(event->windowSize.scale);
break;
case AURORA_EXIT:
return false;
}
event++;
}
if (!aurora_begin_frame()) {
DuskLog.debug("aurora_begin_frame returned false, skipping draw this frame");
continue;
}
dusk::g_imguiConsole.PreDraw();
dusk::g_imguiConsole.PostDraw();
aurora_end_frame();
}
return dusk::IsRunning;
}
void main01(void) {
OS_REPORT("\x1b[m");
@@ -152,6 +196,13 @@ void main01(void) {
OSReport("Entering Main Loop (main01)...\n");
if (preLaunchUIWindowSize.width != 0)
mDoGph_gInf_c::setWindowSize(preLaunchUIWindowSize);
using clock = std::chrono::steady_clock;
constexpr double kSimStepSeconds = 1.0 / 30.0;
auto previous_time = clock::now();
double accumulator = kSimStepSeconds;
do {
// 1. Update Window Events
@@ -175,69 +226,97 @@ void main01(void) {
eventsDone:;
static u32 frame = 0;
frame++;
// Game Inputs
mDoCPd_c::read();
auto current_time = clock::now();
double frame_seconds = std::chrono::duration<double>(current_time - previous_time).count();
previous_time = current_time;
accumulator += frame_seconds;
VIWaitForRetrace();
#if TARGET_PC
dusk::lastFrameAuroraStats = *aurora_get_stats();
if (!aurora_begin_frame()) {
DuskLog.debug("aurora_begin_frame returned false, skipping draw this frame");
continue;
}
#endif
// EXECUTE GAME LOGIC & RENDER
// This calls mDoGph_Painter -> JFWDisplay -> GX Functions
fapGm_Execute();
if (dusk::getSettings().game.enableFrameInterpolation) {
while (accumulator >= kSimStepSeconds) {
mDoCPd_c::read();
fapGm_Execute();
mDoAud_Execute();
accumulator -= kSimStepSeconds;
}
mDoAud_Execute();
float interp_alpha = static_cast<float>(accumulator / kSimStepSeconds);
dusk::frame_interp::interpolate(interp_alpha);
cAPIGph_Painter();
} else {
accumulator = 0.0;
// Game Inputs
mDoCPd_c::read();
// EXECUTE GAME LOGIC & RENDER
// This calls mDoGph_Painter -> JFWDisplay -> GX Functions
fapGm_Execute();
mDoAud_Execute();
}
aurora_end_frame();
} while (true);
FrameMark;
} while (dusk::IsRunning);
exit:;
}
static AuroraBackend ParseAuroraBackend(const std::string& value) {
if (value == "auto") {
return BACKEND_AUTO;
}
if (value == "d3d11") {
return BACKEND_D3D11;
}
if (value == "d3d12") {
return BACKEND_D3D12;
}
if (value == "metal") {
return BACKEND_METAL;
}
if (value == "vulkan") {
return BACKEND_VULKAN;
}
if (value == "opengl") {
return BACKEND_OPENGL;
}
if (value == "opengles") {
return BACKEND_OPENGLES;
}
if (value == "webgpu") {
return BACKEND_WEBGPU;
}
if (value == "null") {
return BACKEND_NULL;
static bool IsBackendAvailable(AuroraBackend backend) {
if (backend == BACKEND_AUTO) {
return true;
}
fmt::print(stderr, "Unknown backend: {}", value);
exit(1);
size_t availableBackendCount = 0;
const AuroraBackend* availableBackends = aurora_get_available_backends(&availableBackendCount);
for (size_t i = 0; i < availableBackendCount; ++i) {
if (availableBackends[i] == backend) {
return true;
}
}
return false;
}
static AuroraBackend ResolveDesiredBackend(const cxxopts::ParseResult& parsedArgOptions) {
AuroraBackend desiredBackend = BACKEND_AUTO;
if (parsedArgOptions.count("backend") != 0) {
const std::string backendArg = parsedArgOptions["backend"].as<std::string>();
if (!dusk::try_parse_backend(backendArg, desiredBackend)) {
fmt::print(stderr, "Unknown backend: {}\n", backendArg);
exit(1);
}
} else if (!dusk::try_parse_backend(
static_cast<const std::string&>(dusk::getSettings().backend.graphicsBackend),
desiredBackend))
{
DuskLog.warn("Unknown configured backend '{}', falling back to Auto",
static_cast<const std::string&>(dusk::getSettings().backend.graphicsBackend));
desiredBackend = BACKEND_AUTO;
}
if (!IsBackendAvailable(desiredBackend)) {
DuskLog.warn("Requested backend '{}' is unavailable, falling back to Auto",
dusk::backend_name(desiredBackend));
desiredBackend = BACKEND_AUTO;
}
return desiredBackend;
}
static void aurora_imgui_init_callback(const AuroraWindowSize* size) {
dusk::ImGuiEngine_Initialize(size->scale);
dusk::ImGuiEngine_AddTextures();
}
static void ApplyCVarOverrides(const cxxopts::OptionValue& option) {
@@ -278,10 +357,50 @@ static const char* CalculateConfigPath() {
return result;
}
static constexpr PADDefaultMapping defaultPadMapping = {
.buttons = {
{SDL_GAMEPAD_BUTTON_SOUTH, PAD_BUTTON_A},
{SDL_GAMEPAD_BUTTON_EAST, PAD_BUTTON_B},
{SDL_GAMEPAD_BUTTON_WEST, PAD_BUTTON_X},
{SDL_GAMEPAD_BUTTON_NORTH, PAD_BUTTON_Y},
{SDL_GAMEPAD_BUTTON_START, PAD_BUTTON_START},
{SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, PAD_TRIGGER_Z},
{PAD_NATIVE_BUTTON_INVALID, PAD_TRIGGER_L},
{PAD_NATIVE_BUTTON_INVALID, PAD_TRIGGER_R},
{SDL_GAMEPAD_BUTTON_DPAD_UP, PAD_BUTTON_UP},
{SDL_GAMEPAD_BUTTON_DPAD_DOWN, PAD_BUTTON_DOWN},
{SDL_GAMEPAD_BUTTON_DPAD_LEFT, PAD_BUTTON_LEFT},
{SDL_GAMEPAD_BUTTON_DPAD_RIGHT, PAD_BUTTON_RIGHT},
},
.axes = {
{{SDL_GAMEPAD_AXIS_LEFTX, AXIS_SIGN_POSITIVE}, SDL_GAMEPAD_BUTTON_INVALID, PAD_AXIS_LEFT_X_POS},
{{SDL_GAMEPAD_AXIS_LEFTX, AXIS_SIGN_NEGATIVE}, SDL_GAMEPAD_BUTTON_INVALID, PAD_AXIS_LEFT_X_NEG},
// SDL's gamepad y-axis is inverted from GC's
{{SDL_GAMEPAD_AXIS_LEFTY, AXIS_SIGN_NEGATIVE}, SDL_GAMEPAD_BUTTON_INVALID, PAD_AXIS_LEFT_Y_POS},
{{SDL_GAMEPAD_AXIS_LEFTY, AXIS_SIGN_POSITIVE}, SDL_GAMEPAD_BUTTON_INVALID, PAD_AXIS_LEFT_Y_NEG},
{{SDL_GAMEPAD_AXIS_RIGHTX, AXIS_SIGN_POSITIVE}, SDL_GAMEPAD_BUTTON_INVALID, PAD_AXIS_RIGHT_X_POS},
{{SDL_GAMEPAD_AXIS_RIGHTX, AXIS_SIGN_NEGATIVE}, SDL_GAMEPAD_BUTTON_INVALID, PAD_AXIS_RIGHT_X_NEG},
// see above
{{SDL_GAMEPAD_AXIS_RIGHTY, AXIS_SIGN_NEGATIVE}, SDL_GAMEPAD_BUTTON_INVALID, PAD_AXIS_RIGHT_Y_POS},
{{SDL_GAMEPAD_AXIS_RIGHTY, AXIS_SIGN_POSITIVE}, SDL_GAMEPAD_BUTTON_INVALID, PAD_AXIS_RIGHT_Y_NEG},
{{SDL_GAMEPAD_AXIS_LEFT_TRIGGER, AXIS_SIGN_POSITIVE}, SDL_GAMEPAD_BUTTON_INVALID, PAD_AXIS_TRIGGER_L},
{{SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, AXIS_SIGN_POSITIVE}, SDL_GAMEPAD_BUTTON_INVALID, PAD_AXIS_TRIGGER_R},
},
};
static bool mainCalled = false;
// =========================================================================
// PC ENTRY POINT
// =========================================================================
int game_main(int argc, char* argv[]) {
// On iOS, when connected to an external monitor, SDLUIKitSceneDelegate scene:willConnectToSession:
// can call our main function again. Explicitly guard against this reinitialization.
if (mainCalled) {
return 0;
}
mainCalled = true;
dusk::registerSettings();
dusk::config::FinishRegistration();
@@ -293,8 +412,8 @@ int game_main(int argc, char* argv[]) {
arg_options.add_options()
("l,log-level", "Log level from " + std::to_string(AuroraLogLevel::LOG_DEBUG) + " to " + std::to_string(AuroraLogLevel::LOG_FATAL), cxxopts::value<uint8_t>()->default_value("0"))
("h,help", "Print usage")
("dvd", "Path to DVD image file", cxxopts::value<std::string>()->default_value("game.iso"))
("backend", "Graphics API backend to use (auto, d3d11, d3d12, metal, vulkan, opengl, opengles, webgpu, null)", cxxopts::value<std::string>()->default_value("auto"))
("dvd", "Path to DVD image file", cxxopts::value<std::string>())
("backend", "Graphics API backend to use (auto, d3d12, metal, vulkan, null)", cxxopts::value<std::string>())
("cvar", "Override configuration variables without modifying config", cxxopts::value<std::vector<std::string>>());
arg_options.parse_positional({"dvd"});
@@ -328,20 +447,64 @@ int game_main(int argc, char* argv[]) {
config.windowPosY = -1;
config.windowWidth = defaultWindowWidth * 2;
config.windowHeight = defaultWindowHeight * 2;
config.desiredBackend = ParseAuroraBackend(parsed_arg_options["backend"].as<std::string>());
config.desiredBackend = ResolveDesiredBackend(parsed_arg_options);
config.logCallback = &aurora_log_callback;
config.logLevel = (AuroraLogLevel)parsed_arg_options["log-level"].as<uint8_t>();
config.mem1Size = 256 * 1024 * 1024;
config.mem2Size = 24 * 1024 * 1024;
config.allowJoystickBackgroundEvents = true;
config.imGuiInitCallback = &aurora_imgui_init_callback;
config.allowTextureReplacements = true;
config.allowTextureDumps = false;
PADSetDefaultMapping(&defaultPadMapping);
auroraInfo = aurora_initialize(argc, argv, &config);
const auto& dvd_path = parsed_arg_options["dvd"].as<std::string>();
DuskLog.info("Loading DVD image: {}", dvd_path);
if (!aurora_dvd_open(dvd_path.c_str())) {
DuskLog.fatal("Failed to open DVD image: {}", dvd_path);
VISetWindowTitle(
fmt::format("Dusk {} [{}]", DUSK_WC_DESCRIBE, dusk::backend_name(auroraInfo.backend))
.c_str());
if (dusk::getSettings().video.lockAspectRatio) {
VILockAspectRatio(defaultAspectRatioW, defaultAspectRatioH);
} else {
VIUnlockAspectRatio();
}
dusk::audio::SetMasterVolume(dusk::getSettings().audio.masterVolume / 100.0f);
dusk::audio::SetEnableReverb(dusk::getSettings().audio.enableReverb);
std::string dvd_path;
bool dvd_opened = false;
if (parsed_arg_options.count("dvd")) {
dvd_path = parsed_arg_options["dvd"].as<std::string>();
DuskLog.info("Loading DVD image from command line: {}", dvd_path);
dvd_opened = aurora_dvd_open(dvd_path.c_str());
if (!dvd_opened) {
DuskLog.warn("Failed to open DVD image from command line: {}, opening prelaunch UI", dvd_path);
} else {
dusk::getSettings().backend.isoPath.setValue(dvd_path);
dusk::config::Save();
dusk::IsGameLaunched = true;
}
}
if (!dvd_opened) {
// pre game launch ui main loop
if (!launchUILoop()) {
aurora_shutdown();
return 0;
}
dvd_path = dusk::getSettings().backend.isoPath;
if (dvd_path.empty()) {
DuskLog.fatal("No DVD image specified, unable to boot!");
}
DuskLog.info("Loading DVD image: {}", dvd_path);
if (!aurora_dvd_open(dvd_path.c_str())) {
DuskLog.fatal("Failed to open DVD image: {}", dvd_path);
}
}
OSInit();