Merge remote-tracking branch 'origin/main' into feature/gamepad-color

# Conflicts:
#	src/f_ap/f_ap_game.cpp
This commit is contained in:
MelonSpeedruns
2026-04-22 13:01:03 -04:00
192 changed files with 5602 additions and 2521 deletions
+5 -5
View File
@@ -117,8 +117,8 @@ static Z2WolfHowlLine sNewSong3[9] = {
#if TARGET_PC
static Z2WolfHowlLine sHowlTimeSong[6] = {
{HOWL_LINE_MID, 20}, {HOWL_LINE_LOW, 20}, {HOWL_LINE_HIGH, 40},
{HOWL_LINE_MID, 20}, {HOWL_LINE_LOW, 20}, {HOWL_LINE_HIGH, 40},
{HOWL_LINE_MID, 15}, {HOWL_LINE_LOW, 15}, {HOWL_LINE_HIGH, 30},
{HOWL_LINE_MID, 15}, {HOWL_LINE_LOW, 15}, {HOWL_LINE_HIGH, 30},
};
#endif
@@ -368,9 +368,9 @@ void Z2WolfHowlMgr::setCorrectData(s8 curveID, Z2WolfHowlData* data) {
break;
#if TARGET_PC
case Z2WOLFHOWL_TIMESONG:
cPitchUp = 1.259906f;
cPitchCenter = 0.94387f;
cPitchDown = 0.840885f;
cPitchUp = 1.3348f;
cPitchCenter = 1.0f;
cPitchDown = 0.7937f;
break;
#endif
default:
+6
View File
@@ -4258,6 +4258,12 @@ int daAlink_c::createHeap() {
return 0;
}
#if TARGET_PC
// lets try to zero-initialize the arrays instead of having garbage values
std::memset(sp1C, 0, sizeof(J3DTransformInfo) * sp38);
std::memset(sp30, 0, sizeof(Quaternion) * sp38);
#endif
field_0x2060 = JKR_NEW mDoExt_MtxCalcOldFrame(sp1C, sp30);
if (field_0x2060 == NULL) {
return 0;
+30 -8
View File
@@ -37,18 +37,40 @@ void daAlink_c::setCrawlMoveDirectionArrow() {
}
if (field_0x3198 & 4) {
if (!bvar) {
direction |= data_80452F38;
} else {
direction |= data_80452F39;
#if TARGET_PC
if (dusk::getSettings().game.enableMirrorMode) {
if (!bvar) {
direction |= data_80452F39;
} else {
direction |= data_80452F38;
}
} else
#endif
{
if (!bvar) {
direction |= data_80452F38;
} else {
direction |= data_80452F39;
}
}
}
if (field_0x3198 & 8) {
if (!bvar) {
direction |= data_80452F39;
} else {
direction |= data_80452F38;
#if TARGET_PC
if (dusk::getSettings().game.enableMirrorMode) {
if (!bvar) {
direction |= data_80452F38;
} else {
direction |= data_80452F39;
}
} else
#endif
{
if (!bvar) {
direction |= data_80452F39;
} else {
direction |= data_80452F38;
}
}
}
+6
View File
@@ -817,6 +817,12 @@ BOOL daAlink_c::checkDownAttackState() {
}
BOOL daAlink_c::checkCutLargeTurnState() const {
#if TARGET_PC
if (dusk::getSettings().game.alwaysGreatspin) {
return TRUE;
}
#endif
return ((dComIfGs_isEventBit(dSv_event_flag_c::F_0344) || checkNoResetFlg3(FLG3_TRANING_CUT_LARGE_TURN))
&& dComIfGs_getLife() == dComIfGs_getMaxLifeGauge()
)
+8 -5
View File
@@ -257,15 +257,18 @@ void daAlink_c::handleQuickTransform() {
procCoMetamorphoseInit();
}
bool daAlink_c::checkGyroAimItemContext() {
if (checkWolf()) {
return false;
}
bool daAlink_c::checkGyroAimContext() {
switch (mProcID) {
case PROC_SUBJECTIVITY:
case PROC_SWIM_SUBJECTIVITY:
case PROC_HORSE_SUBJECTIVITY:
case PROC_CANOE_SUBJECTIVITY:
case PROC_BOARD_SUBJECTIVITY:
case PROC_WOLF_ROPE_SUBJECTIVITY:
case PROC_BOW_SUBJECT:
case PROC_BOOMERANG_SUBJECT:
case PROC_COPY_ROD_SUBJECT:
case PROC_HAWK_SUBJECT:
case PROC_HOOKSHOT_SUBJECT:
case PROC_SWIM_HOOKSHOT_SUBJECT:
case PROC_HORSE_BOW_SUBJECT:
+32
View File
@@ -290,6 +290,12 @@ BOOL daAlink_c::checkHookshotStickBG(cBgS_PolyInfo& i_polyinfo) {
}
#endif
#if TARGET_PC
if (dusk::getSettings().game.superClawshot) {
return TRUE;
}
#endif
if (dComIfG_Bgsp().ChkPolyHSStick(i_polyinfo)) {
dBgW_Base* bgw_p = dComIfG_Bgsp().GetBgWBasePointer(i_polyinfo);
if (bgw_p != NULL && bgw_p->ChkPushPullOk()) {
@@ -448,6 +454,12 @@ void daAlink_c::setHookshotSight() {
max_length = mpHIO->mItem.mHookshot.m.mMaxLength;
}
#if TARGET_PC
if (dusk::getSettings().game.superClawshot) {
max_length = 69420.0f;
}
#endif
BOOL line_cross = checkSightLine(max_length, &sight_pos);
if (mHookTargetAcKeep.getActor() != NULL) {
@@ -890,6 +902,14 @@ void daAlink_c::setHookshotPos() {
max_length = mpHIO->mItem.mHookshot.m.mMaxLength;
}
#if TARGET_PC
if (dusk::getSettings().game.superClawshot) {
return_speed = 2870.0f;
shoot_speed = 2870.0f;
max_length = 69420.0f;
}
#endif
if (mItemMode == HS_MODE_RETURN_e) {
if (targetAc_p != NULL) {
if (checkLv7BossRoom()) {
@@ -899,6 +919,12 @@ void daAlink_c::setHookshotPos() {
}
}
#if TARGET_PC
if (dusk::getSettings().game.superClawshot) {
return_speed = 500.0f;
}
#endif
if (checkModeFlg(0x400)) {
return_speed += current.pos.abs(field_0x3798);
}
@@ -1548,6 +1574,12 @@ int daAlink_c::procHookshotFly() {
f32 temp_f31 = field_0x37d4.abs();
f32 temp_f30 = mpHIO->mItem.mHookshot.m.mStickReturnSpeed + spAC.abs(mHookshotTopPos);
#if TARGET_PC
if (dusk::getSettings().game.superClawshot) {
temp_f30 = 500.0f + spAC.abs(mHookshotTopPos);
}
#endif
if (temp_f31 < temp_f30 || mProcVar1.field_0x300a == 0) {
setHookshotReturnEnd();
} else {
-5
View File
@@ -180,12 +180,7 @@ void daAlink_c::preKandelaarDraw() {
mat_p->setTevColor(2, &color);
cXyz proj;
#if TARGET_PC
mDoLib_project(&mKandelaarFlamePos, &proj, {0, 0, FB_WIDTH, FB_HEIGHT});
#else
mDoLib_project(&mKandelaarFlamePos, &proj);
#endif
camera_process_class* camera_p = dComIfGp_getCamera(0);
f32 trimHeight;
+3 -13
View File
@@ -11,7 +11,7 @@
#include "d/actor/d_a_tag_mhint.h"
#if TARGET_PC
#include "dusk/gyro_aim.h"
#include "dusk/gyro.h"
#endif
bool daAlink_c::checkNoSubjectModeCamera() {
@@ -130,7 +130,7 @@ BOOL daAlink_c::setBodyAngleToCamera() {
}
#if TARGET_PC
if (dusk::getSettings().game.enableGyroAim && checkGyroAimItemContext()) {
if (dusk::getSettings().game.enableGyroAim && checkGyroAimContext()) {
f32 gyro_scale = 1.0f;
if (checkWolfEyeUp()) {
gyro_scale *= 0.6f;
@@ -142,17 +142,7 @@ BOOL daAlink_c::setBodyAngleToCamera() {
f32 gy_yaw = 0.f;
f32 gy_pitch = 0.f;
dusk::gyro_aim::consumeAimDeltas(gy_yaw, gy_pitch);
if (dusk::getSettings().game.gyroAimInvertPitch) {
gy_pitch = -gy_pitch;
}
if (dusk::getSettings().game.gyroAimInvertYaw) {
gy_yaw = -gy_yaw;
}
if (dusk::getSettings().game.enableMirrorMode) {
gy_yaw = -gy_yaw;
}
dusk::gyro::getAimDeltas(gy_yaw, gy_pitch);
shape_angle.y = shape_angle.y + cM_rad2s(gy_yaw * gyro_scale);
sp8 = sp8 + cM_rad2s(gy_pitch * gyro_scale);
-4
View File
@@ -318,11 +318,7 @@ void daBalloon2D_c::addScoreCount(cXyz* param_1, u32 param_2, u8 param_3) {
field_0x5f8[current].field_0xf = field_0x5f8[prev].field_0xf;
}
cXyz acStack_2c;
#if TARGET_PC
mDoLib_project(param_1, &acStack_2c, { 0, 0, FB_WIDTH, FB_HEIGHT });
#else
mDoLib_project(param_1, &acStack_2c);
#endif
field_0x5f8[0].field_0x0.set(acStack_2c);
field_0x5f8[0].field_0xc = param_2;
field_0x5f8[0].field_0xe = 60;
+5
View File
@@ -623,6 +623,11 @@ int daBg_c::create() {
dComIfGp_roomControl_onStatusFlag(roomNo, 0x10);
OS_REPORT("<BG> room%d\n", roomNo);
#if TARGET_PC
draw_interp_frame = true;
#endif
return cPhs_COMPLEATE_e;
}
-6
View File
@@ -337,13 +337,7 @@ void daBoomerang_sight_c::setSight(const cXyz* i_pos, int i_no) {
}
Vec proj;
#if TARGET_PC
mDoLib_project(&m_pos[i_no], &proj, {0, 0, FB_WIDTH, FB_HEIGHT});
#else
mDoLib_project(&m_pos[i_no], &proj);
#endif
m_proj_posX[i_no] = proj.x;
m_proj_posY[i_no] = proj.y;
}
-5
View File
@@ -1658,12 +1658,7 @@ int daDemo00_c::draw() {
MTXCopy(mModel.field_0x5d4->getAnmMtx(0), mDoMtx_stack_c::get());
spb0.set(0.0f, 0.0f, 0.0f);
mDoMtx_stack_c::multVec(&spb0, &sp98);
#if TARGET_PC
mDoLib_project(&sp98, &spa4, {0, 0, FB_WIDTH, FB_HEIGHT});
#else
mDoLib_project(&sp98, &spa4);
#endif
if (spa4.x >= -700.0f && spa4.x < 1600.0f && spa4.y >= -200.0f && spa4.y < 600.0f) {
if (mModel.mID.field_0x18 == 0 || mModel.mID.field_0x18 == 1) {
+8
View File
@@ -215,7 +215,15 @@ int daDsh_c::create() {
mType = getType();
// !@bug Static-init only runs once, so slot 0 keeps the first mType's arc name forever.
// GC/Wii dodges this via REL reload; TPHD is statically linked so later gates of a
// different type load the wrong arc and CreateHeap fails. The storage must stay static
// because mResLoader.load holds the pointer past create(), so we just overwrite slot 0
// each call instead.
static const char* l_resName[] = {l_arcName[mType], ""};
#ifdef TARGET_PC
l_resName[0] = l_arcName[mType];
#endif
int phase = mResLoader.load(l_resName, NULL);
if (phase == cPhs_COMPLEATE_e) {
-6
View File
@@ -429,13 +429,7 @@ void daE_FK_c::DamageAction() {
bool daE_FK_c::checkViewArea() {
Vec proj;
#if TARGET_PC
mDoLib_project(&current.pos, &proj, {0, 0, FB_WIDTH, FB_HEIGHT});
#else
mDoLib_project(&current.pos, &proj);
#endif
return (proj.x >= 0.0f && proj.x <= FB_WIDTH) && (proj.y >= 0.0f && proj.y <= FB_HEIGHT);
}
-6
View File
@@ -463,13 +463,7 @@ static void damage_check(e_fs_class* i_this) {
static bool checkViewArea(cXyz* i_pos) {
Vec proj;
#if TARGET_PC
mDoLib_project(i_pos, &proj, {0, 0, FB_WIDTH, FB_HEIGHT});
#else
mDoLib_project(i_pos, &proj);
#endif
bool ret = false;
if (proj.x >= 0.0f && proj.x <= FB_WIDTH && proj.y >= 0.0f && proj.y <= FB_HEIGHT) {
ret = true;
+5 -4
View File
@@ -6601,13 +6601,14 @@ static int daE_RD_Execute(e_rd_class* i_this) {
1.2f,
};
#if AVOID_UB
s16 x = 0;
s16 y = 0;
#endif
for (int i = 0; i < 2; i++) {
MtxPush();
#if !AVOID_UB
s16 x, y;
#if AVOID_UB
x = 0;
y = 0;
#endif
if (i == 0) {
-6
View File
@@ -1362,13 +1362,7 @@ void daE_SM_c::E_SM_C_Hook() {
bool daE_SM_c::CheckViewArea() {
Vec vec;
#if TARGET_PC
mDoLib_project(&current.pos, &vec, {0, 0, FB_WIDTH, FB_HEIGHT});
#else
mDoLib_project(&current.pos, &vec);
#endif
bool rv = false;
if (vec.x >= 0.0f && vec.x <= FB_WIDTH && vec.y >= 0.0f && vec.y <= FB_HEIGHT) {
+62
View File
@@ -18,6 +18,8 @@
#include "m_Do/m_Do_controller_pad.h"
#include "m_Do/m_Do_graphic.h"
#include "res/Object/Always.h"
#include "dusk/dusk.h"
#include "dusk/frame_interpolation.h"
#include <cstring>
@@ -184,6 +186,30 @@ static bool hio_set;
static daE_WB_HIO_c l_HIO;
#if TARGET_PC
static void e_wb_rein_interp_callback(bool isSimFrame, void* pUserWork) {
e_wb_class* i_this = (e_wb_class*)pUserWork;
if (!i_this->himo_interp_prev_valid || !i_this->himo_interp_curr_valid) {
return;
}
const f32 alpha = dusk::frame_interp::get_interpolation_step();
for (int r = 0; r < 2; r++) {
cXyz* dst = i_this->himo_mat[r].getPos(0);
for (int i = 0; i < 16; i++) {
const cXyz& p0 = i_this->himo_mat_interp_prev[r][i];
const cXyz& p1 = i_this->himo_mat_interp_curr[r][i];
dst[i] = p0 + (p1 - p0) * alpha;
}
}
cXyz* dst = i_this->himo_tex.getPos(0);
for (int i = 0; i < 2; i++) {
const cXyz& p0 = i_this->himo_tex_interp_prev[i];
const cXyz& p1 = i_this->himo_tex_interp_curr[i];
dst[i] = p0 + (p1 - p0) * alpha;
}
}
#endif
static void himo_control1(e_wb_class* i_this, cXyz* i_pos, int i_no, s8 param_3) {
fopEn_enemy_c* enemy = &i_this->enemy;
cXyz mae, ato;
@@ -508,6 +534,21 @@ static int daE_WB_Draw(e_wb_class* i_this) {
dComIfGd_set3DlineMat(&i_this->himo_mat[1]);
i_this->himo_tex.update(2, l_color, &actor->tevStr);
dComIfGd_set3DlineMat(&i_this->himo_tex);
#if TARGET_PC
if (dusk::getSettings().game.enableFrameInterpolation) {
if (i_this->himo_interp_curr_valid) {
memcpy(i_this->himo_mat_interp_prev, i_this->himo_mat_interp_curr, sizeof(i_this->himo_mat_interp_curr));
memcpy(i_this->himo_tex_interp_prev, i_this->himo_tex_interp_curr, sizeof(i_this->himo_tex_interp_curr));
i_this->himo_interp_prev_valid = true;
}
for (int r = 0; r < 2; r++) {
memcpy(i_this->himo_mat_interp_curr[r], i_this->himo_mat[r].getPos(0), 16 * sizeof(cXyz));
}
memcpy(i_this->himo_tex_interp_curr, i_this->himo_tex.getPos(0), 2 * sizeof(cXyz));
i_this->himo_interp_curr_valid = true;
dusk::frame_interp::add_interpolation_callback(&e_wb_rein_interp_callback, i_this);
}
#endif
}
return 1;
@@ -3726,6 +3767,9 @@ static void demo_camera(e_wb_class* i_this) {
boss = (e_rdb_class*)fopAcM_SearchByName(fpcNm_E_RDB_e);
}
cXyz mae, ato, eye, center;
#if TARGET_PC
const s16 entry_demo_mode = i_this->demo_mode;
#endif
switch (i_this->demo_mode) {
case 1: {
@@ -4255,6 +4299,9 @@ static void demo_camera(e_wb_class* i_this) {
if (i_this->demo_timer == 325) {
fpcM_Search(s_wbZrevise_sub, i_this);
#if TARGET_PC
i_this->demo_cam_sync_ticks = 2;
#endif
}
if (i_this->demo_timer == 335) {
@@ -4495,6 +4542,9 @@ static void demo_camera(e_wb_class* i_this) {
i_this->demo_cam_way_spd.z = fabsf(i_this->demo_cam_way.z - i_this->demo_cam_ctr.z);
i_this->demo_cam_morf = 0;
pla->setPlayerPosAndAngle(&pla->current.pos, pla->shape_angle.y - 4000, 0);
#if TARGET_PC
dusk::frame_interp::request_presentation_sync();
#endif
}
if (i_this->demo_timer == 345) {
daPy_getPlayerActorClass()->setThrowDamage(boss->enemy.shape_angle.y - 8000 + TREG_S(8),
@@ -4741,6 +4791,9 @@ static void demo_camera(e_wb_class* i_this) {
i_this->demo_cam_eye.x += 300.0f + VREG_F(8);
i_this->demo_cam_eye.y += 150.0f + VREG_F(9);
i_this->demo_cam_eye.z -= 1400.0f + VREG_F(10);
#if TARGET_PC
dusk::frame_interp::request_presentation_sync();
#endif
}
} else {
i_this->demo_cam_eye = enemy->current.pos;
@@ -4996,6 +5049,15 @@ static void demo_camera(e_wb_class* i_this) {
}
}
}
#if TARGET_PC
if (entry_demo_mode != i_this->demo_mode) {
i_this->demo_cam_sync_ticks = 2;
}
if (i_this->demo_cam_sync_ticks > 0) {
dusk::frame_interp::request_presentation_sync();
i_this->demo_cam_sync_ticks--;
}
#endif
}
static void anm_se_eff_set(e_wb_class* i_this) {
+119 -1
View File
@@ -12,6 +12,7 @@
#if TARGET_PC
#include "dusk/dvd_asset.hpp"
#include "dusk/frame_interpolation.h"
static u8* l_Egnd_mantTEX_get() { alignas(32) static u8 buf[0x4000]; static bool _ = (dusk::LoadRelAsset(buf, "/rel/Final/Release/d_a_mant.rel", 0x1C00, 0x4000), true); return buf; }
static u8* l_Egnd_mantTEX_U_get() { alignas(32) static u8 buf[0x4000]; static bool _ = (dusk::LoadRelAsset(buf, "/rel/Final/Release/d_a_mant.rel", 0x5C00, 0x4000), true); return buf; }
static u8* l_Egnd_mantPAL_get() { alignas(32) static u8 buf[0x60]; static bool _ = (dusk::LoadRelAsset(buf, "/rel/Final/Release/d_a_mant.rel", 0x9C00, 0x60), true); return buf; }
@@ -267,6 +268,37 @@ static void* tex_d[2] = {
static char lbl_277_bss_0;
#if TARGET_PC
static void mant_build_anchor_frame(const cXyz& anchor_a, const cXyz& anchor_b, Mtx out) {
cXyz axis_x = anchor_b - anchor_a;
if (!axis_x.normalizeRS()) {
axis_x = cXyz::BaseX;
}
cXyz helper = fabsf(axis_x.y) > 0.95f ? cXyz::BaseZ : cXyz::BaseY;
cXyz axis_z = axis_x.getCrossProduct(helper);
if (!axis_z.normalizeRS()) {
axis_z = cXyz::BaseZ;
}
cXyz axis_y = axis_z.getCrossProduct(axis_x);
if (!axis_y.normalizeRS()) {
axis_y = cXyz::BaseY;
}
const cXyz center = anchor_a + ((anchor_b - anchor_a) * 0.5f);
const cXyz col[3] = { axis_x, axis_y, axis_z };
const f32 t[3] = { center.x, center.y, center.z };
for (int r = 0; r < 3; ++r) {
out[r][0] = (&col[0].x)[r];
out[r][1] = (&col[1].x)[r];
out[r][2] = (&col[2].x)[r];
out[r][3] = t[r];
}
}
#endif
void daMant_packet_c::draw() {
#if TARGET_PC
void* image = l_Egnd_mantTEX;
@@ -290,8 +322,72 @@ void daMant_packet_c::draw() {
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_NRM, GX_CLR_RGB, GX_F32, 0);
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_CLR_RGBA, GX_F32, 0);
#if TARGET_PC
cXyz* draw_pos = &this->mNrm[0][0];
{
const u8 curr_buffer = this->field_0x74;
const cXyz* curr_pos = &this->mPos[curr_buffer][0];
const MtxP curr_frame = curr_buffer == 0 ? this->mMtx : this->mMtx2;
Mtx curr_frame_inverse;
MTXInverse(curr_frame, curr_frame_inverse);
const u8 prev_buffer = curr_buffer ^ 1;
const cXyz* prev_pos = &this->mPos[prev_buffer][0];
Mtx prev_frame_inverse;
MTXInverse(prev_buffer == 0 ? this->mMtx : this->mMtx2, prev_frame_inverse);
Mtx presented_frame;
MTXCopy(curr_frame, presented_frame);
mant_class* mant_p = reinterpret_cast<mant_class*>(reinterpret_cast<u8*>(this) - offsetof(mant_class, field_0x0570));
if (mant_p != NULL) {
b_gnd_class* parent = (b_gnd_class*)fopAcM_SearchByID(mant_p->parentActorID);
if (parent != NULL && parent->mpModelMorf != NULL) {
J3DModel* model = parent->mpModelMorf->getModel();
if (model != NULL) {
MtxP src34 = model->getAnmMtx(34);
MtxP src25 = model->getAnmMtx(25);
Mtx joint_34_scratch;
Mtx joint_25_scratch;
MtxP joint_34 = dusk::frame_interp::lookup_replacement(src34, joint_34_scratch) ? joint_34_scratch : src34;
MtxP joint_25 = dusk::frame_interp::lookup_replacement(src25, joint_25_scratch) ? joint_25_scratch : src25;
cXyz presented_anchor_a;
cXyz presented_anchor_b;
cXyz local_offset;
MTXCopy(joint_34, *calc_mtx);
local_offset.set(10.0f, 5.0f, -17.0f);
MtxPosition(&local_offset, &presented_anchor_a);
MTXCopy(joint_25, *calc_mtx);
local_offset.set(10.0f, 5.0f, 17.0f);
MtxPosition(&local_offset, &presented_anchor_b);
mant_build_anchor_frame(presented_anchor_a, presented_anchor_b, presented_frame);
}
}
}
const f32 step = dusk::frame_interp::get_interpolation_step();
for (int i = 0; i < 169; ++i) {
cXyz curr_local;
MTXMultVec(curr_frame_inverse, &curr_pos[i], &curr_local);
cXyz prev_local;
MTXMultVec(prev_frame_inverse, &prev_pos[i], &prev_local);
cXyz local = prev_local + ((curr_local - prev_local) * step);
MTXMultVec(presented_frame, &local, &draw_pos[i]);
}
}
GXSETARRAY(GX_VA_POS, draw_pos, sizeof(mNrm[0]), 12, true);
GXSETARRAY(GX_VA_NRM, &l_normal, sizeof(l_normal), 12, false);
#else
GXSETARRAY(GX_VA_POS, this->getPos(), sizeof(mPos[0]), 12, true);
GXSETARRAY(GX_VA_NRM, this->getNrm(), sizeof(mNrm[0]), 12, true);
#endif
GXSETARRAY(GX_VA_TEX0, &l_texCoord, sizeof(l_texCoord), 8, false); // TODO: set to true when converted to float literals
GXSetZCompLoc(0);
@@ -329,9 +425,14 @@ void daMant_packet_c::draw() {
GXSetCullMode(GX_CULL_BACK);
GXLoadPosMtxImm(this->mMtx, GX_PNMTX0);
Mtx MStack_54;
#if TARGET_PC
GXLoadPosMtxImm(j3dSys.getViewMtx(), GX_PNMTX0);
cMtx_inverseTranspose(j3dSys.getViewMtx(), MStack_54);
#else
GXLoadPosMtxImm(this->mMtx, GX_PNMTX0);
cMtx_inverseTranspose(this->mMtx, MStack_54);
#endif
GXLoadNrmMtxImm(MStack_54, GX_PNMTX0);
GXCallDisplayList(l_Egnd_mantDL, 0x3e0);
@@ -347,8 +448,13 @@ void daMant_packet_c::draw() {
GXSetTevKColor(GX_KCOLOR0, COMPOUND_LITERAL(GXColor){0, 0, 0, 0});
GXSetCullMode(GX_CULL_FRONT);
#if TARGET_PC
GXLoadPosMtxImm(j3dSys.getViewMtx(), GX_PNMTX0);
cMtx_inverseTranspose(j3dSys.getViewMtx(), MStack_54);
#else
GXLoadPosMtxImm(this->mMtx2, GX_PNMTX0);
cMtx_inverseTranspose(this->mMtx2, MStack_54);
#endif
GXLoadNrmMtxImm(MStack_54, GX_PNMTX0);
GXCallDisplayList(l_Egnd_mantDL, 0x3e0);
@@ -360,11 +466,13 @@ void daMant_packet_c::draw() {
static int daMant_Draw(mant_class* i_this) {
g_env_light.settingTevStruct(0, &i_this->current.pos, &i_this->tevStr);
#if !TARGET_PC
MtxTrans(0.0f, 0.0f, 0.0f, 0.0f);
cMtx_concat(j3dSys.getViewMtx(), *calc_mtx, i_this->field_0x0570.getMtx());
cMtx_concat(j3dSys.getViewMtx(), *calc_mtx, i_this->field_0x0570.getMtx2());
#endif
i_this->field_0x0570.setTevStr(&i_this->tevStr);
@@ -635,8 +743,13 @@ static void mant_v_calc(mant_class* i_this) {
}
static void mant_move(mant_class* i_this) {
#if TARGET_PC
u8 uVar1 = i_this->field_0x0570.field_0x74 ^ 1;
cXyz* pcVar5 = &i_this->field_0x0570.mPos[uVar1][0];
#else
u8 uVar1 = i_this->field_0x0570.field_0x74;
cXyz* pcVar5 = i_this->field_0x0570.getPos();
#endif
mant_v_calc(i_this);
for (int i = 0; i < 13; i++) {
for (int j = 0; j < 13; j++) {
@@ -644,7 +757,12 @@ static void mant_move(mant_class* i_this) {
}
}
#if TARGET_PC
mant_build_anchor_frame(i_this->field_0x3928[0], i_this->field_0x3928[1], uVar1 == 0 ? i_this->field_0x0570.mMtx : i_this->field_0x0570.mMtx2);
i_this->field_0x0570.field_0x74 = uVar1;
#else
DCStoreRangeNoSync(i_this->field_0x0570.getPos(), 0x7ec);
#endif
}
static int mant_cut_type;
+42 -2
View File
@@ -14,6 +14,10 @@
#include "d/d_s_play.h"
#include "Z2AudioLib/Z2Instances.h"
#if TARGET_PC
#include "dusk/gyro.h"
#endif
enum koro2_parts {
KORO2_PART_BOX = 1,
KORO2_PART_CURVE_A_U_L,
@@ -723,6 +727,14 @@ static void koro2_game(fshop_class* i_this) {
cLib_addCalcAngleS2(&i_this->field_0x4020.x, 0, 2, 0x200);
cLib_addCalcAngleS2(&i_this->field_0x4020.z, 0, 2, 0x200);
case 2:
#if TARGET_PC
if (dusk::getSettings().game.enableGyroRollgoal) {
if (!dusk::gyro::get_sensor_keep_alive()) {
dusk::gyro::set_sensor_keep_alive(true);
}
}
#endif
actor->scale.x = 10.0f;
if (i_this->field_0x4010 == 2) {
static f32 old_stick_x = 0.0f;
@@ -739,11 +751,21 @@ static void koro2_game(fshop_class* i_this) {
old_stick_x = mDoCPd_c::getSubStickX(PAD_1);
cLib_addCalcAngleS2(&i_this->field_0x4060, i_this->field_0x4062, 4, 0x1000);
#if TARGET_PC
if (dusk::getSettings().game.enableGyroRollgoal) {
dusk::gyro::rollgoalTick(true, i_this->field_0x4060);
}
#endif
cMtx_YrotS(*calc_mtx, -i_this->field_0x4060);
sp5C.x = mDoCPd_c::getStickX3D(PAD_1);
sp5C.y = 0.0f;
sp5C.z = mDoCPd_c::getStickY(PAD_1);
#if TARGET_PC
if (dusk::getSettings().game.enableMirrorMode) {
sp5C.x = -sp5C.x;
}
#endif
MtxPosition(&sp5C, &sp68);
f32 reg_f31 = sp68.x;
@@ -765,9 +787,21 @@ static void koro2_game(fshop_class* i_this) {
reg_f30 = 0.0f;
}
cLib_addCalcAngleS2(&i_this->field_0x4020.x, reg_f30 * (-6000.0f + JREG_F(7)), 4, 0x200);
cLib_addCalcAngleS2(&i_this->field_0x4020.z, reg_f31 * (-6000.0f + JREG_F(8)), 4, 0x200);
s16 gyro_ax = 0;
s16 gyro_az = 0;
#if TARGET_PC
if (dusk::getSettings().game.enableGyroRollgoal) {
dusk::gyro::rollgoalTableOffset(gyro_ax, gyro_az);
}
#endif
cLib_addCalcAngleS2(&i_this->field_0x4020.x, reg_f30 * (-6000.0f + JREG_F(7)) + gyro_ax, 4, 0x200);
cLib_addCalcAngleS2(&i_this->field_0x4020.z, reg_f31 * (-6000.0f + JREG_F(8)) + gyro_az, 4, 0x200);
}
#if TARGET_PC
if (i_this->field_0x4010 != 2) {
dusk::gyro::rollgoalTick(false, i_this->field_0x4060);
}
#endif
break;
}
@@ -1145,6 +1179,12 @@ static int daFshop_Delete(fshop_class* i_this) {
}
}
#if TARGET_PC
if (dusk::getSettings().game.enableGyroRollgoal) {
dusk::gyro::set_sensor_keep_alive(false);
}
#endif
return 1;
}
+2 -2
View File
@@ -1054,9 +1054,9 @@ void daMidna_c::setBodyPartMatrix() {
}
mpModel->calcWeightEnvelopeMtx();
#ifdef TARGET_PC
// Frame interpolation: Record weight envelopes for Midna here, as they are otherwise missed causing distortion
// FRAME INTERP NOTE: 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));
dusk::frame_interp::record_final_mtx(mpModel->getWeightAnmMtx(i));
}
#endif
}
+18
View File
@@ -13,6 +13,9 @@
#include <gf/GFGeometry.h>
#include <gf/GFLight.h>
#include "m_Do/m_Do_lib.h"
#if TARGET_PC
#include "dusk/frame_interpolation.h"
#endif
#ifndef __MWERKS__
#include "dusk/math.h"
@@ -27,11 +30,19 @@ static char* l_arcName = "Mirror";
static char* l_arcName2 = "MR-Table";
dMirror_packet_c::dMirror_packet_c() {
#ifdef TARGET_PC
GXInitTexObj(&mTexObj, nullptr, 0, 0, static_cast<GXTexFmt>(-1), GX_MAX_TEXWRAPMODE,
GX_MAX_TEXWRAPMODE, GX_FALSE);
#endif
reset();
}
void dMirror_packet_c::reset() {
#if TARGET_PC
mbReset = true;
#else
mModelCount = 0;
#endif
}
void dMirror_packet_c::calcMinMax() {
@@ -73,6 +84,13 @@ void dMirror_packet_c::calcMinMax() {
}
int dMirror_packet_c::entryModel(J3DModel* i_model) {
#if TARGET_PC
if (mbReset) {
mModelCount = 0;
mbReset = false;
}
#endif
if (mModelCount >= 0x40) {
return 0;
}
+11 -5
View File
@@ -3342,13 +3342,8 @@ static void daMP_THPGXYuv2RgbSetup(const GXRenderModeObj* rmode) {
Mtx44 m;
Mtx e_m;
#if TARGET_PC
w = JUTVideo::getManager()->getFbWidth();
h = JUTVideo::getManager()->getEfbHeight();
#else
w = rmode->fbWidth;
h = rmode->efbHeight;
#endif
var_f31 = 0.0f;
#if WIDESCREEN_SUPPORT
@@ -4383,6 +4378,8 @@ static void daMP_ActivePlayer_Draw() {
daMP_DrawPosX = static_cast<u32>(rect.PosX);
daMP_DrawPosY = static_cast<u32>(rect.PosY);
daMP_THPPlayerSetVolume((dusk::getSettings().audio.masterVolume / 100.0f) * 127.0f, 0);
#endif
int frame = daMP_THPPlayerDrawCurrentFrame(
@@ -4583,3 +4580,12 @@ actor_process_profile_definition g_profile_MOVIE_PLAYER = {
};
AUDIO_INSTANCES;
#if TARGET_PC
void dusk::MoviePlayerShutdown() {
// We need to cleanly shut down the threads to avoid crashes on shutdown.
if (daMP_c::m_myObj) {
daMP_c::m_myObj->daMP_c_Finish();
}
}
#endif
-5
View File
@@ -2694,12 +2694,7 @@ BOOL daNpcT_chkActorInScreen(fopAc_ac_c* i_ActorP, f32 param_1, f32 param_2, f32
}
for (int i = 0; i < 8; i++) {
#if TARGET_PC
mDoLib_project(&pos_array[i], &proj, {0, 0, FB_WIDTH, FB_HEIGHT});
#else
mDoLib_project(&pos_array[i], &proj);
#endif
if (0.0f < proj.x && proj.x < FB_WIDTH && 0.0f < proj.y && proj.y < FB_HEIGHT) {
continue;
}
+4
View File
@@ -110,6 +110,10 @@ static int daNpc_Inko_Execute(npc_inko_class* i_this) {
}
f32 var_f31;
#if AVOID_UB
var_f31 = 0.0f;
#endif
if (i_this->field_0x598 == 0) {
if (i_this->field_0x59c[1] == 0) {
i_this->field_0x59c[1] = 30.0f + cM_rndF(70.0f);
+19
View File
@@ -18,6 +18,7 @@
#include "f_op/f_op_kankyo_mng.h"
#include "c/c_damagereaction.h"
#include "Z2AudioLib/Z2Instances.h"
#include "dusk/frame_interpolation.h"
#include <cstring>
static home_path_pnt home_path[38] = {
@@ -2655,6 +2656,9 @@ static void demo_camera(npc_ne_class* i_this) {
i_this->mCameraFovY = 55.0f;
camera->mCamera.SetTrimSize(3);
daPy_getPlayerActorClass()->changeOriginalDemo();
#ifdef TARGET_PC
dusk::frame_interp::request_presentation_sync();
#endif
// fallthrough
case 2:
@@ -2683,6 +2687,9 @@ static void demo_camera(npc_ne_class* i_this) {
if (i_this->mDemoCounter == 0) {
i_this->mCameraCenter1.set(387.0f, 133.0f, -866.0f);
i_this->mCameraEye1.set(284.0f, 208.0f, -585.0f);
#ifdef TARGET_PC
dusk::frame_interp::request_presentation_sync();
#endif
}
if (i_this->mDemoCounter == 12) {
@@ -2719,6 +2726,9 @@ static void demo_camera(npc_ne_class* i_this) {
i_this->mCameraFovY = 45.0f;
camera->mCamera.SetTrimSize(3);
daPy_getPlayerActorClass()->changeOriginalDemo();
#ifdef TARGET_PC
dusk::frame_interp::request_presentation_sync();
#endif
// fallthrough
case 11:
@@ -2799,8 +2809,14 @@ static void demo_camera(npc_ne_class* i_this) {
MtxPosition(&vec, &i_this->mCameraEye2);
i_this->mCameraEye2 += player->current.pos;
player->changeDemoParam2(2);
#ifdef TARGET_PC
dusk::frame_interp::request_presentation_sync();
#endif
} else if (i_this->mDemoCounter == 120) {
player->changeDemoParam2(0);
#ifdef TARGET_PC
dusk::frame_interp::request_presentation_sync();
#endif
}
}
}
@@ -2853,6 +2869,9 @@ static void demo_camera(npc_ne_class* i_this) {
i_this->mCameraCenter1 = _this->current.pos;
i_this->mCameraCenter1.y += 20.0f;
i_this->mCameraFovY = 55.0f;
#ifdef TARGET_PC
dusk::frame_interp::request_presentation_sync();
#endif
}
camera->mCamera.Set(i_this->mCameraCenter1, i_this->mCameraEye1,
+2 -2
View File
@@ -170,7 +170,7 @@ void daObjLv5Key_c::Fall(int param_0) {
OS_REPORT("FALL SPD = %f\n", speed.y);
if (mAcch.ChkGroundHit()) {
if (mAcch.ChkGroundHit() IF_DUSK(|| current.pos.abs(home.pos) > 200.0f)) {
fopAcM_GetSpeed(this);
fopAcM_SetSpeedF(this, 4.0f);
fopAcM_SetSpeed(this, 0.0f, 22.0f, 0.0f);
@@ -192,7 +192,7 @@ void daObjLv5Key_c::Fall(int param_0) {
mAcch.CrrPos(dComIfG_Bgsp());
current.pos.y = prev_y;
if (mAcch.ChkGroundHit()) {
if (mAcch.ChkGroundHit() IF_DUSK(|| current.pos.abs(home.pos) > 200.0f)) {
setAction(&daObjLv5Key_c::Land, 1);
}
}
-6
View File
@@ -499,13 +499,7 @@ void daObjARI_c::Z_BufferChk() {
cXyz vec2, vec1;
vec1 = current.pos;
vec1.y += 20.0f;
#if TARGET_PC
mDoLib_project(&vec1, &vec2, {0, 0, FB_WIDTH, FB_HEIGHT});
#else
mDoLib_project(&vec1, &vec2);
#endif
f32 trim_height;
camera_process_class* camera = dComIfGp_getCamera(0);
if (camera != NULL) {
-6
View File
@@ -285,13 +285,7 @@ bool Hahen_c::CheckCull() {
bool Hahen_c::checkViewArea() {
Vec proj;
#if TARGET_PC
mDoLib_project(&pos, &proj, {0, 0, FB_WIDTH, FB_HEIGHT});
#else
mDoLib_project(&pos, &proj);
#endif
return (proj.x >= -50.0f && proj.x <= 658.0f) && (proj.y >= -50.0f && proj.y <= 498.0f);
}
-6
View File
@@ -289,13 +289,7 @@ void daObjCHO_c::Z_BufferChk() {
cXyz vec2, vec1;
vec1 = current.pos;
vec1.y += 20.0f;
#if TARGET_PC
mDoLib_project(&vec1, &vec2, {0, 0, FB_WIDTH, FB_HEIGHT});
#else
mDoLib_project(&vec1, &vec2);
#endif
f32 trim_height;
camera_process_class* camera = dComIfGp_getCamera(0);
if (camera != NULL) {
-6
View File
@@ -224,13 +224,7 @@ void daObjCRVFENCE_c::NormalAction() {
bool daObjCRVFENCE_c::checkViewArea(cXyz* param_1) {
Vec sp24;
#if TARGET_PC
mDoLib_project(param_1, &sp24, {0, 0, FB_WIDTH, FB_HEIGHT});
#else
mDoLib_project(param_1, &sp24);
#endif
bool rv = false;
bool bVar1 = false;
-6
View File
@@ -137,13 +137,7 @@ void daObjCRVHAHEN_c::CheckCull() {
bool daObjCRVHAHEN_c::checkViewArea(cXyz* i_this) {
Vec proj;
#if TARGET_PC
mDoLib_project(i_this, &proj, {0, 0, FB_WIDTH, FB_HEIGHT});
#else
mDoLib_project(i_this, &proj);
#endif
bool ret = false;
if (proj.x >= 0.0f && proj.x <= FB_WIDTH && proj.y >= 0.0f && proj.y <= FB_HEIGHT) {
-6
View File
@@ -267,13 +267,7 @@ void daObjDAN_c::Z_BufferChk() {
cXyz vec2, vec1;
vec1 = current.pos;
vec1.y += 20.0f;
#if TARGET_PC
mDoLib_project(&vec1, &vec2, {0, 0, FB_WIDTH, FB_HEIGHT});
#else
mDoLib_project(&vec1, &vec2);
#endif
f32 trim_height;
camera_process_class* camera = dComIfGp_getCamera(0);
if (camera != NULL) {
-6
View File
@@ -201,13 +201,7 @@ void daObjGOMIKABE_c::CheckCull() {
bool daObjGOMIKABE_c::checkViewArea(cXyz param_1) {
Vec local_24;
#if TARGET_PC
mDoLib_project(&param_1, &local_24, {0, 0, FB_WIDTH, FB_HEIGHT});
#else
mDoLib_project(&param_1, &local_24);
#endif
bool rv = false;
if (local_24.x >= 0.0f && local_24.x <= FB_WIDTH && local_24.y >= 0.0f && local_24.y <= FB_HEIGHT) {
rv = true;
-6
View File
@@ -214,13 +214,7 @@ void daObjHHASHI_c::CheckCull() {
bool daObjHHASHI_c::checkViewArea(int param_1) {
Vec local_20;
#if TARGET_PC
mDoLib_project(&field_0x5b0[param_1], &local_20, {0, 0, FB_WIDTH, FB_HEIGHT});
#else
mDoLib_project(&field_0x5b0[param_1], &local_20);
#endif
bool rv = false;
if (local_20.x >= 0.0f && local_20.x <= FB_WIDTH && local_20.y >= 0.0f && local_20.y <= FB_HEIGHT) {
rv = true;
-6
View File
@@ -517,13 +517,7 @@ void daObjKAM_c::Z_BufferChk() {
cXyz currentOffset;
currentOffset = current.pos;
currentOffset.y += 20.0f;
#if TARGET_PC
mDoLib_project(&currentOffset, &currentProj, {0, 0, FB_WIDTH, FB_HEIGHT});
#else
mDoLib_project(&currentOffset, &currentProj);
#endif
camera_process_class* camera = dComIfGp_getCamera(0);
f32 cameraHeight;
if (camera != NULL) {
-6
View File
@@ -611,13 +611,7 @@ void daObjKAT_c::Z_BufferChk() {
cXyz curWithOff;
curWithOff = current.pos;
curWithOff.y += 20.0f;
#if TARGET_PC
mDoLib_project(&curWithOff, &projected, {0, 0, FB_WIDTH, FB_HEIGHT});
#else
mDoLib_project(&curWithOff, &projected);
#endif
camera_process_class* camera = dComIfGp_getCamera(0);
f32 unkFloat1;
if (camera != NULL) {
-6
View File
@@ -528,13 +528,7 @@ void daObjKUW_c::Z_BufferChk() {
cStack_68 = current.pos;
cStack_68.y += 20.0f;
#if TARGET_PC
mDoLib_project(&cStack_68, &local_5c, {0, 0, FB_WIDTH, FB_HEIGHT});
#else
mDoLib_project(&cStack_68, &local_5c);
#endif
camera_process_class* cc = dComIfGp_getCamera(0);
f32 trimHeight;
if (cc != NULL) {
+1 -3
View File
@@ -981,9 +981,7 @@ int daObjStone_c::draw() {
if (!model) {
f32 shadow_size = l_shadow_size[mStoneType];
TGXTexObj* pTex = dDlst_shadowControl_c::getSimpleTex();
cXyz pos = current.pos;
dComIfGd_setSimpleShadow(&pos, mChkObj.GetGroundH(), shadow_size, mChkObj.m_gnd, 0,
dComIfGd_setSimpleShadow(&current.pos, mChkObj.GetGroundH(), shadow_size, mChkObj.m_gnd, 0,
1.0f, pTex);
}
return 1;
-6
View File
@@ -593,13 +593,7 @@ void daObjTEN_c::Z_BufferChk() {
cXyz cStack_68;
cStack_68 = current.pos;
cStack_68.y += 20.0f;
#if TARGET_PC
mDoLib_project(&cStack_68, &local_5c, {0, 0, FB_WIDTH, FB_HEIGHT});
#else
mDoLib_project(&cStack_68, &local_5c);
#endif
camera_process_class* camera = dComIfGp_getCamera(0);
f32 trimHeight;
if (camera != NULL) {
-6
View File
@@ -504,13 +504,7 @@ void daObjTOMBO_c::Z_BufferChk() {
cXyz cStack_68;
cStack_68 = current.pos;
cStack_68.y += 20.0f;
#if TARGET_PC
mDoLib_project(&cStack_68, &local_5c, {0, 0, FB_WIDTH, FB_HEIGHT});
#else
mDoLib_project(&cStack_68, &local_5c);
#endif
camera_process_class* pCamera = dComIfGp_getCamera(0);
f32 trimHeight;
if (pCamera != NULL) {
-5
View File
@@ -38,12 +38,7 @@ BOOL daZraFreeze_c::chkActorInScreen() {
mDoMtx_stack_c::transM(0.0f, 0.0f, 0.0f);
PSMTXMultVecArray(mDoMtx_stack_c::get(), vec, vec, 8);
for (int i = 0; i < 8; i++) {
#if TARGET_PC
mDoLib_project(&vec[i], &proj, {0, 0, FB_WIDTH, FB_HEIGHT});
#else
mDoLib_project(&vec[i], &proj);
#endif
if (0.0f < proj.x && proj.x < FB_WIDTH && 0.0f < proj.y && proj.y < FB_HEIGHT) {
continue;
}
-6
View File
@@ -421,13 +421,7 @@ void daPy_sightPacket_c::draw() {
void daPy_sightPacket_c::setSight() {
Vec proj;
#if TARGET_PC
mDoLib_project(&mPos, &proj, {0, 0, FB_WIDTH, FB_HEIGHT});
#else
mDoLib_project(&mPos, &proj);
#endif
mDoMtx_stack_c::transS(proj.x, proj.y, proj.z);
mDoMtx_stack_c::scaleM(32.0f, 32.0f, 32.0f);
mDoMtx_copy(mDoMtx_stack_c::get(), mProjMtx);
+9 -11
View File
@@ -699,14 +699,14 @@ void dFlower_packet_c::draw() {
if (!cLib_checkBit<u8>(sp44->m_state, 4) && !cLib_checkBit<u8>(sp44->m_state, 0x40)) {
#ifdef TARGET_PC
Mtx flower_mtx;
if (dusk::frame_interp::lookup_replacement(reinterpret_cast<const void*>(&sp44->m_modelMtx), flower_mtx)) {
if (dusk::frame_interp::lookup_replacement(&sp44->m_modelMtx, flower_mtx)) {
cMtx_concat(j3dSys.getViewMtx(), flower_mtx, flower_mtx);
GXLoadPosMtxImm(flower_mtx, 0);
} else {
} else
#endif
{
GXLoadPosMtxImm(sp44->m_modelMtx, 0);
#ifdef TARGET_PC
}
#endif
GXLoadNrmMtxImm(j3dSys.getViewMtx(), 0);
#if TARGET_PC
@@ -854,20 +854,18 @@ void dFlower_packet_c::draw() {
if (!cLib_checkBit<u8>(sp34->m_state, 4) && cLib_checkBit<u8>(sp34->m_state, 0x40)) {
#ifdef TARGET_PC
Mtx flower_mtx;
if (dusk::frame_interp::lookup_replacement(reinterpret_cast<const void*>(&sp34->m_modelMtx), flower_mtx)) {
if (dusk::frame_interp::lookup_replacement(&sp34->m_modelMtx, flower_mtx)) {
cMtx_concat(j3dSys.getViewMtx(), flower_mtx, flower_mtx);
GXLoadPosMtxImm(flower_mtx, 0);
} else {
} else
#endif
{
GXLoadPosMtxImm(sp34->m_modelMtx, 0);
#ifdef TARGET_PC
}
#endif
GXLoadNrmMtxImm(j3dSys.getViewMtx(), 0);
#if TARGET_PC
GXLoadTexObj(&mTexObj_l_J_Ohana01_64128_0419TEX, GX_TEXMAP0);
#endif
if (!cLib_checkBit<u8>(sp34->m_state, 8)) {
if (!cLib_checkBit<u8>(sp34->m_state, 0x10)) {
GXCallDisplayList(mp_Jhana01DL, m_Jhana01DL_size);
@@ -994,7 +992,7 @@ void dFlower_packet_c::update() {
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);
dusk::frame_interp::record_final_mtx(temp_r28, data_p->m_modelMtx);
#endif
}
}
+4 -4
View File
@@ -756,13 +756,13 @@ void dGrass_packet_c::draw() {
#ifdef TARGET_PC
Mtx grass_mtx;
if (dusk::frame_interp::lookup_replacement(reinterpret_cast<const void*>(&var_r29->m_modelMtx), grass_mtx)) {
cMtx_concat(j3dSys.getViewMtx(), grass_mtx, grass_mtx);
GXLoadPosMtxImm(grass_mtx, 0);
} else {
} 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) {
@@ -1018,7 +1018,7 @@ void dGrass_packet_c::update() {
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);
dusk::frame_interp::record_final_mtx(mDoMtx_stack_c::get(), data_p->m_modelMtx);
#endif
}
}
+1 -1
View File
@@ -147,7 +147,7 @@ void dBrightCheck_c::modeMove() {
void dBrightCheck_c::brightCheckWide() {
// Main Canvas
mBrightCheck.Scr->scale(mDoGph_gInf_c::hudAspectScaleUp, 1.0f);
mBrightCheck.Scr->translate(mDoGph_gInf_c::getMinXF(), 0.0f);
mBrightCheck.Scr->translate(mDoGph_gInf_c::getSafeMinXF(), 0.0f);
// Right Square
mBrightCheck.Scr->search(MULTI_CHAR('fuchi_1'))->scale(mDoGph_gInf_c::hudAspectScaleDown, 1.0f);
+18 -4
View File
@@ -7063,6 +7063,15 @@ bool dCamera_c::subjectCamera(s32 param_0) {
}
cXyz sp1E0(val0, val2, val1);
#if TARGET_PC
f32 aspect = mDoGph_gInf_c::getAspect();
f32 baseAspect = FB_WIDTH / FB_HEIGHT;
if (aspect > baseAspect) {
sp1E0.z += (aspect - baseAspect) * 4;
}
#endif
sp1D4 = dCamMath::xyzRotateX(sp1E0, angle_x);
sp1E0 = dCamMath::xyzRotateY(sp1D4, angle_y);
f32 sp6C = sp12 ? 40.0f : 0.0f;
@@ -11009,6 +11018,15 @@ static int camera_execute(camera_process_class* i_this) {
i_this->mCamera.CalcTrimSize();
store(i_this);
#ifdef TARGET_PC
// record new camera for our sim frame
dusk::frame_interp::record_camera(i_this, get_camera_id(i_this));
// interpolate the view now so that this sim frame's view matrix matches what
// we'll be rendering with later
dusk::frame_interp::interp_view(&i_this->view);
#endif
view_setup(i_this);
return 1;
}
@@ -11077,10 +11095,6 @@ static int camera_draw(camera_process_class* i_this) {
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_camera(process, camera_id);
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);
+25 -33
View File
@@ -1096,16 +1096,7 @@ 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);
#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
GXLoadTexMtxImm(mReceiverProjMtx, GX_TEXMTX0, GX_MTX3x4);
mShadowRealPoly.draw();
}
@@ -1263,14 +1254,9 @@ 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;
}
u32 dDlst_shadowReal_c::set(u32 i_key, J3DModel* i_model, cXyz* param_2, f32 param_3, f32 param_4,
dKy_tevstr_c* param_5, f32 i_cameraZ, f32 param_7) {
dScnKy_env_light_c* env_light = dKy_getEnvlight();
@@ -1292,6 +1278,7 @@ u32 dDlst_shadowReal_c::set(u32 i_key, J3DModel* i_model, cXyz* param_2, f32 par
}
field_0x1 = setShadowRealMtx(&sp60, param_2, param_3, param_4, param_7, param_5);
if (!field_0x1) {
return 0;
}
@@ -1331,14 +1318,14 @@ void dDlst_shadowSimple_c::draw() {
GXSetVtxDesc(GX_VA_POS, GX_INDEX8);
#ifdef TARGET_PC
Mtx volume_mtx;
if (dusk::frame_interp::lookup_replacement(&mVolumeMtx, volume_mtx)) {
if (dusk::frame_interp::lookup_replacement(mVolumeMtxKey, volume_mtx)) {
cMtx_concat(j3dSys.getViewMtx(), volume_mtx, volume_mtx);
GXLoadPosMtxImm(volume_mtx, GX_PNMTX0);
} else {
} else
#endif
{
GXLoadPosMtxImm(mVolumeMtx, GX_PNMTX0);
#ifdef TARGET_PC
}
#endif
GXSetCurrentMtx(GX_PNMTX0);
GXCallDisplayList(l_frontMat, 0x40);
GXCallDisplayList(l_shadowVolumeDL, 0x40);
@@ -1346,14 +1333,14 @@ void dDlst_shadowSimple_c::draw() {
GXCallDisplayList(l_shadowVolumeDL, 0x40);
#ifdef TARGET_PC
Mtx shadow_mtx;
if (dusk::frame_interp::lookup_replacement(&mMtx, shadow_mtx)) {
if (dusk::frame_interp::lookup_replacement(mMtxKey, shadow_mtx)) {
cMtx_concat(j3dSys.getViewMtx(), shadow_mtx, shadow_mtx);
GXLoadPosMtxImm(shadow_mtx, GX_PNMTX1);
} else {
} else
#endif
{
GXLoadPosMtxImm(mMtx, GX_PNMTX1);
#ifdef TARGET_PC
}
#endif
GXSetCurrentMtx(GX_PNMTX1);
if (mpTexObj != NULL) {
@@ -1383,6 +1370,12 @@ void dDlst_shadowSimple_c::draw() {
GXCallDisplayList(l_shadowVolumeDL, 0x40);
}
#if TARGET_PC
static const void* getInterpKey(const void* base, int idx) {
return reinterpret_cast<const void*>(reinterpret_cast<uintptr_t>(base) ^ idx);
}
#endif
void dDlst_shadowSimple_c::set(cXyz* param_0, f32 param_1, f32 param_2, cXyz* param_3,
s16 param_4, f32 param_5, TGXTexObj* param_6) {
if (param_5 < 0.0f) {
@@ -1406,6 +1399,10 @@ void dDlst_shadowSimple_c::set(cXyz* param_0, f32 param_1, f32 param_2, cXyz* pa
mDoMtx_stack_c::transS(param_0->x, param_1 + f30, param_0->z);
mDoMtx_stack_c::YrotM(param_4);
mDoMtx_stack_c::scaleM(param_2, f30 + f30 + 16.0f, param_2 * param_5);
#if TARGET_PC
mVolumeMtxKey = getInterpKey(param_0, 0x1);
dusk::frame_interp::record_final_mtx(mDoMtx_stack_c::get(), mVolumeMtxKey);
#endif
cMtx_concat(j3dSys.getViewMtx(), mDoMtx_stack_c::get(), mVolumeMtx);
f32 f31 = JMAFastSqrt(1.0f - param_3->x * param_3->x);
f32 f29;
@@ -1431,17 +1428,11 @@ void dDlst_shadowSimple_c::set(cXyz* param_0, f32 param_1, f32 param_2, cXyz* pa
mDoMtx_stack_c::get()[2][3] = param_0->z;
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
const uint64_t shadow_tag_base = dusk::frame_interp::alloc_simple_shadow_pair_base();
if (shadow_tag_base != 0) {
dusk::frame_interp::record_final_mtx_raw_tagged(&mVolumeMtx, mVolumeMtx, shadow_tag_base);
dusk::frame_interp::record_final_mtx_raw_tagged(&mMtx, mMtx, shadow_tag_base + 1u);
} else {
dusk::frame_interp::record_final_mtx_raw(&mVolumeMtx, mVolumeMtx);
dusk::frame_interp::record_final_mtx_raw(&mMtx, mMtx);
}
mMtxKey = getInterpKey(param_0, 0x2);
dusk::frame_interp::record_final_mtx(mDoMtx_stack_c::get(), mMtxKey);
#endif
cMtx_concat(j3dSys.getViewMtx(), mDoMtx_stack_c::get(), mMtx);
mpTexObj = param_6;
}
@@ -1544,9 +1535,10 @@ void dDlst_shadowControl_c::imageDraw(Mtx param_0) {
#ifdef TARGET_PC
GXCreateFrameBuffer(r26, r26);
needsRestore = true;
#endif
#else
GXSetViewport(0.0f, 0.0f, r26, r26, 0.0f, 1.0f);
GXSetScissor(0, 0, r26, r26);
#endif
}
GXSetTevColor(GX_TEVREG0, l_imageDrawColor[chan]);
if (chan == 3) {
+33 -38
View File
@@ -70,11 +70,7 @@ dFs_HIO_c::dFs_HIO_c() {
select_icon_appear_frames = 5;
appear_display_wait_frames = 15;
field_0x000d = 15;
#if TARGET_PC
card_wait_frames = 0;
#else
card_wait_frames = 90;
#endif
test_frame_counts[0] = 1.11f;
test_frame_counts[1] = 1.11f;
test_frame_counts[2] = 1.11f;
@@ -2102,11 +2098,7 @@ void dFile_select_c::yesnoCursorShow() {
mSelIcon->setPos(pos.x, pos.y, mYnSelPane[field_0x0268]->getPanePtr(), true);
mSelIcon->setAlphaRate(1.0f);
#if TARGET_PC
mSelIcon->setParam(0.96f * mDoGph_gInf_c::hudAspectScaleUp, 0.84f, 0.06f, 0.5f, 0.5f);
#else
mSelIcon->setParam(0.96f, 0.84f, 0.06f, 0.5f, 0.5f);
#endif
}
}
@@ -2259,11 +2251,7 @@ void dFile_select_c::YesNoCancelMove() {
m3mSelPane[mSelectMenuNum]->getPanePtr(), true);
mSelIcon->setAlphaRate(1.0f);
#if TARGET_PC
mSelIcon->setParam(0.96f * mDoGph_gInf_c::hudAspectScaleUp, 0.84f, 0.06f, 0.5f, 0.5f);
#else
mSelIcon->setParam(0.96f, 0.84f, 0.06f, 0.5f, 0.5f);
#endif
#if PLATFORM_WII || PLATFORM_SHIELD
field_0x4333 = mSelectMenuNum;
@@ -2375,7 +2363,7 @@ void dFile_select_c::CommandExec() {
break;
}
mWaitTimer = g_fsHIO.card_wait_frames;
mWaitTimer = IF_DUSK(dusk::getSettings().game.instantSaves ? 0 :) g_fsHIO.card_wait_frames;
}
void dFile_select_c::DataEraseWait() {
@@ -3147,11 +3135,7 @@ void dFile_select_c::screenSet() {
mSelIcon = JKR_NEW dSelect_cursor_c(0, 1.0f, NULL);
JUT_ASSERT(5209, mSelIcon != NULL);
#if TARGET_PC
mSelIcon->setParam(0.96f * mDoGph_gInf_c::hudAspectScaleUp, 0.94f, 0.03f, 0.7f, 0.7f);
#else
mSelIcon->setParam(0.96f, 0.94f, 0.03f, 0.7f, 0.7f);
#endif
Vec vtxCenter;
vtxCenter = mSelFilePanes[mSelectNum]->getGlobalVtxCenter(false, 0);
@@ -3204,6 +3188,9 @@ void dFile_select_c::screenSet() {
timg, NULL);
mpFadePict->setBlackWhite(black, white);
mpFadePict->setAlpha(0);
#ifdef TARGET_PC
mFadeDlst.mpPict = mpFadePict;
#endif
#endif
}
@@ -3284,11 +3271,7 @@ void dFile_select_c::screenSetCopySel() {
mSelIcon2 = JKR_NEW dSelect_cursor_c(0, 1.0f, NULL);
JUT_ASSERT(5406, mSelIcon2 != NULL);
#if TARGET_PC
mSelIcon2->setParam(0.96f * mDoGph_gInf_c::hudAspectScaleUp, 0.94f, 0.03f, 0.7f, 0.7f);
#else
mSelIcon2->setParam(0.96f, 0.94f, 0.03f, 0.7f, 0.7f);
#endif
Vec center = mCpSelPane[0]->getGlobalVtxCenter(false, 0);
mSelIcon2->setPos(center.x, center.y, mCpSelPane[0]->getPanePtr(), true);
@@ -3680,11 +3663,7 @@ void dFile_select_c::selFileCursorShow() {
mSelIcon->setPos(local_1c.x, local_1c.y, mSelFilePanes[mSelectNum]->getPanePtr(), true);
mSelIcon->setAlphaRate(1.0f);
#if TARGET_PC
mSelIcon->setParam(0.96f * mDoGph_gInf_c::hudAspectScaleUp, 0.94f, 0.03f, 0.7f, 0.7f);
#else
mSelIcon->setParam(0.96f, 0.94f, 0.03f, 0.7f, 0.7f);
#endif
}
void dFile_select_c::menuWakuAlpahAnmInit(u8 i_idx, u8 param_1, u8 param_2, u8 param_3) {
@@ -3727,11 +3706,7 @@ void dFile_select_c::menuCursorShow() {
mSelIcon->setPos(local_24.x, local_24.y, m3mSelPane[mSelectMenuNum]->getPanePtr(), true);
mSelIcon->setAlphaRate(1.0f);
#if TARGET_PC
mSelIcon->setParam(0.96f * mDoGph_gInf_c::hudAspectScaleUp, 0.84f, 0.06f, 0.5f, 0.5f);
#else
mSelIcon->setParam(0.96f, 0.84f, 0.06f, 0.5f, 0.5f);
#endif
}
}
@@ -3776,7 +3751,7 @@ bool dFile_select_c::yesnoWakuAlpahAnm(u8 param_1) {
#if TARGET_PC
void dFile_select_c::fileSelectWide() {
mYnSel.ScrYn->scale(mDoGph_gInf_c::hudAspectScaleUp, 1.0f);
mYnSel.ScrYn->translate(mDoGph_gInf_c::getMinXF(), 0.0f);
mYnSel.ScrYn->translate(mDoGph_gInf_c::getSafeMinXF(), 0.0f);
mYnSel.ScrYn->search(MULTI_CHAR('w_no_t'))->scale(mDoGph_gInf_c::hudAspectScaleDown, 1.0f);
mYnSel.ScrYn->search(MULTI_CHAR('f_no_t'))->scale(mDoGph_gInf_c::hudAspectScaleDown, 1.0f);
@@ -3784,7 +3759,7 @@ void dFile_select_c::fileSelectWide() {
mYnSel.ScrYn->search(MULTI_CHAR('f_yes_t'))->scale(mDoGph_gInf_c::hudAspectScaleDown, 1.0f);
m3mSel.Scr3m->scale(mDoGph_gInf_c::hudAspectScaleUp, 1.0f);
m3mSel.Scr3m->translate(mDoGph_gInf_c::getMinXF(), 0.0f);
m3mSel.Scr3m->translate(mDoGph_gInf_c::getSafeMinXF(), 0.0f);
m3mSel.Scr3m->search(MULTI_CHAR('w_sta'))->scale(mDoGph_gInf_c::hudAspectScaleDown, 1.0f);
m3mSel.Scr3m->search(MULTI_CHAR('f_sta'))->scale(mDoGph_gInf_c::hudAspectScaleDown, 1.0f);
@@ -3794,7 +3769,7 @@ void dFile_select_c::fileSelectWide() {
m3mSel.Scr3m->search(MULTI_CHAR('f_cop_t'))->scale(mDoGph_gInf_c::hudAspectScaleDown, 1.0f);
fileSel.Scr->scale(mDoGph_gInf_c::hudAspectScaleUp, 1.0f);
fileSel.Scr->translate(mDoGph_gInf_c::getMinXF(), 0.0f);
fileSel.Scr->translate(mDoGph_gInf_c::getSafeMinXF(), 0.0f);
fileSel.Scr->search(MULTI_CHAR('t_for'))->scale(mDoGph_gInf_c::hudAspectScaleDown, 1.0f);
fileSel.Scr->search(MULTI_CHAR('t_for1'))->scale(mDoGph_gInf_c::hudAspectScaleDown, 1.0f);
@@ -3833,6 +3808,16 @@ void dFile_select_c::fileSelectWide() {
fileSel.Scr->search(MULTI_CHAR('w_uzu07'))->scale(mDoGph_gInf_c::hudAspectScaleDown, 1.0f);
fileSel.Scr->search(MULTI_CHAR('w_uzu08'))->scale(mDoGph_gInf_c::hudAspectScaleDown, 1.0f);
fileSel.Scr->search(MULTI_CHAR('w_uzu09'))->scale(mDoGph_gInf_c::hudAspectScaleDown, 1.0f);
#if TARGET_PC
if (mSelIcon) {
mSelIcon->refreshAspectScale();
}
if (mSelIcon2) {
mSelIcon2->refreshAspectScale();
}
#endif
}
#endif
@@ -3871,9 +3856,7 @@ void dFile_select_c::_draw() {
#if PLATFORM_GCN
#if TARGET_PC
mpFadePict->draw(0, 0,
mDoGph_gInf_c::getWidth(), mDoGph_gInf_c::getHeight(), false, false,
false);
dComIfGd_set2DOpaTop(&mFadeDlst);
#else
mpFadePict->draw(mDoGph_gInf_c::getMinXF(), mDoGph_gInf_c::getMinYF(),
mDoGph_gInf_c::getWidthF(), mDoGph_gInf_c::getHeightF(), false, false,
@@ -3923,6 +3906,13 @@ void dDlst_FileSel3m_c::draw() {
Scr3m->draw(0.0f, 0.0f, graf);
}
#ifdef TARGET_PC
void dDlst_FileSelFade_c::draw() {
mpPict->draw(mDoGph_gInf_c::getMinXF(), mDoGph_gInf_c::getMinYF(),
mDoGph_gInf_c::getWidthF(), mDoGph_gInf_c::getHeightF(), false, false, false);
}
#endif
void dFile_select_c::errorMoveAnmInitSet(int param_1, int param_2) {
mErrorMsgPane->setAnimation(field_0x0090);
field_0x0130 = param_1;
@@ -4765,7 +4755,7 @@ void dFile_select_c::MemCardFormatYesSel2Disp() {
bool isErrorTxtChange = errorTxtChangeAnm();
bool isYnMenuMove = yesnoMenuMoveAnm();
if (isErrorTxtChange == true && isYnMenuMove == true) {
mWaitTimer = g_fsHIO.card_wait_frames;
mWaitTimer = IF_DUSK(dusk::getSettings().game.instantSaves ? 0 :) g_fsHIO.card_wait_frames;
mDoMemCd_Format();
mCardCheckProc = MEMCARDCHECKPROC_FORMAT;
}
@@ -4836,7 +4826,7 @@ void dFile_select_c::MemCardMakeGameFileSelDisp() {
if (isErrorTxtChange == true && isYnMenuMove == true && isKetteiTxtDisp == true) {
if (field_0x0268 != 0) {
mWaitTimer = g_fsHIO.card_wait_frames;
mWaitTimer = IF_DUSK(dusk::getSettings().game.instantSaves ? 0 :) g_fsHIO.card_wait_frames;
setInitSaveData();
dataSave();
mCardCheckProc = MEMCARDCHECKPROC_MAKE_GAMEFILE;
@@ -5584,7 +5574,13 @@ void dFile_select3D_c::createMirrorModel() {
void dFile_select3D_c::toItem3Dpos(f32 param_0, f32 param_1, f32 param_2, cXyz* param_3) {
Mtx adStack_98;
Mtx auStack_c8;
#if TARGET_PC
param_0 =
(2.0f * ((param_0 - mDoGph_gInf_c::getSafeMinXF()) / mDoGph_gInf_c::getSafeWidthF()) -
1.0f);
#else
param_0 = (2.0f * ((param_0 - mDoGph_gInf_c::getMinXF()) / mDoGph_gInf_c::getWidthF()) - 1.0f);
#endif
param_1 = (2.0f * ((param_1 - -100.0f) / FB_HEIGHT_BASE) - 1.0f);
calcViewMtx(adStack_98);
cMtx_inverse(adStack_98, auStack_c8);
@@ -5601,4 +5597,3 @@ void dFile_select3D_c::calcViewMtx(Mtx param_0) {
cXyz pos2(0.0f, 1.0f, 0.0f);
cMtx_lookAt(param_0, &pos1, &cXyz::Zero, &pos2, 0);
}
+3 -4
View File
@@ -37,11 +37,10 @@ void dDlst_Gameover_CAPTURE_c::draw() {
TGXTexObj tex_obj;
Mtx44 m;
#if TARGET_PC
GXSetTexCopySrc(0, 0, mDoGph_gInf_c::getWidth(), mDoGph_gInf_c::getHeight());
GXSetTexCopyDst(mDoGph_gInf_c::getWidth(), mDoGph_gInf_c::getHeight(), GX_TF_RGB565, GX_TRUE);
#else
GXSetTexCopySrc(0, 0, FB_WIDTH, FB_HEIGHT);
#if TARGET_PC
GXSetTexCopyDst(FB_WIDTH, FB_HEIGHT, GX_TF_RGB565, GX_FALSE);
#else
GXSetTexCopyDst(FB_WIDTH / 2, FB_HEIGHT / 2, GX_TF_RGB565, GX_TRUE);
#endif
GXCopyTex(mDoGph_gInf_c::mZbufferTex, 0);
-4
View File
@@ -82,11 +82,7 @@ void dInsect_c::CalcZBuffer(f32 param_0) {
pos = current.pos;
pos.y += 20.0f;
#if TARGET_PC
mDoLib_project(&pos, &pos_projected, {0, 0, FB_WIDTH, FB_HEIGHT});
#else
mDoLib_project(&pos, &pos_projected);
#endif
if (dComIfGp_getCamera(0)) {
camera_trim_height = dComIfGp_getCamera(0)->mCamera.mTrimHeight;
+10 -4
View File
@@ -33,7 +33,9 @@
#include <cstdlib>
#include <cstring>
#if TARGET_PC
#include "dusk/imgui/ImGuiBloomWindow.hpp"
#include "dusk/settings.h"
#include "dusk/frame_interpolation.h"
#endif
static void GxXFog_set();
@@ -2578,6 +2580,10 @@ void dScnKy_env_light_c::setLight() {
mDoGph_gInf_c::getBloom()->setMode(mode);
}
#if TARGET_PC
dusk::ApplyBloomOverride();
#endif
f32 var_f30;
if (dKy_Outdoor_check() == true) {
static f32 now_shadow_alpha[] = {0.25f, 0.35f, 0.6f, 0.6f, 0.25f, 0.35f};
@@ -8246,6 +8252,10 @@ static int dKy_Create(void* i_this) {
kankyo_class* kankyo = (kankyo_class*)i_this;
BOOL next_time_set = false;
#if TARGET_PC
kankyo->base.draw_interp_frame = true;
#endif
stage_envr_info_class* stage_envr_p = dComIfGp_getStageEnvrInfo();
if (stage_envr_p != NULL && dComIfGp_getStartStageRoomNo() != -1) {
stage_envr_p += dComIfGp_getStartStageRoomNo();
@@ -10999,11 +11009,7 @@ void dKy_depth_dist_set(void* process_p) {
f32 var_f31 = sp24.abs(camera_p->view.lookat.eye);
if (var_f31 < 2000.0f && var_f31 < kankyo->field_0x1268) {
#if TARGET_PC
mDoLib_project(&actor_p->eyePos, &sp30, {0, 0, FB_WIDTH, FB_HEIGHT});
#else
mDoLib_project(&actor_p->eyePos, &sp30);
#endif
if ((sp30.x >= 0.0f && sp30.x < FB_WIDTH) && (sp30.y >= 0.0f &&
#if DEBUG
-5
View File
@@ -915,12 +915,7 @@ void dKydb_dungeonlight_draw() {
rot.y = 0;
dDbVw_drawCubeXlu(player->current.pos, size, rot, color);
#if TARGET_PC
mDoLib_project(&g_env_light.dungeonlight[i].mPosition, &proj, {0, 0, FB_WIDTH, FB_HEIGHT});
#else
mDoLib_project(&g_env_light.dungeonlight[i].mPosition, &proj);
#endif
if (proj.x > 30.0f) {
proj.x -= 30.0f;
}
-93
View File
@@ -116,12 +116,7 @@ void dKyr_lenzflare_move() {
cXyz vect;
cXyz proj;
cXyz center;
#if TARGET_PC
mDoLib_project(lenz_packet->mPositions, &proj, {0, 0, FB_WIDTH, FB_HEIGHT});
#else
mDoLib_project(lenz_packet->mPositions, &proj);
#endif
center.x = FB_WIDTH / 2;
center.y = FB_HEIGHT / 2;
@@ -221,12 +216,7 @@ void dKyr_sun_move() {
}
cXyz proj;
#if TARGET_PC
mDoLib_project(sun_packet->mPos, &proj, {0, 0, FB_WIDTH, FB_HEIGHT});
#else
mDoLib_project(sun_packet->mPos, &proj);
#endif
for (int i = 0; i < 5; i++) {
cXyz chkpnt = proj;
@@ -4110,62 +4100,24 @@ void dKyr_drawStar(Mtx drawMtx, u8** tex) {
color_reg0.b = 0xFF;
color_reg0.a = 0xFF;
#if TARGET_PC
Mtx star_gx_view;
cXyz anchor_eye;
f32 star_fovy = 45.0f;
MtxP gx_load_view = drawMtx;
bool star_use_present_view = false;
if (dusk::getSettings().game.enableFrameInterpolation) {
star_use_present_view = dusk::frame_interp::build_star_view(star_gx_view, camMtx, &anchor_eye, &star_fovy);
}
if (star_use_present_view) {
gx_load_view = star_gx_view;
} else {
if (dComIfGd_getView() != NULL) {
MTXInverse(dComIfGd_getView()->viewMtxNoTrans, camMtx);
anchor_eye = camera->view.lookat.eye;
star_fovy = dComIfGd_getView()->fovy;
} else {
return;
}
}
#else
if (dComIfGd_getView() != NULL) {
MTXInverse(dComIfGd_getView()->viewMtxNoTrans, camMtx);
} else {
return;
}
#endif
if (strcmp(dComIfGp_getStartStageName(), "F_SP200") == 0 && dComIfG_play_c::getLayerNo(0) == 0) {
moon_pos = envlight->moon_pos;
} else {
#if TARGET_PC
moon_pos = anchor_eye + envlight->moon_pos;
#else
moon_pos = camera->view.lookat.eye + envlight->moon_pos;
#endif
if (sp38) {
#if TARGET_PC
moon_pos.x = 3900.0f + anchor_eye.x;
moon_pos.y = 8052.0f + anchor_eye.y;
moon_pos.z = -9072.0f + anchor_eye.z;
#else
moon_pos.x = 3900.0f + camera->view.lookat.eye.x;
moon_pos.y = 8052.0f + camera->view.lookat.eye.y;
moon_pos.z = -9072.0f + camera->view.lookat.eye.z;
#endif
}
}
#if TARGET_PC
mDoLib_project(&moon_pos, &moon_proj, {0, 0, FB_WIDTH, FB_HEIGHT});
#else
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.
@@ -4193,11 +4145,7 @@ void dKyr_drawStar(Mtx drawMtx, u8** tex) {
MTXRotRad(rotMtx, 'Z', DEG_TO_RAD(rot));
MTXConcat(camMtx, rotMtx, camMtx);
#if TARGET_PC
GXLoadPosMtxImm(gx_load_view, GX_PNMTX0);
#else
GXLoadPosMtxImm(drawMtx, GX_PNMTX0);
#endif
GXSetCurrentMtx(GX_PNMTX0);
rot += 0.65f;
@@ -4205,23 +4153,12 @@ void dKyr_drawStar(Mtx drawMtx, u8** tex) {
rot = 0.0f;
}
#if TARGET_PC
spBC = anchor_eye;
#else
spBC.x = camera->view.lookat.eye.x;
spBC.y = camera->view.lookat.eye.y;
spBC.z = camera->view.lookat.eye.z;
#endif
f32 sp34 = -1.0f;
int sp30 = 0;
#if TARGET_PC
f32 var_f30 = star_fovy / 45.0f;
if (var_f30 >= 1.0f) {
var_f30 = 1.0f;
}
var_f30 = 1.0f - var_f30;
#else
f32 var_f30 = 0.0f;
if (dComIfGd_getView() != NULL) {
@@ -4231,7 +4168,6 @@ void dKyr_drawStar(Mtx drawMtx, u8** tex) {
}
var_f30 = 1.0f - var_f30;
}
#endif
f32 temp_f27 = 0.28f * (1.0f - var_f30);
sp98.x = 0.0f;
@@ -4330,11 +4266,7 @@ void dKyr_drawStar(Mtx drawMtx, u8** tex) {
sp68.y = spBC.y + star_pos.y;
sp68.z = spBC.z + star_pos.z;
#if TARGET_PC
mDoLib_project(&sp68, &star_proj, {0, 0, FB_WIDTH, FB_HEIGHT});
#else
mDoLib_project(&sp68, &star_proj);
#endif
moon_proj.z = 0.0f;
star_proj.z = 0.0f;
@@ -4749,11 +4681,7 @@ void drawVrkumo(Mtx drawMtx, GXColor& color, u8** tex) {
}
if (g_env_light.daytime > 105.0f && g_env_light.daytime < 240.0f && !dComIfGp_event_runCheck() && sun_packet != NULL && sun_packet->mSunAlpha > 0.0f) {
#if TARGET_PC
mDoLib_project(&sun_packet->mPos[0], &proj, {0, 0, FB_WIDTH, FB_HEIGHT});
#else
mDoLib_project(&sun_packet->mPos[0], &proj);
#endif
if (proj.x > 0.0f && proj.x < FB_WIDTH && proj.y > spC4 && proj.y < (458.0f - spC4)) {
pass = 0;
}
@@ -5018,12 +4946,7 @@ void drawVrkumo(Mtx drawMtx, GXColor& color, u8** tex) {
x = 100.0f;
y = 100.0f;
z = 100.0f;
#if TARGET_PC
mDoLib_project(&spF0, &proj, {0, 0, FB_WIDTH, FB_HEIGHT});
#else
mDoLib_project(&spF0, &proj);
#endif
if (proj.x > -x && proj.x < (FB_WIDTH + x) && proj.y > -y && proj.y < (458.0f + z)) {
break;
@@ -5073,12 +4996,7 @@ void drawVrkumo(Mtx drawMtx, GXColor& color, u8** tex) {
x = 100.0f;
y = 100.0f;
z = 100.0f;
#if TARGET_PC
mDoLib_project(&spE4, &proj, {0, 0, FB_WIDTH, FB_HEIGHT});
#else
mDoLib_project(&spE4, &proj);
#endif
if (proj.x > -x && proj.x < (FB_WIDTH + x) && proj.y > -y && proj.y < (458.0f + z)) {
break;
@@ -6118,13 +6036,7 @@ static void dKyr_evil_draw2(Mtx drawMtx, u8** tex) {
sp34.x = 80.0f;
sp34.y = 80.0f;
sp34.z = 80.0f;
#if TARGET_PC
mDoLib_project(&sp7C, &proj, {0, 0, FB_WIDTH, FB_HEIGHT});
#else
mDoLib_project(&sp7C, &proj);
#endif
if (!(proj.x > -sp34.x) || !(proj.x < (FB_WIDTH + sp34.x)) ||
!(proj.y > -sp34.y) || !(proj.y < (458.0f + sp34.z)))
{
@@ -6349,12 +6261,7 @@ void dKyr_evil_draw(Mtx drawMtx, u8** tex) {
sp44.y = 80.0f;
sp44.z = 80.0f;
#if TARGET_PC
mDoLib_project(&spA4, &proj, {0, 0, FB_WIDTH, FB_HEIGHT});
#else
mDoLib_project(&spA4, &proj);
#endif
if (!(proj.x > -sp44.x) || !(proj.x < (FB_WIDTH + sp44.x)) ||
!(proj.y > -sp44.y) || !(proj.y < (458.0f + sp44.z)))
{
+13 -16
View File
@@ -16,10 +16,6 @@
#ifdef TARGET_PC
constexpr u16 kMapResolutionMultiplier = 4;
// Line widths are relative to the framebuffer size. Since we're rendering to a separate
// framebuffer, we have to scale them accordingly. The original game used about half of the
// EFB for the map rendering, so this is a reasonable approximation.
constexpr u8 kMapLineWidthMultiplier = 2;
#endif
void dMpath_n::dTexObjAggregate_c::create() {
@@ -242,11 +238,7 @@ void dDrawPath_c::rendering(dDrawPath_c::line_class const* p_line) {
int width = getLineWidth(p_line->field_0x1);
if (width > 0 && p_line->mDataNum >= 2) {
#ifdef TARGET_PC
GXSetLineWidth(width * kMapLineWidthMultiplier, GX_TO_ZERO);
#else
GXSetLineWidth(width * 2, GX_TO_ZERO);
#endif
GXSetLineWidth(width, GX_TO_ZERO);
GXSetTevColor(GX_TEVREG0, *getLineColor(p_line->field_0x0 & 0x3F, p_line->field_0x1));
GXBegin(GX_LINESTRIP, GX_VTXFMT0, p_line->mDataNum);
@@ -435,8 +427,12 @@ void dRenderingFDAmap_c::preRenderingMap() {
const u16 w = mTexWidth * kMapResolutionMultiplier;
const u16 h = mTexHeight * kMapResolutionMultiplier;
GXCreateFrameBuffer(w, h);
GXSetViewport(0.0f, 0.0f, w, h, 0.0f, 1.0f);
GXSetScissor(0, 0, w, h);
// Set logical viewport dimensions
GXSetViewport(0.0f, 0.0f, mTexWidth, mTexHeight, 0.0f, 1.0f);
GXSetScissor(0, 0, mTexWidth, mTexHeight);
// Set render viewport dimensions
GXSetViewportRender(0.0f, 0.0f, w, h, 0.0f, 1.0f);
GXSetScissorRender(0, 0, w, h);
#else
GXSetViewport(0.0f, 0.0f, mTexWidth, mTexHeight, 0.0f, 1.0f);
GXSetScissor(0, 0, mTexWidth, mTexHeight);
@@ -456,6 +452,12 @@ void dRenderingFDAmap_c::preRenderingMap() {
GXSetClipMode(GX_CLIP_ENABLE);
setTevSettingNonTextureDirectColor();
f32 right = field_0x8 * 0.5f;
#if TARGET_PC
if (dusk::getSettings().game.enableMirrorMode) {
right = field_0x8 * -0.5f;
}
#endif
f32 top = field_0xc * 0.5f;
Mtx44 matrix;
C_MTXOrtho(matrix, top, -top, -right, right, 0.0f, 10000.0f);
@@ -511,13 +513,8 @@ void dRenderingFDAmap_c::renderingDecoration(dDrawPath_c::line_class const* p_li
BE(u16)* data_p = p_line->mpData;
s32 data_num = p_line->mDataNum;
#ifdef TARGET_PC
GXSetLineWidth(width * kMapLineWidthMultiplier, GX_TO_ZERO);
GXSetPointSize(width * kMapLineWidthMultiplier, GX_TO_ONE);
#else
GXSetLineWidth(width, GX_TO_ONE);
GXSetPointSize(width, GX_TO_ONE);
#endif
GXColor lineColor = *getDecoLineColor(p_line->field_0x0 & 0x3f, p_line->field_0x1);
GXSetTevColor(GX_TEVREG0, lineColor);
lineColor.r = lineColor.r - 4;
+19 -19
View File
@@ -99,7 +99,7 @@ dMenu_Collect2D_c::~dMenu_Collect2D_c() {
void dMenu_Collect2D_c::menuCollectWide() {
// Main Canvas
mpScreen->scale(mDoGph_gInf_c::hudAspectScaleUp, 1.0f);
mpScreen->translate(mDoGph_gInf_c::getMinXF(), 0.0f);
mpScreen->translate(mDoGph_gInf_c::getSafeMinXF(), 0.0f);
// Pieces of Heart
mpScreen->search(MULTI_CHAR('heart_n'))->scale(mDoGph_gInf_c::hudAspectScaleDown, 1.0f);
@@ -164,11 +164,22 @@ void dMenu_Collect2D_c::menuCollectWide() {
// Item Description Text
mpScreen->search(MULTI_CHAR('infotxtn'))->scale(mDoGph_gInf_c::hudAspectScaleDown, 1.0f);
#if TARGET_PC
if (mpDrawCursor) {
mpDrawCursor->refreshAspectScale();
}
#endif
}
#endif
void dMenu_Collect2D_c::_create() {
mpHeap->getTotalFreeSize();
#if TARGET_PC
mpDrawCursor = NULL;
#endif
mpScreen = JKR_NEW J2DScreen();
mpScreen->setPriority("zelda_collect_soubi_screen.blo", 0x1020000,
dComIfGp_getCollectResArchive());
@@ -182,7 +193,7 @@ void dMenu_Collect2D_c::_create() {
}
#if TARGET_PC
mpScreenIcon->translate(-mDoGph_gInf_c::getMinXF(), 0.0f);
mpScreenIcon->translate(-mDoGph_gInf_c::getSafeMinXF(), 0.0f);
#endif
dPaneClass_showNullPane(mpScreenIcon);
@@ -1100,23 +1111,11 @@ void dMenu_Collect2D_c::cursorPosSet() {
Vec pos = mpSelPm[mCursorX][mCursorY]->getGlobalVtxCenter(false, 0);
mpDrawCursor->setPos(pos.x, pos.y, mpSelPm[mCursorX][mCursorY]->getPanePtr(), false);
if (mCursorY == 5) {
#if TARGET_PC
mpDrawCursor->setParam(1.1f * mDoGph_gInf_c::hudAspectScaleUp, 0.85f, 0.05f, 0.5f, 0.5f);
#else
mpDrawCursor->setParam(1.1f, 0.85f, 0.05f, 0.5f, 0.5f);
#endif
} else if (mCursorX == 6 && mCursorY == 0) {
#if TARGET_PC
mpDrawCursor->setParam(0.6f * mDoGph_gInf_c::hudAspectScaleUp, 0.85f, 0.03f, 0.6f, 0.6f);
#else
mpDrawCursor->setParam(0.6f, 0.85f, 0.03f, 0.6f, 0.6f);
#endif
} else {
#if TARGET_PC
mpDrawCursor->setParam(1.0f * mDoGph_gInf_c::hudAspectScaleUp, 1.0f, 0.1f, 0.7f, 0.7f);
#else
mpDrawCursor->setParam(1.0f, 1.0f, 0.1f, 0.7f, 0.7f);
#endif
}
}
@@ -2688,12 +2687,7 @@ u8 dMenu_Collect3D_c::getMaskMdlVisible() {
f32 dMenu_Collect3D_c::mViewOffsetY = -100.0f;
void dMenu_Collect3D_c::setupItem3D(Mtx param_0) {
#if TARGET_PC
f32 scaleFactor = mDoGph_gInf_c::getHeight() / FB_HEIGHT;
GXSetViewport(0.0f, mViewOffsetY * scaleFactor, mDoGph_gInf_c::getWidth(), mDoGph_gInf_c::getHeight(), 0.0f, 1.0f);
#else
GXSetViewport(0.0f, mViewOffsetY, FB_WIDTH, FB_HEIGHT, 0.0f, 1.0f);
#endif
mViewOffsetY = -100.0f;
Mtx44 projection;
C_MTXPerspective(projection, 45.0f, mDoGph_gInf_c::getAspect(), 1.0f, 100000.0f);
@@ -2706,8 +2700,14 @@ void dMenu_Collect3D_c::setupItem3D(Mtx param_0) {
void dMenu_Collect3D_c::toItem3Dpos(f32 param_0, f32 param_1, f32 param_2, cXyz* param_3) {
Mtx adStack_98;
Mtx auStack_c8;
#if TARGET_PC
param_0 =
(2.0f * ((param_0 - mDoGph_gInf_c::getSafeMinXF()) / mDoGph_gInf_c::getSafeWidthF()) -
1.0f);
#else
param_0 =
(2.0f * ((param_0 - mDoGph_gInf_c::getMinXF()) / mDoGph_gInf_c::getWidthF()) - 1.0f);
#endif
param_1 = (2.0f * ((param_1 - -100.0f) / FB_HEIGHT_BASE) - 1.0f);
calcViewMtx(adStack_98);
MTXInverse(adStack_98, auStack_c8);
+30 -29
View File
@@ -864,33 +864,15 @@ void dMenu_DmapBg_c::draw() {
J2DOrthoGraph* grafContext = (J2DOrthoGraph*)dComIfGp_getCurrentGrafPort();
grafContext->setup2D();
#if TARGET_PC
// GXGetScissor uses 11-bit GC register fields (max 2047) which overflow
// at window widths > ~1705px, producing garbage values on restore.
scissor_left = 0;
scissor_top = 0;
scissor_width = (u32)mDoGph_gInf_c::getWidth();
scissor_height = (u32)mDoGph_gInf_c::getHeight();
#else
GXGetScissor(&scissor_left, &scissor_top, &scissor_width, &scissor_height);
#endif
#if TARGET_PC
grafContext->scissor(field_0xd94, 0.0f, mDoGph_gInf_c::getWidth(), mDoGph_gInf_c::getHeight());
#else
grafContext->scissor(field_0xd94, 0.0f, FB_WIDTH, FB_HEIGHT);
#endif
grafContext->scissor(field_0xd94, 0.0f, FB_WIDTH, FB_HEIGHT);
grafContext->setScissor();
mBaseScreen->draw(field_0xd94, field_0xd98, grafContext);
dMenu_Dmap_c::myclass->drawFloorScreenBack(mFloorScreen, field_0xd94, field_0xd98, grafContext);
#if TARGET_PC
f32 dVar21 = mDoGph_gInf_c::getWidthF() / mDoGph_gInf_c::getWidth();
f32 dVar16 = mDoGph_gInf_c::getHeightF() / mDoGph_gInf_c::getHeight();
#else
f32 dVar21 = mDoGph_gInf_c::getWidthF() / FB_WIDTH;
f32 dVar16 = mDoGph_gInf_c::getHeightF() / FB_HEIGHT;
#endif
mMapScreen[0]->draw(field_0xd94, field_0xd98, grafContext);
if (mpBackTexture != NULL) {
@@ -922,15 +904,9 @@ void dMenu_DmapBg_c::draw() {
mpBackTexture->draw(local_28c, field_0xd94 + mpBackTexture->getBounds().i.y, mpBackTexture->getWidth(),
mpBackTexture->getHeight(), false, false, false);
#if TARGET_PC
grafContext->scissor(field_0xd94,
0, mDoGph_gInf_c::getWidth(),
scissor_height);
#else
grafContext->scissor(field_0xd94 + mDoGph_gInf_c::getMinXF(),
scissor_top, mDoGph_gInf_c::getWidthF(),
scissor_height);
#endif
grafContext->setScissor();
}
@@ -957,11 +933,7 @@ void dMenu_DmapBg_c::draw() {
Vec local_26c = pane.getGlobalVtx(mMapPane, &local_110, 0, false, 0);
drawIcon(local_26c.x + field_0xd94, local_26c.y, field_0xda8, 1.0f);
#if TARGET_PC
grafContext->scissor(field_0xd94, scissor_top, mDoGph_gInf_c::getWidth(), scissor_height);
#else
grafContext->scissor(field_0xd94 + mDoGph_gInf_c::getMinXF(), scissor_top, mDoGph_gInf_c::getWidthF(), scissor_height);
#endif
grafContext->setScissor();
grafContext->scissor(scissor_left, scissor_top, scissor_width, scissor_height);
grafContext->setScissor();
@@ -1012,7 +984,36 @@ void dMenu_DmapBg_c::update() {
JUT_ASSERT(2323, mpBackTexture != NULL);
void* spec = mpArchive->getResource("spec/spec.dat");
#if TARGET_PC
struct dmap_spec {
/* 0x00 */ BE(f32) field_0x0;
/* 0x04 */ BE(f32) field_0x4;
/* 0x08 */ BE(f32) field_0x8;
/* 0x0C */ u8 field_0xc;
/* 0x0D */ u8 field_0xd;
/* 0x0E */ u8 field_0xe;
/* 0x0F */ u8 field_0xf;
/* 0x10 */ u8 field_0x10;
/* 0x11 */ u8 field_0x11;
/* 0x12 */ u8 field_0x12;
/* 0x13 */ u8 field_0x13;
};
dmap_spec* dspec = (dmap_spec*)spec;
field_0xd80 = dspec->field_0x0;
field_0xd84 = dspec->field_0x4;
field_0xd88 = dspec->field_0x8;
field_0xd8c = dspec->field_0xc;
field_0xd8d = dspec->field_0xd;
field_0xd8e = dspec->field_0xe;
field_0xd8f = dspec->field_0xf;
field_0xd90 = dspec->field_0x10;
field_0xd91 = dspec->field_0x11;
field_0xd92 = dspec->field_0x12;
field_0xd93 = dspec->field_0x13;
#else
memcpy(&field_0xd80, spec, 20);
#endif
}
}
+23 -31
View File
@@ -276,18 +276,14 @@ void dMenu_Fmap2DBack_c::draw() {
u32 scissorLeft, scissorTop, scissorWidth, scissorHeight;
GXGetScissor(&scissorLeft, &scissorTop, &scissorWidth, &scissorHeight);
#if TARGET_PC
grafPort->scissor(mTransX, 0.0f, mDoGph_gInf_c::getWidth(), mDoGph_gInf_c::getHeight());
#else
grafPort->scissor(mTransX, 0.0f, FB_WIDTH, FB_HEIGHT);
#endif
grafPort->setScissor();
mpBackTex->setBlackWhite(field_0x1208, field_0x120c);
mpBackTex->setAlpha(mAlphaRate * 255.0f * g_fmapHIO.mBackgroundAlpha);
mpBackTex->draw(mTransX + mDoGph_gInf_c::getMinXF(),
mTransZ + mDoGph_gInf_c::getMinYF(), mDoGph_gInf_c::getWidth(),
mDoGph_gInf_c::getHeight(), false, false, false);
mTransZ + mDoGph_gInf_c::getMinYF(), mDoGph_gInf_c::getWidthF(),
mDoGph_gInf_c::getHeightF(), false, false, false);
mpBackScreen->draw(mTransX, mTransZ, grafPort);
mpBaseScreen->draw(mTransX, mTransZ, grafPort);
@@ -297,13 +293,8 @@ void dMenu_Fmap2DBack_c::draw() {
Vec vec2 = mpMapArea->getGlobalVtx(&mtx, 3, false, 0);
#if TARGET_PC
f32 width = mDoGph_gInf_c::getWidthF() / mDoGph_gInf_c::getWidth();
f32 height = mDoGph_gInf_c::getHeightF() / mDoGph_gInf_c::getHeight();
#else
f32 width = mDoGph_gInf_c::getWidthF() / FB_WIDTH;
f32 height = mDoGph_gInf_c::getHeightF() / FB_HEIGHT;
#endif
grafPort->scissor(mTransX + ((vec1.x - mDoGph_gInf_c::getMinXF()) / width),
mTransZ + (vec1.y / height), (vec2.x - vec1.x) / width,
@@ -351,8 +342,13 @@ void dMenu_Fmap2DBack_c::draw() {
scrollAreaDraw();
}
blinkMove(30);
moveLightDropAnime();
#ifdef TARGET_PC
if (dusk::frame_interp::get_ui_tick_pending())
#endif
{
blinkMove(30);
moveLightDropAnime();
}
setCenterPosX(field_0x11dc, 1);
drawIcon(mTransX, mTransZ, mAlphaRate, field_0xfa8 * mSpotTextureFadeAlpha);
@@ -360,11 +356,7 @@ void dMenu_Fmap2DBack_c::draw() {
drawDebugRegionArea();
}
#if TARGET_PC
grafPort->scissor(scissorLeft, scissorTop, mDoGph_gInf_c::getWidth(), mDoGph_gInf_c::getHeight());
#else
grafPort->scissor(scissorLeft, scissorTop, scissorWidth, scissorHeight);
#endif
grafPort->setScissor();
if (isArrowDrawFlag()) {
@@ -392,16 +384,15 @@ void dMenu_Fmap2DBack_c::draw() {
&mArrowPos2DY);
#ifdef TARGET_PC
for (u32 i = 0; i < dusk::frame_interp::get_presentation_ui_advance_ticks(); ++i) {
if (dusk::frame_interp::get_ui_tick_pending())
#endif
{
field_0x11e0 -= g_fmapHIO.mCursorSpeed;
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,
@@ -1778,14 +1769,19 @@ void dMenu_Fmap2DBack_c::calcBlink() {
t * (g_fmapHIO.mMapBlink[i + 1].mUnselectedRegion.mBlinkSpeed -
g_fmapHIO.mMapBlink[i].mUnselectedRegion.mBlinkSpeed);
field_0x1218++;
if (field_0x1218 >= selected_blink_speed) {
field_0x1218 = 0;
}
#if TARGET_PC
if (dusk::frame_interp::get_ui_tick_pending())
#endif
{
field_0x1218++;
if (field_0x1218 >= selected_blink_speed) {
field_0x1218 = 0;
}
field_0x121a++;
if (field_0x121a >= unselected_blink_speed) {
field_0x121a = 0;
field_0x121a++;
if (field_0x121a >= unselected_blink_speed) {
field_0x121a = 0;
}
}
f32 t_selected = 0.0f;
@@ -2580,11 +2576,7 @@ void dMenu_Fmap2DTop_c::draw() {
J2DOrthoGraph* ctx = static_cast<J2DOrthoGraph*>(dComIfGp_getCurrentGrafPort());
ctx->setup2D();
GXGetScissor(&scissor_left, &scissor_top, &scissor_width, &scissor_height);
#if TARGET_PC
ctx->scissor(mTransX, 0.0f, mDoGph_gInf_c::getWidth(), mDoGph_gInf_c::getHeight());
#else
ctx->scissor(mTransX, 0.0f, FB_WIDTH, FB_HEIGHT);
#endif
ctx->setScissor();
mpTitleScreen->draw(mTransX, mTransY, ctx);
ctx->scissor(scissor_left, scissor_top, scissor_width, scissor_height);
-5
View File
@@ -223,13 +223,8 @@ void dMenu_Letter_c::_draw() {
f32 y1 = local_178.y;
Vec local_184;
local_184 = afStack_138.getGlobalVtx(field_0x1ec, &mtx, 3, false, 0);
#if TARGET_PC
f32 dVar17 = mDoGph_gInf_c::getWidthF() / mDoGph_gInf_c::getWidth();
f32 dVar16 = mDoGph_gInf_c::getHeightF() / mDoGph_gInf_c::getHeight();
#else
f32 dVar17 = mDoGph_gInf_c::getWidthF() / FB_WIDTH;
f32 dVar16 = mDoGph_gInf_c::getHeightF() / FB_HEIGHT;
#endif
f32 fVar1 = (x1 - mDoGph_gInf_c::getMinXF()) / dVar17;
f32 fVar2 = y1 / dVar16;
grafContext->scissor(fVar1, fVar2,
+4
View File
@@ -555,19 +555,23 @@ void dMenu_Option_c::_draw() {
#endif
mpBlackTex->setAlpha(0xff);
#if TARGET_PC
mpBlackTex->draw(mDoGph_gInf_c::getMinXF(), mDoGph_gInf_c::getMinYF(), mDoGph_gInf_c::getWidthF(), mDoGph_gInf_c::getHeightF(), 0, 0, 0);
#else
mpBlackTex->draw(0.0f, 0.0f, FB_WIDTH, FB_HEIGHT, 0, 0, 0);
#endif
mpBackScreen->draw(0.0f, 0.0f, ctx);
f32 alpha = (f32)g_drawHIO.mOptionScreen.mBackgroundAlpha * (f32)field_0x374;
mpBlackTex->setAlpha(alpha);
#if TARGET_PC
mpBlackTex->draw(mDoGph_gInf_c::getMinXF(), mDoGph_gInf_c::getMinYF(), mDoGph_gInf_c::getWidthF(), mDoGph_gInf_c::getHeightF(), 0, 0, 0);
#else
mpBlackTex->draw(0.0f, 0.0f, FB_WIDTH, FB_HEIGHT, 0, 0, 0);
#endif
mpScreen->draw(0.0f, 0.0f, ctx);
mpClipScreen->draw(0.0f, 0.0f, ctx);
#if TARGET_PC
+33
View File
@@ -29,6 +29,10 @@
#include <cstdio>
#if TARGET_PC
#include "dusk/game_clock.h"
#endif
typedef void (dMenu_Ring_c::*initFunc)();
static initFunc stick_init[] = {
/* STATUS_WAIT */ &dMenu_Ring_c::stick_wait_init,
@@ -183,6 +187,9 @@ dMenu_Ring_c::dMenu_Ring_c(JKRExpHeap* i_heap, STControl* i_stick, CSTControl* i
}
for (int i = 0; i < 4; i++) {
field_0x674[i] = 0;
#if TARGET_PC
mSelectItemSlideElapsed[i] = 0.0f;
#endif
field_0x518[i] = 0.0f;
field_0x528[i] = 0.0f;
field_0x538[i] = 0.0f;
@@ -1022,6 +1029,9 @@ void dMenu_Ring_c::setJumpItem(bool i_useVibrationM) {
field_0x6b8[0] != dComIfGs_getMixItemIndex(0))
{
field_0x674[0] = 1;
#if TARGET_PC
mSelectItemSlideElapsed[0] = 0.0f;
#endif
}
} else if (field_0x6b3 == 1) {
field_0x538[0] = g_ringHIO.mUnselectItemScale;
@@ -1030,6 +1040,9 @@ void dMenu_Ring_c::setJumpItem(bool i_useVibrationM) {
field_0x6b8[1] != dComIfGs_getMixItemIndex(1))
{
field_0x674[1] = 1;
#if TARGET_PC
mSelectItemSlideElapsed[1] = 0.0f;
#endif
}
}
if (field_0x674[0] == 1) {
@@ -1520,7 +1533,15 @@ void dMenu_Ring_c::setSelectItem(int i_idx, u8 i_itemNo) {
void dMenu_Ring_c::drawSelectItem() {
for (int i = 0; i < 4; i++) {
if (field_0x674[i] != 0) {
#if TARGET_PC
mSelectItemSlideElapsed[i] += dusk::game_clock::consume_interval(this);
const f32 u = std::min(mSelectItemSlideElapsed[i] / dusk::game_clock::period_for_original_frames(10.0f), 1.0f);
if (u >= 1.0f) {
setSelectItemForce(i);
} else {
#else
if (field_0x674[i] < 10) {
#endif
f32 initSizeX = dMeter2Info_getMeterItemPanePtr(i)->getInitSizeX() * 1.7f;
f32 initSizeY = dMeter2Info_getMeterItemPanePtr(i)->getInitSizeY() * 1.7f;
f32 initScaleX = dMeter2Info_getMeterItemPanePtr(i)->getInitScaleX();
@@ -1528,7 +1549,11 @@ void dMenu_Ring_c::drawSelectItem() {
Vec pos = dMeter2Info_getMeterItemPanePtr(i)->getGlobalVtxCenter(
dMeter2Info_getMeterItemPanePtr(i)->mPane, true, 0);
#if TARGET_PC
f32 fVar14 = 0.1f + 0.8f * u;
#else
f32 fVar14 = field_0x674[i] / 10.0f;
#endif
if (field_0x6cd != 0xff) {
fVar14 = 1.0f - fVar14;
}
@@ -1549,9 +1574,11 @@ void dMenu_Ring_c::drawSelectItem() {
0);
}
}
#if !TARGET_PC
field_0x674[i]++;
} else {
setSelectItemForce(i);
#endif
}
}
}
@@ -1562,6 +1589,9 @@ void dMenu_Ring_c::setSelectItemForce(int i_idx) {
if (field_0x674[i_idx] != 0) {
dComIfGs_setSelectItemIndex(i_idx, field_0x6b4[i_idx]);
field_0x674[i_idx] = 0;
#if TARGET_PC
mSelectItemSlideElapsed[i_idx] = 0.0f;
#endif
}
} else if (field_0x674[i_idx] != 0) {
for (int i = 0; i < 2; i++) {
@@ -1569,6 +1599,9 @@ void dMenu_Ring_c::setSelectItemForce(int i_idx) {
dComIfGs_setSelectItemIndex(i, field_0x6b4[i]);
}
field_0x674[i_idx] = 0;
#if TARGET_PC
mSelectItemSlideElapsed[i_idx] = 0.0f;
#endif
}
}
+44 -34
View File
@@ -18,6 +18,7 @@
#include "m_Do/m_Do_controller_pad.h"
#include "m_Do/m_Do_graphic.h"
#include "d/d_msg_scrn_explain.h"
#include "dusk/frame_interpolation.h"
#include "dusk/settings.h"
#include "JSystem/J2DGraph/J2DAnmLoader.h"
#include "f_op/f_op_msg_mng.h"
@@ -386,11 +387,7 @@ void dMenu_save_c::screenSet() {
mSelectedFile = dComIfGs_getDataNum();
mSelIcon = JKR_NEW dSelect_cursor_c(0, 1.0f, NULL);
#if TARGET_PC
mSelIcon->setParam(0.96f * mDoGph_gInf_c::hudAspectScaleUp, 0.94f, 0.03f, 0.7f, 0.7f);
#else
mSelIcon->setParam(0.96f, 0.94f, 0.03f, 0.7f, 0.7f);
#endif
Vec pos;
pos = mpSelData[mSelectedFile]->getGlobalVtxCenter(false, 0);
@@ -719,7 +716,9 @@ void dMenu_save_c::_move() {
}
(this->*MenuSaveProc[mMenuProc])();
#if !TARGET_PC
saveSelAnm();
#endif
if (mWarning != NULL) {
mWarning->_move();
@@ -736,36 +735,46 @@ void dMenu_save_c::saveSelAnm() {
}
void dMenu_save_c::selFileWakuAnm() {
mFileWakuAnmFrame += 2;
if (mFileWakuAnmFrame >= mpFileWakuAnm->getFrameMax()) {
mFileWakuAnmFrame -= mpFileWakuAnm->getFrameMax();
#if TARGET_PC
if (dusk::frame_interp::get_ui_tick_pending())
#endif
{
mFileWakuAnmFrame += 2;
if (mFileWakuAnmFrame >= mpFileWakuAnm->getFrameMax()) {
mFileWakuAnmFrame -= mpFileWakuAnm->getFrameMax();
}
mFileWakuRotAnmFrame += 2;
if (mFileWakuRotAnmFrame >= mpFileWakuRotAnm->getFrameMax()) {
mFileWakuRotAnmFrame -= mpFileWakuRotAnm->getFrameMax();
}
}
mpFileWakuAnm->setFrame(mFileWakuAnmFrame);
mFileWakuRotAnmFrame += 2;
if (mFileWakuRotAnmFrame >= mpFileWakuRotAnm->getFrameMax()) {
mFileWakuRotAnmFrame -= mpFileWakuRotAnm->getFrameMax();
}
mpFileWakuRotAnm->setFrame(mFileWakuRotAnmFrame);
}
void dMenu_save_c::bookIconAnm() {
field_0x154 += 2;
if (field_0x154 >= field_0x150->getFrameMax()) {
field_0x154 -= field_0x150->getFrameMax();
#if TARGET_PC
if (dusk::frame_interp::get_ui_tick_pending())
#endif
{
field_0x154 += 2;
if (field_0x154 >= field_0x150->getFrameMax()) {
field_0x154 -= field_0x150->getFrameMax();
}
field_0x15c += 2;
if (field_0x15c >= field_0x158->getFrameMax()) {
field_0x15c -= field_0x158->getFrameMax();
}
field_0x164 += 2;
if (field_0x164 >= field_0x160->getFrameMax()) {
field_0x164 -= field_0x160->getFrameMax();
}
}
field_0x150->setFrame(field_0x154);
field_0x15c += 2;
if (field_0x15c >= field_0x158->getFrameMax()) {
field_0x15c -= field_0x158->getFrameMax();
}
field_0x158->setFrame(field_0x15c);
field_0x164 += 2;
if (field_0x164 >= field_0x160->getFrameMax()) {
field_0x164 -= field_0x160->getFrameMax();
}
field_0x160->setFrame(field_0x164);
}
@@ -2523,11 +2532,7 @@ void dMenu_save_c::yesnoCursorShow() {
mSelIcon->setPos(pos.x, pos.y, mpNoYes[mYesNoCursor]->getPanePtr(), true);
mSelIcon->setAlphaRate(1.0f);
#if TARGET_PC
mSelIcon->setParam(0.96f * mDoGph_gInf_c::hudAspectScaleUp, 0.84f, 0.06f, 0.5f, 0.5f);
#else
mSelIcon->setParam(0.96f, 0.84f, 0.06f, 0.5f, 0.5f);
#endif
}
}
@@ -2676,11 +2681,7 @@ void dMenu_save_c::selFileCursorShow() {
mSelIcon->setPos(pos.x, pos.y, mpSelData[mSelectedFile]->getPanePtr(), true);
mSelIcon->setAlphaRate(1.0f);
#if TARGET_PC
mSelIcon->setParam(0.96f * mDoGph_gInf_c::hudAspectScaleUp, 0.94f, 0.03f, 0.7f, 0.7f);
#else
mSelIcon->setParam(0.96f, 0.94f, 0.03f, 0.7f, 0.7f);
#endif
}
void dMenu_save_c::yesnoWakuAlpahAnmInit(u8 yesnoIdx, u8 startAlpha, u8 endAlpha, u8 anmTimer) {
@@ -2782,7 +2783,7 @@ void dMenu_save_c::_draw() {
#if TARGET_PC
void dMenu_save_c::menuSaveWide() {
mSaveSel.Scr->scale(mDoGph_gInf_c::hudAspectScaleUp, 1.0f);
mSaveSel.Scr->translate(mDoGph_gInf_c::getMinXF(), 0.0f);
mSaveSel.Scr->translate(mDoGph_gInf_c::getSafeMinXF(), 0.0f);
mSaveSel.Scr->search(MULTI_CHAR('t_for'))->scale(mDoGph_gInf_c::hudAspectScaleDown, 1.0f);
mSaveSel.Scr->search(MULTI_CHAR('t_for1'))->scale(mDoGph_gInf_c::hudAspectScaleDown, 1.0f);
@@ -2813,11 +2814,20 @@ void dMenu_save_c::menuSaveWide() {
mSaveSel.Scr->search(MULTI_CHAR('w_uzu07'))->scale(mDoGph_gInf_c::hudAspectScaleDown, 1.0f);
mSaveSel.Scr->search(MULTI_CHAR('w_uzu08'))->scale(mDoGph_gInf_c::hudAspectScaleDown, 1.0f);
mSaveSel.Scr->search(MULTI_CHAR('w_uzu09'))->scale(mDoGph_gInf_c::hudAspectScaleDown, 1.0f);
#if TARGET_PC
if (mSelIcon) {
mSelIcon->refreshAspectScale();
}
#endif
}
#endif
void dMenu_save_c::_draw2() {
if (field_0x21a1 == 0) {
#if TARGET_PC
saveSelAnm();
#endif
if (mpScrnExplain != NULL) {
dComIfGd_set2DOpa(&mMenuSaveExplain);
}
+15 -21
View File
@@ -32,15 +32,9 @@ public:
if (getDrawFlag() == 1) {
setDrawFlag();
dComIfGp_onPauseFlag();
#if TARGET_PC
GXSetTexCopySrc(0, 0, mDoGph_gInf_c::getWidth(), mDoGph_gInf_c::getHeight());
#else
GXSetTexCopySrc(0, 0, FB_WIDTH, FB_HEIGHT);
#endif
#if TARGET_PC
GXSetTexCopyDst(mDoGph_gInf_c::getWidth(), mDoGph_gInf_c::getHeight(), (GXTexFmt)mDoGph_gInf_c::getFrameBufferTimg()->format, GX_ENABLE);
GXSetTexCopyDst(FB_WIDTH, FB_HEIGHT, (GXTexFmt)mDoGph_gInf_c::getFrameBufferTimg()->format, GX_DISABLE);
#else
GXSetTexCopyDst(FB_WIDTH / 2, FB_HEIGHT / 2, (GXTexFmt)mDoGph_gInf_c::getFrameBufferTimg()->format, GX_ENABLE);
#endif
@@ -48,17 +42,17 @@ public:
GXPixModeSync();
#if TARGET_PC
// init mTexObj at capture time so the gpu ref survives window resizes
mCaptureWidth = mDoGph_gInf_c::getWidth();
mCaptureHeight = mDoGph_gInf_c::getHeight();
GXInitTexObj(&mTexObj, mDoGph_gInf_c::getFrameBufferTex(), mCaptureWidth, mCaptureHeight,
mCaptureWidth = JUTVideo::getManager()->getRenderWidth();
mCaptureHeight = JUTVideo::getManager()->getRenderHeight();
GXInitTexObj(&mTexObj, mDoGph_gInf_c::getFrameBufferTex(), FB_WIDTH / 2, FB_HEIGHT / 2,
(GXTexFmt)mDoGph_gInf_c::getFrameBufferTimg()->format, GX_CLAMP, GX_CLAMP, GX_FALSE);
GXInitTexObjLOD(&mTexObj, GX_LINEAR, GX_LINEAR, 0.0f, 0.0f, 0.0f, GX_FALSE, GX_FALSE, GX_ANISO_1);
#endif
} else {
#if TARGET_PC
// If the window was resized since capture, force a re-capture at the new size
if (mCaptureWidth != (u16)mDoGph_gInf_c::getWidth() ||
mCaptureHeight != (u16)mDoGph_gInf_c::getHeight()) {
if (mCaptureWidth != JUTVideo::getManager()->getRenderWidth() ||
mCaptureHeight != JUTVideo::getManager()->getRenderHeight()) {
mFlag = 1;
return;
}
@@ -137,8 +131,8 @@ private:
/* 0x5 */ u8 mAlpha;
/* 0x6 */ u8 mTopFlag;
#if TARGET_PC
u16 mCaptureWidth;
u16 mCaptureHeight;
u32 mCaptureWidth;
u32 mCaptureHeight;
TGXTexObj mTexObj;
#endif
};
@@ -705,7 +699,7 @@ void dMw_c::collect_open_proc() {
dMeter2Info_set2DVibrationM();
}
if (mDoGph_gInf_c::getFader()->getStatus() == JUTFader::UNKSTATUS_0) {
if (mDoGph_gInf_c::getFader()->getStatus() == JUTFader::None) {
mMenuProc = COLLECT_MOVE;
}
}
@@ -920,7 +914,7 @@ void dMw_c::collect_letter_move_proc() {
}
void dMw_c::collect_letter_close_proc() {
if (mDoGph_gInf_c::getFader()->getStatus() == JUTFader::UNKSTATUS_0) {
if (mDoGph_gInf_c::getFader()->getStatus() == JUTFader::None) {
mMenuProc = COLLECT_MOVE;
}
}
@@ -952,7 +946,7 @@ void dMw_c::collect_fishing_move_proc() {
}
void dMw_c::collect_fishing_close_proc() {
if (mDoGph_gInf_c::getFader()->getStatus() == JUTFader::UNKSTATUS_0) {
if (mDoGph_gInf_c::getFader()->getStatus() == JUTFader::None) {
mMenuProc = COLLECT_MOVE;
}
}
@@ -983,7 +977,7 @@ void dMw_c::collect_skill_move_proc() {
}
void dMw_c::collect_skill_close_proc() {
if (mDoGph_gInf_c::getFader()->getStatus() == JUTFader::UNKSTATUS_0) {
if (mDoGph_gInf_c::getFader()->getStatus() == JUTFader::None) {
mMenuProc = COLLECT_MOVE;
}
}
@@ -1014,13 +1008,13 @@ void dMw_c::collect_insect_move_proc() {
}
void dMw_c::collect_insect_close_proc() {
if (mDoGph_gInf_c::getFader()->getStatus() == JUTFader::UNKSTATUS_0) {
if (mDoGph_gInf_c::getFader()->getStatus() == JUTFader::None) {
mMenuProc = COLLECT_MOVE;
}
}
void dMw_c::insect_open_proc() {
if (mDoGph_gInf_c::getFader()->getStatus() == JUTFader::UNKSTATUS_0) {
if (mDoGph_gInf_c::getFader()->getStatus() == JUTFader::None) {
field_0x152 = 0;
dComIfGp_setHeapLockFlag(1);
dMw_insect_create(1);
@@ -1056,7 +1050,7 @@ void dMw_c::insect_move_proc() {
}
void dMw_c::insect_close_proc() {
if (mDoGph_gInf_c::getFader()->getStatus() == JUTFader::UNKSTATUS_0) {
if (mDoGph_gInf_c::getFader()->getStatus() == JUTFader::None) {
mMenuProc = NO_MENU;
}
}
+5 -13
View File
@@ -638,12 +638,11 @@ void dMeter2Draw_c::draw() {
var_f29 = g_drawHIO.mLightDrop.mDropPikariAnimSpeed_Completed;
int temp_r5_2 = g_drawHIO.mLightDrop.mPikariInterval * 15;
#ifdef TARGET_PC
// Set even if not advancing
// FRAME INTERP NOTE: Set even if not advancing
var_f28 = g_drawHIO.mLightDrop.mPikariScaleComplete;
const u32 ui_advance_ticks = dusk::frame_interp::get_presentation_ui_advance_ticks();
for (u32 tick = 0; tick < ui_advance_ticks; ++tick) {
if (dusk::frame_interp::get_ui_tick_pending())
#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;
@@ -669,17 +668,12 @@ void dMeter2Draw_c::draw() {
}
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) {
@@ -1349,9 +1343,9 @@ void dMeter2Draw_c::drawPikari(f32 i_posX, f32 i_posY, f32* i_framep, f32 i_scal
*i_framep = 0.0f;
} else {
#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) {
if (dusk::frame_interp::get_ui_tick_pending())
#endif
{
*i_framep += param_8;
if (*i_framep > var_f31) {
if (param_9 == 1 || param_9 == 2 || param_9 == 3) {
@@ -1366,9 +1360,7 @@ void dMeter2Draw_c::drawPikari(f32 i_posX, f32 i_posY, f32* i_framep, f32 i_scal
} 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);
+13 -7
View File
@@ -16,6 +16,7 @@
#include "d/d_msg_out_font.h"
#include "d/d_msg_string.h"
#include "d/d_pane_class.h"
#include "dusk/frame_interpolation.h"
#include <cstring>
#if VERSION == VERSION_GCN_JPN
@@ -280,15 +281,20 @@ void dMeterButton_c::draw() {
s16 temp_r6 = g_drawHIO.mEmpButton.mRepeatHitFrameNum;
s16 temp_r6_2 = g_drawHIO.mEmpButton.mRepeatHitFrameNum / 2;
field_0x4b8[i]++;
#ifdef TARGET_PC
if (dusk::frame_interp::get_ui_tick_pending())
#endif
{
field_0x4b8[i]++;
if (field_0x4b8[i] >= temp_r6) {
field_0x4b8[i] = 0;
if (field_0x4b8[i] >= temp_r6) {
field_0x4b8[i] = 0;
if (field_0x4bc[i] == 0) {
field_0x4bc[i] = 1;
} else {
field_0x4bc[i] = 0;
if (field_0x4bc[i] == 0) {
field_0x4bc[i] = 1;
} else {
field_0x4bc[i] = 0;
}
}
}
+37 -21
View File
@@ -11,6 +11,7 @@
#include "d/d_com_inf_game.h"
#include "d/d_meter_HIO.h"
#include "d/d_pane_class.h"
#include "dusk/frame_interpolation.h"
dMeterHaihai_c::dMeterHaihai_c(u8 i_type) {
mType = i_type;
@@ -286,14 +287,19 @@ void dMeterHaihai_c::updateHaihai() {
void dMeterHaihai_c::playBckAnime(J2DAnmTransformKey* i_bck) {
if (checkPlayAnime(1)) {
if (i_bck != NULL) {
if (mType == 4) {
mBckFrame += g_drawHIO.mWiiLockArrowBCKAnimSpeed;
} else {
mBckFrame += g_drawHIO.mScrollArrowBCKAnimSpeed;
}
#ifdef TARGET_PC
if (dusk::frame_interp::get_ui_tick_pending())
#endif
{
if (mType == 4) {
mBckFrame += g_drawHIO.mWiiLockArrowBCKAnimSpeed;
} else {
mBckFrame += g_drawHIO.mScrollArrowBCKAnimSpeed;
}
if (mBckFrame >= i_bck->getFrameMax()) {
mBckFrame -= i_bck->getFrameMax();
if (mBckFrame >= i_bck->getFrameMax()) {
mBckFrame -= i_bck->getFrameMax();
}
}
} else {
mBtkFrame = 1.0f;
@@ -309,14 +315,19 @@ void dMeterHaihai_c::playBckAnime(J2DAnmTransformKey* i_bck) {
void dMeterHaihai_c::playBtkAnime(J2DAnmTextureSRTKey* i_btk) {
if (checkPlayAnime(2)) {
if (i_btk != NULL) {
if (mType == 4) {
mBtkFrame += g_drawHIO.mWiiLockArrowBTKAnimSpeed;
} else {
mBtkFrame += g_drawHIO.mScrollArrowBTKAnimSpeed;
}
#ifdef TARGET_PC
if (dusk::frame_interp::get_ui_tick_pending())
#endif
{
if (mType == 4) {
mBtkFrame += g_drawHIO.mWiiLockArrowBTKAnimSpeed;
} else {
mBtkFrame += g_drawHIO.mScrollArrowBTKAnimSpeed;
}
if (mBtkFrame >= i_btk->getFrameMax()) {
mBtkFrame -= i_btk->getFrameMax();
if (mBtkFrame >= i_btk->getFrameMax()) {
mBtkFrame -= i_btk->getFrameMax();
}
}
} else {
mBtkFrame = 1.0f;
@@ -331,14 +342,19 @@ void dMeterHaihai_c::playBtkAnime(J2DAnmTextureSRTKey* i_btk) {
void dMeterHaihai_c::playBpkAnime(J2DAnmColor* i_bpk) {
if (checkPlayAnime(0)) {
if (i_bpk != NULL) {
if (mType == 4) {
mBpkFrame += g_drawHIO.mWiiLockArrowBPKAnimSpeed;
} else {
mBpkFrame += g_drawHIO.mScrollArrowBPKAnimSpeed;
}
#ifdef TARGET_PC
if (dusk::frame_interp::get_ui_tick_pending())
#endif
{
if (mType == 4) {
mBpkFrame += g_drawHIO.mWiiLockArrowBPKAnimSpeed;
} else {
mBpkFrame += g_drawHIO.mScrollArrowBPKAnimSpeed;
}
if (mBpkFrame >= i_bpk->getFrameMax()) {
mBpkFrame -= i_bpk->getFrameMax();
if (mBpkFrame >= i_bpk->getFrameMax()) {
mBpkFrame -= i_bpk->getFrameMax();
}
}
} else {
mBpkFrame = 1.0f;
+27 -7
View File
@@ -16,6 +16,7 @@
#include "d/d_meter2_info.h"
#include "d/d_meter_HIO.h"
#include "d/d_pane_class.h"
#include "dusk/frame_interpolation.h"
#include <cstring>
dMeterString_c::dMeterString_c(int i_stringID) {
@@ -105,16 +106,27 @@ void dMeterString_c::draw() {
f32 var_f30 = 1.0f;
if (mAnimFrame < 60.0f) {
mAnimFrame += g_drawHIO.mMiniGame.mReadyFightTextAnimSpeed;
if (mAnimFrame > 60.0f) {
mAnimFrame = 60.0f;
#if TARGET_PC
if (dusk::frame_interp::get_ui_tick_pending())
#endif
{
mAnimFrame += g_drawHIO.mMiniGame.mReadyFightTextAnimSpeed;
if (mAnimFrame > 60.0f) {
mAnimFrame = 60.0f;
}
}
playBckAnimation(mAnimFrame);
} else if (mAnimFrame < (f32)g_drawHIO.mMiniGame.mReadyFightTextWaitFrames + 60.0f) {
mAnimFrame += var_f30;
#if TARGET_PC
if (dusk::frame_interp::get_ui_tick_pending())
#endif
mAnimFrame += var_f30;
} else if (mAnimFrame < var_f31) {
mAnimFrame += var_f30;
#if TARGET_PC
if (dusk::frame_interp::get_ui_tick_pending())
#endif
mAnimFrame += var_f30;
var_f30 = acc(g_drawHIO.mMiniGame.field_0x172, var_f31 - mAnimFrame, 0);
}
@@ -128,13 +140,21 @@ void dMeterString_c::draw() {
if (mPikariAnimFrame > 0.0f) {
drawPikari();
} else if (mPikariAnimFrame == -1.0f &&
#if TARGET_PC
dusk::frame_interp::get_ui_tick_pending() &&
#endif
mAnimFrame > g_drawHIO.mMiniGame.mReadyFightPikariAppearFrames)
{
mPikariAnimFrame = 18.0f - g_drawHIO.mMiniGame.mReadyFightPikariAnimSpeed;
}
if (mAnimFrame >= var_f31) {
dMeter2Info_resetMeterString();
#if TARGET_PC
if (dusk::frame_interp::get_ui_tick_pending())
#endif
{
if (mAnimFrame >= var_f31) {
dMeter2Info_resetMeterString();
}
}
}
}
+21
View File
@@ -12,6 +12,10 @@
#include "d/d_lib.h"
#include "JSystem/JUtility/JUTFont.h"
#if TARGET_PC
#include "dusk/scope_guard.hpp"
#endif
#if REGION_JPN
#define CHAR_CODE_MALE_ICON 0x8189
#define CHAR_CODE_FEMALE_ICON 0x818A
@@ -1918,6 +1922,11 @@ void jmessage_tSequenceProcessor::do_begin(void const* pEntry, char const* pszTe
pReference->resetReference();
field_0xb5 = 0;
#if TARGET_PC
if (dusk::getSettings().game.instantText && mDoCPd_c::getHoldB(0)) {
field_0xb2 = 1;
}
#endif
}
void jmessage_tSequenceProcessor::do_end() {
@@ -2154,6 +2163,18 @@ void jmessage_tSequenceProcessor::do_character(int iCharacter) {
bool jmessage_tSequenceProcessor::do_tag(u32 i_tag, void const* i_data, u32 i_size) {
jmessage_tReference* pReference = (jmessage_tReference*)getReference();
#if TARGET_PC
// This class runs the lambda function when it goes out of scope. We want to run
// this code after the switch statement and this saves us from having to litter
// the switch statement with IF_DUSK before every return.
auto instantTextRun = SimpleScopeGuard([&]() {
if (dusk::getSettings().game.instantText && mDoCPd_c::getHoldB(0)) {
field_0xb2 = 1;
pReference->setSendTimer(0);
}
});
#endif
switch (i_tag & 0xFF0000) {
case MSGTAG_GROUP(1): {
cXyz pos = pReference->getActorPos();
+10 -15
View File
@@ -28,6 +28,10 @@
#include "m_Do/m_Do_lib.h"
#include "JSystem/JKernel/JKRExpHeap.h"
#if TARGET_PC
#include "dusk/settings.h"
#endif
static void dMsgObject_addFundRaising(s16 param_0);
static void dMsgObject_addTotalPayment(s16 param_0);
@@ -1464,24 +1468,12 @@ void dMsgObject_c::fukiPosCalc(bool param_1) {
fopAc_ac_c* player = dComIfGp_getPlayer(0);
cXyz local_3c;
cXyz cStack_48;
#if TARGET_PC
mDoLib_project(&player->eyePos, &cStack_48, {0, 0, FB_WIDTH, FB_HEIGHT});
#else
mDoLib_project(&player->eyePos, &cStack_48);
#endif
f32 temp;
if ((field_0x100->pos == cXyz(0.0f, 0.0f, 0.0f))) {
temp = cStack_48.y;
} else {
#if TARGET_PC
mDoLib_project(&field_0x100->pos, &local_3c, {0, 0, FB_WIDTH, FB_HEIGHT});
#else
mDoLib_project(&field_0x100->pos, &local_3c);
#endif
if (local_3c.x >= 0.0f && local_3c.x <= FB_WIDTH && local_3c.y >= 0.0f &&
local_3c.y <= FB_HEIGHT)
{
@@ -1566,7 +1558,8 @@ u8 dMsgObject_c::isSend() {
if (pRef->getSendFlag() == 5) {
if (getStatusLocal() == 21) {
setButtonStatusLocal();
if (mDoCPd_c::getTrigA(0) != 0 || mDoCPd_c::getTrigB(0) != 0) {
if (IF_DUSK((dusk::getSettings().game.instantText && mDoCPd_c::getHoldB(0)) ||)
mDoCPd_c::getTrigA(0) != 0 || mDoCPd_c::getTrigB(0) != 0) {
return 2;
}
return 0;
@@ -1585,7 +1578,8 @@ u8 dMsgObject_c::isSend() {
}
if (pRef->getSendFlag() == 2) {
setButtonStatusLocal();
if (mDoCPd_c::getTrigA(0) != 0 || mDoCPd_c::getTrigB(0) != 0) {
if (IF_DUSK((dusk::getSettings().game.instantText && mDoCPd_c::getHoldB(0)) ||)
mDoCPd_c::getTrigA(0) != 0 || mDoCPd_c::getTrigB(0) != 0) {
return 2;
}
}
@@ -1598,7 +1592,8 @@ u8 dMsgObject_c::isSend() {
return 2;
}
} else {
if (mDoCPd_c::getTrigA(0) != 0 || mDoCPd_c::getTrigB(0) != 0) {
if (IF_DUSK((dusk::getSettings().game.instantText && mDoCPd_c::getHoldB(0)) ||)
mDoCPd_c::getTrigA(0) != 0 || mDoCPd_c::getTrigB(0) != 0) {
return 2;
}
if (mesgCancelButton) {
+18 -3
View File
@@ -5,6 +5,7 @@
#include "JSystem/JUtility/JUTTexture.h"
#include "d/d_meter2_info.h"
#include "d/d_msg_object.h"
#include "dusk/frame_interpolation.h"
#include "f_op/f_op_msg_mng.h"
COutFontSet_c::COutFontSet_c() {
@@ -311,6 +312,15 @@ void COutFont_c::draw(J2DTextBox* i_textbox, f32 param_1, f32 param_2, f32 param
sp256[i] = field_0x1b4[i];
}
#ifdef TARGET_PC
bool uiTickPending = dusk::frame_interp::get_ui_tick_pending();
if (!uiTickPending) {
for (int i = 0; i < 70; i++) {
sp256[i] = -1;
}
}
#endif
for (int i = 0; i < 35; i++) {
u8 type = mpOfs[i]->getType();
J2DTextBox* tbox = mpOfs[i]->getTextBoxPtr();
@@ -505,9 +515,14 @@ void COutFont_c::draw(J2DTextBox* i_textbox, f32 param_1, f32 param_2, f32 param
case 20:
case 21:
case 22:
field_0x1b4[type]++;
if (field_0x1b4[type] >= 28) {
field_0x1b4[type] = 0;
#ifdef TARGET_PC
if (uiTickPending)
#endif
{
field_0x1b4[type]++;
if (field_0x1b4[type] >= 28) {
field_0x1b4[type] = 0;
}
}
mpPane[type]->rotate(0.5f * sizeX, 0.5f * sizeY, ROTATE_Z,
-21
View File
@@ -607,17 +607,10 @@ void dMsgScrnHowl_c::drawGuide() {
J2DGrafContext* grafContext = dComIfGp_getCurrentGrafPort();
Vec local_b0 = field_0x128;
Vec local_bc = field_0x140;
#if TARGET_PC
grafContext->scissor(
(local_b0.x - mDoGph_gInf_c::getMinXF()) / (mDoGph_gInf_c::getWidthF() / mDoGph_gInf_c::getWidth()),
field_0x2118, (local_bc.x - local_b0.x) / (mDoGph_gInf_c::getWidthF() / mDoGph_gInf_c::getWidth()),
field_0x2120);
#else
grafContext->scissor(
(local_b0.x - mDoGph_gInf_c::getMinXF()) / (mDoGph_gInf_c::getWidthF() / FB_WIDTH),
field_0x2118, (local_bc.x - local_b0.x) / (mDoGph_gInf_c::getWidthF() / FB_WIDTH),
field_0x2120);
#endif
grafContext->setScissor();
f32 local_cc = mpLineH[0]->getGlobalPosX();
s16 sVar12 = 0;
@@ -745,19 +738,11 @@ void dMsgScrnHowl_c::drawGuide2() {
}
Vec local_58 = field_0x128;
Vec local_64 = field_0x140;
#if TARGET_PC
f32 local_70 = mDoGph_gInf_c::getHeightF() / mDoGph_gInf_c::getHeight();
grafContext->scissor(
(local_58.x - mDoGph_gInf_c::getMinXF()) / (mDoGph_gInf_c::getWidthF() / mDoGph_gInf_c::getWidth()),
field_0x2118, (local_64.x - local_58.x) / (mDoGph_gInf_c::getWidthF() / mDoGph_gInf_c::getWidth()),
field_0x2120);
#else
f32 local_70 = mDoGph_gInf_c::getHeightF() / mDoGph_gInf_c::getHeight();
grafContext->scissor(
(local_58.x - mDoGph_gInf_c::getMinXF()) / (mDoGph_gInf_c::getWidthF() / FB_WIDTH),
field_0x2118, (local_64.x - local_58.x) / (mDoGph_gInf_c::getWidthF() / FB_WIDTH),
field_0x2120);
#endif
grafContext->setScissor();
f32 local_74 = mpLineH[0]->getGlobalPosX();
s16 local_134 = 0;
@@ -859,15 +844,9 @@ void dMsgScrnHowl_c::drawEffect() {
Vec vec1 = field_0x128;
Vec vec2 = field_0x140;
mDoGph_gInf_c::getHeightF();
#if TARGET_PC
grafContext->scissor(
(vec1.x - mDoGph_gInf_c::getMinXF()) / (mDoGph_gInf_c::getWidthF() / mDoGph_gInf_c::getWidth()), field_0x2118,
12.0f + ((vec2.x - vec1.x) / (mDoGph_gInf_c::getWidthF() / mDoGph_gInf_c::getWidth())), field_0x2120);
#else
grafContext->scissor(
(vec1.x - mDoGph_gInf_c::getMinXF()) / (mDoGph_gInf_c::getWidthF() / FB_WIDTH), field_0x2118,
12.0f + ((vec2.x - vec1.x) / (mDoGph_gInf_c::getWidthF() / FB_WIDTH)), field_0x2120);
#endif
grafContext->setScissor();
u8 timer = daAlink_getAlinkActorClass()->getWolfHowlMgrP()->getReleaseTimer();
u8 screenAlpha = mpScreen->search(MULTI_CHAR('line00'))->getAlpha();
-11
View File
@@ -557,22 +557,11 @@ void dMsgScrnItem_c::fukiPosCalc(u8 param_1) {
cXyz local_70;
cXyz cStack_7c;
f32 f3;
#if TARGET_PC
mDoLib_project(&player->eyePos, &cStack_7c, {0, 0, FB_WIDTH, FB_HEIGHT});
#else
mDoLib_project(&player->eyePos, &cStack_7c);
#endif
if (iVar6->pos == cXyz(0.0f, 0.0f, 0.0f)) {
f3 = cStack_7c.y;
} else {
#if TARGET_PC
mDoLib_project(&iVar6->pos, &local_70, {0, 0, FB_WIDTH, FB_HEIGHT});
#else
mDoLib_project(&iVar6->pos, &local_70);
#endif
if (local_70.x >= 0.0f && local_70.x <= FB_WIDTH && local_70.y >= 0.0f &&
local_70.y <= FB_HEIGHT)
{
+4 -8
View File
@@ -204,16 +204,14 @@ void dMsgScrnLight_c::draw(f32* i_anmFrame, f32 i_posX, f32 i_posY, f32 i_scaleX
if (mPlayAnim) {
#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) {
if (dusk::frame_interp::get_ui_tick_pending())
#endif
{
*i_anmFrame += 1.0f;
if (*i_anmFrame >= mpBck->getFrameMax()) {
*i_anmFrame = 0.0f;
}
#ifdef TARGET_PC
}
#endif
mBckFrame = *i_anmFrame;
mBpkFrame = *i_anmFrame;
@@ -229,17 +227,15 @@ void dMsgScrnLight_c::draw(f32* i_anmFrame, f32 i_posX, f32 i_posY, f32 i_scaleX
if (mPlayAnim) {
#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) {
if (dusk::frame_interp::get_ui_tick_pending())
#endif
{
*i_anmFrame += i_anmRate;
if (*i_anmFrame >= mpBck->getFrameMax()) {
*i_anmFrame = 0.0f;
}
#ifdef TARGET_PC
}
#endif
mBckFrame = *i_anmFrame;
mBpkFrame = *i_anmFrame;
-11
View File
@@ -441,22 +441,11 @@ void dMsgScrnTalk_c::fukiPosCalc(u8 param_1) {
cXyz local_70;
cXyz cStack_7c;
f32 f3y;
#if TARGET_PC
mDoLib_project(&player->eyePos, &cStack_7c, {0, 0, FB_WIDTH, FB_HEIGHT});
#else
mDoLib_project(&player->eyePos, &cStack_7c);
#endif
if (msgActor->pos == cXyz(0.0f, 0.0f, 0.0f)) {
f3y = cStack_7c.y;
} else {
#if TARGET_PC
mDoLib_project(&msgActor->pos, &local_70, {0, 0, FB_WIDTH, FB_HEIGHT});
#else
mDoLib_project(&msgActor->pos, &local_70);
#endif
if (local_70.x >= 0.0f && local_70.x <= FB_WIDTH_BASE && local_70.y >= 0.0f &&
local_70.y <= FB_HEIGHT_BASE)
{
+25
View File
@@ -271,6 +271,30 @@ void dMsgUnit_c::setTag(int i_type, int i_value, char* o_buffer, bool param_4) {
u32 filesize = pHeader->size;
u8* pSection = ((u8*)pHeader) + filepos;
#if TARGET_PC
// patch bug in the original game where filepos would be incremented by the next section's size rather than the current section size.
// in certain scenarios this would read past the end of the file, incrementing filepos by 0 in an infinite loop
while (filepos < filesize) {
switch (((bmg_section_t*)pSection)->magic) {
case 'FLW1':
break;
case 'FLI1':
break;
case 'INF1':
pInfoBlock = (bmg_section_t*)pSection;
break;
case 'DAT1':
pMsgDataBlock = pSection;
break;
case 'STR1':
pStrAttributeBlock = (str1_section_t*)pSection;
break;
}
filepos += ((bmg_section_t*)pSection)->size;
pSection += ((bmg_section_t*)pSection)->size;
}
#else
for (; filepos < filesize; filepos += ((bmg_section_t*)pSection)->size) {
switch (((bmg_section_t*)pSection)->magic) {
case 'FLW1':
@@ -289,6 +313,7 @@ void dMsgUnit_c::setTag(int i_type, int i_value, char* o_buffer, bool param_4) {
}
pSection += ((bmg_section_t*)pSection)->size;
}
#endif
// This section is weird. The debug seems like entriesStr is outside the condition
// but the normal build doesn't really work with that. Same for pInfoBlock->entries.
+5 -5
View File
@@ -1288,7 +1288,11 @@ void dName_c::selectCursorPosSet(int row) {
#if TARGET_PC
void dName_c::nameWide() {
//Resize Select Icon
mSelIcon->setParam(0.82f * mDoGph_gInf_c::hudAspectScaleUp, 0.77f, 0.05f, 0.4f, 0.4f);
#if TARGET_PC
if (mSelIcon) {
mSelIcon->refreshAspectScale();
}
#endif
// List of Characters Box
static u64 l_tagName[65] = {
@@ -1540,11 +1544,7 @@ void dName_c::screenSet() {
mSelIcon = JKR_NEW dSelect_cursor_c(0, 1.0f, NULL);
JUT_ASSERT(0, mSelIcon != NULL);
#if TARGET_PC
mSelIcon->setParam(0.82f * mDoGph_gInf_c::hudAspectScaleUp, 0.77f, 0.05f, 0.4f, 0.4f);
#else
mSelIcon->setParam(0.82f, 0.77f, 0.05f, 0.4f, 0.4f);
#endif
Vec pos = mMojiIcon[mCharRow + mCharColumn * 5]->getGlobalVtxCenter(false, 0);
mSelIcon->setPos(pos.x, pos.y, mMojiIcon[mCharRow + mCharColumn * 5]->getPanePtr(), true);
+2 -2
View File
@@ -26,8 +26,8 @@ static void dOvlpFd_startFadeIn(int param_0) {
JUTFader* fader = JFWDisplay::getManager()->getFader();
JUT_ASSERT(0, fader != NULL);
fader->setStatus(JUTFader::UNKSTATUS_0, 0);
fader->setStatus(JUTFader::UNKSTATUS_0, -1);
fader->setStatus(JUTFader::None, 0);
fader->setStatus(JUTFader::None, -1);
fader->startFadeIn(param_0);
}
-5
View File
@@ -12,13 +12,8 @@
#include "m_Do/m_Do_graphic.h"
void dOvlpFd2_dlst_c::draw() {
#if TARGET_PC
GXSetViewport(0.0f, 0.0f, mDoGph_gInf_c::getWidth(), mDoGph_gInf_c::getHeight(), 0.0f, 1.0f);
GXSetScissor(0, 0, mDoGph_gInf_c::getWidth(), mDoGph_gInf_c::getHeight());
#else
GXSetViewport(0.0f, 0.0f, FB_WIDTH, FB_HEIGHT, 0.0f, 1.0f);
GXSetScissor(0, 0, FB_WIDTH, FB_HEIGHT);
#endif
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_CLR_RGB, GX_RGBA4, 0);
GXClearVtxDesc();
GXSetVtxDesc(GX_VA_POS, GX_DIRECT);
+3 -23
View File
@@ -13,11 +13,10 @@
#include "m_Do/m_Do_graphic.h"
void dDlst_snapShot_c::draw() {
#if TARGET_PC
GXSetTexCopySrc(0, 0, mDoGph_gInf_c::getWidth(), mDoGph_gInf_c::getHeight());
GXSetTexCopyDst(mDoGph_gInf_c::getWidth(), mDoGph_gInf_c::getHeight(), GX_TF_RGBA8, GX_TRUE);
#else
GXSetTexCopySrc(0, 0, FB_WIDTH, FB_HEIGHT);
#if TARGET_PC
GXSetTexCopyDst(FB_WIDTH, FB_HEIGHT, GX_TF_RGBA8, GX_FALSE);
#else
GXSetTexCopyDst(FB_WIDTH / 2, FB_HEIGHT / 2, GX_TF_RGBA8, GX_TRUE);
#endif
GXCopyTex(mDoGph_gInf_c::getFrameBufferTex(), GX_FALSE);
@@ -25,13 +24,8 @@ void dDlst_snapShot_c::draw() {
}
void dOvlpFd3_dlst_c::draw() {
#if TARGET_PC
GXSetViewport(0.0f, 0.0f, mDoGph_gInf_c::getWidth(), mDoGph_gInf_c::getHeight(), 0.0f, 1.0f);
GXSetScissor(0, 0, mDoGph_gInf_c::getWidth(), mDoGph_gInf_c::getHeight());
#else
GXSetViewport(0.0f, 0.0f, FB_WIDTH, FB_HEIGHT, 0.0f, 1.0f);
GXSetScissor(0, 0, FB_WIDTH, FB_HEIGHT);
#endif
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_CLR_RGB, GX_RGBA4, 0);
GXClearVtxDesc();
GXSetVtxDesc(GX_VA_POS, GX_DIRECT);
@@ -112,19 +106,6 @@ void dOvlpFd3_dlst_c::draw() {
GXBegin(GX_QUADS, GX_VTXFMT0, 4);
#if TARGET_PC
GXPosition2s16(-FB_WIDTH / 2, FB_HEIGHT / 2);
GXTexCoord2s8(0, 0);
GXPosition2s16(FB_WIDTH / 2, FB_HEIGHT / 2);
GXTexCoord2s8(1, 0);
GXPosition2s16(FB_WIDTH / 2, -FB_HEIGHT / 2);
GXTexCoord2s8(1, 1);
GXPosition2s16(-FB_WIDTH / 2, -FB_HEIGHT / 2);
GXTexCoord2s8(0, 1);
#else
GXPosition2s16(-mDoGph_gInf_c::getWidth() / 2, mDoGph_gInf_c::getHeight() / 2);
GXTexCoord2s8(0, 0);
@@ -136,7 +117,6 @@ void dOvlpFd3_dlst_c::draw() {
GXPosition2s16(-mDoGph_gInf_c::getWidth() / 2, -mDoGph_gInf_c::getHeight() / 2);
GXTexCoord2s8(0, 1);
#endif
GXEnd();
+1 -5
View File
@@ -356,12 +356,8 @@ Vec CPaneMgr::getGlobalVtx(J2DPane* p_pane, Mtx* param_1, u8 param_2, bool param
Mtx m;
MtxP mp = (MtxP)param_1;
J2DPane* parent = p_pane->getParentPane();
#if TARGET_PC
J2DOrthoGraph ortho(0.0f, 0.0f, mDoGph_gInf_c::getWidth(), mDoGph_gInf_c::getHeight(), -1.0f, 1.0f);
#else
J2DOrthoGraph ortho(0.0f, 0.0f, FB_WIDTH, FB_HEIGHT, -1.0f, 1.0f);
#endif
ortho.setOrtho(mDoGph_gInf_c::getMinXF(), mDoGph_gInf_c::getMinYF(), mDoGph_gInf_c::getWidthF(), mDoGph_gInf_c::getHeightF(), -1.0f, 1.0f);
if (parent != NULL) {
+5 -1
View File
@@ -296,7 +296,11 @@ J3DModelData* dRes_info_c::loaderBasicBmd(u32 i_tag, void* i_data) {
addWarpMaterial(modelData);
}
if (i_tag == 'BMDR' || i_tag == 'BMWR') {
// FRAME INTERP NOTE: Always create shared DL buffers so we can use J3DMaterial::diff()
#ifndef TARGET_PC
if (i_tag == 'BMDR' || i_tag == 'BMWR')
#endif
{
s32 result = modelData->newSharedDisplayList(J3DMdlFlag_UseSingleDL);
if (result != kJ3DError_Success) {
return NULL;
-5
View File
@@ -1418,12 +1418,7 @@ static int phase_4(dScnPly_c* i_this) {
dComIfGp_setPlayerPtr(i, NULL);
}
#if TARGET_PC
dComIfGp_setWindow(0, 0.0f, 0.0f, mDoGph_gInf_c::getWidth(), mDoGph_gInf_c::getHeight(), 0.0f,
1.0f, 0, 2);
#else
dComIfGp_setWindow(0, 0.0f, 0.0f, FB_WIDTH, FB_HEIGHT, 0.0f, 1.0f, 0, 2);
#endif
dComIfGp_setCameraInfo(0, NULL, 0, 0, -1);
dComIfGd_setWindow(NULL);
dComIfGd_setViewport(NULL);
+27 -16
View File
@@ -69,6 +69,9 @@ dSelect_cursor_c::dSelect_cursor_c(u8 param_0, f32 param_1, JKRArchive* param_2)
field_0x84[i] = 0.0f;
}
mParam1 = mpCursorHIO->mXAxisExpansion;
#ifdef TARGET_PC
mBaseParam1 = mParam1;
#endif
mParam2 = mpCursorHIO->mYAxisExpansion;
mParam3 = mpCursorHIO->mOscillation;
mParam4 = mpCursorHIO->mRatioX;
@@ -259,6 +262,13 @@ void dSelect_cursor_c::update() {
if (field_0xb6 == 3) {
fVar1 = 0.5f;
}
#ifdef TARGET_PC
if (mpPane) {
Vec pos = mpPaneMgr->getGlobalVtxCenter(mpPane, false, 0);
mPositionX = pos.x;
mPositionY = pos.y;
}
#endif
mpPaneMgr->translate(mPositionX, mPositionY);
if (mpCursorHIO->mDebugON) {
mParam1 = mpCursorHIO->mXAxisExpansion;
@@ -272,9 +282,9 @@ void dSelect_cursor_c::update() {
if (field_0x30) {
if (chkPlayAnime(0)) {
#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) {
if (dusk::frame_interp::get_ui_tick_pending())
#endif
{
if (mNameIdx == 1) {
field_0x44 += mpCursorHIO->field_0x8 * fVar1;
} else {
@@ -284,9 +294,7 @@ void dSelect_cursor_c::update() {
if (field_0x44 >= field_0x30->getFrameMax()) {
field_0x44 -= field_0x30->getFrameMax();
}
#ifdef TARGET_PC
}
#endif
field_0x30->setFrame(field_0x44);
setBpkAnimation(field_0x30);
@@ -303,9 +311,9 @@ void dSelect_cursor_c::update() {
if (field_0x34[i]) {
if ((i == 0 && chkPlayAnime(2)) || (i == 1 && chkPlayAnime(3))) {
#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) {
if (dusk::frame_interp::get_ui_tick_pending())
#endif
{
if (mNameIdx == 1) {
field_0x48[i] += mpCursorHIO->field_0x8 * fVar1;
} else {
@@ -314,9 +322,7 @@ void dSelect_cursor_c::update() {
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]);
}
@@ -326,9 +332,9 @@ void dSelect_cursor_c::update() {
if (field_0x2C && chkPlayAnime(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) {
if (dusk::frame_interp::get_ui_tick_pending())
#endif
{
if (mNameIdx == 1) {
field_0x40 += mpCursorHIO->field_0x8 * fVar1;
} else {
@@ -337,9 +343,7 @@ void dSelect_cursor_c::update() {
if (field_0x40 >= field_0x2C->getFrameMax()) {
field_0x40 -= field_0x2C->getFrameMax();
}
#ifdef TARGET_PC
}
#endif
field_0x2C->setFrame(field_0x40);
setBckAnimation(field_0x2C);
@@ -348,13 +352,11 @@ void dSelect_cursor_c::update() {
if (chkPlayAnime(1) && mNameIdx == 0) {
#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) {
if (dusk::frame_interp::get_ui_tick_pending())
#endif
{
setCursorAnimation();
#ifdef TARGET_PC
}
#endif
}
mpScreen->animation();
@@ -412,6 +414,9 @@ void dSelect_cursor_c::setPos(f32 i_posX, f32 i_posY, J2DPane* i_pane, bool i_sc
void dSelect_cursor_c::setParam(f32 i_param1, f32 i_param2, f32 i_param3, f32 i_param4,
f32 i_param5) {
mParam1 = i_param1;
#ifdef TARGET_PC
mBaseParam1 = i_param1;
#endif
mParam2 = i_param2;
mParam3 = i_param3;
mParam4 = i_param4;
@@ -570,3 +575,9 @@ void dSelect_cursor_c::setBckAnimation(J2DAnmTransformKey* param_0) {
void dSelect_cursor_c::moveCenter(J2DPane* i_pane, f32 i_x, f32 i_y) {
i_pane->translate(i_x,i_y);
}
#ifdef TARGET_PC
void dSelect_cursor_c::refreshAspectScale() {
mParam1 = mBaseParam1 * mDoGph_gInf_c::hudAspectScaleUp;
}
#endif
+4 -4
View File
@@ -9,9 +9,9 @@ dSi_HIO_c::dSi_HIO_c() {}
void dSelect_icon_c::animation() {
if (field_0x10->getAlpha() != 0) {
#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) {
if (dusk::frame_interp::get_ui_tick_pending())
#endif
{
field_0x20 += field_0x2c;
if (field_0x20 >= field_0x1c->getFrameMax()) {
field_0x20 = 0.0f;
@@ -22,9 +22,9 @@ void dSelect_icon_c::animation() {
if (field_0x28 >= field_0x24->getFrameMax()) {
field_0x28 = 0.0f;
}
#ifdef TARGET_PC
}
// Set even if not advancing
#ifdef TARGET_PC
// FRAME INTERP NOTE: Set even if not advancing
field_0x1c->setFrame(field_0x20);
#endif
+12 -4
View File
@@ -855,11 +855,7 @@ int dShopSystem_c::seq_wait(fopAc_ac_c* param_0, dMsgFlow_c* param_1) {
}
inline void pos3Dto2D(Vec* a, Vec* b) {
#if TARGET_PC
mDoLib_project(a, b, {0, 0, FB_WIDTH, FB_HEIGHT});
#else
mDoLib_project(a, b);
#endif
}
int dShopSystem_c::seq_start(fopAc_ac_c* actor, dMsgFlow_c* i_flow) {
@@ -1572,10 +1568,22 @@ BOOL dShopSystem_c::checkShopOpen() {
}
bool dShopSystem_c::checkLeftTrigger(STControl* i_stick) {
#if TARGET_PC
if (dusk::getSettings().game.enableMirrorMode) {
return i_stick->checkRightTrigger();
}
#endif
return i_stick->checkLeftTrigger();
}
bool dShopSystem_c::checkRightTrigger(STControl* i_stick) {
#if TARGET_PC
if (dusk::getSettings().game.enableMirrorMode) {
return i_stick->checkLeftTrigger();
}
#endif
return i_stick->checkRightTrigger();
}
+28 -30
View File
@@ -23,9 +23,7 @@
#include "m_Do/m_Do_lib.h"
#include <cstring>
#if TARGET_PC
#include "dusk/frame_interpolation.h"
#endif
static int dTimer_createStart2D(s32 param_0, u16 param_1);
@@ -1340,27 +1338,22 @@ void dDlst_TimerScrnDraw_c::draw() {
f32 temp = (f32)g_drawHIO.mMiniGame.mGetInTextAlphaFrames +
((f32)g_drawHIO.mMiniGame.mGetInTextWaitFrames + 60.0f);
#if TARGET_PC
const u32 pending_ui_ticks = dusk::frame_interp::get_presentation_ui_advance_ticks();
#else
const u32 pending_ui_ticks = 1u;
#endif
for (int i = 0; i < 51; i++) {
for (u32 tick = 0; tick < pending_ui_ticks; tick++) {
if (!(m_getin_info[i].bck_frame > 0.0f && m_getin_info[i].bck_frame < temp)) {
break;
}
if (m_getin_info[i].bck_frame < 60.0f) {
m_getin_info[i].bck_frame += g_drawHIO.mMiniGame.mGetInTextAnimSpeed;
if (m_getin_info[i].bck_frame > 60.0f) {
m_getin_info[i].bck_frame = 60.0f;
#if TARGET_PC
if (dusk::frame_interp::get_ui_tick_pending())
#endif
{
if (m_getin_info[i].bck_frame > 0.0f && m_getin_info[i].bck_frame < temp) {
if (m_getin_info[i].bck_frame < 60.0f) {
m_getin_info[i].bck_frame += g_drawHIO.mMiniGame.mGetInTextAnimSpeed;
if (m_getin_info[i].bck_frame > 60.0f) {
m_getin_info[i].bck_frame = 60.0f;
}
} else if (m_getin_info[i].bck_frame < g_drawHIO.mMiniGame.mGetInTextWaitFrames + 60.0f) {
m_getin_info[i].bck_frame++;
} else if (m_getin_info[i].bck_frame < temp) {
m_getin_info[i].bck_frame++;
}
} else if (m_getin_info[i].bck_frame < g_drawHIO.mMiniGame.mGetInTextWaitFrames + 60.0f) {
m_getin_info[i].bck_frame++;
} else if (m_getin_info[i].bck_frame < temp) {
m_getin_info[i].bck_frame++;
}
}
@@ -1369,7 +1362,7 @@ void dDlst_TimerScrnDraw_c::draw() {
if (m_getin_info[i].bck_frame >= g_drawHIO.mMiniGame.mGetInTextWaitFrames + 60.0f &&
m_getin_info[i].bck_frame < temp) {
var_f29 = acc(g_drawHIO.mMiniGame.mGetInTextAlphaFrames,
temp - m_getin_info[i].bck_frame, 0);
temp - m_getin_info[i].bck_frame, 0);
}
if (m_getin_info[i].bck_frame < 60.0f) {
@@ -1382,7 +1375,7 @@ void dDlst_TimerScrnDraw_c::draw() {
if (g_drawHIO.mMiniGame.mGetInTextLocation == 1) {
mpGetInRoot->translate(m_getin_info[i].pos_x + g_drawHIO.mMiniGame.mGetInTextPosX,
m_getin_info[i].pos_y + g_drawHIO.mMiniGame.mGetInTextPosY);
m_getin_info[i].pos_y + g_drawHIO.mMiniGame.mGetInTextPosY);
} else {
f32 temp_f2 = m_getin_info[i].bck_frame - 40.0f;
f32 var_f3 = ((temp_f2 * 0.5f) * temp_f2) * 0.15f;
@@ -1396,20 +1389,25 @@ void dDlst_TimerScrnDraw_c::draw() {
}
mpGetInRoot->scale(g_drawHIO.mMiniGame.mGetInTextSizeX,
g_drawHIO.mMiniGame.mGetInTextSizeY);
g_drawHIO.mMiniGame.mGetInTextSizeY);
mpGetInScreen->draw(0.0f, 0.0f, graf_ctx);
if (m_getin_info[i].pikari_frame > 0.0f) {
drawPikari(i);
} else if (m_getin_info[i].pikari_frame == -1.0f) {
if (m_getin_info[i].field_0xc == 0) {
if (m_getin_info[i].bck_frame > g_drawHIO.mMiniGame.mGetInPikariAppearFrames) {
#if TARGET_PC
if (dusk::frame_interp::get_ui_tick_pending())
#endif
{
if (m_getin_info[i].field_0xc == 0) {
if (m_getin_info[i].bck_frame > g_drawHIO.mMiniGame.mGetInPikariAppearFrames) {
m_getin_info[i].pikari_frame =
18.0f - g_drawHIO.mMiniGame.mGetInPikariAnimSpeed;
}
} else if (m_getin_info[i].bck_frame > g_drawHIO.mMiniGame.mStartPikariAppearFrames) {
m_getin_info[i].pikari_frame =
18.0f - g_drawHIO.mMiniGame.mGetInPikariAnimSpeed;
18.0f - g_drawHIO.mMiniGame.mStartPikariAnimSpeed;
}
} else if (m_getin_info[i].bck_frame > g_drawHIO.mMiniGame.mStartPikariAppearFrames) {
m_getin_info[i].pikari_frame =
18.0f - g_drawHIO.mMiniGame.mStartPikariAnimSpeed;
}
}
}
+8
View File
@@ -77,6 +77,14 @@ void dusk::audio::SetMasterVolume(const f32 value) {
MasterVolume = value;
}
void dusk::audio::SetPaused(const bool paused) {
if (paused) {
SDL_PauseAudioStreamDevice(PlaybackStream);
} else {
SDL_ResumeAudioStreamDevice(PlaybackStream);
}
}
void dusk::audio::SetEnableReverb(const bool value) {
JASCriticalSection section;
+132 -10
View File
@@ -5,14 +5,15 @@
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <span>
#include "Adpcm.hpp"
#include "freeverb/revmodel.hpp"
#include "JSystem/JAudio2/JASDriverIF.h"
#include "dusk/audio/DuskAudioSystem.h"
#include "dusk/endian.h"
#include "dusk/logging.h"
#include "global.h"
#include "tracy/Tracy.hpp"
@@ -95,6 +96,13 @@ static void RenderChannel(
ChannelAuxData& channelAux,
OutputSubframe& subframe);
static void RenderOutputChannel(
const JASDsp::TChannel& sourceChannel,
ChannelAuxData& aux,
OutputChannel outputChannel,
const std::span<f32> inputSamples,
OutputSubframe& fullOutputSubframe);
/**
* Converts a pitch value on a DSP channel to a sample rate.
*/
@@ -117,6 +125,8 @@ static void ResetChannel(JASDsp::TChannel& channel, ChannelAuxData& aux) {
aux.resamplePos = 0.0;
aux.resamplePrev = 0;
aux.oscPhase = 0;
aux.prev_lp_out = 0.0f;
aux.prev_lp_in = 0.0f;
@@ -141,6 +151,119 @@ static void MixSubframe(DspSubframe& dst, const DspSubframe& src) {
}
}
enum class OscType : u16 {
SQUARE_WAVE_PW_50 = 0,
SAW_WAVE = 1,
SQUARE_WAVE_PW_25 = 3,
TRIANGLE_WAVE = 4,
// idk what 5 and 6 are
SINE_WAVE = 7,
// idk what 8 and 9 are
SINE_WAVE_VAR_STEP = 10,
EVOLVING_HARMONIC = 11,
EVOLVING_RAMP = 12,
};
static s16 gEvolvingHarmonic[64];
static void GenerateEvolvingHarmonic() {
static bool initialized = false;
if (!initialized) {
gEvolvingHarmonic[62] = 8191;
gEvolvingHarmonic[63] = 16383;
initialized = true;
}
u32 prev2 = (u32)gEvolvingHarmonic[62];
u32 prev1 = (u32)gEvolvingHarmonic[63];
for (int i = 0; i < 64; i += 2) {
u32 cur = (u32)gEvolvingHarmonic[i];
gEvolvingHarmonic[i] = (s16)((s32)(prev2 * prev1 - (cur << 16)) >> 16);
prev2 = prev1;
prev1 = cur;
cur = (u32)gEvolvingHarmonic[i + 1];
gEvolvingHarmonic[i + 1] = (s16)((s32)(2u * (prev2 * prev1 + (cur << 16))) >> 16);
prev2 = prev1;
prev1 = cur;
}
}
static void RenderOscChannel(
JASDsp::TChannel& channel,
ChannelAuxData& channelAux,
OutputSubframe& subframe) {
if (channel.mResetFlag)
ResetChannel(channel, channelAux);
const u32 pitch = channel.mPitch;
DspSubframe buf = {};
const auto oscType = static_cast<OscType>(channel.mBytesPerBlock);
switch (oscType) {
case OscType::SQUARE_WAVE_PW_50: {
std::generate(buf.begin(), buf.end(), [&] {
f32 s = channelAux.oscPhase < 0x8000u ? 0.5f : -0.5f;
channelAux.oscPhase += pitch >> 1;
return s;
});
break;
}
case OscType::SQUARE_WAVE_PW_25: {
std::generate(buf.begin(), buf.end(), [&] {
f32 s = channelAux.oscPhase < 0x4000u ? 0.5f : -0.5f;
channelAux.oscPhase += pitch >> 1;
return s;
});
break;
}
case OscType::SAW_WAVE:
case OscType::EVOLVING_RAMP: {
std::generate(buf.begin(), buf.end(), [&] {
f32 s = (f32)(s16)channelAux.oscPhase / 32768.0f;
channelAux.oscPhase += pitch >> 1;
return s;
});
break;
}
case OscType::SINE_WAVE:
case OscType::SINE_WAVE_VAR_STEP: {
std::generate(buf.begin(), buf.end(), [&] {
f32 s = sinf((f32)channelAux.oscPhase * (2.0f * M_PI / 65536.0f)) * 0.5f;
channelAux.oscPhase += pitch >> 1;
return s;
});
break;
}
case OscType::TRIANGLE_WAVE: {
std::generate(buf.begin(), buf.end(), [&] {
f32 s = 0.5f - fabsf((f32)(s16)channelAux.oscPhase / 32768.0f);
channelAux.oscPhase += pitch >> 1;
return s;
});
break;
}
case OscType::EVOLVING_HARMONIC: {
std::generate(buf.begin(), buf.end(), [&] {
f32 s = gEvolvingHarmonic[channelAux.oscPhase >> 10] / 32768.0f;
channelAux.oscPhase += pitch >> 1;
return s;
});
break;
}
default:
DuskLog.error("RenderOscChannel: unimplemented oscillator type {}", channel.mBytesPerBlock);
break;
}
auto samples = std::span(buf).subspan(0, DSP_SUBFRAME_SIZE);
RenderOutputChannel(channel, channelAux, OutputChannel::LEFT, samples, subframe);
RenderOutputChannel(channel, channelAux, OutputChannel::RIGHT, samples, subframe);
}
void dusk::audio::DspRender(OutputSubframe& subframe) {
ZoneScoped;
if (DumpAudio != sDumpWasActive) {
@@ -152,6 +275,8 @@ void dusk::audio::DspRender(OutputSubframe& subframe) {
}
}
GenerateEvolvingHarmonic();
std::span channels(JASDsp::CH_BUF, DSP_CHANNELS);
DspSubframe reverbInputL = {};
@@ -174,17 +299,14 @@ void dusk::audio::DspRender(OutputSubframe& subframe) {
channel.mIsFinished = true;
continue;
}
else if (channel.mWaveAramAddress == 0) {
// I think these are oscillator channels? Not backed by audio.
// No idea how to implement these yet, so skip them.
channel.mIsFinished = true;
continue;
}
ValidateChannel(channel);
OutputSubframe channelSubframe = {};
RenderChannel(channel, channelAux, channelSubframe);
if (channel.mWaveAramAddress == 0) {
RenderOscChannel(channel, channelAux, channelSubframe);
} else {
ValidateChannel(channel);
RenderChannel(channel, channelAux, channelSubframe);
}
if (EnableReverb) {
// scale the input to the reverb rather than using wet/dry on the output.
+3
View File
@@ -53,6 +53,9 @@ namespace dusk::audio {
// last consumed sample from decodeBuf
s16 resamplePrev;
// phase of oscillator channels
u16 oscPhase;
// low pass previous state
f32 prev_lp_out; // out[n-1]
f32 prev_lp_in; // in[n-1]
+2 -2
View File
@@ -10,7 +10,7 @@
#include <limits>
#include <string>
#include "dusk/dusk.h"
#include "dusk/main.h"
using namespace dusk::config;
@@ -24,7 +24,7 @@ static absl::flat_hash_map<std::string_view, ConfigVarBase*> RegisteredConfigVar
static bool RegistrationDone = false;
static std::string GetConfigJsonPath() {
return fmt::format("{}{}", configPath, ConfigFileName);
return (dusk::ConfigPath / ConfigFileName).string();
}
ConfigVarBase::ConfigVarBase(const char* name, const ConfigImplBase* impl) : name(name), registered(false), layer(ConfigVarLayer::Default), impl(impl) {
+2 -1
View File
@@ -3,6 +3,7 @@
#include "dusk/app_info.hpp"
#include "dusk/dusk.h"
#include "dusk/logging.h"
#include "dusk/main.h"
#include "dusk/settings.h"
#include "version.h"
@@ -66,7 +67,7 @@ std::string GetReleaseName() {
}
std::filesystem::path GetSentryDatabasePath() {
return std::filesystem::path(configPath) / "sentry";
return dusk::ConfigPath / "sentry";
}
std::filesystem::path GetLogAttachmentPath() {
+122
View File
@@ -0,0 +1,122 @@
#ifdef DUSK_DISCORD_RPC
#include "dusk/discord_presence.hpp"
#include "dusk/logging.h"
#include "dusk/main.h"
#include "dusk/map_loader_definitions.h"
#include "d/d_com_inf_game.h"
#include "discord_rpc.h"
#include "fmt/format.h"
#include <chrono>
#include <cstring>
#include <string>
namespace dusk {
namespace discord {
static int64_t g_startTime = 0;
static bool g_initialized = false;
static const char* APPLICATION_ID = "1495632471994405035";
static void OnReady(const DiscordUser* user) {
DuskLog.info("Discord: Connected as {}", user->username);
}
static void OnDisconnected(int errorCode, const char* message) {
DuskLog.warn("Discord: Disconnected ({}: {})", errorCode, message);
}
static void OnError(int errorCode, const char* message) {
DuskLog.warn("Discord: Error ({}: {})", errorCode, message);
}
static const char* LookupMapName(const char* mapFile) {
if (!mapFile || mapFile[0] == '\0') return nullptr;
for (const auto& region : gameRegions) {
for (const auto& map : region.maps) {
if (map.mapFile && strcmp(mapFile, map.mapFile) == 0) {
return map.mapName;
}
}
}
return nullptr;
}
void Initialize() {
g_startTime = static_cast<int64_t>(
std::chrono::duration_cast<std::chrono::seconds>(
std::chrono::system_clock::now().time_since_epoch()
).count()
);
DiscordEventHandlers handlers{};
handlers.ready = OnReady;
handlers.disconnected = OnDisconnected;
handlers.errored = OnError;
Discord_Initialize(APPLICATION_ID, &handlers, 0, nullptr);
g_initialized = true;
DuskLog.info("Discord Rich Presence initialized");
}
void RunCallbacks() {
if (!g_initialized) return;
Discord_RunCallbacks();
}
void UpdatePresence() {
if (!g_initialized) return;
static auto lastUpdate = std::chrono::steady_clock::time_point{};
const auto now = std::chrono::steady_clock::now();
if (now - lastUpdate < std::chrono::seconds(15)) return;
lastUpdate = now;
static std::string detailsBuf;
static std::string stateBuf;
DiscordRichPresence presence{};
presence.startTimestamp = g_startTime;
presence.largeImageKey = "icon";
presence.largeImageText = "Dusk";
if (dusk::IsGameLaunched) {
const char* stageName = dComIfGp_getLastPlayStageName();
// stageName is empty until a room is actually entered
if (stageName[0] != '\0') {
const char* locationName = LookupMapName(stageName);
if (locationName) {
detailsBuf = locationName;
}
else {
detailsBuf = "Twilight Princess";
}
presence.details = detailsBuf.c_str();
stateBuf = fmt::format(FMT_STRING("{}/{} \u2665 | {} Rupees"),
dComIfGs_getLife() / 4, dComIfGs_getMaxLife() / 5, dComIfGs_getRupee());
presence.state = stateBuf.c_str();
}
}
Discord_UpdatePresence(&presence);
DuskLog.debug("Discord Rich Presence sent");
}
void Shutdown() {
if (!g_initialized) return;
Discord_ClearPresence();
Discord_Shutdown();
g_initialized = false;
DuskLog.info("Discord Rich Presence shut down");
}
} // namespace discord
} // namespace dusk
#endif // DUSK_DISCORD_RPC
+91
View File
@@ -0,0 +1,91 @@
#include "file_select.hpp"
#include <memory>
#include <SDL3/SDL_dialog.h>
#include <SDL3/SDL_error.h>
#if defined(__APPLE__)
#include <TargetConditionals.h>
#endif
#if defined(__APPLE__) && TARGET_OS_IOS && !TARGET_OS_MACCATALYST
#define USE_IOS_DIALOG 1
#include "ios/FileSelectDialog.h"
#else
#define USE_IOS_DIALOG 0
#endif
namespace dusk {
namespace {
#if USE_IOS_DIALOG
struct IOSDialogCallbackState {
FileCallback callback;
void* userdata;
};
void onIOSDialogFinished(void* userdata, const char* path, const char* error) {
std::unique_ptr<IOSDialogCallbackState> state(static_cast<IOSDialogCallbackState*>(userdata));
if (error != nullptr) {
state->callback(state->userdata, nullptr, error);
return;
}
if (path == nullptr) {
state->callback(state->userdata, nullptr, nullptr);
return;
}
state->callback(state->userdata, path, nullptr);
}
#else
struct SDLDialogCallbackState {
FileCallback callback;
void* userdata;
};
void onSDLDialogFinished(void* userdata, const char* const* filelist, [[maybe_unused]] int filter) {
std::unique_ptr<SDLDialogCallbackState> state(static_cast<SDLDialogCallbackState*>(userdata));
if (filelist == nullptr) {
state->callback(state->userdata, nullptr, SDL_GetError());
return;
}
if (filelist[0] == nullptr) {
state->callback(state->userdata, nullptr, nullptr);
return;
}
state->callback(state->userdata, filelist[0], nullptr);
}
#endif
} // namespace
void ShowFileSelect(FileCallback callback, void* userdata, SDL_Window* window,
const SDL_DialogFileFilter* filters, int nfilters, const char* default_location,
bool allow_many) {
if (callback == nullptr) {
return;
}
#if USE_IOS_DIALOG
auto state = std::make_unique<IOSDialogCallbackState>();
state->callback = callback;
state->userdata = userdata;
Dusk_iOS_ShowFileSelect(&onIOSDialogFinished, state.release(), window, filters, nfilters,
default_location, allow_many);
#else
auto state = std::make_unique<SDLDialogCallbackState>();
state->callback = callback;
state->userdata = userdata;
SDL_ShowOpenFileDialog(&onSDLDialogFinished, state.release(), window, filters, nfilters,
default_location, allow_many);
#endif
}
} // namespace dusk
+15
View File
@@ -0,0 +1,15 @@
#pragma once
#include <SDL3/SDL_dialog.h>
struct SDL_Window;
namespace dusk {
using FileCallback = void (*)(void* userdata, const char* path, const char* error);
void ShowFileSelect(FileCallback callback, void* userdata, SDL_Window* window,
const SDL_DialogFileFilter* filters, int nfilters, const char* default_location,
bool allow_many);
} // namespace dusk
+252 -365
View File
@@ -1,91 +1,68 @@
#include "f_op/f_op_camera_mng.h"
#include "dusk/frame_interpolation.h"
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <memory>
#include <unordered_map>
#include <vector>
#include "mtx.h"
#include "f_op/f_op_camera_mng.h"
#include "m_Do/m_Do_graphic.h"
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;
uint64_t stable_tag = 0;
};
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;
Label draw_scope{};
uint32_t simple_shadow_pair_seq = 0;
};
struct Recording {
Path root;
std::unordered_map<uintptr_t, Mtx> matrix_values;
};
struct MatrixValue {
Mtx value;
};
using FinalMtxLookup = std::unordered_map<const Mtx*, const Data*>;
using FinalMtxLookupTagged = std::unordered_map<uint64_t, const Data*>;
bool s_initialized = false;
bool g_enabled = false;
bool g_recording = false;
bool g_interpolating = false;
bool g_sync_presentation = false;
uint32_t g_presentation_counter = 0;
float g_step = 0.0f;
uint32_t g_pending_presentation_ui_ticks = 0;
uint32_t g_current_presentation_ui_ticks = 0;
bool g_is_sim_frame = false;
bool g_ui_tick_pending = false;
Recording g_current_recording;
Recording g_previous_recording;
std::vector<Path*> g_current_path;
std::unordered_map<const Mtx*, MatrixValue> g_replacements;
std::unordered_map<uintptr_t, Mtx> g_replacements;
inline void copy_matrix(const Mtx src, Mtx dst) {
MTXCopy(src, dst);
}
struct CameraSnapshot {
cXyz eye{};
cXyz center{};
cXyz up{};
s16 bank{};
f32 fovy{};
f32 aspect{};
f32 near_{};
f32 far_{};
bool wideZoom{};
bool valid{};
};
inline void concat_matrix(const Mtx lhs, const Mtx rhs, Mtx out) {
MTXConcat(lhs, rhs, out);
CameraSnapshot s_cam_prev{};
CameraSnapshot s_cam_curr{};
view_class s_presentation_view_backup{};
int s_presentation_depth = 0;
struct InterpolationCallBackWork {
dusk::frame_interp::InterpolationCallBack pCallBack;
void* pUserWork;
};
std::vector<InterpolationCallBackWork> s_interpolationCallBackWork;
void copy_view_to_snap(CameraSnapshot* dst, const view_class& v) {
dst->eye = v.lookat.eye;
dst->center = v.lookat.center;
dst->up = v.lookat.up;
dst->bank = v.bank;
dst->fovy = v.fovy;
dst->aspect = v.aspect;
dst->near_ = v.near_;
dst->far_ = v.far_;
dst->valid = true;
}
inline void lerp_matrix(Mtx out, const Mtx lhs, const Mtx rhs, float step) {
@@ -104,6 +81,12 @@ inline void lerp_xyz(cXyz* out, const cXyz& lhs, const cXyz& rhs, float step) {
out->z = lhs.z * old_weight + rhs.z * step;
}
static s16 lerp_bank(s16 a, s16 b, f32 t) {
const f32 ra = S2RAD(a);
const f32 d = remainderf(S2RAD(b) - ra, 2.0f * static_cast<f32>(M_PI));
return cAngle::Radian_to_SAngle(ra + d * t);
}
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) {
@@ -115,162 +98,22 @@ inline bool matrix_differs(const Mtx lhs, const Mtx rhs, float epsilon = 0.0001f
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_lookups(const Path& path, FinalMtxLookup& dest_lookup, FinalMtxLookupTagged& tag_lookup) {
dest_lookup.clear();
tag_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) {
dest_lookup[data.dest] = &data;
}
if (data.stable_tag != 0) {
tag_lookup[data.stable_tag] = &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;
FinalMtxLookupTagged old_final_mtx_lookup_tagged;
build_final_mtx_lookups(old_path, old_final_mtx_lookup, old_final_mtx_lookup_tagged);
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 = nullptr;
if (op == Op::FinalMtx) {
if (new_data->stable_tag != 0) {
const auto it = old_final_mtx_lookup_tagged.find(new_data->stable_tag);
old_data = it != old_final_mtx_lookup_tagged.end() ? it->second : nullptr;
} else {
old_data = find_matching_final_mtx(old_final_mtx_lookup, *new_data);
}
} else {
old_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 || dusk::frame_interp::presentation_sync_active()) {
return source;
}
auto it = g_replacements.find(source);
auto it = g_replacements.find(reinterpret_cast<uintptr_t>(source));
if (it == g_replacements.end()) {
return source;
}
copy_matrix(it->second.value, *scratch);
MTXCopy(it->second, *scratch);
return scratch;
}
bool has_recording_data(const Recording& recording) {
return !recording.root.items.empty() || !recording.root.children.empty();
return !recording.matrix_values.empty();
}
void clear_replacements() {
@@ -281,51 +124,80 @@ void clear_replacements() {
namespace dusk::frame_interp {
void ensure_initialized() {
g_enabled = getSettings().game.enableFrameInterpolation;
s_initialized = true;
}
void begin_sim_tick() {
ensure_initialized();
if (!g_enabled) {
return;
}
s_interpolationCallBackWork.clear();
s_cam_prev = std::move(s_cam_curr);
}
void begin_frame(bool enabled, bool is_sim_frame, float step) {
g_enabled = enabled;
g_is_sim_frame = is_sim_frame;
g_step = std::clamp(step, 0.0f, 1.0f);
}
bool is_enabled() {
return g_enabled;
}
bool is_sim_frame() {
return g_is_sim_frame;
}
void begin_record() {
ensure_initialized();
if (!g_enabled) {
g_interpolating = false;
g_sync_presentation = false;
g_previous_recording = {};
g_current_recording = {};
g_current_path.clear();
clear_replacements();
s_cam_prev.valid = false;
s_cam_curr.valid = false;
return;
}
g_sync_presentation = false;
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();
::camera_process_class* cam = dComIfGp_getCamera(0);
if (cam == nullptr) {
s_cam_prev.valid = false;
s_cam_curr.valid = false;
return;
}
}
void end_record() {
g_recording = false;
}
void interpolate(float step) {
void interpolate() {
ensure_initialized();
clear_replacements();
g_step = std::clamp(step, 0.0f, 1.0f);
g_interpolating = g_enabled && !g_recording && !g_sync_presentation && has_recording_data(g_current_recording);
if (!g_interpolating) {
return;
}
const Path& old_root = has_recording_data(g_previous_recording) ? g_previous_recording.root : g_current_recording.root;
interpolate_branch(old_root, g_current_recording.root, g_step);
}
void notify_presentation_frame() {
ensure_initialized();
++g_presentation_counter;
for (auto const& old : g_previous_recording.matrix_values) {
if (auto it = g_current_recording.matrix_values.find(old.first);
it != g_current_recording.matrix_values.end())
{
lerp_matrix(g_replacements[old.first], old.second, it->second, g_step);
}
}
}
void request_presentation_sync() {
@@ -348,92 +220,40 @@ float get_interpolation_step() {
return presentation_sync_active() ? 1.0f : g_step;
}
void notify_sim_tick_complete() {
void set_ui_tick_pending(bool value) {
if (g_ui_tick_pending == value) { return; }
g_ui_tick_pending = value;
}
bool get_ui_tick_pending() {
ensure_initialized();
g_pending_presentation_ui_ticks++;
return g_enabled ? g_ui_tick_pending : true;
}
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) {
void record_final_mtx(Mtx m, const void* key) {
if (!s_initialized || !g_recording || m == nullptr) {
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>());
Path* const child = siblings.back().get();
child->draw_scope = label;
g_current_path.push_back(child);
auto& it = g_current_recording.matrix_values[reinterpret_cast<uintptr_t>(key)];
MTXCopy(m, it);
}
void close_child() {
if (!s_initialized || !g_recording || g_current_path.size() <= 1) {
return;
}
g_current_path.pop_back();
void record_final_mtx(Mtx m) {
record_final_mtx(m, m);
}
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;
data.stable_tag = 0;
copy_matrix(src, data.matrix);
}
void record_final_mtx_raw_tagged(const Mtx* dest, const Mtx src, uint64_t stable_tag) {
if (!s_initialized || !g_recording || dest == nullptr) {
return;
}
Data& data = append_op(Op::FinalMtx);
data.dest = dest;
data.stable_tag = stable_tag;
copy_matrix(src, data.matrix);
}
bool lookup_replacement(const void* source, Mtx out) {
if (presentation_sync_active() || !g_interpolating || source == nullptr) {
bool lookup_replacement(const void* key, Mtx out) {
if (presentation_sync_active() || !g_interpolating || key == nullptr) {
return false;
}
auto it = g_replacements.find(reinterpret_cast<const Mtx*>(source));
auto it = g_replacements.find(reinterpret_cast<uintptr_t>(key));
if (it == g_replacements.end()) {
return false;
}
copy_matrix(it->second.value, out);
MTXCopy(it->second, out);
return true;
}
@@ -450,103 +270,170 @@ bool lookup_concat_replacement(const void* lhs, const void* rhs, Mtx out) {
return false;
}
concat_matrix(*resolved_lhs, *resolved_rhs, out);
MTXConcat(*resolved_lhs, *resolved_rhs, out);
return true;
}
// TODO: Is there already a built-in function for this?
void camera_eye_from_view_mtx(MtxP view_mtx, cXyz* o_eye) {
o_eye->x = -(view_mtx[0][0] * view_mtx[0][3] + view_mtx[1][0] * view_mtx[1][3] + view_mtx[2][0] * view_mtx[2][3]);
o_eye->y = -(view_mtx[0][1] * view_mtx[0][3] + view_mtx[1][1] * view_mtx[1][3] + view_mtx[2][1] * view_mtx[2][3]);
o_eye->z = -(view_mtx[0][2] * view_mtx[0][3] + view_mtx[1][2] * view_mtx[1][3] + view_mtx[2][2] * view_mtx[2][3]);
}
namespace {
struct CamSnap {
cXyz eye{};
cXyz center{};
cXyz up{};
s16 bank{};
f32 fovy{};
bool valid{};
};
CamSnap s_star_prev{};
CamSnap s_star_curr{};
static void copy_view_to_snap(CamSnap* dst, const view_class& v) {
dst->eye = v.lookat.eye;
dst->center = v.lookat.center;
dst->up = v.lookat.up;
dst->bank = v.bank;
dst->fovy = v.fovy;
dst->valid = true;
}
static void billboard_base_from_view(MtxP view_mtx, MtxP o_cam_billboard_base) {
Mtx rot;
MTXCopy(view_mtx, rot);
rot[0][3] = rot[1][3] = rot[2][3] = 0.0f;
MTXInverse(rot, o_cam_billboard_base);
}
} // namespace
void begin_record_camera() {
::camera_process_class* cam = dComIfGp_getCamera(0);
if (cam == nullptr) {
return;
}
copy_view_to_snap(&s_star_prev, cam->view);
}
void record_camera(::camera_process_class* cam, int camera_id) {
if (!getSettings().game.enableFrameInterpolation || camera_id != 0 || cam == nullptr) {
if (!g_enabled || camera_id != 0 || cam == nullptr) {
return;
}
copy_view_to_snap(&s_star_curr, cam->view);
copy_view_to_snap(&s_cam_curr, cam->view);
#if WIDESCREEN_SUPPORT
s_cam_curr.wideZoom = mDoGph_gInf_c::isWideZoom();
#endif
}
bool build_star_view(Mtx o_view, Mtx o_cam_billboard_base, cXyz* o_anchor_eye, float* o_fovy) {
if (!getSettings().game.enableFrameInterpolation || !s_star_prev.valid || !s_star_curr.valid) {
return false;
}
void interp_view(::view_class* view) {
if (!g_enabled)
return;
if (!s_cam_prev.valid || !s_cam_curr.valid)
return;
const f32 step = get_interpolation_step();
cXyz eye;
cXyz center;
cXyz up;
lerp_xyz(&eye, s_star_prev.eye, s_star_curr.eye, step);
lerp_xyz(&center, s_star_prev.center, s_star_curr.center, step);
lerp_xyz(&up, s_star_prev.up, s_star_curr.up, step);
lerp_xyz(&eye, s_cam_prev.eye, s_cam_curr.eye, step);
lerp_xyz(&center, s_cam_prev.center, s_cam_curr.center, step);
lerp_xyz(&up, s_cam_prev.up, s_cam_curr.up, step);
if (!up.normalizeRS()) {
up = s_star_curr.up;
up = s_cam_curr.up;
up.normalizeRS();
}
const f32 bank_rad = S2RAD(s_star_prev.bank) * (1.0f - step) + S2RAD(s_star_curr.bank) * step;
const s16 bank = cAngle::Radian_to_SAngle(bank_rad);
view->lookat.eye = eye;
view->lookat.center = center;
view->lookat.up = up;
view->bank = lerp_bank(s_cam_prev.bank, s_cam_curr.bank, step);
view->fovy = s_cam_prev.fovy + (s_cam_curr.fovy - s_cam_prev.fovy) * step;
view->aspect = s_cam_prev.aspect + (s_cam_curr.aspect - s_cam_prev.aspect) * step;
view->near_ = s_cam_prev.near_ + (s_cam_curr.near_ - s_cam_prev.near_) * step;
view->far_ = s_cam_prev.far_ + (s_cam_curr.far_ - s_cam_prev.far_) * step;
mDoMtx_lookAt(o_view, &eye, &center, &up, bank);
billboard_base_from_view(o_view, o_cam_billboard_base);
*o_anchor_eye = eye;
*o_fovy = s_star_prev.fovy + (s_star_curr.fovy - s_star_prev.fovy) * step;
return true;
// FRAME INTERP TODO: It might be better if I rewired the game to not clear this flag until the
// next sim frame, but I don't care enough to right now
#if WIDESCREEN_SUPPORT
if (mDoGph_gInf_c::isWide() && !mDoGph_gInf_c::isWideZoom() && step >= 0.5f ?
s_cam_curr.wideZoom :
s_cam_prev.wideZoom)
{
mDoGph_gInf_c::onWideZoom();
}
#endif
}
uint64_t alloc_simple_shadow_pair_base() {
if (!s_initialized || !g_recording || g_current_path.size() <= 1) {
return 0;
static void run_interpolation_callbacks() {
for (size_t i = 0; i < s_interpolationCallBackWork.size(); i++) {
auto const& work = s_interpolationCallBackWork[i];
work.pCallBack(g_is_sim_frame, work.pUserWork);
}
}
void add_interpolation_callback(InterpolationCallBack pCallBack, void* pUserWork) {
if (!is_enabled() || s_presentation_depth > 0 || !g_is_sim_frame)
return;
s_interpolationCallBackWork.emplace_back(pCallBack, pUserWork);
}
void begin_presentation_camera() {
ensure_initialized();
if (!g_enabled) {
return;
}
if (s_presentation_depth > 0) {
s_presentation_depth++;
return;
}
if (!s_cam_prev.valid || !s_cam_curr.valid) {
return;
}
Path* const scope = g_current_path.back();
const uint64_t h = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(scope->draw_scope.key));
const uint32_t lo = scope->simple_shadow_pair_seq;
scope->simple_shadow_pair_seq += 2;
uint64_t tag0 = (h << 17) ^ (static_cast<uint64_t>(lo) << 1u);
if (tag0 == 0) {
tag0 = 2;
view_class* const view = dComIfGd_getView();
if (view == nullptr) {
return;
}
std::memcpy(&s_presentation_view_backup, view, sizeof(view_class));
interp_view(view);
// FRAME INTERP TODO: Largely copied from d_camera's camera_draw function from this point, got any better ideas?
C_MTXPerspective(view->projMtx, view->fovy, view->aspect, view->near_, view->far_);
mDoMtx_lookAt(view->viewMtx, &view->lookat.eye, &view->lookat.center, &view->lookat.up, view->bank);
#if WIDESCREEN_SUPPORT
mDoGph_gInf_c::setWideZoomProjection(view->projMtx);
#endif
j3dSys.setViewMtx(view->viewMtx);
cMtx_inverse(view->viewMtx, view->invViewMtx);
bool camera_attention_status = dComIfGp_getCameraAttentionStatus(0) & 0x80;
Z2GetAudience()->setAudioCamera(view->viewMtx, view->lookat.eye, view->lookat.center, view->fovy, view->aspect, camera_attention_status, 0, false);
dBgS_GndChk gndchk;
gndchk.OnWaterGrp();
gndchk.SetPos(&view->lookat.eye);
f32 cross = dComIfG_Bgsp().GroundCross(&gndchk);
if (cross != -G_CM3D_F_INF) {
if (dComIfG_Bgsp().ChkGrpInf(gndchk, 0x100)) {
mDoAud_getCameraMapInfo(6);
} else {
mDoAud_getCameraMapInfo(dComIfG_Bgsp().GetMtrlSndId(gndchk));
}
mDoAud_setCameraGroupInfo(dComIfG_Bgsp().GetGrpSoundId(gndchk));
Vec spDC;
spDC.x = view->lookat.eye.x;
spDC.y = cross;
spDC.z = view->lookat.eye.z;
Z2AudioMgr::getInterface()->setCameraPolygonPos(&spDC);
} else {
Z2AudioMgr::getInterface()->setCameraPolygonPos(nullptr);
}
MTXCopy(view->viewMtx, view->viewMtxNoTrans);
view->viewMtxNoTrans[0][3] = 0.0f;
view->viewMtxNoTrans[1][3] = 0.0f;
view->viewMtxNoTrans[2][3] = 0.0f;
cMtx_concatProjView(view->projMtx, view->viewMtx, view->projViewMtx);
f32 far_;
f32 var_f30;
if (dComIfGp_getCameraAttentionStatus(0) & 8) {
far_ = view->far_;
} else {
#if DEBUG
if (g_envHIO.mOther.mAdjustCullFar != 0) {
var_f30 = g_envHIO.mOther.mCullFarValue;
} else
#endif
{
var_f30 = dStage_stagInfo_GetCullPoint(dComIfGp_getStageStagInfo());
}
far_ = var_f30;
}
mDoLib_clipper::setup(view->fovy, view->aspect, view->near_, far_);
// FRAME INTERP NOTE: Removed the call to offWideZoom that was here, it causes problems with presentation during cutscenes.
s_presentation_depth = 1;
run_interpolation_callbacks();
}
void end_presentation_camera() {
if (s_presentation_depth == 0) {
return;
}
s_presentation_depth--;
if (s_presentation_depth > 0) {
return;
}
view_class* const view = dComIfGd_getView();
if (view != nullptr) {
std::memcpy(view, &s_presentation_view_backup, sizeof(view_class));
}
return tag0;
}
} // namespace dusk::frame_interp
+103
View File
@@ -0,0 +1,103 @@
#include "dusk/game_clock.h"
#include <algorithm>
#include <chrono>
#include <cmath>
#include <unordered_map>
namespace dusk::game_clock {
using clock = std::chrono::steady_clock;
bool s_initialized = false;
clock::time_point s_previous_sample{};
clock::time_point s_current_snapshot_time{};
std::unordered_map<uintptr_t, clock::time_point> s_interval_last_sample;
constexpr clock::duration kSimPeriodDuration =
std::chrono::duration_cast<clock::duration>(std::chrono::duration<float>(sim_pace()));
constexpr clock::duration kAbnormalGapResetThreshold = std::chrono::milliseconds(250);
constexpr int kMaxSimTicksPerFrame = 2;
void ensure_initialized() {
if (s_initialized) {
return;
}
s_previous_sample = clock::now();
s_current_snapshot_time = s_previous_sample;
s_initialized = true;
}
void reset_frame_timer() {
s_previous_sample = clock::now();
s_current_snapshot_time = s_previous_sample - kSimPeriodDuration;
}
MainLoopPacer advance_main_loop() {
ensure_initialized();
const clock::time_point now = clock::now();
const clock::duration frame_gap = now - s_previous_sample;
const float presentation_dt = std::chrono::duration<float>(frame_gap).count();
s_previous_sample = now;
MainLoopPacer out{};
out.presentation_dt_seconds = presentation_dt;
const bool should_interpolate = dusk::getSettings().game.enableFrameInterpolation &&
!dusk::getTransientSettings().skipFrameRateLimit;
out.is_interpolating = should_interpolate;
out.sim_pace = sim_pace();
if (!should_interpolate) {
s_current_snapshot_time = now;
out.sim_ticks_to_run = 1;
return out;
}
if (frame_gap > kAbnormalGapResetThreshold) {
s_current_snapshot_time = now - kSimPeriodDuration;
out.sim_ticks_to_run = 0;
return out;
}
int sim_ticks_to_run = 0;
clock::time_point projected_snapshot_time = s_current_snapshot_time;
const clock::time_point render_time = now - kSimPeriodDuration;
while (sim_ticks_to_run < kMaxSimTicksPerFrame && projected_snapshot_time < render_time) {
projected_snapshot_time += kSimPeriodDuration;
sim_ticks_to_run++;
}
out.sim_ticks_to_run = sim_ticks_to_run;
return out;
}
void commit_sim_tick() {
ensure_initialized();
s_current_snapshot_time += kSimPeriodDuration;
}
float sample_interpolation_step() {
ensure_initialized();
const float step =
std::chrono::duration<float>(clock::now() - s_current_snapshot_time).count() / sim_pace();
return std::clamp(step, 0.0f, 1.0f);
}
float consume_interval(const void* consumer) {
ensure_initialized();
const uintptr_t key = reinterpret_cast<uintptr_t>(consumer);
const clock::time_point now = clock::now();
float dt = ui_initial_dt();
const auto it = s_interval_last_sample.find(key);
if (it != s_interval_last_sample.end()) {
dt = std::chrono::duration<float>(now - it->second).count();
dt = std::min(dt, ui_maximum_dt());
}
s_interval_last_sample[key] = now;
return dt;
}
} // namespace dusk::game_clock
+123
View File
@@ -0,0 +1,123 @@
#include "dusk/gyro.h"
#include "d/actor/d_a_alink.h"
namespace dusk::gyro {
namespace {
constexpr s32 kRollgoalTableMaxOffset = 6500;
constexpr float kGyroEmaAlphaMin = 0.05f;
constexpr float kGyroEmaAlphaMax = 1.0f;
bool s_sensor_enabled = false;
float s_smooth_gx = 0.0f;
float s_smooth_gy = 0.0f;
float s_smooth_gz = 0.0f;
float s_yaw_rad = 0.0f;
float s_pitch_rad = 0.0f;
float s_roll_rad = 0.0f;
s32 s_rollgoal_ax = 0;
s32 s_rollgoal_az = 0;
void reset_filter_state() {
s_smooth_gx = s_smooth_gy = s_smooth_gz = 0.0f;
s_yaw_rad = s_pitch_rad = s_roll_rad = 0.0f;
s_rollgoal_ax = s_rollgoal_az = 0;
}
float apply_deadband(float v, float deadband_rad_s) {
if (v > -deadband_rad_s && v < deadband_rad_s) {
return 0.0f;
}
return v;
}
} // namespace
bool s_sensor_keep_alive = false;
bool get_sensor_keep_alive() { return s_sensor_keep_alive; }
void set_sensor_keep_alive(bool value) { s_sensor_keep_alive = value; }
bool queryGyroAimContext() {
if (!static_cast<bool>(dusk::getSettings().game.enableGyroAim)) {
return false;
}
daAlink_c* link = daAlink_getAlinkActorClass();
if (link == nullptr) {
return false;
}
return link->checkGyroAimContext() && dComIfGp_checkCameraAttentionStatus(link->field_0x317c, 0x10);
}
void read(float dt) {
if (!s_sensor_keep_alive && !queryGyroAimContext()) {
if (s_sensor_enabled) {
PADSetSensorEnabled(PAD_CHAN0, PAD_SENSOR_GYRO, FALSE);
s_sensor_enabled = false;
}
reset_filter_state();
return;
}
if (!s_sensor_enabled) {
if (!PADHasSensor(PAD_CHAN0, PAD_SENSOR_GYRO)) {
return;
}
if (!PADSetSensorEnabled(PAD_CHAN0, PAD_SENSOR_GYRO, TRUE)) {
return;
}
s_sensor_enabled = true;
}
f32 gyro[3];
if (!PADGetSensorData(PAD_CHAN0, PAD_SENSOR_GYRO, gyro, 3)) {
return;
}
const float smooth_alpha = kGyroEmaAlphaMax + dusk::getSettings().game.gyroSmoothing * (kGyroEmaAlphaMin - kGyroEmaAlphaMax);
const float deadband = dusk::getSettings().game.gyroDeadband;
s_smooth_gx += smooth_alpha * (gyro[0] - s_smooth_gx);
s_smooth_gy += smooth_alpha * (gyro[1] - s_smooth_gy);
s_smooth_gz += smooth_alpha * (gyro[2] - s_smooth_gz);
s_pitch_rad = -apply_deadband(s_smooth_gx, deadband) * dt * dusk::getSettings().game.gyroSensitivityX;
s_yaw_rad = apply_deadband(s_smooth_gy, deadband) * dt * dusk::getSettings().game.gyroSensitivityY;
s_roll_rad = apply_deadband(s_smooth_gz, deadband) * dt * dusk::getSettings().game.gyroSensitivityX; // GYRO NOTE: Exposing Z sensitivity seems unusual, so I'm just using X
s_pitch_rad = dusk::getSettings().game.gyroInvertPitch ? -s_pitch_rad : s_pitch_rad;
s_yaw_rad = dusk::getSettings().game.gyroInvertYaw ? -s_yaw_rad : s_yaw_rad;
s_yaw_rad = dusk::getSettings().game.enableMirrorMode ? -s_yaw_rad : s_yaw_rad;
}
void getAimDeltas(float& out_yaw, float& out_pitch) {
out_yaw = s_yaw_rad;
out_pitch = s_pitch_rad;
}
void rollgoalTick(bool play_active, s16 camera_yaw) {
if (!play_active) {
reset_filter_state();
return;
}
float pitch_rad = -s_pitch_rad * dusk::getSettings().game.gyroSensitivityRollgoal;
float roll_rad = s_roll_rad * dusk::getSettings().game.gyroSensitivityRollgoal;
roll_rad = dusk::getSettings().game.enableMirrorMode ? -roll_rad : roll_rad;
s_rollgoal_az += cM_rad2s(roll_rad);
cXyz in(roll_rad, 0.0f, pitch_rad);
cXyz out;
cMtx_YrotS(*calc_mtx, -camera_yaw);
MtxPosition(&in, &out);
s_rollgoal_ax += cM_rad2s(out.z);
s_rollgoal_az += cM_rad2s(out.x);
s_rollgoal_ax = std::clamp(s_rollgoal_ax, -kRollgoalTableMaxOffset, kRollgoalTableMaxOffset);
s_rollgoal_az = std::clamp(s_rollgoal_az, -kRollgoalTableMaxOffset, kRollgoalTableMaxOffset);
}
void rollgoalTableOffset(s16& out_ax, s16& out_az) {
out_ax = static_cast<s16>(s_rollgoal_ax);
out_az = static_cast<s16>(s_rollgoal_az);
}
} // namespace dusk::gyro
-87
View File
@@ -1,87 +0,0 @@
#include "dusk/gyro_aim.h"
#include <SDL3/SDL.h>
#include "d/actor/d_a_alink.h"
namespace dusk::gyro_aim {
namespace {
// TODO: Make deadband and smoothing configurable
constexpr float kDeadbandRadS = 0.04f;
constexpr float kSmoothAlpha = 0.35f;
bool s_sensor_enabled = false;
float s_smooth_gx = 0.0f;
float s_smooth_gy = 0.0f;
float s_pending_yaw_rad = 0.0f;
float s_pending_pitch_rad = 0.0f;
void reset_filter_state() {
s_smooth_gx = s_smooth_gy = 0.0f;
s_pending_yaw_rad = s_pending_pitch_rad = 0.0f;
}
float apply_deadband(float v) {
if (v > -kDeadbandRadS && v < kDeadbandRadS) {
return 0.0f;
}
return v;
}
} // namespace
void read(float dt, bool context_active) {
if (!context_active || !static_cast<bool>(dusk::getSettings().game.enableGyroAim)) {
SDL_Gamepad* pad = SDL_GetGamepadFromPlayerIndex(0);
if (pad != nullptr && s_sensor_enabled) {
SDL_SetGamepadSensorEnabled(pad, SDL_SENSOR_GYRO, false);
s_sensor_enabled = false;
}
reset_filter_state();
return;
}
SDL_Gamepad* pad = SDL_GetGamepadFromPlayerIndex(0);
if (pad == nullptr || !SDL_GamepadHasSensor(pad, SDL_SENSOR_GYRO)) {
return;
}
if (!s_sensor_enabled) {
if (!SDL_SetGamepadSensorEnabled(pad, SDL_SENSOR_GYRO, true)) {
return;
}
s_sensor_enabled = true;
reset_filter_state();
}
float gyro[3];
if (!SDL_GetGamepadSensorData(pad, SDL_SENSOR_GYRO, gyro, 3)) {
return;
}
s_smooth_gx += kSmoothAlpha * (gyro[0] - s_smooth_gx);
s_smooth_gy += kSmoothAlpha * (gyro[1] - s_smooth_gy);
float yaw_rate = apply_deadband(s_smooth_gy);
float pitch_rate = apply_deadband(s_smooth_gx);
s_pending_yaw_rad += yaw_rate * dt * dusk::getSettings().game.gyroAimSensitivityX;
s_pending_pitch_rad += pitch_rate * dt * dusk::getSettings().game.gyroAimSensitivityY;
}
void consumeAimDeltas(float& out_yaw_rad, float& out_pitch_rad) {
out_yaw_rad = s_pending_yaw_rad;
out_pitch_rad = s_pending_pitch_rad;
s_pending_yaw_rad = 0.0f;
s_pending_pitch_rad = 0.0f;
}
bool queryGyroAimItemContext() {
if (!static_cast<bool>(dusk::getSettings().game.enableGyroAim)) {
return false;
}
daAlink_c* link = daAlink_getAlinkActorClass();
if (link == nullptr) {
return false;
}
return link->checkGyroAimItemContext() && dComIfGp_checkCameraAttentionStatus(link->field_0x317c, 0x10);
}
} // namespace dusk::gyro_aim
+126
View File
@@ -0,0 +1,126 @@
#include <algorithm>
#include "imgui.h"
#include "ImGuiBloomWindow.hpp"
#include "ImGuiMenuTools.hpp"
#include "m_Do/m_Do_graphic.h"
namespace dusk {
namespace {
struct BloomOverride {
bool enabled = false;
bool bloomEnabled = true;
int mode = 0;
int point = 128;
int blureSize = 64;
int blureRatio = 128;
GXColor blendColor = {255, 255, 255, 255};
GXColor monoColor = {0, 0, 0, 0};
};
BloomOverride s_bloomOverride;
void SyncFromCurrentBloom() {
mDoGph_gInf_c::bloom_c* bloom = mDoGph_gInf_c::getBloom();
s_bloomOverride.bloomEnabled = bloom->getEnable() != 0;
s_bloomOverride.mode = bloom->mMode;
s_bloomOverride.point = bloom->getPoint();
s_bloomOverride.blureSize = bloom->getBlureSize();
s_bloomOverride.blureRatio = bloom->getBlureRatio();
s_bloomOverride.blendColor = *bloom->getBlendColor();
s_bloomOverride.monoColor = *bloom->getMonoColor();
}
u8 ClampToByte(int value) {
return static_cast<u8>(std::clamp(value, 0, 255));
}
void DrawColorEdit(const char* label, GXColor& color) {
float colorValue[4] = {
color.r / 255.0f,
color.g / 255.0f,
color.b / 255.0f,
color.a / 255.0f,
};
if (ImGui::ColorEdit4(label, colorValue, ImGuiColorEditFlags_Uint8)) {
color.r = ClampToByte(static_cast<int>(colorValue[0] * 255.0f + 0.5f));
color.g = ClampToByte(static_cast<int>(colorValue[1] * 255.0f + 0.5f));
color.b = ClampToByte(static_cast<int>(colorValue[2] * 255.0f + 0.5f));
color.a = ClampToByte(static_cast<int>(colorValue[3] * 255.0f + 0.5f));
}
}
} // namespace
void ApplyBloomOverride() {
if (!s_bloomOverride.enabled) {
return;
}
mDoGph_gInf_c::bloom_c* bloom = mDoGph_gInf_c::getBloom();
bloom->setEnable(s_bloomOverride.bloomEnabled ? 1 : 0);
bloom->setMode(static_cast<u8>(std::clamp(s_bloomOverride.mode, 0, 1)));
bloom->setPoint(ClampToByte(s_bloomOverride.point));
bloom->setBlureSize(ClampToByte(s_bloomOverride.blureSize));
bloom->setBlureRatio(ClampToByte(s_bloomOverride.blureRatio));
bloom->setBlendColor(s_bloomOverride.blendColor);
bloom->setMonoColor(s_bloomOverride.monoColor);
}
void DrawBloomWindow(bool& open) {
if (!open) {
return;
}
if (!ImGui::Begin("Bloom", &open)) {
ImGui::End();
return;
}
bool copyCurrent = false;
if (ImGui::Checkbox("Override", &s_bloomOverride.enabled) && s_bloomOverride.enabled) {
copyCurrent = true;
}
ImGui::SameLine();
if (ImGui::Button("Sync with current")) {
copyCurrent = true;
}
if (copyCurrent) {
SyncFromCurrentBloom();
}
ImGui::SeparatorText("Values");
ImGui::Checkbox("Enabled", &s_bloomOverride.bloomEnabled);
ImGui::SliderInt("Mode", &s_bloomOverride.mode, 0, 1);
ImGui::SliderInt("Threshold", &s_bloomOverride.point, 0, 255);
ImGui::SliderInt("Blur Size", &s_bloomOverride.blureSize, 0, 255);
ImGui::SliderInt("Blur Ratio", &s_bloomOverride.blureRatio, 0, 255);
DrawColorEdit("Blend Color", s_bloomOverride.blendColor);
DrawColorEdit("Mono Color", s_bloomOverride.monoColor);
ApplyBloomOverride();
ImGui::SeparatorText("Current");
mDoGph_gInf_c::bloom_c* bloom = mDoGph_gInf_c::getBloom();
GXColor blendColor = *bloom->getBlendColor();
GXColor monoColor = *bloom->getMonoColor();
ImGui::Text("Enabled: %d", bloom->getEnable());
ImGui::Text("Mode: %d", bloom->mMode);
ImGui::Text("Threshold: %u", static_cast<unsigned>(bloom->getPoint()));
ImGui::Text("Blur Size: %u", static_cast<unsigned>(bloom->getBlureSize()));
ImGui::Text("Blur Ratio: %u", static_cast<unsigned>(bloom->getBlureRatio()));
ImGui::Text("Blend RGBA: %u, %u, %u, %u", static_cast<unsigned>(blendColor.r),
static_cast<unsigned>(blendColor.g), static_cast<unsigned>(blendColor.b),
static_cast<unsigned>(blendColor.a));
ImGui::Text("Mono RGBA: %u, %u, %u, %u", static_cast<unsigned>(monoColor.r),
static_cast<unsigned>(monoColor.g), static_cast<unsigned>(monoColor.b),
static_cast<unsigned>(monoColor.a));
ImGui::End();
}
void ImGuiMenuTools::ShowBloomWindow() {
DrawBloomWindow(m_showBloomWindow);
}
} // namespace dusk
+6
View File
@@ -0,0 +1,6 @@
#pragma once
namespace dusk {
void DrawBloomWindow(bool& open);
void ApplyBloomOverride();
} // namespace dusk

Some files were not shown because too many files have changed in this diff Show More