Superhop ACTION!

 [ Table of Contents ] [ Disk Image

From page 20 of Antic Magazine August 1989 Volume 8 Number 4.

Superhop ACTION!

Faster fractals grow in your Atari

By Douglas Skrecky



Watch elegant fractal patterns come alive onscreen at top speed with this fast and friendly ACTION! program. It works on 8-bit Atari computers with at least 48K memory and disk drive. If you are typing in the program, you will need the ACTION! cartridge from ICD. But if you own this month's Antic Disk, you will find a version that runs without the special cartridge.

In May, 1987, Antic published my fractal generating program Dot Hopper. That program used floating point arithmetic and was written in BASIC. Consequently, it was quite slow.

After playing with the ACTION! cartridge for awhile, I realized that floating point calculations were completely unnecessary for this language. Between ACTION!'s inherent speed and integer arithmetic, I found that the program could be made to run many times faster than in BASIC. Using ACTION!, the Atari could generate fractal patterns in seconds. The fractals appear to "come alive" and grow right before your eyes.

You don't have to know anything about the mathematics of fractal geometry to appreciate these elegant patterns. Some are startlingly organic, others are reminiscent of snowflakes and lace. If you enjoy the beauty of fractal imagery, you 'll have fun with this program.

Getting Started

Type in Listing 1, SUPERHOP.ACT, and save a copy to disk before you start the program.

Antic Disk users don't need the ACTION! language cartridge to enjoy Superhop ACTION!. A runtime version, SUPERHOP.EXE, is on this month's disk. (As is usually the case, this runtime ACTION! translation would be too long to print as a type-in listing.) Copy SUPERHOP.EXE to another disk that has been formatted with DOS 2 or DOS 2.5, and make sure the disk contains a DOS.SYS file. Rename SUPERHOP.EXE to AUTORUN.SYS so that the program will load and run automatically.

To start growing fractals, turn off your Atari and insert your prepared Superhop ACTION! disk. Remove all cartridges (XL and XE owners press [OPTION]) and turn on your computer. Superhop ACTION! will load and run automatically.



When the program runs, it first presents the main menu, which lists the various commands and options. You can return to this menu from any other screen simply by pressing [M].

Pressing [D] activates the demo mode, which generates successive fractals through 15,000 iterations each (it doesn't take very long). Demo mode continues generating fractals until you press the [M] key to return to the meu, or press [C] to generate a single fractal.

While fractals are being generated in either Demo or Create mode, pressing the cursor keys (you don't have to press the [CONTROL] key with them) will shift the fractal so that you can view a different portion on the screen. However, the fractal is erased from the screen and growth process must begin all over again --- with the same pattern. The patterns are generated fast enough that this isn't a big inconvenience.

You may use the [>] key to "zoom in" on a portion of the fractal, enlarging it on the screen. The [<] key "zooms out". These keys also start the fractal growth process over again.

Pressing [C] changes the pattern. To see some of the possible patterns, try letting each pattern grow for only a few seconds before pressing [C] again. Then if a new pattern looks particularly interesting you can let it grow, and see how it develops.

Also, try letting patterns sit on the screen for several minutes after they seem to have stopped growing --- they may surprise you. 

Save A Fractal

If you see a fractal pattern you like, you can save it to disk by pressing the [S] key. Doing so will read in a disk directory and let you choose a filename to save the screen under. The fractal is saved as a 62-secor Micro-Painter compatible file. Once the image has been saved, the program will return to the pattern in progress, which continues to grow without starting over.

To convert your Micro-Painter image to Micro Illustrator format, you can use Rapid Graphics Convert in the November 1985 Antic.

To load a fractal into Superhop ACTION! press [L]. A directory of the disk in drive 1 will be displayed. Enter the filename of the fractal you want, and it will appear on the screen. (Note that the fractal does not continue to grow after it has been loaded.)

Pressing the [SPACEBAR] will turn off the screen and speed up fractal growth by about 30%, although I realize that this is not an especially useful function! 

Douglas Skrecky is a mainframe programmer who currently lives in Vancouver, Canada. He likes to relax after work with his "trusty Atari 8-bit and perhaps a mug of beer."

Source Code

INVERSE ATASCII characters filter out of source code listing.

;SUPERHOP ACTION!
;BY DOUGLAS SKRECKY
;(C)1989, ANTIC PUBLISHING INC.
;
DEFINE BEGIN="DO",ENDWHILE="OD",
       ENDIF="FI",END="OD"
;
MODULE
 CARD ARRAY LINE(192)
 BYTE ARRAY RSH3(320),FILENAME(16)
 BYTE KEY=764,DISPLAY=559,IOTYPE=850,
      SCREEN_SIZE,R1,R2,Z,MENUKEY,
      CLEAR,LARGER,SMALLER,UP,DOWN,
      LEFT,RIGHT,SPACEBAR,LOAD,SAVE,
      CREATE,DEMO,DEMOMODE,ON,OFF,PY
INT   CX,CY,X,Y,XX,I,J,IC,JC,X0,Y0
CARD  BUFFER_ADDRESS=852,COUNT,PX,
      BUFFER_LENGTH=856,SCREEN=88
;
PROC INITIALIZE_PLOT()
 GRAPHICS(8+16) 
 SETCOLOR(2,0,0)
 FOR PY=0 TO 191 
 BEGIN
  LINE(PY)=SCREEN+40*PY
 END
 FOR PX=0 TO 319
 BEGIN
  RSH3(PX)=PX RSH 3
 END
RETURN
;
PROC PLOT(CARD PX,BYTE PY)
 BYTE POINTER PT
 BYTE ARRAY ON=[128 64 32 16 8 4 2 1]
 PT=LINE(PY) + RSH3(PX)
 PT^==%ON(PX&7)
RETURN
;
PROC CIO=$E456(BYTE AREG,XREG)[]
;
PROC DISKDIR()
 BYTE ARRAY FILES(20)
 GRAPHICS(0)
 SETCOLOR(2,9,0)
 SETCOLOR(4,9,0)
 CLOSE(1)
 OPEN(1,"D1:*.*",6,0)
 PRINTE("           DISK DIRECTORY          ")
 INPUTSD(1,FILES)
 WHILE FILES(16)<>'S 
 BEGIN
  PRINTF("%S%S",FILES,"  ")
  INPUTSD(1,FILES)
 ENDWHILE
 PRINTF("%E%S%S%E","          ",FILES)
 CLOSE(1)
RETURN
;
PROC CHOOSE_FILE()
 BYTE ARRAY TEMP(16)
 PRINT("==>")
 ZERO(FILENAME,16)
 FILENAME(1)='D
 FILENAME(2)='1
 FILENAME(3)=':
 KEY=CLEAR
 INPUTS(TEMP)
 SASSIGN(FILENAME,TEMP,4,16)
RETURN 
;
PROC LOAD_FRACTAL()
 DISKDIR()
 PRINTE("  TYPE IN FILENAME TO LOAD PICTURE  ")
 CHOOSE_FILE()
 CLOSE(1)
 OPEN(1,FILENAME,4,0)
 GRAPHICS(8+16)
 SETCOLOR(2,0,0)
 IOTYPE=7
 BUFFER_ADDRESS=SCREEN
 BUFFER_LENGTH=7680
 CIO(0,16)
 CLOSE(1)
 KEY=CLEAR
 DO UNTIL KEY=LOAD OR KEY=DEMO OR
  KEY=CREATE OR KEY=MENUKEY
 END
 INITIALIZE_PLOT()
RETURN
;
PROC SAVE_FRACTAL()
 BYTE ARRAY SAVESCREEN(7680)
 MOVEBLOCK(SAVESCREEN,SCREEN,7680)
 DISKDIR()
 PRINTE("  TYPE IN FILENAME TO SAVE PICTURE  ")
 CHOOSE_FILE()
 CLOSE(1)
 OPEN(1,FILENAME,8,0)
 IOTYPE=11
 BUFFER_ADDRESS=SAVESCREEN
 BUFFER_LENGTH=7680
 CIO(0,16)
 CLOSE(1)
 INITIALIZE_PLOT()
 MOVEBLOCK(SCREEN,SAVESCREEN,7680)
RETURN
;
PROC MENU()
 GRAPHICS(0) 
 POKE(752,1)
 SETCOLOR(2,9,0)
 SETCOLOR(4,9,0)
 PRINT("               SUPERHOP!              ")
 PUTE()
 PUTE()
 PUTE()
 PUTE()
 PRINTE(" Press M To Return to THIS Menu")
 PRINTE(" Press D To Turn Demomode On")
 PRINTE(" Press C To Create a Fractal")
 PRINTE(" Press L To Load a Fractal Picuture");
 PRINTE(" Press S To Save a Fractal Picture");
 PRINTE(" Press < To Zoom-out For a Wider View") 
 PRINTE(" Press > To Zoom-in Or Magnify")
 PRINTE(" Use the Cursor Keys To Move Fractal")
 PRINTE(" Press Spacebar To Toggle Display")
 PUTE()
 PUTE()
 PUTE()
 PUTE()
 PRINTE("        BY Douglas Skrecky")
 KEY=CLEAR
 WHILE KEY=CLEAR OR KEY=SAVE OR KEY=SPACEBAR
 BEGIN
 ENDWHILE
 INITIALIZE_PLOT()
RETURN
;
PROC SETUP()
 CLEAR=255
 CREATE=18
 DEMO=58
 MENUKEY=37
 LARGER=55
 SMALLER=54
 UP=14
 DOWN=15
 LEFT=6
 RIGHT=7
 LOAD=0
 SAVE=62
 SPACEBAR=33
 ON=34
 OFF=0
 DEMOMODE=OFF
RETURN
;
PROC NEW_PARAMETERS()
 BYTE ATTRACT=77
 ATTRACT=0
 X=0
 Y=0
 Z=0
 COUNT=0
 X0=0
 Y0=0
 CX=200+2*RAND(0)+RAND(0)
 CY=200+2*RAND(0)+RAND(0)
 R1=1+RAND(5)
 R2=2+RAND(4)
 JC=96
 IC=160
 SCREEN_SIZE=6
RETURN
;
PROC DRAW_FRACTAL()
 BYTE ATTRACT=77
 ATTRACT=0
 IF Y>0 THEN J=JC+(Y RSH SCREEN_SIZE)
  ELSE J=JC-(-Y RSH SCREEN_SIZE)
 ENDIF
 IF X>=0 THEN XX=Y+((X RSH R1)+CX)
  IF J>0 AND J<191 THEN I=IC+(X RSH SCREEN_SIZE)
   IF I>0 AND I<319 THEN PLOT(I,J)
   ENDIF
  ENDIF
 ELSE XX=Y+((-X RSH R2)-CX)
  IF J>0 AND J<191 THEN I=IC-(-X RSH SCREEN_SIZE)
   IF I>0 AND I<319 THEN PLOT(I,J)
   ENDIF
  ENDIF
 ENDIF
 Y=(CY-X)       
 Z==+1
 X=XX
 IF Z=0 THEN Y==-7
 ENDIF
 IF DEMOMODE=ON THEN COUNT==+1
  IF COUNT>15000 THEN KEY=DEMO
  ENDIF
 ENDIF
RETURN
;
PROC CHANGE_PARAMETERS()
 IF KEY=MENUKEY THEN MENU()  
  INITIALIZE_PLOT()
 ENDIF
 IF KEY=SPACEBAR THEN
  IF DISPLAY=OFF THEN DISPLAY=ON
   ELSE DISPLAY=OFF
  ENDIF
  KEY=CLEAR RETURN
 ENDIF
 IF KEY=SAVE THEN
  SAVE_FRACTAL()
  RETURN
 ENDIF
 IF KEY=LOAD THEN    
  LOAD_FRACTAL()
  NEW_PARAMETERS()
  RETURN
 ENDIF
 IF KEY=DEMO THEN
  DEMOMODE=ON
  NEW_PARAMETERS()
 ELSE
  DEMOMODE=OFF
 ENDIF
 IF KEY=CREATE THEN
  NEW_PARAMETERS()
 ENDIF
 IF KEY=LARGER AND SCREEN_SIZE>1 THEN
  SCREEN_SIZE==-1
  IC=2*IC-162 
  JC=2*JC-96
 ENDIF
 IF KEY=SMALLER AND SCREEN_SIZE<8 THEN
  SCREEN_SIZE==+1
  IC=(162+IC)/2
  JC=(96+JC)/2
 ENDIF
 IF KEY=LEFT THEN
  IC==-10
 ENDIF
 IF KEY=RIGHT THEN
  IC==+10
 ENDIF
 IF KEY=UP THEN 
  JC==-10
 ENDIF
 IF KEY=DOWN THEN
  JC==+10
 ENDIF
 ZERO(SCREEN,7680)
 X=0
 Y=0
 Z=0
 COUNT=0
 KEY=CLEAR
RETURN
;
PROC HOPDEMO()
 SETUP()
 MENU()
 NEW_PARAMETERS()
 BEGIN
  WHILE KEY=CLEAR      
  BEGIN
   DRAW_FRACTAL()
  ENDWHILE
  CHANGE_PARAMETERS()
 END
RETURN


Comments

Popular posts from this blog

ANALOG MAN

Guessing Game 1