Exploring the Dune files – The Image files

After I figured out the HSQ compression, I started to look into the image files. Something I thought would be relative easy as there was, as with the HSQ compression, code to study. But the code bits I found were incomplete and in some cases wrong. To fill in the gaps I had to do some investigation of the image data myself and in the end, partly reverse engineer the Dune executable.

I still haven’t figure out all the parts of in the files I have studied so far. But I feel like it is time to write a new post about the subject and I would like to shift my focus to other parts of the game.

In this blog post I will go through which files I have been studying and their general layout. In later posts I will go into the various parts in detail and lastly I will write a post about how I managed to gathered all this information.

But firstly, I would like to give credit to the initial sources I used when I got started: bigs.fr and Dune Revival.

The files

In this and the following post, the files I call image files are listed below. I have included information on which various parts they contain too. All parts will be described below.

FileDefault paletteImagesTrans. rectangles Animation instructionsAlt. PalettesUnknown part
ATTACK.HSQYes5213
BACK.HSQYes9
BALCON.HSQYes811
BARO.HSQYes49Yes
BOOK.HSQYes16
BOTA.HSQYes101
BUNK.HSQYes20
CHAN.HSQYes352Yes
CHANKISS.HSQYes2
COMM.HSQYes42
CORR.HSQYes12
CREDITS.HSQYes52
CRYO.HSQYes7
DEATH1.HSQYes261
DEATH2.HSQ22
DEATH3.HSQ34
DUNES.HSQ20
DUNES2.HSQ816
DUNES3.HSQYes188
EMPR.HSQYes3710Yes
EQUI.HSQYes11
FEYD.HSQYes38Yes
FINAL.HSQYes6
FORT.HSQYes91
FRESK.HSQYes8
FRM1.HSQYes805Yes
FRM2.HSQYes7611Yes
FRM3.HSQYes10121Yes
GURN.HSQYes3321Yes
HARA.HSQYes30Yes
HARK.HSQYes283Yes
HAWA.HSQYes269Yes
ICONES.HSQ761
IDAH.HSQYes34Yes
INTDS.HSQYes11
JESS.HSQYes293Yes
KYNE.HSQYes58Yes
LETO.HSQYes2916Yes
MIRROR.HSQYes3
MOIS.HSQYes14Yes
ONMAP.HSQYes155
ORNY.HSQYes45
ORNYCAB.HSQYes1
ORNYPAN.HSQYes6
ORNYTK.HSQYes23
PALPLAN.HSQ7
PAUL.HSQYes272Yes
PERS.HSQYes2016
POR.HSQYes47
PROUGE.HSQYes13
SERRE.HSQYes14
SHAI.HSQYes4411
SHAI2.HSQ173
SIET0.HSQ11
SIET1.HSQYes64
SKY.HSQ833
SMUG.HSQYes4511Yes
STARS.HSQYes611
STIL.HSQYes2611Yes
SUN.HSQ1
SUNRS.HSQYes86
VER.HSQYes7
VILG.HSQYes321
VIS.HSQYes6

The file parts

As you can see in the list above, no non-image part exist in all image files. They only have the image parts in common. The non-image parts are briefly explained as:

  • Default palette: The color definitions used by the images in the file. If this part is missing the game will use the colors already loaded into memory.
  • Transparent rectangle: Basically an image part that when processed will result in an transparent image. I have found that some of them are used in animations. Together with animation instructions they will mark out an area to copy from one Image buffer to another. It is possible that some transparent rectangles have other purposes.
  • Alternative palette: Additional palette for the game to use. For example they are used to give the various stages of the day different environment colors and for animation effects.
  • Animation instructions: Data for how to construct animations from the images in the file.
  • Unknown parts: I still have three files that I have not fully deconstructed yet. Looking at the bytes they look like three distinct parts, but I have yet to verify that.

The general file layout

All files will start with two bytes that is the offset to where an array of part offsets is located in the file (That and all numbers in the files should be read as little endian.)

Between that initial word and section of part offsets is where the default palette will be if defined. All files without a default palette will start with a word with the value of 2.

The Part Offsets section is an array of word sized offsets. Each offset defines the distance from the start location of the array to the start of the part. This means to get the location of one part, the offset found at the start of the file should be added to the offset found in the array.

The first 96 bytes from FORT.HSQ

For example, to find the start of the first part in the file fort.hsq:

  • Read the first word, 0x0038
  • Use that value to find start of array and read the first word of it, 0x0014.
  • Add both values to get the offset of the first part, 0x0038 + 0x0014 = 0x004C.

To find the second part, add the second word of the array instead: 0x0038 + 0x001E = 0x0056.

The length of the array is not defined. Calculate the offset of the first part to find where the array ends.

The array will always start on an even number. This is to make the array “word aligned” in memory. The old x86 systems could read two bytes at the same time, but only if the first byte was on an even address. So making sure word values would be properly aligned in memory was a way to give the game a performance boost.

Next

That’s it for this post. Next time I’ll go through how the palettes are structured. /Henrik

Be the first to comment

Leave a Reply

Your email address will not be published.


*