home *** CD-ROM | disk | FTP | other *** search
/ Turbo Toolbox / Turbo_Toolbox.iso / 1990 / 05 / grdlagen / grau.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1991-08-15  |  2.0 KB  |  65 lines

  1. (* ====================================================== *)
  2. (*                      GRAU.PAS                          *)
  3. (*                  Das EGA/VGA-BIOS:                     *)
  4. (*         Demo #2: Umwandlung in Graustufen (VGA)        *)
  5. (*           (c) 1990 Matthias Uphoff & TOOLBOX           *)
  6. (* ====================================================== *)
  7.  
  8. USES Dos, Crt, Bios2;
  9.  
  10. VAR  ColorSave: ARRAY[0..255] OF ColorValue;
  11.      x, y: Word;
  12.  
  13. PROCEDURE SetVideoMode(ModeNr: Byte);
  14.   (* Intialisiert den Videomodus mit der Nummer ModeNr *)
  15.   VAR R: Registers;
  16. BEGIN
  17.   R.AH := 0;            (* Funktionsnummer nach AH *)
  18.   R.AL := ModeNr;       (* Modusnummer ins AL-Register *)
  19.   Intr($10,R);          (* BIOS-Call über Interrupt $10 *)
  20. END;
  21.  
  22. PROCEDURE Box(x1,y1,x2,y2: Word; c: Byte);
  23.    (* Zeichnet ein mit der Farbe c gefülltes Rechteck    *)
  24.    (* x1,y1 = Ecke links oben, x2,y2 = Ecke rechts unten *)
  25.    VAR x,y: Word;
  26.        R: Registers;
  27. BEGIN
  28.   FOR y := y1 TO y2 DO
  29.     FOR x := x1 TO x2 DO BEGIN
  30.       R.AH := $C;        (* Funktionsnummer *)
  31.       R.AL := c;         (* Farbe nach AL *)
  32.       R.BH := 0;         (* Bildschirmseite 0 *)
  33.       R.CX := x;
  34.       R.DX := y;
  35.       Intr($10,R);       (* BIOS-Call Punkt setzen *)
  36.     END;
  37. END;
  38.  
  39. BEGIN (* Hauptprogramm *)
  40.      (* 256-Farben-Modus einschalten: *)
  41.   SetVideoMode($13);
  42.      (* 256 farbige Rechtecke erzeugen: *)
  43.   FOR y := 0 TO 15 DO
  44.     FOR x := 0 TO 15 DO
  45.       Box(x*20,y*12,x*20+19,y*12+11,x+y*16);
  46.      (* Alle Farbregister retten: *)
  47.   ReadColorBlock(0,256,ColorSave);
  48.   REPEAT
  49.       (* Alle Farbwerte in Graustufen umwandeln: *)
  50.     FOR x := 0 TO 255 DO BEGIN
  51.       GrayScale(x,1);
  52.       Delay(50);
  53.     END;
  54.       (* Alle Farben wieder herstellen: *)
  55.     FOR x := 0 TO 255 DO BEGIN
  56.       SetColorReg(x,ColorSave[x]);
  57.       Delay(50);
  58.     END;
  59.   UNTIL KeyPressed;
  60.   SetVideoMode($3);    (* Zurück in den Textmodus *)
  61. END.
  62.  
  63. (* ====================================================== *)
  64. (*                    Ende GRAU.PAS                       *)
  65.