diff --git a/docs/index.html b/docs/index.html index 45a7dbd60..04b35a205 100644 --- a/docs/index.html +++ b/docs/index.html @@ -3731,12 +3731,6 @@ Ms Pac-Man (Stella extended codes): PAL60 or SECAM60. - Display.Format: - Indicates the television format the game was designed for. The value - must be Auto, NTSC, PAL, SECAM, NTSC50, - PAL60 or SECAM60. - - Display.YStart: Indicates the scan-line to start displaying at. diff --git a/src/common/FrameBufferSDL2.cxx b/src/common/FrameBufferSDL2.cxx index 166280ba3..7fc949736 100644 --- a/src/common/FrameBufferSDL2.cxx +++ b/src/common/FrameBufferSDL2.cxx @@ -32,7 +32,8 @@ FrameBufferSDL2::FrameBufferSDL2(OSystem& osystem) : FrameBuffer(osystem), myWindow(nullptr), myRenderer(nullptr), - myCenter(false) + myCenter(false), + myRenderTargetSupport(false) { ASSERT_MAIN_THREAD; @@ -318,7 +319,10 @@ bool FrameBufferSDL2::setVideoMode(const string& title, const VideoMode& mode) const string& video = myOSystem.settings().getString("video"); // Render hint if(video != "") SDL_SetHint(SDL_HINT_RENDER_DRIVER, video.c_str()); + myRenderer = SDL_CreateRenderer(myWindow, -1, renderFlags); + detectFeatures(); + if(myRenderer == nullptr) { string msg = "ERROR: Unable to create SDL renderer: " + string(SDL_GetError()); @@ -468,3 +472,44 @@ const SDL_PixelFormat& FrameBufferSDL2::pixelFormat() const { return *myPixelFormat; } + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void FrameBufferSDL2::detectFeatures() +{ + myRenderTargetSupport = detectRenderTargetSupport(); + + if (myRenderer) { + if (!myRenderTargetSupport) { + Logger::info("Render targets are not supported --- QIS not available"); + } + } +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool FrameBufferSDL2::detectRenderTargetSupport() +{ + if (myRenderer == nullptr) return false; + + SDL_RendererInfo info; + + SDL_GetRendererInfo(myRenderer, &info); + + if (!(info.flags & SDL_RENDERER_TARGETTEXTURE)) return false; + + SDL_Texture* tex = SDL_CreateTexture(myRenderer, myPixelFormat->format, SDL_TEXTUREACCESS_TARGET, 16, 16); + + if (!tex) return false; + + int sdlError = SDL_SetRenderTarget(myRenderer, tex); + SDL_SetRenderTarget(myRenderer, nullptr); + + SDL_DestroyTexture(tex); + + return sdlError == 0; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool FrameBufferSDL2::hasRenderTargetSupport() const +{ + return myRenderTargetSupport; +} diff --git a/src/common/FrameBufferSDL2.hxx b/src/common/FrameBufferSDL2.hxx index 9959af90c..ff89e1110 100644 --- a/src/common/FrameBufferSDL2.hxx +++ b/src/common/FrameBufferSDL2.hxx @@ -129,6 +129,11 @@ class FrameBufferSDL2 : public FrameBuffer */ bool isInitialized() const; + /** + Does the renderer support render targets? + */ + bool hasRenderTargetSupport() const; + protected: ////////////////////////////////////////////////////////////////////// // The following are derived from protected methods in FrameBuffer.hxx @@ -193,6 +198,16 @@ class FrameBufferSDL2 : public FrameBuffer */ void renderToScreen() override; + /** + After the renderer has been created, detect the features it supports. + */ + void detectFeatures(); + + /** + Detect render target support; + */ + bool detectRenderTargetSupport(); + private: // The SDL video buffer SDL_Window* myWindow; @@ -207,6 +222,8 @@ class FrameBufferSDL2 : public FrameBuffer // last position of windowed window Common::Point myWindowedPos; + bool myRenderTargetSupport; + private: // Following constructors and assignment operators not supported FrameBufferSDL2() = delete; diff --git a/src/common/PKeyboardHandler.cxx b/src/common/PKeyboardHandler.cxx index e57412939..07a20640a 100644 --- a/src/common/PKeyboardHandler.cxx +++ b/src/common/PKeyboardHandler.cxx @@ -431,15 +431,15 @@ PhysicalKeyboardHandler::EventMappingArray PhysicalKeyboardHandler::DefaultCommo {Event::VidmodeDecrease, KBDK_MINUS, MOD3}, {Event::VidmodeIncrease, KBDK_EQUALS, MOD3}, - {Event::DecreaseYStart, KBDK_PAGEUP, MOD3}, - {Event::IncreaseYStart, KBDK_PAGEDOWN, MOD3}, + {Event::YStartDecrease, KBDK_PAGEUP, MOD3}, + {Event::YStartIncrease, KBDK_PAGEDOWN, MOD3}, {Event::VolumeDecrease, KBDK_LEFTBRACKET, MOD3}, {Event::VolumeIncrease, KBDK_RIGHTBRACKET, MOD3}, {Event::SoundToggle, KBDK_RIGHTBRACKET, KBDM_CTRL}, {Event::ToggleFullScreen, KBDK_RETURN, MOD3}, - {Event::DecreaseOverscan, KBDK_PAGEDOWN, KBDM_SHIFT}, - {Event::IncreaseOverScan, KBDK_PAGEUP, KBDM_SHIFT}, + {Event::OverscanDecrease, KBDK_PAGEDOWN, KBDM_SHIFT}, + {Event::OverscanIncrease, KBDK_PAGEUP, KBDM_SHIFT}, {Event::VidmodeStd, KBDK_1, MOD3}, {Event::VidmodeRGB, KBDK_2, MOD3}, {Event::VidmodeSVideo, KBDK_3, MOD3}, @@ -450,8 +450,8 @@ PhysicalKeyboardHandler::EventMappingArray PhysicalKeyboardHandler::DefaultCommo {Event::NextAttribute, KBDK_7, MOD3}, {Event::DecreaseAttribute, KBDK_8, KBDM_SHIFT | MOD3}, {Event::IncreaseAttribute, KBDK_8, MOD3}, - {Event::DecreasePhosphor, KBDK_9, KBDM_SHIFT | MOD3}, - {Event::IncreasePhosphor, KBDK_9, MOD3}, + {Event::PhosphorDecrease, KBDK_9, KBDM_SHIFT | MOD3}, + {Event::PhosphorIncrease, KBDK_9, MOD3}, {Event::TogglePhosphor, KBDK_P, MOD3}, {Event::ScanlinesDecrease, KBDK_0, KBDM_SHIFT | MOD3}, {Event::ScanlinesIncrease, KBDK_0, MOD3}, @@ -467,8 +467,8 @@ PhysicalKeyboardHandler::EventMappingArray PhysicalKeyboardHandler::DefaultCommo {Event::HandleMouseControl, KBDK_0, KBDM_CTRL}, {Event::ToggleGrabMouse, KBDK_G, KBDM_CTRL}, {Event::ToggleSAPortOrder, KBDK_1, KBDM_CTRL}, - {Event::DecreaseFormat, KBDK_F, KBDM_SHIFT | KBDM_CTRL}, - {Event::IncreaseFormat, KBDK_F, KBDM_CTRL}, + {Event::FormatDecrease, KBDK_F, KBDM_SHIFT | KBDM_CTRL}, + {Event::FormatIncrease, KBDK_F, KBDM_CTRL}, {Event::ToggleP0Collision, KBDK_Z, KBDM_SHIFT | MOD3}, {Event::ToggleP0Bit, KBDK_Z, MOD3}, diff --git a/src/common/sdl_blitter/HqBlitter.cxx b/src/common/sdl_blitter/HqBlitter.cxx index 5d408f6e0..20f90bfbb 100644 --- a/src/common/sdl_blitter/HqBlitter.cxx +++ b/src/common/sdl_blitter/HqBlitter.cxx @@ -39,26 +39,9 @@ HqBlitter::~HqBlitter() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool HqBlitter::isSupported(FrameBufferSDL2 &fb) { - ASSERT_MAIN_THREAD; - if (!fb.isInitialized()) throw runtime_error("framebuffer not initialized"); - SDL_RendererInfo info; - - SDL_GetRendererInfo(fb.renderer(), &info); - - if (!(info.flags & SDL_RENDERER_TARGETTEXTURE)) return false; - - SDL_Texture* tex = SDL_CreateTexture(fb.renderer(), fb.pixelFormat().format, SDL_TEXTUREACCESS_TARGET, 16, 16); - - if (!tex) return false; - - int sdlError = SDL_SetRenderTarget(fb.renderer(), tex); - SDL_SetRenderTarget(fb.renderer(), nullptr); - - SDL_DestroyTexture(tex); - - return sdlError == 0; + return fb.hasRenderTargetSupport(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/debugger/RiotDebug.cxx b/src/debugger/RiotDebug.cxx index 449b3b489..51760de6e 100644 --- a/src/debugger/RiotDebug.cxx +++ b/src/debugger/RiotDebug.cxx @@ -366,7 +366,7 @@ string RiotDebug::toString() << " Divider=" << myDebugger.invIfChanged(state.TIMDIV, oldstate.TIMDIV) << endl - << "Left/P0diff: " << diffP0String() << " Right/P1diff: " << diffP0String() + << "Left/P0diff: " << diffP0String() << " Right/P1diff: " << diffP1String() << endl << "TVType: " << tvTypeString() << " Switches: " << switchesString() << endl diff --git a/src/emucore/Event.hxx b/src/emucore/Event.hxx index 2bb9c1629..8b0073286 100644 --- a/src/emucore/Event.hxx +++ b/src/emucore/Event.hxx @@ -90,19 +90,19 @@ class Event ToggleBLCollision, ToggleBLBit, TogglePFCollision, TogglePFBit, ToggleCollisions, ToggleBits, ToggleFixedColors, - DecreasePhosphor, IncreasePhosphor, TogglePhosphor, ToggleJitter, + PhosphorDecrease, PhosphorIncrease, TogglePhosphor, ToggleJitter, ToggleFrameStats, ToggleTimeMachine, ToggleContSnapshots, ToggleContSnapshotsFrame, ToggleColorLoss, TogglePalette, HandleMouseControl, ToggleGrabMouse, ToggleSAPortOrder, - DecreaseFormat, IncreaseFormat, ReloadConsole, + FormatDecrease, FormatIncrease, ReloadConsole, Rewind1Menu, Rewind10Menu, RewindAllMenu, Unwind1Menu, Unwind10Menu, UnwindAllMenu, StartPauseMode, SaveAllStates, LoadAllStates, - DecreaseOverscan, IncreaseOverScan, + OverscanDecrease, OverscanIncrease, ToggleAutoSlot, @@ -120,10 +120,9 @@ class Event CompuMateQuote, CompuMateBackspace, CompuMateEquals, CompuMatePlus, CompuMateSlash, - DecreaseYStart, IncreaseYStart, + YStartDecrease, YStartIncrease, LastType - }; // Event categorizing groups diff --git a/src/emucore/EventHandler.cxx b/src/emucore/EventHandler.cxx index b7296622d..d0ec6d64c 100644 --- a/src/emucore/EventHandler.cxx +++ b/src/emucore/EventHandler.cxx @@ -419,11 +419,11 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated) if(pressed) myOSystem.frameBuffer().changeVidMode(+1); return; - case Event::DecreaseYStart: + case Event::YStartDecrease: if (pressed) myOSystem.console().changeYStart(-1); return; - case Event::IncreaseYStart: + case Event::YStartIncrease: if (pressed) myOSystem.console().changeYStart(+1); return; @@ -431,11 +431,11 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated) if (pressed && !repeated) myOSystem.frameBuffer().toggleFullscreen(); return; - case Event::DecreaseOverscan: + case Event::OverscanDecrease: if (pressed) myOSystem.frameBuffer().changeOverscan(-1); return; - case Event::IncreaseOverScan: + case Event::OverscanIncrease: if (pressed) myOSystem.frameBuffer().changeOverscan(1); return; @@ -507,11 +507,11 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated) } return; - case Event::DecreasePhosphor: + case Event::PhosphorDecrease: if (pressed) myOSystem.console().changePhosphor(-1); return; - case Event::IncreasePhosphor: + case Event::PhosphorIncrease: if (pressed) myOSystem.console().changePhosphor(1); return; @@ -557,11 +557,11 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated) if (pressed && !repeated) toggleSAPortOrder(); return; - case Event::DecreaseFormat: + case Event::FormatDecrease: if (pressed) myOSystem.console().toggleFormat(-1); return; - case Event::IncreaseFormat: + case Event::FormatIncrease: if (pressed) myOSystem.console().toggleFormat(1); return; @@ -1828,12 +1828,12 @@ EventHandler::EmulActionList EventHandler::ourEmulActionList = { { { Event::VidmodeDecrease, "Previous zoom level", "" }, { Event::VidmodeIncrease, "Next zoom level", "" }, { Event::ToggleFullScreen, "Toggle fullscreen", "" }, - { Event::DecreaseOverscan, "Decrease overscan in fullscreen mode", "" }, - { Event::IncreaseOverScan, "Increase overscan in fullscreen mode", "" }, - { Event::DecreaseFormat, "Decrease display format", "" }, - { Event::IncreaseFormat, "Increase display format", "" }, - { Event::DecreaseYStart, "Move display up", "" }, - { Event::IncreaseYStart, "Move display down", "" }, + { Event::OverscanDecrease, "Decrease overscan in fullscreen mode", "" }, + { Event::OverscanIncrease, "Increase overscan in fullscreen mode", "" }, + { Event::FormatDecrease, "Decrease display format", "" }, + { Event::FormatIncrease, "Increase display format", "" }, + { Event::YStartDecrease, "Move display up", "" }, + { Event::YStartIncrease, "Move display down", "" }, { Event::TogglePalette, "Switch palette (Standard/Z26/User)", "" }, // TV effects: @@ -1848,8 +1848,8 @@ EventHandler::EmulActionList EventHandler::ourEmulActionList = { { { Event::DecreaseAttribute, "Decrease selected 'Custom' attribute", "" }, { Event::IncreaseAttribute, "Increase selected 'Custom' attribute", "" }, { Event::TogglePhosphor, "Toggle 'phosphor' effect", "" }, - { Event::DecreasePhosphor, "Decrease 'phosphor' blend", "" }, - { Event::IncreasePhosphor, "Increase 'phosphor' blend", "" }, + { Event::PhosphorDecrease, "Decrease 'phosphor' blend", "" }, + { Event::PhosphorIncrease, "Increase 'phosphor' blend", "" }, { Event::ScanlinesDecrease, "Decrease scanlines", "" }, { Event::ScanlinesIncrease, "Increase scanlines", "" }, // Developer keys: @@ -1957,10 +1957,10 @@ const Event::EventSet EventHandler::AudioVideoEvents = { Event::VidmodeStd, Event::VidmodeRGB, Event::VidmodeSVideo, Event::VidModeComposite, Event::VidModeBad, Event::VidModeCustom, Event::PreviousAttribute, Event::NextAttribute, Event::DecreaseAttribute, Event::IncreaseAttribute, Event::ScanlinesDecrease, Event::ScanlinesIncrease, - Event::DecreasePhosphor, Event::IncreasePhosphor, Event::TogglePhosphor, - Event::DecreaseFormat, Event::IncreaseFormat, - Event::DecreaseYStart, Event::IncreaseYStart, - Event::DecreaseOverscan, Event::IncreaseOverScan, + Event::PhosphorDecrease, Event::PhosphorIncrease, Event::TogglePhosphor, + Event::FormatDecrease, Event::FormatIncrease, + Event::YStartDecrease, Event::YStartIncrease, + Event::OverscanDecrease, Event::OverscanIncrease, Event::TogglePalette, }; diff --git a/src/emucore/Settings.cxx b/src/emucore/Settings.cxx index 17ab8339d..887c22ce9 100644 --- a/src/emucore/Settings.cxx +++ b/src/emucore/Settings.cxx @@ -34,6 +34,9 @@ Settings::Settings() { myRespository = make_shared(); + // If no version is recorded with the persisted settings, we set it to zero + setPermanent(SETTINGS_VERSION_KEY, 0); + // Video-related options setPermanent("video", ""); setPermanent("speed", "1.0"); @@ -225,6 +228,8 @@ void Settings::load(const Options& options) for (const auto& opt: fromFile) setValue(opt.first, opt.second, false); + migrate(); + // Apply commandline options, which override those from settings file for(const auto& opt: options) setValue(opt.first, opt.second, false); @@ -648,3 +653,29 @@ void Settings::setTemporary(const string& key, const Variant& value) { myTemporarySettings[key] = value; } + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void Settings::migrateOne() +{ + const int version = getInt(SETTINGS_VERSION_KEY); + if (version >= SETTINGS_VERSION) return; + + switch (version) { + case 0: + #if defined BSPF_MACOS || defined DARWIN + setPermanent("video", ""); + #endif + + break; + } + + setPermanent(SETTINGS_VERSION_KEY, version + 1); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void Settings::migrate() +{ + while (getInt(SETTINGS_VERSION_KEY) < SETTINGS_VERSION) migrateOne(); + + myRespository->save(SETTINGS_VERSION_KEY, SETTINGS_VERSION); +} diff --git a/src/emucore/Settings.hxx b/src/emucore/Settings.hxx index f151dd814..eb1398e22 100644 --- a/src/emucore/Settings.hxx +++ b/src/emucore/Settings.hxx @@ -51,6 +51,9 @@ class Settings using Options = std::map; + static constexpr int SETTINGS_VERSION = 1; + static constexpr const char* SETTINGS_VERSION_KEY = "settings.version"; + public: /** This method should be called to display usage information. @@ -134,6 +137,16 @@ class Settings */ void validate(); + /** + Migrate settings over one version. + */ + void migrateOne(); + + /** + Migrate settings. + */ + void migrate(); + private: // Holds key/value pairs that are necessary for Stella to // function and must be saved on each program exit. diff --git a/src/gui/HelpDialog.cxx b/src/gui/HelpDialog.cxx index 5716b5495..12b532717 100644 --- a/src/gui/HelpDialog.cxx +++ b/src/gui/HelpDialog.cxx @@ -111,13 +111,13 @@ void HelpDialog::updateStrings(uInt8 page, uInt8 lines, string& title) ADD_EVENT(Event::VidmodeDecrease, "Decrease window size"); ADD_EVENT(Event::ToggleFullScreen, "Toggle fullscreen /"); ADD_BIND("", " windowed mode"); - ADD_EVENT(Event::IncreaseOverScan, "Increase overscan in FS mode"); - ADD_EVENT(Event::DecreaseOverscan, "Decrease overscan in FS mode"); + ADD_EVENT(Event::OverscanIncrease, "Increase overscan in FS mode"); + ADD_EVENT(Event::OverscanDecrease, "Decrease overscan in FS mode"); break; case 2: title = "Special commands"; - ADD_EVENT(Event::IncreaseFormat, "Switch between NTSC/PAL/SECAM"); + ADD_EVENT(Event::FormatIncrease, "Switch between NTSC/PAL/SECAM"); ADD_EVENT(Event::TogglePalette, "Switch palette"); ADD_EVENT(Event::TogglePhosphor, "Toggle 'phosphor' effect"); ADD_LINE(); @@ -139,7 +139,7 @@ void HelpDialog::updateStrings(uInt8 page, uInt8 lines, string& title) ADD_EVENT(Event::VidModeCustom, "Enable 'Custom' mode"); ADD_EVENT(Event::NextAttribute, "Select 'Custom' attribute"); ADD_EVENT(Event::IncreaseAttribute, "Modify 'Custom' attribute"); - ADD_EVENT(Event::IncreasePhosphor, "Adjust phosphor blend"); + ADD_EVENT(Event::PhosphorIncrease, "Adjust phosphor blend"); ADD_EVENT(Event::ScanlinesIncrease, "Adjust scanline intensity"); break; diff --git a/src/gui/RomInfoWidget.cxx b/src/gui/RomInfoWidget.cxx index e7ec39959..9cef9f0fe 100644 --- a/src/gui/RomInfoWidget.cxx +++ b/src/gui/RomInfoWidget.cxx @@ -89,7 +89,7 @@ void RomInfoWidget::parseProperties(const FilesystemNode& node) if(mySurface == nullptr) { mySurface = instance().frameBuffer().allocateSurface( - TIAConstants::viewableWidth*2, TIAConstants::viewableHeight*2); + TIAConstants::viewableWidth*2, TIAConstants::viewableHeight*2, FrameBuffer::ScalingInterpolation::blur); mySurface->applyAttributes(); dialog().addSurface(mySurface);