fceux icon indicating copy to clipboard operation
fceux copied to clipboard

WRAM is not initialized by Power?

Open bbbradsmith opened this issue 6 years ago • 0 comments

While reviewing the various mappers' WRAM initialization code for this pull request, I noticed that while WRAM seems to always be initialized by a board Init, it is not generally initialized by Power.

I found 3 exceptions, which explicitly initialize WRAM at Power if not battery backed. Not sure if these were motivated by past problems, though they do manage to cover a lot of games between them. There may be more:

  1. MMC1: https://github.com/TASVideos/fceux/blob/master/src/boards/mmc1.cpp#L275
  2. MMC3: https://github.com/TASVideos/fceux/blob/master/src/boards/mmc3.cpp#L282
  3. N106: https://github.com/TASVideos/fceux/blob/master/src/boards/n106.cpp#L403

Since implicit WRAM is pretty common, and it appears that recording a movie from start only does Power, not Init, that it's easy to intentionally produce a divergent WRAM memory state from a movie. (E.g. open Super Mario Bros. and edit some hex values around $6000, record a movie, notice these values aren't kept.)

I don't know how severe this problem is in practice. I'm wondering if the 3 existing examples cover cases where it's come up before?

I am not sure if making movies that record from start Close and re-Init the cart would be appropriate, or if every mapper that has WRAM should explicitly check for no battery and initialize-- this is a lot of cases, but not horribly too much, and it could be an excuse to replace a lot of them with more generic shared WRAM code though.

Other option I guess is just ignore it and maybe it'll never come up, or take a long time to. Games with WRAM and no battery that have relevant lack-of-initialization bugs might be a very small set.

bbbradsmith avatar Jun 20 '18 07:06 bbbradsmith