Mail Archives: djgpp/1998/02/05/22:17:28
Message-ID: | <34DA37DC.54205A4F@student.umass.edu>
|
Date: | Thu, 05 Feb 1998 17:06:20 -0500
|
From: | Paolo Piselli <paolo AT student DOT umass DOT edu>
|
MIME-Version: | 1.0
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Joystick Polling Woes.
|
NNTP-Posting-Host: | wash-211.dhcp.umass.edu
|
Organization: | University of Massachusetts, Amherst
|
Lines: | 47
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Well, none of the Win32 hacks over at rec.games.programmer could give
me any help with this one, so I'm hoping this NG still remembers how to
use things like joystick polling and assembly.
Anyways, I was wondering if someone who knows a thing or two about
joystick
polling could take a minute to check out the following routine. It was
copied from Lamothe's "Black Art" book almost exactly (excepting the
conversion to AT&T syntax assembly for DJGPP). I also checked out the
section on joystick polling in the PCGPE for a second opinion and
decided the implementation was fine. Anyways, the function reads most
of the axes (sp?) correctly for my Gravis Pad, except when I press down
(directly down, not diagonally) the y-axis drops below the neutral axis
value. To make sure my pad was working fine, I ran the joystick
calibration in bloodlust's genecyst to get a look at the axis values,
and they were right on (and very close to the values my own code
returned).
Anyways, if you're still reading, here is the code. I'm thinking it
could be some AT&T syntax error, because everything else seems fine...
unsigned int Joystick( unsigned char stick ) {
unsigned short count;
__asm__("
cli \n
movb %1, %%ah \n
xorb %%al, %%al \n
xorw %%cx, %%cx \n
movw $0x201, %%dx \n
outb %%al, %%dx \n
charged: \n
inb %%dx, %%al \n
testb %%ah, %%al \n
loopne charged \n
xorw %%ax, %%ax \n
subw %%cx, %%ax \n
movw %%ax, %0 \n
sti \n
": "=g" (count)
: "g" (stick)
);
return (unsigned int) count;
}
-Paolo
- Raw text -