home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / das_buch / dos / joytest.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1993-05-29  |  2.6 KB  |  83 lines

  1. {$A+,B-,D-,E-,F-,G-,I-,L-,N-,O-,P-,Q-,R-,S-,T-,V-,X-}
  2. (*===================================================================*)
  3. (*                            JOYTEST.PAS                            *)
  4. (*     Demonstration und Test für die Routinen in JOYSTICK.PAS       *)
  5. (*                 Copyright (C) 1993 te-wi Verlag, München          *)
  6. (*===================================================================*)
  7. PROGRAM JoystickTest;
  8.  
  9. USES
  10.   Crt,
  11.   Cursor,
  12.   Joystick;
  13.  
  14. CONST
  15.   pressed: ARRAY[FALSE..TRUE] OF STRING[3] = ('AUS', 'AN ');
  16.  
  17.  
  18. VAR
  19.   x,  y : INTEGER;
  20.   f1, f2,
  21.   f3, f4: BOOLEAN;
  22.   oldx1, oldx2, oldy1, oldy2 : INTEGER;
  23. BEGIN
  24.   IF Joystick.IsInstalled THEN
  25.   BEGIN
  26.     oldx1 := 0; oldy1 := 0;
  27.     oldx2 := 0; oldy2 := 0;
  28.     ClrScr;
  29.     HideCursor;
  30.     TextAttr := Yellow;
  31.     GotoXY(27, 1); Write('Joystick-Probe');
  32.     GotoXY(21, 2); Write('Routinen für ');
  33.     IF ATFunctions THEN Write('AT über Int 15h')
  34.                    ELSE Write('XT über Ports ');
  35.     GotoXY( 5, 5); Write('Daten Joystick 1');
  36.     GotoXY( 5, 6); Write('----------------');
  37.     GotoXY(45, 5); Write('Daten Joystick 2');
  38.     GotoXY(45, 6); Write('----------------');
  39.     NormVideo;
  40.     GotoXY(19, 24); Write('Für <Ende> beliebige Taste drücken');
  41.     HighVideo;
  42.     REPEAT
  43.       Joystick.WhereXY1(x, y);
  44.       x := x * 8 DIV 7 DIV 3;
  45.       y := y * 8 DIV 7 DIV 3;
  46.       GotoXY(5, 10); Write('X-Wert:', x: 6, '  ');
  47.       IF oldx1 < x THEN Write(#26) ELSE
  48.       IF oldx1 > x THEN Write(#27) ELSE Write(#196);
  49.       GotoXY(5, 11); Write('Y-Wert:', y: 6, '  ');
  50.       IF oldy1 < y THEN Write(#24) ELSE
  51.       IF oldy1 > y THEN Write(#25) ELSE Write(#179);
  52.       oldx1 := x; oldy1 := y;
  53.       Joystick.WhereXY2(x, y);
  54.       x := x * 8 DIV 7 DIV 3;
  55.       y := y * 8 DIV 7 DIV 3;
  56.       GotoXY(45, 10); Write('X-Wert:', x: 6, '  ');
  57.       
  58.       IF oldx2 < x THEN Write(#26) ELSE
  59.       IF oldx2 > x THEN Write(#27) ELSE Write(#196);
  60.       GotoXY(45, 11); Write('Y-Wert:', y: 6, '  ');
  61.       IF oldy2 < y THEN Write(#24) ELSE
  62.       IF oldy2 > y THEN Write(#25) ELSE Write(#179);
  63.       oldx2 := x; oldy2 := y;
  64.       FireButton(f1, f2, f3, f4);
  65.       GotoXY( 5,13); Write('Button 1: ', pressed[f1]);
  66.       GotoXY( 5,14); Write('Button 2: ', pressed[f2]);
  67.       GotoXY(45,13); Write('Button 1: ', pressed[f3]);
  68.       GotoXY(45,14); Write('Button 2: ', pressed[f4]);
  69.     UNTIL KeyPressed;
  70.     SetCursor(StartCursor);
  71.     ClrScr;
  72.   END
  73.   ELSE
  74.   BEGIN
  75.     HighVideo;
  76.     WriteLn('Kein Joystick am Rechner angeschlossen!');
  77.   END;
  78.   NormVideo;
  79.   WriteLn(' ');
  80. END.
  81.  
  82. (*===================================================================*)
  83.