mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-02-24 07:02:27 +01:00
byuu says: This will easily be the biggest diff in the history of higan. And not in a good way. * target-higan and target-loki have been blown away completely * nall and ruby massively updated * phoenix replaced with hiro (pretty near a total rewrite) * target-higan restarted using hiro (just a window for now) * all emulation cores updated to compile again * installation changed to not require root privileges (installs locally) For the foreseeable future (maybe even permanently?), the new higan UI will only build under Linux/BSD with GTK+ 2.20+. Probably the most likely route for Windows/OS X will be to try and figure out how to build hiro/GTK on those platforms, as awful as that would be. The other alternative would be to produce new UIs for those platforms ... which would actually be a good opportunity to make something much more user friendly. Being that I just started on this a few hours ago, that means that for at least a few weeks, don't expect to be able to actually play any games. Right now, you can pretty much just compile the binary and that's it. It's quite possible that some nall changes didn't produce compilation errors, but will produce runtime errors. So until the UI can actually load games, we won't know if anything is broken. But we should mostly be okay. It was mostly just trim<1> -> trim changes, moving to Hash::SHA256 (much cleaner), and patching some reckless memory copy functions enough to compile. Progress isn't going to be like it was before: I'm now dividing my time much thinner between studying and other hobbies. My aim this time is not to produce a binary for everyone to play games on. Rather, it's to keep the emulator alive. I want to be able to apply critical patches again. And I would also like the base of the emulator to live on, for use in other emulator frontends that utilize higan.
216 lines
6.6 KiB
C++
216 lines
6.6 KiB
C++
#include <sfc/sfc.hpp>
|
|
|
|
#define CARTRIDGE_CPP
|
|
namespace SuperFamicom {
|
|
|
|
#include "markup.cpp"
|
|
#include "serialization.cpp"
|
|
Cartridge cartridge;
|
|
|
|
string Cartridge::title() {
|
|
if(information.title.gameBoy.empty() == false) {
|
|
return {information.title.cartridge, " + ", information.title.gameBoy};
|
|
}
|
|
|
|
if(information.title.satellaview.empty() == false) {
|
|
return {information.title.cartridge, " + ", information.title.satellaview};
|
|
}
|
|
|
|
if(information.title.sufamiTurboA.empty() == false) {
|
|
if(information.title.sufamiTurboB.empty() == true) {
|
|
return {information.title.cartridge, " + ", information.title.sufamiTurboA};
|
|
} else {
|
|
return {information.title.cartridge, " + ", information.title.sufamiTurboA, " + ", information.title.sufamiTurboB};
|
|
}
|
|
}
|
|
|
|
return information.title.cartridge;
|
|
}
|
|
|
|
void Cartridge::load() {
|
|
region = Region::NTSC;
|
|
|
|
has_gb_slot = false;
|
|
has_bs_cart = false;
|
|
has_bs_slot = false;
|
|
has_st_slots = false;
|
|
has_nss_dip = false;
|
|
has_event = false;
|
|
has_sa1 = false;
|
|
has_superfx = false;
|
|
has_armdsp = false;
|
|
has_hitachidsp = false;
|
|
has_necdsp = false;
|
|
has_epsonrtc = false;
|
|
has_sharprtc = false;
|
|
has_spc7110 = false;
|
|
has_sdd1 = false;
|
|
has_obc1 = false;
|
|
has_hsu1 = false;
|
|
has_msu1 = false;
|
|
|
|
information.markup.cartridge = "";
|
|
information.markup.gameBoy = "";
|
|
information.markup.satellaview = "";
|
|
information.markup.sufamiTurboA = "";
|
|
information.markup.sufamiTurboB = "";
|
|
|
|
information.title.cartridge = "";
|
|
information.title.gameBoy = "";
|
|
information.title.satellaview = "";
|
|
information.title.sufamiTurboA = "";
|
|
information.title.sufamiTurboB = "";
|
|
|
|
interface->loadRequest(ID::Manifest, "manifest.bml");
|
|
parse_markup(information.markup.cartridge);
|
|
|
|
//Super Game Boy
|
|
if(cartridge.has_gb_slot()) {
|
|
sha256 = Hash::SHA256(GameBoy::cartridge.romdata, GameBoy::cartridge.romsize).digest();
|
|
}
|
|
|
|
//Broadcast Satellaview
|
|
else if(cartridge.has_bs_cart() && cartridge.has_bs_slot()) {
|
|
sha256 = Hash::SHA256(satellaviewcartridge.memory.data(), satellaviewcartridge.memory.size()).digest();
|
|
}
|
|
|
|
//Sufami Turbo
|
|
else if(cartridge.has_st_slots()) {
|
|
Hash::SHA256 sha;
|
|
sha.data(sufamiturboA.rom.data(), sufamiturboA.rom.size());
|
|
sha.data(sufamiturboB.rom.data(), sufamiturboB.rom.size());
|
|
sha256 = sha.digest();
|
|
}
|
|
|
|
//Super Famicom
|
|
else {
|
|
Hash::SHA256 sha;
|
|
//hash each ROM image that exists; any with size() == 0 is ignored by sha256_chunk()
|
|
sha.data(rom.data(), rom.size());
|
|
sha.data(bsxcartridge.rom.data(), bsxcartridge.rom.size());
|
|
sha.data(sa1.rom.data(), sa1.rom.size());
|
|
sha.data(superfx.rom.data(), superfx.rom.size());
|
|
sha.data(hitachidsp.rom.data(), hitachidsp.rom.size());
|
|
sha.data(spc7110.prom.data(), spc7110.prom.size());
|
|
sha.data(spc7110.drom.data(), spc7110.drom.size());
|
|
sha.data(sdd1.rom.data(), sdd1.rom.size());
|
|
//hash all firmware that exists
|
|
vector<uint8> buffer;
|
|
buffer = armdsp.firmware();
|
|
sha.data(buffer.data(), buffer.size());
|
|
buffer = hitachidsp.firmware();
|
|
sha.data(buffer.data(), buffer.size());
|
|
buffer = necdsp.firmware();
|
|
sha.data(buffer.data(), buffer.size());
|
|
//finalize hash
|
|
sha256 = sha.digest();
|
|
}
|
|
|
|
rom.write_protect(true);
|
|
ram.write_protect(false);
|
|
|
|
system.load();
|
|
loaded = true;
|
|
}
|
|
|
|
void Cartridge::load_super_game_boy() {
|
|
interface->loadRequest(ID::SuperGameBoyManifest, "manifest.bml");
|
|
auto document = Markup::Document(information.markup.gameBoy);
|
|
information.title.gameBoy = document["information/title"].text();
|
|
|
|
auto rom = document["cartridge/rom"];
|
|
auto ram = document["cartridge/ram"];
|
|
|
|
GameBoy::cartridge.information.markup = information.markup.gameBoy;
|
|
GameBoy::cartridge.load(GameBoy::System::Revision::SuperGameBoy);
|
|
|
|
if(rom["name"].exists()) interface->loadRequest(ID::SuperGameBoyROM, rom["name"].data);
|
|
if(ram["name"].exists()) interface->loadRequest(ID::SuperGameBoyRAM, ram["name"].data);
|
|
if(ram["name"].exists()) memory.append({ID::SuperGameBoyRAM, ram["name"].data});
|
|
}
|
|
|
|
void Cartridge::load_satellaview() {
|
|
interface->loadRequest(ID::SatellaviewManifest, "manifest.bml");
|
|
auto document = Markup::Document(information.markup.satellaview);
|
|
information.title.satellaview = document["information/title"].text();
|
|
|
|
auto rom = document["cartridge/rom"];
|
|
|
|
if(rom["name"].exists()) {
|
|
unsigned size = numeral(rom["size"].data);
|
|
satellaviewcartridge.memory.map(allocate<uint8>(size, 0xff), size);
|
|
interface->loadRequest(ID::SatellaviewROM, rom["name"].data);
|
|
|
|
satellaviewcartridge.readonly = (rom["type"].text() == "MaskROM");
|
|
}
|
|
}
|
|
|
|
void Cartridge::load_sufami_turbo_a() {
|
|
interface->loadRequest(ID::SufamiTurboSlotAManifest, "manifest.bml");
|
|
auto document = Markup::Document(information.markup.sufamiTurboA);
|
|
information.title.sufamiTurboA = document["information/title"].text();
|
|
|
|
auto rom = document["cartridge/rom"];
|
|
auto ram = document["cartridge/ram"];
|
|
|
|
if(rom["name"].exists()) {
|
|
unsigned size = numeral(rom["size"].data);
|
|
sufamiturboA.rom.map(allocate<uint8>(size, 0xff), size);
|
|
interface->loadRequest(ID::SufamiTurboSlotAROM, rom["name"].data);
|
|
}
|
|
|
|
if(ram["name"].exists()) {
|
|
unsigned size = numeral(ram["size"].data);
|
|
sufamiturboA.ram.map(allocate<uint8>(size, 0xff), size);
|
|
interface->loadRequest(ID::SufamiTurboSlotARAM, ram["name"].data);
|
|
memory.append({ID::SufamiTurboSlotARAM, ram["name"].data});
|
|
}
|
|
|
|
if(document["cartridge/linkable"].exists()) {
|
|
interface->loadRequest(ID::SufamiTurboSlotB, "Sufami Turbo - Slot B", "st");
|
|
}
|
|
}
|
|
|
|
void Cartridge::load_sufami_turbo_b() {
|
|
interface->loadRequest(ID::SufamiTurboSlotBManifest, "manifest.bml");
|
|
auto document = Markup::Document(information.markup.sufamiTurboB);
|
|
information.title.sufamiTurboB = document["information/title"].text();
|
|
|
|
auto rom = document["cartridge/rom"];
|
|
auto ram = document["cartridge/ram"];
|
|
|
|
if(rom["name"].exists()) {
|
|
unsigned size = numeral(rom["size"].data);
|
|
sufamiturboB.rom.map(allocate<uint8>(size, 0xff), size);
|
|
interface->loadRequest(ID::SufamiTurboSlotBROM, rom["name"].data);
|
|
}
|
|
|
|
if(ram["name"].exists()) {
|
|
unsigned size = numeral(ram["size"].data);
|
|
sufamiturboB.ram.map(allocate<uint8>(size, 0xff), size);
|
|
interface->loadRequest(ID::SufamiTurboSlotBRAM, ram["name"].data);
|
|
memory.append({ID::SufamiTurboSlotBRAM, ram["name"].data});
|
|
}
|
|
}
|
|
|
|
void Cartridge::unload() {
|
|
if(loaded == false) return;
|
|
|
|
system.unload();
|
|
rom.reset();
|
|
ram.reset();
|
|
|
|
loaded = false;
|
|
memory.reset();
|
|
}
|
|
|
|
Cartridge::Cartridge() {
|
|
loaded = false;
|
|
}
|
|
|
|
Cartridge::~Cartridge() {
|
|
unload();
|
|
}
|
|
|
|
}
|