First post here, so please be gentle.
I wanted to spend some time on a compressed format for a game, and to have samples of both compressed and uncompressed data, however I'm having trouble interepting the "raw" data.
Thus, I decided to grab whole VGA memory block and work backwards from there. And still, I can't interept the data :/ I'm positive, that once I can "view" the VGA dump, I would relatively easily work out everything else.
Here's what I know. Game uses Mode X, as it's 256-color 320x240. This leads to conclusion, data in VGA memory must be planar VGA. And this is where I'm at loss.
From what I read, there are 4 planes. So, I simple-mindedly attempted something like this:
Code: Select all
int x = 0, y = 0;
int plane_offset = n / 4;
for (i = 0; i < n; i += 4) {
int off = i / 4;
for (j = 0; j < 4; j++) {
char c = src[j * plane_offset + off];
put_pixel(x, y, c);
x++; if (x > width) { x = 0; y++; }
}
}
But then, I read there is also WRITE PLANE register (0x03C4), which adjust which plane is going to be written to. But here's where I'm mostly at loss, why would one need a special register? If you have offset into VGA memory anyway? And more importantly, can I just dump the VGA memory block, i.e. is it "complete", with all 4 planes, or should I iterate over each plane, set register, dump, repeat? (In other words, does A000:0000 always point to the same location, or does this location change, when you set register?)
And just if it helps, here is a blitting function (one of a several) from the game.
Code: Select all
mov dx,03C4 ; Write Plane Reg
mov ax,0F02 ; 0x02 ?? 0010
out dx,ax
mov ax,A000 ;
mov es,ax ; es= VGA mem
mov cx,8000 ; 0x8000 times
mov ax,0000 ;
mov di,0000 ; dst_offset = 0
repe stosw ; (from ds:si to es:di, cx times)
Thanks in advance!