home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!usc!sdd.hp.com!spool.mu.edu!agate!stanford.edu!rutgers!flop.ENGR.ORST.EDU!leela.CS.ORST.EDU!atlantis.CS.ORST.EDU!omarab
- From: omarab@atlantis.CS.ORST.EDU (Scorpion)
- Newsgroups: comp.lang.c
- Subject: JOYSICK HANDLER HELP.... PLEASE EMAIL RESPONCE!! Thanks...
- Summary: I need some help on my joystick handler. Please email responce...
- Keywords: joystick C c++ help IBM
- Message-ID: <1iaueuINNgtf@leela.CS.ORST.EDU>
- Date: 5 Jan 93 03:14:38 GMT
- Organization: OSU CS Outreach Services, Corvallis, Oregon
- Lines: 72
- NNTP-Posting-Host: atlantis.cs.orst.edu
-
- I need some help with a joystick handler. If you can help me, I would
- appreciate it!!!
-
- I originally wrote this program to control one joystick. It made an int86
- call (see code below) to set the registers to the X and Y coordinates for
- the joystick. I could then display the coordinates on screen. Now I decided
- to rewrite the program to display the coordinates for 2 joysticks. According
- to the book I was reading, the registers were assigned as follows:
-
- AX = A joystick X coordinate value
- BX = A joystick Y coordinate value
- CX = B joystick X coordinate value
- DX = B joystick Y coordinate value
-
- Now here is the code I used so you guys can take a look at it:
-
- int joyax,joyay,joybx,joyby;
- void joystick()
- {
- union REGS regs;
-
- regs.h.ah = 0x84;
- regs.x.dx = 1;
- int86(0x15,®s,®s);
- joyax=regs.x.ax;
- joyay=regs.x.bx;
- }
-
- Now this works just great. I set the variables joyax and joyay to the AX and
- BX registers as above. Now in order to rewrite the program, I must set
- joybx and joyby to regs.x.cx and regs.x.dx, respectively. Now, the code would
- look like this:
-
- int joyax,joyay,joybx,joyby;
- void joystick()
- {
- union REGS inregs, outregs;
-
- inregs.h.ah = 0x84;
- inregs.x.dx = 1;
- int86(0x15,&inregs,&outregs);
- joyax=outregs.x.ax;
- joyay=outregs.x.bx;
- joybx=outregs.x.cx;
- joyby=outregs.x.dx;
- }
-
- Now, when I display these coordinates for the B joystick, the X axis works
- and displays fine, but the Y axis displays a constant 0 on the screen. Now
- I got no errors on compile (No undecleared variables, etc) and I checked the
- joystick, and it works great when running alone. I don't have a real good
- understanding of the int86 command so I may be screwing up there... but
- according to this book... it should work fine. If you are wondering, it is
- the 'PROGRAMMERS PROBLEM SOLVER', second edition, by Roboer Jourdain and
- the Peter Norton Computing Group. Now I was a little suspicious when It
- set the regs.x.dx (at the top) to 1 and then I was making a call to set joyby
- to that same value. So I re-wrote it as above, using seperatue arrays for
- input registers and output registers. IT DOESN'T WORK HERE EITHER.
-
- If you can help me, please E-Mail your responce... it is better for me that
- way because I have to log into a different machine that normal to access news..
-
- Thanks alot guys....
-
- ----------------------------------------------------------------------------
- Brendan O'Mara omarab@jacobs.cs.orst.edu
- ----------------------------------------------------------------------------
- --
- -----------------------------------------------------------------------------
- Brendan O'Mara Owner, Stealth Technologies,
- Email: omarab@jacobs.ucs.orst.edu specializing in:
- Alias: Scorpion
-