Category Archives: Game Hacking

Sega CD Ripper

I’ve started to plunder my stash of Sega CD games for my Gaming Pathology project. To run the games with the Gens emulator under Windows it is necessary to either install ASPI drivers for accessing the game CD-ROMs in a particular manner, or rip the data and audio tracks into a particular filename sequence in order to play them directly from the hard disk. Since I couldn’t make the former work on my new machine, I proceeded with the latter option.


Sega CD unit

Gens wants the data track, i.e. ISO-9660 CD-ROM filesystem, as ‘title.iso’. Any redbook CD audio tracks after the data track need to be in the same directory, compressed as MP3, and named as ‘title 02.mp3’…’title nn.mp3’. After performing the process more or less manually for Revengers of Vengeance (I automated some parts, but had to manually rename the files in the end, and RoV has 44 audio tracks), I wrote a Python script to help me with other games (and I’m not very good at Python yet but I like these opportunities to learn).

There might be other ways, better ways, but this is my new way. The script relies on cdparanoia and LAME (oh, and dd and rm). I didn’t know any program to query a CD to learn how many audio tracks it had (except my own hacked up program and I didn’t feel like leveraging it), so I just perform a rip loop until cdparanoia returns an error. LAME is instructed to encode at its ‘insane’ profile, sparing no bitrate. Syntax is ‘./rip-sega-cd.py “game title”‘ which will produce an ISO file and a series of MP3 files if redbook audio is present:

$ ./rip-sega-cd.py "Revengers Of Vengeance"
ripping Revengers Of Vengeance
ripping data track...
/bin/dd if=/dev/cdrom of="Revengers Of Vengeance.iso"

ripping audio tracks...
/usr/bin/cdparanoia --quiet 2
/usr/bin/lame --quiet --preset insane cdda.wav "Revengers Of Vengeance 02.mp3"
/bin/rm cdda.wav

[...repeated for each redbook CD audio track...]

The Interpreter

Somewhere along the line I got sucked into this multimedia hacking field as an extracurricular activity. There are abundant specializations in the computer field that one can take up as a hobby. But other specialties that I have always been curious about got sidelined, such as 3D graphics and artificial intelligence — 2 things I have always wanted to study more carefully.

Yet another topic is that of compiler and interpreter theory. There were compiler construction elective courses in school but I honestly didn’t care back then. Let the compiler do its job; I have higher level tasks. Naturally, if I’m suddenly interested in compiler theory, there must a reason for it.

Certain computer games use (what are probably) custom scripting languages to describe the game flow and character interactions. When I study these plaintext scripting files, I find myself wondering what would be involved in writing an interpreter for such a language. One such game is Clue Chronicles: Fatal Illusion, based on the popular Clue board game (a.k.a. Cluedo).


Clue Chronicles cover

