From: anyone@cyberden.sf.ca.us
Newsgroups: comp.sys.atari.8bit
Subject: POLYB.ACT
Date: Mon, 25 Jan 93 21:40:43 PST
Reply-To: anyone@cyberden.sf.ca.us
Organization: Indescribable Creations

Ran outta time last time.  Using alternate account:  POLYB.ACTion! 
follows:

; PolyB.ACT  - Action! version of PolyB.C
; programmed by Scott0LaValley in C "IHOL" BBS 1993
; translated to Action! by Bill Kendrick, NBS 1993
 
; fully commented!!!  :)
 
; global declarations: (can be used anywhere)
Byte InternalKeyAddress=764, ; Address of internal key value
  ColrReg1=708,ColrReg2=709,ColrReg3=710,
  LMar=82,RMar=83,Chg
Char Array SpeedCh(5),Buffer(25),ClearCh(5)
Int Dimensiona=[160],Dimensionb=[192],j,
  Colr,Speed,i,Compare,Echo,Clear,e,f,a,
  b,x,y,h,k,IncrementA,IncrementB,
  IncrementC,IncrementD,ea,fa,ab,bb,xc,
  yc,hd,kd,jv
Card ScreenMem=88 ; screen memory pointer
 
 
 
; following is Function "Key", which returns Byte values...
Byte Func Key() ; Replaces "KbHit" function in C
  If InternalKeyAddress=255 Then Return(0) Fi ; No keys hit
  InternalKeyAddress=255 ; Clear it...
Return(1) ; Otherwise, someone hit something
 
 
Proc ScreenOn()
  Graphics(31) ; 160 x 192 x 4 - no text window
  SetColor(0,1,14) ; bright yellow   /
  SetColor(1,12,8) ; medium green   < default colors
  SetColor(2,4,2) ; dark red         \
  ; (the SetColor commands effect the ColrReg_ values, at addresses 708, 
709, 710)
Return
 
 
Proc Rotate() ; Rotates colors
Byte C1,C2,C3 ; I added this myself
  C1=ColrReg1 ; color 1
  C2=ColrReg2 ; color 2
  C3=ColrReg3 ; color 3
  If Chg=0 Then C1=Rand(256) Fi ; Insert random color
  ColrReg1=C2
  ColrReg2=C3
  ColrReg3=C1
