bsnes/sfc/chip/sharprtc/memory.cpp
Tim Allen 4e2eb23835 Update to v093 release.
byuu says:

Changelog:
- added Cocoa target: higan can now be compiled for OS X Lion
  [Cydrak, byuu]
- SNES/accuracy profile hires color blending improvements - fixes
  Marvelous text [AWJ]
- fixed a slight bug in SNES/SA-1 VBR support caused by a typo
- added support for multi-pass shaders that can load external textures
  (requires OpenGL 3.2+)
- added game library path (used by ananke->Import Game) to
  Settings->Advanced
- system profiles, shaders and cheats database can be stored in "all
  users" shared folders now (eg /usr/share on Linux)
- all configuration files are in BML format now, instead of XML (much
  easier to read and edit this way)
- main window supports drag-and-drop of game folders (but not game files
  / ZIP archives)
- audio buffer clears when entering a modal loop on Windows (prevents
  audio repetition with DirectSound driver)
- a substantial amount of code clean-up (probably the biggest
  refactoring to date)

One highly desired target for this release was to default to the optimal
drivers instead of the safest drivers, but because AMD drivers don't
seem to like my OpenGL 3.2 driver, I've decided to postpone that. AMD
has too big a market share. Hopefully with v093 officially released, we
can get some public input on what AMD doesn't like.
2013-08-18 13:21:14 +10:00

68 lines
2.0 KiB
C++

uint4 SharpRTC::rtc_read(uint4 addr) {
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;
default: return 0;
}
}
void SharpRTC::rtc_write(uint4 addr, uint4 data) {
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;
}
}
void SharpRTC::load(const uint8* data) {
for(unsigned byte = 0; byte < 8; byte++) {
rtc_write(byte * 2 + 0, data[byte] >> 0);
rtc_write(byte * 2 + 1, data[byte] >> 4);
}
uint64 timestamp = 0;
for(unsigned byte = 0; byte < 8; byte++) {
timestamp |= data[8 + byte] << (byte * 8);
}
uint64 diff = (uint64)time(0) - timestamp;
while(diff >= 60 * 60 * 24) { tick_day(); diff -= 60 * 60 * 24; }
while(diff >= 60 * 60) { tick_hour(); diff -= 60 * 60; }
while(diff >= 60) { tick_minute(); diff -= 60; }
while(diff--) tick_second();
}
void SharpRTC::save(uint8* data) {
for(unsigned byte = 0; byte < 8; byte++) {
data[byte] = rtc_read(byte * 2 + 0) << 0;
data[byte] |= rtc_read(byte * 2 + 1) << 4;
}
uint64 timestamp = (uint64)time(0);
for(unsigned byte = 0; byte < 8; byte++) {
data[8 + byte] = timestamp;
timestamp >>= 8;
}
}