mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-24 14:49:53 -06:00
Refactor NDS
and DSi
to be objects (#1893)
* First crack at refactoring NDS and DSi into objects - Remove all global/`static` variables in `NDS` and related classes - Rely more on virtual dispatch when we need to pick methods at runtime - Pass `NDS&` or `DSi&` to its constituent components where necessary - Introduce some headers or move some definitions to break `#include` cycles * Refactor the frontend to accommodate the core's changes * Move up `SchedList`'s declaration - Move it to before the components are initialized so the `map`s inside are initialized - Fields in C++ are initialized in the order they're declared * Fix a crash when allocating memory * Fix JIT-free builds * Fix GDB-free builds * Fix Linux builds - Explicitly qualify some member types in NDS, since they share the same name as their classes * Remove an unnecessary template argument - This was causing the build to fail on macOS * Fix ARM and Android builds * Rename `Constants.h` to `MemConstants.h` * Add `NDS::IsRunning()` * Use an `#include` guard instead of `#pragma once`
This commit is contained in:

committed by
GitHub

parent
c84cb17462
commit
e973236203
@ -24,16 +24,16 @@
|
||||
using namespace melonDS;
|
||||
extern EmuThread* emuThread;
|
||||
|
||||
s32 GetMainRAMValue(const u32& addr, const ramInfo_ByteType& byteType)
|
||||
s32 GetMainRAMValue(NDS& nds, const u32& addr, const ramInfo_ByteType& byteType)
|
||||
{
|
||||
switch (byteType)
|
||||
{
|
||||
case ramInfo_OneByte:
|
||||
return *(s8*)(NDS::MainRAM + (addr&NDS::MainRAMMask));
|
||||
return *(s8*)(nds.MainRAM + (addr&nds.MainRAMMask));
|
||||
case ramInfo_TwoBytes:
|
||||
return *(s16*)(NDS::MainRAM + (addr&NDS::MainRAMMask));
|
||||
return *(s16*)(nds.MainRAM + (addr&nds.MainRAMMask));
|
||||
case ramInfo_FourBytes:
|
||||
return *(s32*)(NDS::MainRAM + (addr&NDS::MainRAMMask));
|
||||
return *(s32*)(nds.MainRAM + (addr&nds.MainRAMMask));
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
@ -41,7 +41,7 @@ s32 GetMainRAMValue(const u32& addr, const ramInfo_ByteType& byteType)
|
||||
|
||||
RAMInfoDialog* RAMInfoDialog::currentDlg = nullptr;
|
||||
|
||||
RAMInfoDialog::RAMInfoDialog(QWidget* parent) : QDialog(parent), ui(new Ui::RAMInfoDialog)
|
||||
RAMInfoDialog::RAMInfoDialog(QWidget* parent, EmuThread* emuThread) : QDialog(parent), emuThread(emuThread), ui(new Ui::RAMInfoDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
@ -91,7 +91,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(SearchThread->GetSearchByteType());
|
||||
rowData.Update(*emuThread->NDS, SearchThread->GetSearchByteType());
|
||||
|
||||
if (ui->ramTable->item(row, ramInfo_Address) == nullptr)
|
||||
{
|
||||
@ -186,7 +186,7 @@ void RAMInfoDialog::on_ramTable_itemChanged(QTableWidgetItem *item)
|
||||
s32 itemValue = item->text().toInt();
|
||||
|
||||
if (rowData.Value != itemValue)
|
||||
rowData.SetValue(itemValue);
|
||||
rowData.SetValue(*emuThread->NDS, itemValue);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -241,14 +241,14 @@ void RAMSearchThread::run()
|
||||
if (SearchMode == ramInfoSTh_SearchAll || RowDataVector->size() == 0)
|
||||
{
|
||||
// First search mode
|
||||
for (u32 addr = 0x02000000; SearchRunning && addr < 0x02000000+NDS::MainRAMMaxSize; addr += SearchByteType)
|
||||
for (u32 addr = 0x02000000; SearchRunning && addr < 0x02000000+MainRAMMaxSize; addr += SearchByteType)
|
||||
{
|
||||
const s32& value = GetMainRAMValue(addr, SearchByteType);
|
||||
const s32& value = GetMainRAMValue(*emuThread->NDS, addr, SearchByteType);
|
||||
|
||||
RowDataVector->push_back({ addr, value, value });
|
||||
|
||||
// A solution to prevent to call too many slot.
|
||||
u32 newProgress = (int)((addr-0x02000000) / (NDS::MainRAMMaxSize-1.0f) * 100);
|
||||
u32 newProgress = (int)((addr-0x02000000) / (MainRAMMaxSize-1.0f) * 100);
|
||||
if (progress < newProgress)
|
||||
{
|
||||
progress = newProgress;
|
||||
@ -264,7 +264,7 @@ void RAMSearchThread::run()
|
||||
for (u32 row = 0; SearchRunning && row < RowDataVector->size(); row++)
|
||||
{
|
||||
const u32& addr = RowDataVector->at(row).Address;
|
||||
const s32& value = GetMainRAMValue(addr, SearchByteType);
|
||||
const s32& value = GetMainRAMValue(*emuThread->NDS, addr, SearchByteType);
|
||||
|
||||
if (SearchValue == value)
|
||||
newRowDataVector->push_back({ addr, value, value });
|
||||
|
Reference in New Issue
Block a user