www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/02/06/05:30:31

From: "Petr Stehlik" <pstehlik AT zln DOT cz>
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

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019