-
Notifications
You must be signed in to change notification settings - Fork 1
Unmangling and decoding algorithms
Game files are obfuscated in the release versions of Fatal Racing and Whiplash using one or both of the following processes:
- Mangling: "RLE algorithm on steroids"
- Encoding: Fibonacci-like XOR cipher stream.
No obfuscation is used in the Fatal Racing demo or beta.
The Whiptools unmangler is adapted from this implementation by @samunders-core.
4-byte header containing the length of the unmangled file.
One of eight functions is performed depending on the control byte (next unread byte). Gremlin's original unmangler implementation examines the top bits of the control byte to determine the required function as follows:
Literal / Diff / Clone0xxxxxxx
|
Block1xxxxxxx
|
||||||
|---|---|---|---|---|---|---|---|
Literal00xxxxxx
|
Diff / Clone01xxxxxx
|
Short block10xxxxxx
|
Medium / Long block11xxxxxx
|
||||
Diff010xxxxx
|
Clone011xxxxx
|
Medium block110xxxxx
|
Long block111xxxxx
|
||||
Byte diff0100xxxx
|
Word diff0101xxxx
|
Byte clone0110xxxx
|
Word clone0111xxxx
|
||||
0x00 to 0x3F
|
0x40 to 0x4F
|
0x50 to 0x5F
|
0x60 to 0x6F
|
0x70 to 0x7F
|
0x80 to 0xBF
|
0xC0 to 0xDF
|
0xE0 to 0xFF
|
The Actua Soccer/UEFA Euro 96 England source code was accidentally distributed on the cover disc of issue 71 (May 1996) of French computer magazine Joystick, including the original unmangler implementation (UNMANGLE.C). The source code was later made available on the Gremlin Archive under a CC BY-NC-ND 4.0 licence.
Note that UNMANGLE.C ignores the 4-byte header containing the unmangled file length and instead terminates the output when a zero control byte is found. However, the header is used by SOUND.C in Fatal Racing/Whiplash (loadfile and getcompactedfilelength).
Encoding is applied to .KC files (cheat audio activated by TOPTUNES), FATAL.INI (configuration file) and PASSWORD.INI (cheat names). To decode these, apply a bitwise XOR against the Fibonacci-like sequence
-
.KC files:
$a_0 = 115$ ,$a_1 = 150$ Note .KC files must be unmangled first, then decoded.
-
FATAL.INI:$a_0 = 77$ ,$a_1 = 101$ -
PASSWORD.INI:$a_0 = 23$ ,$a_1 = 37$ By decoding
PASSWORD.INIin Fatal Racing V2.0 builds or Whiplash we can find two undocumented cheat names:- PROCESS: performs a Pentium FDIV bug check and changes to TYPE A if the bug is found or TYPE B if not
- CLONES: not implemented.
frontend.c also calls this function with