mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-26 15:50:00 -06:00
bulldoze more shit. make cheats work again.
This commit is contained in:
@ -50,8 +50,6 @@ void DeInit()
|
|||||||
|
|
||||||
void Reset()
|
void Reset()
|
||||||
{
|
{
|
||||||
CodeFile = nullptr;
|
|
||||||
|
|
||||||
if (NDS::ConsoleType == 1)
|
if (NDS::ConsoleType == 1)
|
||||||
{
|
{
|
||||||
BusRead8 = DSi::ARM7Read8;
|
BusRead8 = DSi::ARM7Read8;
|
||||||
@ -73,6 +71,11 @@ void Reset()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ARCodeFile* GetCodeFile()
|
||||||
|
{
|
||||||
|
return CodeFile;
|
||||||
|
}
|
||||||
|
|
||||||
void SetCodeFile(ARCodeFile* file)
|
void SetCodeFile(ARCodeFile* file)
|
||||||
{
|
{
|
||||||
CodeFile = file;
|
CodeFile = file;
|
||||||
|
@ -28,6 +28,7 @@ bool Init();
|
|||||||
void DeInit();
|
void DeInit();
|
||||||
void Reset();
|
void Reset();
|
||||||
|
|
||||||
|
ARCodeFile* GetCodeFile();
|
||||||
void SetCodeFile(ARCodeFile* file);
|
void SetCodeFile(ARCodeFile* file);
|
||||||
|
|
||||||
void RunCheats();
|
void RunCheats();
|
||||||
|
@ -75,23 +75,8 @@ void Init_ROM();
|
|||||||
// deinitialize the ROM handling utility
|
// deinitialize the ROM handling utility
|
||||||
void DeInit_ROM();
|
void DeInit_ROM();
|
||||||
|
|
||||||
// load the BIOS/firmware and boot from it
|
|
||||||
int LoadBIOS();
|
|
||||||
|
|
||||||
// load a ROM file to the specified cart slot
|
|
||||||
// note: loading a ROM to the NDS slot resets emulation
|
|
||||||
int LoadROM(const char* file, int slot);
|
|
||||||
int LoadROM(const u8 *romdata, u32 romlength, const char *archivefilename, const char *romfilename, const char *sramfilename, int slot);
|
|
||||||
|
|
||||||
// unload the ROM loaded in the specified cart slot
|
|
||||||
// simulating ejection of the cartridge
|
|
||||||
void UnloadROM(int slot);
|
|
||||||
|
|
||||||
void ROMIcon(u8 (&data)[512], u16 (&palette)[16], u32* iconRef);
|
|
||||||
void AnimatedROMIcon(u8 (&data)[8][512], u16 (&palette)[8][16], u16 (&sequence)[64], u32 (&animatedTexRef)[32 * 32 * 64], std::vector<int> &animatedSequenceRef);
|
|
||||||
|
|
||||||
// reset execution of the current ROM
|
|
||||||
int Reset();
|
|
||||||
|
|
||||||
// get the filename associated with the given savestate slot (1-8)
|
// get the filename associated with the given savestate slot (1-8)
|
||||||
std::string GetSavestateName(int slot);
|
std::string GetSavestateName(int slot);
|
||||||
@ -109,12 +94,6 @@ bool SaveState(std::string filename);
|
|||||||
// undo the latest savestate load
|
// undo the latest savestate load
|
||||||
void UndoStateLoad();
|
void UndoStateLoad();
|
||||||
|
|
||||||
// imports savedata from an external file. Returns the difference between the filesize and the SRAM size
|
|
||||||
int ImportSRAM(const char* filename);
|
|
||||||
|
|
||||||
// enable or disable cheats
|
|
||||||
void EnableCheats(bool enable);
|
|
||||||
|
|
||||||
|
|
||||||
// setup the display layout based on the provided display size and parameters
|
// setup the display layout based on the provided display size and parameters
|
||||||
// * screenWidth/screenHeight: size of the host display
|
// * screenWidth/screenHeight: size of the host display
|
||||||
|
@ -75,591 +75,9 @@ void DeInit_ROM()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: currently, when failing to load a ROM for whatever reason, we attempt
|
|
||||||
// to revert to the previous state and resume execution; this may not be a very
|
|
||||||
// good thing, depending on what state the core was left in.
|
|
||||||
// should we do a better state revert (via the savestate system)? completely stop?
|
|
||||||
|
|
||||||
void SetupSRAMPath(int slot)
|
|
||||||
{
|
|
||||||
SRAMPath[slot] = ROMPath[slot].substr(0, ROMPath[slot].length() - 3) + "sav";
|
|
||||||
}
|
|
||||||
|
|
||||||
int VerifyDSBIOS()
|
|
||||||
{
|
|
||||||
FILE* f;
|
|
||||||
long len;
|
|
||||||
|
|
||||||
if (!Config::ExternalBIOSEnable) return Load_OK;
|
|
||||||
|
|
||||||
f = Platform::OpenLocalFile(Config::BIOS9Path, "rb");
|
|
||||||
if (!f) return Load_BIOS9Missing;
|
|
||||||
|
|
||||||
fseek(f, 0, SEEK_END);
|
|
||||||
len = ftell(f);
|
|
||||||
if (len != 0x1000)
|
|
||||||
{
|
|
||||||
fclose(f);
|
|
||||||
return Load_BIOS9Bad;
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose(f);
|
|
||||||
|
|
||||||
f = Platform::OpenLocalFile(Config::BIOS7Path, "rb");
|
|
||||||
if (!f) return Load_BIOS7Missing;
|
|
||||||
|
|
||||||
fseek(f, 0, SEEK_END);
|
|
||||||
len = ftell(f);
|
|
||||||
if (len != 0x4000)
|
|
||||||
{
|
|
||||||
fclose(f);
|
|
||||||
return Load_BIOS7Bad;
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose(f);
|
|
||||||
|
|
||||||
return Load_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
int VerifyDSiBIOS()
|
|
||||||
{
|
|
||||||
FILE* f;
|
|
||||||
long len;
|
|
||||||
|
|
||||||
// TODO: check the first 32 bytes
|
|
||||||
|
|
||||||
f = Platform::OpenLocalFile(Config::DSiBIOS9Path, "rb");
|
|
||||||
if (!f) return Load_DSiBIOS9Missing;
|
|
||||||
|
|
||||||
fseek(f, 0, SEEK_END);
|
|
||||||
len = ftell(f);
|
|
||||||
if (len != 0x10000)
|
|
||||||
{
|
|
||||||
fclose(f);
|
|
||||||
return Load_DSiBIOS9Bad;
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose(f);
|
|
||||||
|
|
||||||
f = Platform::OpenLocalFile(Config::DSiBIOS7Path, "rb");
|
|
||||||
if (!f) return Load_DSiBIOS7Missing;
|
|
||||||
|
|
||||||
fseek(f, 0, SEEK_END);
|
|
||||||
len = ftell(f);
|
|
||||||
if (len != 0x10000)
|
|
||||||
{
|
|
||||||
fclose(f);
|
|
||||||
return Load_DSiBIOS7Bad;
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose(f);
|
|
||||||
|
|
||||||
return Load_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
int VerifyDSFirmware()
|
|
||||||
{
|
|
||||||
FILE* f;
|
|
||||||
long len;
|
|
||||||
|
|
||||||
if (!Config::ExternalBIOSEnable) return Load_FirmwareNotBootable;
|
|
||||||
|
|
||||||
f = Platform::OpenLocalFile(Config::FirmwarePath, "rb");
|
|
||||||
if (!f) return Load_FirmwareNotBootable;
|
|
||||||
|
|
||||||
fseek(f, 0, SEEK_END);
|
|
||||||
len = ftell(f);
|
|
||||||
if (len == 0x20000)
|
|
||||||
{
|
|
||||||
// 128KB firmware, not bootable
|
|
||||||
fclose(f);
|
|
||||||
return Load_FirmwareNotBootable;
|
|
||||||
}
|
|
||||||
else if (len != 0x40000 && len != 0x80000)
|
|
||||||
{
|
|
||||||
fclose(f);
|
|
||||||
return Load_FirmwareBad;
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose(f);
|
|
||||||
|
|
||||||
return Load_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
int VerifyDSiFirmware()
|
|
||||||
{
|
|
||||||
FILE* f;
|
|
||||||
long len;
|
|
||||||
|
|
||||||
f = Platform::OpenLocalFile(Config::DSiFirmwarePath, "rb");
|
|
||||||
if (!f) return Load_FirmwareMissing;
|
|
||||||
|
|
||||||
fseek(f, 0, SEEK_END);
|
|
||||||
len = ftell(f);
|
|
||||||
if (len != 0x20000)
|
|
||||||
{
|
|
||||||
// not 128KB
|
|
||||||
// TODO: check whether those work
|
|
||||||
fclose(f);
|
|
||||||
return Load_FirmwareBad;
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose(f);
|
|
||||||
|
|
||||||
return Load_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
int SetupDSiNAND()
|
|
||||||
{
|
|
||||||
FILE* f;
|
|
||||||
long len;
|
|
||||||
|
|
||||||
f = Platform::OpenLocalFile(Config::DSiNANDPath, "r+b");
|
|
||||||
if (!f) return Load_DSiNANDMissing;
|
|
||||||
|
|
||||||
// TODO: some basic checks
|
|
||||||
// check that it has the nocash footer, and all
|
|
||||||
|
|
||||||
//DSi::SDMMCFile = f;
|
|
||||||
|
|
||||||
return Load_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
void LoadCheats()
|
|
||||||
{
|
|
||||||
if (CheatFile)
|
|
||||||
{
|
|
||||||
delete CheatFile;
|
|
||||||
CheatFile = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string filename;
|
|
||||||
if (!ROMPath[ROMSlot_NDS].empty())
|
|
||||||
{
|
|
||||||
filename = ROMPath[ROMSlot_NDS].substr(0, ROMPath[ROMSlot_NDS].length() - 3) + "mch";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
filename = "firmware.mch";
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: add custom path here
|
|
||||||
|
|
||||||
// TODO: check for error (malformed cheat file, ...)
|
|
||||||
CheatFile = new ARCodeFile(filename);
|
|
||||||
|
|
||||||
AREngine::SetCodeFile(CheatsOn ? CheatFile : nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
int LoadBIOS()
|
|
||||||
{
|
|
||||||
//DSi::CloseDSiNAND();
|
|
||||||
|
|
||||||
int res;
|
|
||||||
|
|
||||||
res = VerifyDSBIOS();
|
|
||||||
if (res != Load_OK) return res;
|
|
||||||
|
|
||||||
if (Config::ConsoleType == 1)
|
|
||||||
{
|
|
||||||
res = VerifyDSiBIOS();
|
|
||||||
if (res != Load_OK) return res;
|
|
||||||
|
|
||||||
res = VerifyDSiFirmware();
|
|
||||||
if (res != Load_OK) return res;
|
|
||||||
|
|
||||||
res = SetupDSiNAND();
|
|
||||||
if (res != Load_OK) return res;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
res = VerifyDSFirmware();
|
|
||||||
if (res != Load_OK) return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO:
|
|
||||||
// original code in the libui frontend called NDS::LoadGBAROM() if needed
|
|
||||||
// should this be carried over here?
|
|
||||||
// is that behavior consistent with that of LoadROM() below?
|
|
||||||
|
|
||||||
ROMPath[ROMSlot_NDS] = "";
|
|
||||||
SRAMPath[ROMSlot_NDS] = "";
|
|
||||||
|
|
||||||
NDS::SetConsoleType(Config::ConsoleType);
|
|
||||||
NDS::LoadBIOS();
|
|
||||||
|
|
||||||
SavestateLoaded = false;
|
|
||||||
|
|
||||||
LoadCheats();
|
|
||||||
|
|
||||||
return Load_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
int LoadROM(const u8 *romdata, u32 romlength, const char *archivefilename, const char *romfilename, const char *sramfilename, int slot)
|
|
||||||
{
|
|
||||||
int res;
|
|
||||||
bool directboot = Config::DirectBoot;
|
|
||||||
|
|
||||||
if (Config::ConsoleType == 1 && slot == 1)
|
|
||||||
{
|
|
||||||
// cannot load a GBA ROM into a DSi
|
|
||||||
return Load_ROMLoadError;
|
|
||||||
}
|
|
||||||
|
|
||||||
res = VerifyDSBIOS();
|
|
||||||
if (res != Load_OK) return res;
|
|
||||||
|
|
||||||
if (Config::ConsoleType == 1)
|
|
||||||
{
|
|
||||||
res = VerifyDSiBIOS();
|
|
||||||
if (res != Load_OK) return res;
|
|
||||||
|
|
||||||
res = VerifyDSiFirmware();
|
|
||||||
if (res != Load_OK) return res;
|
|
||||||
|
|
||||||
res = SetupDSiNAND();
|
|
||||||
if (res != Load_OK) return res;
|
|
||||||
|
|
||||||
//GBACart::Eject();
|
|
||||||
ROMPath[ROMSlot_GBA] = "";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
res = VerifyDSFirmware();
|
|
||||||
if (res != Load_OK)
|
|
||||||
{
|
|
||||||
if (res == Load_FirmwareNotBootable)
|
|
||||||
directboot = true;
|
|
||||||
else
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string oldpath = ROMPath[slot];
|
|
||||||
std::string oldsram = SRAMPath[slot];
|
|
||||||
|
|
||||||
SRAMPath[slot] = sramfilename;
|
|
||||||
ROMPath[slot] = archivefilename;
|
|
||||||
|
|
||||||
NDS::SetConsoleType(Config::ConsoleType);
|
|
||||||
|
|
||||||
/* if (slot == ROMSlot_NDS && NDS::LoadROM(romdata, romlength, SRAMPath[slot].c_str(), directboot))
|
|
||||||
{
|
|
||||||
SavestateLoaded = false;
|
|
||||||
|
|
||||||
LoadCheats();
|
|
||||||
|
|
||||||
// Reload the inserted GBA cartridge (if any)
|
|
||||||
// TODO: report failure there??
|
|
||||||
//if (!ROMPath[ROMSlot_GBA].empty()) NDS::LoadGBAROM(ROMPath[ROMSlot_GBA], SRAMPath[ROMSlot_GBA]);
|
|
||||||
|
|
||||||
PrevSRAMPath[slot] = SRAMPath[slot]; // safety
|
|
||||||
return Load_OK;
|
|
||||||
}
|
|
||||||
else if (slot == ROMSlot_GBA && NDS::LoadGBAROM(romdata, romlength, romfilename, SRAMPath[slot].c_str()))
|
|
||||||
{
|
|
||||||
SavestateLoaded = false; // checkme??
|
|
||||||
|
|
||||||
PrevSRAMPath[slot] = SRAMPath[slot]; // safety
|
|
||||||
return Load_OK;
|
|
||||||
}
|
|
||||||
else*/
|
|
||||||
{
|
|
||||||
ROMPath[slot] = oldpath;
|
|
||||||
SRAMPath[slot] = oldsram;
|
|
||||||
return Load_ROMLoadError;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int LoadROM(const char* file, int slot)
|
|
||||||
{
|
|
||||||
//DSi::CloseDSiNAND();
|
|
||||||
|
|
||||||
int res;
|
|
||||||
bool directboot = Config::DirectBoot != 0;
|
|
||||||
|
|
||||||
if (Config::ConsoleType == 1 && slot == 1)
|
|
||||||
{
|
|
||||||
// cannot load a GBA ROM into a DSi
|
|
||||||
return Load_ROMLoadError;
|
|
||||||
}
|
|
||||||
|
|
||||||
res = VerifyDSBIOS();
|
|
||||||
if (res != Load_OK) return res;
|
|
||||||
|
|
||||||
if (Config::ConsoleType == 1)
|
|
||||||
{
|
|
||||||
res = VerifyDSiBIOS();
|
|
||||||
if (res != Load_OK) return res;
|
|
||||||
|
|
||||||
res = VerifyDSiFirmware();
|
|
||||||
if (res != Load_OK) return res;
|
|
||||||
|
|
||||||
res = SetupDSiNAND();
|
|
||||||
if (res != Load_OK) return res;
|
|
||||||
|
|
||||||
//GBACart::Eject();
|
|
||||||
ROMPath[ROMSlot_GBA] = "";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
res = VerifyDSFirmware();
|
|
||||||
if (res != Load_OK)
|
|
||||||
{
|
|
||||||
if (res == Load_FirmwareNotBootable)
|
|
||||||
directboot = true;
|
|
||||||
else
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string oldpath = ROMPath[slot];
|
|
||||||
std::string oldsram = SRAMPath[slot];
|
|
||||||
|
|
||||||
ROMPath[slot] = file;
|
|
||||||
|
|
||||||
SetupSRAMPath(0);
|
|
||||||
SetupSRAMPath(1);
|
|
||||||
|
|
||||||
NDS::SetConsoleType(Config::ConsoleType);
|
|
||||||
|
|
||||||
/*if (slot == ROMSlot_NDS && NDS::LoadROM(ROMPath[slot].c_str(), SRAMPath[slot].c_str(), directboot))
|
|
||||||
{
|
|
||||||
SavestateLoaded = false;
|
|
||||||
|
|
||||||
LoadCheats();
|
|
||||||
|
|
||||||
// Reload the inserted GBA cartridge (if any)
|
|
||||||
// TODO: report failure there??
|
|
||||||
if (!ROMPath[ROMSlot_GBA].empty()) NDS::LoadGBAROM(ROMPath[ROMSlot_GBA].c_str(), SRAMPath[ROMSlot_GBA].c_str());
|
|
||||||
|
|
||||||
PrevSRAMPath[slot] = SRAMPath[slot]; // safety
|
|
||||||
return Load_OK;
|
|
||||||
}
|
|
||||||
else if (slot == ROMSlot_GBA && NDS::LoadGBAROM(ROMPath[slot].c_str(), SRAMPath[slot].c_str()))
|
|
||||||
{
|
|
||||||
SavestateLoaded = false; // checkme??
|
|
||||||
|
|
||||||
PrevSRAMPath[slot] = SRAMPath[slot]; // safety
|
|
||||||
return Load_OK;
|
|
||||||
}
|
|
||||||
else*/
|
|
||||||
{
|
|
||||||
ROMPath[slot] = oldpath;
|
|
||||||
SRAMPath[slot] = oldsram;
|
|
||||||
return Load_ROMLoadError;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ROMIcon(u8 (&data)[512], u16 (&palette)[16], u32* iconRef)
|
|
||||||
{
|
|
||||||
int index = 0;
|
|
||||||
for (int i = 0; i < 4; i++)
|
|
||||||
{
|
|
||||||
for (int j = 0; j < 4; j++)
|
|
||||||
{
|
|
||||||
for (int k = 0; k < 8; k++)
|
|
||||||
{
|
|
||||||
for (int l = 0; l < 8; l++)
|
|
||||||
{
|
|
||||||
u8 pal_index = index % 2 ? data[index/2] >> 4 : data[index/2] & 0x0F;
|
|
||||||
u8 r = ((palette[pal_index] >> 0) & 0x1F) * 255 / 31;
|
|
||||||
u8 g = ((palette[pal_index] >> 5) & 0x1F) * 255 / 31;
|
|
||||||
u8 b = ((palette[pal_index] >> 10) & 0x1F) * 255 / 31;
|
|
||||||
u8 a = pal_index ? 255: 0;
|
|
||||||
u32* row = &iconRef[256 * i + 32 * k + 8 * j];
|
|
||||||
row[l] = (a << 24) | (r << 16) | (g << 8) | b;
|
|
||||||
index++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#define SEQ_FLIPV(i) ((i & 0b1000000000000000) >> 15)
|
|
||||||
#define SEQ_FLIPH(i) ((i & 0b0100000000000000) >> 14)
|
|
||||||
#define SEQ_PAL(i) ((i & 0b0011100000000000) >> 11)
|
|
||||||
#define SEQ_BMP(i) ((i & 0b0000011100000000) >> 8)
|
|
||||||
#define SEQ_DUR(i) ((i & 0b0000000011111111) >> 0)
|
|
||||||
|
|
||||||
void AnimatedROMIcon(u8 (&data)[8][512], u16 (&palette)[8][16], u16 (&sequence)[64], u32 (&animatedTexRef)[32 * 32 * 64], std::vector<int> &animatedSequenceRef)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < 64; i++)
|
|
||||||
{
|
|
||||||
if (!sequence[i])
|
|
||||||
break;
|
|
||||||
u32* frame = &animatedTexRef[32 * 32 * i];
|
|
||||||
ROMIcon(data[SEQ_BMP(sequence[i])], palette[SEQ_PAL(sequence[i])], frame);
|
|
||||||
|
|
||||||
if (SEQ_FLIPH(sequence[i]))
|
|
||||||
{
|
|
||||||
for (int x = 0; x < 32; x++)
|
|
||||||
{
|
|
||||||
for (int y = 0; y < 32/2; y++)
|
|
||||||
{
|
|
||||||
std::swap(frame[x * 32 + y], frame[x * 32 + (32 - 1 - y)]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (SEQ_FLIPV(sequence[i]))
|
|
||||||
{
|
|
||||||
for (int x = 0; x < 32/2; x++)
|
|
||||||
{
|
|
||||||
for (int y = 0; y < 32; y++)
|
|
||||||
{
|
|
||||||
std::swap(frame[x * 32 + y], frame[(32 - 1 - x) * 32 + y]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int j = 0; j < SEQ_DUR(sequence[i]); j++)
|
|
||||||
animatedSequenceRef.push_back(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void UnloadROM(int slot)
|
|
||||||
{
|
|
||||||
if (slot == ROMSlot_NDS)
|
|
||||||
{
|
|
||||||
// TODO!
|
|
||||||
}
|
|
||||||
else if (slot == ROMSlot_GBA)
|
|
||||||
{
|
|
||||||
// GBACart::Eject();
|
|
||||||
}
|
|
||||||
|
|
||||||
ROMPath[slot] = "";
|
|
||||||
|
|
||||||
// DSi::CloseDSiNAND();
|
|
||||||
}
|
|
||||||
|
|
||||||
int Reset()
|
|
||||||
{
|
|
||||||
// DSi::CloseDSiNAND();
|
|
||||||
|
|
||||||
int res;
|
|
||||||
bool directboot = Config::DirectBoot != 0;
|
|
||||||
|
|
||||||
res = VerifyDSBIOS();
|
|
||||||
if (res != Load_OK) return res;
|
|
||||||
|
|
||||||
if (Config::ConsoleType == 1)
|
|
||||||
{
|
|
||||||
res = VerifyDSiBIOS();
|
|
||||||
if (res != Load_OK) return res;
|
|
||||||
|
|
||||||
res = VerifyDSiFirmware();
|
|
||||||
if (res != Load_OK) return res;
|
|
||||||
|
|
||||||
res = SetupDSiNAND();
|
|
||||||
if (res != Load_OK) return res;
|
|
||||||
|
|
||||||
// GBACart::Eject();
|
|
||||||
ROMPath[ROMSlot_GBA][0] = '\0';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
res = VerifyDSFirmware();
|
|
||||||
if (res != Load_OK)
|
|
||||||
{
|
|
||||||
if (res == Load_FirmwareNotBootable)
|
|
||||||
directboot = true;
|
|
||||||
else
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SavestateLoaded = false;
|
|
||||||
|
|
||||||
NDS::SetConsoleType(Config::ConsoleType);
|
|
||||||
|
|
||||||
if (ROMPath[ROMSlot_NDS].empty())
|
|
||||||
{
|
|
||||||
NDS::LoadBIOS();
|
|
||||||
}
|
|
||||||
/*else
|
|
||||||
{
|
|
||||||
std::string ext = ROMPath[ROMSlot_NDS].substr(ROMPath[ROMSlot_NDS].length() - 4);
|
|
||||||
std::transform(ext.begin(), ext.end(), ext.begin(), tolower);
|
|
||||||
|
|
||||||
if (ext == ".nds" || ext == ".srl" || ext == ".dsi")
|
|
||||||
{
|
|
||||||
SetupSRAMPath(0);
|
|
||||||
if (!NDS::LoadROM(ROMPath[ROMSlot_NDS].c_str(), SRAMPath[ROMSlot_NDS].c_str(), directboot))
|
|
||||||
return Load_ROMLoadError;
|
|
||||||
}
|
|
||||||
#ifdef ARCHIVE_SUPPORT_ENABLED
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// TODO!!!
|
|
||||||
// THIS WILL BREAK IF CUSTOM SRAM PATHS ARE ADDED
|
|
||||||
|
|
||||||
/*u8 *romdata = nullptr; u32 romlen;
|
|
||||||
char romfilename[1024] = {0}, sramfilename[1024];
|
|
||||||
strncpy(sramfilename, SRAMPath[ROMSlot_NDS], 1024); // Use existing SRAMPath
|
|
||||||
|
|
||||||
int pos = strlen(sramfilename) - 1;
|
|
||||||
while (pos > 0 && sramfilename[pos] != '/' && sramfilename[pos] != '\\')
|
|
||||||
--pos;
|
|
||||||
|
|
||||||
strncpy(romfilename, &sramfilename[pos + 1], 1024);
|
|
||||||
strncpy(&romfilename[strlen(romfilename) - 3], NDSROMExtension, 3); // extension could be nds, srl or dsi
|
|
||||||
printf("RESET loading from archive : %s\n", romfilename);
|
|
||||||
romlen = Archive::ExtractFileFromArchive(ROMPath[ROMSlot_NDS], romfilename, &romdata);
|
|
||||||
if (!romdata)
|
|
||||||
return Load_ROMLoadError;
|
|
||||||
|
|
||||||
bool ok = NDS::LoadROM(romdata, romlen, sramfilename, directboot);
|
|
||||||
delete romdata;
|
|
||||||
if (!ok)*-/
|
|
||||||
return Load_ROMLoadError;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ROMPath[ROMSlot_GBA].empty())
|
|
||||||
{
|
|
||||||
std::string ext = ROMPath[ROMSlot_GBA].substr(ROMPath[ROMSlot_GBA].length() - 4);
|
|
||||||
std::transform(ext.begin(), ext.end(), ext.begin(), tolower);
|
|
||||||
|
|
||||||
if (ext == ".gba")
|
|
||||||
{
|
|
||||||
SetupSRAMPath(1);
|
|
||||||
if (!NDS::LoadGBAROM(ROMPath[ROMSlot_GBA].c_str(), SRAMPath[ROMSlot_GBA].c_str()))
|
|
||||||
return Load_ROMLoadError;
|
|
||||||
}
|
|
||||||
#ifdef ARCHIVE_SUPPORT_ENABLED
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// TODO!! SAME AS ABOVE
|
|
||||||
|
|
||||||
/*u8 *romdata = nullptr; u32 romlen;
|
|
||||||
char romfilename[1024] = {0}, sramfilename[1024];
|
|
||||||
strncpy(sramfilename, SRAMPath[ROMSlot_GBA], 1024); // Use existing SRAMPath
|
|
||||||
|
|
||||||
int pos = strlen(sramfilename) - 1;
|
|
||||||
while (pos > 0 && sramfilename[pos] != '/' && sramfilename[pos] != '\\')
|
|
||||||
--pos;
|
|
||||||
|
|
||||||
strncpy(romfilename, &sramfilename[pos + 1], 1024);
|
|
||||||
strncpy(&romfilename[strlen(romfilename) - 3], "gba", 3);
|
|
||||||
printf("RESET loading from archive : %s\n", romfilename);
|
|
||||||
romlen = Archive::ExtractFileFromArchive(ROMPath[ROMSlot_GBA], romfilename, &romdata);
|
|
||||||
if (!romdata)
|
|
||||||
return Load_ROMLoadError;
|
|
||||||
|
|
||||||
bool ok = NDS::LoadGBAROM(romdata, romlen, romfilename, SRAMPath[ROMSlot_GBA]);
|
|
||||||
delete romdata;
|
|
||||||
if (!ok)*-/
|
|
||||||
return Load_ROMLoadError;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}*/
|
|
||||||
|
|
||||||
LoadCheats();
|
|
||||||
|
|
||||||
return Load_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// SAVESTATE TODO
|
// SAVESTATE TODO
|
||||||
@ -824,11 +242,4 @@ int ImportSRAM(const char* filename)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EnableCheats(bool enable)
|
|
||||||
{
|
|
||||||
CheatsOn = enable;
|
|
||||||
if (CheatFile)
|
|
||||||
AREngine::SetCodeFile(CheatsOn ? CheatFile : nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "Platform.h"
|
#include "Platform.h"
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
#include "ROMManager.h"
|
||||||
|
|
||||||
#include "CheatsDialog.h"
|
#include "CheatsDialog.h"
|
||||||
#include "ui_CheatsDialog.h"
|
#include "ui_CheatsDialog.h"
|
||||||
@ -33,15 +34,13 @@ CheatsDialog* CheatsDialog::currentDlg = nullptr;
|
|||||||
|
|
||||||
extern std::string EmuDirectory;
|
extern std::string EmuDirectory;
|
||||||
|
|
||||||
namespace Frontend { extern ARCodeFile* CheatFile; }
|
|
||||||
|
|
||||||
|
|
||||||
CheatsDialog::CheatsDialog(QWidget* parent) : QDialog(parent), ui(new Ui::CheatsDialog)
|
CheatsDialog::CheatsDialog(QWidget* parent) : QDialog(parent), ui(new Ui::CheatsDialog)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
|
||||||
codeFile = Frontend::CheatFile;
|
codeFile = ROMManager::GetCheatFile();
|
||||||
|
|
||||||
QStandardItemModel* model = new QStandardItemModel();
|
QStandardItemModel* model = new QStandardItemModel();
|
||||||
ui->tvCodeList->setModel(model);
|
ui->tvCodeList->setModel(model);
|
||||||
|
@ -45,14 +45,14 @@ ROMInfoDialog::ROMInfoDialog(QWidget* parent) : QDialog(parent), ui(new Ui::ROMI
|
|||||||
|
|
||||||
|
|
||||||
u32 iconData[32 * 32];
|
u32 iconData[32 * 32];
|
||||||
Frontend::ROMIcon(NDSCart::Banner.Icon, NDSCart::Banner.Palette, iconData);
|
ROMManager::ROMIcon(NDSCart::Banner.Icon, NDSCart::Banner.Palette, iconData);
|
||||||
iconImage = QImage(reinterpret_cast<unsigned char*>(iconData), 32, 32, QImage::Format_ARGB32).copy();
|
iconImage = QImage(reinterpret_cast<unsigned char*>(iconData), 32, 32, QImage::Format_ARGB32).copy();
|
||||||
ui->iconImage->setPixmap(QPixmap::fromImage(iconImage));
|
ui->iconImage->setPixmap(QPixmap::fromImage(iconImage));
|
||||||
|
|
||||||
if (NDSCart::Banner.Version == 0x103)
|
if (NDSCart::Banner.Version == 0x103)
|
||||||
{
|
{
|
||||||
u32 animatedIconData[32 * 32 * 64] = {0};
|
u32 animatedIconData[32 * 32 * 64] = {0};
|
||||||
Frontend::AnimatedROMIcon(NDSCart::Banner.DSiIcon, NDSCart::Banner.DSiPalette, NDSCart::Banner.DSiSequence, animatedIconData, animatedSequence);
|
ROMManager::AnimatedROMIcon(NDSCart::Banner.DSiIcon, NDSCart::Banner.DSiPalette, NDSCart::Banner.DSiSequence, animatedIconData, animatedSequence);
|
||||||
|
|
||||||
for (int i = 0; i < 64; i++)
|
for (int i = 0; i < 64; i++)
|
||||||
{
|
{
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
#include <QImage>
|
#include <QImage>
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "FrontendUtil.h"
|
#include "ROMManager.h"
|
||||||
|
|
||||||
namespace Ui { class ROMInfoDialog; }
|
namespace Ui { class ROMInfoDialog; }
|
||||||
class ROMInfoDialog;
|
class ROMInfoDialog;
|
||||||
|
@ -32,12 +32,11 @@
|
|||||||
#include "NDS.h"
|
#include "NDS.h"
|
||||||
#include "DSi.h"
|
#include "DSi.h"
|
||||||
|
|
||||||
#include "AREngine.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace ROMManager
|
namespace ROMManager
|
||||||
{
|
{
|
||||||
|
|
||||||
|
int CartType = -1;
|
||||||
std::string BaseROMDir = "";
|
std::string BaseROMDir = "";
|
||||||
std::string BaseROMName = "";
|
std::string BaseROMName = "";
|
||||||
std::string BaseAssetName = "";
|
std::string BaseAssetName = "";
|
||||||
@ -50,6 +49,9 @@ std::string BaseGBAAssetName = "";
|
|||||||
SaveManager* NDSSave = nullptr;
|
SaveManager* NDSSave = nullptr;
|
||||||
SaveManager* GBASave = nullptr;
|
SaveManager* GBASave = nullptr;
|
||||||
|
|
||||||
|
ARCodeFile* CheatFile = nullptr;
|
||||||
|
bool CheatsOn = false;
|
||||||
|
|
||||||
|
|
||||||
int LastSep(std::string path)
|
int LastSep(std::string path)
|
||||||
{
|
{
|
||||||
@ -260,6 +262,40 @@ QString VerifySetup()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void UnloadCheats()
|
||||||
|
{
|
||||||
|
if (CheatFile)
|
||||||
|
{
|
||||||
|
delete CheatFile;
|
||||||
|
CheatFile = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoadCheats()
|
||||||
|
{
|
||||||
|
UnloadCheats();
|
||||||
|
|
||||||
|
std::string filename = GetAssetPath(false, Config::CheatFilePath, ".mch");
|
||||||
|
|
||||||
|
// TODO: check for error (malformed cheat file, ...)
|
||||||
|
CheatFile = new ARCodeFile(filename);
|
||||||
|
|
||||||
|
AREngine::SetCodeFile(CheatsOn ? CheatFile : nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EnableCheats(bool enable)
|
||||||
|
{
|
||||||
|
CheatsOn = enable;
|
||||||
|
if (CheatFile)
|
||||||
|
AREngine::SetCodeFile(CheatsOn ? CheatFile : nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
ARCodeFile* GetCheatFile()
|
||||||
|
{
|
||||||
|
return CheatFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Reset()
|
void Reset()
|
||||||
{
|
{
|
||||||
NDS::SetConsoleType(Config::ConsoleType);
|
NDS::SetConsoleType(Config::ConsoleType);
|
||||||
@ -282,12 +318,13 @@ bool LoadBIOS()
|
|||||||
if (NDS::NeedsDirectBoot())
|
if (NDS::NeedsDirectBoot())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (NDSSave) delete NDSSave;
|
/*if (NDSSave) delete NDSSave;
|
||||||
NDSSave = nullptr;
|
NDSSave = nullptr;
|
||||||
|
|
||||||
|
CartType = -1;
|
||||||
BaseROMDir = "";
|
BaseROMDir = "";
|
||||||
BaseROMName = "";
|
BaseROMName = "";
|
||||||
BaseAssetName = "";
|
BaseAssetName = "";*/
|
||||||
|
|
||||||
NDS::Reset();
|
NDS::Reset();
|
||||||
return true;
|
return true;
|
||||||
@ -402,7 +439,10 @@ bool LoadROM(QStringList filepath, bool reset)
|
|||||||
|
|
||||||
if (res)
|
if (res)
|
||||||
{
|
{
|
||||||
|
CartType = 0;
|
||||||
NDSSave = new SaveManager(savname);
|
NDSSave = new SaveManager(savname);
|
||||||
|
|
||||||
|
LoadCheats();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (savedata) delete[] savedata;
|
if (savedata) delete[] savedata;
|
||||||
@ -415,16 +455,24 @@ void EjectCart()
|
|||||||
if (NDSSave) delete NDSSave;
|
if (NDSSave) delete NDSSave;
|
||||||
NDSSave = nullptr;
|
NDSSave = nullptr;
|
||||||
|
|
||||||
|
UnloadCheats();
|
||||||
|
|
||||||
NDS::EjectCart();
|
NDS::EjectCart();
|
||||||
|
|
||||||
|
CartType = -1;
|
||||||
BaseROMDir = "";
|
BaseROMDir = "";
|
||||||
BaseROMName = "";
|
BaseROMName = "";
|
||||||
BaseAssetName = "";
|
BaseAssetName = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CartInserted()
|
||||||
|
{
|
||||||
|
return CartType != -1;
|
||||||
|
}
|
||||||
|
|
||||||
QString CartLabel()
|
QString CartLabel()
|
||||||
{
|
{
|
||||||
if (BaseROMName.empty())
|
if (CartType == -1)
|
||||||
return "(none)";
|
return "(none)";
|
||||||
|
|
||||||
QString ret = QString::fromStdString(BaseROMName);
|
QString ret = QString::fromStdString(BaseROMName);
|
||||||
@ -532,6 +580,7 @@ bool LoadGBAROM(QStringList filepath)
|
|||||||
|
|
||||||
if (res)
|
if (res)
|
||||||
{
|
{
|
||||||
|
GBACartType = 0;
|
||||||
GBASave = new SaveManager(savname);
|
GBASave = new SaveManager(savname);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -566,6 +615,11 @@ void EjectGBACart()
|
|||||||
BaseGBAAssetName = "";
|
BaseGBAAssetName = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GBACartInserted()
|
||||||
|
{
|
||||||
|
return GBACartType != -1;
|
||||||
|
}
|
||||||
|
|
||||||
QString GBACartLabel()
|
QString GBACartLabel()
|
||||||
{
|
{
|
||||||
switch (GBACartType)
|
switch (GBACartType)
|
||||||
@ -581,11 +635,6 @@ QString GBACartLabel()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void ROMIcon(u8 (&data)[512], u16 (&palette)[16], u32* iconRef)
|
void ROMIcon(u8 (&data)[512], u16 (&palette)[16], u32* iconRef)
|
||||||
{
|
{
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "SaveManager.h"
|
#include "SaveManager.h"
|
||||||
|
#include "AREngine.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@ -37,51 +38,22 @@ bool LoadBIOS();
|
|||||||
|
|
||||||
bool LoadROM(QStringList filepath, bool reset);
|
bool LoadROM(QStringList filepath, bool reset);
|
||||||
void EjectCart();
|
void EjectCart();
|
||||||
|
bool CartInserted();
|
||||||
QString CartLabel();
|
QString CartLabel();
|
||||||
|
|
||||||
bool LoadGBAROM(QStringList filepath);
|
bool LoadGBAROM(QStringList filepath);
|
||||||
void LoadGBAAddon(int type);
|
void LoadGBAAddon(int type);
|
||||||
void EjectGBACart();
|
void EjectGBACart();
|
||||||
|
bool GBACartInserted();
|
||||||
QString GBACartLabel();
|
QString GBACartLabel();
|
||||||
|
|
||||||
enum
|
void EnableCheats(bool enable);
|
||||||
{
|
ARCodeFile* GetCheatFile();
|
||||||
ROMSlot_NDS = 0,
|
|
||||||
ROMSlot_GBA,
|
|
||||||
|
|
||||||
ROMSlot_MAX
|
|
||||||
};
|
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
Load_OK = 0,
|
|
||||||
|
|
||||||
Load_BIOS9Missing,
|
|
||||||
Load_BIOS9Bad,
|
|
||||||
|
|
||||||
Load_BIOS7Missing,
|
|
||||||
Load_BIOS7Bad,
|
|
||||||
|
|
||||||
Load_FirmwareMissing,
|
|
||||||
Load_FirmwareBad,
|
|
||||||
Load_FirmwareNotBootable,
|
|
||||||
|
|
||||||
Load_DSiBIOS9Missing,
|
|
||||||
Load_DSiBIOS9Bad,
|
|
||||||
|
|
||||||
Load_DSiBIOS7Missing,
|
|
||||||
Load_DSiBIOS7Bad,
|
|
||||||
|
|
||||||
Load_DSiNANDMissing,
|
|
||||||
Load_DSiNANDBad,
|
|
||||||
|
|
||||||
// TODO: more precise errors for ROM loading
|
|
||||||
Load_ROMLoadError,
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void ROMIcon(u8 (&data)[512], u16 (&palette)[16], u32* iconRef);
|
||||||
|
void AnimatedROMIcon(u8 (&data)[8][512], u16 (&palette)[8][16],
|
||||||
|
u16 (&sequence)[64], u32 (&animatedTexRef)[32 * 32 * 64],
|
||||||
|
std::vector<int> &animatedSequenceRef);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "Platform.h"
|
#include "Platform.h"
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
#include "FrontendUtil.h"
|
#include "ROMManager.h"
|
||||||
#include "DSi_NAND.h"
|
#include "DSi_NAND.h"
|
||||||
|
|
||||||
#include "TitleManagerDialog.h"
|
#include "TitleManagerDialog.h"
|
||||||
@ -111,7 +111,7 @@ void TitleManagerDialog::createTitleItem(u32 category, u32 titleid)
|
|||||||
DSi_NAND::GetTitleInfo(category, titleid, version, &header, &banner);
|
DSi_NAND::GetTitleInfo(category, titleid, version, &header, &banner);
|
||||||
|
|
||||||
u32 icondata[32*32];
|
u32 icondata[32*32];
|
||||||
Frontend::ROMIcon(banner.Icon, banner.Palette, icondata);
|
ROMManager::ROMIcon(banner.Icon, banner.Palette, icondata);
|
||||||
QImage iconimg((const uchar*)icondata, 32, 32, QImage::Format_ARGB32);
|
QImage iconimg((const uchar*)icondata, 32, 32, QImage::Format_ARGB32);
|
||||||
QIcon icon(QPixmap::fromImage(iconimg.copy()));
|
QIcon icon(QPixmap::fromImage(iconimg.copy()));
|
||||||
|
|
||||||
|
@ -1840,8 +1840,7 @@ void MainWindow::dropEvent(QDropEvent* event)
|
|||||||
|
|
||||||
emuThread->emuUnpause();
|
emuThread->emuUnpause();
|
||||||
|
|
||||||
actCurrentGBACart->setText("GBA slot: " + ROMManager::GBACartLabel());
|
updateCartInserted(true);
|
||||||
actEjectGBACart->setEnabled(true);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1860,9 +1859,7 @@ void MainWindow::dropEvent(QDropEvent* event)
|
|||||||
NDS::Start();
|
NDS::Start();
|
||||||
emuThread->emuRun();
|
emuThread->emuRun();
|
||||||
|
|
||||||
actCurrentCart->setText("DS slot: " + ROMManager::CartLabel());
|
updateCartInserted(false);
|
||||||
actEjectCart->setEnabled(true);
|
|
||||||
actImportSavefile->setEnabled(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1928,14 +1925,11 @@ bool MainWindow::preloadROMs(QString filename, QString gbafilename)
|
|||||||
NDS::Start();
|
NDS::Start();
|
||||||
emuThread->emuRun();
|
emuThread->emuRun();
|
||||||
|
|
||||||
actCurrentCart->setText("DS slot: " + ROMManager::CartLabel());
|
updateCartInserted(false);
|
||||||
actEjectCart->setEnabled(true);
|
|
||||||
actImportSavefile->setEnabled(true);
|
|
||||||
|
|
||||||
if (gbaloaded)
|
if (gbaloaded)
|
||||||
{
|
{
|
||||||
actCurrentGBACart->setText("GBA slot: " + ROMManager::GBACartLabel());
|
updateCartInserted(true);
|
||||||
actEjectGBACart->setEnabled(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -2038,6 +2032,26 @@ QStringList MainWindow::pickROM(bool gba)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::updateCartInserted(bool gba)
|
||||||
|
{
|
||||||
|
bool inserted;
|
||||||
|
if (gba)
|
||||||
|
{
|
||||||
|
inserted = ROMManager::GBACartInserted();
|
||||||
|
actCurrentGBACart->setText("GBA slot: " + ROMManager::GBACartLabel());
|
||||||
|
actEjectGBACart->setEnabled(inserted);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
inserted = ROMManager::CartInserted();
|
||||||
|
actCurrentCart->setText("DS slot: " + ROMManager::CartLabel());
|
||||||
|
actEjectCart->setEnabled(inserted);
|
||||||
|
actImportSavefile->setEnabled(inserted);
|
||||||
|
actSetupCheats->setEnabled(inserted);
|
||||||
|
actROMInfo->setEnabled(inserted);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::onOpenFile()
|
void MainWindow::onOpenFile()
|
||||||
{
|
{
|
||||||
emuThread->emuPause();
|
emuThread->emuPause();
|
||||||
@ -2071,9 +2085,7 @@ void MainWindow::onOpenFile()
|
|||||||
NDS::Start();
|
NDS::Start();
|
||||||
emuThread->emuRun();
|
emuThread->emuRun();
|
||||||
|
|
||||||
actCurrentCart->setText("DS slot: " + ROMManager::CartLabel());
|
updateCartInserted(false);
|
||||||
actEjectCart->setEnabled(true);
|
|
||||||
actImportSavefile->setEnabled(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onClearRecentFiles()
|
void MainWindow::onClearRecentFiles()
|
||||||
@ -2164,9 +2176,7 @@ void MainWindow::onClickRecentFile()
|
|||||||
NDS::Start();
|
NDS::Start();
|
||||||
emuThread->emuRun();
|
emuThread->emuRun();
|
||||||
|
|
||||||
actCurrentCart->setText("DS slot: " + ROMManager::CartLabel());
|
updateCartInserted(false);
|
||||||
actEjectCart->setEnabled(true);
|
|
||||||
actImportSavefile->setEnabled(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onBootFirmware()
|
void MainWindow::onBootFirmware()
|
||||||
@ -2212,9 +2222,7 @@ void MainWindow::onInsertCart()
|
|||||||
|
|
||||||
emuThread->emuUnpause();
|
emuThread->emuUnpause();
|
||||||
|
|
||||||
actCurrentCart->setText("DS slot: " + ROMManager::CartLabel());
|
updateCartInserted(false);
|
||||||
actEjectCart->setEnabled(true);
|
|
||||||
actImportSavefile->setEnabled(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onEjectCart()
|
void MainWindow::onEjectCart()
|
||||||
@ -2225,9 +2233,7 @@ void MainWindow::onEjectCart()
|
|||||||
|
|
||||||
emuThread->emuUnpause();
|
emuThread->emuUnpause();
|
||||||
|
|
||||||
actCurrentCart->setText("DS slot: " + ROMManager::CartLabel());
|
updateCartInserted(false);
|
||||||
actEjectCart->setEnabled(false);
|
|
||||||
actImportSavefile->setEnabled(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onInsertGBACart()
|
void MainWindow::onInsertGBACart()
|
||||||
@ -2251,8 +2257,7 @@ void MainWindow::onInsertGBACart()
|
|||||||
|
|
||||||
emuThread->emuUnpause();
|
emuThread->emuUnpause();
|
||||||
|
|
||||||
actCurrentGBACart->setText("GBA slot: " + ROMManager::GBACartLabel());
|
updateCartInserted(true);
|
||||||
actEjectGBACart->setEnabled(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onInsertGBAAddon()
|
void MainWindow::onInsertGBAAddon()
|
||||||
@ -2266,8 +2271,7 @@ void MainWindow::onInsertGBAAddon()
|
|||||||
|
|
||||||
emuThread->emuUnpause();
|
emuThread->emuUnpause();
|
||||||
|
|
||||||
actCurrentGBACart->setText("GBA slot: " + ROMManager::GBACartLabel());
|
updateCartInserted(true);
|
||||||
actEjectGBACart->setEnabled(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onEjectGBACart()
|
void MainWindow::onEjectGBACart()
|
||||||
@ -2278,8 +2282,7 @@ void MainWindow::onEjectGBACart()
|
|||||||
|
|
||||||
emuThread->emuUnpause();
|
emuThread->emuUnpause();
|
||||||
|
|
||||||
actCurrentGBACart->setText("GBA slot: " + ROMManager::GBACartLabel());
|
updateCartInserted(true);
|
||||||
actEjectGBACart->setEnabled(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onSaveState()
|
void MainWindow::onSaveState()
|
||||||
@ -2500,7 +2503,7 @@ void MainWindow::onFrameStep()
|
|||||||
void MainWindow::onEnableCheats(bool checked)
|
void MainWindow::onEnableCheats(bool checked)
|
||||||
{
|
{
|
||||||
Config::EnableCheats = checked?1:0;
|
Config::EnableCheats = checked?1:0;
|
||||||
Frontend::EnableCheats(Config::EnableCheats != 0);
|
ROMManager::EnableCheats(Config::EnableCheats != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onSetupCheats()
|
void MainWindow::onSetupCheats()
|
||||||
@ -2829,10 +2832,7 @@ void MainWindow::onEmuStart()
|
|||||||
actStop->setEnabled(true);
|
actStop->setEnabled(true);
|
||||||
actFrameStep->setEnabled(true);
|
actFrameStep->setEnabled(true);
|
||||||
|
|
||||||
actSetupCheats->setEnabled(true);
|
|
||||||
actTitleManager->setEnabled(false);
|
actTitleManager->setEnabled(false);
|
||||||
|
|
||||||
actROMInfo->setEnabled(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onEmuStop()
|
void MainWindow::onEmuStop()
|
||||||
@ -2851,10 +2851,7 @@ void MainWindow::onEmuStop()
|
|||||||
actStop->setEnabled(false);
|
actStop->setEnabled(false);
|
||||||
actFrameStep->setEnabled(false);
|
actFrameStep->setEnabled(false);
|
||||||
|
|
||||||
actSetupCheats->setEnabled(false);
|
|
||||||
actTitleManager->setEnabled(!Config::DSiNANDPath.empty());
|
actTitleManager->setEnabled(!Config::DSiNANDPath.empty());
|
||||||
|
|
||||||
actROMInfo->setEnabled(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onUpdateVideoSettings(bool glchange)
|
void MainWindow::onUpdateVideoSettings(bool glchange)
|
||||||
@ -2888,9 +2885,6 @@ void emuStop()
|
|||||||
{
|
{
|
||||||
RunningSomething = false;
|
RunningSomething = false;
|
||||||
|
|
||||||
Frontend::UnloadROM(Frontend::ROMSlot_NDS);
|
|
||||||
Frontend::UnloadROM(Frontend::ROMSlot_GBA);
|
|
||||||
|
|
||||||
emit emuThread->windowEmuStop();
|
emit emuThread->windowEmuStop();
|
||||||
|
|
||||||
OSD::AddMessage(0xFFC040, "Shutdown");
|
OSD::AddMessage(0xFFC040, "Shutdown");
|
||||||
@ -3009,7 +3003,7 @@ int main(int argc, char** argv)
|
|||||||
micWavBuffer = nullptr;
|
micWavBuffer = nullptr;
|
||||||
|
|
||||||
Frontend::Init_ROM();
|
Frontend::Init_ROM();
|
||||||
Frontend::EnableCheats(Config::EnableCheats != 0);
|
ROMManager::EnableCheats(Config::EnableCheats != 0);
|
||||||
|
|
||||||
Frontend::Init_Audio(audioFreq);
|
Frontend::Init_Audio(audioFreq);
|
||||||
|
|
||||||
|
@ -304,11 +304,10 @@ private:
|
|||||||
bool verifySetup();
|
bool verifySetup();
|
||||||
QString pickFileFromArchive(QString archiveFileName);
|
QString pickFileFromArchive(QString archiveFileName);
|
||||||
QStringList pickROM(bool gba);
|
QStringList pickROM(bool gba);
|
||||||
|
void updateCartInserted(bool gba);
|
||||||
|
|
||||||
void createScreenPanel();
|
void createScreenPanel();
|
||||||
|
|
||||||
QString loadErrorStr(int error);
|
|
||||||
|
|
||||||
bool pausedManually = false;
|
bool pausedManually = false;
|
||||||
|
|
||||||
int oldW, oldH;
|
int oldW, oldH;
|
||||||
|
Reference in New Issue
Block a user