bsnes/higan/sfc/coprocessor/sharprtc/memory.cpp

68 lines
2.0 KiB
C++
Raw Normal View History

Update to v098r06 release. byuu says: Changelog: - emulation cores now refresh video from host thread instead of cothreads (fix AMD crash) - SFC: fixed another bug with leap year months in SharpRTC emulation - SFC: cleaned up camelCase on function names for armdsp,epsonrtc,hitachidsp,mcc,nss,sharprtc classes - GB: added MBC1M emulation (requires manually setting mapper=MBC1M in manifest.bml for now, sorry) - audio: implemented Emulator::Audio mixer and effects processor - audio: implemented Emulator::Stream interface - it is now possible to have more than two audio streams: eg SNES + SGB + MSU1 + Voicer-Kun (eventually) - audio: added reverb delay + reverb level settings; exposed balance configuration in UI - video: reworked palette generation to re-enable saturation, gamma, luminance adjustments - higan/emulator.cpp is gone since there was nothing left in it I know you guys are going to say the color adjust/balance/reverb stuff is pointless. And indeed it mostly is. But I like the idea of allowing some fun special effects and configurability that isn't system-wide. Note: there seems to be some kind of added audio lag in the SGB emulation now, and I don't really understand why. The code should be effectively identical to what I had before. The only main thing is that I'm sampling things to 48000hz instead of 32040hz before mixing. There's no point where I'm intentionally introducing added latency though. I'm kind of stumped, so if anyone wouldn't mind taking a look at it, it'd be much appreciated :/ I don't have an MSU1 test ROM, but the latency issue may affect MSU1 as well, and that would be very bad.
2016-04-22 13:35:51 +00:00
auto SharpRTC::rtcRead(uint4 addr) -> uint4 {
switch(addr) {
case 0: return second % 10;
case 1: return second / 10;
case 2: return minute % 10;
case 3: return minute / 10;
case 4: return hour % 10;
case 5: return hour / 10;
case 6: return day % 10;
case 7: return day / 10;
case 8: return month;
case 9: return year % 10;
case 10: return year / 10 % 10;
case 11: return year / 100;
case 12: return weekday;
Update to v089r06 release. [Yes, the release number is re-used. -Ed.] byuu says: I had some bugs in r07 that I couldn't track down, DKJM2's clock was getting all out of sync. So I just reverted to r05, blew away both RTCs entirely, and wrote them cleanly from scratch (obviously looking off the old code.) A bit extreme, but it worked. I believe I found the error in the process, day and month were resetting the counter to 0 instead of 1, it wasn't handling leap year, etc. While I was at it, I fixed the day-of-week calculation. The SharpRTC epoch is actually 1000-01-01, and not 1900-01-01. I'm sure you guys will be really happy that if it ever becomes 1000AD again and you're playing a ROM hack that uses the SharpRTC and relies on its weekday value that it will show the correct day now ... Kind of a pain to compute, but nothing compared to the seventh circle of hell that was my IBM dBase III Julian<>Gregorian conversion functions :/ Also found a few bugs in the Epson code this way. And I moved the round seconds actions and flag clear to +125us after flag set. So, if you had the old r06 or r07, please delete those. Unfortunately, this took all of my energy today, so the file names inside manifest changes will have to be in the next WIP. EDIT: ran a diff against old r07 and new r06. - added if(days == 31) case twice in EpsonRTC::tick_day() - forgot weekday = 0; in SharpRTC::load() - need to move the cartridge+cheat objects up in sfc/Makefile again - System::init() needs assert(interface != nullptr /* not 0 */)
2012-05-24 23:26:06 +00:00
default: return 0;
}
}
Update to v098r06 release. byuu says: Changelog: - emulation cores now refresh video from host thread instead of cothreads (fix AMD crash) - SFC: fixed another bug with leap year months in SharpRTC emulation - SFC: cleaned up camelCase on function names for armdsp,epsonrtc,hitachidsp,mcc,nss,sharprtc classes - GB: added MBC1M emulation (requires manually setting mapper=MBC1M in manifest.bml for now, sorry) - audio: implemented Emulator::Audio mixer and effects processor - audio: implemented Emulator::Stream interface - it is now possible to have more than two audio streams: eg SNES + SGB + MSU1 + Voicer-Kun (eventually) - audio: added reverb delay + reverb level settings; exposed balance configuration in UI - video: reworked palette generation to re-enable saturation, gamma, luminance adjustments - higan/emulator.cpp is gone since there was nothing left in it I know you guys are going to say the color adjust/balance/reverb stuff is pointless. And indeed it mostly is. But I like the idea of allowing some fun special effects and configurability that isn't system-wide. Note: there seems to be some kind of added audio lag in the SGB emulation now, and I don't really understand why. The code should be effectively identical to what I had before. The only main thing is that I'm sampling things to 48000hz instead of 32040hz before mixing. There's no point where I'm intentionally introducing added latency though. I'm kind of stumped, so if anyone wouldn't mind taking a look at it, it'd be much appreciated :/ I don't have an MSU1 test ROM, but the latency issue may affect MSU1 as well, and that would be very bad.
2016-04-22 13:35:51 +00:00
auto SharpRTC::rtcWrite(uint4 addr, uint4 data) -> void {
switch(addr) {
case 0: second = second / 10 * 10 + data; break;
case 1: second = data * 10 + second % 10; break;
case 2: minute = minute / 10 * 10 + data; break;
case 3: minute = data * 10 + minute % 10; break;
case 4: hour = hour / 10 * 10 + data; break;
case 5: hour = data * 10 + hour % 10; break;
case 6: day = day / 10 * 10 + data; break;
case 7: day = data * 10 + day % 10; break;
case 8: month = data; break;
case 9: year = year / 10 * 10 + data; break;
case 10: year = year / 100 * 100 + data * 10 + year % 10; break;
case 11: year = data * 100 + year % 100; break;
case 12: weekday = data; break;
}
}
auto SharpRTC::load(const uint8* data) -> void {
for(auto byte : range(8)) {
Update to v098r06 release. byuu says: Changelog: - emulation cores now refresh video from host thread instead of cothreads (fix AMD crash) - SFC: fixed another bug with leap year months in SharpRTC emulation - SFC: cleaned up camelCase on function names for armdsp,epsonrtc,hitachidsp,mcc,nss,sharprtc classes - GB: added MBC1M emulation (requires manually setting mapper=MBC1M in manifest.bml for now, sorry) - audio: implemented Emulator::Audio mixer and effects processor - audio: implemented Emulator::Stream interface - it is now possible to have more than two audio streams: eg SNES + SGB + MSU1 + Voicer-Kun (eventually) - audio: added reverb delay + reverb level settings; exposed balance configuration in UI - video: reworked palette generation to re-enable saturation, gamma, luminance adjustments - higan/emulator.cpp is gone since there was nothing left in it I know you guys are going to say the color adjust/balance/reverb stuff is pointless. And indeed it mostly is. But I like the idea of allowing some fun special effects and configurability that isn't system-wide. Note: there seems to be some kind of added audio lag in the SGB emulation now, and I don't really understand why. The code should be effectively identical to what I had before. The only main thing is that I'm sampling things to 48000hz instead of 32040hz before mixing. There's no point where I'm intentionally introducing added latency though. I'm kind of stumped, so if anyone wouldn't mind taking a look at it, it'd be much appreciated :/ I don't have an MSU1 test ROM, but the latency issue may affect MSU1 as well, and that would be very bad.
2016-04-22 13:35:51 +00:00
rtcWrite(byte * 2 + 0, data[byte] >> 0);
rtcWrite(byte * 2 + 1, data[byte] >> 4);
}
uint64 timestamp = 0;
for(auto byte : range(8)) {
timestamp |= data[8 + byte] << (byte * 8);
}
uint64 diff = (uint64)time(0) - timestamp;
Update to v098r06 release. byuu says: Changelog: - emulation cores now refresh video from host thread instead of cothreads (fix AMD crash) - SFC: fixed another bug with leap year months in SharpRTC emulation - SFC: cleaned up camelCase on function names for armdsp,epsonrtc,hitachidsp,mcc,nss,sharprtc classes - GB: added MBC1M emulation (requires manually setting mapper=MBC1M in manifest.bml for now, sorry) - audio: implemented Emulator::Audio mixer and effects processor - audio: implemented Emulator::Stream interface - it is now possible to have more than two audio streams: eg SNES + SGB + MSU1 + Voicer-Kun (eventually) - audio: added reverb delay + reverb level settings; exposed balance configuration in UI - video: reworked palette generation to re-enable saturation, gamma, luminance adjustments - higan/emulator.cpp is gone since there was nothing left in it I know you guys are going to say the color adjust/balance/reverb stuff is pointless. And indeed it mostly is. But I like the idea of allowing some fun special effects and configurability that isn't system-wide. Note: there seems to be some kind of added audio lag in the SGB emulation now, and I don't really understand why. The code should be effectively identical to what I had before. The only main thing is that I'm sampling things to 48000hz instead of 32040hz before mixing. There's no point where I'm intentionally introducing added latency though. I'm kind of stumped, so if anyone wouldn't mind taking a look at it, it'd be much appreciated :/ I don't have an MSU1 test ROM, but the latency issue may affect MSU1 as well, and that would be very bad.
2016-04-22 13:35:51 +00:00
while(diff >= 60 * 60 * 24) { tickDay(); diff -= 60 * 60 * 24; }
while(diff >= 60 * 60) { tickHour(); diff -= 60 * 60; }
while(diff >= 60) { tickMinute(); diff -= 60; }
while(diff--) tickSecond();
}
auto SharpRTC::save(uint8* data) -> void {
for(auto byte : range(8)) {
Update to v098r06 release. byuu says: Changelog: - emulation cores now refresh video from host thread instead of cothreads (fix AMD crash) - SFC: fixed another bug with leap year months in SharpRTC emulation - SFC: cleaned up camelCase on function names for armdsp,epsonrtc,hitachidsp,mcc,nss,sharprtc classes - GB: added MBC1M emulation (requires manually setting mapper=MBC1M in manifest.bml for now, sorry) - audio: implemented Emulator::Audio mixer and effects processor - audio: implemented Emulator::Stream interface - it is now possible to have more than two audio streams: eg SNES + SGB + MSU1 + Voicer-Kun (eventually) - audio: added reverb delay + reverb level settings; exposed balance configuration in UI - video: reworked palette generation to re-enable saturation, gamma, luminance adjustments - higan/emulator.cpp is gone since there was nothing left in it I know you guys are going to say the color adjust/balance/reverb stuff is pointless. And indeed it mostly is. But I like the idea of allowing some fun special effects and configurability that isn't system-wide. Note: there seems to be some kind of added audio lag in the SGB emulation now, and I don't really understand why. The code should be effectively identical to what I had before. The only main thing is that I'm sampling things to 48000hz instead of 32040hz before mixing. There's no point where I'm intentionally introducing added latency though. I'm kind of stumped, so if anyone wouldn't mind taking a look at it, it'd be much appreciated :/ I don't have an MSU1 test ROM, but the latency issue may affect MSU1 as well, and that would be very bad.
2016-04-22 13:35:51 +00:00
data[byte] = rtcRead(byte * 2 + 0) << 0;
data[byte] |= rtcRead(byte * 2 + 1) << 4;
}
uint64 timestamp = (uint64)time(nullptr);
for(auto byte : range(8)) {
data[8 + byte] = timestamp;
timestamp >>= 8;
}
}