mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-07-05 03:29:45 -04:00
Merge remote-tracking branch 'refs/remotes/origin/main' into unhackify-widescreen
# Conflicts: # src/m_Do/m_Do_main.cpp
This commit is contained in:
+25
-89
@@ -471,72 +471,32 @@ void darwFilter(GXColor matColor) {
|
||||
GXEnd();
|
||||
}
|
||||
|
||||
#ifdef TARGET_PC
|
||||
static void mDoGph_AdvanceFadeState() {
|
||||
if (mDoGph_gInf_c::isFade() != 0) {
|
||||
f32 fade_rate = mDoGph_gInf_c::getFadeRate() + mDoGph_gInf_c::getFadeSpeed();
|
||||
|
||||
if (fade_rate < 0.0f) {
|
||||
fade_rate = 0.0f;
|
||||
mDoGph_gInf_c::offFade();
|
||||
} else if (fade_rate > 1.0f) {
|
||||
fade_rate = 1.0f;
|
||||
}
|
||||
|
||||
mDoGph_gInf_c::setFadeRate(fade_rate);
|
||||
mDoGph_gInf_c::getFadeColor().a = 255.0f * fade_rate;
|
||||
} else {
|
||||
GXColor& fade_color = mDoGph_gInf_c::getFadeColor();
|
||||
if (dComIfG_getBrightness() != 255) {
|
||||
fade_color.r = 0;
|
||||
fade_color.g = 0;
|
||||
fade_color.b = 0;
|
||||
fade_color.a = 255 - dComIfG_getBrightness();
|
||||
} else {
|
||||
fade_color.a = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void mDoGph_AdvanceFadeState(u32 tick_count) {
|
||||
for (u32 i = 0; i < tick_count; ++i) {
|
||||
mDoGph_AdvanceFadeState();
|
||||
}
|
||||
}
|
||||
|
||||
static void mDoGph_DrawStoredFade() {
|
||||
GXColor& fade_color = mDoGph_gInf_c::getFadeColor();
|
||||
if (fade_color.a != 0) {
|
||||
darwFilter(fade_color);
|
||||
}
|
||||
}
|
||||
|
||||
void mDoGph_gInf_c::calcFade() {
|
||||
mDoGph_AdvanceFadeState();
|
||||
mDoGph_DrawStoredFade();
|
||||
}
|
||||
#else
|
||||
void mDoGph_gInf_c::calcFade() {
|
||||
if (mDoGph_gInf_c::mFade != 0) {
|
||||
mFadeRate += mFadeSpeed;
|
||||
#if TARGET_PC
|
||||
if (dusk::frame_interp::get_ui_tick_pending())
|
||||
#endif
|
||||
{
|
||||
if (mFade != 0) {
|
||||
mFadeRate += mFadeSpeed;
|
||||
|
||||
if (mFadeRate < 0.0f) {
|
||||
mFadeRate = 0.0f;
|
||||
mDoGph_gInf_c::mFade = 0;
|
||||
} else {
|
||||
if (mFadeRate > 1.0f) {
|
||||
mFadeRate = 1.0f;
|
||||
if (mFadeRate < 0.0f) {
|
||||
mFadeRate = 0.0f;
|
||||
mFade = 0;
|
||||
} else {
|
||||
if (mFadeRate > 1.0f) {
|
||||
mFadeRate = 1.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
mFadeColor.a = 255.0f * mFadeRate;
|
||||
} else {
|
||||
if (dComIfG_getBrightness() != 255) {
|
||||
mFadeColor.r = 0;
|
||||
mFadeColor.g = 0;
|
||||
mFadeColor.b = 0;
|
||||
mFadeColor.a = 255 - dComIfG_getBrightness();
|
||||
mFadeColor.a = 255.0f * mFadeRate;
|
||||
} else {
|
||||
mFadeColor.a = 0;
|
||||
if (dComIfG_getBrightness() != 255) {
|
||||
mFadeColor.r = 0;
|
||||
mFadeColor.g = 0;
|
||||
mFadeColor.b = 0;
|
||||
mFadeColor.a = 255 - dComIfG_getBrightness();
|
||||
} else {
|
||||
mFadeColor.a = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -544,7 +504,6 @@ void mDoGph_gInf_c::calcFade() {
|
||||
darwFilter(mFadeColor);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if PLATFORM_WII || PLATFORM_SHIELD
|
||||
u32 mDoGph_gInf_c::csr_c::m_blurID;
|
||||
@@ -944,9 +903,6 @@ int mDoGph_AfterOfDraw() {
|
||||
|
||||
JUTVideo::getManager()->setRenderMode(mDoMch_render_c::getRenderModeObj());
|
||||
mDoGph_gInf_c::endFrame();
|
||||
#ifdef TARGET_PC
|
||||
dusk::frame_interp::notify_sim_tick_complete();
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -2099,8 +2055,6 @@ int mDoGph_Painter() {
|
||||
|
||||
#if TARGET_PC
|
||||
dusk::g_imguiConsole.PreDraw();
|
||||
|
||||
const u32 pending_ui_ticks = dusk::frame_interp::begin_presentation_ui_pass();
|
||||
#endif
|
||||
|
||||
#if DEBUG
|
||||
@@ -2108,7 +2062,7 @@ int mDoGph_Painter() {
|
||||
#endif
|
||||
|
||||
#ifdef TARGET_PC
|
||||
for (u32 i = 0; i < pending_ui_ticks; ++i)
|
||||
if (dusk::frame_interp::get_ui_tick_pending())
|
||||
#endif
|
||||
{
|
||||
dComIfGp_particle_calcMenu();
|
||||
@@ -2193,7 +2147,7 @@ int mDoGph_Painter() {
|
||||
view_port->height);
|
||||
|
||||
#ifdef TARGET_PC
|
||||
// Frame interpolation: Call setViewMtx earlier so that it's interpolated in time for draw_info to use it
|
||||
// FRAME INTERP NOTE: Call setViewMtx earlier so that it's interpolated in time for draw_info to use it
|
||||
j3dSys.setViewMtx(camera_p->view.viewMtx);
|
||||
JPADrawInfo draw_info(j3dSys.getViewMtx(), camera_p->view.fovy, camera_p->view.aspect);
|
||||
#else
|
||||
@@ -2590,12 +2544,7 @@ int mDoGph_Painter() {
|
||||
if (strcmp(dComIfGp_getStartStageName(), "F_SP127") != 0 &&
|
||||
(mDoGph_gInf_c::isFade() & 0x80) == 0)
|
||||
{
|
||||
#ifdef TARGET_PC
|
||||
mDoGph_AdvanceFadeState(pending_ui_ticks);
|
||||
mDoGph_DrawStoredFade();
|
||||
#else
|
||||
mDoGph_gInf_c::calcFade();
|
||||
#endif
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
@@ -2661,7 +2610,7 @@ int mDoGph_Painter() {
|
||||
|
||||
GXSetClipMode(GX_CLIP_ENABLE);
|
||||
#if TARGET_PC
|
||||
for (u32 i = 0; i < pending_ui_ticks; ++i)
|
||||
if (dusk::frame_interp::get_ui_tick_pending())
|
||||
#endif
|
||||
{
|
||||
dDlst_list_c::calcWipe();
|
||||
@@ -2715,12 +2664,7 @@ int mDoGph_Painter() {
|
||||
|
||||
if (strcmp(dComIfGp_getStartStageName(), "F_SP127") == 0 || (mDoGph_gInf_c::isFade() & 0x80) != 0)
|
||||
{
|
||||
#ifdef TARGET_PC
|
||||
mDoGph_AdvanceFadeState(pending_ui_ticks);
|
||||
mDoGph_DrawStoredFade();
|
||||
#else
|
||||
mDoGph_gInf_c::calcFade();
|
||||
#endif
|
||||
}
|
||||
|
||||
GX_DEBUG_GROUP(dComIfGp_particle_draw2DmenuFore, &draw_info3);
|
||||
@@ -2753,18 +2697,10 @@ int mDoGph_Painter() {
|
||||
|
||||
#if TARGET_PC
|
||||
dusk::g_imguiConsole.PostDraw();
|
||||
|
||||
if (dusk::getSettings().game.enableFrameInterpolation) {
|
||||
JFWDisplay::getManager()->setFaderSimSteps(pending_ui_ticks);
|
||||
}
|
||||
#endif
|
||||
|
||||
mDoGph_gInf_c::endRender();
|
||||
|
||||
#ifdef TARGET_PC
|
||||
dusk::frame_interp::end_presentation_ui_pass();
|
||||
#endif
|
||||
|
||||
#if WIDESCREEN_SUPPORT
|
||||
mDoGph_gInf_c::offWideZoom();
|
||||
#endif
|
||||
|
||||
+13
-17
@@ -42,7 +42,6 @@
|
||||
#include "SSystem/SComponent/c_counter.h"
|
||||
#include <cstring>
|
||||
|
||||
#include <chrono>
|
||||
#include <filesystem>
|
||||
#include <system_error>
|
||||
#include <thread>
|
||||
@@ -51,6 +50,7 @@
|
||||
#include "dusk/crash_reporting.h"
|
||||
#include "dusk/dusk.h"
|
||||
#include "dusk/frame_interpolation.h"
|
||||
#include "dusk/game_clock.h"
|
||||
#include "dusk/gyro.h"
|
||||
#include "dusk/imgui/ImGuiEngine.hpp"
|
||||
#include "dusk/logging.h"
|
||||
@@ -197,9 +197,7 @@ void main01(void) {
|
||||
|
||||
OSReport("Entering Main Loop (main01)...\n");
|
||||
|
||||
constexpr float kSimStepSeconds = 1.0 / 30.0;
|
||||
auto previous_time = std::chrono::steady_clock::now();
|
||||
float accumulator = kSimStepSeconds;
|
||||
dusk::game_clock::ensure_initialized();
|
||||
|
||||
do {
|
||||
// 1. Update Window Events
|
||||
@@ -223,10 +221,7 @@ void main01(void) {
|
||||
|
||||
eventsDone:;
|
||||
|
||||
auto current_time = std::chrono::steady_clock::now();
|
||||
float frame_seconds = std::chrono::duration<float>(current_time - previous_time).count();
|
||||
previous_time = current_time;
|
||||
accumulator += frame_seconds;
|
||||
const dusk::game_clock::MainLoopPacer pacing = dusk::game_clock::advance_main_loop();
|
||||
|
||||
VIWaitForRetrace();
|
||||
|
||||
@@ -238,26 +233,27 @@ void main01(void) {
|
||||
|
||||
mDoGph_gInf_c::updateRenderSize();
|
||||
|
||||
if (dusk::getSettings().game.enableFrameInterpolation && !dusk::getTransientSettings().skipFrameRateLimit) {
|
||||
dusk::frame_interp::notify_presentation_frame();
|
||||
if (accumulator >= kSimStepSeconds) {
|
||||
if (pacing.is_interpolating) {
|
||||
if (pacing.do_sim_tick) {
|
||||
dusk::frame_interp::set_ui_tick_pending(true);
|
||||
mDoCPd_c::read();
|
||||
dusk::gyro::read(kSimStepSeconds);
|
||||
dusk::gyro::read(pacing.sim_pace);
|
||||
fapGm_Execute();
|
||||
mDoAud_Execute();
|
||||
accumulator = 0.0f;
|
||||
dusk::game_clock::reset_accumulator();
|
||||
}
|
||||
dusk::frame_interp::interpolate(static_cast<float>(accumulator / kSimStepSeconds));
|
||||
dusk::frame_interp::interpolate(pacing.interpolation_step);
|
||||
{
|
||||
dusk::frame_interp::PresentationCameraScope presentation_camera;
|
||||
cAPIGph_Painter();
|
||||
}
|
||||
dusk::frame_interp::set_ui_tick_pending(false);
|
||||
} else {
|
||||
accumulator = 0.0f;
|
||||
|
||||
dusk::frame_interp::set_ui_tick_pending(true);
|
||||
|
||||
// Game Inputs
|
||||
mDoCPd_c::read();
|
||||
dusk::gyro::read(frame_seconds);
|
||||
dusk::gyro::read(pacing.presentation_dt_seconds);
|
||||
|
||||
// EXECUTE GAME LOGIC & RENDER
|
||||
// This calls mDoGph_Painter -> JFWDisplay -> GX Functions
|
||||
|
||||
Reference in New Issue
Block a user