fix DSi loading crash
I hate every aspect of this code also fix potential crash when changing console type
This commit is contained in:
parent
1d4c5d1576
commit
36ee6ef345
|
@ -1123,6 +1123,7 @@ bool EmuInstance::updateConsole(UpdateConsoleNDSArgs&& _ndsargs, UpdateConsoleGB
|
||||||
static_cast<AudioInterpolation>(globalCfg.GetInt("Audio.Interpolation")),
|
static_cast<AudioInterpolation>(globalCfg.GetInt("Audio.Interpolation")),
|
||||||
gdbargs,
|
gdbargs,
|
||||||
};
|
};
|
||||||
|
NDSArgs* args = &ndsargs;
|
||||||
|
|
||||||
std::optional<DSiArgs> dsiargs = std::nullopt;
|
std::optional<DSiArgs> dsiargs = std::nullopt;
|
||||||
if (consoletype == 1)
|
if (consoletype == 1)
|
||||||
|
@ -1143,10 +1144,7 @@ bool EmuInstance::updateConsole(UpdateConsoleNDSArgs&& _ndsargs, UpdateConsoleGB
|
||||||
|
|
||||||
auto sdcard = loadSDCard("DSi.SD");
|
auto sdcard = loadSDCard("DSi.SD");
|
||||||
|
|
||||||
// FIXME!!! this operation fucking OBLITERATES THE DS BIOS
|
DSiArgs _dsiargs {
|
||||||
// yes, it somehow makes the std::array null.
|
|
||||||
// so in the end if you start in DSi mode... crash.
|
|
||||||
DSiArgs args {
|
|
||||||
std::move(ndsargs),
|
std::move(ndsargs),
|
||||||
std::move(arm9ibios),
|
std::move(arm9ibios),
|
||||||
std::move(arm7ibios),
|
std::move(arm7ibios),
|
||||||
|
@ -1155,7 +1153,8 @@ bool EmuInstance::updateConsole(UpdateConsoleNDSArgs&& _ndsargs, UpdateConsoleGB
|
||||||
globalCfg.GetBool("DSi.FullBIOSBoot"),
|
globalCfg.GetBool("DSi.FullBIOSBoot"),
|
||||||
};
|
};
|
||||||
|
|
||||||
dsiargs = std::move(args);
|
dsiargs = std::move(_dsiargs);
|
||||||
|
args = &(*dsiargs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1174,25 +1173,25 @@ bool EmuInstance::updateConsole(UpdateConsoleNDSArgs&& _ndsargs, UpdateConsoleGB
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
nds->SetARM7BIOS(*ndsargs.ARM7BIOS);
|
nds->SetARM7BIOS(*args->ARM7BIOS);
|
||||||
nds->SetARM9BIOS(*ndsargs.ARM9BIOS);
|
nds->SetARM9BIOS(*args->ARM9BIOS);
|
||||||
nds->SetFirmware(std::move(ndsargs.Firmware));
|
nds->SetFirmware(std::move(args->Firmware));
|
||||||
nds->SetNDSCart(std::move(ndsargs.NDSROM));
|
nds->SetNDSCart(std::move(args->NDSROM));
|
||||||
nds->SetJITArgs(ndsargs.JIT);
|
nds->SetJITArgs(args->JIT);
|
||||||
// TODO GDB stub shit
|
// TODO GDB stub shit
|
||||||
nds->SPU.SetInterpolation(ndsargs.Interpolation);
|
nds->SPU.SetInterpolation(args->Interpolation);
|
||||||
nds->SPU.SetDegrade10Bit(ndsargs.BitDepth);
|
nds->SPU.SetDegrade10Bit(args->BitDepth);
|
||||||
|
|
||||||
if (consoletype == 1)
|
if (consoletype == 1)
|
||||||
{
|
{
|
||||||
DSi* dsi = (DSi*)nds;
|
DSi* dsi = (DSi*)nds;
|
||||||
DSiArgs& args = dsiargs.value();
|
DSiArgs& _dsiargs = *dsiargs;
|
||||||
|
|
||||||
dsi->SetFullBIOSBoot(args.FullBIOSBoot);
|
dsi->SetFullBIOSBoot(_dsiargs.FullBIOSBoot);
|
||||||
dsi->ARM7iBIOS = *args.ARM7iBIOS;
|
dsi->ARM7iBIOS = *_dsiargs.ARM7iBIOS;
|
||||||
dsi->ARM9iBIOS = *args.ARM9iBIOS;
|
dsi->ARM9iBIOS = *_dsiargs.ARM9iBIOS;
|
||||||
dsi->SetNAND(std::move(args.NANDImage));
|
dsi->SetNAND(std::move(_dsiargs.NANDImage));
|
||||||
dsi->SetSDCard(std::move(args.DSiSDCard));
|
dsi->SetSDCard(std::move(_dsiargs.DSiSDCard));
|
||||||
// We're moving the optional, not the card
|
// We're moving the optional, not the card
|
||||||
// (inserting std::nullopt here is okay, it means no card)
|
// (inserting std::nullopt here is okay, it means no card)
|
||||||
|
|
||||||
|
|
|
@ -1683,8 +1683,6 @@ void MainWindow::onOpenEmuSettings()
|
||||||
|
|
||||||
void MainWindow::onEmuSettingsDialogFinished(int res)
|
void MainWindow::onEmuSettingsDialogFinished(int res)
|
||||||
{
|
{
|
||||||
emuThread->emuUnpause();
|
|
||||||
|
|
||||||
if (globalCfg.GetInt("Emu.ConsoleType") == 1)
|
if (globalCfg.GetInt("Emu.ConsoleType") == 1)
|
||||||
{
|
{
|
||||||
actInsertGBACart->setEnabled(false);
|
actInsertGBACart->setEnabled(false);
|
||||||
|
@ -1707,6 +1705,8 @@ void MainWindow::onEmuSettingsDialogFinished(int res)
|
||||||
|
|
||||||
if (!emuThread->emuIsActive())
|
if (!emuThread->emuIsActive())
|
||||||
actTitleManager->setEnabled(!globalCfg.GetString("DSi.NANDPath").empty());
|
actTitleManager->setEnabled(!globalCfg.GetString("DSi.NANDPath").empty());
|
||||||
|
|
||||||
|
emuThread->emuUnpause();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onOpenInputConfig()
|
void MainWindow::onOpenInputConfig()
|
||||||
|
|
Loading…
Reference in New Issue