Update to v076r06 release.

byuu says:

Changelog:
- path code finished for ui/, just need to expose for ui-libsnes/ now
- filters and shaders use radio items now, so you know which is active
- smooth video was placed inside video mode (list is getting too long)
- .bsnes -> .config/bsnes in make install
- pixelshaders -> snesshader, added Makefile with make install target
- snesfilter, added Makefile with make install and make clean targets
- maybe other stuff
This commit is contained in:
Tim Allen 2011-03-17 21:20:51 +11:00
parent d5cd21eb0c
commit 5cbf5b617b
23 changed files with 174 additions and 150 deletions

View File

@ -1,2 +1,2 @@
@mingw32-make -j 2
@mingw32-make -j 8
@pause

View File

@ -3,14 +3,15 @@
namespace nall {
string realpath(const char *name) {
string currentpath() {
char path[PATH_MAX];
if(::realpath(name, path)) {
if(::getcwd(path)) {
string result(path);
result.transform("\\", "/");
if(result.endswith("/") == false) result.append("/");
return result;
}
return "";
return "./";
}
string userpath() {
@ -21,18 +22,17 @@ string userpath() {
if(result.endswith("/") == false) result.append("/");
return result;
}
return "";
return currentpath();
}
string currentpath() {
string realpath(const char *name) {
char path[PATH_MAX];
if(::getcwd(path)) {
if(::realpath(name, path)) {
string result(path);
result.transform("\\", "/");
if(result.endswith("/") == false) result.append("/");
return result;
}
return "";
return userpath();
}
}

View File

@ -80,7 +80,7 @@ void CheckItem::setChecked(bool checked) { state.checked = checked; return p.set
void CheckItem::setText(const string &text) { state.text = text; return p.setText(text); }
CheckItem::CheckItem() : state(*new State), base_from_member<pCheckItem&>(*new pCheckItem(*this)), Action(base_from_member<pCheckItem&>::value), p(base_from_member<pCheckItem&>::value) { p.constructor(); }
void RadioItem::group_(const reference_array<RadioItem&> &list) { foreach(item, list) item.p.setGroup(item.state.group = list); if(list.size()) list[0].setChecked(); }
void RadioItem::group(const reference_array<RadioItem&> &list) { foreach(item, list) item.p.setGroup(item.state.group = list); if(list.size()) list[0].setChecked(); }
bool RadioItem::checked() { return p.checked(); }
void RadioItem::setChecked() { foreach(item, state.group) item.state.checked = false; state.checked = true; return p.setChecked(); }
void RadioItem::setText(const string &text) { state.text = text; return p.setText(text); }
@ -148,7 +148,7 @@ ListView::ListView() : state(*new State), base_from_member<pListView&>(*new pLis
void ProgressBar::setPosition(unsigned position) { state.position = position; return p.setPosition(position); }
ProgressBar::ProgressBar() : state(*new State), base_from_member<pProgressBar&>(*new pProgressBar(*this)), Widget(base_from_member<pProgressBar&>::value), p(base_from_member<pProgressBar&>::value) { p.constructor(); }
void RadioBox::group_(const reference_array<RadioBox&> &list) { foreach(item, list) item.p.setGroup(item.state.group = list); if(list.size()) list[0].setChecked(); }
void RadioBox::group(const reference_array<RadioBox&> &list) { foreach(item, list) item.p.setGroup(item.state.group = list); if(list.size()) list[0].setChecked(); }
bool RadioBox::checked() { return p.checked(); }
void RadioBox::setChecked() { foreach(item, state.group) item.state.checked = false; state.checked = true; return p.setChecked(); }
void RadioBox::setText(const string &text) { state.text = text; return p.setText(text); }

View File

@ -179,7 +179,8 @@ struct CheckItem : private nall::base_from_member<pCheckItem&>, Action {
};
struct RadioItem : private nall::base_from_member<pRadioItem&>, Action {
template<typename... Args> static void group(Args&... args) { group_({ args... }); }
template<typename... Args> static void group(Args&... args) { group({ args... }); }
static void group(const nall::reference_array<RadioItem&> &list);
nall::function<void ()> onTick;
@ -191,9 +192,6 @@ struct RadioItem : private nall::base_from_member<pRadioItem&>, Action {
struct State;
State &state;
pRadioItem &p;
private:
static void group_(const nall::reference_array<RadioItem&> &list);
};
struct Layout : Object {
@ -348,7 +346,8 @@ struct ProgressBar : private nall::base_from_member<pProgressBar&>, Widget {
};
struct RadioBox : private nall::base_from_member<pRadioBox&>, Widget {
template<typename... Args> static void group(Args&... args) { group_({ args... }); }
template<typename... Args> static void group(Args&... args) { group({ args... }); }
static void group(const nall::reference_array<RadioBox&> &list);
nall::function<void ()> onTick;
@ -360,9 +359,6 @@ struct RadioBox : private nall::base_from_member<pRadioBox&>, Widget {
struct State;
State &state;
pRadioBox &p;
private:
static void group_(const nall::reference_array<RadioBox&> &list);
};
struct TextEdit : private nall::base_from_member<pTextEdit&>, Widget {

View File

@ -1,7 +1,7 @@
/****************************************************************************
** Meta object code from reading C++ file 'qt.moc.hpp'
**
** Created: Sun Mar 13 14:53:22 2011
** Created: Mon Mar 14 20:13:45 2011
** by: The Qt Meta Object Compiler version 62 (Qt 4.7.0)
**
** WARNING! All changes made in this file will be lost!

View File

@ -13,17 +13,13 @@ public:
PAL,
};
enum class Path : unsigned {
enum class Slot : unsigned {
Base,
Bsx,
SufamiTurbo,
SufamiTurboA,
SufamiTurboB,
GameBoy,
NECDSP,
MSU1,
Serial,
};
MappedRAM rom;
@ -55,10 +51,10 @@ public:
const string id;
uint8_t *data;
unsigned size;
Path path;
NonVolatileRAM() : id(""), data(0), size(0), path(Path::Base) {}
NonVolatileRAM(const string id, uint8_t *data, unsigned size, Path path = Path::Base)
: id(id), data(data), size(size), path(path) {}
Slot slot;
NonVolatileRAM() : id(""), data(0), size(0), slot(Slot::Base) {}
NonVolatileRAM(const string id, uint8_t *data, unsigned size, Slot slot = Slot::Base)
: id(id), data(data), size(size), slot(slot) {}
};
linear_vector<NonVolatileRAM> nvram;

View File

@ -269,12 +269,13 @@ void Cartridge::xml_parse_necdsp(xml_element &root) {
}
}
string path = { dir(system.interface->path(Slot::Base, ".dsp")), program };
unsigned promsize = (necdsp.revision == NECDSP::Revision::uPD7725 ? 2048 : 16384);
unsigned dromsize = (necdsp.revision == NECDSP::Revision::uPD7725 ? 1024 : 2048);
unsigned filesize = promsize * 3 + dromsize * 2;
file fp;
if(fp.open(system.interface->path(Path::NECDSP, program), file::mode::read)) {
if(fp.open(path, 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);

View File

@ -50,7 +50,7 @@ void MSU1::init() {
void MSU1::load() {
if(datafile.open()) datafile.close();
datafile.open(system.interface->path(Cartridge::Path::MSU1, ".msu"), file::mode::read);
datafile.open(system.interface->path(Cartridge::Slot::Base, ".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(system.interface->path(Cartridge::Path::MSU1, { "-", (unsigned)mmio.audio_track, ".pcm" }), file::mode::read)) {
if(audiofile.open(system.interface->path(Cartridge::Slot::Base, { "-", (unsigned)mmio.audio_track, ".pcm" }), file::mode::read)) {
uint32 header = audiofile.readm(4);
if(header != 0x4d535531) { //verify 'MSU1' header
audiofile.close();

View File

@ -16,12 +16,12 @@ void MSU1::serialize(serializer &s) {
s.integer(mmio.audio_play);
if(datafile.open()) datafile.close();
if(datafile.open(system.interface->path(Cartridge::Path::MSU1, ".msu"), file::mode::read)) {
if(datafile.open(system.interface->path(Cartridge::Slot::Base, ".msu"), file::mode::read)) {
datafile.seek(mmio.data_offset);
}
if(audiofile.open()) audiofile.close();
if(audiofile.open(system.interface->path(Cartridge::Path::MSU1, { "-", (unsigned)mmio.audio_track, ".pcm" }), file::mode::read)) {
if(audiofile.open(system.interface->path(Cartridge::Slot::Base, { "-", (unsigned)mmio.audio_track, ".pcm" }), file::mode::read)) {
audiofile.seek(mmio.audio_offset);
}
}

View File

@ -79,7 +79,7 @@ void Serial::init() {
void Serial::load() {
if(opened()) close();
string basename = system.interface->path(Cartridge::Path::Serial, "");
string basename = system.interface->path(Cartridge::Slot::Base, "");
string name = notdir(basename);
string path = dir(basename);
if(open(name, path)) {

View File

@ -11,13 +11,13 @@ void SufamiTurbo::load() {
slotB.ram.map(allocate<uint8>(128 * 1024, 0xff), 128 * 1024);
if(slotA.rom.data()) {
cartridge.nvram.append({ ".sts", slotA.ram.data(), slotA.ram.size(), Cartridge::Path::SufamiTurboA });
cartridge.nvram.append({ ".sts", slotA.ram.data(), slotA.ram.size(), Cartridge::Slot::SufamiTurboA });
} else {
slotA.rom.map(allocate<uint8>(128 * 1024, 0xff), 128 * 1024);
}
if(slotB.rom.data()) {
cartridge.nvram.append({ ".sts", slotB.ram.data(), slotB.ram.size(), Cartridge::Path::SufamiTurboB });
cartridge.nvram.append({ ".sts", slotB.ram.data(), slotB.ram.size(), Cartridge::Slot::SufamiTurboB });
} else {
slotB.rom.map(allocate<uint8>(128 * 1024, 0xff), 128 * 1024);
}

View File

@ -6,5 +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::Path path, const string &hint) { return hint; };
virtual string path(Cartridge::Slot slot, const string &hint) = 0;
};

View File

@ -1,7 +1,7 @@
namespace SNES {
namespace Info {
static const char Name[] = "bsnes";
static const char Version[] = "076.05";
static const char Version[] = "076.06";
static const unsigned SerializerVersion = 18;
}
}

View File

@ -96,9 +96,9 @@ ifeq ($(platform),x)
endif
install -D -m 644 data/bsnes.png $(DESTDIR)$(prefix)/share/pixmaps/bsnes.png
install -D -m 644 data/bsnes.desktop $(DESTDIR)$(prefix)/share/applications/bsnes.desktop
test -d ~/.bsnes || mkdir ~/.bsnes
cp data/cheats.xml ~/.bsnes/cheats.xml
chmod 777 ~/.bsnes ~/.bsnes/cheats.xml
mkdir -p ~/.config/bsnes
cp data/cheats.xml ~/.config/bsnes/cheats.xml
chmod 777 ~/.config/bsnes ~/.config/bsnes/cheats.xml
uninstall:
ifeq ($(platform),x)

View File

@ -73,7 +73,7 @@ bool Cartridge::loadSuperGameBoy(const char *basename, const char *slotname) {
SNES::cartridge.load(SNES::Cartridge::Mode::SuperGameBoy, { baseXML, "" });
foreach(memory, SNES::cartridge.nvram) loadMemory(memory);
if(GameBoy::cartridge.info.battery && fp.open(path.load(SNES::Cartridge::Path::GameBoy, ".sav"), file::mode::read)) {
if(GameBoy::cartridge.info.battery && fp.open(path.load(SNES::Cartridge::Slot::GameBoy, ".sav"), file::mode::read)) {
fp.read(GameBoy::cartridge.ramdata, min(GameBoy::cartridge.ramsize, fp.size()));
fp.close();
}
@ -89,7 +89,7 @@ void Cartridge::unload() {
foreach(memory, SNES::cartridge.nvram) saveMemory(memory);
if(SNES::cartridge.mode() == SNES::Cartridge::Mode::SuperGameBoy) {
file fp;
if(GameBoy::cartridge.info.battery && fp.open(path.load(SNES::Cartridge::Path::GameBoy, ".sav"), file::mode::write)) {
if(GameBoy::cartridge.info.battery && fp.open(path.load(SNES::Cartridge::Slot::GameBoy, ".sav"), file::mode::write)) {
fp.write(GameBoy::cartridge.ramdata, GameBoy::cartridge.ramsize);
fp.close();
}
@ -133,7 +133,7 @@ bool Cartridge::loadCartridge(SNES::MappedRAM &memory, string &XML, const char *
bool Cartridge::loadMemory(SNES::Cartridge::NonVolatileRAM &memory) {
if(memory.size == 0) return true;
string filename = path.load(memory.path, memory.id);
string filename = path.load(memory.slot, memory.id);
file fp;
if(fp.open(filename, file::mode::read) == false) return false;
fp.read(memory.data, min(memory.size, fp.size()));
@ -143,7 +143,7 @@ bool Cartridge::loadMemory(SNES::Cartridge::NonVolatileRAM &memory) {
bool Cartridge::saveMemory(SNES::Cartridge::NonVolatileRAM &memory) {
if(memory.size == 0) return true;
string filename = path.load(memory.path, memory.id);
string filename = path.load(memory.slot, memory.id);
file fp;
if(fp.open(filename, file::mode::write) == false) return false;
fp.write(memory.data, memory.size);

View File

@ -118,6 +118,9 @@ void MainWindow::create() {
settingsVideoModeAspectRatioCorrection.setText("Correct Aspect Ratio");
settingsVideoMode.append(settingsVideoModeAspectRatioCorrection);
settingsVideoModeSmoothVideo.setText("Smooth Video");
settingsVideoMode.append(settingsVideoModeSmoothVideo);
settingsVideoMode.append(settingsVideoModeSeparator2);
settingsVideoModeNTSC.setText("NTSC");
@ -126,31 +129,12 @@ void MainWindow::create() {
settingsVideoModePAL.setText("PAL");
settingsVideoMode.append(settingsVideoModePAL);
settingsVideoFilter.setText("Video Filter");
settings.append(settingsVideoFilter);
settingsVideoFilterNone.setText("None");
settingsVideoFilter.append(settingsVideoFilterNone);
settingsVideoFilter.append(settingsVideoFilterSeparator);
settingsVideoShader.setText("Video Shader");
settings.append(settingsVideoShader);
settingsVideoShaderNone.setText("None");
settingsVideoShader.append(settingsVideoShaderNone);
settingsVideoShader.append(settingsVideoShaderSeparator);
setupFiltersAndShaders();
RadioItem::group(
settingsVideoModeNTSC, settingsVideoModePAL
);
settingsSmoothVideo.setText("Smooth Video");
settings.append(settingsSmoothVideo);
settings.append(settingsSeparator1);
settingsSynchronizeVideo.setText("Synchronize Video");
@ -258,9 +242,9 @@ void MainWindow::create() {
if(config.video.scale == 4) settingsVideoMode4x.setChecked();
if(config.video.scale == 5) settingsVideoMode5x.setChecked();
settingsVideoModeAspectRatioCorrection.setChecked(config.video.aspectRatioCorrection);
settingsVideoModeSmoothVideo.setChecked(config.video.smooth);
if(config.video.region == 0) settingsVideoModeNTSC.setChecked();
if(config.video.region == 1) settingsVideoModePAL.setChecked();
settingsSmoothVideo.setChecked(config.video.smooth);
settingsSynchronizeVideo.setChecked(config.video.synchronize);
settingsSynchronizeAudio.setChecked(config.audio.synchronize);
settingsMuteAudio.setChecked(config.audio.mute);
@ -317,6 +301,11 @@ void MainWindow::create() {
utility.setScale();
};
settingsVideoModeSmoothVideo.onTick = []() {
config.video.smooth = mainWindow.settingsVideoModeSmoothVideo.checked();
video.set(Video::Filter, (unsigned)config.video.smooth);
};
settingsVideoModeNTSC.onTick = []() { config.video.region = 0; utility.setScale(); };
settingsVideoModePAL.onTick = []() { config.video.region = 1; utility.setScale(); };
@ -330,11 +319,6 @@ void MainWindow::create() {
utility.setShader();
};
settingsSmoothVideo.onTick = []() {
config.video.smooth = mainWindow.settingsSmoothVideo.checked();
video.set(Video::Filter, (unsigned)config.video.smooth);
};
settingsSynchronizeVideo.onTick = []() {
config.video.synchronize = mainWindow.settingsSynchronizeVideo.checked();
video.set(Video::Synchronize, config.video.synchronize);
@ -405,11 +389,27 @@ void MainWindow::synchronize() {
void MainWindow::setupFiltersAndShaders() {
string folderPath;
lstring files;
reference_array<RadioItem&> group;
signed active;
settingsVideoFilter.setText("Video Filter");
settingsVideoFilterNone.setText("None");
settingsVideoFilter.append(settingsVideoFilterNone);
settingsVideoFilter.append(settingsVideoFilterSeparator);
group.append(settingsVideoFilterNone);
active = -1;
folderPath = { path.base, "filters/" };
files = directory::files(folderPath, "*.filter");
if(files.size() == 0) {
#if defined(PLATFORM_X) || defined(PLATFORM_OSX)
folderPath = { path.user, ".config/bsnes/filters/" };
#else
folderPath = { path.user, "bsnes/filters/" };
#endif
files = directory::files(folderPath, "*.filter");
}
foreach(filename, files) {
@ -417,11 +417,10 @@ void MainWindow::setupFiltersAndShaders() {
}
if(settingsVideoFilterName.size() == 0) {
settingsVideoFilter.setVisible(false);
config.video.filter = ""; //as the list (and thus the 'None' option) is invisible,
utility.setFilter(); //erase any previously saved filter name
} else {
settingsVideoFilterItem = new Item[settingsVideoFilterName.size()];
settingsVideoFilterItem = new RadioItem[settingsVideoFilterName.size()];
foreach(filename, settingsVideoFilterName, n) {
settingsVideoFilterItem[n].onTick = [n]() {
config.video.filter = mainWindow.settingsVideoFilterName[n];
@ -429,13 +428,34 @@ void MainWindow::setupFiltersAndShaders() {
};
settingsVideoFilterItem[n].setText(nall::basename(notdir(filename)));
settingsVideoFilter.append(settingsVideoFilterItem[n]);
group.append(settingsVideoFilterItem[n]);
if(filename == config.video.filter) active = n;
}
RadioItem::group(group);
group.reset();
active < 0 ? settingsVideoFilterNone.setChecked() : settingsVideoFilterItem[active].setChecked();
settings.append(settingsVideoFilter);
}
settingsVideoShader.setText("Video Shader");
settingsVideoShaderNone.setText("None");
settingsVideoShader.append(settingsVideoShaderNone);
settingsVideoShader.append(settingsVideoShaderSeparator);
group.append(settingsVideoShaderNone);
active = -1;
folderPath = { path.base, "shaders/" };
files = directory::files(folderPath, { "*.", config.video.driver, ".shader" });
if(files.size() == 0) {
#if defined(PLATFORM_X) || defined(PLATFORM_OSX)
folderPath = { path.user, ".config/bsnes/shaders/" };
#else
folderPath = { path.user, "bsnes/shaders/" };
#endif
files = directory::files(folderPath, { "*.", config.video.driver, ".shader" });
}
foreach(filename, files) {
@ -443,11 +463,10 @@ void MainWindow::setupFiltersAndShaders() {
}
if(settingsVideoShaderName.size() == 0) {
settingsVideoShader.setVisible(false);
config.video.shader = "";
utility.setShader();
} else {
settingsVideoShaderItem = new Item[settingsVideoShaderName.size()];
settingsVideoShaderItem = new RadioItem[settingsVideoShaderName.size()];
foreach(filename, settingsVideoShaderName, n) {
settingsVideoShaderItem[n].onTick = [n]() {
config.video.shader = mainWindow.settingsVideoShaderName[n];
@ -455,6 +474,13 @@ void MainWindow::setupFiltersAndShaders() {
};
settingsVideoShaderItem[n].setText(nall::basename(nall::basename(notdir(filename))));
settingsVideoShader.append(settingsVideoShaderItem[n]);
group.append(settingsVideoShaderItem[n]);
if(filename == config.video.shader) active = n;
}
RadioItem::group(group);
group.reset();
active < 0 ? settingsVideoShaderNone.setChecked() : settingsVideoShaderItem[active].setChecked();
settings.append(settingsVideoShader);
}
}

View File

@ -33,23 +33,23 @@ struct MainWindow : TopLevelWindow {
RadioItem settingsVideoMode5x;
Separator settingsVideoModeSeparator1;
CheckItem settingsVideoModeAspectRatioCorrection;
CheckItem settingsVideoModeSmoothVideo;
Separator settingsVideoModeSeparator2;
RadioItem settingsVideoModeNTSC;
RadioItem settingsVideoModePAL;
Menu settingsVideoFilter;
Item settingsVideoFilterNone;
RadioItem settingsVideoFilterNone;
Separator settingsVideoFilterSeparator;
Item *settingsVideoFilterItem;
RadioItem *settingsVideoFilterItem;
lstring settingsVideoFilterName;
Menu settingsVideoShader;
Item settingsVideoShaderNone;
RadioItem settingsVideoShaderNone;
Separator settingsVideoShaderSeparator;
Item *settingsVideoShaderItem;
RadioItem *settingsVideoShaderItem;
lstring settingsVideoShaderName;
CheckItem settingsSmoothVideo;
Separator settingsSeparator1;
CheckItem settingsSynchronizeVideo;
CheckItem settingsSynchronizeAudio;

View File

@ -138,6 +138,6 @@ void Interface::message(const string &text) {
MessageWindow::information(mainWindow, text);
}
string Interface::path(SNES::Cartridge::Path path, const string &hint) {
return ::path.load(path, hint);
string Interface::path(SNES::Cartridge::Slot slot, const string &hint) {
return ::path.load(slot, hint);
}

View File

@ -21,7 +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::Path path, const string &hint);
string path(SNES::Cartridge::Slot slot, const string &hint);
};
extern Palette palette;

View File

@ -48,63 +48,69 @@ void Path::save(const string &path, const string &value) {
}
}
string Path::load(SNES::Cartridge::Path pathHint, const string &hint) {
string romPath;
switch(pathHint) {
case SNES::Cartridge::Path::Base: {
romPath = cartridge.baseName;
break;
}
case SNES::Cartridge::Path::Bsx: {
romPath = cartridge.bsxName != "" ? cartridge.bsxName : cartridge.baseName;
break;
}
case SNES::Cartridge::Path::SufamiTurbo: {
if(cartridge.sufamiTurboAName == "" && cartridge.sufamiTurboBName == "") {
romPath = cartridge.baseName;
} else if(cartridge.sufamiTurboAName != "" && cartridge.sufamiTurboBName == "") {
romPath = cartridge.sufamiTurboAName;
} else if(cartridge.sufamiTurboAName == "" && cartridge.sufamiTurboBName != "") {
romPath = cartridge.sufamiTurboBName;
} else {
romPath = { cartridge.sufamiTurboAName, "+", notdir(cartridge.sufamiTurboBName) };
}
break;
}
case SNES::Cartridge::Path::SufamiTurboA: {
romPath = cartridge.sufamiTurboAName != "" ? cartridge.sufamiTurboAName : cartridge.baseName;
break;
}
case SNES::Cartridge::Path::SufamiTurboB: {
romPath = cartridge.sufamiTurboBName != "" ? cartridge.sufamiTurboBName : cartridge.baseName;
break;
}
case SNES::Cartridge::Path::GameBoy: {
romPath = cartridge.gameBoyName != "" ? cartridge.gameBoyName : cartridge.baseName;
break;
}
string Path::load(SNES::Cartridge::Slot slot, const string &hint) {
string basePath = basepath(slot);
string baseName = notdir(basePath);
string filePath = dir(basePath);
case SNES::Cartridge::Path::NECDSP: romPath = cartridge.baseName; break;
case SNES::Cartridge::Path::MSU1: romPath = cartridge.baseName; break;
case SNES::Cartridge::Path::Serial: romPath = cartridge.baseName; break;
if(hint == ".srm" && srm != "") filePath = srm;
if(hint == ".bsp" && bsp != "") filePath = bsp;
if(hint == ".bss" && bss != "") filePath = bss;
if(hint == ".sts" && sts != "") filePath = sts;
if(hint == ".sav" && sav != "") filePath = sav;
if(hint == ".rtc" && rtc != "") filePath = rtc;
if(hint.endswith(".dsp") && necdsp != "") filePath = necdsp;
if(hint.endswith(".msu") && msu1 != "") filePath = msu1;
if(hint.endswith(".pcm") && msu1 != "") filePath = msu1;
if(hint.endswith(".so") && serial != "") filePath = serial;
if(hint.endswith(".bsa") && bsa != "") filePath = bsa;
if(hint.endswith(".bst") && bst != "") filePath = bst;
if(hint.endswith(".cht") && cht != "") filePath = cht;
if(hint.endswith(".log") && log != "") filePath = log;
filePath = decode(filePath, basePath);
return { filePath, baseName, hint };
}
string Path::basepath(SNES::Cartridge::Slot slot) {
if(slot == SNES::Cartridge::Slot::Base) {
return cartridge.baseName;
}
string path = romPath;
if(pathHint == SNES::Cartridge::Path::NECDSP && necdsp != "") path = necdsp;
if(pathHint == SNES::Cartridge::Path::MSU1 && msu1 != "") path = string(msu1, notdir(path));
if(pathHint == SNES::Cartridge::Path::Serial && serial != "") path = string(serial, notdir(path));
if(slot == SNES::Cartridge::Slot::Bsx) {
if(cartridge.bsxName == "") return cartridge.baseName;
return cartridge.bsxName;
}
if(hint == ".srm" && srm != "") path = string(srm, notdir(path));
if(hint == ".bsp" && bsp != "") path = string(bsp, notdir(path));
if(hint == ".bss" && bss != "") path = string(bss, notdir(path));
if(hint == ".sts" && sts != "") path = string(sts, notdir(path));
if(hint == ".sav" && sav != "") path = string(sav, notdir(path));
if(hint == ".rtc" && rtc != "") path = string(rtc, notdir(path));
if(slot == SNES::Cartridge::Slot::SufamiTurbo) {
if(cartridge.sufamiTurboAName == "" && cartridge.sufamiTurboBName == "") return cartridge.baseName;
if(cartridge.sufamiTurboAName != "" && cartridge.sufamiTurboBName == "") return cartridge.sufamiTurboAName;
if(cartridge.sufamiTurboAName == "" && cartridge.sufamiTurboBName != "") return cartridge.sufamiTurboBName;
return { cartridge.sufamiTurboAName, "+", notdir(cartridge.sufamiTurboBName) };
}
if(hint == ".bsa" && bsa != "") path = string(bsa, notdir(path));
if(hint.endswith(".bst") && bst != "") path = string(bst, notdir(path));
if(hint == ".cht" && cht != "") path = string(cht, notdir(path));
if(hint == ".log" && log != "") path = string(log, notdir(path));
if(slot == SNES::Cartridge::Slot::SufamiTurboA) {
if(cartridge.sufamiTurboAName == "") return cartridge.baseName;
return cartridge.sufamiTurboAName;
}
if(slot == SNES::Cartridge::Slot::SufamiTurboB) {
if(cartridge.sufamiTurboBName == "") return cartridge.baseName;
return cartridge.sufamiTurboBName;
}
if(slot == SNES::Cartridge::Slot::GameBoy) {
if(cartridge.gameBoyName == "") return cartridge.baseName;
return cartridge.gameBoyName;
}
throw "Path::basepath(): invalid slot ID.";
}
string Path::decode(const string &filePath, const string &basePath) {
string path = filePath;
if(path.beginswith("user/")) {
path.ltrim<1>("user/");
@ -118,19 +124,15 @@ string Path::load(SNES::Cartridge::Path pathHint, const string &hint) {
path = string(base, path);
} else if(path.beginswith("./")) {
path.ltrim<1>("./");
path = string(dir(romPath), path);
path = string(dir(basePath), path);
} else if(path.beginswith("../")) {
string base = dir(romPath);
string base = dir(basePath);
base.rtrim<1>("/");
path.ltrim<1>("../");
path = string(dir(base), path);
}
if(pathHint == SNES::Cartridge::Path::NECDSP) return { dir(path), hint };
if(pathHint == SNES::Cartridge::Path::MSU1) return { path, hint };
if(pathHint == SNES::Cartridge::Path::Serial) return { path, hint };
return { path, hint };
return path;
}
void Path::load() {

View File

@ -30,7 +30,10 @@ struct Path : public configuration {
string home(const string &filename);
string load(const string &path);
void save(const string &path, const string &value);
string load(SNES::Cartridge::Path path, const string &hint);
string load(SNES::Cartridge::Slot slot, const string &hint);
string basepath(SNES::Cartridge::Slot slot);
string decode(const string &filePath, const string &basePath);
void load();
void save();

View File

@ -167,12 +167,12 @@ void Utility::cartridgeUnloaded() {
mainWindow.synchronize();
}
SNES::Cartridge::Path Utility::slotPath() {
SNES::Cartridge::Path path = SNES::Cartridge::Path::Base;
if(SNES::cartridge.mode() == SNES::Cartridge::Mode::Bsx) path = SNES::Cartridge::Path::Bsx;
if(SNES::cartridge.mode() == SNES::Cartridge::Mode::SufamiTurbo) path = SNES::Cartridge::Path::SufamiTurbo;
if(SNES::cartridge.mode() == SNES::Cartridge::Mode::SuperGameBoy) path = SNES::Cartridge::Path::GameBoy;
return path;
SNES::Cartridge::Slot Utility::slotPath() {
SNES::Cartridge::Slot slot = SNES::Cartridge::Slot::Base;
if(SNES::cartridge.mode() == SNES::Cartridge::Mode::Bsx) slot = SNES::Cartridge::Slot::Bsx;
if(SNES::cartridge.mode() == SNES::Cartridge::Mode::SufamiTurbo) slot = SNES::Cartridge::Slot::SufamiTurbo;
if(SNES::cartridge.mode() == SNES::Cartridge::Mode::SuperGameBoy) slot = SNES::Cartridge::Slot::GameBoy;
return slot;
}
void Utility::saveState(unsigned slot) {

View File

@ -15,7 +15,7 @@ struct Utility : property<Utility> {
void cartridgeLoaded();
void cartridgeUnloaded();
SNES::Cartridge::Path slotPath();
SNES::Cartridge::Slot slotPath();
void saveState(unsigned slot);
void loadState(unsigned slot);