VOGONS


First post, by subjugator

User metadata
Rank Newbie
Rank
Newbie

Hi guys,

For nostalgia's sake I have decided to implement Black & White monitor support for DosBox 0.74 ( I remember my old days with a XT clone with B&W CGA). It is very crude at this stage as I manipulate palette values in the RENDER_SetPal function before outputing data to the screen, but it works and requires minimal changes to the source code.

For this I have implemented a new parameter under [render] section called bwmonitor. When set to false it will produce normal color pictures, setting it to true will alter palette to look black and white. The one benefit of this approach is that it is machine agnostic and will work with all display types.

Here are the changes:

In render.cpp

Under RENDER_Init(Section * sec)
{
render.bwmonitor=section->Get_bool("bwmonitor");
}

void RENDER_SetPal(Bit8u entry,Bit8u red,Bit8u green,Bit8u blue)
{

if (render.bwmonitor)
{
render.pal.rgb[entry].red=static_cast<Bit8u>(red*.2+green*.3+blue*.5);
render.pal.rgb[entry].green=static_cast<Bit8u>(red*.2+green*.3+blue*.5);
render.pal.rgb[entry].blue=static_cast<Bit8u>(red*.2+green*.3+blue*.5);
}
else
{
render.pal.rgb[entry].red=red;
render.pal.rgb[entry].green=green;
render.pal.rgb[entry].blue=blue;
}

if (render.pal.first>entry) render.pal.first=entry;
if (render.pal.last<entry) render.pal.last=entry;
}

In render.h under Render_t typedef add
bool bwmonitor;

In dosbox.cpp under DOSBOX_Init

Pbool = secprop->Add_bool("bwmonitor",Property::Changeable::Always,false);
Pbool->Set_help("Sets B&W monitor mode, false for color, true for monochrome");

In dosbox.conf

# bwmonitor: Scaler used to enlarge/enhance low resolution modes.
bwmonitor=true

I am sure there are far more elegant solutions and more accurate, but it seemed to satisfy my nostalgia fix. Any suggestions to improve this are much appreciated.

Here are some screenshots.

Reply 1 of 4, by ripsaw8080

User metadata
Rank DOSBox Author
Rank
DOSBox Author

Where did you get the RGB weights? If you go by the Wikipedia article on grayscale, maybe something like:

   if (render.bwmonitor) {
Bit8u luma=(Bit8u)(red*0.30+green*0.59+blue*0.11);
render.pal.rgb[entry].red=luma;
render.pal.rgb[entry].green=luma;
render.pal.rgb[entry].blue=luma;
} else {

Reply 2 of 4, by subjugator

User metadata
Rank Newbie
Rank
Newbie

Thanks for that.

Frankly I just pulled them from thin air, experimenting till I thought it looked right. I will change code using your provided weights.

Reply 3 of 4, by subjugator

User metadata
Rank Newbie
Rank
Newbie

Yep, looks much better now. Here are the new screens. Thanks for the link.

Reply 4 of 4, by h-a-l-9000

User metadata
Rank DOSBox Author
Rank
DOSBox Author

For monochrome VGA monitors, games that use the BIOS to set the DAC palette use the gray scale summing feature that is already available in DOSBox iirc, for those that directly write to it it's luma=green.

1+1=10