The Sega Genesis system had a rather interesting game. X-Men (1993) was based on the popular cartoon version of the comic book series. But it had what was still one of the most unique (and unintuitive) mechanisms I've ever heard of. In the second to last level, the game asks you to "reset the computer". The strange thing about this is there's no in-game way to do this, and many people would get frustrated with the inability to progress to the game's final level. But the reset mechanism the game wants you to activate is the console's reset button

Now years after attempting, failing and just moving on to other games, I happened to find the answer. This was years ago, by the way. To reset the computer- the player had to press reset on the Sega Genesis console. Yes. I was taken aback. It felt like a slap in the face. Not only was the player supposed to think outside the game cartridge, but they were supposed to do something NO gamer in their right mind would ever think of doing for fear of losing progress in the game.
And to top it off- if you pressed it for even a fraction of a second to long, the game would do exactly that- reset the system and you'd lose your progress. So gamers were supposed to tap the reset button which brought up a screen full of numbers and then moved you on to the next level.

The reset button should clear the console's memory. How did the game manage to survive pressing the reset button AND know that that was what had happened?

user3840170's user avatar

user3840170

28k4 gold badges113 silver badges172 bronze badges

asked Dec 28, 2022 at 15:20

Machavity's user avatar

3

The reset button should clear the console's memory.

No, it shouldn’t. The 68000 reset vector is the first eight bytes in cartridge ROM. The cartridge will point at its own initialization code; the boot ROM (if there is one; very early Geneses didn’t have lockout) only enables the “TradeMark Security System” lockout.

How did the game manage to survive pressing the reset button AND know that that was what had happened?

I’m making an educated guess that it checked RAM for a known pattern, which was unlikely to be randomly set. The Genesis uses PSRAM (pseudo-static RAM, basically DRAM with a built-in refresh controller), which does not get cleared on reset, only on power loss.


I disassembled the cartridge using Ghidra and found the following "magic constant" comparison of an apparently-uninitialized RAM value ($ff0800) fairly early in the reset logic, in the function starting at $014cd8 (I labeled it Start2):

Decompilation of the cartridge at address $014cec

The magic constant $57425554 is an ASCII string WBUT.

If the comparison succeeds, control jumps to $027fe0, otherwise it skips to the next address, $014cfe.

See also:

answered Dec 28, 2022 at 15:58

Jacob Krall's user avatar

12

Similar methods have existed and are still used.

The reset does not clear the memory, it simply resets the CPU to start running code from start vector.

All the code needs to do is to check a known piece of memory if something known exists in memory or not, to trigger an action how to proceed after startup.

Then it is up to the game progress to write something known to the special memory address or write nonsense to make sure the function is not triggered at next reset.

This was for example used in IBM PC 5150 to skip cold boot memory test. After cold boot is done, pressing CTRL-ALT-DEL writes a special word to known memory address, so the startup code knows to skip the RAM test.

answered Dec 28, 2022 at 16:28

Justme's user avatar

The reset button should clear the console's memory.

Why? And who should do that?

The Mega Drive is a very classic console. There is no OS or monitor (*1) that controls execution and prepares the machine. It's all up to the cartridge if it wants to clear memory, or how it initializes anything at all.

The Reset button just resets the system, that means whatever reset address is in the reset vector - the first few bytes of the cartridge - gets executed.

How did the game manage to survive pressing the reset button AND know that that was what had happened?

It knows it happened because it gets started at the reset entry point. Most likely it will check a few memory locations for some value stored there prior to reset. If that value (usually with some checksum) is found, it knows it's a warm-boot, so it continues the game. If not, which for all chance is when the console gets powered up, it'll setup whatever needed and start the game.


*1 Situation is a bit different with CD based games

Jean-François Fabre's user avatar

answered Dec 28, 2022 at 16:00

Raffzahn's user avatar

15

Found an interesting blog entry that adds some details to the answer by Jacob Krall. The main gist is that Jacob was right, in that RAM is not cleared between resets

SGDK doesn’t clear the entire RAM on a soft reset, so that you can keep certain data like high scores and settings alive even after a reset. It would be a bit overkill to use SRAM (saving using a battery in the cartridge) just for that. Plus, you could do even more interesting things with it… Have you ever played the original X-Men game on the Mega Drive? That game had you reset your console to gain access to the final level. That obviously wouldn’t work if a soft reset deleted everything!

What differs from what Jacob noted about architecture is that apparently the Genesis could report this state to your code directly

The simplest way is to initialize everything we need reset in main() before our game loop starts. The main() function is called every time we reset the console (using a soft or hard reset), so in our case, adding a ticker = 0; before while(1) would solve our problem and set the ticker back to 0 after each reset of the emulator.

Later

If you add a parameter to main(), you can see whether the console has been reset and how

 int main(int resetType){}

When the console has just been turned on, resetType will equal 1, indicating a hard reset. But if the reset button has just been pressed, resetType will equal 0! (You can call the parameter anything you want, by the way).

Jacob Krall's user avatar

Jacob Krall

2,5792 gold badges20 silver badges34 bronze badges

answered Jan 17, 2024 at 13:52

Machavity's user avatar

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.