From 6bcf17ea5572e4698987e859c6671fb31bf0362b Mon Sep 17 00:00:00 2001 From: DepressedTWM Date: Sun, 2 Aug 2026 14:50:33 +0400 Subject: [PATCH] Sex Gay --- binding-mri/binding-mri.cpp | 5 ----- binding-mri/graphics-binding.cpp | 11 ++++++++++- scripts/Data_Settings.rb | 23 +++++++++++++++-------- scripts/Main.rb | 1 - scripts/Settings_Setters.rb | 10 ++++++++++ src/eventthread.cpp | 25 +++++++++++++++---------- src/eventthread.h | 3 ++- src/graphics.cpp | 4 ++++ src/graphics.h | 2 ++ 9 files changed, 58 insertions(+), 26 deletions(-) diff --git a/binding-mri/binding-mri.cpp b/binding-mri/binding-mri.cpp index 39bf941..d484746 100644 --- a/binding-mri/binding-mri.cpp +++ b/binding-mri/binding-mri.cpp @@ -582,12 +582,7 @@ static void mriBindingExecute(){ * but not doing it will lead to crashes due to closed * stdio streams on some platforms (eg. Windows) */ int argc = 0; -<<<<<<< HEAD char **argv = 0; -======= - char **argv = nullptr; - //options_argv3[] = "--jit" ->>>>>>> b9cd221a9e6e6586cc4ca23a2b2d315b074f14e7 char options_argv1[] = "oneshot", options_argv2[] = "-ev"; char* options_argv[] = {options_argv1, options_argv2, NULL}; ruby_sysinit(&argc, &argv); diff --git a/binding-mri/graphics-binding.cpp b/binding-mri/graphics-binding.cpp index 581bf97..d816578 100644 --- a/binding-mri/graphics-binding.cpp +++ b/binding-mri/graphics-binding.cpp @@ -133,6 +133,15 @@ RB_METHOD(graphicsWait){ return Qnil; } +RB_METHOD(graphicsSetVsync){ + RB_UNUSED_PARAM; + int xuinia_ebania; + rb_get_args(argc, argv, "i", &xuinia_ebania RB_ARG_END); + shState->graphics().setVsync(xuinia_ebania); + + return Qnil; +} + RB_METHOD(graphicsFadeout){ RB_UNUSED_PARAM; @@ -284,7 +293,7 @@ void graphicsBindingInit(){ _rb_define_module_function(module, "freeze", graphicsFreeze); _rb_define_module_function(module, "transition", graphicsTransition); _rb_define_module_function(module, "frame_reset", graphicsFrameReset); - + _rb_define_module_function(module, "setVsync", graphicsSetVsync); _rb_define_module_function(module, "__reset__", graphicsReset); // Variables diff --git a/scripts/Data_Settings.rb b/scripts/Data_Settings.rb index c8fd5b7..42f8f79 100644 --- a/scripts/Data_Settings.rb +++ b/scripts/Data_Settings.rb @@ -16,6 +16,7 @@ module Settings :twm_shader => true, :light => true, :scaling_mode => 0, + :vsync => 0, # UI :in_game_timer => false, @@ -205,6 +206,12 @@ class Window_Settings :parameter => :scaling_mode, :values => ["Nearest Neighbor", "Smooth(old)"] }, + { + :type => :enum, + :name => "Vsync mode", + :parameter => :vsync, + :values => ["Normal", "Adaptive", "Disabled"] + }, { :type => :sep, :name => "Effects"}, { :type => :bool, @@ -517,37 +524,37 @@ class Window_Settings { :type => :bool, :name => "Show debug character", - :parameter => :debug_character + :parameter => :debug_character, :icon => [1, 0], }, { :type => :bool, :name => "Draw debug text in main menu", - :parameter => :debug_text_scene_title + :parameter => :debug_text_scene_title, :icon => [1, 0], }, { :type => :bool, :name => "Show debug text", - :parameter => :debug_text + :parameter => :debug_text, :icon => [1, 0], }, { :type => :bool, :name => "Show picture names", - :parameter => :debug_picture_names + :parameter => :debug_picture_names, :icon => [1, 0], }, { :type => :bool, :name => "Debug lightmap", - :parameter => :debug_lightmap + :parameter => :debug_lightmap, :icon => [1, 0], }, { :type => :bool, :name => "SDL_HINT_SHUTDOWN_DBUS_ON_QUIT", - :parameter => :SDL_HINT_SHUTDOWN_DBUS_ON_QUIT + :parameter => :SDL_HINT_SHUTDOWN_DBUS_ON_QUIT, :icon => [1, 0], }, { :type => :sep }, @@ -555,14 +562,14 @@ class Window_Settings :type => :key, :name => "Debug", :parameter => :controls_debug, - :bind => Input::DEBUGACTION + :bind => Input::DEBUGACTION, :icon => [1, 0], }, { :type => :sep }, { :type => :action, :name => "Clear image cache", - :action => Proc.new { RPG::Cache.clear } + :action => Proc.new { RPG::Cache.clear }, :icon => [1, 0], } ], diff --git a/scripts/Main.rb b/scripts/Main.rb index 04df541..d35a355 100644 --- a/scripts/Main.rb +++ b/scripts/Main.rb @@ -22,7 +22,6 @@ begin Font.default_size = 20 #debug shit Input.set_led(255, 150, 30) - # Load persistent data Persistent.load diff --git a/scripts/Settings_Setters.rb b/scripts/Settings_Setters.rb index 0cfd10e..ac276e4 100644 --- a/scripts/Settings_Setters.rb +++ b/scripts/Settings_Setters.rb @@ -77,6 +77,16 @@ module Settings end end + def vsync(value) + if value == 0 + Graphics.setVsync(1) + elsif value == 1 + Graphics.setVsync(-1) + else + Graphics.setVsync(0) + end + end + def SDL_HINT_SHUTDOWN_DBUS_ON_QUIT(value) if value Sunshine.setSDLHint("SDL_HINT_SHUTDOWN_DBUS_ON_QUIT", "1") diff --git a/src/eventthread.cpp b/src/eventthread.cpp index 9d1eab8..d170927 100644 --- a/src/eventthread.cpp +++ b/src/eventthread.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include "sharedstate.h" #include "graphics.h" @@ -84,7 +85,8 @@ enum{ REQUEST_WINMOVETO, REQUEST_MESSAGEBOX, REQUEST_SETCURSORVISIBLE, - + REQUEST_VSYNC, + UPDATE_FPS, UPDATE_SCREEN_RECT, @@ -96,15 +98,13 @@ SDL_Gamepad* gc = nullptr; bool EventThread::allocUserEvents(){ usrIdStart = SDL_RegisterEvents(EVENT_COUNT); - // SDL_RegisterEvents() now returns 0 if it couldn't allocate any user events. if (usrIdStart == (uint32_t) 0) return false; return true; } -EventThread::EventThread() - : fullscreen(false), showCursor(true){} +EventThread::EventThread(): fullscreen(false), showCursor(true){} void EventThread::process(RGSSThreadData &rtData){ SDL_Event event; @@ -412,8 +412,10 @@ void EventThread::process(RGSSThreadData &rtData){ default : /* Handle user events */ - switch(event.type - usrIdStart) - { + switch(event.type - usrIdStart){ + case REQUEST_VSYNC: + SDL_GL_SetSwapInterval(event.user.code); + break; case REQUEST_SETFULLSCREEN : setFullscreen(win, static_cast(event.user.code)); break; @@ -511,10 +513,6 @@ bool EventThread::eventFilter(void *data, SDL_Event *event){ Debug() << "SDL_EVENT_TERMINATING"; return 0; - case SDL_EVENT_LOW_MEMORY : - Debug() << "SDL_EVENT_LOW_MEMORY"; - return 0; - /* Workaround for Windows pausing on drag */ default: if (event->window.type == SDL_EVENT_WINDOW_MOVED){ @@ -579,6 +577,13 @@ void EventThread::requestFullscreenMode(bool mode){ SDL_PushEvent(&event); } +void EventThread::requestVsync(int interval){ + SDL_Event event; + event.type = usrIdStart + REQUEST_VSYNC; + event.user.code = interval; + SDL_PushEvent(&event); +} + void EventThread::requestWindowMove(int x, int y){ SDL_Event event; event.type = usrIdStart + REQUEST_WINMOVETO; diff --git a/src/eventthread.h b/src/eventthread.h index 33cc36e..ae3d54c 100644 --- a/src/eventthread.h +++ b/src/eventthread.h @@ -96,7 +96,8 @@ public: void requestWindowMove(int x, int y); void requestWindowResize(int width, int height); void requestShowCursor(bool mode); - + void requestVsync(int interval); + void requestTerminate(); Vec2i getWindowPosition() const; diff --git a/src/graphics.cpp b/src/graphics.cpp index 473f7d3..4508175 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -958,6 +958,10 @@ void Graphics::setFullscreen(bool value){ p->threadData->ethread->requestFullscreenMode(value); } +void Graphics::setVsync(int value){ + p->threadData->ethread->requestVsync(value); +} + bool Graphics::getSmooth() const{ return p->threadData->config.smoothScaling; } diff --git a/src/graphics.h b/src/graphics.h index 2e18885..aa99402 100644 --- a/src/graphics.h +++ b/src/graphics.h @@ -58,6 +58,8 @@ public: void reset(); + void setVsync(int value); + /* Non-standard extension */ DECL_ATTR( Fullscreen, bool ) DECL_ATTR( ShowCursor, bool )