VOGONS


First post, by zerker

User metadata
Rank Member
Rank
Member

So a little while ago I converted some images to the CGA color palettes for fun. Now, I'm playing around with DOS programming (via Open Watcom C) and wanted to draw these bitmaps in real hardware. That part works fine.

The problem I'm having is that I can't seem to change to the Brown/Green/Yellow color palette. I've downloaded the old IBM CGA Options and Adaptors manual, as well as located a decent CGA information page.

Looking at the CGA manual, it implies that setting 0 to bit 5 at address 0x3D9 should change to the desired palette. But the following has no effect for me:

regs.h.ah = 0x00;
regs.h.al = 0x04;
int86(0x10,&regs,&regs);
outp(0x3D9, 0x00);

The information page implies that video mode 5 has an alternate palette on an RGB monitor, but I still get Cyan when I do the following:

regs.h.ah = 0x00;
regs.h.al = 0x05;
int86(0x10,&regs,&regs);

I've heard information that it's a bit different when using EGA or VGA cards, but I can't find anything more concrete than that. I would have expected that if I was do it the 'proper' way, it would still be compatible. Pharoah's Tomb and Monuments of Mars don't revert to the cyan palette on a VGA card after all.

EDIT: I also found information on the "Set Color Palette" Video BIOS service, but I can't get it to work either. Here's what I tried there:

regs.h.ah = 0x00;
regs.h.al = 0x04;
int86(0x10,&regs,&regs);
regs.h.ah = 0x0B;
regs.h.al = 0x00;
int86(0x10,&regs,&regs);
Last edited by zerker on 2018-03-17, 16:13. Edited 2 times in total.

Reply 1 of 4, by VileR

User metadata
Rank l33t
Rank
l33t

You didn't mention what video adapter you're using. That code should work on an actual CGA, but EGA/VGA aren't register-compatible. Some models have their own utilities to help with that.
You should probably download the CGA Compatibility Tester and run it on your card, see what you get with the medium-resolution color palette tests.

For what it's worth, I recently tried Monuments of Mars on a real CGA, and got the cyan-magenta-white palette instead of the expected red-green-brown. So it wasn't aimed at (or tested with) real CGA cards after all.

[ WEB ] - [ BLOG ] - [ TUBE ] - [ CODE ]

Reply 2 of 4, by zerker

User metadata
Rank Member
Rank
Member

It's a later SVGA card (Voodoo 3), so it's operating on whatever compatibility it has. I figured it wasn't fully register compatible, but I'm trying to try every possibility I can find in order to actually find what DOES work on a EGA/VGA/later card.

I'll try out that tool and see what works. I see source code is available; that will be a huge help assuming I can switch palettes at all.

EDIT: Nevermind, that program uses only register access that I can tell. As such, I only get cyan/magenta.

EDIT #2: I couldn't read very well, and have since figured it out. I was supposed to be using registers bh and bl with the set palette bios function. The correct snippet is:

regs.h.ah = 0x00;
regs.h.al = 0x04;
int86(0x10,&regs,&regs);
regs.h.ah = 0x0B;
regs.h.bh = 0x01;
regs.h.bl = 0x00;
int86(0x10,&regs,&regs);
Last edited by zerker on 2018-03-17, 17:02. Edited 1 time in total.

Reply 3 of 4, by VileR

User metadata
Rank l33t
Rank
l33t

Yep, that's the point of the compatibility tester- it only uses registers to determine your card's register-level CGA compatibility.

If you're already doing it through the BIOS, you have more flexibility: see Int 10/AX=1000h. In a CGA mode on a better-than-CGA adapter, this lets you set any of the four colors (palette registers 00 through 03) to anything you want. That means you can emulate the "alternate palette" of CGA video mode 5, which isn't available through INT 10h/AH=0Bh (but of course, you can come up with your own custom palettes as well). 😀

[ WEB ] - [ BLOG ] - [ TUBE ] - [ CODE ]

Reply 4 of 4, by reenigne

User metadata
Rank Oldbie
Rank
Oldbie

Try doing an INT 0x10 with AH = 0x0b, BH = 1 and BL = 0. I'm not sure if all EGA/VGA cards support this, but I think at least some do.

Even if your card's BIOS doesn't handle this call, you can still switch palettes by setting the internal palette registers (EGA/VGA) or external DAC palette (VGA). These methods won't work on CGA, but by writing to both port 0x3d9 and the internal palette registers you can make a palette switching routine that will work on all cards.

Btw, the alternate palette in BIOS mode 5 on RGBI is red/cyan/white, not red/green/brown. On composite output this makes the image monochrome (and suppresses the color burst, which causes some monitors to make the image very bright and/or have random, oversaturated colours).