mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-25 23:29:55 -06:00
make recent ROM list work
This commit is contained in:
@ -487,11 +487,7 @@ void CartGame::SRAMWrite_FLASH(u32 addr, u8 val)
|
|||||||
u32 start_addr = addr + 0x10000 * SRAMFlashState.bank;
|
u32 start_addr = addr + 0x10000 * SRAMFlashState.bank;
|
||||||
memset((u8*)&SRAM[start_addr], 0xFF, 0x1000);
|
memset((u8*)&SRAM[start_addr], 0xFF, 0x1000);
|
||||||
|
|
||||||
/*if (SRAMFile)
|
Platform::WriteGBASave(SRAM, SRAMLength, start_addr, 0x1000);
|
||||||
{
|
|
||||||
fseek(SRAMFile, start_addr, SEEK_SET);
|
|
||||||
fwrite((u8*)&SRAM[start_addr], 1, 0x1000, SRAMFile);
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
SRAMFlashState.state = 0;
|
SRAMFlashState.state = 0;
|
||||||
SRAMFlashState.cmd = 0;
|
SRAMFlashState.cmd = 0;
|
||||||
@ -549,11 +545,8 @@ void CartGame::SRAMWrite_SRAM(u32 addr, u8 val)
|
|||||||
{
|
{
|
||||||
*(u8*)&SRAM[addr] = val;
|
*(u8*)&SRAM[addr] = val;
|
||||||
|
|
||||||
/*if (SRAMFile)
|
// TODO: optimize this!!
|
||||||
{
|
Platform::WriteGBASave(SRAM, SRAMLength, addr, 1);
|
||||||
fseek(SRAMFile, addr, SEEK_SET);
|
|
||||||
fwrite((u8*)&SRAM[addr], 1, 1, SRAMFile);
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -381,7 +381,8 @@ void WriteNDSSave(const u8* savedata, u32 savelen, u32 writeoffset, u32 writelen
|
|||||||
|
|
||||||
void WriteGBASave(const u8* savedata, u32 savelen, u32 writeoffset, u32 writelen)
|
void WriteGBASave(const u8* savedata, u32 savelen, u32 writeoffset, u32 writelen)
|
||||||
{
|
{
|
||||||
//
|
if (ROMManager::GBASave)
|
||||||
|
ROMManager::GBASave->RequestFlush(savedata, savelen, writeoffset, writelen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -46,6 +46,7 @@ std::string BaseAssetName = "";
|
|||||||
int GBACartType = -1;
|
int GBACartType = -1;
|
||||||
|
|
||||||
SaveManager* NDSSave = nullptr;
|
SaveManager* NDSSave = nullptr;
|
||||||
|
SaveManager* GBASave = nullptr;
|
||||||
|
|
||||||
|
|
||||||
int LastSep(std::string path)
|
int LastSep(std::string path)
|
||||||
@ -300,7 +301,6 @@ bool LoadROM(QStringList filepath, bool reset)
|
|||||||
u8* filedata;
|
u8* filedata;
|
||||||
u32 filelen;
|
u32 filelen;
|
||||||
|
|
||||||
std::string fullpath;
|
|
||||||
std::string basepath;
|
std::string basepath;
|
||||||
std::string romname;
|
std::string romname;
|
||||||
|
|
||||||
@ -334,8 +334,6 @@ bool LoadROM(QStringList filepath, bool reset)
|
|||||||
fclose(f);
|
fclose(f);
|
||||||
filelen = (u32)len;
|
filelen = (u32)len;
|
||||||
|
|
||||||
fullpath = filename;
|
|
||||||
|
|
||||||
int pos = LastSep(filename);
|
int pos = LastSep(filename);
|
||||||
basepath = filename.substr(0, pos);
|
basepath = filename.substr(0, pos);
|
||||||
romname = filename.substr(pos+1);
|
romname = filename.substr(pos+1);
|
||||||
@ -359,8 +357,6 @@ bool LoadROM(QStringList filepath, bool reset)
|
|||||||
|
|
||||||
std::string std_romname = filepath.at(1).toStdString();
|
std::string std_romname = filepath.at(1).toStdString();
|
||||||
romname = std_romname.substr(LastSep(std_romname)+1);
|
romname = std_romname.substr(LastSep(std_romname)+1);
|
||||||
|
|
||||||
fullpath = std_archivepath + "//" + std_romname;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
else
|
else
|
||||||
@ -369,7 +365,7 @@ bool LoadROM(QStringList filepath, bool reset)
|
|||||||
if (NDSSave) delete NDSSave;
|
if (NDSSave) delete NDSSave;
|
||||||
NDSSave = nullptr;
|
NDSSave = nullptr;
|
||||||
|
|
||||||
FullROMPath = fullpath;
|
FullROMPath = filepath.join('|').toStdString();
|
||||||
BaseROMDir = basepath;
|
BaseROMDir = basepath;
|
||||||
BaseROMName = romname;
|
BaseROMName = romname;
|
||||||
BaseAssetName = romname.substr(0, romname.rfind('.'));
|
BaseAssetName = romname.substr(0, romname.rfind('.'));
|
||||||
|
@ -29,6 +29,7 @@ namespace ROMManager
|
|||||||
{
|
{
|
||||||
|
|
||||||
extern SaveManager* NDSSave;
|
extern SaveManager* NDSSave;
|
||||||
|
extern SaveManager* GBASave;
|
||||||
|
|
||||||
QString VerifySetup();
|
QString VerifySetup();
|
||||||
void Reset();
|
void Reset();
|
||||||
|
@ -546,6 +546,9 @@ void EmuThread::run()
|
|||||||
if (ROMManager::NDSSave)
|
if (ROMManager::NDSSave)
|
||||||
ROMManager::NDSSave->CheckFlush();
|
ROMManager::NDSSave->CheckFlush();
|
||||||
|
|
||||||
|
if (ROMManager::GBASave)
|
||||||
|
ROMManager::GBASave->CheckFlush();
|
||||||
|
|
||||||
FrontBufferLock.lock();
|
FrontBufferLock.lock();
|
||||||
FrontBuffer = GPU::FrontBuffer;
|
FrontBuffer = GPU::FrontBuffer;
|
||||||
#ifdef OGLRENDERER_ENABLED
|
#ifdef OGLRENDERER_ENABLED
|
||||||
@ -1883,7 +1886,7 @@ void MainWindow::onAppStateChanged(Qt::ApplicationState state)
|
|||||||
|
|
||||||
QString MainWindow::loadErrorStr(int error)
|
QString MainWindow::loadErrorStr(int error)
|
||||||
{
|
{
|
||||||
switch (error)
|
/*switch (error)
|
||||||
{
|
{
|
||||||
case Frontend::Load_BIOS9Missing:
|
case Frontend::Load_BIOS9Missing:
|
||||||
return "DS ARM9 BIOS was not found or could not be accessed. Check your emu settings.";
|
return "DS ARM9 BIOS was not found or could not be accessed. Check your emu settings.";
|
||||||
@ -1921,7 +1924,8 @@ QString MainWindow::loadErrorStr(int error)
|
|||||||
return "Failed to load the ROM. Make sure the file is accessible and isn't used by another application.";
|
return "Failed to load the ROM. Make sure the file is accessible and isn't used by another application.";
|
||||||
|
|
||||||
default: return "Unknown error during launch; smack Arisotura.";
|
default: return "Unknown error during launch; smack Arisotura.";
|
||||||
}
|
}*/
|
||||||
|
return "REMOVE ME";
|
||||||
}
|
}
|
||||||
|
|
||||||
/*void MainWindow::loadROM(QByteArray *romData, QString archiveFileName, QString romFileName)
|
/*void MainWindow::loadROM(QByteArray *romData, QString archiveFileName, QString romFileName)
|
||||||
@ -2146,8 +2150,6 @@ void MainWindow::onOpenFile()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: add to recent ROM list
|
|
||||||
|
|
||||||
if (!ROMManager::LoadROM(file, true))
|
if (!ROMManager::LoadROM(file, true))
|
||||||
{
|
{
|
||||||
// TODO: better error reporting?
|
// TODO: better error reporting?
|
||||||
@ -2156,6 +2158,11 @@ void MainWindow::onOpenFile()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString filename = file.join('|');
|
||||||
|
recentFileList.removeAll(filename);
|
||||||
|
recentFileList.prepend(filename);
|
||||||
|
updateRecentFilesMenu();
|
||||||
|
|
||||||
NDS::Start();
|
NDS::Start();
|
||||||
emuThread->emuRun();
|
emuThread->emuRun();
|
||||||
|
|
||||||
@ -2229,8 +2236,10 @@ void MainWindow::updateRecentFilesMenu()
|
|||||||
{
|
{
|
||||||
recentMenu->clear();
|
recentMenu->clear();
|
||||||
|
|
||||||
for(int i = 0; i < recentFileList.size(); ++i)
|
for (int i = 0; i < recentFileList.size(); ++i)
|
||||||
{
|
{
|
||||||
|
if (i >= 10) break;
|
||||||
|
|
||||||
QString item_full = recentFileList.at(i);
|
QString item_full = recentFileList.at(i);
|
||||||
QString item_display = item_full;
|
QString item_display = item_full;
|
||||||
int itemlen = item_full.length();
|
int itemlen = item_full.length();
|
||||||
@ -2257,16 +2266,18 @@ void MainWindow::updateRecentFilesMenu()
|
|||||||
actRecentFile_i->setData(item_full);
|
actRecentFile_i->setData(item_full);
|
||||||
connect(actRecentFile_i, &QAction::triggered, this, &MainWindow::onClickRecentFile);
|
connect(actRecentFile_i, &QAction::triggered, this, &MainWindow::onClickRecentFile);
|
||||||
|
|
||||||
if (i < 10)
|
|
||||||
Config::RecentROMList[i] = recentFileList.at(i).toStdString();
|
Config::RecentROMList[i] = recentFileList.at(i).toStdString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while (recentFileList.size() > 10)
|
||||||
|
recentFileList.removeLast();
|
||||||
|
|
||||||
recentMenu->addSeparator();
|
recentMenu->addSeparator();
|
||||||
|
|
||||||
QAction *actClearRecentList = recentMenu->addAction("Clear");
|
QAction *actClearRecentList = recentMenu->addAction("Clear");
|
||||||
connect(actClearRecentList, &QAction::triggered, this, &MainWindow::onClearRecentFiles);
|
connect(actClearRecentList, &QAction::triggered, this, &MainWindow::onClearRecentFiles);
|
||||||
|
|
||||||
if(recentFileList.empty())
|
if (recentFileList.empty())
|
||||||
actClearRecentList->setEnabled(false);
|
actClearRecentList->setEnabled(false);
|
||||||
|
|
||||||
Config::Save();
|
Config::Save();
|
||||||
@ -2274,29 +2285,35 @@ void MainWindow::updateRecentFilesMenu()
|
|||||||
|
|
||||||
void MainWindow::onClickRecentFile()
|
void MainWindow::onClickRecentFile()
|
||||||
{
|
{
|
||||||
/*QAction *act = (QAction *)sender();
|
QAction *act = (QAction *)sender();
|
||||||
QString fileName = act->data().toString();
|
QString filename = act->data().toString();
|
||||||
|
QStringList file = filename.split('|');
|
||||||
|
|
||||||
if (fileName.endsWith(".gba", Qt::CaseInsensitive) ||
|
|
||||||
fileName.endsWith(".nds", Qt::CaseInsensitive) ||
|
|
||||||
fileName.endsWith(".srl", Qt::CaseInsensitive) ||
|
|
||||||
fileName.endsWith(".dsi", Qt::CaseInsensitive))
|
|
||||||
{
|
|
||||||
emuThread->emuPause();
|
emuThread->emuPause();
|
||||||
loadROM(fileName);
|
|
||||||
}
|
if (!verifySetup())
|
||||||
else
|
|
||||||
{
|
{
|
||||||
// Archives
|
emuThread->emuUnpause();
|
||||||
QString archiveFileName = fileName;
|
return;
|
||||||
QByteArray romBuffer;
|
|
||||||
QString romFileName = MainWindow::pickAndExtractFileFromArchive(archiveFileName, &romBuffer);
|
|
||||||
if(!romFileName.isEmpty())
|
|
||||||
{
|
|
||||||
emuThread->emuPause();
|
|
||||||
loadROM(&romBuffer, archiveFileName, romFileName);
|
|
||||||
}
|
}
|
||||||
}*/
|
|
||||||
|
if (!ROMManager::LoadROM(file, true))
|
||||||
|
{
|
||||||
|
// TODO: better error reporting?
|
||||||
|
QMessageBox::critical(this, "melonDS", "Failed to load the ROM.");
|
||||||
|
emuThread->emuUnpause();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
recentFileList.removeAll(filename);
|
||||||
|
recentFileList.prepend(filename);
|
||||||
|
updateRecentFilesMenu();
|
||||||
|
|
||||||
|
NDS::Start();
|
||||||
|
emuThread->emuRun();
|
||||||
|
|
||||||
|
actCurrentCart->setText("DS slot: " + ROMManager::CartLabel());
|
||||||
|
actEjectCart->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onBootFirmware()
|
void MainWindow::onBootFirmware()
|
||||||
|
Reference in New Issue
Block a user