In the last two articles I explained in detail what the ATTRIBUTEZ.TXT and CHEATZ.TXT files are and how to read them. They’re encrypted configuration files located in the GRUNTZ.REZ archive. The Gruntz Decryptor allows these files to be modified – you can now decrypt such file, change any parameters of interest and encrypt it back again, so that Gruntz is able to properly read them. The program also automatically decodes all cheat codes so that you can freely modify them and add your own.

Only the ATTRIBUTEZ.TXT file is really loaded and used by the game – the CHEATZ.TXT file is just a relic from the game development. Because of that the option of encrypting the CHEATZ.TXT file might seem superfluous; I’ve decided to include it however for completeness’ sake.

DOWNLOAD
Gruntz Decryptor 1.1.0.zip (1.23 MB)


Decoding cheat codes

All cheat codes in the configuration file are initially encoded – each character is modified by adding the 61 (0x3D) offset to its ASCII value (for a more detailed explanation read the article about the ATTRIBUTEZ.TXT file). The Gruntz Decryptor searches for all cheat codes and decodes them by default, so that they are in a user-friendly format.

To make it happen I’ve written a simple LL parser for the configuration file. The parser recovers from every error (be it lexical or syntax) in a way to salvage as many cheat codes as possible, skipping to the next closest definition. The generated abstract syntax tree (AST) is then analyzed:

  1. The program looks for and enters the “Cheatz” section,
  2. It reads the value of the parameter “NumCheatz”,
  3. The program decodes all cheat codes which reside in sections named “Cheat<N>”, where “N” ranges from 1 to “N” inclusive.

Finally the list of all lexical and syntax errors (if any) is shown to the user, accompanied by the line numbers where the errors occurred. You have to take care not to leave any errors unattended, since each one is potentially an invalid cheat code which the game will not load properly.

The parser is using the following simplistic grammar (the pseudocode below is styled according to the grammar syntax used by ANTLR. I find it way cleaner and more friendly than the Backus-Naur form (BNF). I’m not using ANTLR at any point however and the listing below is for illustration purposes only):

ini
  : section* EOF
section
  : '[' ID ']' parameter*
parameter
  : ID '=' (STRING | NUMBER)
  | ID '=' '(' ID ')' (STRING | NUMBER)

STRING
  : '"' BYTE*? '"'
NUMBER
  : '0'..'9'+
ID
  : ('a'..'z' | 'A'..'Z' | '_') ('a'..'z' | 'A'..'Z' | '_' | '0'..'9')*

The grammar was designed specifically for use in Gruntz and is not fit for standard INI configuration file format used in Windows. I haven’t implemented it for … er, practical reasons (*cough* was too lazy *cough*). Some amendments in the future are still possible though.


Changelog:

Legend:
“+” = Addition
“*” = Bug Fix

  • 1.1.0 (24-09-2018)
    + Option for decoding and encoding cheat codes
    * Fixed text in a dynamically set label in the “Paths” section
  • 1.0.0 (18-08-2018)