Commit a9571ff5 authored by Talarubi's avatar Talarubi

Fixed: Restore SPC7110 and S-RTC time properly

Loading and unloading the RTC is a little odd, since it's normally
always powered in the first place. What we want, and what the load()
functions really do, is to resync using the saved timestamps or
reset it. unload() proper doesn't do anything.

However, an interface refactoring after v098 reordered the above
operations, and this (along with a typo, shh!) was causing the already
synced time to be cleared.

I've added checks so that whenever rtc.ram can't be found, load() gets
called with empty arguments to initialise the defaults (like putting
in a fresh battery).
parent 3d21e9af
......@@ -261,9 +261,12 @@ auto Cartridge::loadEpsonRTC(Markup::Node node) -> void {
if(auto fp = platform->open(ID::SuperFamicom, node["ram"]["name"].text(), File::Read)) {
uint8 data[16] = {0};
for(auto& byte : data) fp->read();
for(auto& byte : data) byte = fp->read();
epsonrtc.load(data);
}
else {
epsonrtc.load();
}
for(auto leaf : node.find("map")) loadMap(leaf, {&EpsonRTC::read, &epsonrtc}, {&EpsonRTC::write, &epsonrtc});
}
......@@ -273,9 +276,12 @@ auto Cartridge::loadSharpRTC(Markup::Node node) -> void {
if(auto fp = platform->open(ID::SuperFamicom, node["ram"]["name"].text(), File::Read)) {
uint8 data[16] = {0};
for(auto& byte : data) fp->read();
for(auto& byte : data) byte = fp->read();
sharprtc.load(data);
}
else {
sharprtc.load();
}
for(auto leaf : node.find("map")) loadMap(leaf, {&SharpRTC::read, &sharprtc}, {&SharpRTC::write, &sharprtc});
}
......
......@@ -22,8 +22,6 @@ auto SharpRTC::init() -> void {
}
auto SharpRTC::load() -> void {
return;
second = 0;
minute = 0;
hour = 0;
......
......@@ -80,8 +80,6 @@ auto System::load(Emulator::Interface* interface) -> bool {
if(cartridge.has.ARMDSP) armdsp.load();
if(cartridge.has.HitachiDSP) hitachidsp.load();
if(cartridge.has.NECDSP) necdsp.load();
if(cartridge.has.EpsonRTC) epsonrtc.load();
if(cartridge.has.SharpRTC) sharprtc.load();
if(cartridge.has.SPC7110) spc7110.load();
if(cartridge.has.SDD1) sdd1.load();
if(cartridge.has.OBC1) obc1.load();
......@@ -118,8 +116,6 @@ auto System::unload() -> void {
if(cartridge.has.ARMDSP) armdsp.unload();
if(cartridge.has.HitachiDSP) hitachidsp.unload();
if(cartridge.has.NECDSP) necdsp.unload();
if(cartridge.has.EpsonRTC) epsonrtc.unload();
if(cartridge.has.SharpRTC) sharprtc.unload();
if(cartridge.has.SPC7110) spc7110.unload();
if(cartridge.has.SDD1) sdd1.unload();
if(cartridge.has.OBC1) obc1.unload();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment