Configuration File Format
Each episode of the game has a configuration file named
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.
|0h||byte||Scancode for the “look up” key.|
|1h||byte||Scancode for the “look down” key.|
|2h||byte||Scancode for the “walk left” key.|
|3h||byte||Scancode for the “walk right” key.|
|4h||byte||Scancode for the “jump” key.|
|5h||byte||Scancode for the “drop bomb” key.|
|6h||byte||Music toggle state. |
|7h||byte||Sound effects toggle state. |
|8h||varies||High score table. 10 entries in the format |
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:
- Write the score as a sequence of ASCII digits.
- Write a single space character.
- Write the name as a sequence of characters.
- Write a single newline (
The above steps run a total of ten times, once for each entry in the high score table.
To read the values back:
- Read ASCII digits until the first non-digit character. Interpreted as an integer, this is the score.
- Read one character and discard it. This should be the space from step 2 above.
- Read characters until the first
\ncharacter. 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.
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.