mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-02-06 22:20:35 +01:00
byuu says: This should be basically final now. Works with all media types (nes, sfc, gb, gbc, gba, bs, st), strips headers, can use internal or external firmware, imports saves on first run. Added a custom file dialog. It seems both GTK+ and Windows XP have (un)intelligent file sorting, which puts eg "ActRaiser 2 (NA)" before "ActRaiser (NA)". So, screw 'em.
32 lines
1.1 KiB
C++
32 lines
1.1 KiB
C++
void Ananke::copyFamicomSaves(const string &pathname) {
|
|
if(!file::exists({pathname, "save.ram"})) {
|
|
if(file::exists({information.path, nall::basename(information.name), ".sav"})) {
|
|
file::copy({information.path, nall::basename(information.name), ".srm"}, {pathname, "save.ram"});
|
|
}
|
|
}
|
|
}
|
|
|
|
string Ananke::createFamicomHeuristic(vector<uint8_t> &buffer) {
|
|
string pathname = {
|
|
userpath(), "Emulation/Famicom/",
|
|
nall::basename(information.name),
|
|
" (!).fc/"
|
|
};
|
|
directory::create(pathname);
|
|
|
|
FamicomCartridge info(buffer.data(), buffer.size());
|
|
string markup = info.markup();
|
|
if(!information.manifest.empty()) markup = information.manifest; //override with embedded beat manifest, if one exists
|
|
|
|
file::write({pathname, "manifest.bml"}, markup);
|
|
file::write({pathname, "program.rom"}, buffer.data() + 16, info.prgrom);
|
|
if(info.chrrom > 0) file::write({pathname, "character.rom"}, buffer.data() + 16 + info.prgrom, info.chrrom);
|
|
|
|
copyFamicomSaves(pathname);
|
|
return pathname;
|
|
}
|
|
|
|
string Ananke::openFamicom(vector<uint8_t> &buffer) {
|
|
return createFamicomHeuristic(buffer);
|
|
}
|