30

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?

3
  • 3
    One bit that the answers do not address is that progress is supposedly lost when the reset button is pressed too long. I'd welcome an explanation of that (I wouldn't think a separate question is necessary)
    – Oliphaunt
    Commented Dec 29, 2022 at 15:26
  • 3
    @Oliphaunt Just a comment as I no longer have actual Genesis hardware to test on (and it’s also a fairly hard game), but I suspect that’s just a misconception. The Genesis can’t tell how long the reset button was held down. Someone would have to disassemble the ROM to know for sure the mechanism for X-Men warm booting; if it’s actually using a different component that does use dynamic memory (maybe the VDP or a CPU’s registers?), that might explain it, but I’m not convinced. Commented Dec 29, 2022 at 17:07
  • @Oliphaunt I'd guess it's not the amount of time the reset button is pressed - but rather pressing the button repeatedly (be it intentionally or because of random keybounce) that makes you lose your game
    – tofro
    Commented Jan 18 at 13:04

4 Answers 4

33

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:

11
  • 9
    @Davislor Possibly because the designers were trying for a unique gimmick for player interaction? Stranger things have been discussed for this type of thing, such as Rare’s ‘Stop N' Swop' gimmick on the N64 (which would have had players literally swapping the cartridge while the system was running). Commented Dec 29, 2022 at 2:46
  • 4
    ^ That same technique is used by Paper Mario speedrunners to do an Arbitrary Code Execution glitch. They set the RAM to known values by first playing Zelda 64, then hotswapping the cartridge to Paper Mario without turning off the console Commented Dec 29, 2022 at 4:19
  • 4
    @AndreKR I think whomever wrote that quote was confused. They're assuming the game can detect a reset button "tap" which wasn't long enough to perform a real reset. But as this answers says, that's wrong -- the game is detecting an actual reset. Commented Dec 29, 2022 at 16:33
  • 3
    @Davislor the conceit is that the player is in a virtual world, and there is a virus in the system, and the only way to get rid of it is to “reset the computer.” Once you do, it fills the screen with 1337 h4x0r green 0’s and 1’s… SYSTEM RESET. VIRUS PROGRAM SUSPENDED. youtu.be/ffpfi2a5bfA Commented Dec 29, 2022 at 17:10
  • 5
    @OwenReynolds If the reset button turns off the power supply and pulls the reset line low you might get the described behavior, where the memory state is lost iff you hold the button longer than the capacitors last.
    – AndreKR
    Commented Dec 29, 2022 at 17:47
15

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.

11

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

15
  • While many cartridge-based consoles had no internal ROM, many others (including the first one I owned--a Magnavox Odyssey2) did include one. For a cartridge-based machine of the Genesis era, booting from an internal ROM would have been fairly typical.
    – supercat
    Commented Dec 28, 2022 at 19:14
  • @supercat no, most did not, not until the late 90s. G7000, Intelivision, Colleco and Vectrex are outliers even within teh second generation consoles.
    – Raffzahn
    Commented Dec 29, 2022 at 1:08
  • Many consoles included some internal ROM, and many did not. I'd regard both inclusion and omission of ROM as "fairly typical". Having an internal ROM would make various kinds of future system enhancements easier, and make it possible to avoid nailing down certain aspects of system design if, for example, Sega wanted to migrate toward using a common video chip for PAL, NTSC, and SCART outputs, and have code in ROM configure a chip suitably at startup.
    – supercat
    Commented Dec 29, 2022 at 1:33
  • @supercat Consider what ever you want and speculate ahead. I'd rather go with fact.
    – Raffzahn
    Commented Dec 29, 2022 at 1:38
  • 1
    @LieRyan interrupting external power is often not enough to destroy RAM content immideately. You will have to wait some time until capacitors and inductors discharge. This is why after split-second blackout some devices turn off or restart, and other seem to not notice it at all. Commented Dec 30, 2022 at 8:55
1

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).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .