From 22ee9538a258792665c8401911aac84d88370ac1 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Sun, 5 Apr 2026 01:31:02 +0200 Subject: [PATCH] vsync, integer scale --- data/locale/ca.yaml | 2 ++ source/core/rendering/menu.cpp | 8 ++++++++ source/core/rendering/screen.cpp | 8 ++++++++ source/core/rendering/screen.hpp | 1 + source/game/defaults.hpp | 1 + source/game/options.cpp | 3 +++ source/game/options.hpp | 1 + 7 files changed, 24 insertions(+) diff --git a/data/locale/ca.yaml b/data/locale/ca.yaml index 60bb41f..7b959b1 100644 --- a/data/locale/ca.yaml +++ b/data/locale/ca.yaml @@ -18,6 +18,8 @@ menu: shader: "SHADER" aspect_4_3: "ASPECTE 4:3" supersampling: "SUPERSAMPLING" + vsync: "VSYNC" + integer_scale: "ESCALA ENTERA" shader_type: "TIPUS SHADER" preset: "PRESET" stretch_filter: "FILTRE 4:3" diff --git a/source/core/rendering/menu.cpp b/source/core/rendering/menu.cpp index 445401d..847812b 100644 --- a/source/core/rendering/menu.cpp +++ b/source/core/rendering/menu.cpp @@ -136,6 +136,14 @@ namespace Menu { [] { return onOff(Options::video.supersampling); }, [](int) { Screen::get()->toggleSupersampling(); }, nullptr}); + p.items.push_back({Locale::get("menu.items.vsync"), ItemKind::Toggle, + [] { return onOff(Options::video.vsync); }, + [](int) { Screen::get()->toggleVSync(); }, nullptr}); + + p.items.push_back({Locale::get("menu.items.integer_scale"), ItemKind::Toggle, + [] { return onOff(Options::video.integer_scale); }, + [](int) { Screen::get()->toggleIntegerScale(); }, nullptr}); + p.items.push_back({Locale::get("menu.items.shader_type"), ItemKind::Cycle, [] { return std::string(Screen::get()->getActiveShaderName()); }, [](int dir) { if (dir < 0) Screen::get()->prevShaderType(); diff --git a/source/core/rendering/screen.cpp b/source/core/rendering/screen.cpp index d55696b..5860aae 100644 --- a/source/core/rendering/screen.cpp +++ b/source/core/rendering/screen.cpp @@ -88,6 +88,7 @@ void Screen::initShaders() { // Aplica opcions de vídeo shader_backend_->setScaleMode(Options::video.integer_scale); + shader_backend_->setVSync(Options::video.vsync); shader_backend_->setStretchFilter(Options::video.stretch_filter_linear); shader_backend_->setStretch4_3(Options::video.aspect_ratio_4_3); shader_backend_->setLinearUpscale(Options::video.linear_upscale); @@ -203,6 +204,13 @@ void Screen::toggleIntegerScale() { } } +void Screen::toggleVSync() { + Options::video.vsync = !Options::video.vsync; + if (shader_backend_) { + shader_backend_->setVSync(Options::video.vsync); + } +} + void Screen::toggleStretchFilter() { Options::video.stretch_filter_linear = !Options::video.stretch_filter_linear; if (shader_backend_) { diff --git a/source/core/rendering/screen.hpp b/source/core/rendering/screen.hpp index a876e2a..9c3a404 100644 --- a/source/core/rendering/screen.hpp +++ b/source/core/rendering/screen.hpp @@ -27,6 +27,7 @@ class Screen { void toggleSupersampling(); void toggleAspectRatio(); void toggleIntegerScale(); + void toggleVSync(); void toggleStretchFilter(); void nextShaderType(); // Cicla PostFX ↔ CrtPi (F7) void prevShaderType(); // Cicla al revés diff --git a/source/game/defaults.hpp b/source/game/defaults.hpp index ce94699..77ee467 100644 --- a/source/game/defaults.hpp +++ b/source/game/defaults.hpp @@ -32,6 +32,7 @@ namespace Defaults::Video { constexpr bool SHADER_ENABLED = false; constexpr bool SUPERSAMPLING = false; constexpr bool INTEGER_SCALE = true; + constexpr bool VSYNC = true; constexpr bool ASPECT_RATIO_4_3 = true; // CRT original estira 200→240 constexpr bool STRETCH_FILTER_LINEAR = false; // Filtre per a l'estirament 4:3 (false=NEAREST) constexpr int DOWNSCALE_ALGO = 1; // 0=bilinear, 1=Lanczos2, 2=Lanczos3 diff --git a/source/game/options.cpp b/source/game/options.cpp index 173369b..ba80b71 100644 --- a/source/game/options.cpp +++ b/source/game/options.cpp @@ -65,6 +65,8 @@ namespace Options { video.supersampling = node["supersampling"].get_value(); if (node.contains("integer_scale")) video.integer_scale = node["integer_scale"].get_value(); + if (node.contains("vsync")) + video.vsync = node["vsync"].get_value(); if (node.contains("aspect_ratio_4_3")) video.aspect_ratio_4_3 = node["aspect_ratio_4_3"].get_value(); if (node.contains("stretch_filter_linear")) @@ -220,6 +222,7 @@ namespace Options { file << " shader_enabled: " << (video.shader_enabled ? "true" : "false") << "\n"; file << " supersampling: " << (video.supersampling ? "true" : "false") << "\n"; file << " integer_scale: " << (video.integer_scale ? "true" : "false") << "\n"; + file << " vsync: " << (video.vsync ? "true" : "false") << "\n"; file << " aspect_ratio_4_3: " << (video.aspect_ratio_4_3 ? "true" : "false") << "\n"; file << " stretch_filter_linear: " << (video.stretch_filter_linear ? "true" : "false") << " # filtre 4:3: false=nearest, true=linear\n"; file << " downscale_algo: " << video.downscale_algo << " # 0=bilinear, 1=Lanczos2, 2=Lanczos3\n"; diff --git a/source/game/options.hpp b/source/game/options.hpp index 6d65576..f291377 100644 --- a/source/game/options.hpp +++ b/source/game/options.hpp @@ -44,6 +44,7 @@ namespace Options { bool shader_enabled{Defaults::Video::SHADER_ENABLED}; bool supersampling{Defaults::Video::SUPERSAMPLING}; bool integer_scale{Defaults::Video::INTEGER_SCALE}; + bool vsync{Defaults::Video::VSYNC}; bool aspect_ratio_4_3{Defaults::Video::ASPECT_RATIO_4_3}; bool stretch_filter_linear{Defaults::Video::STRETCH_FILTER_LINEAR}; int downscale_algo{Defaults::Video::DOWNSCALE_ALGO};