• Please review our updated Terms and Rules here

Setting the VGA border/overscan color.

PgrAm

Experienced Member
Joined
Sep 28, 2011
Messages
276
Location
Toronto, Canada
Hi all,

I've noticed that all VGA card's I've tried seem to set their border color to palette index zero. I'd like to set the border color in my game to black however for various reasons I'd prefer to use palette index 0 for something other than black. Black is still in my palette it's just not at index zero. I'm using 256 color mode X.

does anyone know a portable way to set the border color across different VGA cards?
 
I think you want attribute controller register 0x11. Here's some code:

Code:
  mov dx,0x3da  ; Input status register
  in al,dx ; Reading from this register resets attribute controller address/value flip-flop
  mov dl,0xc0 ; Set dx to 0x3c0 == attribute controller port address
  mov al,0x11 ; Register number for overscan colour
  out dx,al  ; Set attribute address number
  mov al,0xff ; The colour you want for overscan (index into external palette)
  out dx,al  ; Set attribute controller data register

I have no idea if there are clone VGA cards that omit this feature, but it's a standard part of IBM VGA and at least some clones if not all.
 
I wasn't able to get your code working on my Trident card, perhaps I'm missing something. When I use the code above it seems to set the entire screen to the color specified and not just the border.

EDIT: I did find something that did work

Code:
mov ax, 0x1001
mov bh, 0x02 ;sets border color to index 2
int 0x10

not sure if this is portable though. From everything I've read this is supposed to take a 6bit rgb value. On my VGA card it seems to work with indices. I suppose this was initially intended for EGA.
 
Last edited:
I wasn't able to get your code working on my Trident card, perhaps I'm missing something. When I use the code above it seems to set the entire screen to the color specified and not just the border.

It's possible my code is broken - I didn't actually try it. I can't think why it would be setting the entire screen to that colour though. It may just be that your card isn't compatible with IBM VGA at the register level.

EDIT: I did find something that did work

Code:
mov ax, 0x1001
mov bh, 0x02 ;sets border color to index 2
int 0x10

not sure if this is portable though.

Oh, right - I should have thought of that. It is probably more portable that than the register access method. I'm too used to programming the hardware directly...

From everything I've read this is supposed to take a 6bit rgb value. On my VGA card it seems to work with indices. I suppose this was initially intended for EGA.

Yes. Essentially they are equivalent - the 6-bit rgbRGB values on EGA correspond to the "external" DAC palette entries on VGA. VGA just has an extra level of indirection on the card instead of a fixed translation from bits to colours in the monitor.
 
not sure if this is portable though. From everything I've read this is supposed to take a 6bit rgb value. On my VGA card it seems to work with indices. I suppose this was initially intended for EGA.

Using the BIOS is always the most portable method, and you're doing it correctly. I'm not sure what you've read, but the BIOS interface is fairly straightforward and has never taken an exact color value for this function, only an index number.

Nothing says you have to "fix" the border color -- those with analog VGA monitors may like to see it change :)
 
Back
Top