mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-25 07:10:00 -06:00
Extract gba roms to memory
Signed-off-by: Madhav Kanbur <abcdjdj@gmail.com>
This commit is contained in:
@ -677,6 +677,20 @@ bool LoadROM(const char* path, const char* sram)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LoadROM(const u8* romdata, u32 filelength, const char *sram)
|
||||
{
|
||||
CartROMSize = 0x200;
|
||||
while (CartROMSize < filelength)
|
||||
CartROMSize <<= 1;
|
||||
|
||||
CartROM = new u8[CartROMSize];
|
||||
memcpy(CartROM, romdata, filelength);
|
||||
|
||||
LoadROMCommon(sram);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void RelocateSave(const char* path, bool write)
|
||||
{
|
||||
// derp herp
|
||||
|
@ -66,6 +66,7 @@ void Eject();
|
||||
|
||||
void DoSavestate(Savestate* file);
|
||||
bool LoadROM(const char* path, const char* sram);
|
||||
bool LoadROM(const u8* romdata, u32 filelength, const char *sram);
|
||||
void RelocateSave(const char* path, bool write);
|
||||
|
||||
void WriteGPIO(u32 addr, u16 val);
|
||||
|
13
src/NDS.cpp
13
src/NDS.cpp
@ -864,6 +864,19 @@ bool LoadGBAROM(const char* path, const char* sram)
|
||||
}
|
||||
}
|
||||
|
||||
bool LoadGBAROM(const u8* romdata, u32 filelength, const char *filename, const char *sram)
|
||||
{
|
||||
if (GBACart::LoadROM(romdata, filelength, sram))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Failed to load ROM %s from archive\n", filename);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void LoadBIOS()
|
||||
{
|
||||
Reset();
|
||||
|
@ -195,6 +195,7 @@ void SetConsoleType(int type);
|
||||
bool LoadROM(const char* path, const char* sram, bool direct);
|
||||
bool LoadROM(const u8* romdata, u32 filelength, const char *sram, bool direct);
|
||||
bool LoadGBAROM(const char* path, const char* sram);
|
||||
bool LoadGBAROM(const u8* romdata, u32 filelength, const char *filename, const char *sram);
|
||||
void LoadBIOS();
|
||||
void SetupDirectBoot();
|
||||
void RelocateSave(const char* path, bool write);
|
||||
|
@ -350,13 +350,13 @@ int LoadROM(const QByteArray *romdata, QString archivefilename, QString romfilen
|
||||
strncpy(PrevSRAMPath[slot], SRAMPath[slot], 1024); // safety
|
||||
return Load_OK;
|
||||
}
|
||||
/*else if (slot == ROMSlot_GBA && NDS::LoadGBAROM(ROMPath[slot], SRAMPath[slot]))
|
||||
else if (slot == ROMSlot_GBA && NDS::LoadGBAROM((const u8*)romdata->constData(), romdata->size(), romfilename.toStdString().c_str(), SRAMPath[slot]))
|
||||
{
|
||||
SavestateLoaded = false; // checkme??
|
||||
|
||||
strncpy(PrevSRAMPath[slot], SRAMPath[slot], 1024); // safety
|
||||
return Load_OK;
|
||||
}*/
|
||||
}
|
||||
else
|
||||
{
|
||||
strncpy(ROMPath[slot], oldpath, 1024);
|
||||
|
@ -1507,20 +1507,17 @@ void MainWindow::loadROM(QByteArray *romData, QString archiveFileName, QString r
|
||||
strncpy(Config::LastROMFolder, QFileInfo(archiveFileName).absolutePath().toStdString().c_str(), 1024);
|
||||
|
||||
int slot; int res;
|
||||
/*if (!strcasecmp(ext, "gba"))
|
||||
if (romFileName.endsWith("gba"))
|
||||
{
|
||||
slot = 1;
|
||||
res = Frontend::LoadROM(file, Frontend::ROMSlot_GBA);
|
||||
res = Frontend::LoadROM(romData, archiveFileName, romFileName, Frontend::ROMSlot_GBA);
|
||||
}
|
||||
else
|
||||
{
|
||||
slot = 0;
|
||||
res = Frontend::LoadROM(file, Frontend::ROMSlot_NDS);
|
||||
}*/
|
||||
res = Frontend::LoadROM(romData, archiveFileName, romFileName, Frontend::ROMSlot_NDS);
|
||||
}
|
||||
|
||||
// TODO: GBA support here!
|
||||
slot = 0;
|
||||
res = Frontend::LoadROM(romData, archiveFileName, romFileName, Frontend::ROMSlot_NDS);
|
||||
if (res != Frontend::Load_OK)
|
||||
{
|
||||
QMessageBox::critical(this,
|
||||
|
Reference in New Issue
Block a user