From b74025597932f6a097bbeb4fb6bdd7f87134548b Mon Sep 17 00:00:00 2001 From: Andrea Odetti Date: Sat, 4 Dec 2021 12:47:09 +0000 Subject: [PATCH] Fix VidHD card insertion. Signed-off-by: Andrea Odetti --- source/frontends/sdl/imgui/sdlsettings.cpp | 2 +- source/frontends/sdl/imgui/settingshelper.cpp | 22 +++++++++++++++++-- source/frontends/sdl/imgui/settingshelper.h | 4 +++- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/source/frontends/sdl/imgui/sdlsettings.cpp b/source/frontends/sdl/imgui/sdlsettings.cpp index e9ed4a39..158d419d 100644 --- a/source/frontends/sdl/imgui/sdlsettings.cpp +++ b/source/frontends/sdl/imgui/sdlsettings.cpp @@ -306,7 +306,7 @@ namespace sa2 const bool isSelected = card == current; if (ImGui::Selectable(getCardName(card).c_str(), isSelected)) { - insertCard(slot, card); + insertCard(slot, card, frame); } if (isSelected) { diff --git a/source/frontends/sdl/imgui/settingshelper.cpp b/source/frontends/sdl/imgui/settingshelper.cpp index 148e1691..e0c11e15 100644 --- a/source/frontends/sdl/imgui/settingshelper.cpp +++ b/source/frontends/sdl/imgui/settingshelper.cpp @@ -4,6 +4,7 @@ #include "Harddisk.h" #include "Core.h" #include "Memory.h" +#include "Interface.h" #include "Debugger/Debug.h" #include "Tfe/tfe.h" @@ -160,11 +161,23 @@ namespace sa2 return statuses.at(status); } - void insertCard(size_t slot, SS_CARDTYPE card) + void insertCard(size_t slot, SS_CARDTYPE card, FrameBase * frame) { CardManager & cardManager = GetCardMgr(); + Video & video = GetVideo(); + const bool oldHasVid = video.HasVidHD(); switch (slot) { + case 3: + { + if (cardManager.QuerySlot(slot) == CT_VidHD) + { + // the old card was a VidHD, which will be removed + // reset it + video.SetVidHD(false); + } + break; + } case 4: case 5: { @@ -174,7 +187,6 @@ namespace sa2 } else { - CardManager & cardManager = GetCardMgr(); if (cardManager.QuerySlot(slot) == CT_MockingboardC) { cardManager.Insert(9 - slot, CT_Empty); // the other @@ -189,6 +201,12 @@ namespace sa2 // keep everything consistent // a bit of a heavy call, but nothing simpler is available now MemInitializeIO(); + + if (oldHasVid != video.HasVidHD()) + { + frame->Destroy(); + frame->Initialize(true); + } } void setVideoStyle(Video & video, const VideoStyle_e style, const bool enabled) diff --git a/source/frontends/sdl/imgui/settingshelper.h b/source/frontends/sdl/imgui/settingshelper.h index 694d5c39..c39d3ddc 100644 --- a/source/frontends/sdl/imgui/settingshelper.h +++ b/source/frontends/sdl/imgui/settingshelper.h @@ -10,6 +10,8 @@ #include #include +class FrameBase; + namespace sa2 { @@ -24,7 +26,7 @@ namespace sa2 const std::vector & getExpansionCards(); const std::map & getAapple2Types(); - void insertCard(size_t slot, SS_CARDTYPE card); + void insertCard(size_t slot, SS_CARDTYPE card, FrameBase * frame); void setVideoStyle(Video & video, const VideoStyle_e style, const bool enabled);