gambatte: rip out unused save directory and gameshark\gamegenie internal stuff

This commit is contained in:
goyuken 2014-05-07 22:26:13 +00:00
parent 7b95dd4745
commit c687ac7cfd
9 changed files with 0 additions and 164 deletions

View File

@ -231,14 +231,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
[DllImport("libgambatte.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern void gambatte_setrtccallback(IntPtr core, RTCCallback callback);
/// <summary>
/// Sets the directory used for storing save data. The default is the same directory as the ROM Image file.
/// </summary>
/// <param name="core">opaque state pointer</param>
/// <param name="sdir"></param>
//[DllImport("libgambatte.dll", CallingConvention = CallingConvention.Cdecl)]
//public static extern void gambatte_setsavedir(IntPtr core, string sdir);
/// <summary>
/// Returns true if the currently loaded ROM image is treated as having CGB support.
/// </summary>
@ -314,22 +306,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
[DllImport("libgambatte.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern string gambatte_romtitle(IntPtr core);
/// <summary>
/// Set Game Genie codes to apply to currently loaded ROM image. Cleared on ROM load.
/// </summary>
/// <param name="core">opaque state pointer</param>
/// <param name="codes">Game Genie codes in format HHH-HHH-HHH;HHH-HHH-HHH;... where H is [0-9]|[A-F]</param>
[DllImport("libgambatte.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern void gambatte_setgamegenie(IntPtr core, string codes);
/// <summary>
/// Game Shark codes to apply to currently loaded ROM image. Cleared on ROM load.
/// </summary>
/// <param name="core">opaque state pointer</param>
/// <param name="codes">Game Shark codes in format 01HHHHHH;01HHHHHH;... where H is [0-9]|[A-F]</param>
[DllImport("libgambatte.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern void gambatte_setgameshark(IntPtr core, string codes);
/// <summary>
/// memory areas that gambatte_getmemoryarea() can return
/// </summary>

View File

@ -92,9 +92,6 @@ public:
void setScanlineCallback(void (*callback)(), int sl);
void setRTCCallback(std::uint32_t (*callback)());
/** Sets the directory used for storing save data. The default is the same directory as the ROM Image file. */
void setSaveDir(const std::string &sdir);
/** Returns true if the currently loaded ROM image is treated as having CGB support. */
bool isCgb() const;
@ -124,16 +121,6 @@ public:
/** ROM header title of currently loaded ROM image. */
const std::string romTitle() const;
/** Set Game Genie codes to apply to currently loaded ROM image. Cleared on ROM load.
* @param codes Game Genie codes in format HHH-HHH-HHH;HHH-HHH-HHH;... where H is [0-9]|[A-F]
*/
void setGameGenie(const std::string &codes);
/** Set Game Shark codes to apply to currently loaded ROM image. Cleared on ROM load.
* @param codes Game Shark codes in format 01HHHHHH;01HHHHHH;... where H is [0-9]|[A-F]
*/
void setGameShark(const std::string &codes);
unsigned char ExternalRead(unsigned short addr);
void ExternalWrite(unsigned short addr, unsigned char val);

View File

@ -113,12 +113,6 @@ GBEXPORT void gambatte_setrtccallback(void *core, unsigned int (*callback)())
g->setRTCCallback(callback);
}
GBEXPORT void gambatte_setsavedir(void *core, const char *sdir)
{
GB *g = (GB *) core;
g->setSaveDir(std::string(sdir));
}
GBEXPORT int gambatte_iscgb(void *core)
{
GB *g = (GB *) core;
@ -187,18 +181,6 @@ GBEXPORT const char *gambatte_romtitle(void *core)
return horriblebuff;
}
GBEXPORT void gambatte_setgamegenie(void *core, const char *codes)
{
GB *g = (GB *) core;
g->setGameGenie(std::string(codes));
}
GBEXPORT void gambatte_setgameshark(void *core, const char *codes)
{
GB *g = (GB *) core;
g->setGameShark(std::string(codes));
}
GBEXPORT int gambatte_getmemoryarea(void *core, int which, unsigned char **data, int *length)
{
GB *g = (GB *) core;

View File

@ -91,14 +91,6 @@ public:
memory.setRTCCallback(callback);
}
void setSaveDir(const std::string &sdir) {
memory.setSaveDir(sdir);
}
const std::string saveBasePath() const {
return memory.saveBasePath();
}
int load(const char *romfiledata, unsigned romfilelength, bool forceDmg, bool multicartCompat) {
return memory.loadROM(romfiledata, romfilelength, forceDmg, multicartCompat);
}
@ -119,9 +111,6 @@ public:
memory.setCgbPalette(lut);
}
void setGameGenie(const std::string &codes) { memory.setGameGenie(codes); }
void setGameShark(const std::string &codes) { memory.setGameShark(codes); }
//unsigned char ExternalRead(unsigned short addr) { return memory.read(addr, cycleCounter_); }
unsigned char ExternalRead(unsigned short addr) { return memory.peek(addr); }
void ExternalWrite(unsigned short addr, unsigned char val) { memory.write_nocb(addr, val, cycleCounter_); }

View File

@ -135,10 +135,6 @@ void GB::setRTCCallback(std::uint32_t (*callback)()) {
p_->cpu.setRTCCallback(callback);
}
void GB::setSaveDir(const std::string &sdir) {
p_->cpu.setSaveDir(sdir);
}
int GB::load(const char *romfiledata, unsigned romfilelength, const std::uint32_t now, const unsigned flags) {
//if (p_->cpu.loaded())
// p_->cpu.saveSavedata();
@ -249,14 +245,6 @@ const std::string GB::romTitle() const {
return std::string();
}
void GB::setGameGenie(const std::string &codes) {
p_->cpu.setGameGenie(codes);
}
void GB::setGameShark(const std::string &codes) {
p_->cpu.setGameShark(codes);
}
int GB::LinkStatus(int which) {
return p_->cpu.LinkStatus(which);
}

View File

@ -460,36 +460,6 @@ void Cartridge::loadState(const SaveState &state) {
mbc->loadState(state.mem);
}
static const std::string stripExtension(const std::string &str) {
const std::string::size_type lastDot = str.find_last_of('.');
const std::string::size_type lastSlash = str.find_last_of('/');
if (lastDot != std::string::npos && (lastSlash == std::string::npos || lastSlash < lastDot))
return str.substr(0, lastDot);
return str;
}
static const std::string stripDir(const std::string &str) {
const std::string::size_type lastSlash = str.find_last_of('/');
if (lastSlash != std::string::npos)
return str.substr(lastSlash + 1);
return str;
}
const std::string Cartridge::saveBasePath() const {
return saveDir.empty() ? defaultSaveBasePath : saveDir + stripDir(defaultSaveBasePath);
}
void Cartridge::setSaveDir(const std::string &dir) {
saveDir = dir;
if (!saveDir.empty() && saveDir[saveDir.length() - 1] != '/')
saveDir += '/';
}
static void enforce8bit(unsigned char *data, unsigned long sz) {
if (static_cast<unsigned char>(0x100))
while (sz--)
@ -607,8 +577,6 @@ int Cartridge::loadROM(const char *romfiledata, unsigned romfilelength, const bo
rombanks = std::max(pow2ceil(filesize / 0x4000), 2u);
std::printf("rombanks: %u\n", static_cast<unsigned>(filesize / 0x4000));
defaultSaveBasePath.clear();
ggUndoList.clear();
mbc.reset();
memptrs.reset(rombanks, rambanks, cgb ? 8 : 2);
rtc.set(false, 0);
@ -622,8 +590,6 @@ int Cartridge::loadROM(const char *romfiledata, unsigned romfilelength, const bo
//if (rom->fail())
// return -1;
defaultSaveBasePath = stripExtension("fixmefixme.gb"); //(romfile);
switch (type) {
case PLAIN: mbc.reset(new Mbc0(memptrs)); break;
case MBC1:
@ -726,46 +692,4 @@ bool Cartridge::getMemoryArea(int which, unsigned char **data, int *length) {
return false;
}
static int asHex(const char c) {
return c >= 'A' ? c - 'A' + 0xA : c - '0';
}
void Cartridge::applyGameGenie(const std::string &code) {
if (6 < code.length()) {
const unsigned val = (asHex(code[0]) << 4 | asHex(code[1])) & 0xFF;
const unsigned addr = (asHex(code[2]) << 8 | asHex(code[4]) << 4 | asHex(code[5]) | (asHex(code[6]) ^ 0xF) << 12) & 0x7FFF;
unsigned cmp = 0xFFFF;
if (10 < code.length()) {
cmp = (asHex(code[8]) << 4 | asHex(code[10])) ^ 0xFF;
cmp = ((cmp >> 2 | cmp << 6) ^ 0x45) & 0xFF;
}
for (unsigned bank = 0; bank < static_cast<std::size_t>(memptrs.romdataend() - memptrs.romdata()) / 0x4000; ++bank) {
if (mbc->isAddressWithinAreaRombankCanBeMappedTo(addr, bank)
&& (cmp > 0xFF || memptrs.romdata()[bank * 0x4000ul + (addr & 0x3FFF)] == cmp)) {
ggUndoList.push_back(AddrData(bank * 0x4000ul + (addr & 0x3FFF), memptrs.romdata()[bank * 0x4000ul + (addr & 0x3FFF)]));
memptrs.romdata()[bank * 0x4000ul + (addr & 0x3FFF)] = val;
}
}
}
}
void Cartridge::setGameGenie(const std::string &codes) {
if (loaded()) {
for (std::vector<AddrData>::reverse_iterator it = ggUndoList.rbegin(), end = ggUndoList.rend(); it != end; ++it) {
if (memptrs.romdata() + it->addr < memptrs.romdataend())
memptrs.romdata()[it->addr] = it->data;
}
ggUndoList.clear();
std::string code;
for (std::size_t pos = 0; pos < codes.length()
&& (code = codes.substr(pos, codes.find(';', pos) - pos), true); pos += code.length() + 1) {
applyGameGenie(code);
}
}
}
}

View File

@ -47,9 +47,6 @@ class Cartridge {
MemPtrs memptrs;
Rtc rtc;
std::auto_ptr<Mbc> mbc;
std::string defaultSaveBasePath;
std::string saveDir;
std::vector<AddrData> ggUndoList;
void applyGameGenie(const std::string &code);
@ -85,14 +82,11 @@ public:
void loadSavedata(const char *data);
int saveSavedataLength();
void saveSavedata(char *dest);
const std::string saveBasePath() const;
void setSaveDir(const std::string &dir);
bool getMemoryArea(int which, unsigned char **data, int *length);
int loadROM(const char *romfiledata, unsigned romfilelength, bool forceDmg, bool multicartCompat);
const char * romTitle() const { return reinterpret_cast<const char *>(memptrs.romdata() + 0x134); }
void setGameGenie(const std::string &codes);
void setRTCCallback(std::uint32_t (*callback)()) {
rtc.setRTCCallback(callback);

View File

@ -91,7 +91,6 @@ public:
void loadSavedata(const char *data) { cart.loadSavedata(data); }
int saveSavedataLength() {return cart.saveSavedataLength(); }
void saveSavedata(char *dest) { cart.saveSavedata(dest); }
const std::string saveBasePath() const { return cart.saveBasePath(); }
bool getMemoryArea(int which, unsigned char **data, int *length); // { return cart.getMemoryArea(which, data, length); }
@ -159,7 +158,6 @@ public:
unsigned long resetCounters(unsigned long cycleCounter);
int loadROM(const char *romfiledata, unsigned romfilelength, bool forceDmg, bool multicartCompat);
void setSaveDir(const std::string &dir) { cart.setSaveDir(dir); }
void setInputGetter(InputGetter *getInput) {
this->getInput = getInput;
@ -194,8 +192,6 @@ public:
void setDmgPaletteColor(unsigned palNum, unsigned colorNum, unsigned long rgb32);
void setCgbPalette(unsigned *lut);
void setGameGenie(const std::string &codes) { cart.setGameGenie(codes); }
void setGameShark(const std::string &codes) { interrupter.setGameShark(codes); }
int LinkStatus(int which);
};

Binary file not shown.