The scripting language appears to be mildly object oriented with C++-type comments (‘//’) and reliant upon a number of implicit library functions. Principally, it defines scenes with graphic backdrops and the transparent Smacker multimedia files that are to be played as animations, as well as the subtitle text that should be overlaid. At the conclusion of certain interactions, methods are called that, e.g., add an item to your inventory or a clue to your notepad.

From my computer science studies, I seem to recall something about tools named Lex and Yacc along with the GNU variants, Flex and Bison. These are supposed to be suited for the task of writing compilers and interpreters in some cases. Here is a page that discusses writing a simple interpreter using Lex and Yacc.

Here is a sample of the language:

  // ## Common Scripts ##

  //  Scarlet says, "Sorry...I don't know..."
  sc1105 = SequentialScript(Autoplay, Looping, Scripts
  (
    Cursor(Name("wait"),EnableWindows(false)),
    WaitScript(scActiveIdleAnim),
    SetState(ge(scarlet),state(scTalkState)),
    ParallelScript(Scripts
    (
      SequentialScript(Autoplay, Looping, Scripts
      (
        {scActiveStill.SetActive(false)},
        GraphicScript(Skippable,Graphic(SmackAnimation
        (
          Layer(0),
          Offset(0,50),
          File("assets\\act1\\scarlet\\sc1105.smk"),
          Looping(false), NoSkip(false),
          Transparent(0, 255, 0)
        ))),
        {scActiveStill.SetActive(true)}
      )),
      SequentialScript(Skippable,AutoPlay(true),Looping(true),Scripts
      (
        Caption(Text("Scarlet: Sorry...I don't know anything about that.")),
        Caption(Text(" ")),
        DelayScript(Seconds(3))
      ))
    )),
    Caption(Text(" ")),
    Caption(Text(" ")),
    Caption(Reset()),
    SetState(ge(scarlet),state(scActiveState)),
    Cursor(Name("default"),EnableWindows(true)),
    Dialogue(ge(scarlet))
  ))

And here is the full file (originally titled sc1.ini), which is one of many files used to drive the game: clue-chronicles-scarlet-1.txt

I’m just wondering if anyone reading this blog has the first clue about how one would go about writing an interpreter for this little language? This is not a field to which I have had extensive exposure.

Dynamic Uninteresting Movie-Based Adventure System Simulator

I’ve been suffering through a wave of interactive movie schlock for my Gaming Pathology project. This has led me to hypothesize about what I can do to help share these wretched I-movie experiences with a broader audience and even preserve this misery for future generations to revile. To that end, I have brainstormed about the Dynamic Uninteresting Movie-Based Adventure System Simulator (thanks to Cyril Z. for helping me with the expository project name).

Loosely, an I-movie is a “game” that relies heavily on pre-rendered full motion video (FMV) sequences. The sequences can be used to show transitions from one location to another or — more often than not — exhibit a marginal actor disgracing his chosen craft in order to advance the sheer confusion that passes for a storyline. Many of these so-called games also feature one or more puzzles so as not to rely entirely on one type of gameplay.

After playing through a number of these I-movie titles, I can’t help but notice certain programmatic similarities. For example, games like D and Of Light And Darkness feign immersive 3D environments with a combination of FMV files. Start at point A. Define a series of hotspots for the current scene that map to other FMV files. When the player clicks in one of those hotspots, play the next FMV file. There; that’s 90% of the game engine right there.

Internally, the games probably have a little of what might be termed a virtual machine in order to track the game’s state. At least, I postulate that it could be forced into some kind of virtual machine structure. This is used for tracking how far the player has progressed into the game, which hoops he has jumped through, and, by extension, what special things need to happen on certain screens. this would also pertain to various puzzles which are typically comprised of series of FMV files.

So here’s the pitch: A portable virtual machine in the spirit of ScummVM that knows how to interpret the data files for a variety of these I-movies and force them into a common model. This would probably entail a graph data structure describing a map and which FMV files get played when the player chooses to transition from point A to point B. Further, there would be some list of game goals to progress through. Most of these I-movies couldn’t possibly be much more involved than that. From my understanding, most of the FMV formats that these games use are already well supported by portable, open source software.

It’s just crazy enough to work. And to what end? That should be obvious– to continue humiliating the people responsible for these tarnishes on the good name of computer gaming.

A Game Each Day

I have embarked on an ambitious new project, with a new blog to match: Gaming Pathology. Remember all those games I have picked up on the cheap so I can study their multimedia? I have managed to amass in excess of 500 games. I decided that this year I would try to play one of them each day. My early focus is on games that are missing data from the MobyGames database. As vast as the database is, I still have at least 80 games out of 500+ that don’t exist in the tables at all. That fact is changing steadily.

Anyway, I thought it would be pertinent to announce the Gaming Pathology blog here since I know that this blog has readers interested in game hacking. Sometimes, my reviews on the new blog include theories or empirical evidence of the underlying technologies, algorithms, and formats that the games use.

And lots of pretty screenshots and videos as well.