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"
using namespace melonDS;
extern EmuThread* emuThread;
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(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);
setAttribute(Qt::WA_DeleteOnClose);
emuInstance = ((MainWindow*)parent)->getEmuInstance();
qRegisterMetaType<QVector<int>>("QVector<int>");
qRegisterMetaType<u32>("u32");
qRegisterMetaType<s32>("s32");
@ -91,7 +92,7 @@ void RAMInfoDialog::ShowRowsInTable()
for (u32 row = scrollValue; row < std::min<u32>(scrollValue+25, RowDataVector->size()); 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)
{
@ -186,7 +187,7 @@ void RAMInfoDialog::on_ramTable_itemChanged(QTableWidgetItem *item)
s32 itemValue = item->text().toInt();
if (rowData.Value != itemValue)
rowData.SetValue(*emuThread->NDS, itemValue);
rowData.SetValue(*emuInstance->getNDS(), itemValue);
}
/**
@ -235,7 +236,7 @@ void RAMSearchThread::run()
u32 progress = 0;
// Pause game running
emuThread->emuPause();
Dialog->emuInstance->getEmuThread()->emuPause();
// For following search modes below, RowDataVector must be filled.
if (SearchMode == ramInfoSTh_SearchAll || RowDataVector->size() == 0)
@ -243,7 +244,7 @@ void RAMSearchThread::run()
// First search mode
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 });
@ -264,7 +265,7 @@ void RAMSearchThread::run()
for (u32 row = 0; SearchRunning && row < RowDataVector->size(); row++)
{
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)
newRowDataVector->push_back({ addr, value, value });
@ -282,7 +283,7 @@ void RAMSearchThread::run()
}
// Unpause game running
emuThread->emuUnpause();
Dialog->emuInstance->getEmuThread()->emuUnpause();
SearchRunning = false;
}

View File

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

View File

@ -27,6 +27,7 @@
#include "NDSCart.h"
#include "Platform.h"
#include "Config.h"
#include "main.h"
using namespace melonDS;
@ -42,15 +43,18 @@ QString QStringBytes(u64 num)
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);
setAttribute(Qt::WA_DeleteOnClose);
const NDSBanner* banner = rom.Banner();
const NDSHeader& header = rom.GetHeader();
emuInstance = ((MainWindow*)parent)->getEmuInstance();
auto rom = emuInstance->getNDS()->NDSCartSlot.GetCart();
const NDSBanner* banner = rom->Banner();
const NDSHeader& header = rom->GetHeader();
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();
ui->iconImage->setPixmap(QPixmap::fromImage(iconImage));
@ -58,7 +62,7 @@ ROMInfoDialog::ROMInfoDialog(QWidget* parent, const melonDS::NDSCart::CartCommon
{
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)
{

View File

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

View File

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

View File

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