Mail Archives: djgpp/1998/02/06/05:30:31
Hi,
>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
this is a routine written by myself some time ago for Atari800 emulator. It
works fine (if a joystick is connected ;-).
int joystick0(int *x, int *y)
{
int jx, jy, jb;
__asm__ __volatile__(
"cli\n\t"
"movw $0x201,%%dx\n\t"
"xorl %%ebx,%%ebx\n\t"
"xorl %%ecx,%%ecx\n\t"
"outb %%al,%%dx\n\t"
"__jloop:\n\t"
"inb %%dx,%%al\n\t"
"testb $1,%%al\n\t"
"jz x_ok\n\t"
"incl %%ecx\n\t"
"x_ok:\n\t"
"testb $2,%%al\n\t"
"jz y_ok\n\t"
"incl %%ebx\n\t"
"jmp __jloop\n\t"
"y_ok:\n\t"
"testb $1,%%al\n\t"
"jnz __jloop\n\t"
"sti\n\t"
"shrb $4,%%al"
:"=a"(jb), "=b"(jy), "=c"(jx)
: /* no input values */
:"%al", "%ebx", "%ecx", "%dx"
);
*x = jx;
*y = jy;
return jb & 0x03;
}
- Raw text -