Petri Häkkinen Profile picture
May 11 19 tweets 5 min read Read on X
Reversing Bloodfest Part 2: The MYSTERY of *.IM Files! A thread🧵 Image
Last time we cracked the main graphics and sound effects banks. Unfortunately these do not contain the fullscreen background images such as the glorious title and game over screens.

Most likely the screens are stored in these pesky *.IM files that we failed to decode last time: Image
I think the screens cannot be found by scanning memory dumps because they are very likely dynamically loaded and unpacked only when needed. A 320x256 image with 32 colors (5 bitplanes) is about 50 KB. It would simply have been too costly to keep them in memory all the time.
When I looked at the sample banks it looked like data files were encypted with something simple like XORring the bits. But is that really the case? Let's take a closer look...
We already know that *.IM files were compressed with Turbo Imploder 4.0. After unpacking here's how they look like. This is gfx/stargate.im. All other im files in gfx folder have a similar beginning. Image
The large amount of zeroes and the curious 12031990 in the beginning make me think this data is not scrambled.

Hmm... 12031990? 12th March 1990? That's too much of a coincidence!
I bet that number must mean something. It cannot be just some random scrambled bits. Especially since AMOS was created around that time... Let's look into the AMOS Professional manual once more and see if we can find any clues...
Bingo! It’s a magic number indicating a packed screen. Image
So we have a packed file inside a packed file! That's probably not very good for compression, but ehh...

Luckily the manual says it's created with SPACK instruction in AMOS and that it can be unpacked with UNPACK instruction. Let's try that next.
This must work right?
Result: a black screen. Bummer!

Hmm, the other graphics files had broken palettes. Maybe the zeroes in the unpacked IM file are supposed to be the palette but it has been zeroed out?
Let's try to override the palette with some random colors. Whoah! It's working! Image
I have a theory. Fading! AMOS simply uses the palette as is from the file. So if the palette was there, the image would appear fully faded in initially. The code must fade in the correct palette after unpacking. Which also means the palette is probably stored directly in the exe.
Typing "Palette $000,$EEF,$AAD,$227,$D95,$B73,$A62,$942,$831,$731,$621,$510,$400,$300,$200,$100,$CCC,$AAB,$99A,$779,$558,$447,$336,$225,..." brought back memories of taking turns with a childhood friend and typing in C64 programs from Mikrobitti magazine on a summer day. Image
That's it. The mystery of the IM files has been finally solved. Phew! But one thing remains... "12031990"?
There’s another file format described in the AMOS manual with a similar header. So it IS a date code! Francois Lionet is the author of AMOS. March 12th 1990 must be a very important date to him. (Or is it December 3rd 1990? The conventions differ across the world.) Image
There’s this interesting section about the history of AMOS in the book. Francois was in the French army in 1990 so maybe something important happened there? Or maybe he got married on that date? ”Baby Lionet” was born in 1992 which could support that theory. Image
Does anybody know? It would be very interesting to know, AMOS having had such an impact on my career and life.

And so we come to the end of the thread. Thanks for reading!
P.S. How did I get the palette for that stargate image? I forgot to mention earlier... I cheated a bit (again) and grabbed it using WinUAE by dumping the video registers.

Below's a reward to you for getting this far into the thread. RRRRAAGGH!! 👋 Image

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Petri Häkkinen

Petri Häkkinen Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @petrih3

May 9
Trying to reverse my own game, Bloodfest for the Amiga. The game was released 29(!) years ago. I've lost source code and assets a long time ago... A thread! Image
First things first. I downloaded the game from Aminet. Files were archived with LHA which was a very common packer on the Amiga. List of files after unarchiving: Image
The game was written using AMOS Professional. AMOS was a full blown IDE for making games for the Amiga, similar to Pico8 today. But instead of Lua, AMOS used a custom dialect of BASIC which could be compiled to 68k machine code using AMOS Compiler (a seperate product).
Read 42 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us!

:(