home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Computing 65
/
ac065a.adf
/
mandy.asc
< prev
next >
Wrap
Text File
|
1993-07-21
|
6KB
|
385 lines
' Mandelbrot Explorer
'
' (c)1993 William Creasy
'
' Last compiled 16/6/93
'
' Entered into Amiga Computing fractal competition
'
A#=0.0
SQUARE=True
'
Unpack 5 To 1
'
Reserve Zone 5
Set Zone 1,38,8 To 124,18
Set Zone 2,172,8 To 258,18
Set Zone 3,38,27 To 124,37
Set Zone 4,172,27 To 258,37
Set Zone 5,350,8 To 436,18
'
Menu$(1)=" Project "
Menu$(1,1)=" Render "
Menu$(1,2)=" Save IFF "
Menu$(1,3)=" Reset "
Menu$(1,4)=" Quit "
'
Menu$(2)=" Options "
Menu$(2,1)=""
Menu$(2,2)=" Preview Mode "
Menu$(2,3)=" Fullscreen Mode "
Menu$(2,4)=" Zoom "
Menu$(2,5)=" Be Square Yes "
'
Menu On
On Menu Gosub PROJECT,OPTIONS
'
Screen Open 0,320,200,16,Lowres
Screen Hide 0
Curs Off : Flash Off : Cls 0
Unpack 6 To 0
Wind Open 1,35,50,30,12,1
Curs Off : Pen 15
Centre "Mandelbrot Explorer "
Print : Centre "(c)1993 William Creasy"
Print : Centre "For Amiga Computing AMOS"
Print : Centre "Fractal Competition"
Print : Print : Centre "This program is"
Print : Centre "Public Domain"
Print : Print : Centre "Please read the docs!"
Screen Display 0,,98,,
Screen Show 0
Repeat : Until Mouse Click=1
Limit Mouse 129,40 To 447,297
'
' initialize
'
Gosub RESET
'
Gosub REDRAW
'
Do
On Menu On
ZNE=Mouse Zone
If Mouse Click=1 and ZNE<>0
On ZNE Gosub EX1,EX2,EY1,EY2,EIT
End If
ZNE=0
Loop
'
'
'
GENERATOR:
MSG2$="Rendering..."
Gosub REDRAW
Screen 0 : Cls 0 : Hide On
'
XGAP#=(X2#-X1#)/SWIDE# : YGAP#=(Y2#-Y1#)/SHIGH#
'
Timer=0
For Y=0 To SHIGH#
Gosub STATS : Screen 0
YNEXT#=Y1#+(Y*YGAP#)
'
For X=0 To SWIDE#
XNEXT#=X1#+(X*XGAP#)
'
AX#=0.0
AY#=0.0
COUNT=0
'
Repeat
'
AXNEW#=AX#*AX#-AY#*AY#+XNEXT#
AYNEW#=2.0*AX#*AY#+YNEXT#
'
AX#=AXNEW#
AY#=AYNEW#
'
If COUNT>ITERATIONS
COUNT=0
Exit
End If
'
Inc COUNT
'
If Mouse Click=1
Show On
Goto LEAVE
End If
Until AX#*AX#+AY#*AY#>4.0
PIGMENT=COUNT mod(Screen Colour-1)
Plot X,Y,PIGMENT
'
Next X
Next Y
LEAVE:
Gosub STATS
MSG2$="What next ?"
Gosub REDRAW
Show On
Return
'
PROJECT:
'
If Choice(2)=1
Gosub GENERATOR
End If
'
If Choice(2)=2
F$=Fsel$("*.iff","","Save work as .IFF picture","")
If F$<>""
MSG2$="Saving work..."
Gosub REDRAW
Screen 0
Save Iff F$
MSG2$="What next ?"
Gosub REDRAW
Else
MSG2$="NOT SAVED!"
Bell
Gosub REDRAW
Wait 50
MSG2$="What next ?"
Gosub REDRAW
End If
F$=""
End If
'
If Choice(2)=3
Gosub RESET
Gosub REDRAW
End If
'
If Choice(2)=4
End
End If
'
Return
'
OPTIONS:
'
'
If Choice(2)=2
Gosub PREVIEW
End If
'
If Choice(2)=3
Gosub FULL_SCREEN
End If
'
If Choice(2)=4
Gosub _ZOOM
End If
'
If Choice(2)=5
'
If SQUARE=True
SQUARE=False
Menu$(2,5)=" Be Square No "
Else
SQUARE=True
Menu$(2,5)=" Be Square Yes "
End If
'
End If
'
Return
'
REDRAW:
'
Screen 1
Ink 1,0
'
Cls 0,40,9 To 123,17
Text 42,16,X1$
'
Cls 0,174,9 To 257,17
Text 176,16,X2$
'
Cls 0,40,28 To 123,36
Text 42,35,Y1$
'
Cls 0,174,28 To 257,36
Text 176,35,Y2$
'
Cls 0,352,9 To 435,17
Text 354,16,ITERATIONS$
'
Cls 0,552,9 To 629,17
Text 554,16,LINE$
'
Cls 0,552,28 To 629,36
Text 554,35,TIME$
'
Cls 0,268,20 To 430,40
Text 269,29,MSG1$
Text 269,39,MSG2$
'
Return
'
'
RESET:
'
X1#=-3.2 : X1$="-3.2"
X2#=3.2 : X2$="3.2"
Y1#=2.0 : Y1$="2"
Y2#=-2.0 : Y2$="-2"
ITERATIONS=100 : ITERATIONS$="100"
SWIDE#=320.0
SHIGH#=200.0
MSG1$="Full-screen Mode"
MSG2$="What next ?"
LINE$="200/200"
NOLINES$="/200"
TIME$="00:00:00"
Unpack 6 To 0
'
Return
'
_ZOOM:
'
MSG2$="Select zoom area..."
Gosub REDRAW
Screen 0 : Change Mouse 2 : Ink Screen Colour-1
'
While Mouse Click<>1
Wend
'
BX1=X Screen(X Mouse) : BY1=Y Screen(Y Mouse)
Repeat
Gr Writing 2
BX2=X Screen(X Mouse) : BY2=Y Screen(Y Mouse)
Box BX1,BY1 To BX2,BY2
Box BX1,BY1 To BX2,BY2
Until Mouse Click=1
'
If SQUARE=True
BY2=BY1+((BX2-BX1)*(200.0/320.0))
End If
'
Gr Writing 1
Box BX1,BY1 To BX2,BY2
'
XGAP#=(X2#-X1#)/SWIDE#
YGAP#=(Y2#-Y1#)/SHIGH#
'
X2#=BX2*XGAP#+X1# : X2$=Left$(Str$(X2#),10)
Y2#=BY2*YGAP#+Y1# : Y2$=Left$(Str$(Y2#),10)
X1#=BX1*XGAP#+X1# : X1$=Left$(Str$(X1#),10)
Y1#=BY1*YGAP#+Y1# : Y1$=Left$(Str$(Y1#),10)
'
MSG2$="What next ?"
Gosub REDRAW
'
Change Mouse 1
Return
'
PREVIEW:
'
SWIDE#=64.0
SHIGH#=40.0
MSG1$="Preview Mode"
NOLINES$="/40"
Gosub REDRAW
'
Return
'
FULL_SCREEN:
'
SWIDE#=320.0
SHIGH#=200.0
MSG1$="Full-screen Mode"
NOLINES$="/200"
Gosub REDRAW
'
Return
'
STATS:
'
SEC=Timer/50 mod 60 : SEC$=Str$(SEC)
MNS=Timer/3000 mod 60 : MNS$=Str$(MNS)
HRS=Timer/180000 : HRS$=Str$(HRS)
'
TIME$=HRS$-" "+":"+MNS$-" "+":"+SEC$-" "
'
LINE$=Str$(Y)
LINE$=LINE$+NOLINES$
'
Gosub REDRAW
'
Return
'
EX1:
Cls 0,40,9 To 124,18
ENTER_TEXT[41,16,9,Asc("-"),Asc("9")]
X1$=Param$
X1#=Val(X1$)
Return
'
EX2:
Cls 0,174,9 To 258,18
ENTER_TEXT[175,16,9,Asc("-"),Asc("9")]
X2$=Param$
X2#=Val(X2$)
Return
'
EY1:
Cls 0,40,28 To 124,37
ENTER_TEXT[41,35,9,Asc("-"),Asc("9")]
Y1$=Param$
Y1#=Val(Y1$)
Return
'
EY2:
Cls 0,174,28 To 258,37
ENTER_TEXT[175,35,9,Asc("-"),Asc("9")]
Y2$=Param$
Y2#=Val(Y2$)
Return
'
EIT:
Cls 0,352,9 To 436,18
ENTER_TEXT[353,16,9,Asc("0"),Asc("9")]
ITERATIONS$=Param$
ITERATIONS=Val(ITERATIONS$)
Return
'
Procedure ENTER_TEXT[X,Y,MOST,LORANGE,HIRANGE]
'
Ink 1,0
'
' define key scancodes
'
RET=68 : ENTER=67 : BACK=65
'
While SC<>RET and SC<>ENTER
'
K$=Inkey$
SC=Scancode
Ink 3 : Draw X,Y To X+7,Y : Ink 1
'
If Asc(K$)>=LORANGE and Asc(K$)<=HIRANGE and Asc(K$)<>47
If COUNT<MOST
Inc COUNT
Text X,Y,K$
Add X,8
TXT$=TXT$+K$
End If
End If
'
'
If SC=BACK and COUNT>0
Ink 0
Draw X,Y To X+7,Y
Ink 1
Add X,-8
Text X,Y," "
TXT$=Left$(TXT$,COUNT-1)
Dec COUNT
End If
Wend
'
Ink 0 : Draw X,Y To X+7,Y
End Proc[TXT$]