home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / das_buch / grafik / testsvga.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1993-05-09  |  5.7 KB  |  167 lines

  1. (*===================================================================*)
  2. (*                             TESTSVGA.PAS                          *)
  3. (*                         (C) 1993 te-wi Verlag                     *)
  4. (*-------------------------------------------------------------------*)
  5. (* Demo- und Testprogramm für den Grafiktreiber SVGA und BGI-Grafik  *)
  6. (* in 800 * 600 Punkten / 16 Farben.                                 *)
  7. (* Für dieses Programm muß der Grafiktreiber SVGA.BGI erstellt und   *)
  8. (* mit dem richtigen Wert gepatcht sein.                             *)
  9. (* Verwenden Sie hierfür das Programm MAKEBGI.PAS!                   *)
  10. (*===================================================================*)
  11.  
  12. PROGRAM TestSVGA;
  13.  
  14. USES
  15.   Crt, Graph, GraphErg;
  16.  
  17. CONST
  18.   SVGAHi = 0;
  19.   DriverID : STRING[8] = 'SVGA';
  20.  
  21. VAR
  22.   SVGADriverPtr    : Pointer;
  23.   gd, gm, result,
  24.   f, CtrX, CtrY,
  25.   corr1, corr2,
  26.   x1, x2, XMax, xr, xl,
  27.   MaxX, MaxY, i, j,
  28.   EuropeanFont     : INTEGER;
  29.   ch               : CHAR;
  30.   s                : STRING;
  31. BEGIN
  32.   ClrScr;
  33.   TextAttr := Yellow;
  34.   GotoXY(33, 2); WriteLn('==============');
  35.   GotoXY(33, 3); WriteLn('Test-SVGA V1.0');
  36.   GotoXY(33, 4); WriteLn('==============');
  37.   TextAttr := White;
  38.   GotoXY(15, 7);
  39.   WriteLn('Achtung: Dieses Programm läuft nicht auf jeder Hard-');
  40.   WriteLn('w': 15, 'are! Es benötigt außerdem im aktuellen Verzeichnis');
  41.   WriteLn('d': 15, 'ie Dateien ', DriverID,'.BGI, EURO.CHR und LITT.CHR.'#10);
  42.   WriteLn('S': 15, 'ie können nun das Programm noch mit [ESC] abbrechen -');
  43.   Write  ('a': 15, 'nsonsten drücken Sie bitte eine beliebige Taste. ');
  44.   ch := #0;
  45.   REPEAT
  46.     ch := Readkey;
  47.   UNTIL ch <> #0;
  48.   IF ch = #27 THEN Halt;
  49.   DetectGraph(gd, gm);
  50.   IF gd <> VGA THEN BEGIN
  51.     ClrScr;
  52.     WriteLn('Ich habe keine VGA-Karte gefunden, also wird das Programm');
  53.     WriteLn('auf keinen Fall unterstützt.');
  54.     WriteLn('Testprogramm wird abgebrochen!');
  55.     Halt;
  56.   END;
  57.   IF ParamCount > 0 THEN DriverID := ParamStr(1);
  58.   FOR i := 1 TO LENGTH(DriverID) DO DriverID[i] := UpCase(DriverID[i]);
  59.   IF DriverID = 'EGAVGA' THEN gm := VGAHi
  60.                          ELSE gm := SVGAHi;
  61.   gd := InstallUserDriver(DriverID, SVGADriverPtr);
  62.   EuropeanFont := InstallUserFont('EURO');
  63.   InitGraph(gd, gm, '');
  64.   CheckSnow := FALSE;
  65.   DirectVideo := TRUE;
  66.   result := GraphResult;
  67.   IF result < 0 THEN BEGIN
  68.     WriteLn(^G, GraphErrorMsg(result));
  69.     Halt;
  70.   END;
  71.   MaxX := GetMaxX + 1; CtrX := MaxX DIV 2;
  72.   MaxY := GetMaxY + 1; CtrY := MaxY DIV 2;
  73.   SetFillStyle(SolidFill, DarkGray);
  74.   Bar(0,0, MaxX, MaxY);
  75.   SetBkColor(Black);
  76.   SetFillStyle(SolidFill, Red);
  77.   Bar(CtrX DIV 4, 0, MaxX - CtrX DIV 4, CtrY * 2 - 1);
  78.   IF MaxX > 320 THEN
  79.     SetLineStyle(SolidLn, 0, ThickWidth);
  80.   Circle(CtrX, CtrY, CtrY);
  81.   SetFillStyle(XHatchFill, LightBlue);
  82.   PieSlice(CtrX, CtrY, 0, 90, CtrY);
  83.   SetFillStyle(HatchFill, LightBlue);
  84.   PieSlice(CtrX, CtrY, 90, 180, CtrY);
  85.   SetFillStyle(CloseDotFill, LightCyan);
  86.   PieSlice(CtrX, CtrY, 180, 270, CtrY);
  87.   SetFillStyle(WideDotFill, Cyan);
  88.   PieSlice(CtrX, CtrY, 270, 360, CtrY);
  89.   Rectangle(CtrX DIV 4, 0, MaxX - CtrX DIV 4, CtrY * 2 - 1);
  90.   SetLineStyle(SolidLn, 0, NormWidth);
  91.   Line(CtrX DIV 4, CtrY, MaxX - (CtrX DIV 4), CtrY);
  92.   Line(CtrX , 0, CtrX, MaxY);
  93.   XMax := MaxX DIV 4;
  94.   IF MaxX = 320 THEN BEGIN
  95.     corr1 := 16;
  96.     corr2 := 16;
  97.   END ELSE BEGIN
  98.     corr1 := 8;
  99.     corr2 := 4;
  100.   END;
  101.   FOR i := 0 TO GetMaxColor DO BEGIN
  102.     xr := MaxX - XMax DIV 2 - 2;
  103.     xl := (XMax DIV 2 + (XMax DIV (Succ(GetMaxColor) DIV corr2)
  104.           * i) * 6 DIV corr1) + 2;
  105.     IF xl > xr THEN xl := xr;
  106.     SetFillStyle(SolidFill, i);
  107.     SetColor(White);
  108.     Bar(xl, CtrY DIV 2, xr, CtrY);
  109.     IF GetMaxColor <= 15 THEN
  110.       Rectangle(xl, CtrY DIV 2, xr, CtrY);
  111.   END;
  112.   FOR i := 0 TO 11 DO BEGIN
  113.     SetFillStyle(i, White);
  114.     Bar((XMax DIV 2 + (XMax DIV 8 * i) * 2) + 2,
  115.         CtrY,
  116.         (MaxX - (CtrX DIV 4) - 2),
  117.         MaxY - CtrY DIV 2);
  118.     Rectangle((XMax DIV 2 + (XMax DIV 8 * i) * 2) + 2,
  119.               CtrY, (MaxX - (CtrX DIV 4) - 2),
  120.               MaxY - CtrY DIV 2);
  121.   END;
  122.   SetColor(White);
  123.   IF MaxX >= 799 THEN
  124.     SetUserCharSize(1, 1, 1, 1)
  125.   ELSE
  126.    SetUserCharSize(1, 3, 1, 3);
  127.   SetTextStyle(EuropeanFont, HorizDir, UserCharSize);
  128.   SetFillStyle(InterleaveFill, DarkGray);
  129.   Bar(CtrX - (TextWidth(GetModeName(gm)) DIV 2) - 8,
  130.       MaxY - MaxY DIV 6 - (TextHeight('Pp') DIV 2) - 4,
  131.       CtrX + (TextWidth(GetModeName(gm)) DIV 2) + 4,
  132.       MaxY - MaxY DIV 6 + (TextHeight('Pp') DIV 2) + 8);
  133.   Rectangle(CtrX - (TextWidth(GetModeName(gm)) DIV 2) - 8,
  134.            MaxY - MaxY DIV 6 - (TextHeight('Pp') DIV 2) - 4,
  135.            CtrX + (TextWidth(GetModeName(gm)) DIV 2) + 4,
  136.            MaxY - MaxY DIV 6 + (TextHeight('Pp') DIV 2) + 8);
  137.   SetTextJustify(CenterText, CenterText);
  138.   SetFillStyle(SolidFill, Red);
  139.   IF MaxX > 320 THEN BEGIN
  140.     FontAttr := FilledOut;
  141.     SetFillStyle(SolidFill, Red);
  142.     SetColor(White);
  143.     OutTextXY(CtrX, MaxY - MaxY DIV 6, GetModeName(gm));
  144.     FontAttr := Normal;
  145.   END ELSE BEGIN
  146.     FontAttr := Normal;
  147.     OutTextXY(CtrX, (MaxY - MaxY DIV 6), GetModeName(gm));
  148.   END;
  149.   SetTextStyle(SmallFont, VertDir, 4);
  150.   SetTextJustify(LeftText, BottomText);
  151.   SetColor(LightCyan);
  152.   OutTextXY(GetMaxX - 12, GetMaxY - 10,
  153.             '(C) 1993 te-wi Verlag');
  154.   SetColor(White);
  155.   Str(MemAvail DIV 1024, s);
  156.   FontAttr := OutLine;
  157.   SetTextStyle(SmallFont, HorizDir, 4);
  158.   SetTextJustify(RightText, BottomText);
  159.   OutTextXY(MaxX - CtrX DIV 4 - 5, MaxX DIV 40, s + ' KBytes RAM frei');
  160.   ch := #0;
  161.   REPEAT
  162.     ch := ReadKey;
  163.   UNTIL ch <> #0;
  164.   CloseGraph;
  165. END.
  166.  
  167. (*===================================================================*)