Path: utzoo!utgpu!attcan!uunet!lll-winken!ames!ucsd!sdcc6!sdcc10!cs161agc From: cs161agc@sdcc10.ucsd.EDU (John Schultz) Newsgroups: comp.sys.amiga.tech Subject: Re: Simple questions/Modula-2 Message-ID: <48@sdcc10.ucsd.EDU> Date: 14 Jan 89 04:03:21 GMT References: <341@csd4.milw.wisc.edu> Reply-To: cs161agc@sdcc10.ucsd.edu.UUCP (John Schultz) Organization: University of California, San Diego Lines: 68 In article <341@csd4.milw.wisc.edu> gregm@csd4.milw.wisc.edu (Gregory Mumm) writes: > > How do you read the Joystick port? The only manual I have is the Here is modula-2 example code to read the joystick. It reads the hardware directly, and is (was) legal when I wrote it (according to Bob). This is as fast and concise as I could get, without reverting to assembly... DEFINITION MODULE joystick; PROCEDURE readjoystick(VAR x,y : INTEGER; VAR buttonpressed : BOOLEAN; port : CARDINAL); END joystick. IMPLEMENTATION MODULE joystick; FROM SYSTEM IMPORT ADDRESS,SHIFT; FROM CIAHardware IMPORT ciaa,CIABITS; FROM CustomHardware IMPORT custom; CONST one = BITSET(1); TYPE bitsetptr = POINTER TO BITSET; VAR buttonloc : POINTER TO CIABITS; joydat : ARRAY[0..1] OF bitsetptr; j : BITSET; PROCEDURE readjoystick(VAR x,y : INTEGER; VAR buttonpressed : BOOLEAN; port : CARDINAL); BEGIN j := joydat[port]^; x := CARDINAL(SHIFT(j,-1) * one) - CARDINAL(SHIFT(j,-9) * one); y := CARDINAL(SHIFT(SHIFT(j,1) / j,-1) * one) - CARDINAL(SHIFT(SHIFT(j,1) / j,-9) * one); buttonpressed := NOT((6+port) IN buttonloc^); END readjoystick; BEGIN buttonloc := ADDRESS(ciaa^.pra); WITH custom^ DO joydat[0] := bitsetptr(joy0dat); joydat[1] := bitsetptr(joy1dat); END; END joystick. Hope this helps, John Schultz