home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / c / 19219 < prev    next >
Encoding:
Internet Message Format  |  1993-01-05  |  3.3 KB

  1. 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
  2. From: omarab@atlantis.CS.ORST.EDU (Scorpion)
  3. Newsgroups: comp.lang.c
  4. Subject: JOYSICK HANDLER HELP.... PLEASE EMAIL RESPONCE!!  Thanks...
  5. Summary: I need some help on my joystick handler.  Please email responce...
  6. Keywords: joystick C c++ help IBM
  7. Message-ID: <1iaueuINNgtf@leela.CS.ORST.EDU>
  8. Date: 5 Jan 93 03:14:38 GMT
  9. Organization: OSU CS Outreach Services, Corvallis, Oregon
  10. Lines: 72
  11. NNTP-Posting-Host: atlantis.cs.orst.edu
  12.  
  13. I need some help with a joystick handler.  If you can help me, I would
  14. appreciate it!!!
  15.  
  16. I originally wrote this program to control one joystick.  It made an int86
  17. call (see code below) to set the registers to the X and Y coordinates for 
  18. the joystick. I could then display the coordinates on screen.  Now I decided
  19. to rewrite the program to display the coordinates for 2 joysticks.  According
  20. to the book I was reading, the registers were assigned as follows:
  21.  
  22. AX = A joystick X coordinate value
  23. BX = A joystick Y coordinate value
  24. CX = B joystick X coordinate value
  25. DX = B joystick Y coordinate value
  26.  
  27. Now here is the code I used so you guys can take a look at it:
  28.  
  29. int joyax,joyay,joybx,joyby;
  30. void joystick()
  31. {
  32.   union REGS regs;
  33.  
  34.   regs.h.ah = 0x84;
  35.   regs.x.dx = 1;
  36.   int86(0x15,®s,®s);
  37.   joyax=regs.x.ax;
  38.   joyay=regs.x.bx;
  39. }
  40.  
  41. Now this works just great.  I set the variables joyax and joyay to the AX and
  42. BX registers as above.  Now in order to rewrite the program, I must set
  43. joybx and joyby to regs.x.cx and regs.x.dx, respectively.  Now, the code would
  44. look like this:
  45.  
  46. int joyax,joyay,joybx,joyby;
  47. void joystick()
  48. {
  49.   union REGS inregs, outregs;
  50.  
  51.   inregs.h.ah = 0x84;
  52.   inregs.x.dx = 1;
  53.   int86(0x15,&inregs,&outregs);
  54.   joyax=outregs.x.ax;
  55.   joyay=outregs.x.bx;
  56.   joybx=outregs.x.cx;
  57.   joyby=outregs.x.dx;
  58. }
  59.  
  60. Now, when I display these coordinates for the B joystick, the X axis works
  61. and displays fine, but the Y axis displays a constant 0 on the screen.  Now
  62. I got no errors on compile (No undecleared variables, etc) and I checked the
  63. joystick, and it works great when running alone.  I don't have a real good
  64. understanding of the int86 command so I may be screwing up there... but 
  65. according to this book... it should work fine.  If you are wondering, it is
  66. the 'PROGRAMMERS PROBLEM SOLVER', second edition, by Roboer Jourdain and
  67. the Peter Norton Computing Group.  Now I was a little suspicious when It
  68. set the regs.x.dx (at the top) to 1 and then I was making a call to set joyby
  69. to that same value.  So I re-wrote it as above, using seperatue arrays for
  70. input registers and output registers.  IT DOESN'T WORK HERE EITHER.  
  71.  
  72. If you can help me, please E-Mail your responce... it is better for me that
  73. way because I have to log into a different machine that normal to access news..
  74.  
  75. Thanks alot guys....
  76.  
  77. ----------------------------------------------------------------------------
  78. Brendan O'Mara                                     omarab@jacobs.cs.orst.edu
  79. ----------------------------------------------------------------------------
  80. -- 
  81. -----------------------------------------------------------------------------
  82.  Brendan O'Mara                    Owner, Stealth Technologies,
  83.  Email: omarab@jacobs.ucs.orst.edu        specializing in:
  84.  Alias: Scorpion                    
  85.