The apogee Parameter

Many online cheat guides (a notable example being 3D Realms1 themselves) refer to a special cheat mode where running the game with apogee as a command line argument will unlock a special mode of operation. It doesn’t. Providing apogee (or anything that doesn’t resolve to a valid directory) as the write path makes it so that the game cannot load or save its configuration or save files, and this results in strange behavior:

The effects of this are many. One, the game will not recognize your old high scores or saved games. (The high scores will be reset to those of Simpsons' characters until you exit and re-enter the program normally.) In this mode, if you die quickly enough after entering a level, you’ll be invincible from then on, to everything but pits on the bottom of each level.

http://legacy.3drealms.com/cheat/cosmo.html

For configuration files, it doesn’t matter so much – the game is designed to handle the case where the file is missing. This is where the default values in the high score table come from.

For saved games, the behavior is also predictable. No games can be loaded, because no files exist in the invalid directory. Save attempts fail silently. One of the stranger side effects of this condition is that it’s relatively easy for the player to become invincible by dying during gameplay. This is caused by the interaction of a few different components of the game.

Unintended Invincibility

When a new level is entered, a temporary save file named COSMOx.SVT is written which contains the game state at that point. When the player dies and the level needs to be restarted, this save file is reloaded to return the player’s score, stars, health, and so on back to the state they were in when the level was originally entered. If the save directory is not writable, this file is not written.

While the game is running, the player’s health is tracked in an integer variable that decrements when damage is taken and increments when Power-Up Modules are collected. When health drops to 0 the player dies, but this check only happens at the instant the player is taking damage.

Once the player takes enough damage to drop their health to 0 (falling off the bottom of the map does not count) the level restarts. A load operation is attempted on the COSMOx.SVT save file to reset the game state, but the fopen() call returns a null pointer due to the file having never been written in the first place. The “load game” function does detect this condition, but simply returns early without resetting any of the save game variables.

As a result, the level is restarted with the player health value still at 0. The game is fully playable in this state. The “HEALTH” area of the status bar uses [current health] - 1 to determine how many bars to draw, and since this particular variable is an unsigned 16-bit value which wraps around 0, the player effectively has 65,535 bars of health. Similar behavior occurs in the code where the player takes damage from enemies – the player is actually taking damage, but the amount of health available is so preposterously high they will practically never die.

Other Observable Effects

When invoked, this quirk briefly desynchronizes demo playback during episode 3, after the player first dies on map 6. Playback eventually corrects itself once the demo advances to map 9.

Another potentially interesting side-effect of playing without a COSMOx.SVT file comes as the result of the score/stars values not resetting during level restarts. If one were to continually replay the same levels, but fall off the bottom of the map instead of exiting to the next level, it’s quite possible to amass so many stars that it overflows the two-digit “STARS” space in the status bar. Conceivably the same thing could happen to the score as well, given enough dedication.


  1. http://legacy.3drealms.com/cheat/cosmo.html ↩︎