home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / TURBOPAS / BORDER.ZIP / BORDER.PAS
Encoding:
Pascal/Delphi Source File  |  1985-12-28  |  3.0 KB  |  75 lines

  1. (*
  2.    This procedure allows the programmer to set the border color on the IBM
  3.    Color Display from within Turbo Pascal.  It seems odd to me that Turbo
  4.    provides TextColor and TextBackground functions without supplying border
  5.    color control.  (If it is available, I haven't found it!)  You may choose
  6.    the color you want from among the 16 that IBM provides-- they are
  7.    the same as in BASIC, and are numbered 0 (black) through F hex (high
  8.    intensity white).  In the third line of code:
  9.  
  10.               $B0/$01/                { MOV AL,01 }
  11.                     ^                           ^
  12.                     |--------this nybble--------|
  13.  
  14.    is what controls the color.  I have set it to "1" right now for blue, but
  15.    it can be any of the low-intensity colors 0 through 7 or high-intensity 8
  16.    through F hex.
  17.  
  18.    Eric Cohane              CompuServe 75206,1117                  12-Mar-85
  19.  
  20.    Reference: IBM PC Technical Reference (April 1983), p. 1-149.
  21. *)
  22. (*
  23. Procedure TurnOnBorderColor;
  24.  
  25. Begin
  26.    Inline
  27.       ($50/                 { PUSH AX             ; save registers         }
  28.        $52/                 { PUSH DX             ;   "      "             }
  29.        $B0/$01/             { MOV  AL,01          ; 01 is blue             }
  30.        $BA/$D9/$03/         { MOV  DX,03D9H       ; portaddress of 6845 CRT
  31.                                                     color-select register  }
  32.        $EE/                 { OUT  DX,AL          ; send the color code    }
  33.        $5A/                 { POP  DX             ; restore registers      }
  34.        $58);                { POP  AX             ;   "         "          }
  35. End;
  36. *)
  37. (*
  38.    The border color can also be set by use of a variable (Thanks to Bela
  39.    Lubkin for this one!) and be changed from within the program by the
  40.    programmer or the user.  This is coded slightly differently.  A calling
  41.    routine is provided to demonstrate its effectiveness.
  42. *)
  43.  
  44. Program Border;
  45.  
  46. var
  47.    ColorNumber : byte;
  48.    Ch          : char;
  49.  
  50. Procedure SetBorderColor(ColorNumber : byte);
  51.  
  52. Begin
  53.    Inline
  54.       ($50/                 { PUSH AX             ; save registers         }
  55.        $52/                 { PUSH DX             ;   "      "             }
  56.        $8A/$86/ColorNumber/ { MOV  AL,[BP + ColorNumber]                   }
  57.        $BA/$D9/$03/         { MOV  DX,03D9H       ; portaddress of 6845 CRT
  58.                                                     color-select register  }
  59.        $EE/                 { OUT  DX,AL          ; send the color code    }
  60.        $5A/                 { POP  DX             ; restore registers      }
  61.        $58);                { POP  AX             ;   "         "          }
  62. End;
  63.  
  64. Begin
  65.    repeat
  66.       ClrScr;
  67.       Write('To change the border color, enter a number in [0..15]: ');
  68.       Readln(ColorNumber);
  69.       SetBorderColor(ColorNumber);
  70.       Write('Enter D for Done or press another key to do it again: ');
  71.       Read(kbd,ch);
  72.       ch := upcase(ch);
  73.    until (ch = 'D');
  74. End.
  75.