it keeps going

This commit is contained in:
Arisotura 2024-05-19 01:42:44 +02:00
parent 30444036a6
commit cde47f56c5
6 changed files with 36 additions and 25 deletions

View File

@ -22,7 +22,6 @@
#include "main.h" #include "main.h"
using namespace melonDS; using namespace melonDS;
extern EmuThread* emuThread;
s32 GetMainRAMValue(NDS& nds, const u32& addr, const ramInfo_ByteType& byteType) s32 GetMainRAMValue(NDS& nds, const u32& addr, const ramInfo_ByteType& byteType)
{ {
@ -41,11 +40,13 @@ s32 GetMainRAMValue(NDS& nds, const u32& addr, const ramInfo_ByteType& byteType)
RAMInfoDialog* RAMInfoDialog::currentDlg = nullptr; RAMInfoDialog* RAMInfoDialog::currentDlg = nullptr;
RAMInfoDialog::RAMInfoDialog(QWidget* parent, EmuThread* emuThread) : QDialog(parent), emuThread(emuThread), ui(new Ui::RAMInfoDialog) RAMInfoDialog::RAMInfoDialog(QWidget* parent) : QDialog(parent), ui(new Ui::RAMInfoDialog)
{ {
ui->setupUi(this); ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
emuInstance = ((MainWindow*)parent)->getEmuInstance();
qRegisterMetaType<QVector<int>>("QVector<int>"); qRegisterMetaType<QVector<int>>("QVector<int>");
qRegisterMetaType<u32>("u32"); qRegisterMetaType<u32>("u32");
qRegisterMetaType<s32>("s32"); qRegisterMetaType<s32>("s32");
@ -91,7 +92,7 @@ void RAMInfoDialog::ShowRowsInTable()
for (u32 row = scrollValue; row < std::min<u32>(scrollValue+25, RowDataVector->size()); row++) for (u32 row = scrollValue; row < std::min<u32>(scrollValue+25, RowDataVector->size()); row++)
{ {
ramInfo_RowData& rowData = RowDataVector->at(row); ramInfo_RowData& rowData = RowDataVector->at(row);
rowData.Update(*emuThread->NDS, SearchThread->GetSearchByteType()); rowData.Update(*emuInstance->getNDS(), SearchThread->GetSearchByteType());
if (ui->ramTable->item(row, ramInfo_Address) == nullptr) if (ui->ramTable->item(row, ramInfo_Address) == nullptr)
{ {
@ -186,7 +187,7 @@ void RAMInfoDialog::on_ramTable_itemChanged(QTableWidgetItem *item)
s32 itemValue = item->text().toInt(); s32 itemValue = item->text().toInt();
if (rowData.Value != itemValue) if (rowData.Value != itemValue)
rowData.SetValue(*emuThread->NDS, itemValue); rowData.SetValue(*emuInstance->getNDS(), itemValue);
} }
/** /**
@ -235,7 +236,7 @@ void RAMSearchThread::run()
u32 progress = 0; u32 progress = 0;
// Pause game running // Pause game running
emuThread->emuPause(); Dialog->emuInstance->getEmuThread()->emuPause();
// For following search modes below, RowDataVector must be filled. // For following search modes below, RowDataVector must be filled.
if (SearchMode == ramInfoSTh_SearchAll || RowDataVector->size() == 0) if (SearchMode == ramInfoSTh_SearchAll || RowDataVector->size() == 0)
@ -243,7 +244,7 @@ void RAMSearchThread::run()
// First search mode // First search mode
for (u32 addr = 0x02000000; SearchRunning && addr < 0x02000000+MainRAMMaxSize; addr += SearchByteType) for (u32 addr = 0x02000000; SearchRunning && addr < 0x02000000+MainRAMMaxSize; addr += SearchByteType)
{ {
const s32& value = GetMainRAMValue(*emuThread->NDS, addr, SearchByteType); const s32& value = GetMainRAMValue(*Dialog->emuInstance->getNDS(), addr, SearchByteType);
RowDataVector->push_back({ addr, value, value }); RowDataVector->push_back({ addr, value, value });
@ -264,7 +265,7 @@ void RAMSearchThread::run()
for (u32 row = 0; SearchRunning && row < RowDataVector->size(); row++) for (u32 row = 0; SearchRunning && row < RowDataVector->size(); row++)
{ {
const u32& addr = RowDataVector->at(row).Address; const u32& addr = RowDataVector->at(row).Address;
const s32& value = GetMainRAMValue(*emuThread->NDS, addr, SearchByteType); const s32& value = GetMainRAMValue(*Dialog->emuInstance->getNDS(), addr, SearchByteType);
if (SearchValue == value) if (SearchValue == value)
newRowDataVector->push_back({ addr, value, value }); newRowDataVector->push_back({ addr, value, value });
@ -282,7 +283,7 @@ void RAMSearchThread::run()
} }
// Unpause game running // Unpause game running
emuThread->emuUnpause(); Dialog->emuInstance->getEmuThread()->emuUnpause();
SearchRunning = false; SearchRunning = false;
} }

View File

@ -32,7 +32,7 @@ namespace Ui { class RAMInfoDialog; }
class RAMInfoDialog; class RAMInfoDialog;
class RAMSearchThread; class RAMSearchThread;
class RAMUpdateThread; class RAMUpdateThread;
class EmuThread; class EmuInstance;
enum ramInfo_ByteType enum ramInfo_ByteType
{ {
@ -79,11 +79,11 @@ class RAMInfoDialog : public QDialog
Q_OBJECT Q_OBJECT
public: public:
explicit RAMInfoDialog(QWidget* parent, EmuThread* emuThread); explicit RAMInfoDialog(QWidget* parent);
~RAMInfoDialog(); ~RAMInfoDialog();
static RAMInfoDialog* currentDlg; static RAMInfoDialog* currentDlg;
static RAMInfoDialog* openDlg(QWidget* parent, EmuThread* emuThread) static RAMInfoDialog* openDlg(QWidget* parent)
{ {
if (currentDlg) if (currentDlg)
{ {
@ -91,7 +91,7 @@ public:
return currentDlg; return currentDlg;
} }
currentDlg = new RAMInfoDialog(parent, emuThread); currentDlg = new RAMInfoDialog(parent);
currentDlg->show(); currentDlg->show();
return currentDlg; return currentDlg;
} }
@ -119,11 +119,13 @@ private slots:
void SetProgressbarValue(const melonDS::u32& value); void SetProgressbarValue(const melonDS::u32& value);
private: private:
EmuThread* emuThread;
Ui::RAMInfoDialog* ui; Ui::RAMInfoDialog* ui;
EmuInstance* emuInstance;
RAMSearchThread* SearchThread; RAMSearchThread* SearchThread;
QTimer* TableUpdater; QTimer* TableUpdater;
friend class RAMSearchThread;
}; };
class RAMSearchThread : public QThread class RAMSearchThread : public QThread

View File

@ -27,6 +27,7 @@
#include "NDSCart.h" #include "NDSCart.h"
#include "Platform.h" #include "Platform.h"
#include "Config.h" #include "Config.h"
#include "main.h"
using namespace melonDS; using namespace melonDS;
@ -42,15 +43,18 @@ QString QStringBytes(u64 num)
ROMInfoDialog* ROMInfoDialog::currentDlg = nullptr; ROMInfoDialog* ROMInfoDialog::currentDlg = nullptr;
ROMInfoDialog::ROMInfoDialog(QWidget* parent, const melonDS::NDSCart::CartCommon& rom) : QDialog(parent), ui(new Ui::ROMInfoDialog) ROMInfoDialog::ROMInfoDialog(QWidget* parent) : QDialog(parent), ui(new Ui::ROMInfoDialog)
{ {
ui->setupUi(this); ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
const NDSBanner* banner = rom.Banner(); emuInstance = ((MainWindow*)parent)->getEmuInstance();
const NDSHeader& header = rom.GetHeader();
auto rom = emuInstance->getNDS()->NDSCartSlot.GetCart();
const NDSBanner* banner = rom->Banner();
const NDSHeader& header = rom->GetHeader();
u32 iconData[32 * 32]; u32 iconData[32 * 32];
ROMManager::ROMIcon(banner->Icon, banner->Palette, iconData); emuInstance->romIcon(banner->Icon, banner->Palette, iconData);
iconImage = QImage(reinterpret_cast<u8*>(iconData), 32, 32, QImage::Format_RGBA8888).copy(); iconImage = QImage(reinterpret_cast<u8*>(iconData), 32, 32, QImage::Format_RGBA8888).copy();
ui->iconImage->setPixmap(QPixmap::fromImage(iconImage)); ui->iconImage->setPixmap(QPixmap::fromImage(iconImage));
@ -58,7 +62,7 @@ ROMInfoDialog::ROMInfoDialog(QWidget* parent, const melonDS::NDSCart::CartCommon
{ {
ui->saveAnimatedIconButton->setEnabled(true); ui->saveAnimatedIconButton->setEnabled(true);
ROMManager::AnimatedROMIcon(banner->DSiIcon, banner->DSiPalette, banner->DSiSequence, animatedIconData, animatedSequence); emuInstance->animatedROMIcon(banner->DSiIcon, banner->DSiPalette, banner->DSiSequence, animatedIconData, animatedSequence);
for (u32* image: animatedIconData) for (u32* image: animatedIconData)
{ {

View File

@ -28,17 +28,19 @@
namespace Ui { class ROMInfoDialog; } namespace Ui { class ROMInfoDialog; }
class ROMInfoDialog; class ROMInfoDialog;
class EmuInstance;
namespace melonDS::NDSCart { class CartCommon; } namespace melonDS::NDSCart { class CartCommon; }
class ROMInfoDialog : public QDialog class ROMInfoDialog : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit ROMInfoDialog(QWidget* parent, const melonDS::NDSCart::CartCommon& rom); explicit ROMInfoDialog(QWidget* parent);
~ROMInfoDialog(); ~ROMInfoDialog();
static ROMInfoDialog* currentDlg; static ROMInfoDialog* currentDlg;
static ROMInfoDialog* openDlg(QWidget* parent, const melonDS::NDSCart::CartCommon& rom) static ROMInfoDialog* openDlg(QWidget* parent)
{ {
if (currentDlg) if (currentDlg)
{ {
@ -46,7 +48,7 @@ public:
return currentDlg; return currentDlg;
} }
currentDlg = new ROMInfoDialog(parent, rom); currentDlg = new ROMInfoDialog(parent);
currentDlg->open(); currentDlg->open();
return currentDlg; return currentDlg;
} }
@ -65,6 +67,7 @@ private slots:
private: private:
Ui::ROMInfoDialog* ui; Ui::ROMInfoDialog* ui;
EmuInstance* emuInstance;
QImage iconImage; QImage iconImage;
QTimeLine* iconTimeline; QTimeLine* iconTimeline;

View File

@ -1629,7 +1629,7 @@ void MainWindow::onOpenDateTime()
void MainWindow::onOpenPowerManagement() void MainWindow::onOpenPowerManagement()
{ {
PowerManagementDialog* dlg = PowerManagementDialog::openDlg(this, emuThread); PowerManagementDialog* dlg = PowerManagementDialog::openDlg(this);
} }
void MainWindow::onEnableCheats(bool checked) void MainWindow::onEnableCheats(bool checked)
@ -1655,12 +1655,12 @@ void MainWindow::onROMInfo()
{ {
auto cart = emuInstance->nds->NDSCartSlot.GetCart(); auto cart = emuInstance->nds->NDSCartSlot.GetCart();
if (cart) if (cart)
ROMInfoDialog* dlg = ROMInfoDialog::openDlg(this, *cart); ROMInfoDialog* dlg = ROMInfoDialog::openDlg(this);
} }
void MainWindow::onRAMInfo() void MainWindow::onRAMInfo()
{ {
RAMInfoDialog* dlg = RAMInfoDialog::openDlg(this, emuThread); RAMInfoDialog* dlg = RAMInfoDialog::openDlg(this);
} }
void MainWindow::onOpenTitleManager() void MainWindow::onOpenTitleManager()
@ -1763,7 +1763,7 @@ void MainWindow::onCameraSettingsFinished(int res)
void MainWindow::onOpenAudioSettings() void MainWindow::onOpenAudioSettings()
{ {
AudioSettingsDialog* dlg = AudioSettingsDialog::openDlg(this, emuThread->emuIsActive(), emuThread); AudioSettingsDialog* dlg = AudioSettingsDialog::openDlg(this);
connect(emuThread, &EmuThread::syncVolumeLevel, dlg, &AudioSettingsDialog::onSyncVolumeLevel); connect(emuThread, &EmuThread::syncVolumeLevel, dlg, &AudioSettingsDialog::onSyncVolumeLevel);
connect(emuThread, &EmuThread::windowEmuStart, dlg, &AudioSettingsDialog::onConsoleReset); connect(emuThread, &EmuThread::windowEmuStart, dlg, &AudioSettingsDialog::onConsoleReset);
connect(dlg, &AudioSettingsDialog::updateAudioSettings, this, &MainWindow::onUpdateAudioSettings); connect(dlg, &AudioSettingsDialog::updateAudioSettings, this, &MainWindow::onUpdateAudioSettings);

View File

@ -31,6 +31,7 @@
#include <QScreen> #include <QScreen>
#include <QCloseEvent> #include <QCloseEvent>
#include "EmuInstance.h"
#include "Window.h" #include "Window.h"
#include "EmuThread.h" #include "EmuThread.h"
#include "FrontendUtil.h" #include "FrontendUtil.h"