Introduction
TYRIAN.CFG keeps the settings that Tyrian and its setup program write: how much detail to draw, how fast to run, the two volumes,
what the joystick buttons do and which keys play. It is 28 bytes and, unlike TYRIAN.SAV, not scrambled.
The layout is OpenTyrian’s (config.c, loadConfiguration and saveConfiguration), which reads and writes the same file as the DOS game; it was checked against the real
tyrian.cfg found on this machine, which decodes to sensible values in every field.
.cfg is a very common extension. The game itself checks only the length and clamps the volumes, so it loads any 28-byte file. To keep
other programs’ files out, the explorer takes a 28-byte file for Tyrian’s when at most three of 13 checks fail:
background layer 2 is 0 or 1, speed 1 to 5, version 0 to 3 (3 is Tyrian 2000), detail 1 to 6, difficulty up to 10, and each of the eight key codes 1 to 88. Every check that fails is marked on the
setting (“the game loads the file as it is”). A random 28-byte file passes this about once in a million times (1 of 1,000,000 measured). Any volume is accepted and one above 255 is
marked “used as 255”. A file of 10 to 27 or of 29 to 64 bytes that begins like one is shown as far as it goes with the problem marked (the game finds it invalid and uses its defaults).
Any other file is shown as text.
Fields
| Offset | Size | Name | Description |
|---|---|---|---|
0x00 | 1 | Background layer 2 | The second background layer’s setting. It is read, but OpenTyrian then sets the layer on whatever the byte says, except that detail level 1 turns it off, so the byte has no effect there. |
0x01 | 1 | Game speed | 1 Slug Mode, 2 Slower, 3 Slow, 4 Normal, 5 Turbo (OpenTyrian’s comment calls it Pentium Hyper). OpenTyrian turns it into a timing, as frames to a step and a step value: 1 Slug Mode four frames, 0x5300; 2 Slower three frames, 0x4300; 3 Slow two frames, 0x53C0 (the longest step); 4 Normal two frames, 0x4300; 5 Turbo two frames, 0x3000 (the shortest). |
0x02 | 1 | Input device | Kept for compatibility; OpenTyrian ignores it and sets it to 0. |
0x03 | 1 | Joystick configured | A flag; OpenTyrian turns a 0 into 1 when it loads the file. |
0x04 | 1 | Version | OpenTyrian’s comment: “SW 1.0 and SW/Reg 1.1 = 0 or 1, EA 1.2 = 2”. No other source for those releases was found, so that meaning is unconfirmed. OpenTyrian sets it to 2 whatever the file holds (“Game resets version number; ShipEdit doesn’t”) and writes 2 back, and nothing else reads it: so it is a marker of the program that wrote the file, never used. OpenTyrian2000’s comment adds “T2K = 3” for Tyrian 2000. Real files hold 2 (the file here) and 0 (the TYRIAN.CFG in the archive.org 2.1 package). |
0x05 | 1 | Detail level | 1 Low (a 386), 2 Normal (a 486), 3 High, 4 Pentium, 5 Laptop VGA (nonstandard VGA), 6 Wild (the “super wild” effects). OpenTyrian sets from it: 1 no second background, no score display, opaque explosions; 2 the defaults (smooth scrolling, transparent explosions, score shown); 3 smooth scrolling off; 4 “wild” effects and colour filtering on; 5 smooth scrolling off; 6 “wild”, “super wild” effects and colour filtering. |
0x06 | 1 | MIDI port | Kept from the DOS setup; OpenTyrian keeps the value and does not use it. |
0x07 | 1 | Sound effects | Kept from the DOS setup; OpenTyrian keeps the value and does not use it. |
0x08 | 1 | Gamma correction | The screen brightness step, 0 to 3: a key in the game cycles it (adds 1 modulo 4) and the palette is corrected by it, at once and at the start of each level. |
0x09 | 1 | Difficulty | A signed byte: the difficulty last chosen (the numbering). |
0x0A | 4 | Joystick buttons | What buttons 1 to 4 do: 1 fire the main weapons, 2 fire the left sidekick, 3 fire the right sidekick, 4 fire both sidekicks, 5 change the rear weapon. The defaults are 1, 4, 5, 5. |
0x0E | 2 | Music volume | 0 to 255; the game treats a larger value as 255. Default 223. |
0x10 | 2 | Sound volume | 0 to 255. Default 223. |
0x12 | 1 | Player 1 input device | 0 any, 1 keyboard, 2 mouse, 3 and up joysticks. |
0x13 | 1 | Player 2 input device | The same for player 2. |
0x14 | 8 | Keys | The keyboard scan codes (IBM PC set 1) of Up, Down, Left, Right, Fire, Change fire, Left sidekick and Right sidekick, in that order. |
When the file is missing, is not 28 bytes or cannot be read, OpenTyrian starts with background layer 2 on, speed 4, version 2, detail 3, MIDI port 1, sound effects 1, gamma 0, difficulty 0, the default joystick buttons, both volumes 223, both input devices 0 and the default keys 72, 80, 75, 77, 57, 28, 29, 56 (Up, Down, Left, Right, Space, Enter, Ctrl, Alt).
Scan codes
The key bytes are the codes the PC keyboard sends: 72 Up, 80 Down, 75 Left, 77 Right, 57 Space, 28 Enter, 29 Ctrl, 56 Alt, 30 A, 32 D, and so on (letters follow the keyboard rows: Q 16 to P 25, A 30 to L 38, Z 44 to M 50; digits 2 to 11; F1 to F10 are 59 to 68). The explorer names every code from 1 to 88 that has a key.
A real file
The tyrian.cfg found here is 28 bytes: 01 04 00 01 02 04 02 04 00 03 01 04 05 05 CF 00 FE 00 00 00 48 50 4B 4D 39 1C 1E 20.
It says: background layer 2 on, speed Normal (4), joystick configured, version 2, detail Pentium (4), MIDI port 2, sound effects 4, gamma 0, difficulty Hard (3),
the default joystick buttons, music volume 207, sound volume 254, both input devices 0, and the keys Up, Down, Left, Right, Space, Enter and, for the sidekicks, A and D (codes 30 and 32)
instead of Ctrl and Alt.
opentyrian.cfg
OpenTyrian keeps its own settings, which the DOS game has no place for, in a second file, opentyrian.cfg: a text file in a small
sectioned format of its own (not INI). The rules below are read from OpenTyrian’s config_file.c (config_parse,
config_write) and config.c (loadOpenTyrianConfig), with the scaler and display rules from
video.c and video_scale.c, and the key names from SDL’s SDL_keyboard.c. They were read, not copied.
Syntax
- A line ends at a line feed or a carriage return. A line whose first word, after spaces and tabs, is not
section,itemorlist(followed by a space, a tab or the end of the line) is ignored: that is how the file holds blank lines and comments, and nothing marks a comment. section type [name]starts a section.item key valuesets an option of the section (a repeated key replaces the earlier value);list key valueadds a value to a list option. Anitemorlistbefore any section is skipped.- A field is bare (printable ASCII, no space, and none of
#'") or quoted with'or", with the escapes\'\"\t\n\r\\and\xwith two hexadecimal digits; the text inside quotes is printable ASCII. A field must be followed by white space or the end of the line. A line whose type, key or value does not parse is skipped (a section’s name that does not parse is simply absent). OpenTyrian writes every field in single quotes,itemlines after a tab, and a blank line after each section. - The game reads the first section of each type that has no name; sections with a name, other sections and other options are not used, but are written back when it saves.
Settings the game reads
| Section | Option | Value | Default |
|---|---|---|---|
video | fullscreen | An integer read with C’s %i over the whole value (decimal, 0x hexadecimal or a leading 0 for octal). -1 is a window; 0 and up is the display to fill (display 0 when there is no such display). The source does not say what a value below -1 does. | -1 |
video | scaler | One of None (320 × 200), 2x, Scale2x, hq2x (640 × 400), 3x, Scale3x, hq3x (960 × 600), 4x, hq4x (1280 × 800); the name must match exactly, with its case. | Scale2x |
video | scaling_mode | One of Center, Integer, Fit 8:5, Fit 4:3 (exact). | Integer |
keyboard | up, down, left, right, fire, change fire, left sidekick, right sidekick | An SDL key name such as Up, Space, Return, Left Ctrl or Keypad 5; SDL compares without regard to case and the first scancode with the name wins. A name SDL does not know is ignored. | Up, Down, Left, Right, Space, Return, Left Ctrl, Left Alt |
An option that is a list gives the game no value, so it keeps its default. A value that does not fit (a name that is not in the lists, an integer with
trailing text) is ignored the same way, silently. The explorer opens a file named opentyrian.cfg, or a .cfg with a section video or
section keyboard line, shows what the game takes from it and what it keeps as default, and marks each ignored value and each skipped line as a problem.
SDL’s key names are those of SDL 2.30 on every platform; a platform may rename a key at run time (SDL_SetScancodeName), which a file cannot show.
section 'video'
item 'fullscreen' '-1'
item 'scaler' 'Scale2x'
item 'scaling_mode' 'Integer'
section 'keyboard'
item 'up' 'Up'
item 'fire' 'Space'
item 'left sidekick' 'Left Ctrl'
opentyrian.cfg was found on this machine; the example follows the writer in config_file.c.Not described
Known, not yet covered
Nothing: both files this page covers, TYRIAN.CFG and opentyrian.cfg, are read to the last field.
Unknown
- Reference: what the MIDI port and sound-effects bytes mean to the DOS setup program. OpenTyrian reads them and writes them back and never uses them; the real files hold 2 and 4 (the file here) and 2 and 2 (the 2.1 package).
- Reference: a
TYRIAN.CFGwritten by Tyrian 1.0, 1.1 or 2.0: none was found (the archive.org dumps are fresh installs); the 2.1 package’s file has the layout described here.
Also used for
- INI-style configuration file – Configuration text: sections in brackets, then key=value lines.
Links
Reference
- OpenTyrian src/config.c – loadConfiguration and saveConfiguration
- OpenTyrian src/config_file.c – the opentyrian.cfg syntax
- OpenTyrian src/video_scale.c – the scaler names
- SDL src/events/SDL_keyboard.c – the key names
- Tyrian saved games – the other file of the game