mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-10-04 17:31:50 +02:00
Update to v091r13 release, and ananke v00r01.
byuu says (about higan): - dropped release/ root node for individual games (still there in ananke's database.) - Memory export uses smarter names (vram.rwm -> video.ram, etc.) - cheat database moved from XML to BML (3.1MB to 1.9MB file size.) - cheat codes moved from XML to BML - resource manifest moved from XML to BML What can I say, I like consistency. But I'll leave the shaders alone until I get around to shader folders. byuu says (about ananke): Works with higan v091r13. Only does SNES stuff so far.
This commit is contained in:
@@ -1,79 +1,63 @@
|
||||
#include <nall/nall.hpp>
|
||||
#include <nall/beat/patch.hpp>
|
||||
#include <nall/emulation/super-famicom.hpp>
|
||||
using namespace nall;
|
||||
|
||||
#include <phoenix/phoenix.hpp>
|
||||
using namespace phoenix;
|
||||
|
||||
struct Ananke {
|
||||
struct Configuration : configuration {
|
||||
string path;
|
||||
#include "configuration.cpp"
|
||||
|
||||
Configuration() {
|
||||
append(path = userpath(), "Path");
|
||||
directory::create({configpath(), "ananke/"});
|
||||
load({configpath(), "ananke/settings.cfg"});
|
||||
}
|
||||
struct Information {
|
||||
string path; //path to selected file
|
||||
string name; //name of selected file (inside of archive if .zip)
|
||||
string archive; //pathname of archive
|
||||
string manifest; //manifest from successfully applied patch
|
||||
} information;
|
||||
|
||||
~Configuration() {
|
||||
save({configpath(), "ananke/settings.cfg"});
|
||||
}
|
||||
} config;
|
||||
//archive.cpp
|
||||
vector<uint8_t> extractROM();
|
||||
vector<uint8_t> extractFile(const string &filename);
|
||||
|
||||
string createSuperFamicomDatabase(const string &filename, Markup::Node &document, const string &manifest) {
|
||||
string pathname = {
|
||||
userpath(), "Emulation/Super Famicom/",
|
||||
document["release/information/name"].text(),
|
||||
" (", document["release/information/region"].text(), ")",
|
||||
" (", document["release/information/revision"].text(), ")",
|
||||
".sfc/"
|
||||
};
|
||||
directory::create(pathname);
|
||||
//patch.cpp
|
||||
void applyBeatPatch(vector<uint8_t> &buffer);
|
||||
|
||||
file::write({pathname, "manifest.bml"}, (const uint8_t*)(const char*)manifest, manifest.length());
|
||||
auto buffer = file::read(filename);
|
||||
unsigned offset = 0;
|
||||
|
||||
for(auto &node : document["release/information/configuration"]) {
|
||||
if(node.name != "rom") continue;
|
||||
string name = node["name"].text();
|
||||
unsigned size = node["size"].decimal();
|
||||
if(file::exists({pathname, name}) == false) {
|
||||
file::write({pathname, name}, buffer.data() + offset, size);
|
||||
}
|
||||
offset += size;
|
||||
}
|
||||
|
||||
return pathname;
|
||||
}
|
||||
|
||||
string openSuperFamicom(const string &filename) {
|
||||
string sha256 = file::sha256(filename);
|
||||
|
||||
string databaseText = string::read({configpath(), "ananke/database/Super Famicom.bml"}).rtrim("\n");
|
||||
lstring databaseItem = databaseText.split("\n\n");
|
||||
|
||||
for(auto &item : databaseItem) {
|
||||
item.append("\n");
|
||||
auto document = Markup::Document(item);
|
||||
|
||||
if(document["release/information/sha256"].text() == sha256) {
|
||||
return createSuperFamicomDatabase(filename, document, item);
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
//super-famicom.cpp
|
||||
string createSuperFamicomDatabase(vector<uint8_t> &buffer, Markup::Node &document, const string &manifest);
|
||||
string createSuperFamicomHeuristic(vector<uint8_t> &buffer);
|
||||
string openSuperFamicom(vector<uint8_t> &buffer);
|
||||
|
||||
string open(string filename = "") {
|
||||
if(filename.empty()) filename = DialogWindow::fileOpen(Window::none(), config.path);
|
||||
if(filename.empty()) return "";
|
||||
config.path = dir(filename);
|
||||
|
||||
if(filename.endswith(".sfc")) return openSuperFamicom(filename);
|
||||
information.path = dir(filename);
|
||||
information.name = notdir(filename);
|
||||
config.path = information.path; //remember last used directory
|
||||
|
||||
vector<uint8_t> buffer;
|
||||
if(filename.endswith(".zip")) {
|
||||
information.archive = filename;
|
||||
buffer = extractROM();
|
||||
} else {
|
||||
buffer = file::read(filename);
|
||||
}
|
||||
if(buffer.size() == 0) return ""; //failed to read file
|
||||
|
||||
applyBeatPatch(buffer);
|
||||
|
||||
if(information.name.endswith(".sfc")) return openSuperFamicom(buffer);
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
#include "archive.cpp"
|
||||
#include "patch.cpp"
|
||||
#include "super-famicom.cpp"
|
||||
|
||||
extern "C" string ananke_browse(const string &filename) {
|
||||
Ananke ananke;
|
||||
return ananke.open();
|
||||
|
Reference in New Issue
Block a user