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

  1. ¢¢;¢;        SHARP SHOOTER¢;    by Matthew J.W. Ratcliff ¢;¢;        COPYRIGHT 1989¢;     BY ANALOG COMPUTING¢;¢¢¢;      CHECKSUM DATA¢;[48 0B 1E 62 0B 10 10 12 ¢; 78 1A 5B 6E 9E 58 23 EE ¢; D8 EB E2 41 52 46 14 71 ¢; 0B 3A 83 1F A4 53 18 ]¢¢BYTE RTS=[$60] ; This declaration ¢               ; must be the first¢               ; compiled code if ¢               ; using this pgm with¢               ; OS/A+ versions 2.2¢               ; and before¢¢; Game global target array¢¢BYTE ARRAY XCS=[26 79 132 26 79 132]¢BYTE ARRAY YCS=[48 48 48 144 144 144]¢BYTE ARRAY Tgsel(6)¢¢BYTE Jiffy  = 20¢BYTE Jiffy1 = 19¢BYTE CH     = 764¢BYTE TRIGGER= 632¢BYTE Attract= 77¢¢;-------------------------¢INCLUDE "D:GUNREAD.ACT"¢;-------------------------¢¢PROC ZeroTime()¢¢CARD Timer=19¢¢Timer = 0¢¢RETURN¢¢;-------------------------¢; Get elapsed time in jiffies¢;¢CARD FUNC GetJTime()¢¢CARD tic¢¢tic = Jiffy1*256 + Jiffy ¢¢RETURN(tic)¢;-------------------------¢PROC Blast( CARD xb, BYTE yb )¢¢BYTE s¢CARD d¢¢Attract = 0¢¢IF xb < 1 THEN ¢  xb = 1¢FI¢¢IF xb >158 THEN¢  xb = 158¢FI¢¢IF yb < 1 THEN¢  yb = 1¢FI¢¢IF yb > 190 THEN¢  yb = 190¢FI¢¢Plot(xb-1, yb)¢Plot(xb+1, yb)¢Plot(xb, yb-1)¢Plot(xb, yb+1)¢¢s = 16  ¢Sound(0, 100, 8, 15)¢¢FOR d = 0 TO 200¢  DO¢  ;¢  OD¢¢WHILE s # 0¢  DO¢  s = s - 1¢  Sound(0, 140, 8, s)¢  FOR d = 0 TO 100¢    DO¢    ;¢    OD¢  OD¢¢Sound(0, 0, 0, 0)¢¢RETURN ¢¢;-------------------------¢; Return the integer square¢; ROOT of the value passed.¢;¢; Algorithm:  The integer square ¢; root is the count of the total¢; successive odd numbers, starting¢; from 1, that can be subtracted¢; from the parameter before it goes¢; negative.¢¢BYTE FUNC ISqrt( INT r )¢¢BYTE i, j¢¢i = 1¢j = 0¢WHILE (r > 0)¢  DO¢  r = r - i¢  i = i + 2¢  IF r >= 0 THEN¢    j = j + 1¢    FI¢  OD¢¢RETURN( j )¢¢;-------------------------¢¢PROC SelTarget( BYTE tg )¢¢CARD X¢BYTE y¢¢Attract = 0¢¢x = XCS(tg)¢y = YCS(tg) ¢¢Plot(x-26,y-26)¢DrawTo(x+26,y-26)¢DrawTo(x+26,y+26)¢DrawTo(x-26,y+26)¢DrawTo(x-26,y-26)¢¢IF color # 0 THEN¢  FOR y = 0 TO 15¢    DO¢    Sound(0, 60, 10, y)¢    FOR x = 0 TO 200¢      DO¢      ;¢      OD¢    OD       ¢    Sound(0, 0, 0, 0)¢  FI¢¢RETURN¢¢;-------------------------¢¢INT FUNC ABS(INT NUMBER)¢¢IF (NUMBER < 0) THEN¢ RETURN(-NUMBER)¢FI¢RETURN(NUMBER)¢¢;---------------------------¢¢PROC GAMESCREEN()¢¢BYTE I,R¢INT DX¢INT DY¢INT PHI, PHIXY, PHIY¢¢CARD X¢BYTE Y¢¢Attract = 0¢color = 1¢¢FOR R=5 TO 25 STEP 5¢  DO¢  DX=R¢  DY=0¢  PHI = 0¢  WHILE DX >= DY  ¢    DO¢    PHIY = PHI+DY+DY+1¢    PHIXY= PHIY-DX-DX+1¢    X = DX¢    Y = DY¢    FOR I=0 TO 5¢      DO¢      Plot (XCS(I)+X,YCS(I)+Y)¢      Plot (XCS(I)+Y,YCS(I)+X)¢      Plot (XCS(I)+Y,YCS(I)-X)¢      Plot (XCS(I)+X,YCS(I)-Y)¢      Plot (XCS(I)-X,YCS(I)-Y)¢      Plot (XCS(I)-Y,YCS(I)-X)¢      Plot (XCS(I)-Y,YCS(I)+X)¢      Plot (XCS(I)-X,YCS(I)+Y)¢      OD¢    PHI = PHIY¢    DY = DY + 1¢    IF ABS(PHIXY)+0<ABS(PHIY) THEN¢      PHI= PHIXY¢      DX = DX-1¢      FI¢    OD ; WHILE¢  OD ; R LOOP¢RETURN¢¢; ------------------¢¢INT FUNC GetRadius( INT x, INT y, BYTE tg)¢¢INT xx, yy, rr¢¢rr = XCS(tg)¢xx = x¢xx = xx-rr¢xx = Abs(xx)¢¢rr = YCS(tg)¢yy = y¢yy = yy-rr¢yy = Abs(yy)¢¢xx = xx * xx¢yy = yy * yy¢xx = xx + yy¢¢IF xx < 625 THEN   ¢  rr = ISqrt( xx )¢ELSE¢  rr = 26¢FI¢¢RETURN(rr)¢¢;-------------------¢PROC Title( )¢¢Graphics( 0 )¢Poke (710, 4)¢PrintE("Sharp Shooter, by Mat*Rat")¢PrintE("(c) 1989, Analog Computing")¢PrintE("")¢PrintE("Connect Light Gun first game port")¢PrintE("")¢PrintE("Press קפחוודפ for NEXT game or")¢PrintE("type  דצבIJסדá key to exit program")¢¢DO  ¢  ;¢UNTIL TRIGGER=15 OR CH = 28¢OD¢¢DO¢  ;¢UNTIL TRIGGER=14 OR CH = 28¢OD¢¢RETURN¢;------------------¢PROC RandTgts() ¢BYTE i, y, f¢¢¢¢FOR i = 0 TO 5¢  DO¢  Tgsel(i) = i¢  OD¢FOR i = 0 TO 5¢  DO¢    DO¢    f = Rand( 6 )¢    UNTIL f # i¢    OD¢  y = Tgsel(i)¢  Tgsel(i) = Tgsel(f)¢  Tgsel(f) = y¢  OD¢RETURN  ¢¢;-------------------¢PROC BingBong()¢      ¢BYTE bi, bo¢¢FOR bi = 0 TO 15  ¢  DO¢  Sound(0, 60, 10, 15-bi)¢  Sound(1, 64, 10, 15-bi)¢  FOR bo = 0 TO 250¢    DO¢    ;¢    OD¢  Sound(0, 80, 10, 15-bi)¢  Sound(0, 84, 10, 15-bi)¢  FOR bo = 0 TO 250¢    DO¢    ;¢    OD¢  OD¢¢Sound(0, 0, 0, 0)¢Sound(1, 0, 0, 0)¢RETURN¢¢¢;-------------------¢PROC BingBap()¢¢BYTE bi, ba¢¢FOR bi = 0 TO 15  ¢  DO¢  Sound(0, 240, 8, 15-bi)¢  Sound(1, 245, 6, bi)¢  FOR ba = 0 TO 250¢    DO¢    ;¢    OD¢  Sound(0, 180, 8, 15-bi)¢  Sound(0, 194, 12, bi)¢  FOR ba = 0 TO 250¢    DO¢    ;¢    OD¢  OD¢¢Sound(0, 0, 0, 0)¢Sound(1, 0, 0, 0)¢RETURN¢¢;-------------------¢¢PROC MAIN()¢  BYTE y, f, i, j¢  INT radius¢  BYTE bulls¢  CARD score, hits, misses¢  CARD hiscore, round¢  BYTE hipct¢  CARD x¢  BYTE BK=712¢  ¢  round   = 1¢  hipct   = 0¢  hiscore = 0¢  Title( )¢DO¢; Until ESCAPE¢  Graphics(31)  ¢  BK = 12¢  bulls = 0¢  score = 0¢  hits  = 0¢  misses= 0¢  GAMESCREEN()¢  ZeroTime()¢; Randomize target selection¢  RandTgts() ¢  i = 0¢  FOR j = 0 TO 5¢    DO¢    color = 3¢    FOR f = 1 TO 10¢      DO¢      SelTarget( tgsel( i ) )¢        DO¢        GunRead( @x, @y )¢        UNTIL TRIGGER=15 OR CH=28¢        OD¢      IF CH = 28 THEN¢        CH=255¢        Graphics(0)¢        PrintE("Sharp Shooter, by Mat*Rat")¢        PrintE("(c) 1989, Analog Computing")¢        RETURN¢        FI¢      color = color + 1¢      IF color > 3 THEN¢        color = 1¢      FI¢      Blast( x, y )¢      radius = GetRadius(x,y,tgsel(i))¢      IF radius <= 5 THEN¢        bulls = bulls + 1¢        BingBong()¢        FI¢      IF radius <= 25 THEN¢        hits  = hits  + 1¢        score = score + (26-radius)¢      ELSE¢        misses = misses + 1¢        BingBap()¢        FI¢        DO¢        UNTIL TRIGGER=14¢        OD¢      color = 0¢      SelTarget( tgsel(i))¢      i = i + 1¢      IF i > 5 THEN¢        i = 0¢        RandTgts()¢        FI¢      color = Rand(3) + 1¢      OD¢    OD¢  x = GetJTime()¢  x = x/60¢  IF x < 3600 THEN¢    x = 3600/x¢  ELSE¢    x = 0¢  FI¢  CH = 255¢  Graphics(0)  ¢  Poke (710, 20)¢  Position(2,2)¢  PrintE("Sharp Shooter By Mat*Rat")¢  Print("Final Score for Round ")¢  PrintCE( round )¢  round = round + 1¢  Print("Bullets/Min  = ")¢  PrintCE( x )¢  Print("Total Hits   = ")¢  PrintCE( hits )¢  Print("Total Misses = ")¢  PrintCE( misses )¢  Print("Bullseyes    = ")¢  PrintBE( bulls )¢  Print("Score        = ")¢  PrintCE( score )¢  IF score > hiscore THEN¢    hiscore = score¢    FI¢  Print("Accuracy     = ")¢  x = 100 * bulls¢  x = x/60¢  IF x > hipct THEN¢    hipct = x¢    FI¢  PrintC( x )¢  PrintE("%")¢  PrintE("")¢  Print("High Score   = ")¢  PrintCE( hiscore )¢  Print("Best Accuracy= ")¢  PrintB( hipct )¢  PrintE("%")¢  PrintE("")¢  PrintE("Press  ק≥Θττσ≥á to play")¢  PrintE("Or typeáדצבIJסדá to exit")¢  DO¢  UNTIL TRIGGER=14 OR CH=28¢  OD¢  DO ¢  UNTIL TRIGGER=15 OR CH=28¢  OD¢  DO¢  UNTIL TRIGGER=14 OR CH=28¢  OD¢¢UNTIL (CH = 28)¢OD¢¢CH=255¢Graphics(0)¢PrintE("Sharp Shooter, by Mat*Rat")¢PrintE("(c) 1989, Analog Computing")¢RETURN¢¢