*/
Want to see what people are talking about? See the latest forum posts.
*/

View \JOYDEMO.PAS

JOYSTICK Unit for Turbo Pascal

Submitted By: WEBMASTER
Rating: (Not rated) (Rate It)


PROGRAM JoystickDemo;
Uses Crt,Joystick;

VAR
 x, ox : Byte;
 y, oy : Byte;

PROCEDURE UnHighLight(x,y : Byte);
  BEGIN
    Mem[$B800 : ((y-1)*160)+((x)*2)-1] := $0F;   { Unhighlight & highlight }
  END;                                        { Changes attrib at (x,y) }

PROCEDURE HighLight(x,y : Byte);
  BEGIN
    Mem[$B800 : ((y-1)*160)+((x)*2)-1] := $4F;
  END;

BEGIN
 BetterInitJS(2);        { Initialize the joystick }
 TextMode(CO80);         { Set to 80x25 color mode }
 TextBackGround(BLACK){ Set up colors..... }
 TextColor(WHITE);
 ClrScr;
 WRITELN('JonSoft Joystick Unit for Turbo Pascal - press any key to end');
 Window(32,5,50,12);
 WRITELN('\               /');   { Make joystick 8-direction pattern }
 WRITELN('');
 WRITELN('');
 WRITELN('        C       ',CHR(26));
 WRITELN('');
 WRITELN('');
 WRITELN('/               \');
 Window(1,1,80,25);
 GotoXY(20,14);           { Set up indicators }
 WRITELN('Button 1 : released   Button 2 : released');
 GotoXY(33,18);
 WRITELN('X : xxx   Y : xxx');
 REPEAT
  GotoXY(37,18);
  WRITE(joy_X,'   ');     { Update X and Y on the screen }
  GotoXY(47,18);
  WRITE(joy_Y,'   ');
  GotoXY(31,14);
  IF button_1 = 1 THEN WRITE('PRESSED ')  { Update button info onscreen }
   ELSE WRITE('released');
  GotoXY(53,14);
  IF button_2 = 1 THEN WRITE('PRESSED ')
   ELSE WRITE('released');
  ox := x;
  oy := y;
  CASE Horiz OF         { Check 8-direction info, update on screen }
   -1 : x := 32;
    0 : x := 40;
    1 : x := 48;
  END;
  CASE Vert OF
   -1 : y := 5;
    0 : y := 8;
    1 : y := 11;
  END;
  Unhighlight(ox,oy);
  Highlight(x,y);
 UNTIL KeyPressed       { Exit when user pressed any key }
END.

corner
© 1996-2008 CommunityHeaven LLC. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
North American business development: Nicolai Wadstrom. Publisher: Lars Hagelin.