mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-02-24 07:02:27 +01:00
byuu says: Changelog: - moved Thread, Scheduler, Cheat functionality into emulator/ for all cores - start of actual Mega Drive emulation (two 68K instructions) I'm going to be rather terse on MD emulation, as it's too early for any meaningful dialogue here.
81 lines
1.8 KiB
C++
81 lines
1.8 KiB
C++
#include <md/md.hpp>
|
|
|
|
namespace MegaDrive {
|
|
|
|
Cartridge cartridge;
|
|
|
|
auto Cartridge::load() -> bool {
|
|
information = Information();
|
|
|
|
if(auto pathID = interface->load(ID::MegaDrive, "Mega Drive", "md")) {
|
|
information.pathID = pathID();
|
|
} else return false;
|
|
|
|
if(auto fp = interface->open(pathID(), "manifest.bml", File::Read, File::Required)) {
|
|
information.manifest = fp->reads();
|
|
} else return false;
|
|
|
|
auto document = BML::unserialize(information.manifest);
|
|
information.title = document["information/title"].text();
|
|
|
|
if(auto node = document["board/rom"]) {
|
|
rom.size = node["size"].natural();
|
|
rom.mask = bit::round(rom.size) - 1;
|
|
if(rom.size) {
|
|
rom.data = new uint8[rom.mask + 1];
|
|
if(auto name = node["name"].text()) {
|
|
if(auto fp = interface->open(pathID(), name, File::Read, File::Required)) {
|
|
fp->read(rom.data, rom.size);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if(auto node = document["board/ram"]) {
|
|
ram.size = node["size"].natural();
|
|
ram.mask = bit::round(ram.size) - 1;
|
|
if(ram.size) {
|
|
ram.data = new uint8[ram.mask + 1];
|
|
if(auto name = node["name"].text()) {
|
|
if(auto fp = interface->open(pathID(), name, File::Read)) {
|
|
fp->read(ram.data, ram.size);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
auto Cartridge::save() -> void {
|
|
auto document = BML::unserialize(information.manifest);
|
|
|
|
if(auto name = document["board/ram/name"].text()) {
|
|
if(auto fp = interface->open(pathID(), name, File::Write)) {
|
|
fp->write(ram.data, ram.size);
|
|
}
|
|
}
|
|
}
|
|
|
|
auto Cartridge::unload() -> void {
|
|
delete[] rom.data;
|
|
delete[] ram.data;
|
|
rom = Memory();
|
|
ram = Memory();
|
|
}
|
|
|
|
auto Cartridge::power() -> void {
|
|
}
|
|
|
|
auto Cartridge::reset() -> void {
|
|
}
|
|
|
|
auto Cartridge::read(uint24 addr) -> uint8 {
|
|
return rom.data[addr & rom.mask];
|
|
}
|
|
|
|
auto Cartridge::write(uint24 addr, uint8 data) -> void {
|
|
}
|
|
|
|
}
|