Skip to content

Commit

Permalink
Fix VidHD card insertion.
Browse files Browse the repository at this point in the history
Signed-off-by: Andrea Odetti <mariofutire@gmail.com>
  • Loading branch information
audetto committed Dec 4, 2021
1 parent ad6ca9c commit b740255
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion source/frontends/sdl/imgui/sdlsettings.cpp
Expand Up @@ -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)
{
Expand Down
22 changes: 20 additions & 2 deletions source/frontends/sdl/imgui/settingshelper.cpp
Expand Up @@ -4,6 +4,7 @@
#include "Harddisk.h"
#include "Core.h"
#include "Memory.h"
#include "Interface.h"
#include "Debugger/Debug.h"

#include "Tfe/tfe.h"
Expand Down Expand Up @@ -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:
{
Expand All @@ -174,7 +187,6 @@ namespace sa2
}
else
{
CardManager & cardManager = GetCardMgr();
if (cardManager.QuerySlot(slot) == CT_MockingboardC)
{
cardManager.Insert(9 - slot, CT_Empty); // the other
Expand All @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion source/frontends/sdl/imgui/settingshelper.h
Expand Up @@ -10,6 +10,8 @@
#include <vector>
#include <map>

class FrameBase;

namespace sa2
{

Expand All @@ -24,7 +26,7 @@ namespace sa2
const std::vector<SS_CARDTYPE> & getExpansionCards();
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);

Expand Down

0 comments on commit b740255

Please sign in to comment.