From 05dd698578e16f702c069f0b2cd80d98494af64b Mon Sep 17 00:00:00 2001 From: Mathieu Schroeter Date: Thu, 28 Jun 2018 23:54:30 +0200 Subject: [PATCH] Add a --legacy option for starting the game in 640x480 mode --- src/blupi.cxx | 13 ++++++++++++- src/blupi.h | 1 + src/display.cxx | 10 ++++++++-- src/display.h | 1 + src/event.cxx | 4 ++++ 5 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/blupi.cxx b/src/blupi.cxx index 9401758..7ff7992 100644 --- a/src/blupi.cxx +++ b/src/blupi.cxx @@ -576,6 +576,10 @@ parseArgs (int argc, char * argv[], bool & exit) {"-z", "--zoom"}, "change the window scale (only if fullscreen is off) [1;2] (default: 1)", 1}, + {"legacy", + {"-l", "--legacy"}, + "start the game in legacy display mode (640x480)", + 0}, {"renderer", {"-r", "--renderer"}, "set a renderer [auto;software;accelerated] (default: auto)", @@ -656,6 +660,12 @@ parseArgs (int argc, char * argv[], bool & exit) g_settingsOverload |= SETTING_ZOOM; } + if (args["legacy"]) + { + Display::getDisplay ().setDisplaySize (LXLOGIC (), LYLOGIC ()); + g_settingsOverload |= SETTING_LEGACY; + } + if (args["renderer"]) { if (args["renderer"].as () == "auto") @@ -729,7 +739,8 @@ DoInit (int argc, char * argv[], bool & exit) return EXIT_FAILURE; } - Display::getDisplay ().readDisplaySize (); + if (!(g_settingsOverload & SETTING_LEGACY)) + Display::getDisplay ().readDisplaySize (); // Create a window. g_window = SDL_CreateWindow ( diff --git a/src/blupi.h b/src/blupi.h index 1219fa9..a28675e 100644 --- a/src/blupi.h +++ b/src/blupi.h @@ -46,6 +46,7 @@ enum Settings { SETTING_ZOOM = 1 << 4, SETTING_DRIVER = 1 << 5, SETTING_MIDI = 1 << 6, + SETTING_LEGACY = 1 << 7, }; extern int g_settingsOverload; diff --git a/src/display.cxx b/src/display.cxx index af9a94c..49afb9a 100644 --- a/src/display.cxx +++ b/src/display.cxx @@ -31,8 +31,14 @@ Display::readDisplaySize () if (res < 0) return; - this->width = displayMode.w; - this->height = displayMode.h; + this->setDisplaySize (displayMode.w, displayMode.h); +} + +void +Display::setDisplaySize (Sint32 w, Sint32 h) +{ + this->width = w; + this->height = h; if (this->width < this->getLogicWidth ()) this->width = this->getLogicWidth (); diff --git a/src/display.h b/src/display.h index 449f1d3..7acf801 100644 --- a/src/display.h +++ b/src/display.h @@ -16,6 +16,7 @@ public: static Display & getDisplay (); void readDisplaySize (); + void setDisplaySize (Sint32 w, Sint32 h); Sint32 getWidth (); Sint32 getHeight (); Sint32 getLogicWidth (); diff --git a/src/event.cxx b/src/event.cxx index 6dd0b77..01c7777 100644 --- a/src/event.cxx +++ b/src/event.cxx @@ -4933,6 +4933,10 @@ CEvent::ReadInfo () g_bFullScreen = !!info.fullScreen; if (!(g_settingsOverload & SETTING_ZOOM)) g_zoom = info.zoom; + + /* Prefer the desktop fullscreen mode by default. */ + if (!(g_settingsOverload & SETTING_LEGACY) && g_bFullScreen && g_zoom == 2) + g_zoom = 1; } fclose (file);