Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!ucbvax!ucdavis!pollux.ucdavis.edu!s110018 From: s110018@pollux.ucdavis.edu (0000;0000001007;4000;250;216;s110) Newsgroups: comp.sys.amiga Subject: Re: Joystick Port 2 in C in PD games? Summary: Here you are Keywords: Due to C= continuing support in correct documentation Message-ID: <4642@ucdavis.ucdavis.edu> Date: 13 Jun 89 05:22:33 GMT References: <18380@unix.cis.pittsburgh.edu> Sender: uucp@ucdavis.ucdavis.edu Reply-To: s110018@pollux.ucdavis.edu (Bruce Rogers) Organization: University of California, Davis Lines: 43 In article <18380@unix.cis.pittsburgh.edu> smsst5@unix.cis.pittsburgh.edu (Steve M Suhy) writes: > > Does anyone know of any cucug, amicus, or fish disks that contain >any games or routines that contain C source for reading Port 2 of >a joystick? Thanks for any response. > >-Steve Here's a nice short way to do it. (Just a tad bit shorter than the example by Rob Peck in the RKM.) #include #define DMA_REGS 0xdff000 #define JOY1DAT 0x00C+DMA_REGS void CheckJoystick() { USHORT *joyPort2,joyData; short dirX,dirY,a,b,c,d; joyPort2=JOY1DAT; joyData=*joyPort2; dirX=dirY=0; a= ((joyData & 0x0002) >> 1); b= ((joyData & 0x0200) >> 9); c= ((joyData & 0x0001) ); d= ((joyData & 0x0100) >> 8); c^=a; d^=b; if (a) dirX= 1; if (b) dirX=-1; if (c) dirY= 1; if (d) dirY=-1; /* Just check for dirX or dirY here */ } -Bruce Rogers -u586182058ea@deneb.ucdavis.edu _______________________________________________________________________________ Just a man whose circumstances went beyond his control....