comp.lang.ada
 help / color / mirror / Atom feed
From: tmoran@bix.com (Tom Moran)
Subject: Re: Joystick control
Date: 1999/05/06
Date: 1999-05-06T00:00:00+00:00	[thread overview]
Message-ID: <3731cfee.1463515@news.pacbell.net> (raw)
In-Reply-To: 7gqmd1$imo$1@nnrp1.deja.com

>I am trying to write an application that supports a joystick.
My ancient DOS code for joystick buttons is

  type joybuttons is record
    button_a:boolean;
    button_b:boolean;
    button_c:boolean;
    button_d:boolean;
  end record;
  for joybuttons use record
    button_a at 0 range 7 .. 7;
    button_b at 0 range 6 .. 6;
    button_c at 0 range 5 .. 5;
    button_d at 0 range 4 .. 4;
  end record;

  function joy return joybuttons is
    b:byte;
    function convert is new unchecked_conversion(byte, joybuttons);
  begin
    inport(16#200#, b);
    return convert(b);
  end joy;

Getting x,y positions at that level is less convenient because
basically
you have to send a byte, then see how long it takes for different bits
to become 1 - time is proportional to coordinate.  An easier way
is to do an interrupt 16#15# with AX = 16#84#.  If DX = 0 you'll
get "joybuttons" back in AL, if DX = 1 you'll get x,y of joystick one
back in AX,BX, and x,y of joystick two in CX,DX.  I don't include
that code here because calling an interrupt is even more compiler
library specific than "inport" IO.
  Of course if you are running under an OS that insulates you from the
joystick, you'll have to look in that OS's docs to see how to input
joystick info.





  reply	other threads:[~1999-05-06  0:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-05-06  0:00 Joystick control jboulais
1999-05-06  0:00 ` Tom Moran [this message]
1999-05-06  0:00   ` jboulais
1999-05-06  0:00     ` Robert Dewar
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox