more work

aaaaaaaa
This commit is contained in:
Arisotura 2024-05-16 21:20:10 +02:00
parent d10b5f8b8a
commit 10380320c5
11 changed files with 129 additions and 2076 deletions

View File

@ -7,6 +7,7 @@ set(SOURCES_QT_SDL
main_shaders.h main_shaders.h
Screen.cpp Screen.cpp
Window.cpp Window.cpp
EmuInstance.cpp
EmuThread.cpp EmuThread.cpp
CheatsDialog.cpp CheatsDialog.cpp
Config.cpp Config.cpp
@ -36,7 +37,6 @@ set(SOURCES_QT_SDL
font.h font.h
Platform.cpp Platform.cpp
QPathInput.h QPathInput.h
ROMManager.cpp
SaveManager.cpp SaveManager.cpp
CameraManager.cpp CameraManager.cpp
AudioInOut.cpp AudioInOut.cpp

View File

@ -24,7 +24,7 @@
#include "types.h" #include "types.h"
#include "Platform.h" #include "Platform.h"
#include "Config.h" #include "Config.h"
#include "ROMManager.h" #include "EmuInstance.h"
#include "CheatsDialog.h" #include "CheatsDialog.h"
#include "ui_CheatsDialog.h" #include "ui_CheatsDialog.h"
@ -43,6 +43,9 @@ CheatsDialog::CheatsDialog(QWidget* parent) : QDialog(parent), ui(new Ui::Cheats
ui->setupUi(this); ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
MainWindow* win = (MainWindow*)parent;
//
codeFile = ROMManager::GetCheatFile(); codeFile = ROMManager::GetCheatFile();
QStandardItemModel* model = new QStandardItemModel(); QStandardItemModel* model = new QStandardItemModel();

View File

@ -38,6 +38,8 @@ public:
// return: empty string = setup OK, non-empty = error message // return: empty string = setup OK, non-empty = error message
QString verifySetup(); QString verifySetup();
bool updateConsole(UpdateConsoleNDSArgs&& ndsargs, UpdateConsoleGBAArgs&& gbaargs) noexcept;
private: private:
static int lastSep(const std::string& path); static int lastSep(const std::string& path);
std::string getAssetPath(bool gba, const std::string& configpath, const std::string& ext, const std::string& file); 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(); melonDS::ARCodeFile* getCheatFile();
void setBatteryLevels(); void setBatteryLevels();
void setDateTime(); void setDateTime();
bool updateConsole(UpdateConsoleNDSArgs&& ndsargs, UpdateConsoleGBAArgs&& gbaargs) noexcept;
void reset(); void reset();
bool bootToMenu(); bool bootToMenu();
melonDS::u32 decompressROM(const melonDS::u8* inContent, const melonDS::u32 inSize, std::unique_ptr<melonDS::u8[]>& outContent); 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; melonDS::ARCodeFile* cheatFile;
bool cheatsOn; bool cheatsOn;
friend class EmuThread;
friend class MainWindow;
}; };
#endif //EMUINSTANCE_H #endif //EMUINSTANCE_H

View File

@ -55,7 +55,7 @@
#include "Savestate.h" #include "Savestate.h"
#include "ROMManager.h" #include "EmuInstance.h"
//#include "ArchiveUtil.h" //#include "ArchiveUtil.h"
//#include "CameraManager.h" //#include "CameraManager.h"
@ -72,8 +72,10 @@ extern int videoRenderer;
extern bool videoSettingsDirty; extern bool videoSettingsDirty;
EmuThread::EmuThread(QObject* parent) : QThread(parent) EmuThread::EmuThread(EmuInstance* inst, QObject* parent) : QThread(parent)
{ {
emuInstance = inst;
EmuStatus = emuStatus_Exit; EmuStatus = emuStatus_Exit;
EmuRunning = emuStatus_Paused; EmuRunning = emuStatus_Paused;
EmuPauseStack = EmuPauseStackRunning; EmuPauseStack = EmuPauseStackRunning;
@ -133,218 +135,12 @@ void EmuThread::detachWindow(MainWindow* window)
mainWindow = windowList.front(); 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() void EmuThread::run()
{ {
u32 mainScreenPos[3]; u32 mainScreenPos[3];
Platform::FileHandle* file; Platform::FileHandle* file;
UpdateConsole(nullptr, nullptr); emuInstance->updateConsole(nullptr, nullptr);
// No carts are inserted when melonDS first boots // No carts are inserted when melonDS first boots
mainScreenPos[0] = 0; mainScreenPos[0] = 0;
@ -376,7 +172,7 @@ void EmuThread::run()
if (videoRenderer == 0) if (videoRenderer == 0)
{ // If we're using the software renderer... { // 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 else
{ {
@ -384,7 +180,7 @@ void EmuThread::run()
auto glrenderer = melonDS::GLRenderer::New(); auto glrenderer = melonDS::GLRenderer::New();
glrenderer->SetRenderSettings(Config::GL_BetterPolygons, Config::GL_ScaleFactor); glrenderer->SetRenderSettings(Config::GL_BetterPolygons, Config::GL_ScaleFactor);
NDS->GPU.SetRenderer3D(std::move(glrenderer)); emuInstance->nds->GPU.SetRenderer3D(std::move(glrenderer));
} }
Input::Init(); Input::Init();
@ -404,7 +200,7 @@ void EmuThread::run()
RTC::StateData state; RTC::StateData state;
Platform::FileRead(&state, sizeof(state), 1, file); Platform::FileRead(&state, sizeof(state), 1, file);
Platform::CloseFile(file); Platform::CloseFile(file);
NDS->RTC.SetState(state); emuInstance->nds->RTC.SetState(state);
} }
char melontitle[100]; char melontitle[100];
@ -431,7 +227,7 @@ void EmuThread::run()
if (Input::HotkeyPressed(HK_SolarSensorDecrease)) 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) if (level != -1)
{ {
//mainWindow->osdAddMessage(0, "Solar sensor level: %d", level); //mainWindow->osdAddMessage(0, "Solar sensor level: %d", level);
@ -439,48 +235,48 @@ void EmuThread::run()
} }
if (Input::HotkeyPressed(HK_SolarSensorIncrease)) 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) if (level != -1)
{ {
//mainWindow->osdAddMessage(0, "Solar sensor level: %d", level); //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; double currentTime = SDL_GetPerformanceCounter() * perfCountsSec;
// Handle power button // Handle power button
if (Input::HotkeyDown(HK_PowerButton)) if (Input::HotkeyDown(HK_PowerButton))
{ {
dsi.I2C.GetBPTWL()->SetPowerButtonHeld(currentTime); dsi->I2C.GetBPTWL()->SetPowerButtonHeld(currentTime);
} }
else if (Input::HotkeyReleased(HK_PowerButton)) else if (Input::HotkeyReleased(HK_PowerButton))
{ {
dsi.I2C.GetBPTWL()->SetPowerButtonReleased(currentTime); dsi->I2C.GetBPTWL()->SetPowerButtonReleased(currentTime);
} }
// Handle volume buttons // Handle volume buttons
if (Input::HotkeyDown(HK_VolumeUp)) 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)) 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)) 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)) 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) if (useOpenGL)
@ -512,35 +308,35 @@ void EmuThread::run()
if (videoRenderer == 0) if (videoRenderer == 0)
{ // If we're using the software renderer... { // 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 else
{ {
auto glrenderer = melonDS::GLRenderer::New(); auto glrenderer = melonDS::GLRenderer::New();
glrenderer->SetRenderSettings(Config::GL_BetterPolygons, Config::GL_ScaleFactor); 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 // process input and hotkeys
NDS->SetKeyMask(Input::InputMask); emuInstance->nds->SetKeyMask(Input::InputMask);
if (Input::HotkeyPressed(HK_Lid)) if (Input::HotkeyPressed(HK_Lid))
{ {
bool lid = !NDS->IsLidClosed(); bool lid = !emuInstance->nds->IsLidClosed();
NDS->SetLidClosed(lid); emuInstance->nds->SetLidClosed(lid);
//mainWindow->osdAddMessage(0, lid ? "Lid closed" : "Lid opened"); //mainWindow->osdAddMessage(0, lid ? "Lid closed" : "Lid opened");
} }
// microphone input // microphone input
AudioInOut::MicProcess(*NDS); //AudioInOut::MicProcess(emuInstance->nds);
// auto screen layout // auto screen layout
if (Config::ScreenSizing == Frontend::screenSizing_Auto) if (Config::ScreenSizing == Frontend::screenSizing_Auto)
{ {
mainScreenPos[2] = mainScreenPos[1]; mainScreenPos[2] = mainScreenPos[1];
mainScreenPos[1] = mainScreenPos[0]; mainScreenPos[1] = mainScreenPos[0];
mainScreenPos[0] = NDS->PowerControl9 >> 15; mainScreenPos[0] = emuInstance->nds->PowerControl9 >> 15;
int guess; int guess;
if (mainScreenPos[0] == mainScreenPos[2] && if (mainScreenPos[0] == mainScreenPos[2] &&
@ -567,26 +363,26 @@ void EmuThread::run()
// emulate // emulate
u32 nlines = NDS->RunFrame(); u32 nlines = emuInstance->nds->RunFrame();
if (ROMManager::NDSSave) if (emuInstance->ndsSave)
ROMManager::NDSSave->CheckFlush(); emuInstance->ndsSave->CheckFlush();
if (ROMManager::GBASave) if (emuInstance->gbaSave)
ROMManager::GBASave->CheckFlush(); emuInstance->gbaSave->CheckFlush();
if (ROMManager::FirmwareSave) if (emuInstance->firmwareSave)
ROMManager::FirmwareSave->CheckFlush(); emuInstance->firmwareSave->CheckFlush();
if (!useOpenGL) if (!useOpenGL)
{ {
FrontBufferLock.lock(); FrontBufferLock.lock();
FrontBuffer = NDS->GPU.FrontBuffer; FrontBuffer = emuInstance->nds->GPU.FrontBuffer;
FrontBufferLock.unlock(); FrontBufferLock.unlock();
} }
else else
{ {
FrontBuffer = NDS->GPU.FrontBuffer; FrontBuffer = emuInstance->nds->GPU.FrontBuffer;
//screenGL->drawScreenGL(); //screenGL->drawScreenGL();
for (auto window : windowList) for (auto window : windowList)
window->drawScreenGL(); window->drawScreenGL();
@ -614,10 +410,10 @@ void EmuThread::run()
window->setGLSwapInterval(0); window->setGLSwapInterval(0);
} }
if (Config::DSiVolumeSync && NDS->ConsoleType == 1) if (Config::DSiVolumeSync && emuInstance->nds->ConsoleType == 1)
{ {
DSi& dsi = static_cast<DSi&>(*NDS); DSi* dsi = static_cast<DSi*>(emuInstance->nds);
u8 volumeLevel = dsi.I2C.GetBPTWL()->GetVolumeLevel(); u8 volumeLevel = dsi->I2C.GetBPTWL()->GetVolumeLevel();
if (volumeLevel != dsiVolumeLevel) if (volumeLevel != dsiVolumeLevel)
{ {
dsiVolumeLevel = volumeLevel; dsiVolumeLevel = volumeLevel;
@ -627,8 +423,8 @@ void EmuThread::run()
Config::AudioVolume = volumeLevel * (256.0 / 31.0); Config::AudioVolume = volumeLevel * (256.0 / 31.0);
} }
if (Config::AudioSync && !fastforward) //if (Config::AudioSync && !fastforward)
AudioInOut::AudioSync(*this->NDS); // AudioInOut::AudioSync(emuInstance->nds);
double frametimeStep = nlines / (60.0 * 263.0); double frametimeStep = nlines / (60.0 * 263.0);
@ -734,7 +530,7 @@ void EmuThread::run()
if (file) if (file)
{ {
RTC::StateData state; RTC::StateData state;
NDS->RTC.GetState(state); emuInstance->nds->RTC.GetState(state);
Platform::FileWrite(&state, sizeof(state), 1, file); Platform::FileWrite(&state, sizeof(state), 1, file);
Platform::CloseFile(file); Platform::CloseFile(file);
} }

View File

@ -38,6 +38,7 @@ namespace melonDS
class NDS; class NDS;
} }
class EmuInstance;
class MainWindow; class MainWindow;
class ScreenPanelGL; class ScreenPanelGL;
@ -47,7 +48,7 @@ class EmuThread : public QThread
void run() override; void run() override;
public: public:
explicit EmuThread(QObject* parent = nullptr); explicit EmuThread(EmuInstance* inst, QObject* parent = nullptr);
void attachWindow(MainWindow* window); void attachWindow(MainWindow* window);
void detachWindow(MainWindow* window); void detachWindow(MainWindow* window);
@ -70,13 +71,6 @@ public:
int FrontBuffer = 0; int FrontBuffer = 0;
QMutex FrontBufferLock; 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: signals:
void windowUpdate(); void windowUpdate();
void windowTitleChange(QString title); void windowTitleChange(QString title);
@ -99,11 +93,6 @@ signals:
void syncVolumeLevel(); void syncVolumeLevel();
private: private:
std::unique_ptr<melonDS::NDS> CreateConsole(
std::unique_ptr<melonDS::NDSCart::CartCommon>&& ndscart,
std::unique_ptr<melonDS::GBACart::CartCommon>&& gbacart
) noexcept;
enum EmuStatusKind enum EmuStatusKind
{ {
emuStatus_Exit, emuStatus_Exit,
@ -128,6 +117,8 @@ private:
}; };
std::atomic<ContextRequestKind> ContextRequest = contextRequest_None; std::atomic<ContextRequestKind> ContextRequest = contextRequest_None;
EmuInstance* emuInstance;
//ScreenPanelGL* screenGL; //ScreenPanelGL* screenGL;
MainWindow* mainWindow; MainWindow* mainWindow;
std::list<MainWindow*> windowList; std::list<MainWindow*> windowList;

View File

@ -25,7 +25,6 @@
#include <QImage> #include <QImage>
#include "types.h" #include "types.h"
#include "ROMManager.h"
namespace Ui { class ROMInfoDialog; } namespace Ui { class ROMInfoDialog; }
class ROMInfoDialog; class ROMInfoDialog;

File diff suppressed because it is too large Load Diff

View File

@ -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

View File

@ -77,7 +77,7 @@
//#include "main_shaders.h" //#include "main_shaders.h"
#include "ROMManager.h" #include "EmuInstance.h"
#include "ArchiveUtil.h" #include "ArchiveUtil.h"
#include "CameraManager.h" #include "CameraManager.h"
@ -198,8 +198,10 @@ static void signalHandler(int)
int test = 0; int test = 0;
MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent) MainWindow::MainWindow(EmuInstance* inst, QWidget* parent) : QMainWindow(parent)
{ {
emuInstance = inst;
test_num = test++; test_num = test++;
#ifndef _WIN32 #ifndef _WIN32
if (!parent) if (!parent)
@ -231,7 +233,7 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent)
setAcceptDrops(true); setAcceptDrops(true);
setFocusPolicy(Qt::ClickFocus); setFocusPolicy(Qt::ClickFocus);
int inst = Platform::InstanceID(); //int inst = Platform::InstanceID();
QMenuBar* menubar = new QMenuBar(); QMenuBar* menubar = new QMenuBar();
{ {
@ -260,7 +262,7 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent)
menu->addSeparator(); menu->addSeparator();
actCurrentCart = menu->addAction("DS slot: " + ROMManager::CartLabel()); actCurrentCart = menu->addAction("DS slot: " + emuInstance->cartLabel());
actCurrentCart->setEnabled(false); actCurrentCart->setEnabled(false);
actInsertCart = menu->addAction("Insert cart..."); actInsertCart = menu->addAction("Insert cart...");
@ -271,7 +273,7 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent)
menu->addSeparator(); menu->addSeparator();
actCurrentGBACart = menu->addAction("GBA slot: " + ROMManager::GBACartLabel()); actCurrentGBACart = menu->addAction("GBA slot: " + emuInstance->gbaCartLabel());
actCurrentGBACart->setEnabled(false); actCurrentGBACart->setEnabled(false);
actInsertGBACart = menu->addAction("Insert ROM cart..."); actInsertGBACart = menu->addAction("Insert ROM cart...");
@ -675,7 +677,7 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent)
actLimitFramerate->setChecked(Config::LimitFPS); actLimitFramerate->setChecked(Config::LimitFPS);
actAudioSync->setChecked(Config::AudioSync); actAudioSync->setChecked(Config::AudioSync);
if (inst > 0) if (emuInstance->instanceID > 0)
{ {
actEmuSettings->setEnabled(false); actEmuSettings->setEnabled(false);
actVideoSettings->setEnabled(false); actVideoSettings->setEnabled(false);
@ -900,7 +902,7 @@ void MainWindow::dropEvent(QDropEvent* event)
if (isNdsRom) if (isNdsRom)
{ {
if (!ROMManager::LoadROM(mainWindow, emuThread, file, true)) if (!emuInstance->loadROM(file, true))
{ {
emuThread->emuUnpause(); emuThread->emuUnpause();
return; return;
@ -911,15 +913,15 @@ void MainWindow::dropEvent(QDropEvent* event)
recentFileList.prepend(barredFilename); recentFileList.prepend(barredFilename);
updateRecentFilesMenu(); updateRecentFilesMenu();
assert(emuThread->NDS != nullptr); assert(emuInstance->nds != nullptr);
emuThread->NDS->Start(); emuInstance->nds->Start();
emuThread->emuRun(); emuThread->emuRun();
updateCartInserted(false); updateCartInserted(false);
} }
else if (isGbaRom) else if (isGbaRom)
{ {
if (!ROMManager::LoadGBAROM(mainWindow, *emuThread->NDS, file)) if (!emuInstance->loadGBAROM(file))
{ {
emuThread->emuUnpause(); emuThread->emuUnpause();
return; return;
@ -963,7 +965,7 @@ void MainWindow::onAppStateChanged(Qt::ApplicationState state)
bool MainWindow::verifySetup() bool MainWindow::verifySetup()
{ {
QString res = ROMManager::VerifySetup(); QString res = emuInstance->verifySetup();
if (!res.isEmpty()) if (!res.isEmpty())
{ {
QMessageBox::critical(this, "melonDS", res); QMessageBox::critical(this, "melonDS", res);
@ -983,7 +985,7 @@ bool MainWindow::preloadROMs(QStringList file, QStringList gbafile, bool boot)
bool gbaloaded = false; bool gbaloaded = false;
if (!gbafile.isEmpty()) if (!gbafile.isEmpty())
{ {
if (!ROMManager::LoadGBAROM(mainWindow, *emuThread->NDS, gbafile)) return false; if (!emuInstance->loadGBAROM(gbafile)) return false;
gbaloaded = true; gbaloaded = true;
} }
@ -991,7 +993,7 @@ bool MainWindow::preloadROMs(QStringList file, QStringList gbafile, bool boot)
bool ndsloaded = false; bool ndsloaded = false;
if (!file.isEmpty()) if (!file.isEmpty())
{ {
if (!ROMManager::LoadROM(mainWindow, emuThread, file, true)) return false; if (!emuInstance->loadROM(file, true)) return false;
recentFileList.removeAll(file.join("|")); recentFileList.removeAll(file.join("|"));
recentFileList.prepend(file.join("|")); recentFileList.prepend(file.join("|"));
@ -1003,7 +1005,7 @@ bool MainWindow::preloadROMs(QStringList file, QStringList gbafile, bool boot)
{ {
if (ndsloaded) if (ndsloaded)
{ {
emuThread->NDS->Start(); emuInstance->nds->Start();
emuThread->emuRun(); emuThread->emuRun();
} }
else else
@ -1163,14 +1165,14 @@ void MainWindow::updateCartInserted(bool gba)
bool inserted; bool inserted;
if (gba) if (gba)
{ {
inserted = ROMManager::GBACartInserted() && (Config::ConsoleType == 0); inserted = emuInstance->gbaCartInserted() && (Config::ConsoleType == 0);
actCurrentGBACart->setText("GBA slot: " + ROMManager::GBACartLabel()); actCurrentGBACart->setText("GBA slot: " + emuInstance->gbaCartLabel());
actEjectGBACart->setEnabled(inserted); actEjectGBACart->setEnabled(inserted);
} }
else else
{ {
inserted = ROMManager::CartInserted(); inserted = emuInstance->cartInserted();
actCurrentCart->setText("DS slot: " + ROMManager::CartLabel()); actCurrentCart->setText("DS slot: " + emuInstance->cartLabel());
actEjectCart->setEnabled(inserted); actEjectCart->setEnabled(inserted);
actImportSavefile->setEnabled(inserted); actImportSavefile->setEnabled(inserted);
actSetupCheats->setEnabled(inserted); actSetupCheats->setEnabled(inserted);
@ -1196,7 +1198,7 @@ void MainWindow::onOpenFile()
return; return;
} }
if (!ROMManager::LoadROM(mainWindow, emuThread, file, true)) if (!emuInstance->loadROM(file, true))
{ {
emuThread->emuUnpause(); emuThread->emuUnpause();
return; return;
@ -1207,8 +1209,8 @@ void MainWindow::onOpenFile()
recentFileList.prepend(filename); recentFileList.prepend(filename);
updateRecentFilesMenu(); updateRecentFilesMenu();
assert(emuThread->NDS != nullptr); assert(emuInstance->nds != nullptr);
emuThread->NDS->Start(); emuInstance->nds->Start();
emuThread->emuRun(); emuThread->emuRun();
updateCartInserted(false); updateCartInserted(false);
@ -1293,7 +1295,7 @@ void MainWindow::onClickRecentFile()
return; return;
} }
if (!ROMManager::LoadROM(mainWindow, emuThread, file, true)) if (!emuInstance->loadROM(file, true))
{ {
emuThread->emuUnpause(); emuThread->emuUnpause();
return; return;
@ -1303,8 +1305,8 @@ void MainWindow::onClickRecentFile()
recentFileList.prepend(filename); recentFileList.prepend(filename);
updateRecentFilesMenu(); updateRecentFilesMenu();
assert(emuThread->NDS != nullptr); assert(emuInstance->nds != nullptr);
emuThread->NDS->Start(); emuInstance->nds->Start();
emuThread->emuRun(); emuThread->emuRun();
updateCartInserted(false); updateCartInserted(false);
@ -1320,7 +1322,7 @@ void MainWindow::onBootFirmware()
return; return;
} }
if (!ROMManager::BootToMenu(emuThread)) if (!emuInstance->bootToMenu())
{ {
// TODO: better error reporting? // TODO: better error reporting?
QMessageBox::critical(this, "melonDS", "This firmware is not bootable."); QMessageBox::critical(this, "melonDS", "This firmware is not bootable.");
@ -1328,8 +1330,8 @@ void MainWindow::onBootFirmware()
return; return;
} }
assert(emuThread->NDS != nullptr); assert(emuInstance->nds != nullptr);
emuThread->NDS->Start(); emuInstance->nds->Start();
emuThread->emuRun(); emuThread->emuRun();
} }
@ -1344,7 +1346,7 @@ void MainWindow::onInsertCart()
return; return;
} }
if (!ROMManager::LoadROM(mainWindow, emuThread, file, false)) if (!emuInstance->loadROM(file, false))
{ {
emuThread->emuUnpause(); emuThread->emuUnpause();
return; return;
@ -1359,7 +1361,7 @@ void MainWindow::onEjectCart()
{ {
emuThread->emuPause(); emuThread->emuPause();
ROMManager::EjectCart(*emuThread->NDS); emuInstance->ejectCart();
emuThread->emuUnpause(); emuThread->emuUnpause();
@ -1377,7 +1379,7 @@ void MainWindow::onInsertGBACart()
return; return;
} }
if (!ROMManager::LoadGBAROM(mainWindow, *emuThread->NDS, file)) if (!emuInstance->loadGBAROM(file))
{ {
emuThread->emuUnpause(); emuThread->emuUnpause();
return; return;
@ -1395,7 +1397,7 @@ void MainWindow::onInsertGBAAddon()
emuThread->emuPause(); emuThread->emuPause();
ROMManager::LoadGBAAddon(*emuThread->NDS, type); emuInstance->loadGBAAddon(type);
emuThread->emuUnpause(); emuThread->emuUnpause();
@ -1406,7 +1408,7 @@ void MainWindow::onEjectGBACart()
{ {
emuThread->emuPause(); emuThread->emuPause();
ROMManager::EjectGBACart(*emuThread->NDS); emuInstance->ejectGBACart();
emuThread->emuUnpause(); emuThread->emuUnpause();
@ -1422,7 +1424,7 @@ void MainWindow::onSaveState()
std::string filename; std::string filename;
if (slot > 0) if (slot > 0)
{ {
filename = ROMManager::GetSavestateName(slot); filename = emuInstance->getSavestateName(slot);
} }
else else
{ {
@ -1440,7 +1442,7 @@ void MainWindow::onSaveState()
filename = qfilename.toStdString(); filename = qfilename.toStdString();
} }
if (ROMManager::SaveState(*emuThread->NDS, filename)) if (emuInstance->saveState(filename))
{ {
if (slot > 0) osdAddMessage(0, "State saved to slot %d", slot); if (slot > 0) osdAddMessage(0, "State saved to slot %d", slot);
else osdAddMessage(0, "State saved to file"); else osdAddMessage(0, "State saved to file");
@ -1464,7 +1466,7 @@ void MainWindow::onLoadState()
std::string filename; std::string filename;
if (slot > 0) if (slot > 0)
{ {
filename = ROMManager::GetSavestateName(slot); filename = emuInstance->getSavestateName(slot);
} }
else else
{ {
@ -1491,7 +1493,7 @@ void MainWindow::onLoadState()
return; return;
} }
if (ROMManager::LoadState(*emuThread->NDS, filename)) if (emuInstance->loadState(filename))
{ {
if (slot > 0) osdAddMessage(0, "State loaded from slot %d", slot); if (slot > 0) osdAddMessage(0, "State loaded from slot %d", slot);
else osdAddMessage(0, "State loaded from file"); else osdAddMessage(0, "State loaded from file");
@ -1509,7 +1511,7 @@ void MainWindow::onLoadState()
void MainWindow::onUndoStateLoad() void MainWindow::onUndoStateLoad()
{ {
emuThread->emuPause(); emuThread->emuPause();
ROMManager::UndoStateLoad(*emuThread->NDS); emuInstance->undoStateLoad();
emuThread->emuUnpause(); emuThread->emuUnpause();
osdAddMessage(0, "State load undone"); osdAddMessage(0, "State load undone");
@ -1548,7 +1550,7 @@ void MainWindow::onImportSavefile()
return; return;
} }
ROMManager::Reset(emuThread); emuInstance->reset();
} }
u32 len = FileLength(f); u32 len = FileLength(f);
@ -1557,8 +1559,8 @@ void MainWindow::onImportSavefile()
Platform::FileRewind(f); Platform::FileRewind(f);
Platform::FileRead(data.get(), len, 1, f); Platform::FileRead(data.get(), len, 1, f);
assert(emuThread->NDS != nullptr); assert(emuInstance->nds != nullptr);
emuThread->NDS->SetNDSSave(data.get(), len); emuInstance->nds->SetNDSSave(data.get(), len);
CloseFile(f); CloseFile(f);
emuThread->emuUnpause(); emuThread->emuUnpause();
@ -1599,7 +1601,7 @@ void MainWindow::onReset()
actUndoStateLoad->setEnabled(false); actUndoStateLoad->setEnabled(false);
ROMManager::Reset(emuThread); emuInstance->reset();
osdAddMessage(0, "Reset"); osdAddMessage(0, "Reset");
emuThread->emuRun(); emuThread->emuRun();
@ -1610,7 +1612,7 @@ void MainWindow::onStop()
if (!RunningSomething) return; if (!RunningSomething) return;
emuThread->emuPause(); emuThread->emuPause();
emuThread->NDS->Stop(); emuInstance->nds->Stop();
} }
void MainWindow::onFrameStep() void MainWindow::onFrameStep()
@ -1633,7 +1635,7 @@ void MainWindow::onOpenPowerManagement()
void MainWindow::onEnableCheats(bool checked) void MainWindow::onEnableCheats(bool checked)
{ {
Config::EnableCheats = checked?1:0; Config::EnableCheats = checked?1:0;
ROMManager::EnableCheats(*emuThread->NDS, Config::EnableCheats != 0); emuInstance->enableCheats(Config::EnableCheats != 0);
} }
void MainWindow::onSetupCheats() void MainWindow::onSetupCheats()
@ -1651,7 +1653,7 @@ void MainWindow::onCheatsDialogFinished(int res)
void MainWindow::onROMInfo() void MainWindow::onROMInfo()
{ {
auto cart = emuThread->NDS->NDSCartSlot.GetCart(); auto cart = emuInstance->nds->NDSCartSlot.GetCart();
if (cart) if (cart)
ROMInfoDialog* dlg = ROMInfoDialog::openDlg(this, *cart); ROMInfoDialog* dlg = ROMInfoDialog::openDlg(this, *cart);
} }
@ -1707,13 +1709,13 @@ void MainWindow::onEmuSettingsDialogFinished(int res)
actInsertGBACart->setEnabled(true); actInsertGBACart->setEnabled(true);
for (int i = 0; i < 1; i++) for (int i = 0; i < 1; i++)
actInsertGBAAddon[i]->setEnabled(true); actInsertGBAAddon[i]->setEnabled(true);
actEjectGBACart->setEnabled(ROMManager::GBACartInserted()); actEjectGBACart->setEnabled(emuInstance->gbaCartInserted());
} }
if (EmuSettingsDialog::needsReset) if (EmuSettingsDialog::needsReset)
onReset(); onReset();
actCurrentGBACart->setText("GBA slot: " + ROMManager::GBACartLabel()); actCurrentGBACart->setText("GBA slot: " + emuInstance->gbaCartLabel());
if (!RunningSomething) if (!RunningSomething)
actTitleManager->setEnabled(!Config::DSiNANDPath.empty()); actTitleManager->setEnabled(!Config::DSiNANDPath.empty());
@ -1802,18 +1804,18 @@ void MainWindow::onPathSettingsFinished(int res)
void MainWindow::onUpdateAudioSettings() void MainWindow::onUpdateAudioSettings()
{ {
assert(emuThread->NDS != nullptr); assert(emuInstance->nds != nullptr);
emuThread->NDS->SPU.SetInterpolation(static_cast<AudioInterpolation>(Config::AudioInterp)); emuInstance->nds->SPU.SetInterpolation(static_cast<AudioInterpolation>(Config::AudioInterp));
if (Config::AudioBitDepth == 0) if (Config::AudioBitDepth == 0)
emuThread->NDS->SPU.SetDegrade10Bit(emuThread->NDS->ConsoleType == 0); emuInstance->nds->SPU.SetDegrade10Bit(emuInstance->nds->ConsoleType == 0);
else else
emuThread->NDS->SPU.SetDegrade10Bit(Config::AudioBitDepth == 1); emuInstance->nds->SPU.SetDegrade10Bit(Config::AudioBitDepth == 1);
} }
void MainWindow::onAudioSettingsFinished(int res) void MainWindow::onAudioSettingsFinished(int res)
{ {
AudioInOut::UpdateSettings(*emuThread->NDS); //AudioInOut::UpdateSettings(*emuThread->NDS);
} }
void MainWindow::onOpenMPSettings() void MainWindow::onOpenMPSettings()
@ -2029,7 +2031,7 @@ void MainWindow::onEmuStart()
for (int i = 1; i < 9; i++) for (int i = 1; i < 9; i++)
{ {
actSaveState[i]->setEnabled(true); actSaveState[i]->setEnabled(true);
actLoadState[i]->setEnabled(ROMManager::SavestateExists(i)); actLoadState[i]->setEnabled(emuInstance->savestateExists(i));
} }
actSaveState[0]->setEnabled(true); actSaveState[0]->setEnabled(true);
actLoadState[0]->setEnabled(true); actLoadState[0]->setEnabled(true);

View File

@ -36,6 +36,7 @@
#include "Screen.h" #include "Screen.h"
class EmuInstance;
class EmuThread; class EmuThread;
/* /*
@ -100,7 +101,7 @@ class MainWindow : public QMainWindow
Q_OBJECT Q_OBJECT
public: public:
explicit MainWindow(QWidget* parent = nullptr); explicit MainWindow(EmuInstance* inst, QWidget* parent = nullptr);
~MainWindow(); ~MainWindow();
void attachEmuThread(EmuThread* thread); void attachEmuThread(EmuThread* thread);
@ -236,6 +237,8 @@ private:
int test_num; int test_num;
EmuInstance* emuInstance;
EmuThread* emuThread; EmuThread* emuThread;
public: public:

View File

@ -100,7 +100,7 @@
//#include "main_shaders.h" //#include "main_shaders.h"
#include "ROMManager.h" #include "EmuInstance.h"
#include "ArchiveUtil.h" #include "ArchiveUtil.h"
#include "CameraManager.h" #include "CameraManager.h"
@ -161,8 +161,9 @@ QStringList ArchiveExtensions
bool RunningSomething; bool RunningSomething;
MainWindow* mainWindow; //MainWindow* mainWindow;
EmuThread* emuThread; //EmuThread* emuThread;
EmuInstance* testinst;
int autoScreenSizing = 0; int autoScreenSizing = 0;
@ -258,7 +259,7 @@ void emuStop()
{ {
RunningSomething = false; RunningSomething = false;
emit emuThread->windowEmuStop(); //emit emuThread->windowEmuStop();
} }
MelonApplication::MelonApplication(int& argc, char** argv) MelonApplication::MelonApplication(int& argc, char** argv)
@ -278,10 +279,10 @@ bool MelonApplication::event(QEvent *event)
{ {
QFileOpenEvent *openEvent = static_cast<QFileOpenEvent*>(event); QFileOpenEvent *openEvent = static_cast<QFileOpenEvent*>(event);
emuThread->emuPause(); /*emuThread->emuPause();
const QStringList file = mainWindow->splitArchivePath(openEvent->file(), true); const QStringList file = mainWindow->splitArchivePath(openEvent->file(), true);
if (!mainWindow->preloadROMs(file, {}, true)) if (!mainWindow->preloadROMs(file, {}, true))
emuThread->emuUnpause(); emuThread->emuUnpause();*/
} }
return QApplication::event(event); return QApplication::event(event);
@ -375,7 +376,7 @@ int main(int argc, char** argv)
Input::JoystickID = Config::JoystickID; Input::JoystickID = Config::JoystickID;
Input::OpenJoystick(); Input::OpenJoystick();
mainWindow = new MainWindow(); /* mainWindow = new MainWindow();
if (options->fullscreen) if (options->fullscreen)
ToggleFullscreen(mainWindow); ToggleFullscreen(mainWindow);
@ -385,9 +386,11 @@ int main(int argc, char** argv)
emuThread->attachWindow(mainWindow); emuThread->attachWindow(mainWindow);
emuThread->attachWindow(poop); emuThread->attachWindow(poop);
emuThread->start(); emuThread->start();
emuThread->emuPause(); emuThread->emuPause();*/
AudioInOut::Init(emuThread); testinst = new EmuInstance(0);
/*AudioInOut::Init(emuThread);
ROMManager::EnableCheats(*emuThread->NDS, Config::EnableCheats != 0); ROMManager::EnableCheats(*emuThread->NDS, Config::EnableCheats != 0);
AudioInOut::AudioMute(mainWindow); 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"); 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(); int ret = melon.exec();
delete options; delete options;
emuThread->emuStop(); /*emuThread->emuStop();
emuThread->wait(); emuThread->wait();
delete emuThread; delete emuThread;*/
delete testinst;
Input::CloseJoystick(); Input::CloseJoystick();