[comp.os.msdos.programmer] Small utility to disable VGA border

mmshah@athena.mit.edu (Milan M Shah) (03/04/91)

I got sick of the silly border (overscan) color feature of the VGA. Its
epsecially annoying because I use a 'dos shell' to execute programs, and this
always screws up the border color for a very disturbing look. So, after a lot
of hacking, I have come up with a small (29 bytes when assembled!!) program
that disables the border color altogether (ie, its always black). Of course,
there's a catch. It works *only* on a Paradise VGA 1024 card based on the
PVGA1B or Western Digital WE90C00 chipset. (from what I know, any card that
is a Paradise / paradise clone made after 1986). Here is the assembly source
for it.

;*****************************************************************************
;
;Author : Milan Shah
;Date   : 3/3/91
;Program to disable the border color on Paradise 1024 cards based on the
;Western Digital WD90C00 / Paradise PVGA 1B chipset
;
;*****************************************************************************

_TEXT          SEGMENT PUBLIC 'CODE'
               ASSUME  CS:_TEXT,DS:_TEXT
               ASSUME  ES:_TEXT,SS:_TEXT

                    ORG       100H
START:              jmp       main

;*****************************************************************************
;
; The following code was pieced together with information from 'Advanced
; Programmer's Guide to Super VGAs' by George Sutty and Steve Blair, Brady
; Books, Simon and Schuster.
; Relevant information:
;    I/O port 3CEh is the index register and I/O port 3CFh is the data
; Relevant information:
;    I/O port 3CEh is the index register and I/O port 3CFh is the data
;    register for the Graphics Controller. Index 0Fh of this file is to be set
;    to 05h to unlock extended registers. In addition, index 29H of the
;    CRT Controller (Index at 3D4h, data at 3D5h) must be set to A5 to
;    access indexes 2Ah - 30h of the CRT Controller registers. Index 2Eh of
;    the CRT controller registers is Misc. Control 1. Bit 0 of Misc. Control
;    1 disables the border.
;
; To address index i of register file located at I/O port XXXh, first write
; out the index at XXXh, then read or write the data at XXX+1h. Can combine
; the two operations for a write by sending out the word dih to XXXh. Thus
; writing 050Fh at port 3CEh selects index 0Fh and writes 05h into the
; register at that index.

MAIN:               mov  dx,03CEh       ;Extended Register Locking register
                    mov  ax,050Fh       ;Index 0Fh, data 05h
                    out  dx,ax          ;unlock extended registers
                    mov  dx,03D4h       ;Port address of Misc. Control1 Reg.
                    mov  ax,0A529h      ;Unlock extended reg index 2A-30h
                    out  dx,ax
                    mov  al,2Eh         ;Index 2Eh is Misc. Control Reg 1
                    out  dx,al          ;Tell PVGA we want to access it
                    mov  al,2Eh         ;Index 2Eh is Misc. Control Reg 1
                    out  dx,al          ;Tell PVGA we want to access it
                    mov  dx,03D5h       ;Get existing data in Misc Control 1
                    in   al,dx
                    or   al,01h         ;Disable the Border bit
                    out  dx,al          ;Write Misc. Control 1 data
                    int  20h            ;Done

_TEXT               ENDS

END  START

I assembled it with Tlink /t. Works like a charm on my machine (clone paradise
1024 card purchased about 2 years ago).

If there's any interest, I can put the .com file somewhere.

Milan
.

amead@s.psych.uiuc.edu (alan mead) (03/04/91)

In comp.os.msdos.programmer you write:

>...
>; The following code was pieced together with information from 'Advanced
>; Programmer's Guide to Super VGAs' by George Sutty and Steve Blair, Brady
>; Books, Simon and Schuster.

Very interesting.  I'm looking for good books on VGA graphics and
optical disc technology.  I'm programming in Turbo Pascal but assembly
or C would be OK if they are easy to follow.  I am definitely a novice
at graphics although I am rather knowledgable about text display and
other system features.

Have you (or anyone else) any other recommendations?  Thanks.

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

swh@hpcupt1.cup.hp.com (Steve Harrold) (03/05/91)

Re: Removing the VGA border color

Try this 2-line C program:

#include <stdio.h>
main() { puts ("\x1b[50m") ; }

Assembler gurus will want to translate this to a very short equivalent 
ASM source code.

This works only if ANSI.SYS or its equivalent is present.
BUT it is screen-hardware independent!!!

mmshah@athena.mit.edu (Milan M Shah) (03/06/91)

>Try this 2-line C program:

>#include <stdio.h>
>main() { puts ("\x1b[50m") ; }

Yes, but you misunderstand the intend of my asm program. 
I am faced with this situation:
My normal DOS colors are black letters on white background (ok, you can quit
laughing any day now :-) This is done by setting the prompt to an ansi sequence
that changes colors, and works quite well. Now, when I execute certain programs
for example foxbase, windows etc., all of a sudden my border color gets set to
white. Hence the problem is not how to execute a program that turns off the 
border or sets it to some color, but how to prevent the border color from
being changed even if someone tries to set it to a different color. 

My program will work on a Paradise VGA 1024i, and after you run it once, 
even if someone tries to set up the border color, the border will not be 
affected. One might wonder where I ever got software that manipulates the
border color. Well, none of the programs I use manipulate the border color,
but what happens is that upon entry/exit, DOS sets the border color to  
whatever was the background color before. If your background is black, there's
no problem, but if its not, its quite sinister.

Milan
.