mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-27 00:00:07 -06:00
remove more shitty strings
This commit is contained in:
@ -43,7 +43,10 @@
|
|||||||
* different minor means adjustments may have to be made
|
* different minor means adjustments may have to be made
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Savestate::Savestate(const char* filename, bool save)
|
// TODO: buffering system! or something of that sort
|
||||||
|
// repeated fread/fwrite is slow on Switch
|
||||||
|
|
||||||
|
Savestate::Savestate(std::string filename, bool save)
|
||||||
{
|
{
|
||||||
const char* magic = "MELN";
|
const char* magic = "MELN";
|
||||||
|
|
||||||
@ -55,7 +58,7 @@ Savestate::Savestate(const char* filename, bool save)
|
|||||||
file = Platform::OpenLocalFile(filename, "wb");
|
file = Platform::OpenLocalFile(filename, "wb");
|
||||||
if (!file)
|
if (!file)
|
||||||
{
|
{
|
||||||
printf("savestate: file %s doesn't exist\n", filename);
|
printf("savestate: file %s doesn't exist\n", filename.c_str());
|
||||||
Error = true;
|
Error = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -74,7 +77,7 @@ Savestate::Savestate(const char* filename, bool save)
|
|||||||
file = Platform::OpenFile(filename, "rb");
|
file = Platform::OpenFile(filename, "rb");
|
||||||
if (!file)
|
if (!file)
|
||||||
{
|
{
|
||||||
printf("savestate: file %s doesn't exist\n", filename);
|
printf("savestate: file %s doesn't exist\n", filename.c_str());
|
||||||
Error = true;
|
Error = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#ifndef SAVESTATE_H
|
#ifndef SAVESTATE_H
|
||||||
#define SAVESTATE_H
|
#define SAVESTATE_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
@ -28,7 +29,7 @@
|
|||||||
class Savestate
|
class Savestate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Savestate(const char* filename, bool save);
|
Savestate(std::string filename, bool save);
|
||||||
~Savestate();
|
~Savestate();
|
||||||
|
|
||||||
bool Error;
|
bool Error;
|
||||||
|
@ -62,12 +62,12 @@ enum
|
|||||||
Load_ROMLoadError,
|
Load_ROMLoadError,
|
||||||
};
|
};
|
||||||
|
|
||||||
extern char ROMPath [ROMSlot_MAX][1024];
|
extern std::string ROMPath [ROMSlot_MAX];
|
||||||
extern char SRAMPath[ROMSlot_MAX][1024];
|
extern std::string SRAMPath[ROMSlot_MAX];
|
||||||
extern bool SavestateLoaded;
|
extern bool SavestateLoaded;
|
||||||
|
|
||||||
// Stores type of nds rom i.e. nds/srl/dsi. Should be updated everytime an NDS rom is loaded from an archive
|
// Stores type of nds rom i.e. nds/srl/dsi. Should be updated everytime an NDS rom is loaded from an archive
|
||||||
extern char NDSROMExtension[4];
|
extern std::string NDSROMExtension;
|
||||||
|
|
||||||
// initialize the ROM handling utility
|
// initialize the ROM handling utility
|
||||||
void Init_ROM();
|
void Init_ROM();
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#ifdef ARCHIVE_SUPPORT_ENABLED
|
#ifdef ARCHIVE_SUPPORT_ENABLED
|
||||||
@ -38,11 +39,11 @@
|
|||||||
namespace Frontend
|
namespace Frontend
|
||||||
{
|
{
|
||||||
|
|
||||||
char ROMPath [ROMSlot_MAX][1024];
|
std::string ROMPath [ROMSlot_MAX];
|
||||||
char SRAMPath [ROMSlot_MAX][1024];
|
std::string SRAMPath [ROMSlot_MAX];
|
||||||
char PrevSRAMPath[ROMSlot_MAX][1024]; // for savestate 'undo load'
|
std::string PrevSRAMPath[ROMSlot_MAX]; // for savestate 'undo load'
|
||||||
|
|
||||||
char NDSROMExtension[4];
|
std::string NDSROMExtension;
|
||||||
|
|
||||||
bool SavestateLoaded;
|
bool SavestateLoaded;
|
||||||
|
|
||||||
@ -54,12 +55,12 @@ void Init_ROM()
|
|||||||
{
|
{
|
||||||
SavestateLoaded = false;
|
SavestateLoaded = false;
|
||||||
|
|
||||||
memset(ROMPath[ROMSlot_NDS], 0, 1024);
|
ROMPath[ROMSlot_NDS] = "";
|
||||||
memset(ROMPath[ROMSlot_GBA], 0, 1024);
|
ROMPath[ROMSlot_GBA] = "";
|
||||||
memset(SRAMPath[ROMSlot_NDS], 0, 1024);
|
SRAMPath[ROMSlot_NDS] = "";
|
||||||
memset(SRAMPath[ROMSlot_GBA], 0, 1024);
|
SRAMPath[ROMSlot_GBA] = "";
|
||||||
memset(PrevSRAMPath[ROMSlot_NDS], 0, 1024);
|
PrevSRAMPath[ROMSlot_NDS] = "";
|
||||||
memset(PrevSRAMPath[ROMSlot_GBA], 0, 1024);
|
PrevSRAMPath[ROMSlot_GBA] = "";
|
||||||
|
|
||||||
CheatFile = nullptr;
|
CheatFile = nullptr;
|
||||||
CheatsOn = false;
|
CheatsOn = false;
|
||||||
@ -81,9 +82,7 @@ void DeInit_ROM()
|
|||||||
|
|
||||||
void SetupSRAMPath(int slot)
|
void SetupSRAMPath(int slot)
|
||||||
{
|
{
|
||||||
strncpy(SRAMPath[slot], ROMPath[slot], 1023);
|
SRAMPath[slot] = ROMPath[slot].substr(0, ROMPath[slot].length() - 3) + "sav";
|
||||||
SRAMPath[slot][1023] = '\0';
|
|
||||||
strncpy(SRAMPath[slot] + strlen(ROMPath[slot]) - 3, "sav", 3);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int VerifyDSBIOS()
|
int VerifyDSBIOS()
|
||||||
@ -234,18 +233,18 @@ void LoadCheats()
|
|||||||
CheatFile = nullptr;
|
CheatFile = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
char filename[1024];
|
std::string filename;
|
||||||
if (ROMPath[ROMSlot_NDS][0] != '\0')
|
if (!ROMPath[ROMSlot_NDS].empty())
|
||||||
{
|
{
|
||||||
strncpy(filename, ROMPath[ROMSlot_NDS], 1023);
|
filename = ROMPath[ROMSlot_NDS].substr(0, ROMPath[ROMSlot_NDS].length() - 3) + "mch";
|
||||||
filename[1023] = '\0';
|
|
||||||
strncpy(filename + strlen(ROMPath[ROMSlot_NDS]) - 3, "mch", 3);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
strncpy(filename, "firmware.mch", 1023);
|
filename = "firmware.mch";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: add custom path here
|
||||||
|
|
||||||
// TODO: check for error (malformed cheat file, ...)
|
// TODO: check for error (malformed cheat file, ...)
|
||||||
CheatFile = new ARCodeFile(filename);
|
CheatFile = new ARCodeFile(filename);
|
||||||
|
|
||||||
@ -283,8 +282,8 @@ int LoadBIOS()
|
|||||||
// should this be carried over here?
|
// should this be carried over here?
|
||||||
// is that behavior consistent with that of LoadROM() below?
|
// is that behavior consistent with that of LoadROM() below?
|
||||||
|
|
||||||
ROMPath[ROMSlot_NDS][0] = '\0';
|
ROMPath[ROMSlot_NDS] = "";
|
||||||
SRAMPath[ROMSlot_NDS][0] = '\0';
|
SRAMPath[ROMSlot_NDS] = "";
|
||||||
|
|
||||||
NDS::SetConsoleType(Config::ConsoleType);
|
NDS::SetConsoleType(Config::ConsoleType);
|
||||||
NDS::LoadBIOS();
|
NDS::LoadBIOS();
|
||||||
@ -322,7 +321,7 @@ int LoadROM(const u8 *romdata, u32 romlength, const char *archivefilename, const
|
|||||||
if (res != Load_OK) return res;
|
if (res != Load_OK) return res;
|
||||||
|
|
||||||
GBACart::Eject();
|
GBACart::Eject();
|
||||||
ROMPath[ROMSlot_GBA][0] = '\0';
|
ROMPath[ROMSlot_GBA] = "";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -336,17 +335,15 @@ int LoadROM(const u8 *romdata, u32 romlength, const char *archivefilename, const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char oldpath[1024];
|
std::string oldpath = ROMPath[slot];
|
||||||
char oldsram[1024];
|
std::string oldsram = SRAMPath[slot];
|
||||||
strncpy(oldpath, ROMPath[slot], 1024);
|
|
||||||
strncpy(oldsram, SRAMPath[slot], 1024);
|
|
||||||
|
|
||||||
strncpy(SRAMPath[slot], sramfilename, 1024);
|
SRAMPath[slot] = sramfilename;
|
||||||
strncpy(ROMPath[slot], archivefilename, 1024);
|
ROMPath[slot] = archivefilename;
|
||||||
|
|
||||||
NDS::SetConsoleType(Config::ConsoleType);
|
NDS::SetConsoleType(Config::ConsoleType);
|
||||||
|
|
||||||
if (slot == ROMSlot_NDS && NDS::LoadROM(romdata, romlength, SRAMPath[slot], directboot))
|
if (slot == ROMSlot_NDS && NDS::LoadROM(romdata, romlength, SRAMPath[slot].c_str(), directboot))
|
||||||
{
|
{
|
||||||
SavestateLoaded = false;
|
SavestateLoaded = false;
|
||||||
|
|
||||||
@ -354,22 +351,22 @@ int LoadROM(const u8 *romdata, u32 romlength, const char *archivefilename, const
|
|||||||
|
|
||||||
// Reload the inserted GBA cartridge (if any)
|
// Reload the inserted GBA cartridge (if any)
|
||||||
// TODO: report failure there??
|
// TODO: report failure there??
|
||||||
//if (ROMPath[ROMSlot_GBA][0] != '\0') NDS::LoadGBAROM(ROMPath[ROMSlot_GBA], SRAMPath[ROMSlot_GBA]);
|
//if (!ROMPath[ROMSlot_GBA].empty()) NDS::LoadGBAROM(ROMPath[ROMSlot_GBA], SRAMPath[ROMSlot_GBA]);
|
||||||
|
|
||||||
strncpy(PrevSRAMPath[slot], SRAMPath[slot], 1024); // safety
|
PrevSRAMPath[slot] = SRAMPath[slot]; // safety
|
||||||
return Load_OK;
|
return Load_OK;
|
||||||
}
|
}
|
||||||
else if (slot == ROMSlot_GBA && NDS::LoadGBAROM(romdata, romlength, romfilename, SRAMPath[slot]))
|
else if (slot == ROMSlot_GBA && NDS::LoadGBAROM(romdata, romlength, romfilename, SRAMPath[slot].c_str()))
|
||||||
{
|
{
|
||||||
SavestateLoaded = false; // checkme??
|
SavestateLoaded = false; // checkme??
|
||||||
|
|
||||||
strncpy(PrevSRAMPath[slot], SRAMPath[slot], 1024); // safety
|
PrevSRAMPath[slot] = SRAMPath[slot]; // safety
|
||||||
return Load_OK;
|
return Load_OK;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
strncpy(ROMPath[slot], oldpath, 1024);
|
ROMPath[slot] = oldpath;
|
||||||
strncpy(SRAMPath[slot], oldsram, 1024);
|
SRAMPath[slot] = oldsram;
|
||||||
return Load_ROMLoadError;
|
return Load_ROMLoadError;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -402,7 +399,7 @@ int LoadROM(const char* file, int slot)
|
|||||||
if (res != Load_OK) return res;
|
if (res != Load_OK) return res;
|
||||||
|
|
||||||
GBACart::Eject();
|
GBACart::Eject();
|
||||||
ROMPath[ROMSlot_GBA][0] = '\0';
|
ROMPath[ROMSlot_GBA] = "";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -416,20 +413,17 @@ int LoadROM(const char* file, int slot)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char oldpath[1024];
|
std::string oldpath = ROMPath[slot];
|
||||||
char oldsram[1024];
|
std::string oldsram = SRAMPath[slot];
|
||||||
strncpy(oldpath, ROMPath[slot], 1024);
|
|
||||||
strncpy(oldsram, SRAMPath[slot], 1024);
|
|
||||||
|
|
||||||
strncpy(ROMPath[slot], file, 1023);
|
ROMPath[slot] = file;
|
||||||
ROMPath[slot][1023] = '\0';
|
|
||||||
|
|
||||||
SetupSRAMPath(0);
|
SetupSRAMPath(0);
|
||||||
SetupSRAMPath(1);
|
SetupSRAMPath(1);
|
||||||
|
|
||||||
NDS::SetConsoleType(Config::ConsoleType);
|
NDS::SetConsoleType(Config::ConsoleType);
|
||||||
|
|
||||||
if (slot == ROMSlot_NDS && NDS::LoadROM(ROMPath[slot], SRAMPath[slot], directboot))
|
if (slot == ROMSlot_NDS && NDS::LoadROM(ROMPath[slot].c_str(), SRAMPath[slot].c_str(), directboot))
|
||||||
{
|
{
|
||||||
SavestateLoaded = false;
|
SavestateLoaded = false;
|
||||||
|
|
||||||
@ -437,22 +431,22 @@ int LoadROM(const char* file, int slot)
|
|||||||
|
|
||||||
// Reload the inserted GBA cartridge (if any)
|
// Reload the inserted GBA cartridge (if any)
|
||||||
// TODO: report failure there??
|
// TODO: report failure there??
|
||||||
if (ROMPath[ROMSlot_GBA][0] != '\0') NDS::LoadGBAROM(ROMPath[ROMSlot_GBA], SRAMPath[ROMSlot_GBA]);
|
if (!ROMPath[ROMSlot_GBA].empty()) NDS::LoadGBAROM(ROMPath[ROMSlot_GBA].c_str(), SRAMPath[ROMSlot_GBA].c_str());
|
||||||
|
|
||||||
strncpy(PrevSRAMPath[slot], SRAMPath[slot], 1024); // safety
|
PrevSRAMPath[slot] = SRAMPath[slot]; // safety
|
||||||
return Load_OK;
|
return Load_OK;
|
||||||
}
|
}
|
||||||
else if (slot == ROMSlot_GBA && NDS::LoadGBAROM(ROMPath[slot], SRAMPath[slot]))
|
else if (slot == ROMSlot_GBA && NDS::LoadGBAROM(ROMPath[slot].c_str(), SRAMPath[slot].c_str()))
|
||||||
{
|
{
|
||||||
SavestateLoaded = false; // checkme??
|
SavestateLoaded = false; // checkme??
|
||||||
|
|
||||||
strncpy(PrevSRAMPath[slot], SRAMPath[slot], 1024); // safety
|
PrevSRAMPath[slot] = SRAMPath[slot]; // safety
|
||||||
return Load_OK;
|
return Load_OK;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
strncpy(ROMPath[slot], oldpath, 1024);
|
ROMPath[slot] = oldpath;
|
||||||
strncpy(SRAMPath[slot], oldsram, 1024);
|
SRAMPath[slot] = oldsram;
|
||||||
return Load_ROMLoadError;
|
return Load_ROMLoadError;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -534,7 +528,7 @@ void UnloadROM(int slot)
|
|||||||
GBACart::Eject();
|
GBACart::Eject();
|
||||||
}
|
}
|
||||||
|
|
||||||
ROMPath[slot][0] = '\0';
|
ROMPath[slot] = "";
|
||||||
|
|
||||||
DSi::CloseDSiNAND();
|
DSi::CloseDSiNAND();
|
||||||
}
|
}
|
||||||
@ -579,79 +573,82 @@ int Reset()
|
|||||||
|
|
||||||
NDS::SetConsoleType(Config::ConsoleType);
|
NDS::SetConsoleType(Config::ConsoleType);
|
||||||
|
|
||||||
if (ROMPath[ROMSlot_NDS][0] == '\0')
|
if (ROMPath[ROMSlot_NDS].empty())
|
||||||
{
|
{
|
||||||
NDS::LoadBIOS();
|
NDS::LoadBIOS();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char ext[5] = {0}; int _len = strlen(ROMPath[ROMSlot_NDS]);
|
std::string ext = ROMPath[ROMSlot_NDS].substr(ROMPath[ROMSlot_NDS].length() - 4);
|
||||||
strncpy(ext, ROMPath[ROMSlot_NDS] + _len - 4, 4);
|
|
||||||
|
|
||||||
if(!strncasecmp(ext, ".nds", 4) || !strncasecmp(ext, ".srl", 4) || !strncasecmp(ext, ".dsi", 4))
|
if (ext == ".nds" || ext == ".srl" || ext == ".dsi")
|
||||||
{
|
{
|
||||||
SetupSRAMPath(0);
|
SetupSRAMPath(0);
|
||||||
if (!NDS::LoadROM(ROMPath[ROMSlot_NDS], SRAMPath[ROMSlot_NDS], directboot))
|
if (!NDS::LoadROM(ROMPath[ROMSlot_NDS].c_str(), SRAMPath[ROMSlot_NDS].c_str(), directboot))
|
||||||
return Load_ROMLoadError;
|
return Load_ROMLoadError;
|
||||||
}
|
}
|
||||||
#ifdef ARCHIVE_SUPPORT_ENABLED
|
#ifdef ARCHIVE_SUPPORT_ENABLED
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
u8 *romdata = nullptr; u32 romlen;
|
// TODO!!!
|
||||||
|
// THIS WILL BREAK IF CUSTOM SRAM PATHS ARE ADDED
|
||||||
|
|
||||||
|
/*u8 *romdata = nullptr; u32 romlen;
|
||||||
char romfilename[1024] = {0}, sramfilename[1024];
|
char romfilename[1024] = {0}, sramfilename[1024];
|
||||||
strncpy(sramfilename, SRAMPath[ROMSlot_NDS], 1024); // Use existing SRAMPath
|
strncpy(sramfilename, SRAMPath[ROMSlot_NDS], 1024); // Use existing SRAMPath
|
||||||
|
|
||||||
int pos = strlen(sramfilename) - 1;
|
int pos = strlen(sramfilename) - 1;
|
||||||
while(pos > 0 && sramfilename[pos] != '/' && sramfilename[pos] != '\\')
|
while (pos > 0 && sramfilename[pos] != '/' && sramfilename[pos] != '\\')
|
||||||
--pos;
|
--pos;
|
||||||
|
|
||||||
strncpy(romfilename, &sramfilename[pos + 1], 1024);
|
strncpy(romfilename, &sramfilename[pos + 1], 1024);
|
||||||
strncpy(&romfilename[strlen(romfilename) - 3], NDSROMExtension, 3); // extension could be nds, srl or dsi
|
strncpy(&romfilename[strlen(romfilename) - 3], NDSROMExtension, 3); // extension could be nds, srl or dsi
|
||||||
printf("RESET loading from archive : %s\n", romfilename);
|
printf("RESET loading from archive : %s\n", romfilename);
|
||||||
romlen = Archive::ExtractFileFromArchive(ROMPath[ROMSlot_NDS], romfilename, &romdata);
|
romlen = Archive::ExtractFileFromArchive(ROMPath[ROMSlot_NDS], romfilename, &romdata);
|
||||||
if(!romdata)
|
if (!romdata)
|
||||||
return Load_ROMLoadError;
|
return Load_ROMLoadError;
|
||||||
|
|
||||||
bool ok = NDS::LoadROM(romdata, romlen, sramfilename, directboot);
|
bool ok = NDS::LoadROM(romdata, romlen, sramfilename, directboot);
|
||||||
delete romdata;
|
delete romdata;
|
||||||
if(!ok)
|
if (!ok)*/
|
||||||
return Load_ROMLoadError;
|
return Load_ROMLoadError;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ROMPath[ROMSlot_GBA][0] != '\0')
|
if (!ROMPath[ROMSlot_GBA].empty())
|
||||||
{
|
{
|
||||||
char ext[5] = {0}; int _len = strlen(ROMPath[ROMSlot_GBA]);
|
std::string ext = ROMPath[ROMSlot_GBA].substr(ROMPath[ROMSlot_GBA].length() - 4);
|
||||||
strncpy(ext, ROMPath[ROMSlot_GBA] + _len - 4, 4);
|
|
||||||
|
|
||||||
if(!strncasecmp(ext, ".gba", 4))
|
if (ext == ".gba")
|
||||||
{
|
{
|
||||||
SetupSRAMPath(1);
|
SetupSRAMPath(1);
|
||||||
if (!NDS::LoadGBAROM(ROMPath[ROMSlot_GBA], SRAMPath[ROMSlot_GBA]))
|
if (!NDS::LoadGBAROM(ROMPath[ROMSlot_GBA].c_str(), SRAMPath[ROMSlot_GBA].c_str()))
|
||||||
return Load_ROMLoadError;
|
return Load_ROMLoadError;
|
||||||
}
|
}
|
||||||
#ifdef ARCHIVE_SUPPORT_ENABLED
|
#ifdef ARCHIVE_SUPPORT_ENABLED
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
u8 *romdata = nullptr; u32 romlen;
|
// TODO!! SAME AS ABOVE
|
||||||
|
|
||||||
|
/*u8 *romdata = nullptr; u32 romlen;
|
||||||
char romfilename[1024] = {0}, sramfilename[1024];
|
char romfilename[1024] = {0}, sramfilename[1024];
|
||||||
strncpy(sramfilename, SRAMPath[ROMSlot_GBA], 1024); // Use existing SRAMPath
|
strncpy(sramfilename, SRAMPath[ROMSlot_GBA], 1024); // Use existing SRAMPath
|
||||||
|
|
||||||
int pos = strlen(sramfilename) - 1;
|
int pos = strlen(sramfilename) - 1;
|
||||||
while(pos > 0 && sramfilename[pos] != '/' && sramfilename[pos] != '\\')
|
while (pos > 0 && sramfilename[pos] != '/' && sramfilename[pos] != '\\')
|
||||||
--pos;
|
--pos;
|
||||||
|
|
||||||
strncpy(romfilename, &sramfilename[pos + 1], 1024);
|
strncpy(romfilename, &sramfilename[pos + 1], 1024);
|
||||||
strncpy(&romfilename[strlen(romfilename) - 3], "gba", 3);
|
strncpy(&romfilename[strlen(romfilename) - 3], "gba", 3);
|
||||||
printf("RESET loading from archive : %s\n", romfilename);
|
printf("RESET loading from archive : %s\n", romfilename);
|
||||||
romlen = Archive::ExtractFileFromArchive(ROMPath[ROMSlot_GBA], romfilename, &romdata);
|
romlen = Archive::ExtractFileFromArchive(ROMPath[ROMSlot_GBA], romfilename, &romdata);
|
||||||
if(!romdata)
|
if (!romdata)
|
||||||
return Load_ROMLoadError;
|
return Load_ROMLoadError;
|
||||||
|
|
||||||
bool ok = NDS::LoadGBAROM(romdata, romlen, romfilename, SRAMPath[ROMSlot_GBA]);
|
bool ok = NDS::LoadGBAROM(romdata, romlen, romfilename, SRAMPath[ROMSlot_GBA]);
|
||||||
delete romdata;
|
delete romdata;
|
||||||
if(!ok)
|
if (!ok)*/
|
||||||
return Load_ROMLoadError;
|
return Load_ROMLoadError;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -668,39 +665,28 @@ int Reset()
|
|||||||
|
|
||||||
std::string GetSavestateName(int slot)
|
std::string GetSavestateName(int slot)
|
||||||
{
|
{
|
||||||
int pos;
|
std::string filename;
|
||||||
char filename[1024] = {0};
|
|
||||||
int len = 1024;
|
|
||||||
|
|
||||||
if (ROMPath[ROMSlot_NDS][0] == '\0') // running firmware, no ROM
|
if (ROMPath[ROMSlot_NDS].empty()) // running firmware, no ROM
|
||||||
{
|
{
|
||||||
strcpy(filename, "firmware");
|
filename = "firmware";
|
||||||
pos = 8;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char *rompath;
|
std::string rompath;
|
||||||
char ext[5] = {0}; int _len = strlen(ROMPath[ROMSlot_NDS]);
|
std::string ext = ROMPath[ROMSlot_NDS].substr(ROMPath[ROMSlot_NDS].length() - 4);
|
||||||
strncpy(ext, ROMPath[ROMSlot_NDS] + _len - 4, 4);
|
|
||||||
|
|
||||||
if(!strncasecmp(ext, ".nds", 4) || !strncasecmp(ext, ".srl", 4) || !strncasecmp(ext, ".dsi", 4))
|
// TODO!!! MORE SHIT THAT IS GONNA ASPLODE
|
||||||
|
if (ext == ".nds" || ext == ".srl" || ext == ".dsi")
|
||||||
rompath = ROMPath[ROMSlot_NDS];
|
rompath = ROMPath[ROMSlot_NDS];
|
||||||
else
|
else
|
||||||
rompath = SRAMPath[ROMSlot_NDS]; // If archive, construct ssname from sram file
|
rompath = SRAMPath[ROMSlot_NDS]; // If archive, construct ssname from sram file
|
||||||
|
|
||||||
int l = strlen(rompath);
|
filename = rompath.substr(0, rompath.rfind('.'));
|
||||||
pos = l;
|
|
||||||
while (rompath[pos] != '.' && pos > 0) pos--;
|
|
||||||
if (pos == 0) pos = l;
|
|
||||||
|
|
||||||
// avoid buffer overflow. shoddy
|
|
||||||
if (pos > len-5) pos = len-5;
|
|
||||||
|
|
||||||
strncpy(&filename[0], rompath, pos);
|
|
||||||
}
|
}
|
||||||
strcpy(&filename[pos], ".ml");
|
|
||||||
filename[pos+3] = '0'+slot;
|
filename += ".ml";
|
||||||
filename[pos+4] = '\0';
|
filename += ('0'+slot);
|
||||||
|
|
||||||
return filename;
|
return filename;
|
||||||
}
|
}
|
||||||
@ -722,7 +708,7 @@ bool LoadState(std::string filename)
|
|||||||
|
|
||||||
bool failed = false;
|
bool failed = false;
|
||||||
|
|
||||||
Savestate* state = new Savestate(filename.c_str(), false);
|
Savestate* state = new Savestate(filename, false);
|
||||||
if (state->Error)
|
if (state->Error)
|
||||||
{
|
{
|
||||||
delete state;
|
delete state;
|
||||||
@ -739,16 +725,14 @@ bool LoadState(std::string filename)
|
|||||||
|
|
||||||
if (!failed)
|
if (!failed)
|
||||||
{
|
{
|
||||||
if (Config::SavestateRelocSRAM && ROMPath[ROMSlot_NDS][0]!='\0')
|
if (Config::SavestateRelocSRAM && !ROMPath[ROMSlot_NDS].empty())
|
||||||
{
|
{
|
||||||
strncpy(PrevSRAMPath[ROMSlot_NDS], SRAMPath[0], 1024);
|
PrevSRAMPath[ROMSlot_NDS] = SRAMPath[ROMSlot_NDS];
|
||||||
|
|
||||||
strncpy(SRAMPath[ROMSlot_NDS], filename.c_str(), 1019);
|
// TODO: how should this interact with custom paths?
|
||||||
int len = strlen(SRAMPath[ROMSlot_NDS]);
|
SRAMPath[ROMSlot_NDS] = filename + ".sav";
|
||||||
strcpy(&SRAMPath[ROMSlot_NDS][len], ".sav");
|
|
||||||
SRAMPath[ROMSlot_NDS][len+4] = '\0';
|
|
||||||
|
|
||||||
NDS::RelocateSave(SRAMPath[ROMSlot_NDS], false);
|
NDS::RelocateSave(SRAMPath[ROMSlot_NDS].c_str(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool loadedPartialGBAROM = false;
|
bool loadedPartialGBAROM = false;
|
||||||
@ -759,8 +743,8 @@ bool LoadState(std::string filename)
|
|||||||
// loaded save file. therefore, their paths are "nulled".
|
// loaded save file. therefore, their paths are "nulled".
|
||||||
if (GBACart::CartInserted && GBACart::CartCRC != oldGBACartCRC)
|
if (GBACart::CartInserted && GBACart::CartCRC != oldGBACartCRC)
|
||||||
{
|
{
|
||||||
ROMPath[ROMSlot_GBA][0] = '\0';
|
ROMPath[ROMSlot_GBA] = "";
|
||||||
SRAMPath[ROMSlot_GBA][0] = '\0';
|
SRAMPath[ROMSlot_GBA] = "";
|
||||||
loadedPartialGBAROM = true;
|
loadedPartialGBAROM = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -780,7 +764,7 @@ bool LoadState(std::string filename)
|
|||||||
|
|
||||||
bool SaveState(std::string filename)
|
bool SaveState(std::string filename)
|
||||||
{
|
{
|
||||||
Savestate* state = new Savestate(filename.c_str(), true);
|
Savestate* state = new Savestate(filename, true);
|
||||||
if (state->Error)
|
if (state->Error)
|
||||||
{
|
{
|
||||||
delete state;
|
delete state;
|
||||||
@ -791,14 +775,12 @@ bool SaveState(std::string filename)
|
|||||||
NDS::DoSavestate(state);
|
NDS::DoSavestate(state);
|
||||||
delete state;
|
delete state;
|
||||||
|
|
||||||
if (Config::SavestateRelocSRAM && ROMPath[ROMSlot_NDS][0]!='\0')
|
if (Config::SavestateRelocSRAM && !ROMPath[ROMSlot_NDS].empty())
|
||||||
{
|
{
|
||||||
strncpy(SRAMPath[ROMSlot_NDS], filename.c_str(), 1019);
|
// TODO: how should this interact with custom paths?
|
||||||
int len = strlen(SRAMPath[ROMSlot_NDS]);
|
SRAMPath[ROMSlot_NDS] = filename + ".sav";
|
||||||
strcpy(&SRAMPath[ROMSlot_NDS][len], ".sav");
|
|
||||||
SRAMPath[ROMSlot_NDS][len+4] = '\0';
|
|
||||||
|
|
||||||
NDS::RelocateSave(SRAMPath[ROMSlot_NDS], true);
|
NDS::RelocateSave(SRAMPath[ROMSlot_NDS].c_str(), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -816,10 +798,10 @@ void UndoStateLoad()
|
|||||||
NDS::DoSavestate(backup);
|
NDS::DoSavestate(backup);
|
||||||
delete backup;
|
delete backup;
|
||||||
|
|
||||||
if (ROMPath[ROMSlot_NDS][0]!='\0')
|
if (!ROMPath[ROMSlot_NDS].empty())
|
||||||
{
|
{
|
||||||
strncpy(SRAMPath[ROMSlot_NDS], PrevSRAMPath[ROMSlot_NDS], 1024);
|
SRAMPath[ROMSlot_NDS] = PrevSRAMPath[ROMSlot_NDS];
|
||||||
NDS::RelocateSave(SRAMPath[ROMSlot_NDS], false);
|
NDS::RelocateSave(SRAMPath[ROMSlot_NDS].c_str(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,6 +124,10 @@ std::string LastROMFolder;
|
|||||||
|
|
||||||
std::string RecentROMList[10];
|
std::string RecentROMList[10];
|
||||||
|
|
||||||
|
std::string SaveFilePath;
|
||||||
|
std::string SavestatePath;
|
||||||
|
std::string CheatFilePath;
|
||||||
|
|
||||||
bool EnableCheats;
|
bool EnableCheats;
|
||||||
|
|
||||||
bool MouseHide;
|
bool MouseHide;
|
||||||
@ -291,6 +295,10 @@ ConfigEntry ConfigFile[] =
|
|||||||
{"RecentROM_8", 2, &RecentROMList[8], ""},
|
{"RecentROM_8", 2, &RecentROMList[8], ""},
|
||||||
{"RecentROM_9", 2, &RecentROMList[9], ""},
|
{"RecentROM_9", 2, &RecentROMList[9], ""},
|
||||||
|
|
||||||
|
{"SaveFilePath", 2, &SaveFilePath, ""},
|
||||||
|
{"SavestatePath", 2, &SavestatePath, ""},
|
||||||
|
{"CheatFilePath", 2, &CheatFilePath, ""},
|
||||||
|
|
||||||
{"EnableCheats", 1, &EnableCheats, false},
|
{"EnableCheats", 1, &EnableCheats, false},
|
||||||
|
|
||||||
{"MouseHide", 1, &MouseHide, false},
|
{"MouseHide", 1, &MouseHide, false},
|
||||||
@ -302,12 +310,12 @@ ConfigEntry ConfigFile[] =
|
|||||||
|
|
||||||
|
|
||||||
void Load()
|
void Load()
|
||||||
{printf("LOADZORZ\n");
|
{
|
||||||
ConfigEntry* entry = &ConfigFile[0];
|
ConfigEntry* entry = &ConfigFile[0];
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
if (!entry->Value) break;
|
if (!entry->Value) break;
|
||||||
printf("GETTING ENTRY %s %d\n", entry->Name, entry->Type);
|
|
||||||
switch (entry->Type)
|
switch (entry->Type)
|
||||||
{
|
{
|
||||||
case 0: *(int*)entry->Value = std::get<int>(entry->Default); break;
|
case 0: *(int*)entry->Value = std::get<int>(entry->Default); break;
|
||||||
|
@ -148,6 +148,10 @@ extern std::string LastROMFolder;
|
|||||||
|
|
||||||
extern std::string RecentROMList[10];
|
extern std::string RecentROMList[10];
|
||||||
|
|
||||||
|
extern std::string SaveFilePath;
|
||||||
|
extern std::string SavestatePath;
|
||||||
|
extern std::string CheatFilePath;
|
||||||
|
|
||||||
extern bool EnableCheats;
|
extern bool EnableCheats;
|
||||||
|
|
||||||
extern bool MouseHide;
|
extern bool MouseHide;
|
||||||
|
@ -1794,8 +1794,8 @@ void MainWindow::dropEvent(QDropEvent* event)
|
|||||||
slot = (romFileName.endsWith(".gba", Qt::CaseInsensitive) ? 1 : 0);
|
slot = (romFileName.endsWith(".gba", Qt::CaseInsensitive) ? 1 : 0);
|
||||||
QString sramFileName = QFileInfo(_filename).absolutePath() + QDir::separator() + QFileInfo(romFileName).completeBaseName() + ".sav";
|
QString sramFileName = QFileInfo(_filename).absolutePath() + QDir::separator() + QFileInfo(romFileName).completeBaseName() + ".sav";
|
||||||
|
|
||||||
if(slot == 0)
|
if (slot == 0)
|
||||||
strncpy(Frontend::NDSROMExtension, QFileInfo(romFileName).suffix().toStdString().c_str(), 4);
|
Frontend::NDSROMExtension= QFileInfo(romFileName).suffix().toStdString();
|
||||||
|
|
||||||
res = Frontend::LoadROM((const u8*)romBuffer.constData(), romBuffer.size(),
|
res = Frontend::LoadROM((const u8*)romBuffer.constData(), romBuffer.size(),
|
||||||
_filename, romFileName.toStdString().c_str(), sramFileName.toStdString().c_str(),
|
_filename, romFileName.toStdString().c_str(), sramFileName.toStdString().c_str(),
|
||||||
@ -1900,7 +1900,7 @@ void MainWindow::loadROM(QByteArray *romData, QString archiveFileName, QString r
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
strncpy(Frontend::NDSROMExtension, QFileInfo(romFileName).suffix().toStdString().c_str(), 4);
|
Frontend::NDSROMExtension = QFileInfo(romFileName).suffix().toStdString();
|
||||||
slot = 0;
|
slot = 0;
|
||||||
res = Frontend::LoadROM((const u8*)romData->constData(), romData->size(),
|
res = Frontend::LoadROM((const u8*)romData->constData(), romData->size(),
|
||||||
archiveFileName.toStdString().c_str(),
|
archiveFileName.toStdString().c_str(),
|
||||||
|
Reference in New Issue
Block a user