Skip to content

FDS: Implement DRAM refresh watchdog - #302

Open
TakuikaNinja wants to merge 5 commits into
nesdev-org:masterfrom
TakuikaNinja:FDS-DRAM-Watchdog
Open

TakuikaNinja wants to merge 5 commits into
nesdev-org:masterfrom
TakuikaNinja:FDS-DRAM-Watchdog

Conversation

@TakuikaNinja

Copy link
Copy Markdown

This PR implements the FDS DRAM refresh watchdog that was discovered last year. (It's been over a year already? Jeez...)

  • Timing matches my FDS-4030D1-Addr test
  • No regressions in the timer IRQ test suite (which happens to trigger the watchdog IRQ while idle)
  • Adds backwards compatibility for savestates predating the watchdog's discovery

I've tested a random selection of commercial titles and homebrew programs so far (some of which indeed use "everything in NMI" and trigger the IRQ) but it will obviously need more thorough game testing and performance profiling. There's also one edge case labelled as a TODO which I'll need to test on original hardware, though it involves toggling $4023.D7 and thus should be irrelevant for everything else which preserves the $83 value set by the BIOS.

image image

- Timing matches FDS-4030D1-Addr test
- No regressions in timer IRQ test suite
- Checked against older FDS-4030D1-Micro test
@TakuikaNinja

Copy link
Copy Markdown
Author

I found some inaccuracies when comparing against the older FDS-4030D1-Micro test, so I've fixed those and the numbers match my console there as well.

  • $4023.D7 = 0 ack's/disables the watchdog IRQ (so you can't trip the thing and have the pending IRQ linger until the bit is set)
  • Reordered watchdog timer & DRAM row clocking as to avoid extra decrements of the former
  • Optimised IRQ state update WRT the timer and watchdog sources
  • Clear DRAM access flag every clock regardless of the disk register state
4030d1-micro_003

Also only call UpdateIRQState when flags have changed
@TakuikaNinja

Copy link
Copy Markdown
Author

I've been checking the commercial library and I haven't noticed any obvious performance dips at max speed with the current changes.
Good examples for benchmarking so far have been Breeder (intro sequence was already quite demanding) and Cleopatra no Mahou (trips watchdog & plays wavetable audio on title screen).

@TakuikaNinja

Copy link
Copy Markdown
Author

Just noting here that the Sailor Fuku Bishoujo Zukan series (unlicensed) will crash when the previous MesenCE version would just show error 24. (We should make this series a candidate for testing any drive emulation changes)

I checked the program and determined that the crash occurs due to a nested IRQ triggered by the watchdog while waiting for NMIs. (They use the same handler for NMI & IRQ for license screen bypass purposes) Any error being thrown by the program's own LoadFiles call will do this, so I'm classifying it as a game bug.

It also crashes when trying to load it on my console using the FDSKey (it can't seem to handle the disk loading correctly for this either, go figures), so this behaviour is actually an accuracy improvement.
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant