Fix VidHD card insertion.

Signed-off-by: Andrea Odetti <mariofutire@gmail.com>
This commit is contained in:
Andrea Odetti 2021-12-04 12:47:09 +00:00
parent ad6ca9c940
commit b740255979
3 changed files with 24 additions and 4 deletions

View file

@ -306,7 +306,7 @@ namespace sa2
const bool isSelected = card == current; const bool isSelected = card == current;
if (ImGui::Selectable(getCardName(card).c_str(), isSelected)) if (ImGui::Selectable(getCardName(card).c_str(), isSelected))
{ {
insertCard(slot, card); insertCard(slot, card, frame);
} }
if (isSelected) if (isSelected)
{ {

View file

@ -4,6 +4,7 @@
#include "Harddisk.h" #include "Harddisk.h"
#include "Core.h" #include "Core.h"
#include "Memory.h" #include "Memory.h"
#include "Interface.h"
#include "Debugger/Debug.h" #include "Debugger/Debug.h"
#include "Tfe/tfe.h" #include "Tfe/tfe.h"
@ -160,11 +161,23 @@ namespace sa2
return statuses.at(status); 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(); CardManager & cardManager = GetCardMgr();
Video & video = GetVideo();
const bool oldHasVid = video.HasVidHD();
switch (slot) 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 4:
case 5: case 5:
{ {
@ -174,7 +187,6 @@ namespace sa2
} }
else else
{ {
CardManager & cardManager = GetCardMgr();
if (cardManager.QuerySlot(slot) == CT_MockingboardC) if (cardManager.QuerySlot(slot) == CT_MockingboardC)
{ {
cardManager.Insert(9 - slot, CT_Empty); // the other cardManager.Insert(9 - slot, CT_Empty); // the other
@ -189,6 +201,12 @@ namespace sa2
// keep everything consistent // keep everything consistent
// a bit of a heavy call, but nothing simpler is available now // a bit of a heavy call, but nothing simpler is available now
MemInitializeIO(); MemInitializeIO();
if (oldHasVid != video.HasVidHD())
{
frame->Destroy();
frame->Initialize(true);
}
} }
void setVideoStyle(Video & video, const VideoStyle_e style, const bool enabled) void setVideoStyle(Video & video, const VideoStyle_e style, const bool enabled)

View file

@ -10,6 +10,8 @@
#include <vector> #include <vector>
#include <map> #include <map>
class FrameBase;
namespace sa2 namespace sa2
{ {
@ -24,7 +26,7 @@ namespace sa2
const std::vector<SS_CARDTYPE> & getExpansionCards(); const std::vector<SS_CARDTYPE> & getExpansionCards();
const std::map<eApple2Type, std::string> & getAapple2Types(); const std::map<eApple2Type, std::string> & 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); void setVideoStyle(Video & video, const VideoStyle_e style, const bool enabled);