diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/LibGambatte.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/LibGambatte.cs index d4a57ed26b..bbe95e20cf 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/LibGambatte.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/LibGambatte.cs @@ -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); - /// - /// Sets the directory used for storing save data. The default is the same directory as the ROM Image file. - /// - /// opaque state pointer - /// - //[DllImport("libgambatte.dll", CallingConvention = CallingConvention.Cdecl)] - //public static extern void gambatte_setsavedir(IntPtr core, string sdir); - /// /// Returns true if the currently loaded ROM image is treated as having CGB support. /// @@ -314,22 +306,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy [DllImport("libgambatte.dll", CallingConvention = CallingConvention.Cdecl)] public static extern string gambatte_romtitle(IntPtr core); - /// - /// Set Game Genie codes to apply to currently loaded ROM image. Cleared on ROM load. - /// - /// opaque state pointer - /// Game Genie codes in format HHH-HHH-HHH;HHH-HHH-HHH;... where H is [0-9]|[A-F] - [DllImport("libgambatte.dll", CallingConvention = CallingConvention.Cdecl)] - public static extern void gambatte_setgamegenie(IntPtr core, string codes); - - /// - /// Game Shark codes to apply to currently loaded ROM image. Cleared on ROM load. - /// - /// opaque state pointer - /// Game Shark codes in format 01HHHHHH;01HHHHHH;... where H is [0-9]|[A-F] - [DllImport("libgambatte.dll", CallingConvention = CallingConvention.Cdecl)] - public static extern void gambatte_setgameshark(IntPtr core, string codes); - /// /// memory areas that gambatte_getmemoryarea() can return /// diff --git a/libgambatte/include/gambatte.h b/libgambatte/include/gambatte.h index c800189461..4af0e6eb43 100644 --- a/libgambatte/include/gambatte.h +++ b/libgambatte/include/gambatte.h @@ -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); diff --git a/libgambatte/src/cinterface.cpp b/libgambatte/src/cinterface.cpp index 56c128b197..deb0f2b528 100644 --- a/libgambatte/src/cinterface.cpp +++ b/libgambatte/src/cinterface.cpp @@ -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; diff --git a/libgambatte/src/cpu.h b/libgambatte/src/cpu.h index 35a802ac1c..04bb74d12b 100644 --- a/libgambatte/src/cpu.h +++ b/libgambatte/src/cpu.h @@ -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_); } diff --git a/libgambatte/src/gambatte.cpp b/libgambatte/src/gambatte.cpp index 37436fd71f..f54b62f33c 100644 --- a/libgambatte/src/gambatte.cpp +++ b/libgambatte/src/gambatte.cpp @@ -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); } diff --git a/libgambatte/src/mem/cartridge.cpp b/libgambatte/src/mem/cartridge.cpp index 4b4c72b386..fb9d476c22 100644 --- a/libgambatte/src/mem/cartridge.cpp +++ b/libgambatte/src/mem/cartridge.cpp @@ -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(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(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(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::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); - } - } -} - } diff --git a/libgambatte/src/mem/cartridge.h b/libgambatte/src/mem/cartridge.h index 3883772243..2f45346341 100644 --- a/libgambatte/src/mem/cartridge.h +++ b/libgambatte/src/mem/cartridge.h @@ -47,9 +47,6 @@ class Cartridge { MemPtrs memptrs; Rtc rtc; std::auto_ptr mbc; - std::string defaultSaveBasePath; - std::string saveDir; - std::vector 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(memptrs.romdata() + 0x134); } - void setGameGenie(const std::string &codes); void setRTCCallback(std::uint32_t (*callback)()) { rtc.setRTCCallback(callback); diff --git a/libgambatte/src/memory.h b/libgambatte/src/memory.h index 182eba1369..48f0389133 100644 --- a/libgambatte/src/memory.h +++ b/libgambatte/src/memory.h @@ -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); }; diff --git a/output/dll/libgambatte.dll b/output/dll/libgambatte.dll index 1cbdeb911f..635b46e5d6 100644 Binary files a/output/dll/libgambatte.dll and b/output/dll/libgambatte.dll differ