parent
d10b5f8b8a
commit
10380320c5
|
@ -7,6 +7,7 @@ set(SOURCES_QT_SDL
|
|||
main_shaders.h
|
||||
Screen.cpp
|
||||
Window.cpp
|
||||
EmuInstance.cpp
|
||||
EmuThread.cpp
|
||||
CheatsDialog.cpp
|
||||
Config.cpp
|
||||
|
@ -36,7 +37,6 @@ set(SOURCES_QT_SDL
|
|||
font.h
|
||||
Platform.cpp
|
||||
QPathInput.h
|
||||
ROMManager.cpp
|
||||
SaveManager.cpp
|
||||
CameraManager.cpp
|
||||
AudioInOut.cpp
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include "types.h"
|
||||
#include "Platform.h"
|
||||
#include "Config.h"
|
||||
#include "ROMManager.h"
|
||||
#include "EmuInstance.h"
|
||||
|
||||
#include "CheatsDialog.h"
|
||||
#include "ui_CheatsDialog.h"
|
||||
|
@ -43,6 +43,9 @@ CheatsDialog::CheatsDialog(QWidget* parent) : QDialog(parent), ui(new Ui::Cheats
|
|||
ui->setupUi(this);
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
MainWindow* win = (MainWindow*)parent;
|
||||
//
|
||||
|
||||
codeFile = ROMManager::GetCheatFile();
|
||||
|
||||
QStandardItemModel* model = new QStandardItemModel();
|
||||
|
|
|
@ -38,6 +38,8 @@ public:
|
|||
// return: empty string = setup OK, non-empty = error message
|
||||
QString verifySetup();
|
||||
|
||||
bool updateConsole(UpdateConsoleNDSArgs&& ndsargs, UpdateConsoleGBAArgs&& gbaargs) noexcept;
|
||||
|
||||
private:
|
||||
static int lastSep(const std::string& path);
|
||||
std::string getAssetPath(bool gba, const std::string& configpath, const std::string& ext, const std::string& file);
|
||||
|
@ -70,7 +72,6 @@ private:
|
|||
melonDS::ARCodeFile* getCheatFile();
|
||||
void setBatteryLevels();
|
||||
void setDateTime();
|
||||
bool updateConsole(UpdateConsoleNDSArgs&& ndsargs, UpdateConsoleGBAArgs&& gbaargs) noexcept;
|
||||
void reset();
|
||||
bool bootToMenu();
|
||||
melonDS::u32 decompressROM(const melonDS::u8* inContent, const melonDS::u32 inSize, std::unique_ptr<melonDS::u8[]>& outContent);
|
||||
|
@ -125,6 +126,9 @@ private:
|
|||
|
||||
melonDS::ARCodeFile* cheatFile;
|
||||
bool cheatsOn;
|
||||
|
||||
friend class EmuThread;
|
||||
friend class MainWindow;
|
||||
};
|
||||
|
||||
#endif //EMUINSTANCE_H
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
|
||||
#include "Savestate.h"
|
||||
|
||||
#include "ROMManager.h"
|
||||
#include "EmuInstance.h"
|
||||
//#include "ArchiveUtil.h"
|
||||
//#include "CameraManager.h"
|
||||
|
||||
|
@ -72,8 +72,10 @@ extern int videoRenderer;
|
|||
extern bool videoSettingsDirty;
|
||||
|
||||
|
||||
EmuThread::EmuThread(QObject* parent) : QThread(parent)
|
||||
EmuThread::EmuThread(EmuInstance* inst, QObject* parent) : QThread(parent)
|
||||
{
|
||||
emuInstance = inst;
|
||||
|
||||
EmuStatus = emuStatus_Exit;
|
||||
EmuRunning = emuStatus_Paused;
|
||||
EmuPauseStack = EmuPauseStackRunning;
|
||||
|
@ -133,218 +135,12 @@ void EmuThread::detachWindow(MainWindow* window)
|
|||
mainWindow = windowList.front();
|
||||
}
|
||||
|
||||
std::unique_ptr<NDS> EmuThread::CreateConsole(
|
||||
std::unique_ptr<melonDS::NDSCart::CartCommon>&& ndscart,
|
||||
std::unique_ptr<melonDS::GBACart::CartCommon>&& gbacart
|
||||
) noexcept
|
||||
{
|
||||
auto arm7bios = ROMManager::LoadARM7BIOS();
|
||||
if (!arm7bios)
|
||||
return nullptr;
|
||||
|
||||
auto arm9bios = ROMManager::LoadARM9BIOS();
|
||||
if (!arm9bios)
|
||||
return nullptr;
|
||||
|
||||
auto firmware = ROMManager::LoadFirmware(Config::ConsoleType);
|
||||
if (!firmware)
|
||||
return nullptr;
|
||||
|
||||
#ifdef JIT_ENABLED
|
||||
JITArgs jitargs {
|
||||
static_cast<unsigned>(Config::JIT_MaxBlockSize),
|
||||
Config::JIT_LiteralOptimisations,
|
||||
Config::JIT_BranchOptimisations,
|
||||
Config::JIT_FastMemory,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef GDBSTUB_ENABLED
|
||||
GDBArgs gdbargs {
|
||||
static_cast<u16>(Config::GdbPortARM7),
|
||||
static_cast<u16>(Config::GdbPortARM9),
|
||||
Config::GdbARM7BreakOnStartup,
|
||||
Config::GdbARM9BreakOnStartup,
|
||||
};
|
||||
#endif
|
||||
|
||||
NDSArgs ndsargs {
|
||||
std::move(ndscart),
|
||||
std::move(gbacart),
|
||||
*arm9bios,
|
||||
*arm7bios,
|
||||
std::move(*firmware),
|
||||
#ifdef JIT_ENABLED
|
||||
Config::JIT_Enable ? std::make_optional(jitargs) : std::nullopt,
|
||||
#else
|
||||
std::nullopt,
|
||||
#endif
|
||||
static_cast<AudioBitDepth>(Config::AudioBitDepth),
|
||||
static_cast<AudioInterpolation>(Config::AudioInterp),
|
||||
#ifdef GDBSTUB_ENABLED
|
||||
Config::GdbEnabled ? std::make_optional(gdbargs) : std::nullopt,
|
||||
#else
|
||||
std::nullopt,
|
||||
#endif
|
||||
};
|
||||
|
||||
if (Config::ConsoleType == 1)
|
||||
{
|
||||
auto arm7ibios = ROMManager::LoadDSiARM7BIOS();
|
||||
if (!arm7ibios)
|
||||
return nullptr;
|
||||
|
||||
auto arm9ibios = ROMManager::LoadDSiARM9BIOS();
|
||||
if (!arm9ibios)
|
||||
return nullptr;
|
||||
|
||||
auto nand = ROMManager::LoadNAND(*arm7ibios);
|
||||
if (!nand)
|
||||
return nullptr;
|
||||
|
||||
auto sdcard = ROMManager::LoadDSiSDCard();
|
||||
DSiArgs args {
|
||||
std::move(ndsargs),
|
||||
*arm9ibios,
|
||||
*arm7ibios,
|
||||
std::move(*nand),
|
||||
std::move(sdcard),
|
||||
Config::DSiFullBIOSBoot,
|
||||
};
|
||||
|
||||
args.GBAROM = nullptr;
|
||||
|
||||
return std::make_unique<melonDS::DSi>(std::move(args));
|
||||
}
|
||||
|
||||
return std::make_unique<melonDS::NDS>(std::move(ndsargs));
|
||||
}
|
||||
|
||||
bool EmuThread::UpdateConsole(UpdateConsoleNDSArgs&& ndsargs, UpdateConsoleGBAArgs&& gbaargs) noexcept
|
||||
{
|
||||
// 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.
|
||||
std::unique_ptr<NDSCart::CartCommon> nextndscart;
|
||||
if (std::holds_alternative<Keep>(ndsargs))
|
||||
{ // If we want to keep the existing cart (if any)...
|
||||
nextndscart = NDS ? NDS->EjectCart() : nullptr;
|
||||
ndsargs = {};
|
||||
}
|
||||
else if (const auto ptr = std::get_if<std::unique_ptr<NDSCart::CartCommon>>(&ndsargs))
|
||||
{
|
||||
nextndscart = std::move(*ptr);
|
||||
ndsargs = {};
|
||||
}
|
||||
|
||||
if (auto* cartsd = dynamic_cast<NDSCart::CartSD*>(nextndscart.get()))
|
||||
{
|
||||
// LoadDLDISDCard will return nullopt if the SD card is disabled;
|
||||
// SetSDCard will accept nullopt, which means no SD card
|
||||
cartsd->SetSDCard(ROMManager::GetDLDISDCardArgs());
|
||||
}
|
||||
|
||||
std::unique_ptr<GBACart::CartCommon> nextgbacart;
|
||||
if (std::holds_alternative<Keep>(gbaargs))
|
||||
{
|
||||
nextgbacart = NDS ? NDS->EjectGBACart() : nullptr;
|
||||
}
|
||||
else if (const auto ptr = std::get_if<std::unique_ptr<GBACart::CartCommon>>(&gbaargs))
|
||||
{
|
||||
nextgbacart = std::move(*ptr);
|
||||
gbaargs = {};
|
||||
}
|
||||
|
||||
if (!NDS || NDS->ConsoleType != Config::ConsoleType)
|
||||
{ // If we're switching between DS and DSi mode, or there's no console...
|
||||
// To ensure the destructor is called before a new one is created,
|
||||
// as the presence of global signal handlers still complicates things a bit
|
||||
NDS = nullptr;
|
||||
NDS::Current = nullptr;
|
||||
|
||||
NDS = CreateConsole(std::move(nextndscart), std::move(nextgbacart));
|
||||
|
||||
if (NDS == nullptr)
|
||||
return false;
|
||||
|
||||
NDS->Reset();
|
||||
NDS::Current = NDS.get();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
auto arm9bios = ROMManager::LoadARM9BIOS();
|
||||
if (!arm9bios)
|
||||
return false;
|
||||
|
||||
auto arm7bios = ROMManager::LoadARM7BIOS();
|
||||
if (!arm7bios)
|
||||
return false;
|
||||
|
||||
auto firmware = ROMManager::LoadFirmware(NDS->ConsoleType);
|
||||
if (!firmware)
|
||||
return false;
|
||||
|
||||
if (NDS->ConsoleType == 1)
|
||||
{ // If the console we're updating is a DSi...
|
||||
DSi& dsi = static_cast<DSi&>(*NDS);
|
||||
|
||||
auto arm9ibios = ROMManager::LoadDSiARM9BIOS();
|
||||
if (!arm9ibios)
|
||||
return false;
|
||||
|
||||
auto arm7ibios = ROMManager::LoadDSiARM7BIOS();
|
||||
if (!arm7ibios)
|
||||
return false;
|
||||
|
||||
auto nandimage = ROMManager::LoadNAND(*arm7ibios);
|
||||
if (!nandimage)
|
||||
return false;
|
||||
|
||||
auto dsisdcard = ROMManager::LoadDSiSDCard();
|
||||
|
||||
dsi.SetFullBIOSBoot(Config::DSiFullBIOSBoot);
|
||||
dsi.ARM7iBIOS = *arm7ibios;
|
||||
dsi.ARM9iBIOS = *arm9ibios;
|
||||
dsi.SetNAND(std::move(*nandimage));
|
||||
dsi.SetSDCard(std::move(dsisdcard));
|
||||
// We're moving the optional, not the card
|
||||
// (inserting std::nullopt here is okay, it means no card)
|
||||
|
||||
dsi.EjectGBACart();
|
||||
}
|
||||
|
||||
if (NDS->ConsoleType == 0)
|
||||
{
|
||||
NDS->SetGBACart(std::move(nextgbacart));
|
||||
}
|
||||
|
||||
#ifdef JIT_ENABLED
|
||||
JITArgs jitargs {
|
||||
static_cast<unsigned>(Config::JIT_MaxBlockSize),
|
||||
Config::JIT_LiteralOptimisations,
|
||||
Config::JIT_BranchOptimisations,
|
||||
Config::JIT_FastMemory,
|
||||
};
|
||||
NDS->SetJITArgs(Config::JIT_Enable ? std::make_optional(jitargs) : std::nullopt);
|
||||
#endif
|
||||
NDS->SetARM7BIOS(*arm7bios);
|
||||
NDS->SetARM9BIOS(*arm9bios);
|
||||
NDS->SetFirmware(std::move(*firmware));
|
||||
NDS->SetNDSCart(std::move(nextndscart));
|
||||
NDS->SPU.SetInterpolation(static_cast<AudioInterpolation>(Config::AudioInterp));
|
||||
NDS->SPU.SetDegrade10Bit(static_cast<AudioBitDepth>(Config::AudioBitDepth));
|
||||
|
||||
NDS::Current = NDS.get();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void EmuThread::run()
|
||||
{
|
||||
u32 mainScreenPos[3];
|
||||
Platform::FileHandle* file;
|
||||
|
||||
UpdateConsole(nullptr, nullptr);
|
||||
emuInstance->updateConsole(nullptr, nullptr);
|
||||
// No carts are inserted when melonDS first boots
|
||||
|
||||
mainScreenPos[0] = 0;
|
||||
|
@ -376,7 +172,7 @@ void EmuThread::run()
|
|||
|
||||
if (videoRenderer == 0)
|
||||
{ // If we're using the software renderer...
|
||||
NDS->GPU.SetRenderer3D(std::make_unique<SoftRenderer>(Config::Threaded3D != 0));
|
||||
emuInstance->nds->GPU.SetRenderer3D(std::make_unique<SoftRenderer>(Config::Threaded3D != 0));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -384,7 +180,7 @@ void EmuThread::run()
|
|||
|
||||
auto glrenderer = melonDS::GLRenderer::New();
|
||||
glrenderer->SetRenderSettings(Config::GL_BetterPolygons, Config::GL_ScaleFactor);
|
||||
NDS->GPU.SetRenderer3D(std::move(glrenderer));
|
||||
emuInstance->nds->GPU.SetRenderer3D(std::move(glrenderer));
|
||||
}
|
||||
|
||||
Input::Init();
|
||||
|
@ -404,7 +200,7 @@ void EmuThread::run()
|
|||
RTC::StateData state;
|
||||
Platform::FileRead(&state, sizeof(state), 1, file);
|
||||
Platform::CloseFile(file);
|
||||
NDS->RTC.SetState(state);
|
||||
emuInstance->nds->RTC.SetState(state);
|
||||
}
|
||||
|
||||
char melontitle[100];
|
||||
|
@ -431,7 +227,7 @@ void EmuThread::run()
|
|||
|
||||
if (Input::HotkeyPressed(HK_SolarSensorDecrease))
|
||||
{
|
||||
int level = NDS->GBACartSlot.SetInput(GBACart::Input_SolarSensorDown, true);
|
||||
int level = emuInstance->nds->GBACartSlot.SetInput(GBACart::Input_SolarSensorDown, true);
|
||||
if (level != -1)
|
||||
{
|
||||
//mainWindow->osdAddMessage(0, "Solar sensor level: %d", level);
|
||||
|
@ -439,48 +235,48 @@ void EmuThread::run()
|
|||
}
|
||||
if (Input::HotkeyPressed(HK_SolarSensorIncrease))
|
||||
{
|
||||
int level = NDS->GBACartSlot.SetInput(GBACart::Input_SolarSensorUp, true);
|
||||
int level = emuInstance->nds->GBACartSlot.SetInput(GBACart::Input_SolarSensorUp, true);
|
||||
if (level != -1)
|
||||
{
|
||||
//mainWindow->osdAddMessage(0, "Solar sensor level: %d", level);
|
||||
}
|
||||
}
|
||||
|
||||
if (NDS->ConsoleType == 1)
|
||||
if (emuInstance->nds->ConsoleType == 1)
|
||||
{
|
||||
DSi& dsi = static_cast<DSi&>(*NDS);
|
||||
DSi* dsi = static_cast<DSi*>(emuInstance->nds);
|
||||
double currentTime = SDL_GetPerformanceCounter() * perfCountsSec;
|
||||
|
||||
// Handle power button
|
||||
if (Input::HotkeyDown(HK_PowerButton))
|
||||
{
|
||||
dsi.I2C.GetBPTWL()->SetPowerButtonHeld(currentTime);
|
||||
dsi->I2C.GetBPTWL()->SetPowerButtonHeld(currentTime);
|
||||
}
|
||||
else if (Input::HotkeyReleased(HK_PowerButton))
|
||||
{
|
||||
dsi.I2C.GetBPTWL()->SetPowerButtonReleased(currentTime);
|
||||
dsi->I2C.GetBPTWL()->SetPowerButtonReleased(currentTime);
|
||||
}
|
||||
|
||||
// Handle volume buttons
|
||||
if (Input::HotkeyDown(HK_VolumeUp))
|
||||
{
|
||||
dsi.I2C.GetBPTWL()->SetVolumeSwitchHeld(DSi_BPTWL::volumeKey_Up);
|
||||
dsi->I2C.GetBPTWL()->SetVolumeSwitchHeld(DSi_BPTWL::volumeKey_Up);
|
||||
}
|
||||
else if (Input::HotkeyReleased(HK_VolumeUp))
|
||||
{
|
||||
dsi.I2C.GetBPTWL()->SetVolumeSwitchReleased(DSi_BPTWL::volumeKey_Up);
|
||||
dsi->I2C.GetBPTWL()->SetVolumeSwitchReleased(DSi_BPTWL::volumeKey_Up);
|
||||
}
|
||||
|
||||
if (Input::HotkeyDown(HK_VolumeDown))
|
||||
{
|
||||
dsi.I2C.GetBPTWL()->SetVolumeSwitchHeld(DSi_BPTWL::volumeKey_Down);
|
||||
dsi->I2C.GetBPTWL()->SetVolumeSwitchHeld(DSi_BPTWL::volumeKey_Down);
|
||||
}
|
||||
else if (Input::HotkeyReleased(HK_VolumeDown))
|
||||
{
|
||||
dsi.I2C.GetBPTWL()->SetVolumeSwitchReleased(DSi_BPTWL::volumeKey_Down);
|
||||
dsi->I2C.GetBPTWL()->SetVolumeSwitchReleased(DSi_BPTWL::volumeKey_Down);
|
||||
}
|
||||
|
||||
dsi.I2C.GetBPTWL()->ProcessVolumeSwitchInput(currentTime);
|
||||
dsi->I2C.GetBPTWL()->ProcessVolumeSwitchInput(currentTime);
|
||||
}
|
||||
|
||||
if (useOpenGL)
|
||||
|
@ -512,35 +308,35 @@ void EmuThread::run()
|
|||
|
||||
if (videoRenderer == 0)
|
||||
{ // If we're using the software renderer...
|
||||
NDS->GPU.SetRenderer3D(std::make_unique<SoftRenderer>(Config::Threaded3D != 0));
|
||||
emuInstance->nds->GPU.SetRenderer3D(std::make_unique<SoftRenderer>(Config::Threaded3D != 0));
|
||||
}
|
||||
else
|
||||
{
|
||||
auto glrenderer = melonDS::GLRenderer::New();
|
||||
glrenderer->SetRenderSettings(Config::GL_BetterPolygons, Config::GL_ScaleFactor);
|
||||
NDS->GPU.SetRenderer3D(std::move(glrenderer));
|
||||
emuInstance->nds->GPU.SetRenderer3D(std::move(glrenderer));
|
||||
}
|
||||
}
|
||||
|
||||
// process input and hotkeys
|
||||
NDS->SetKeyMask(Input::InputMask);
|
||||
emuInstance->nds->SetKeyMask(Input::InputMask);
|
||||
|
||||
if (Input::HotkeyPressed(HK_Lid))
|
||||
{
|
||||
bool lid = !NDS->IsLidClosed();
|
||||
NDS->SetLidClosed(lid);
|
||||
bool lid = !emuInstance->nds->IsLidClosed();
|
||||
emuInstance->nds->SetLidClosed(lid);
|
||||
//mainWindow->osdAddMessage(0, lid ? "Lid closed" : "Lid opened");
|
||||
}
|
||||
|
||||
// microphone input
|
||||
AudioInOut::MicProcess(*NDS);
|
||||
//AudioInOut::MicProcess(emuInstance->nds);
|
||||
|
||||
// auto screen layout
|
||||
if (Config::ScreenSizing == Frontend::screenSizing_Auto)
|
||||
{
|
||||
mainScreenPos[2] = mainScreenPos[1];
|
||||
mainScreenPos[1] = mainScreenPos[0];
|
||||
mainScreenPos[0] = NDS->PowerControl9 >> 15;
|
||||
mainScreenPos[0] = emuInstance->nds->PowerControl9 >> 15;
|
||||
|
||||
int guess;
|
||||
if (mainScreenPos[0] == mainScreenPos[2] &&
|
||||
|
@ -567,26 +363,26 @@ void EmuThread::run()
|
|||
|
||||
|
||||
// emulate
|
||||
u32 nlines = NDS->RunFrame();
|
||||
u32 nlines = emuInstance->nds->RunFrame();
|
||||
|
||||
if (ROMManager::NDSSave)
|
||||
ROMManager::NDSSave->CheckFlush();
|
||||
if (emuInstance->ndsSave)
|
||||
emuInstance->ndsSave->CheckFlush();
|
||||
|
||||
if (ROMManager::GBASave)
|
||||
ROMManager::GBASave->CheckFlush();
|
||||
if (emuInstance->gbaSave)
|
||||
emuInstance->gbaSave->CheckFlush();
|
||||
|
||||
if (ROMManager::FirmwareSave)
|
||||
ROMManager::FirmwareSave->CheckFlush();
|
||||
if (emuInstance->firmwareSave)
|
||||
emuInstance->firmwareSave->CheckFlush();
|
||||
|
||||
if (!useOpenGL)
|
||||
{
|
||||
FrontBufferLock.lock();
|
||||
FrontBuffer = NDS->GPU.FrontBuffer;
|
||||
FrontBuffer = emuInstance->nds->GPU.FrontBuffer;
|
||||
FrontBufferLock.unlock();
|
||||
}
|
||||
else
|
||||
{
|
||||
FrontBuffer = NDS->GPU.FrontBuffer;
|
||||
FrontBuffer = emuInstance->nds->GPU.FrontBuffer;
|
||||
//screenGL->drawScreenGL();
|
||||
for (auto window : windowList)
|
||||
window->drawScreenGL();
|
||||
|
@ -614,10 +410,10 @@ void EmuThread::run()
|
|||
window->setGLSwapInterval(0);
|
||||
}
|
||||
|
||||
if (Config::DSiVolumeSync && NDS->ConsoleType == 1)
|
||||
if (Config::DSiVolumeSync && emuInstance->nds->ConsoleType == 1)
|
||||
{
|
||||
DSi& dsi = static_cast<DSi&>(*NDS);
|
||||
u8 volumeLevel = dsi.I2C.GetBPTWL()->GetVolumeLevel();
|
||||
DSi* dsi = static_cast<DSi*>(emuInstance->nds);
|
||||
u8 volumeLevel = dsi->I2C.GetBPTWL()->GetVolumeLevel();
|
||||
if (volumeLevel != dsiVolumeLevel)
|
||||
{
|
||||
dsiVolumeLevel = volumeLevel;
|
||||
|
@ -627,8 +423,8 @@ void EmuThread::run()
|
|||
Config::AudioVolume = volumeLevel * (256.0 / 31.0);
|
||||
}
|
||||
|
||||
if (Config::AudioSync && !fastforward)
|
||||
AudioInOut::AudioSync(*this->NDS);
|
||||
//if (Config::AudioSync && !fastforward)
|
||||
// AudioInOut::AudioSync(emuInstance->nds);
|
||||
|
||||
double frametimeStep = nlines / (60.0 * 263.0);
|
||||
|
||||
|
@ -734,7 +530,7 @@ void EmuThread::run()
|
|||
if (file)
|
||||
{
|
||||
RTC::StateData state;
|
||||
NDS->RTC.GetState(state);
|
||||
emuInstance->nds->RTC.GetState(state);
|
||||
Platform::FileWrite(&state, sizeof(state), 1, file);
|
||||
Platform::CloseFile(file);
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ namespace melonDS
|
|||
class NDS;
|
||||
}
|
||||
|
||||
class EmuInstance;
|
||||
class MainWindow;
|
||||
class ScreenPanelGL;
|
||||
|
||||
|
@ -47,7 +48,7 @@ class EmuThread : public QThread
|
|||
void run() override;
|
||||
|
||||
public:
|
||||
explicit EmuThread(QObject* parent = nullptr);
|
||||
explicit EmuThread(EmuInstance* inst, QObject* parent = nullptr);
|
||||
|
||||
void attachWindow(MainWindow* window);
|
||||
void detachWindow(MainWindow* window);
|
||||
|
@ -70,13 +71,6 @@ public:
|
|||
int FrontBuffer = 0;
|
||||
QMutex FrontBufferLock;
|
||||
|
||||
/// Applies the config in args.
|
||||
/// Creates a new NDS console if needed,
|
||||
/// modifies the existing one if possible.
|
||||
/// @return \c true if the console was updated.
|
||||
/// If this returns \c false, then the existing NDS console is not modified.
|
||||
bool UpdateConsole(UpdateConsoleNDSArgs&& ndsargs, UpdateConsoleGBAArgs&& gbaargs) noexcept;
|
||||
std::unique_ptr<melonDS::NDS> NDS; // TODO: Proper encapsulation and synchronization
|
||||
signals:
|
||||
void windowUpdate();
|
||||
void windowTitleChange(QString title);
|
||||
|
@ -99,11 +93,6 @@ signals:
|
|||
void syncVolumeLevel();
|
||||
|
||||
private:
|
||||
std::unique_ptr<melonDS::NDS> CreateConsole(
|
||||
std::unique_ptr<melonDS::NDSCart::CartCommon>&& ndscart,
|
||||
std::unique_ptr<melonDS::GBACart::CartCommon>&& gbacart
|
||||
) noexcept;
|
||||
|
||||
enum EmuStatusKind
|
||||
{
|
||||
emuStatus_Exit,
|
||||
|
@ -128,6 +117,8 @@ private:
|
|||
};
|
||||
std::atomic<ContextRequestKind> ContextRequest = contextRequest_None;
|
||||
|
||||
EmuInstance* emuInstance;
|
||||
|
||||
//ScreenPanelGL* screenGL;
|
||||
MainWindow* mainWindow;
|
||||
std::list<MainWindow*> windowList;
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#include <QImage>
|
||||
|
||||
#include "types.h"
|
||||
#include "ROMManager.h"
|
||||
|
||||
namespace Ui { class ROMInfoDialog; }
|
||||
class ROMInfoDialog;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,102 +0,0 @@
|
|||
/*
|
||||
Copyright 2016-2023 melonDS team
|
||||
|
||||
This file is part of melonDS.
|
||||
|
||||
melonDS is free software: you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free
|
||||
Software Foundation, either version 3 of the License, or (at your option)
|
||||
any later version.
|
||||
|
||||
melonDS is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with melonDS. If not, see http://www.gnu.org/licenses/.
|
||||
*/
|
||||
|
||||
#ifndef ROMMANAGER_H
|
||||
#define ROMMANAGER_H
|
||||
|
||||
#include "types.h"
|
||||
#include "SaveManager.h"
|
||||
#include "AREngine.h"
|
||||
#include "DSi_NAND.h"
|
||||
#include <QMainWindow>
|
||||
|
||||
#include "MemConstants.h"
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
namespace melonDS
|
||||
{
|
||||
class NDS;
|
||||
class DSi;
|
||||
class FATStorage;
|
||||
class FATStorageArgs;
|
||||
}
|
||||
class EmuThread;
|
||||
namespace ROMManager
|
||||
{
|
||||
|
||||
using namespace melonDS;
|
||||
extern std::unique_ptr<SaveManager> NDSSave;
|
||||
extern std::unique_ptr<SaveManager> GBASave;
|
||||
extern std::unique_ptr<SaveManager> FirmwareSave;
|
||||
|
||||
QString VerifySetup();
|
||||
void Reset(EmuThread* thread);
|
||||
|
||||
/// Boots the emulated console into its system menu without starting a game.
|
||||
bool BootToMenu(EmuThread* thread);
|
||||
void ClearBackupState();
|
||||
|
||||
/// Returns the configured ARM9 BIOS loaded from disk,
|
||||
/// the FreeBIOS if external BIOS is disabled and we're in NDS mode,
|
||||
/// or nullopt if loading failed.
|
||||
std::optional<std::array<u8, ARM9BIOSSize>> LoadARM9BIOS() noexcept;
|
||||
std::optional<std::array<u8, ARM7BIOSSize>> LoadARM7BIOS() noexcept;
|
||||
std::optional<std::array<u8, DSiBIOSSize>> LoadDSiARM9BIOS() noexcept;
|
||||
std::optional<std::array<u8, DSiBIOSSize>> LoadDSiARM7BIOS() noexcept;
|
||||
std::optional<FATStorageArgs> GetDSiSDCardArgs() noexcept;
|
||||
std::optional<FATStorage> LoadDSiSDCard() noexcept;
|
||||
std::optional<FATStorageArgs> GetDLDISDCardArgs() noexcept;
|
||||
std::optional<FATStorage> LoadDLDISDCard() noexcept;
|
||||
void CustomizeFirmware(Firmware& firmware) noexcept;
|
||||
Firmware GenerateFirmware(int type) noexcept;
|
||||
/// Loads and customizes a firmware image based on the values in Config
|
||||
std::optional<Firmware> LoadFirmware(int type) noexcept;
|
||||
/// Loads and customizes a NAND image based on the values in Config
|
||||
std::optional<DSi_NAND::NANDImage> LoadNAND(const std::array<u8, DSiBIOSSize>& arm7ibios) noexcept;
|
||||
|
||||
/// Inserts a ROM into the emulated console.
|
||||
bool LoadROM(QMainWindow* mainWindow, EmuThread*, QStringList filepath, bool reset);
|
||||
void EjectCart(NDS& nds);
|
||||
bool CartInserted();
|
||||
QString CartLabel();
|
||||
|
||||
bool LoadGBAROM(QMainWindow* mainWindow, NDS& nds, QStringList filepath);
|
||||
void LoadGBAAddon(NDS& nds, int type);
|
||||
void EjectGBACart(NDS& nds);
|
||||
bool GBACartInserted();
|
||||
QString GBACartLabel();
|
||||
|
||||
std::string GetSavestateName(int slot);
|
||||
bool SavestateExists(int slot);
|
||||
bool LoadState(NDS& nds, const std::string& filename);
|
||||
bool SaveState(NDS& nds, const std::string& filename);
|
||||
void UndoStateLoad(NDS& nds);
|
||||
|
||||
void EnableCheats(NDS& nds, bool enable);
|
||||
ARCodeFile* GetCheatFile();
|
||||
|
||||
void ROMIcon(const u8 (&data)[512], const u16 (&palette)[16], u32 (&iconRef)[32*32]);
|
||||
void AnimatedROMIcon(const u8 (&data)[8][512], const u16 (&palette)[8][16],
|
||||
const u16 (&sequence)[64], u32 (&animatedIconRef)[64][32*32],
|
||||
std::vector<int> &animatedSequenceRef);
|
||||
}
|
||||
|
||||
#endif // ROMMANAGER_H
|
|
@ -77,7 +77,7 @@
|
|||
|
||||
//#include "main_shaders.h"
|
||||
|
||||
#include "ROMManager.h"
|
||||
#include "EmuInstance.h"
|
||||
#include "ArchiveUtil.h"
|
||||
#include "CameraManager.h"
|
||||
|
||||
|
@ -198,8 +198,10 @@ static void signalHandler(int)
|
|||
|
||||
int test = 0;
|
||||
|
||||
MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent)
|
||||
MainWindow::MainWindow(EmuInstance* inst, QWidget* parent) : QMainWindow(parent)
|
||||
{
|
||||
emuInstance = inst;
|
||||
|
||||
test_num = test++;
|
||||
#ifndef _WIN32
|
||||
if (!parent)
|
||||
|
@ -231,7 +233,7 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent)
|
|||
setAcceptDrops(true);
|
||||
setFocusPolicy(Qt::ClickFocus);
|
||||
|
||||
int inst = Platform::InstanceID();
|
||||
//int inst = Platform::InstanceID();
|
||||
|
||||
QMenuBar* menubar = new QMenuBar();
|
||||
{
|
||||
|
@ -260,7 +262,7 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent)
|
|||
|
||||
menu->addSeparator();
|
||||
|
||||
actCurrentCart = menu->addAction("DS slot: " + ROMManager::CartLabel());
|
||||
actCurrentCart = menu->addAction("DS slot: " + emuInstance->cartLabel());
|
||||
actCurrentCart->setEnabled(false);
|
||||
|
||||
actInsertCart = menu->addAction("Insert cart...");
|
||||
|
@ -271,7 +273,7 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent)
|
|||
|
||||
menu->addSeparator();
|
||||
|
||||
actCurrentGBACart = menu->addAction("GBA slot: " + ROMManager::GBACartLabel());
|
||||
actCurrentGBACart = menu->addAction("GBA slot: " + emuInstance->gbaCartLabel());
|
||||
actCurrentGBACart->setEnabled(false);
|
||||
|
||||
actInsertGBACart = menu->addAction("Insert ROM cart...");
|
||||
|
@ -675,7 +677,7 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent)
|
|||
actLimitFramerate->setChecked(Config::LimitFPS);
|
||||
actAudioSync->setChecked(Config::AudioSync);
|
||||
|
||||
if (inst > 0)
|
||||
if (emuInstance->instanceID > 0)
|
||||
{
|
||||
actEmuSettings->setEnabled(false);
|
||||
actVideoSettings->setEnabled(false);
|
||||
|
@ -900,7 +902,7 @@ void MainWindow::dropEvent(QDropEvent* event)
|
|||
|
||||
if (isNdsRom)
|
||||
{
|
||||
if (!ROMManager::LoadROM(mainWindow, emuThread, file, true))
|
||||
if (!emuInstance->loadROM(file, true))
|
||||
{
|
||||
emuThread->emuUnpause();
|
||||
return;
|
||||
|
@ -911,15 +913,15 @@ void MainWindow::dropEvent(QDropEvent* event)
|
|||
recentFileList.prepend(barredFilename);
|
||||
updateRecentFilesMenu();
|
||||
|
||||
assert(emuThread->NDS != nullptr);
|
||||
emuThread->NDS->Start();
|
||||
assert(emuInstance->nds != nullptr);
|
||||
emuInstance->nds->Start();
|
||||
emuThread->emuRun();
|
||||
|
||||
updateCartInserted(false);
|
||||
}
|
||||
else if (isGbaRom)
|
||||
{
|
||||
if (!ROMManager::LoadGBAROM(mainWindow, *emuThread->NDS, file))
|
||||
if (!emuInstance->loadGBAROM(file))
|
||||
{
|
||||
emuThread->emuUnpause();
|
||||
return;
|
||||
|
@ -963,7 +965,7 @@ void MainWindow::onAppStateChanged(Qt::ApplicationState state)
|
|||
|
||||
bool MainWindow::verifySetup()
|
||||
{
|
||||
QString res = ROMManager::VerifySetup();
|
||||
QString res = emuInstance->verifySetup();
|
||||
if (!res.isEmpty())
|
||||
{
|
||||
QMessageBox::critical(this, "melonDS", res);
|
||||
|
@ -983,7 +985,7 @@ bool MainWindow::preloadROMs(QStringList file, QStringList gbafile, bool boot)
|
|||
bool gbaloaded = false;
|
||||
if (!gbafile.isEmpty())
|
||||
{
|
||||
if (!ROMManager::LoadGBAROM(mainWindow, *emuThread->NDS, gbafile)) return false;
|
||||
if (!emuInstance->loadGBAROM(gbafile)) return false;
|
||||
|
||||
gbaloaded = true;
|
||||
}
|
||||
|
@ -991,7 +993,7 @@ bool MainWindow::preloadROMs(QStringList file, QStringList gbafile, bool boot)
|
|||
bool ndsloaded = false;
|
||||
if (!file.isEmpty())
|
||||
{
|
||||
if (!ROMManager::LoadROM(mainWindow, emuThread, file, true)) return false;
|
||||
if (!emuInstance->loadROM(file, true)) return false;
|
||||
|
||||
recentFileList.removeAll(file.join("|"));
|
||||
recentFileList.prepend(file.join("|"));
|
||||
|
@ -1003,7 +1005,7 @@ bool MainWindow::preloadROMs(QStringList file, QStringList gbafile, bool boot)
|
|||
{
|
||||
if (ndsloaded)
|
||||
{
|
||||
emuThread->NDS->Start();
|
||||
emuInstance->nds->Start();
|
||||
emuThread->emuRun();
|
||||
}
|
||||
else
|
||||
|
@ -1163,14 +1165,14 @@ void MainWindow::updateCartInserted(bool gba)
|
|||
bool inserted;
|
||||
if (gba)
|
||||
{
|
||||
inserted = ROMManager::GBACartInserted() && (Config::ConsoleType == 0);
|
||||
actCurrentGBACart->setText("GBA slot: " + ROMManager::GBACartLabel());
|
||||
inserted = emuInstance->gbaCartInserted() && (Config::ConsoleType == 0);
|
||||
actCurrentGBACart->setText("GBA slot: " + emuInstance->gbaCartLabel());
|
||||
actEjectGBACart->setEnabled(inserted);
|
||||
}
|
||||
else
|
||||
{
|
||||
inserted = ROMManager::CartInserted();
|
||||
actCurrentCart->setText("DS slot: " + ROMManager::CartLabel());
|
||||
inserted = emuInstance->cartInserted();
|
||||
actCurrentCart->setText("DS slot: " + emuInstance->cartLabel());
|
||||
actEjectCart->setEnabled(inserted);
|
||||
actImportSavefile->setEnabled(inserted);
|
||||
actSetupCheats->setEnabled(inserted);
|
||||
|
@ -1196,7 +1198,7 @@ void MainWindow::onOpenFile()
|
|||
return;
|
||||
}
|
||||
|
||||
if (!ROMManager::LoadROM(mainWindow, emuThread, file, true))
|
||||
if (!emuInstance->loadROM(file, true))
|
||||
{
|
||||
emuThread->emuUnpause();
|
||||
return;
|
||||
|
@ -1207,8 +1209,8 @@ void MainWindow::onOpenFile()
|
|||
recentFileList.prepend(filename);
|
||||
updateRecentFilesMenu();
|
||||
|
||||
assert(emuThread->NDS != nullptr);
|
||||
emuThread->NDS->Start();
|
||||
assert(emuInstance->nds != nullptr);
|
||||
emuInstance->nds->Start();
|
||||
emuThread->emuRun();
|
||||
|
||||
updateCartInserted(false);
|
||||
|
@ -1293,7 +1295,7 @@ void MainWindow::onClickRecentFile()
|
|||
return;
|
||||
}
|
||||
|
||||
if (!ROMManager::LoadROM(mainWindow, emuThread, file, true))
|
||||
if (!emuInstance->loadROM(file, true))
|
||||
{
|
||||
emuThread->emuUnpause();
|
||||
return;
|
||||
|
@ -1303,8 +1305,8 @@ void MainWindow::onClickRecentFile()
|
|||
recentFileList.prepend(filename);
|
||||
updateRecentFilesMenu();
|
||||
|
||||
assert(emuThread->NDS != nullptr);
|
||||
emuThread->NDS->Start();
|
||||
assert(emuInstance->nds != nullptr);
|
||||
emuInstance->nds->Start();
|
||||
emuThread->emuRun();
|
||||
|
||||
updateCartInserted(false);
|
||||
|
@ -1320,7 +1322,7 @@ void MainWindow::onBootFirmware()
|
|||
return;
|
||||
}
|
||||
|
||||
if (!ROMManager::BootToMenu(emuThread))
|
||||
if (!emuInstance->bootToMenu())
|
||||
{
|
||||
// TODO: better error reporting?
|
||||
QMessageBox::critical(this, "melonDS", "This firmware is not bootable.");
|
||||
|
@ -1328,8 +1330,8 @@ void MainWindow::onBootFirmware()
|
|||
return;
|
||||
}
|
||||
|
||||
assert(emuThread->NDS != nullptr);
|
||||
emuThread->NDS->Start();
|
||||
assert(emuInstance->nds != nullptr);
|
||||
emuInstance->nds->Start();
|
||||
emuThread->emuRun();
|
||||
}
|
||||
|
||||
|
@ -1344,7 +1346,7 @@ void MainWindow::onInsertCart()
|
|||
return;
|
||||
}
|
||||
|
||||
if (!ROMManager::LoadROM(mainWindow, emuThread, file, false))
|
||||
if (!emuInstance->loadROM(file, false))
|
||||
{
|
||||
emuThread->emuUnpause();
|
||||
return;
|
||||
|
@ -1359,7 +1361,7 @@ void MainWindow::onEjectCart()
|
|||
{
|
||||
emuThread->emuPause();
|
||||
|
||||
ROMManager::EjectCart(*emuThread->NDS);
|
||||
emuInstance->ejectCart();
|
||||
|
||||
emuThread->emuUnpause();
|
||||
|
||||
|
@ -1377,7 +1379,7 @@ void MainWindow::onInsertGBACart()
|
|||
return;
|
||||
}
|
||||
|
||||
if (!ROMManager::LoadGBAROM(mainWindow, *emuThread->NDS, file))
|
||||
if (!emuInstance->loadGBAROM(file))
|
||||
{
|
||||
emuThread->emuUnpause();
|
||||
return;
|
||||
|
@ -1395,7 +1397,7 @@ void MainWindow::onInsertGBAAddon()
|
|||
|
||||
emuThread->emuPause();
|
||||
|
||||
ROMManager::LoadGBAAddon(*emuThread->NDS, type);
|
||||
emuInstance->loadGBAAddon(type);
|
||||
|
||||
emuThread->emuUnpause();
|
||||
|
||||
|
@ -1406,7 +1408,7 @@ void MainWindow::onEjectGBACart()
|
|||
{
|
||||
emuThread->emuPause();
|
||||
|
||||
ROMManager::EjectGBACart(*emuThread->NDS);
|
||||
emuInstance->ejectGBACart();
|
||||
|
||||
emuThread->emuUnpause();
|
||||
|
||||
|
@ -1422,7 +1424,7 @@ void MainWindow::onSaveState()
|
|||
std::string filename;
|
||||
if (slot > 0)
|
||||
{
|
||||
filename = ROMManager::GetSavestateName(slot);
|
||||
filename = emuInstance->getSavestateName(slot);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1440,7 +1442,7 @@ void MainWindow::onSaveState()
|
|||
filename = qfilename.toStdString();
|
||||
}
|
||||
|
||||
if (ROMManager::SaveState(*emuThread->NDS, filename))
|
||||
if (emuInstance->saveState(filename))
|
||||
{
|
||||
if (slot > 0) osdAddMessage(0, "State saved to slot %d", slot);
|
||||
else osdAddMessage(0, "State saved to file");
|
||||
|
@ -1464,7 +1466,7 @@ void MainWindow::onLoadState()
|
|||
std::string filename;
|
||||
if (slot > 0)
|
||||
{
|
||||
filename = ROMManager::GetSavestateName(slot);
|
||||
filename = emuInstance->getSavestateName(slot);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1491,7 +1493,7 @@ void MainWindow::onLoadState()
|
|||
return;
|
||||
}
|
||||
|
||||
if (ROMManager::LoadState(*emuThread->NDS, filename))
|
||||
if (emuInstance->loadState(filename))
|
||||
{
|
||||
if (slot > 0) osdAddMessage(0, "State loaded from slot %d", slot);
|
||||
else osdAddMessage(0, "State loaded from file");
|
||||
|
@ -1509,7 +1511,7 @@ void MainWindow::onLoadState()
|
|||
void MainWindow::onUndoStateLoad()
|
||||
{
|
||||
emuThread->emuPause();
|
||||
ROMManager::UndoStateLoad(*emuThread->NDS);
|
||||
emuInstance->undoStateLoad();
|
||||
emuThread->emuUnpause();
|
||||
|
||||
osdAddMessage(0, "State load undone");
|
||||
|
@ -1548,7 +1550,7 @@ void MainWindow::onImportSavefile()
|
|||
return;
|
||||
}
|
||||
|
||||
ROMManager::Reset(emuThread);
|
||||
emuInstance->reset();
|
||||
}
|
||||
|
||||
u32 len = FileLength(f);
|
||||
|
@ -1557,8 +1559,8 @@ void MainWindow::onImportSavefile()
|
|||
Platform::FileRewind(f);
|
||||
Platform::FileRead(data.get(), len, 1, f);
|
||||
|
||||
assert(emuThread->NDS != nullptr);
|
||||
emuThread->NDS->SetNDSSave(data.get(), len);
|
||||
assert(emuInstance->nds != nullptr);
|
||||
emuInstance->nds->SetNDSSave(data.get(), len);
|
||||
|
||||
CloseFile(f);
|
||||
emuThread->emuUnpause();
|
||||
|
@ -1599,7 +1601,7 @@ void MainWindow::onReset()
|
|||
|
||||
actUndoStateLoad->setEnabled(false);
|
||||
|
||||
ROMManager::Reset(emuThread);
|
||||
emuInstance->reset();
|
||||
|
||||
osdAddMessage(0, "Reset");
|
||||
emuThread->emuRun();
|
||||
|
@ -1610,7 +1612,7 @@ void MainWindow::onStop()
|
|||
if (!RunningSomething) return;
|
||||
|
||||
emuThread->emuPause();
|
||||
emuThread->NDS->Stop();
|
||||
emuInstance->nds->Stop();
|
||||
}
|
||||
|
||||
void MainWindow::onFrameStep()
|
||||
|
@ -1633,7 +1635,7 @@ void MainWindow::onOpenPowerManagement()
|
|||
void MainWindow::onEnableCheats(bool checked)
|
||||
{
|
||||
Config::EnableCheats = checked?1:0;
|
||||
ROMManager::EnableCheats(*emuThread->NDS, Config::EnableCheats != 0);
|
||||
emuInstance->enableCheats(Config::EnableCheats != 0);
|
||||
}
|
||||
|
||||
void MainWindow::onSetupCheats()
|
||||
|
@ -1651,7 +1653,7 @@ void MainWindow::onCheatsDialogFinished(int res)
|
|||
|
||||
void MainWindow::onROMInfo()
|
||||
{
|
||||
auto cart = emuThread->NDS->NDSCartSlot.GetCart();
|
||||
auto cart = emuInstance->nds->NDSCartSlot.GetCart();
|
||||
if (cart)
|
||||
ROMInfoDialog* dlg = ROMInfoDialog::openDlg(this, *cart);
|
||||
}
|
||||
|
@ -1707,13 +1709,13 @@ void MainWindow::onEmuSettingsDialogFinished(int res)
|
|||
actInsertGBACart->setEnabled(true);
|
||||
for (int i = 0; i < 1; i++)
|
||||
actInsertGBAAddon[i]->setEnabled(true);
|
||||
actEjectGBACart->setEnabled(ROMManager::GBACartInserted());
|
||||
actEjectGBACart->setEnabled(emuInstance->gbaCartInserted());
|
||||
}
|
||||
|
||||
if (EmuSettingsDialog::needsReset)
|
||||
onReset();
|
||||
|
||||
actCurrentGBACart->setText("GBA slot: " + ROMManager::GBACartLabel());
|
||||
actCurrentGBACart->setText("GBA slot: " + emuInstance->gbaCartLabel());
|
||||
|
||||
if (!RunningSomething)
|
||||
actTitleManager->setEnabled(!Config::DSiNANDPath.empty());
|
||||
|
@ -1802,18 +1804,18 @@ void MainWindow::onPathSettingsFinished(int res)
|
|||
|
||||
void MainWindow::onUpdateAudioSettings()
|
||||
{
|
||||
assert(emuThread->NDS != nullptr);
|
||||
emuThread->NDS->SPU.SetInterpolation(static_cast<AudioInterpolation>(Config::AudioInterp));
|
||||
assert(emuInstance->nds != nullptr);
|
||||
emuInstance->nds->SPU.SetInterpolation(static_cast<AudioInterpolation>(Config::AudioInterp));
|
||||
|
||||
if (Config::AudioBitDepth == 0)
|
||||
emuThread->NDS->SPU.SetDegrade10Bit(emuThread->NDS->ConsoleType == 0);
|
||||
emuInstance->nds->SPU.SetDegrade10Bit(emuInstance->nds->ConsoleType == 0);
|
||||
else
|
||||
emuThread->NDS->SPU.SetDegrade10Bit(Config::AudioBitDepth == 1);
|
||||
emuInstance->nds->SPU.SetDegrade10Bit(Config::AudioBitDepth == 1);
|
||||
}
|
||||
|
||||
void MainWindow::onAudioSettingsFinished(int res)
|
||||
{
|
||||
AudioInOut::UpdateSettings(*emuThread->NDS);
|
||||
//AudioInOut::UpdateSettings(*emuThread->NDS);
|
||||
}
|
||||
|
||||
void MainWindow::onOpenMPSettings()
|
||||
|
@ -2029,7 +2031,7 @@ void MainWindow::onEmuStart()
|
|||
for (int i = 1; i < 9; i++)
|
||||
{
|
||||
actSaveState[i]->setEnabled(true);
|
||||
actLoadState[i]->setEnabled(ROMManager::SavestateExists(i));
|
||||
actLoadState[i]->setEnabled(emuInstance->savestateExists(i));
|
||||
}
|
||||
actSaveState[0]->setEnabled(true);
|
||||
actLoadState[0]->setEnabled(true);
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "Screen.h"
|
||||
|
||||
|
||||
class EmuInstance;
|
||||
class EmuThread;
|
||||
|
||||
/*
|
||||
|
@ -100,7 +101,7 @@ class MainWindow : public QMainWindow
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget* parent = nullptr);
|
||||
explicit MainWindow(EmuInstance* inst, QWidget* parent = nullptr);
|
||||
~MainWindow();
|
||||
|
||||
void attachEmuThread(EmuThread* thread);
|
||||
|
@ -236,6 +237,8 @@ private:
|
|||
|
||||
int test_num;
|
||||
|
||||
EmuInstance* emuInstance;
|
||||
|
||||
EmuThread* emuThread;
|
||||
|
||||
public:
|
||||
|
|
|
@ -100,7 +100,7 @@
|
|||
|
||||
//#include "main_shaders.h"
|
||||
|
||||
#include "ROMManager.h"
|
||||
#include "EmuInstance.h"
|
||||
#include "ArchiveUtil.h"
|
||||
#include "CameraManager.h"
|
||||
|
||||
|
@ -161,8 +161,9 @@ QStringList ArchiveExtensions
|
|||
|
||||
bool RunningSomething;
|
||||
|
||||
MainWindow* mainWindow;
|
||||
EmuThread* emuThread;
|
||||
//MainWindow* mainWindow;
|
||||
//EmuThread* emuThread;
|
||||
EmuInstance* testinst;
|
||||
|
||||
int autoScreenSizing = 0;
|
||||
|
||||
|
@ -258,7 +259,7 @@ void emuStop()
|
|||
{
|
||||
RunningSomething = false;
|
||||
|
||||
emit emuThread->windowEmuStop();
|
||||
//emit emuThread->windowEmuStop();
|
||||
}
|
||||
|
||||
MelonApplication::MelonApplication(int& argc, char** argv)
|
||||
|
@ -278,10 +279,10 @@ bool MelonApplication::event(QEvent *event)
|
|||
{
|
||||
QFileOpenEvent *openEvent = static_cast<QFileOpenEvent*>(event);
|
||||
|
||||
emuThread->emuPause();
|
||||
/*emuThread->emuPause();
|
||||
const QStringList file = mainWindow->splitArchivePath(openEvent->file(), true);
|
||||
if (!mainWindow->preloadROMs(file, {}, true))
|
||||
emuThread->emuUnpause();
|
||||
emuThread->emuUnpause();*/
|
||||
}
|
||||
|
||||
return QApplication::event(event);
|
||||
|
@ -375,7 +376,7 @@ int main(int argc, char** argv)
|
|||
Input::JoystickID = Config::JoystickID;
|
||||
Input::OpenJoystick();
|
||||
|
||||
mainWindow = new MainWindow();
|
||||
/* mainWindow = new MainWindow();
|
||||
if (options->fullscreen)
|
||||
ToggleFullscreen(mainWindow);
|
||||
|
||||
|
@ -385,9 +386,11 @@ int main(int argc, char** argv)
|
|||
emuThread->attachWindow(mainWindow);
|
||||
emuThread->attachWindow(poop);
|
||||
emuThread->start();
|
||||
emuThread->emuPause();
|
||||
emuThread->emuPause();*/
|
||||
|
||||
AudioInOut::Init(emuThread);
|
||||
testinst = new EmuInstance(0);
|
||||
|
||||
/*AudioInOut::Init(emuThread);
|
||||
ROMManager::EnableCheats(*emuThread->NDS, Config::EnableCheats != 0);
|
||||
AudioInOut::AudioMute(mainWindow);
|
||||
|
||||
|
@ -412,15 +415,16 @@ int main(int argc, char** argv)
|
|||
|
||||
if (memberSyntaxUsed) printf("Warning: use the a.zip|b.nds format at your own risk!\n");
|
||||
|
||||
mainWindow->preloadROMs(dsfile, gbafile, options->boot);
|
||||
mainWindow->preloadROMs(dsfile, gbafile, options->boot);*/
|
||||
|
||||
int ret = melon.exec();
|
||||
|
||||
delete options;
|
||||
|
||||
emuThread->emuStop();
|
||||
/*emuThread->emuStop();
|
||||
emuThread->wait();
|
||||
delete emuThread;
|
||||
delete emuThread;*/
|
||||
delete testinst;
|
||||
|
||||
Input::CloseJoystick();
|
||||
|
||||
|
|
Loading…
Reference in New Issue