wiki:Introduction to this project

Why am I doing this? Why did I chose Lectures Enjeu?

  • As a kid, I always disassembled my toys to understand how they worked (to the dismay of my parents, who tried everything they oculd think of, such as transparent toys where you could see all the gears).
  • This is a relatively easy reverse engineering project: no need to look at x86 assembler

What is this thing?

  • An "interactive fiction" engine: basically, a text-based computer game
  • This one uses hyperlinks and buttons, that's one of the two "types" of interactive fictions, the other one being syntax analyzers where you enter commands by typing them at the keyboard (in a more or less natural language, depending on the game and engine).
  • Hyperlink based interactive fiction usually has a bad reputation of being too simple, but there are more tricks to it than it looks at first glance.

How did I proceed?

  • Start by looking at the list of files: just by the filenames we can already guess where the data for each game is.
  • Use the "file" command to identify known fileformats
  • Some files are textfiles, so just read them
  • Use the "strings" command to find text in binary files

Using an hex editor

  • The basic idea of an hex editor is to edit non-text files.
  • Shows each byte in hexadecimal (hence the name)
  • It's easy to get lost in the values
  • Use an advanced editor (such as rehex) and annotate things as much as you can (you can mark bytes in different colors for example)
  • Rehex also has an image viewer which allowed to decode the two images used in this game (COWBOY.DAT).

Deep dive into the files:

  • I started with the ones containing text (found by string) and tried to guess the file structure starting from there
  • Studying the text allowed to identify escape sequences, and then extract some info such as button IDs from the escape sequences, as well as some idea about the variables and screens (for example by investigating %c and %f in conditionals).
  • The files are split in "chunks" with an ID and sometimes a size (not a very unusual way to do things)
  • A simple rehex script allows to highlight the chunks, a structure starts to emerge (rooms and screens within each room)
  • First surprise: the game does not start in room 1, screen 1
  • Studying CONDINIT and understanding there is a script bytecode going on.

Using "external" knowledge (things you must know or research elsewhere)

  • EGA palette, 16-bit integers (expected in a DOS game), endianness
  • The EGA palette allows to identify that a specific byte was the main text area color (confirmed by editing that byte). Next to it was the size of the text area. Other things (buttons, ...) use a similar format.
  • This allowd to better understand the button system.
  • To check the findings, reimplement the game so it can be studied while running (while keeping the original game a "black box").

Results

  • An application that is both an interpreter allowing to play the game, and a debugger to investigate how it runs.
Last modified 3 weeks ago Last modified on Apr 28, 2024, 6:34:34 PM
Note: See TracWiki for help on using the wiki.