bsnes/icarus/core/core.cpp

75 lines
2.5 KiB
C++
Raw Normal View History

Icarus::Icarus() {
Update to higan and icarus v095r15 release. r13 and r14 weren't posted as individual releases, but their changelogs were posted. byuu says about r13: I'm not going to be posting WIPs for r13 and above for a while. The reason is that I'm working on the major manifest overhaul I've discussed previously on the icarus subforum. I'm recreating my boards database from scratch using the map files and the new map analyzer. The only games that will load are ones I've created board definitions for, and updated sfc/cartridge/markup.cpp to parse. Once I've finished all the boards, then I'll update the heuristics. Then finally, I'll sync the syntax changes over to the fc, gb, gba cores. Once that's done, I'll start posting WIPs again, along with a new build of icarus. But I'll still post changelogs as I work through things. Changelog (r13): - preservation: created new database-builder tool (merges region-specific databases with boards) - icarus: support new, external database format (~/.config/icarus/Database/(Super Famicom.bml, ...) - added 1A3B-(10,11,12); 1A3B-20 byuu says about r14: r14 work: I successfully created mappings for every board used in the US set. I also updated icarus' heuristics to use the new mappings, and created ones there for the boards that are only in the JP set. Then I patched icarus to support pulling games out of the database when it's used on a game folder to generate a manifest file. Then I updated a lot of code in higan/sfc to support the new mapping syntax. sfc/cartridge/markup.cpp is about half the size it used to be with the new mappings, and I was able to kill off both map/id and map/select entirely. Then I updated all four emulated systems (and both subsystems) to use "board" as the root node, and harmonized their syntax (made them all more consistent with each other.) Then I added a manifest viewer to the tools window+menu. It's kind of an advanced user feature, but oh well. No reason to coddle people when the feature is very useful for developers. The viewer will show all manifests in order when you load multi-cart games as well. Still not going to call any syntax 100% done right now, but thankfully with the new manifest-free folders, nobody will have to do anything to use the new format. Just download the new version and go. The Super Famicom Event stuff is currently broken (CC92/PF94 boards). That's gonna be fun to support. byuu says about r15: EDIT: small bug in icarus with heuristics. Edit core/super-famicom.cpp line 27: if(/*auto*/ markup = cartridge.markup) { Gotta remove that "auto" so that it returns valid markup. Resolved the final concerns I had with the new manifest format. Right now there are two things that are definitely broken: MCC (BS-X Town cart) and Event (CC '92 and PF'94). And there are a few things that are untested: SPC7110, EpsonRTC, SharpRTC, SDD1+RAM, SufamiTurbo, BS-X slotted carts.
2015-12-19 08:52:34 +00:00
database.superFamicom = BML::unserialize(string::read(locate({configpath(), "icarus/"}, "Database/Super Famicom.bml")));
}
2015-08-21 11:29:53 +00:00
auto Icarus::error() const -> string {
return errorMessage;
}
auto Icarus::success() -> bool {
errorMessage = "";
return true;
}
auto Icarus::failure(const string& message) -> bool {
errorMessage = message;
return false;
}
auto Icarus::manifest(string location) -> string {
location.transform("\\", "/").rtrim("/").append("/");
if(!directory::exists(location)) return "";
auto type = suffixname(location).downcase();
2015-08-21 11:29:53 +00:00
if(type == ".fc") return famicomManifest(location);
if(type == ".sfc") return superFamicomManifest(location);
if(type == ".gb") return gameBoyManifest(location);
if(type == ".gbc") return gameBoyColorManifest(location);
if(type == ".gba") return gameBoyAdvanceManifest(location);
if(type == ".bs") return bsxSatellaviewManifest(location);
if(type == ".st") return sufamiTurboManifest(location);
return "";
}
auto Icarus::import(string location) -> bool {
location.transform("\\", "/").rtrim("/");
if(!file::exists(location)) return failure("file does not exist");
if(!file::readable(location)) return failure("file is unreadable");
auto name = prefixname(location);
auto type = suffixname(location).downcase();
2015-08-21 11:29:53 +00:00
if(!name || !type) return failure("invalid file name");
auto buffer = file::read(location);
if(!buffer) return failure("file is empty");
if(type == ".zip") {
Decode::ZIP zip;
if(!zip.open(location)) return failure("ZIP archive is invalid");
if(!zip.file) return failure("ZIP archive is empty");
name = prefixname(zip.file[0].name);
type = suffixname(zip.file[0].name).downcase();
2015-08-21 11:29:53 +00:00
buffer = zip.extract(zip.file[0]);
}
if(type == ".fc" || type == ".nes") return famicomImport(buffer, location);
if(type == ".sfc" || type == ".smc") return superFamicomImport(buffer, location);
if(type == ".gb") return gameBoyImport(buffer, location);
if(type == ".gbc") return gameBoyColorImport(buffer, location);
if(type == ".gba") return gameBoyAdvanceImport(buffer, location);
if(type == ".bs") return bsxSatellaviewImport(buffer, location);
if(type == ".st") return sufamiTurboImport(buffer, location);
return failure("unrecognized file extension");
}
auto Icarus::concatenate(vector<uint8_t>& output, const string& location) -> void {
if(auto input = file::read(location)) {
auto size = output.size();
output.resize(size + input.size());
memory::copy(output.data() + size, input.data(), input.size());
}
}