home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / mbug / mbug130.arc / JOYSTICK.INC < prev    next >
Text File  |  1979-12-31  |  896b  |  31 lines

  1. { JOYSTICK.INC - routines for using joystick
  2.   Written by Keith Wood             15/04/89 }
  3.  
  4. var    joy_avail : boolean;    { joystick present ? }
  5.  
  6. procedure init_joystick;       { initialise PIO }
  7. begin
  8.   port[1] := 255;
  9.   port[1] := 255
  10. end;
  11.  
  12. function joystick : byte;      { read joystick setting,
  13.                                  bit 0 - up, bit 1 - down,
  14.                                  bit 3 - left, bit 4 - right,
  15.                                  bit 7 - fire }
  16. var    j: byte;
  17. begin
  18.   j := 0;
  19.   if joy_avail then j := not port[0] and $8F;
  20.   if j>0 then delay(100);
  21.   joystick := j
  22. end;
  23.  
  24. procedure check_joy;           { check joystick present,
  25.                                  sets joy_avail accordingly }
  26. begin
  27.   init_joystick;
  28.   joy_avail := true;
  29.   joy_avail := joystick<>$8F;
  30. end;
  31.