[comp.lang.pascal] SOLUTION: need to change border color

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

Thanks to all who helped me with changing the border color.  I was 
directed towards and found BORDER.ZIP in /mirrors/msdos/screen on
wuarchive.wustl.edu.  BORDER.ZIP has C & ASM source and executable,
but it was pretty simple stuff and I needed to use it from a Turbo
Pascal program, so here is my pascal version.  It uses BIOS function
$0B, so it should be relatively compatible.

In case it's not obvious, the four lines marked {*} is where the border
color gets changed (ie, those four are what you would need to put into
your code).

Thanks again.

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

--------------

program change_border;

uses dos;

(***************************************************************************

                 BORDER

                 A utility to set the border colors of
                 CGA and compatible displays.

                 Originally a C driver for the following
                 ASM code available in the package
                 BORDER.ZIP (from eg, SIMTEL).

                 I wrote both parts into Turbo Pascal
                 (any version greater than 2 ought to work).

                 Hope this helps.

                 -alan mead <amead@s.psych.uiuc.edu> 05/18/91


;--------------------------------------------------------------------
;	This is a C callable function which uses the BIOS to
; change the hardware border on a video display.
;
; Written By: Gary L. Hennigan <ghenniga@NMSU.Edu>
;	      New Mexico State University
;	      Las Cruces, NM
; Date: 11/30/90
;
; Note that I use Turbo Assembler's simplified segment directives
; and stack frame addressing conventions so this code will not
; compile properly under MSASM.
;--------------------------------------------------------------------
; Variable Used:
;	      	brd_color (int) -  The border color to change to.
;--------------------------------------------------------------------
; Pre-processor Equates
;
	BIOS_INT	EQU	10h
	BIOS_CC		EQU	0Bh
;--------------------------------------------------------------------
; Set up the segments with Turbo's simplified segment directives
;
	DOSSEG
	.MODEL SMALL
	.DATA
	.CODE
	PUBLIC	C bord_change

bord_change PROC
	ARG brd_color:WORD
	push	bp
	mov	bp,sp
	mov	bx, brd_color
	mov	ah, BIOS_CC
	int	BIOS_INT
	pop	bp
	ret
bord_change ENDP
	END

**************************************************************************)

const
  BIOS_CC = $0B;
  BIOS_INT = $10;
  MaxColors = 15; { this is CGA compatible, VGA goes to 63? }

var
  regs          : registers;
  s             : string;
  color,
  err           : word;

  procedure Usage( ExitCode:word );

    begin
      writeln( ' BORDER                     by Gary L Hennigan <ghenniga@NMSU.edu>' );
      writeln( '       Turbo Pascal version by Alan D Mead <amead@s.psych.uiuc.edu>' );
      writeln;
      writeln( 'BORDER n' );
      writeln;
      writeln( '     where n is an integer greater than -1 and less than ',MaxColors+1 );
      Halt( ExitCode );
    end;

begin
  if ParamCount <> 1 then
    Usage( 1 )
  else
    begin
      s := ParamStr( 1 );
      val( s,color,err );
      if ( err <> 0 ) OR ( color<0 ) OR ( color>MaxColors ) then
        Usage( 2 );
      fillchar( regs, SizeOf( regs ),#0 );   {*}
      regs.Ah := BIOS_CC;                    {*}
      regs.BX := color;                      {*}
      intr( BIOS_INT,regs );                 {*}
    end;
end.