fix one of the cursed bugs

This commit is contained in:
Arisotura 2024-10-23 20:33:31 +02:00
parent d68b58f37e
commit 1428bfb2cf
3 changed files with 10 additions and 11 deletions

View File

@ -1116,6 +1116,9 @@ void EmuInstance::setDateTime()
bool EmuInstance::updateConsole(UpdateConsoleNDSArgs&& _ndsargs, UpdateConsoleGBAArgs&& _gbaargs) noexcept bool EmuInstance::updateConsole(UpdateConsoleNDSArgs&& _ndsargs, UpdateConsoleGBAArgs&& _gbaargs) noexcept
{ {
// update the console type
consoleType = globalCfg.GetInt("Emu.ConsoleType");
// Let's get the cart we want to use; // Let's get the cart we want to use;
// if we wnat to keep the cart, we'll eject it from the existing console first. // if we wnat to keep the cart, we'll eject it from the existing console first.
std::unique_ptr<NDSCart::CartCommon> nextndscart; std::unique_ptr<NDSCart::CartCommon> nextndscart;
@ -1149,8 +1152,6 @@ bool EmuInstance::updateConsole(UpdateConsoleNDSArgs&& _ndsargs, UpdateConsoleGB
} }
int consoletype = globalCfg.GetInt("Emu.ConsoleType");
auto arm9bios = loadARM9BIOS(); auto arm9bios = loadARM9BIOS();
if (!arm9bios) if (!arm9bios)
return false; return false;
@ -1159,7 +1160,7 @@ bool EmuInstance::updateConsole(UpdateConsoleNDSArgs&& _ndsargs, UpdateConsoleGB
if (!arm7bios) if (!arm7bios)
return false; return false;
auto firmware = loadFirmware(consoletype); auto firmware = loadFirmware(consoleType);
if (!firmware) if (!firmware)
return false; return false;
@ -1203,7 +1204,7 @@ bool EmuInstance::updateConsole(UpdateConsoleNDSArgs&& _ndsargs, UpdateConsoleGB
NDSArgs* args = &ndsargs; NDSArgs* args = &ndsargs;
std::optional<DSiArgs> dsiargs = std::nullopt; std::optional<DSiArgs> dsiargs = std::nullopt;
if (consoletype == 1) if (consoleType == 1)
{ {
ndsargs.GBAROM = nullptr; ndsargs.GBAROM = nullptr;
@ -1234,19 +1235,19 @@ bool EmuInstance::updateConsole(UpdateConsoleNDSArgs&& _ndsargs, UpdateConsoleGB
args = &(*dsiargs); args = &(*dsiargs);
} }
if ((!nds) || (consoleType != nds->ConsoleType))
if ((!nds) || (consoletype != nds->ConsoleType))
{ {
NDS::Current = nullptr; NDS::Current = nullptr;
if (nds) delete nds; if (nds) delete nds;
if (consoletype == 1) if (consoleType == 1)
nds = new DSi(std::move(dsiargs.value()), this); nds = new DSi(std::move(dsiargs.value()), this);
else else
nds = new NDS(std::move(ndsargs), this); nds = new NDS(std::move(ndsargs), this);
NDS::Current = nds; NDS::Current = nds;
nds->Reset(); nds->Reset();
//emuThread->updateVideoRenderer(); // not actually needed?
} }
else else
{ {
@ -1260,7 +1261,7 @@ bool EmuInstance::updateConsole(UpdateConsoleNDSArgs&& _ndsargs, UpdateConsoleGB
nds->SPU.SetInterpolation(args->Interpolation); nds->SPU.SetInterpolation(args->Interpolation);
nds->SPU.SetDegrade10Bit(args->BitDepth); nds->SPU.SetDegrade10Bit(args->BitDepth);
if (consoletype == 1) if (consoleType == 1)
{ {
DSi* dsi = (DSi*)nds; DSi* dsi = (DSi*)nds;
DSiArgs& _dsiargs = *dsiargs; DSiArgs& _dsiargs = *dsiargs;
@ -1282,8 +1283,6 @@ bool EmuInstance::updateConsole(UpdateConsoleNDSArgs&& _ndsargs, UpdateConsoleGB
void EmuInstance::reset() void EmuInstance::reset()
{ {
consoleType = globalCfg.GetInt("Emu.ConsoleType");
updateConsole(Keep {}, Keep {}); updateConsole(Keep {}, Keep {});
if (consoleType == 1) ejectGBACart(); if (consoleType == 1) ejectGBACart();

View File

@ -664,7 +664,6 @@ void EmuThread::updateRenderer()
{ {
if (videoRenderer != lastVideoRenderer) if (videoRenderer != lastVideoRenderer)
{ {
printf("creating renderer %d\n", videoRenderer);
switch (videoRenderer) switch (videoRenderer)
{ {
case renderer3D_Software: case renderer3D_Software:

View File

@ -106,6 +106,7 @@ public:
void initContext(); void initContext();
void deinitContext(); void deinitContext();
void updateVideoSettings() { videoSettingsDirty = true; } void updateVideoSettings() { videoSettingsDirty = true; }
void updateVideoRenderer() { videoSettingsDirty = true; lastVideoRenderer = -1; }
int FrontBuffer = 0; int FrontBuffer = 0;
QMutex FrontBufferLock; QMutex FrontBufferLock;