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?

user3840170
  • 23,072
  • 4
  • 91
  • 150
Machavity
  • 503
  • 3
  • 8
  • 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 Dec 29 '22 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. – Jacob Krall Dec 29 '22 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 Jan 18 '24 at 13:04

4 Answers4

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:

Jacob Krall
  • 2,299
  • 2
  • 17
  • 31
  • This raises the question: why didn’t the game just jump to the address in the start vector? The reset button surely did something other than that, or the game wouldn’t be telling the player to do something so bizarre. – Davislor Dec 29 '22 at 01:54
  • 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). – Austin Hemmelgarn Dec 29 '22 at 02: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 – BlueRaja - Danny Pflughoeft Dec 29 '22 at 04:19
  • @AustinHemmelgarn If there’s reason to believe so (Was that a time-travel game where the player resets to alter the timeline, for example?), that would make a great answer! – Davislor Dec 29 '22 at 08:10
  • @Davislor I unfortunately do not have conclusive evidence, my comment was more intended to point out what seems (to me as a software developer and avid gamer) like the most logical reasoning for this being the case. – Austin Hemmelgarn Dec 29 '22 at 12:56
  • 2
    What about the "if you pressed it [too] long" part? – AndreKR Dec 29 '22 at 15:00
  • 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. – Owen Reynolds Dec 29 '22 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. https://youtu.be/ffpfi2a5bfA – Jacob Krall Dec 29 '22 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 Dec 29 '22 at 17:47
  • 1
    @AndreKR Perhaps holding the button for too long can trigger two resets (either it's level-triggered, or the button can bounce and accidentally send two reset edges). That's just my wild speculation, I don't know anything about the actual hardware. But you can imagine that resetting again halfway through the special resume code can corrupt game state enough so that it fails to resume again after the second reset. – TooTea Dec 30 '22 at 10:44
  • I went out and bought a Model 2 Sega Genesis (NTSC US). It resets when I press the RESET button down, but boots up and continues playing as I hold it and release it. – Jacob Krall Dec 31 '22 at 21:52
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.

Justme
  • 31,506
  • 1
  • 73
  • 145
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

Jean-François Fabre
  • 10,805
  • 1
  • 35
  • 62
Raffzahn
  • 222,541
  • 22
  • 631
  • 918
  • 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 Dec 28 '22 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 Dec 29 '22 at 01: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 Dec 29 '22 at 01:33
  • @supercat Consider what ever you want and speculate ahead. I'd rather go with fact. – Raffzahn Dec 29 '22 at 01:38
  • My point was that while the Sega Megadrive/Genesis happens not to include any internal ROM, it was common both for systems to include ROM, and for systems to omit it. – supercat Dec 29 '22 at 16:35
  • It's not so strange to think that the hardware -- specifically, the memory controller -- would wipe the contents of RAM when the reset button was pressed. I understand you to be saying that in reality this was the responsibility of the software on the cartridge, but it really isn't obvious to anyone who hasn't studied the architectures of these systems that that's how it worked. – zwol Dec 29 '22 at 18:57
  • @supercat Most systems at did not include ROM. Check anything from Atari to Nintendo or Sega of the time. – Raffzahn Dec 29 '22 at 21:40
  • @zwol Erm, there is no memory controller. Even less one as complex as needed to clear memory on it's own. Not even the most modern CPUs with their highly complex memory controllers does something alike and even less on their own. Also, more general, when deeper knowledge is missing Mr. Occams rule is always of help: The most simple behaviour is the most likely. In this case: Reset does just that, re-sets the CPU to a known program state, not more. Implemented as a special form of interrupt. – Raffzahn Dec 29 '22 at 21:49
  • You don't need a memory controller to reset a RAM to blank state. The system designer just need to implement the reset mechanism by powering down the RAM and all RAM content should've been destroyed. The reason this hack worked is because the system designer chose to implement a system reset in a way that doesn't involve that step. They could've implemented reset completely in hardware, by completely interrupting the power supply for everything for a brief moment, that likely would've been much simpler to implement, but for some reasons, they don't. – Lie Ryan Dec 30 '22 at 01:29
  • @LieRyan destroying content is not the same as cleaning it. It also is no 'hack' as it works with next to any computer - The Apple II for example uses Reset as a basic method to stop some program running to get back to command line. Also, your suggestion would mean additional hardware - why on earth should Sega (or anyone else) make a console more expensive without any benefit? They make their money by selling games, not consoles. – Raffzahn Dec 30 '22 at 01:52
  • @Raffzahn: no additional hardware necessary, at the simplest level, the Reset button just need to temporarily physically disconnect the power, that's basically the function of a simple switch. Sega instead found a reason to chose to add a more complicated (and the more expensive) mechanism and hardware to implement a soft reset button. – Lie Ryan Dec 30 '22 at 06:53
  • 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. – Revolver_Ocelot Dec 30 '22 at 08:55
  • @LieRyan Not really. For one, disconnecting power is not the same as reset. It usually leads to a POR, which is handled different. Next does disconnecting power not clear RAM. It might loose some or all content, but that is neither instant nor guaranteed. It may take several hundret micro seconds up to many minutes, depending on RAM technology and structure. Sega's solution is not more costly, but less, as the reset button simply connects to the reset input of the CPU - exactly what a reset is intended to do. – Raffzahn Dec 30 '22 at 19:45
  • Earlier Genesis consoles have no boot ROM. Later model 1 consoles and all model 2 and 3 consoles have Trademark Security System (TMSS) to display "PRODUCED BY OR UNDER LICENSE FROM SEGA ENTERPRISES LTD." – Damian Yerrick Jan 01 '23 at 01:42
  • @Raffzahn You know that, I know that, most people don't know that. What I am saying is that you are writing answers as if everything you know about the architectures of early microcomputers (including early game consoles) is obvious to everyone, which is not good pedagogy. – zwol Jan 01 '23 at 18:49
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).

Jacob Krall
  • 2,299
  • 2
  • 17
  • 31
Machavity
  • 503
  • 3
  • 8