10

I owned a Paperboy cartridge for the NES and something odd I noticed was that the random order of houses in the game stayed the same between pressing the Reset button, but were different when turning the console off and on. The cartridge didn't have any kind of a battery for saving, which is what I would expect would be necessary to store even that small amount of information, which means there must be some technical quirk to resetting that accidentally keeps a little saved data around, but not everything.

Any hints what's going on at a hardware level during this interaction?

1
  • 6
    Without taking it apart, a pretty good guess is it initializes its RNG state using the contents of memory on game start; which would be randomized on power on but constant across restarts. Commented Feb 13 at 0:44

2 Answers 2

21

NES uses a standard SRAM chip. SRAM is basically made of flip-flops that keep the logic state of a bit written to it so the bit can be read back. But on power-up, the flip-flops will go randomly to either contain a '0' or '1' bit, and thus the state of memory contents is random or unknown. Of course it is not truly random, as it depends on transistor manufacturing tolerances and the circuit on silicon will have different leakage currents depending on temperature etc. So each bit will just have a likelihood of being '0' or '1', depending on what the temperature is, how fast supply voltage rises, any noise and electromagnetic interference present etc. But basically, random enough to be called random, but not random enough to be completely random: there tends to be a pattern and given a few powerups, the few bytes that the game uses as initial randomness source could be identical.

Pressing the reset button on NES will do nothing to the SRAM contents; it simply resets the CPU which just starts running code from ROM cart again. If the game does not initialize the memory by writing something to it, then it will be in the powerup state until written.

In all likelihood, the game uses some bytes in the SRAM as seed for the randomness, and that never changes when pressing reset.

There is also at least one game that uses the fact that memory persists between resets by storing contents into memory, so the game can know what state it is in after reset is pressed. At one point of the game, part of the plot is for the player is to realize that there is no way to continue in the game by just playing, and there are hints that the player should press reset to continue in the game and finish it.

2
  • 9
    That was X-Men for the Genesis: retrocomputing.stackexchange.com/questions/25995/… Commented Feb 13 at 5:54
  • 3
    This same aspect also leads to some interesting behavior when swapping cartridges and resetting if the new game does not rewrite some parts of memory before reading them. This famously has been used to access glitch worlds in the original Super Mario Bros. by setting up the initial memory state using the SMB1 cartridge, swapping to Tennis to manipulate parts of the RAM (it uses parts that SMB1 does not clear on reset), and then swapping back to SMB1. Commented Feb 13 at 16:31
9

On the NES, RAM is not cleared when you press RESET.

When a game starts up, many games will check if a special signature they had previously put in the RAM is still present, to help tell if the console was reset (if a valid signature is still present) or powered on (if a valid signature is not present). If the game detects a reset, then it can reuse the existing RAM values from before the reset. If the game detects a power on, then it will probably clear all of the RAM before using it and then write its special signature for a future check.

Many games use this kind of a check to preserve things like the high score and the level you can continue on after you press RESET.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.