Old DOS / Amiga CD32 image formats

Programming, for all ages and all languages.
Post Reply
User avatar
Creature
Member
Member
Posts: 548
Joined: Sat Dec 27, 2008 2:34 pm
Location: Belgium

Old DOS / Amiga CD32 image formats

Post by Creature »

Hey

Purely for educational purposes, I'm studying the images of an older DOS-game (which originated from the Amiga CD32) and am trying to display the images in an OpenGL-based application. The image I'm trying to load is 64768 bytes long and I'm fairly sure it's a 320x200 image. After examining the file with a hex editor, I found out that the first 768 bytes define the palette of the images (256 times 3 bytes for RGB colors, making a 24-bit color per index) and the remaining bytes are the image data (320 * 200 = 64000 with each byte being an index into the palette, there is no header). It took me a couple of days to figure most of this out but when I finally got the image on-screen, I noticed it was duplicated several times as smaller versions (i.e. I got the same image 4 times vertically as 320x50 images instead of one large 320x200 image). I did some research and found out that some older image formats use things like striping, tiling as well as bit planes. I wanted if someone is familiar with this kind of format and could tell me how one goes about combining these images into one larger image? I have the final 320x200 image as reference and have tried several ways of merging the smaller versions together (using specific bits of each part, linearly adding them together, etc.), but it seems I'm shooting in the dark and just not finding the right combination.

PS: A "strange" observation I've made is that if I just display the palette colors as indicated in the file, each of the four replica's is too dark. But if I add these four colors together, the brightness is correct, but the positions of the pixels never are and this only gives me 1 pixel rather than 4 of course.

Anything you guys might know about these kind of image formats may be helpful, as I said I'm not very familiar with older consoles and their programming practises.

Thanks in advance,
Creature
When the chance of succeeding is 99%, there is still a 50% chance of that success happening.
linguofreak
Member
Member
Posts: 510
Joined: Wed Mar 09, 2011 3:55 am

Re: Old DOS / Amiga CD32 image formats

Post by linguofreak »

From your description, I'm thinking the images are probably meant to be dumped more or less straight to a VGA card.

The "too dark" issue probably comes from the fact that VGA uses a 18-bit (not 24-bit) palette: only the low 6 bits of each byte are used by the image, so white is 0x3f3f3f, not 0xffffff.

The "four subimages" issue comes from the fact that VGA doesn't use a linear screen buffer, but rather divides things up into four planes. So the mapping of image pixels to screen pixels is something like:

Code: Select all

Screen     Image
0          0
1          16000
2          32000
3          48000
4          1
5          16001
...         ...
User avatar
Creature
Member
Member
Posts: 548
Joined: Sat Dec 27, 2008 2:34 pm
Location: Belgium

Re: Old DOS / Amiga CD32 image formats

Post by Creature »

I can't believe it's as simple as this! I've been searching for almost a week now and had tried adding the pixels as rows vertically rather than horizontally, taking specific bits of the pixels, etc. but no solution seemed to work. The 24-bit to 18-bit change only took a simple multiplication in the conversion code and it works now, thanks a lot :).
When the chance of succeeding is 99%, there is still a 50% chance of that success happening.
Post Reply