deltabeard / Peanut-GB

A Game Boy (DMG) emulator single header library written in C99. Performance is prioritised over accuracy.
https://projects.deltabeard.com/peanutgb/
329 stars 41 forks source link

gb: Improve RTC accuracy with MBC3 #90

Closed deltabeard closed 11 months ago

deltabeard commented 1 year ago

Since the RTC is updated every second, and currently only during VSYNC, RTC latching for each read/write may not be required as the RTC is guaranteed to not be updated during VSYNC. The only instance that there could be an issue is when the game has latched the RTC on the last CPU instruction before VSYNC occurs, causing the RTC to be updated whilst the game is reading/writing to it.

Hence, whenever the front end is updating the RTC, Peanut-GB should check whether the RTC has been latched first and only update the RTC if it is not latched.

deltabeard commented 1 year ago

RTC latching is emulated on the https://github.com/deltabeard/Peanut-GB/tree/fix-rtc2 branch, but the rtc3test at https://github.com/aaaaaa123456789/rtc3test still does not pass.

deltabeard commented 11 months ago

RTC emulation greatly improved in 97548efe9688176cac3f29aa1a3acdce945bf878 but still not perfect.