VOGONS


First post, by fuxx

User metadata
Rank Newbie
Rank
Newbie

Hi,
please excuse my horrible english. If i posted this question to wrong place please excuse me too.

I extracted several screens from old DOS game which runs in EGA mode 0xd (320x200x16) and game palette table. This game runs in DOSBox well.

Those screens are just dumps of all four color planes of ega screen in mode 0xd. I can convert and dump those screens to BMP file. The picture is correct, but i can not figure out how to convret game palette to modern 24bit colors. The game uses bios int 0x10 to set palette, but i wrote my own conversion routine. But my algorithm gives me wrong colors.

I briefly scanned DOXBox sources but can not figure out where does palette is converted to dosbox screen colors. I believe this code could help me. But was not able to find one.

In case you interested how i do color conversion, here is my algorithm:

  /* xxrgbRGB scheme */
r = 0x40*(((dc & 0x20) >> 5)&1) + 0xb0*((((dc & 0x04) >> 2)&1));
g = 0x40*(((dc & 0x10) >> 4)&1) + 0xb0*((((dc & 0x02) >> 1)&1));
b = 0x40*(((dc & 0x08) >> 3)&1) + 0xb0*((((dc & 0x01) >> 0)&1));

variable dc here is dos color. This code is based on assumption that bits 7 and 6 aren't used, 5-3 are lowintensity rgb bits of color, and 2-0 are hi intensity RGB bits.

If someone is able to help me to find color conversion code in DOSBox, or can give me correct conversion algorithm, or point to right manual, or even simply show bug in my code, i will be greatly appreciated.
---
Thank you in advance,
Serge

Last edited by fuxx on 2005-11-12, 15:06. Edited 1 time in total.

Reply 1 of 8, by Qbix

User metadata
Rank DOSBox Author
Rank
DOSBox Author

Let me get it straight

you want to convert the image which is in the video memory to a bmp ?
The game you are talking about is a mode 0xd game (16 colours)
(you know dosbox can make screenshots with ctrll-f5 ? )

Some pointers:
VGA_Draw_4BPP_Line in hardware vga_draw.cpp : draws 16 colours (it does it by writing pallette values).
The pallete itself is set via int10 to the video card in the file hardware/vga_attr.cpp

Water flows down the stream
How to ask questions the smart way!

Reply 2 of 8, by fuxx

User metadata
Rank Newbie
Rank
Newbie

>> you want to convert the image which is in the video memory to a bmp ?
Nope. I take image from file show it to screen, сonvert it to bmp and so on...
>> The game you are talking about is a mode 0xd game (16 colours)
Yes.
>> you know dosbox can make screenshots with ctrll-f5 ?
Yes i know. But i does not need this. I plan to start remake of this game, capable of playing with original data, so i try to figure out data formats and basic parameters.

>> VGA_Draw_4BPP_Line in hardware vga_draw.cpp : draws 16 colours (it does it by writing pallette values).
>> The pallete itself is set via int10 to the video card in the file hardware/vga_attr.cpp
Ok, thanks. I partially fixed problem with color conversion.

There still is mysterious thing: game palette has entry for white color which sets five of six color bits to 1: 0x1f. When i convert it with my routine it looks like wery bright cyan (because here one red bit missing). When i run game under Dosbox white looks like white. First i thought they reprogrammed videocontroller somehow, but if i add one red component to all colors picture looks worse than before. Can not figure out reasons for that and find solution :-/

Reply 4 of 8, by fuxx

User metadata
Rank Newbie
Rank
Newbie

> Do they change the palette (through int10 or by reprogramming
the DAC or attr regs)? Or does it use the standard pal set up
by the video mode change?
They change palette through int 10h. Here is palette extracted from the game:

static Uint8
dos_color_table[16]=
{
0x00, 0x01, 0x02, 0x03,
0x04, 0x05, 0x06, 0x07,
0x18, 0x19, 0x1a, 0x1b,
0x1c, 0x1d, 0x1e, 0x1f
};

As you can see top half of palette defines colors without one red bit. The misterious thing here is that colors look correct in dosbox and without emulation. But since my conversion routine expects red here half part of palette in converted pictures lacks red. Low eight colors looks good.
> Also what game is it?
The game in question is Dangerous Dave in tht Haunted Mansion.