Return
 
 
; following is Function "Inp" (input), which returns Int(eger) values...
Int Func Inp(Int Default) ; Inputs from user, null input results in 
returning of default value
Int UserVal
  Print(" (") PrintI(Default) Print("):") ; show default value in ()'s
  InternalKeyAddress=255
  Do ; Repeat
    ; NADA
  Until InternalKeyAddress<255 Od ; wait for key... (don't clear tho!!)
  If InternalKeyAddress<>12 Then ; didn't hit [RETURN]
    UserVal=InputI()
    Return(UserVal)
  Fi
  ; did hit [RETURN]
  PrintIE(Default)
Return(Default)
 
 
Proc GetData() ; get data from user (or use default data)
  PutE() PrintE("Return alone selects defaults (in '()'s)")
  Print("Point 1 Increment?") ; speed values
  IncrementA=Inp(2)
  Print("Point 2 Increment?")
  IncrementB=Inp(4)
  Print("Point 3 Increment?")
  IncrementC=Inp(6)
  Print("Point 4 Increment?")
  IncrementD=Inp(8)
  Print("Echo? (0=yes, 1=no)") ; leave trail?
  Echo=Inp(0)
  Print("Clear speed?") ; clear screen ever ?th count
  Clear=Inp(500)
  Print("Insert colors? (0=yes, 1=no)") ; insert random colors every 
color rotate?
  Chg=Inp(0)
  Print("Color change speed? (1=fast)") ; change speed every ?th count
  JV=Inp(10)
  InternalKeyAddress=255
Return
 
 
; - main -
 
Proc Main() ; the main loop!
  ; title:
  Graphics(0) LMar=0 RMar=39 ColrReg2=15 ColrReg3=0 ; text mode, white 
text, black bkgd
  PrintE("PolyBounce Version 1.0 by Scott LaValley") PutE()
  PrintE("The International House of LeeChes") PrIntE("415-897-8190") 
PutE() PutE()
  PrintE("Converted to Action! by Bill Kendrick") PutE()
  PrintE("NBS 1993")
  GetData()
  j=0 Colr=1
 
  ; startup:
  ScreenOn()
  Color=1 ; (not same as "Colr".. "Colr" is variable, "Color" is system 
command!!!)
  e=Rand(50)  f=Rand(20)
  a=Rand(175) b=Rand(200)
  x=Rand(22)  y=Rand(97)
  h=Rand(3)   k=Rand(125)
  ea=2  fa=2
  ab=-3 bb=-3
  xc=5 ; where's yc Scott?
  hd=-7 kd=-7
 
  ; main loop:
  While Key()=0 Do ; while nobody hits a key, do ALL of this stuff!:
    j=j+1 ; increase 'J' counter
    If J Mod JV=0 Then Colr=Colr+1 Fi ; every 'JV'th count, change color
    If Colr=4 Then ; every 4th color, roll over to 0 & rotate colors
      Colr=0 Rotate()
      If Echo=1 And Colr=0 Then Colr=1 Fi
    Fi
 
    ; erase line if need be (move above update so it won't be DIRECTLY 
after last draw... thus replacing the Pause()
    If Echo<>0 Then ; routine from the C version)
      SetBlock(ScreenMem,7680,0) ; note: this replaces a bunch of plot's 
and DrawTo's by simply clearing screen memory     
    Fi ; FAST! (7680=bytes of RAM used by screen)
 
    ; update (move) the points' positions:
    e=e+ea ; point position updaters moved ABOVE IF-tests so any moves 
off of screen will be caught
    f=f+fa ; BEFORE draw, rather than before MOVE and THEN draw.... (get 
it?!)
    If e<=1 Then E=1 ea=IncrementA Fi
    If f<=1 Then F=1 fa=IncrementA Fi
    If e>=DimensionA-1 Then E=DimensionA-1 ea=-IncrementA Fi
    If f>=Dimensionb-1 Then F=DimensionB-1 fa=-IncrementA Fi
 
    a=a+ab b=b+bb
    If a<=1 Then A=1 ab=IncrementB Fi
    If b<=1 Then B=1 bb=IncrementB Fi
    If a>=Dimensiona-1 Then A=DimensionA-1 ab=-IncrementB Fi
    If b>=Dimensionb-1 Then B=DimensionB-1 bb=-IncrementB Fi
 
    x=x+xc y=y+yc
    If x<=1 Then X=1 xc=IncrementC Fi
    If y<=1 Then Y=1 yc=IncrementC Fi
    If x>=Dimensiona-1 Then X=DimensionA-1 xc=-IncrementC Fi
    If y>=Dimensionb-1 Then Y=DimensionB-1 yc=-IncrementC Fi
 
    h=h+hd k=k+kd
    If h<=1 Then H=1 hd=IncrementD Fi
    If k<=1 Then K=1 kd=IncrementD Fi
    If h>=Dimensiona-1 Then H=DimensionA-1 hd=-IncrementD Fi
    If k>=Dimensionb-1 Then K=DimensionB-1 kd=-IncrementD Fi
 
    ; draw the lines:
    Color=Colr
    Plot(e,f) ; start line ...
    DrawTo(a,b) ; draw ...
    DrawTo(x,y) ; draw ...
    DrawTo(h,k) ; draw ...
    DrawTo(e,f) ; draw (connect to start)
 
    If j Mod Clear=0 And Echo=0 Then ScreenOn() Color=Colr Fi ; clear 
screen (every 'Clear'th count)
  Od ; end of loop
 
  Graphics(0) ; back to mode 0 and ...
Return ; ...the end!
 

__________________________________________________________________________
   |       /         |\
   | H E   \ Y B E R |/ E N            [ anyone@cyberden.sf.ca.us ]