[comp.lang.pascal] VGA

amead@s.psych.uiuc.edu (alan mead) (05/15/91)

Can anyone tell me how to cause the border area of a normal display to
have a particular color?

If possible, I'd like to do this in any video mode.

I'm using a PS2 (model 50, but if it differs by model, I'd like to know
how to do it on any) with VGA, but I'm curious about CGA, SVGA and XVGA
(etc...) displays as well.

Any help would be appreciated--pointers to books, a textual
description, or code (Pascal, ASM, or C).

If this is simple, then email would be most appropriate otherwise, perhaps
the net would be interested.

Thanks.

-alan mead : amead@s.psych.uiuc.edu

bobb@vice.ICO.TEK.COM (Bob Beauchaine) (05/15/91)

In article <1991May14.204252.5492@ux1.cso.uiuc.edu> amead@s.psych.uiuc.edu (alan mead) writes:
>Can anyone tell me how to cause the border area of a normal display to
>have a particular color?
>
>If possible, I'd like to do this in any video mode.
>
>I'm using a PS2 (model 50, but if it differs by model, I'd like to know
>how to do it on any) with VGA, but I'm curious about CGA, SVGA and XVGA
>(etc...) displays as well.
>

  Well, my _Programmer's_Guide_to_the_EGA_and_VGA_cards_ tells me 
  this.

  The border area color is controlled by the Overscan register (one of
  the VGA / EGA attribute control registers.).  This register is 
  indexed as port 11 hex from the base address of 3C0 hex.  To access
  this port, you write 11 hex to port 3C0 to indicate which of the 
  available ports is to receive the next byte.  The following byte
  of information written to port 3C0 hex will be directed to the 
  Overscan register.
   
  The overscan register is laid out as 6 bits as follows :
  
     5    4   3  2  1  0  (bit)
    SR   SG  SB  R  G  B

    where   SR = secondary red
	    SG = secondary green 
	    SB = secondary blue 
	     R = primary red
	     G = primary green
	     B = primary blue

  I won't go into detail about color mixing here, but will note that
  this register uses the same color coding scheme as the palette 
  registers use for normal video.


  A Turbo Pascal code fragment to modify this register would be:
      
      const overscan_reg_base = $3C0;
	    overscan_reg_index = $11;

      var color : byte;

      .
      .
      .

      port[overscan_reg_base] := overscan_reg_index;
      port[overscan_reg_base] := color;
      .
      .
      .

/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ 

Bob Beauchaine bobb@vice.ICO.TEK.COM 

C: The language that combines the power of assembly language with the 
   flexibility of assembly language.

   "It seems that the less a statesman amounts to, the more he appears

dj@ctron.com (DJ Delorie) (05/15/91)

In article <1991May14.204252.5492@ux1.cso.uiuc.edu>, amead@s.psych.uiuc.edu (alan mead) writes:
> Can anyone tell me how to cause the border area of a normal display to
> have a particular color?

I've done this, but it's UGLY.  Why? The EGA/VGA/SVGA scan so fast
they don't have time to let the scan reach the edge of the CRT before
pulling it back.  Thus, when the scan is enabled during these times,
you don't see a colored border, you see the retrace process instead.  In
order to get it close, you have to reprogram the CRTC registers, and
it's neither trivial nor reliable (aka portable).

DJ
dj@ctron.com

danr@bcsfse.boeing.com (Dan Richardson) (05/16/91)

Seems to me that Peter Norton talks about this in Programmer's Guide to the IBM
PC. I've done this myself in text mode with a screen handler that I wrote a few
years ago. It's an interrupt 10 call, I believe. But know that it really shows
up in modes with less than optimum resolution. Let's see...I think that 640x200
(graphics mode) can do it, but I could be mistaken. Setting the border color on
a CGA card (Eeeeek!) is pretty easy, but my poor eyes could never take the grainy
resolution. Setting a border color on an EGA or higher card gives a very slim 
border (at least on my Paradise-clone card) and really isn't worth fiddling with.

For what it's worth...

--------------------------------------------------------------------------------
Dan Richardson                  | "If there's anything more important than my
Analysts International Corp.    |  ego around here, I want it caught and shot
for Boeing Computer Services    |  now!"    --Zaphod Beeblebrox
--------------------------------------------------------------------------------
"My opinions are not necessarily those of my clients or my employers."
================================================================================