home *** CD-ROM | disk | FTP | other *** search
/ A.N.A.L.O.G. Magazine 1989 September / 89_sep.atr / gunread.act < prev    next >
Text File  |  2023-02-26  |  2KB  |  1 lines

  1. ; GUNREAD.ACT¢;¢;      CHECKSUM DATA¢;[6A BA 3A 75 52 ]¢¢; Read the Atari light gun¢; and convert the readings¢; of LPENH & LPENV to current¢; graphics mode screen coordinates¢;¢; Algorithm developed by:¢; Matthew J. W. Ratcliff¢; Ratware Softworks¢; (c) 1989¢;¢; For Analog Computing¢;¢; Algorithm:¢; The DELTA-X gun readings were¢; apparently DESIGNED to be 160¢; with DELTA-Y at 96.  These values¢; work out to be multiples of two,¢; by powers of two, for each and¢; EVERY possible Atari graphics mode¢; 0 through 15 (full screen modes).¢; ¢; The X reading starts at about 89¢; at the far left of the display,¢; increases to 227 at about text¢; column 34, then drops to zero.¢; It increases to about 22 at the¢; far right of the display.¢;¢; The Y reading starts at about 17¢; at the top to 112 at the bottom.¢;¢; GunRead normalizes the X reading¢; to 0-159, inclusive and Y to a¢; range of 0-95.  Then the XSHIFT¢; and YSHIFT tables are accessed,¢; based on the current graphics mode.¢; If the value is less than 128, it¢; is a right shift count (divide).¢; A value of 128 indicates a single¢; left shift (multiply by 2).¢; ¢; The end result is a valid X,Y¢; coordinate reading of the light¢; gun for the present graphics¢; mode.  It is up to the user¢; to assure the screen intensity¢; (COLOR*16+INTENSITY) is at a level¢; to get valid gun readings.  A value¢; of at least 10 is recommended.¢; A "flash" technique may work best¢; Set all playfield intensities to ¢; 14, call GunRead, and restore the¢; original playfield colors.¢; ¢    ¢PROC GunRead( CARD POINTER xx,¢              BYTE POINTER yy)¢¢BYTE ARRAY xshift=[2 3 3 1 1 1 0 0 128 1 1 1 2 2 0 0]¢ ¢BYTE ARRAY yshift=[2 2 3 2 1 1 0 0 128 128 128 128 2 3 128 128]¢¢CARD GunX¢BYTE GunY¢¢BYTE DINDEX= $57¢BYTE LPENH = 564¢BYTE LPENV = 565¢¢BYTE shift, index¢     ¢¢GunX  = LPENH¢GunX  = GunX & $FF¢GunY  = LPENV¢index = DINDEX¢¢IF GunX <= 40 THEN¢ GunX = GunX + 227¢ IF GunX > 255 THEN¢  GunX = 255¢ FI¢FI¢¢IF GunX <= 90 THEN¢  GunX = 90¢FI¢¢GunX = GunX - 90¢¢IF GunX > 159 THEN¢ GunX = 159       ¢FI¢¢shift = xshift(index)¢¢IF shift = 128 THEN¢  GunX = GunX LSH 1¢ELSE¢  GunX = GunX RSH shift¢FI¢¢GunY = GunY - 17¢¢  ¢IF GunY > 127 THEN¢  GunY = 0¢FI¢     ¢IF GunY > 95 THEN¢  GunY = 95¢FI¢¢shift = yshift(index)¢¢IF shift = 128 THEN¢  GunY = GunY LSH 1¢ELSE¢  GunY = GunY RSH shift¢FI¢¢xx ^= GunX¢yy ^= GunY¢¢RETURN¢¢¢