From: "Petr Stehlik" Newsgroups: comp.os.msdos.djgpp Subject: Re: Joystick Polling Woes. Date: Fri, 6 Feb 1998 11:11:14 +0100 Organization: Czech Technical University Lines: 45 Message-ID: <6benpm$2ti$1@ns.felk.cvut.cz> References: <34DA37DC DOT 54205A4F AT student DOT umass DOT edu> NNTP-Posting-Host: joy.zln.cz To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk 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; }