Configuration File Format

Each episode of the game has a configuration file named COSMO1.CFG, COSMO2.CFG, or COSMO3.CFG, respectively. The configuration file records the user’s preferred keyboard layout, the on/off state of the sound effects/music, and the contents of the high score table.

The configuration file does not record anything pertaining to the joystick, nor does it contain anything specific to the environment or location where the game runs. Configuration files are freely movable from location to location, and computer to computer.

Each episode uses an identical configuration format, so it is possible to take a configuration file generated by one episode and rename/duplicate it for use with a different episode.

Format

Offset (Bytes)SizeDescription
0hbyteScancode for the “look up” key.
1hbyteScancode for the “look down” key.
2hbyteScancode for the “walk left” key.
3hbyteScancode for the “walk right” key.
4hbyteScancode for the “jump” key.
5hbyteScancode for the “drop bomb” key.
6hbyteMusic toggle state. 0 = music off, 1 = music on.
7hbyteSound effects toggle state. 0 = sound off, 1 = sound on.
8hvariesHigh score table. 10 entries in the format score name\n. See next section.

High Score Table

The game tracks the integer score and string name of the ten highest final scores. These values are written to the configuration file starting at offset 8h in the following way:

  1. Write the score as a sequence of ASCII digits.
  2. Write a single space character.
  3. Write the name as a sequence of characters.
  4. Write a single newline (\n) character.

The above steps run a total of ten times, once for each entry in the high score table.

To read the values back:

  1. Read ASCII digits until the first non-digit character. Interpreted as an integer, this is the score.
  2. Read one character and discard it. This should be the space from step 2 above.
  3. Read characters until the first \n character. Interpreted as a string, this is the name.

As before, the above steps run ten times.

Internally, the scores are unsigned 32-bit values and can represent any value between 0 and 232 - 1. Names are each allocated 16 bytes, which means there can be a maximum of 15 significant characters in each name due to each string’s null termination.

For display in the in-game high score table, any score higher than 9,999,999 or any name longer than 14 characters will encroach on other visual elements and look unpleasant. Normal gameplay keeps the sizes within these limits.

Location

The configuration file is stored in the save directory, which is usually (but not necessarily) the DOS working directory when the game was launched.

Loading and Saving

The configuration file is loaded once during the game’s startup, while the pre-title image is on screen. If the configuration file does not exist, hard-coded default values (including the Simpsons high score names) are used instead. A missing configuration file is not created on disk at this time.

The configuration file is written during exit, immediately before the game switches the video hardware from graphics mode back to text mode. The file is created at this time if it doesn’t exist, otherwise the existing file is overwritten.

While the game is running, configuration values are manipulated in memory only. If the game crashes without going through the normal exit functions, the in-memory changes are lost.