diff --git a/bsnes/nall/snes/cartridge.hpp b/bsnes/nall/snes/cartridge.hpp
index 48d32720..e3c0e0c5 100755
--- a/bsnes/nall/snes/cartridge.hpp
+++ b/bsnes/nall/snes/cartridge.hpp
@@ -362,7 +362,7 @@ SNESCartridge::SNESCartridge(const uint8_t *data, unsigned size) {
xml << " \n";
xml << " \n";
xml << " \n";
- xml << " \n";
+ xml << " \n";
xml << " \n";
xml << " \n";
xml << " \n";
@@ -372,7 +372,7 @@ SNESCartridge::SNESCartridge(const uint8_t *data, unsigned size) {
xml << " \n";
xml << " \n";
xml << " \n";
- xml << " \n";
+ xml << " \n";
xml << " \n";
xml << " \n";
xml << " \n";
diff --git a/bsnes/snes/cartridge/cartridge.hpp b/bsnes/snes/cartridge/cartridge.hpp
index d50f5c3d..3e0d682e 100755
--- a/bsnes/snes/cartridge/cartridge.hpp
+++ b/bsnes/snes/cartridge/cartridge.hpp
@@ -19,15 +19,15 @@ public:
SufamiTurboA,
SufamiTurboB,
GameBoy,
+
+ NECDSP,
+ MSU1,
+ Serial,
};
MappedRAM rom;
MappedRAM ram;
- //assigned externally to point to file-system datafiles (msu1 and serial)
- //example: "/path/to/filename.sfc" would set this to "/path/to/filename"
- readwrite basename;
-
readonly loaded;
readonly crc32;
readonly sha256;
diff --git a/bsnes/snes/cartridge/xml.cpp b/bsnes/snes/cartridge/xml.cpp
index 58584b3d..488bdc33 100755
--- a/bsnes/snes/cartridge/xml.cpp
+++ b/bsnes/snes/cartridge/xml.cpp
@@ -274,7 +274,7 @@ void Cartridge::xml_parse_necdsp(xml_element &root) {
unsigned filesize = promsize * 3 + dromsize * 2;
file fp;
- if(fp.open(string(dir(basename()), program), file::mode::read)) {
+ if(fp.open(system.interface->path(Slot::NECDSP, program), file::mode::read)) {
if(fp.size() == filesize) {
for(unsigned n = 0; n < promsize; n++) necdsp.programROM[n] = fp.readm(3);
for(unsigned n = 0; n < dromsize; n++) necdsp.dataROM[n] = fp.readm(2);
@@ -328,7 +328,7 @@ void Cartridge::xml_parse_necdsp(xml_element &root) {
}
}
- if(program == "") {
+ if(programhash == "") {
system.interface->message({ "Warning: NEC DSP program ", program, " is missing." });
} else if(sha256 != "" && sha256 != programhash) {
system.interface->message({
@@ -405,10 +405,17 @@ void Cartridge::xml_parse_sufamiturbo(xml_element &root) {
if(attr.name == "offset") m.offset = hex(attr.content);
if(attr.name == "size") m.size = hex(attr.content);
}
- if(memory.size() > 0) mapping.append(m);
+ if(m.size == 0) m.size = memory.size();
+ if(m.size) mapping.append(m);
}
}
} else if(slot.name == "ram") {
+ unsigned ram_size = 0;
+
+ foreach(attr, slot.attribute) {
+ if(attr.name == "size") ram_size = hex(attr.content);
+ }
+
foreach(leaf, slot.element) {
if(leaf.name == "map") {
Memory &memory = slotid == 0 ? sufamiturbo.slotA.ram : sufamiturbo.slotB.ram;
@@ -419,7 +426,8 @@ void Cartridge::xml_parse_sufamiturbo(xml_element &root) {
if(attr.name == "offset") m.offset = hex(attr.content);
if(attr.name == "size") m.size = hex(attr.content);
}
- if(memory.size() > 0) mapping.append(m);
+ if(m.size == 0) m.size = ram_size;
+ if(m.size) mapping.append(m);
}
}
}
diff --git a/bsnes/snes/chip/msu1/msu1.cpp b/bsnes/snes/chip/msu1/msu1.cpp
index 2b78d660..cc27244f 100755
--- a/bsnes/snes/chip/msu1/msu1.cpp
+++ b/bsnes/snes/chip/msu1/msu1.cpp
@@ -50,7 +50,7 @@ void MSU1::init() {
void MSU1::load() {
if(datafile.open()) datafile.close();
- datafile.open(string(cartridge.basename(), ".msu"), file::mode::read);
+ datafile.open(system.interface->path(Cartridge::Slot::MSU1, ".msu"), file::mode::read);
}
void MSU1::unload() {
@@ -133,7 +133,7 @@ void MSU1::mmio_write(unsigned addr, uint8 data) {
if(addr == 0x2005) {
mmio.audio_track = (mmio.audio_track & 0x00ff) | (data << 8);
if(audiofile.open()) audiofile.close();
- if(audiofile.open(string(cartridge.basename(), "-", (unsigned)mmio.audio_track, ".pcm"), file::mode::read)) {
+ if(audiofile.open(system.interface->path(Cartridge::Slot::MSU1, { "-", (unsigned)mmio.audio_track, ".pcm" }), file::mode::read)) {
uint32 header = audiofile.readm(4);
if(header != 0x4d535531) { //verify 'MSU1' header
audiofile.close();
diff --git a/bsnes/snes/chip/msu1/serialization.cpp b/bsnes/snes/chip/msu1/serialization.cpp
index 53df1ee3..e01f3a39 100755
--- a/bsnes/snes/chip/msu1/serialization.cpp
+++ b/bsnes/snes/chip/msu1/serialization.cpp
@@ -16,12 +16,12 @@ void MSU1::serialize(serializer &s) {
s.integer(mmio.audio_play);
if(datafile.open()) datafile.close();
- if(datafile.open(string(cartridge.basename(), ".msu"), file::mode::read)) {
+ if(datafile.open(system.interface->path(Cartridge::Slot::MSU1, ".msu"), file::mode::read)) {
datafile.seek(mmio.data_offset);
}
if(audiofile.open()) audiofile.close();
- if(audiofile.open(string(cartridge.basename(), "-", (unsigned)mmio.audio_track, ".pcm"), file::mode::read)) {
+ if(audiofile.open(system.interface->path(Cartridge::Slot::MSU1, { "-", (unsigned)mmio.audio_track, ".pcm" }), file::mode::read)) {
audiofile.seek(mmio.audio_offset);
}
}
diff --git a/bsnes/snes/chip/serial/serial.cpp b/bsnes/snes/chip/serial/serial.cpp
index a0bfbb93..1fee5b2e 100755
--- a/bsnes/snes/chip/serial/serial.cpp
+++ b/bsnes/snes/chip/serial/serial.cpp
@@ -79,8 +79,9 @@ void Serial::init() {
void Serial::load() {
if(opened()) close();
- string name = notdir(cartridge.basename());
- string path = dir(cartridge.basename());
+ string basename = system.interface->path(Cartridge::Slot::Serial, "");
+ string name = notdir(basename);
+ string path = dir(basename);
if(open(name, path)) {
baudrate = sym("snesserial_baudrate");
flowcontrol = sym("snesserial_flowcontrol");
diff --git a/bsnes/snes/chip/sufamiturbo/sufamiturbo.cpp b/bsnes/snes/chip/sufamiturbo/sufamiturbo.cpp
index 8104e3b5..33ebb8ef 100755
--- a/bsnes/snes/chip/sufamiturbo/sufamiturbo.cpp
+++ b/bsnes/snes/chip/sufamiturbo/sufamiturbo.cpp
@@ -11,13 +11,13 @@ void SufamiTurbo::load() {
slotB.ram.map(allocate(128 * 1024, 0xff), 128 * 1024);
if(slotA.rom.data()) {
- cartridge.nvram.append({ "srm", slotA.ram.data(), slotA.ram.size(), Cartridge::Slot::SufamiTurboA });
+ cartridge.nvram.append({ "sts", slotA.ram.data(), slotA.ram.size(), Cartridge::Slot::SufamiTurboA });
} else {
slotA.rom.map(allocate(128 * 1024, 0xff), 128 * 1024);
}
if(slotB.rom.data()) {
- cartridge.nvram.append({ "srm", slotB.ram.data(), slotB.ram.size(), Cartridge::Slot::SufamiTurboB });
+ cartridge.nvram.append({ "sts", slotB.ram.data(), slotB.ram.size(), Cartridge::Slot::SufamiTurboB });
} else {
slotB.rom.map(allocate(128 * 1024, 0xff), 128 * 1024);
}
diff --git a/bsnes/snes/interface/interface.hpp b/bsnes/snes/interface/interface.hpp
index fb236aea..71aabe7c 100755
--- a/bsnes/snes/interface/interface.hpp
+++ b/bsnes/snes/interface/interface.hpp
@@ -6,4 +6,5 @@ public:
virtual int16_t input_poll(bool port, Input::Device device, unsigned index, unsigned id) { return 0; }
virtual void message(const string &text) { print(text, "\n"); }
+ virtual string path(Cartridge::Slot slot, const string &path) { return path; };
};
diff --git a/bsnes/snes/snes.hpp b/bsnes/snes/snes.hpp
index cc227247..a69d84ca 100755
--- a/bsnes/snes/snes.hpp
+++ b/bsnes/snes/snes.hpp
@@ -1,7 +1,7 @@
namespace SNES {
namespace Info {
static const char Name[] = "bsnes";
- static const char Version[] = "076.03";
+ static const char Version[] = "076.04";
static const unsigned SerializerVersion = 18;
}
}
@@ -132,6 +132,7 @@ namespace SNES {
#include
#include
#include
+ #include
#include
#include
diff --git a/bsnes/snes/system/system.hpp b/bsnes/snes/system/system.hpp
index 4cf7474b..2382de8d 100755
--- a/bsnes/snes/system/system.hpp
+++ b/bsnes/snes/system/system.hpp
@@ -2,6 +2,7 @@ class Interface;
class System : property {
public:
+ Interface *interface;
enum class Region : unsigned { NTSC = 0, PAL = 1, Autodetect = 2 };
enum class ExpansionPortDevice : unsigned { None = 0, BSX = 1 };
@@ -31,7 +32,6 @@ public:
System();
private:
- Interface *interface;
void runthreadtosave();
void serialize(serializer&);
@@ -50,7 +50,6 @@ private:
#include
#include
-#include
#include
extern System system;
diff --git a/bsnes/ui/cartridge/cartridge.cpp b/bsnes/ui/cartridge/cartridge.cpp
index 92504bf4..81852e8b 100755
--- a/bsnes/ui/cartridge/cartridge.cpp
+++ b/bsnes/ui/cartridge/cartridge.cpp
@@ -4,7 +4,7 @@ Cartridge cartridge;
bool Cartridge::loadNormal(const char *basename) {
unload();
if(loadCartridge(SNES::cartridge.rom, baseXML, basename) == false) return false;
- SNES::cartridge.basename = baseName = nall::basename(basename);
+ baseName = nall::basename(basename);
SNES::cartridge.load(SNES::Cartridge::Mode::Normal, { baseXML });
foreach(memory, SNES::cartridge.nvram) loadMemory(memory);
utility.cartridgeLoaded();
@@ -15,7 +15,7 @@ bool Cartridge::loadBsxSlotted(const char *basename, const char *slotname) {
unload();
if(loadCartridge(SNES::cartridge.rom, baseXML, basename) == false) return false;
loadCartridge(SNES::bsxflash.memory, bsxXML, slotname);
- SNES::cartridge.basename = baseName = nall::basename(basename);
+ baseName = nall::basename(basename);
bsxName = nall::basename(slotname);
SNES::cartridge.load(SNES::Cartridge::Mode::BsxSlotted, { baseXML, bsxXML });
foreach(memory, SNES::cartridge.nvram) loadMemory(memory);
@@ -27,7 +27,7 @@ bool Cartridge::loadBsx(const char *basename, const char *slotname) {
unload();
if(loadCartridge(SNES::cartridge.rom, baseXML, basename) == false) return false;
loadCartridge(SNES::bsxflash.memory, bsxXML, slotname);
- SNES::cartridge.basename = baseName = nall::basename(basename);
+ baseName = nall::basename(basename);
bsxName = nall::basename(slotname);
SNES::cartridge.load(SNES::Cartridge::Mode::Bsx, { baseXML, bsxXML });
foreach(memory, SNES::cartridge.nvram) loadMemory(memory);
@@ -40,7 +40,7 @@ bool Cartridge::loadSufamiTurbo(const char *basename, const char *slotAname, con
if(loadCartridge(SNES::cartridge.rom, baseXML, basename) == false) return false;
loadCartridge(SNES::sufamiturbo.slotA.rom, sufamiTurboAXML, slotAname);
loadCartridge(SNES::sufamiturbo.slotB.rom, sufamiTurboBXML, slotBname);
- SNES::cartridge.basename = baseName = nall::basename(basename);
+ baseName = nall::basename(basename);
sufamiTurboAName = nall::basename(slotAname);
sufamiTurboBName = nall::basename(slotBname);
SNES::cartridge.load(SNES::Cartridge::Mode::SufamiTurbo, { baseXML, sufamiTurboAXML, sufamiTurboBXML });
@@ -68,7 +68,7 @@ bool Cartridge::loadSuperGameBoy(const char *basename, const char *slotname) {
GameBoy::cartridge.load(info.xml, data, size);
if(data) delete[] data;
- SNES::cartridge.basename = baseName = nall::basename(basename);
+ baseName = nall::basename(basename);
gameBoyName = nall::basename(slotname);
SNES::cartridge.load(SNES::Cartridge::Mode::SuperGameBoy, { baseXML, "" });
diff --git a/bsnes/ui/debugger/console.cpp b/bsnes/ui/debugger/console.cpp
index 36144aec..996eab75 100755
--- a/bsnes/ui/debugger/console.cpp
+++ b/bsnes/ui/debugger/console.cpp
@@ -54,7 +54,7 @@ void Console::write(const string &text, bool echo) {
void Console::tracerEnable(bool state) {
if(state == true) {
- logfile.open(path.load(SNES::Cartridge::Slot::Cartridge, "log"), file::mode::write);
+ logfile.open(path.load(SNES::Cartridge::Slot::Base, "log"), file::mode::write);
} else {
logfile.close();
}
diff --git a/bsnes/ui/interface.cpp b/bsnes/ui/interface.cpp
index 5ee935cf..fabeb003 100755
--- a/bsnes/ui/interface.cpp
+++ b/bsnes/ui/interface.cpp
@@ -137,3 +137,7 @@ int16_t Interface::input_poll(bool port, SNES::Input::Device device, unsigned in
void Interface::message(const string &text) {
MessageWindow::information(mainWindow, text);
}
+
+string Interface::path(SNES::Cartridge::Slot slot, const string &pathname) {
+ return ::path.load(slot, pathname);
+}
diff --git a/bsnes/ui/interface.hpp b/bsnes/ui/interface.hpp
index 34f795c0..321a87f9 100755
--- a/bsnes/ui/interface.hpp
+++ b/bsnes/ui/interface.hpp
@@ -21,6 +21,7 @@ struct Interface : public SNES::Interface {
int16_t input_poll(bool port, SNES::Input::Device device, unsigned index, unsigned id);
void message(const string &text);
+ string path(SNES::Cartridge::Slot slot, const string &path);
};
extern Palette palette;
diff --git a/bsnes/ui/path/path.cpp b/bsnes/ui/path/path.cpp
index 3a93d597..0b8e0cf2 100755
--- a/bsnes/ui/path/path.cpp
+++ b/bsnes/ui/path/path.cpp
@@ -62,14 +62,24 @@ string Path::load(SNES::Cartridge::Slot slot, const string &type, const string &
case SNES::Cartridge::Slot::SufamiTurboA: romPath = cartridge.sufamiTurboAName; break;
case SNES::Cartridge::Slot::SufamiTurboB: romPath = cartridge.sufamiTurboBName; break;
case SNES::Cartridge::Slot::GameBoy: romPath = cartridge.gameBoyName; break;
+
+ case SNES::Cartridge::Slot::NECDSP: romPath = cartridge.baseName; break;
+ case SNES::Cartridge::Slot::MSU1: romPath = cartridge.baseName; break;
+ case SNES::Cartridge::Slot::Serial: romPath = cartridge.baseName; break;
}
string path = romPath;
+ if(slot == SNES::Cartridge::Slot::NECDSP && necdsp != "") path = necdsp;
+ if(slot == SNES::Cartridge::Slot::MSU1 && msu1 != "") path = string(msu1, notdir(path));
+ if(slot == SNES::Cartridge::Slot::Serial && serial != "") path = string(serial, notdir(path));
+
if(type == "srm" && srm != "") path = string(srm, notdir(path));
- if(type == "bsp" && srm != "") path = string(srm, notdir(path));
- if(type == "bss" && srm != "") path = string(srm, notdir(path));
- if(type == "sav" && srm != "") path = string(srm, notdir(path));
+ if(type == "bsp" && bsp != "") path = string(bsp, notdir(path));
+ if(type == "bss" && bss != "") path = string(bss, notdir(path));
+ if(type == "sts" && sts != "") path = string(sts, notdir(path));
+ if(type == "sav" && sav != "") path = string(sav, notdir(path));
if(type == "rtc" && rtc != "") path = string(rtc, notdir(path));
+
if(type == "bsa" && bsa != "") path = string(bsa, notdir(path));
if(type == "bst" && bst != "") path = string(bst, notdir(path));
if(type == "cht" && cht != "") path = string(cht, notdir(path));
@@ -95,6 +105,10 @@ string Path::load(SNES::Cartridge::Slot slot, const string &type, const string &
path = string(dir(base), path);
}
+ if(slot == SNES::Cartridge::Slot::NECDSP) return { dir(path), type };
+ if(slot == SNES::Cartridge::Slot::MSU1) return { path, type };
+ if(slot == SNES::Cartridge::Slot::Serial) return { path, type };
+
return { path, suffix, ".", type };
}
@@ -119,8 +133,16 @@ Path::Path() {
attach(sufamiTurboBios = "", "sufamiTurboBios");
attach(superGameBoyBios = "", "superGameBoyBios");
+ attach(necdsp = "", "necdsp");
+ attach(msu1 = "", "msu1");
+ attach(serial = "", "serial");
+
attach(srm = "", "srm");
attach(rtc = "", "rtc");
+ attach(bss = "", "bss");
+ attach(bsp = "", "bsp");
+ attach(sts = "", "sts");
+ attach(sav = "", "sav");
attach(bsa = "", "bsa");
attach(bst = "", "bst");
diff --git a/bsnes/ui/path/path.hpp b/bsnes/ui/path/path.hpp
index 0eadc79b..54a54d1a 100755
--- a/bsnes/ui/path/path.hpp
+++ b/bsnes/ui/path/path.hpp
@@ -14,8 +14,16 @@ struct Path : public configuration {
string sufamiTurboBios;
string superGameBoyBios;
+ string necdsp;
+ string msu1;
+ string serial;
+
string srm;
string rtc;
+ string bss;
+ string bsp;
+ string sts;
+ string sav;
string bsa;
string bst;