home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / das_buch / grafik / pdemo.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1993-04-18  |  3.5 KB  |  74 lines

  1. {$A+,B-,D-,E+,F+,G+,I+,K-,L+,N-,O-,P-,Q-,R-,S+,T-,V+,W-,X+,Y+}
  2. {$M 16384,0}
  3. (*===================================================================*)
  4. (*                            PDEMO.PAS                              *)
  5. (*    Demo für Grafik im Protected Mode unter Verwendung von DLLS    *)
  6. (*                    in Borland Pascal 7.0/DPMI                     *)
  7. (*          Copyright (C) 1993 te-wi Verlag München                  *)
  8. (*===================================================================*)
  9. (* Dieses Programm kann nicht mit Turbo Pascal compiliert werden     *)
  10. (* Das Programm benötigt außerdem die DLL BGILIB.DLL und den         *)
  11. (* Borland Pascal DOS-Extender um lauffähig zu sein.                 *)
  12. (*===================================================================*)
  13. PROGRAM PDemo;                       (* Protected-Mode Demonstration *)
  14.  
  15. USES
  16.   Crt, Graph, BGIImport;
  17.  
  18. VAR
  19.   gd, gm: INTEGER;
  20.   s     : STRING;
  21.   ma    : Real;
  22.   i     : INTEGER;
  23. BEGIN
  24.   DetectGraph(gd, gm);                          (* Treiber ermitteln *)
  25.   InitGraph(gd, gm, '');                      (* Init mit BGILIB.DLL *)
  26.   SetTextStyle(SmallFont, VertDir, 4);      (* Copyright rechts hoch *)
  27.   SetTextJustify(LeftText, BottomText);
  28.   SetColor(Cyan);                                          (* türkis *)
  29.   OutTextXY(GetMaxX - 10, GetMaxY - 10, '(C) 1993 te-wi Verlag');
  30.   SetColor(White);                                           (* weiß *)
  31.   Circle(GetMaxX DIV 2, GetMaxY DIV 2, GetMaxY DIV 2);    (* Umkreis *)
  32.   Circle(GetMaxX DIV 2, GetMaxY DIV 2, GetMaxY DIV 2 - 3);
  33.   SetTextJustify(CenterText, CenterText);            (* umdefinieren *)
  34.   ma := MemAvail / 1024;                (* Freien Speicher ermitteln *)
  35.   ma := ma / 1024;
  36.   Str(ma:2:3, s);       (* ... und die Mbytes in einen String packen *)
  37.   s := s + ' Mbytes RAM frei';
  38.   s[Pos('.', s)] := ',';     (* Punkt durch Komma ersetzen (nix USA! *)
  39.   SetTextStyle(TriplexFont, HorizDir, 4);       (* Messages ausgeben *)
  40.   OutTextXY(GetMaxX DIV 2, GetMaxY DIV 4, 'Grafik mit Treiber-DLL');
  41.   OutTextXY(GetMaxX DIV 2, GetMaxY DIV 2, GetModeName(gm));
  42.   OutTextXY(GetMaxX DIV 2, GetMaxY DIV 2 + GetMaxY DIV 4, s);
  43.   SetWriteMode(AndPut);                           (* erst mal AndPut *)
  44.   i := 1;
  45.   REPEAT
  46.     IF i <= 1 THEN
  47.     BEGIN
  48.       Randomize;                                    (* Zufallszähler *)
  49.       SetColor(Random(GetMaxColor + 1));       (* Farbe durch Zufall *)
  50.       SetWriteMode(Random(4));            (* WriteModus durch Zufall *)
  51.     END;                                 (* Kreis mit Interferenzen: *)
  52.     Circle(GetMaxX DIV 2, GetMaxY DIV 2, i);
  53.     Inc(i, 2);
  54.     IF i = (GetMaxY DIV 2)      THEN i := 0;
  55.     IF i = (GetMaxY DIV 2) - 1  THEN i := 1;
  56.     IF i > (GetMaxY DIV 2) - 3  THEN
  57.     BEGIN
  58.       SetColor(Black);                   (* Die Schrift sollte immer *)
  59.       SetWriteMode(NormalPut);           (* wieder upgedated werden  *)
  60.       ma := MemAvail / 1024;
  61.       ma := ma / 1024;
  62.       OutTextXY(GetMaxX DIV 2, GetMaxY DIV 2 + GetMaxY DIV 4, s);
  63.       Str(ma:2:3, s);
  64.       s := s + ' Mbytes RAM frei';
  65.       s[Pos('.', s)] := ',';
  66.       OutTextXY(GetMaxX DIV 2, GetMaxY DIV 4,
  67.                 'Grafik mit Treiber-DLL');
  68.       OutTextXY(GetMaxX DIV 2, GetMaxY DIV 2, GetModeName(gm));
  69.       OutTextXY(GetMaxX DIV 2, GetMaxY DIV 2 + GetMaxY DIV 4, s);
  70.     END;
  71.   UNTIL KeyPressed;                       (* ... bis beliebige Taste *)
  72.   CloseGraph;                                        (* ... und Ende *)
  73. END.
  74.