home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 2 / crawlyvol2.bin / graphics / fractal2 / fractal2.lst < prev    next >
File List  |  1985-11-17  |  18KB  |  718 lines

  1. '
  2. ' Mandelbrot set (fractal) generator program
  3. ' Originally programmed in "C" by Tom Hudson (January, 1986 ANALOG Computing).
  4. '
  5. ' Converted to GFA and enhanced (GEM support, etc.) by Blake Arnold
  6. ' (co-author of Ultra-Graph from the November, 1988 ST-Log).
  7. '
  8. ' 10-18-89
  9. '
  10. ' ************* NOTICE ************ NOTICE ************ NOTICE ************
  11. ' Portions of this program are Copyright 1989 by Tom Hudson, ANALOG
  12. ' Computing, Blake Arnold, and Phil Mast.  This program is not public
  13. ' domain but may be freely distributed.  It may not be sold in any way.
  14. ' *************************************************************************
  15. '
  16. ' -------------------------------------------------------------------
  17. Gosub Main
  18. Procedure Main
  19.   ' Initialize
  20.   Res%=Xbios(4)  !Get the resolution
  21.   If Res%<>0
  22.     Alert 3,"|Use low resolution.",1," Ok ",Dum%
  23.     Edit
  24.   Endif
  25.   Dim S_colr%(15,2),Rgb%(2)
  26.   Dim Colrtable%(15)
  27.   Dim Sav%(15,3),Sa%(16)
  28.   Dim D$(34)
  29.   ' Menu data
  30.   D$(0)="Desk"
  31.   D$(1)=" About Fractals "
  32.   D$(2)="----------------"
  33.   D$(3)="-"  ! "-" disables that menu item (disables ACC's here)
  34.   D$(4)="-"
  35.   D$(5)="-"
  36.   D$(6)="-"
  37.   D$(7)="-"
  38.   D$(8)="-"
  39.   D$(9)=""  !menus are seperated by a null
  40.   D$(10)="File"
  41.   D$(11)=" Degas Save      "
  42.   D$(12)="-----------------"
  43.   D$(13)=" Save Fractal    "
  44.   D$(14)=" Save Parameters "
  45.   D$(15)="-----------------"
  46.   D$(16)=" Load Fractal    "
  47.   D$(17)=" Load Parameters "
  48.   D$(18)="-----------------"
  49.   D$(19)="      Quit       "
  50.   D$(20)=""
  51.   D$(21)="Options"
  52.   D$(22)="  Spectrum    "
  53.   D$(23)="  Yellow      "
  54.   D$(24)="  Gradient    "
  55.   D$(25)="  Sys. Default"
  56.   D$(26)="--------------"
  57.   D$(27)="  Draw it!    "
  58.   D$(28)="--------------"
  59.   D$(29)="  Input Data  "
  60.   D$(30)="  Iterations  "
  61.   D$(31)="  Defaults    "
  62.   D$(32)=""
  63.   ' store original color palette
  64.   For I%=0 To 15
  65.     Dpoke Contrl,26
  66.     Dpoke Contrl+2,0
  67.     Dpoke Contrl+6,2
  68.     Dpoke Intin,I%
  69.     Dpoke Intin+2,0
  70.     Vdisys
  71.     S_colr%(I%,0)=Dpeek(Intout+2)
  72.     S_colr%(I%,1)=Dpeek(Intout+4)
  73.     S_colr%(I%,2)=Dpeek(Intout+6)
  74.   Next I%
  75.   Colrtable%(0)=0
  76.   Colrtable%(1)=2
  77.   Colrtable%(2)=3
  78.   Colrtable%(3)=6
  79.   Colrtable%(4)=4
  80.   Colrtable%(5)=7
  81.   Colrtable%(6)=5
  82.   Colrtable%(7)=8
  83.   Colrtable%(8)=9
  84.   Colrtable%(9)=10
  85.   Colrtable%(10)=11
  86.   Colrtable%(11)=14
  87.   Colrtable%(12)=12
  88.   Colrtable%(13)=15
  89.   Colrtable%(14)=13
  90.   Colrtable%(15)=1
  91.   Gosub Palette
  92.   Cls
  93.   Palette%=0
  94.   Scrn%=1
  95.   Sget Screen1$
  96.   Iterations!=True
  97.   Fractal!=False   ! we havent drawn a fractal yet
  98.   If Exist("MANDEL.MBS")
  99.     ' Why waste time redrawing the set?  We'll cheat and load it right in!
  100.     Fractal!=True
  101.     Filename$="MANDEL.MBS"
  102.     Gosub Load_screen
  103.     Close #1
  104.   Else
  105.     Fractal!=False
  106.   Endif
  107.   Gosub Screenswap
  108.   ' Let the program know where to go on a drop-down selection
  109.   On Menu  Gosub Set_options
  110.   Gosub Defaults
  111.   Gosub Mark_menu
  112.   ' ----Main Loop for the option menu----
  113.   Do
  114.     On Menu
  115.     If Mousek=2
  116.       Gosub Screenswap
  117.     Endif
  118.     If Mousek=3
  119.       Gosub Process
  120.       Gosub Hold_it
  121.     Endif
  122.   Loop
  123. Return
  124. Procedure Set_options
  125.   ' OOOOOOOOOOOOOOOOOOOOOOOOOOO-Set Options-OOOOOOOOOOOOOOOOOOOOOOOOOOO
  126.   ' Drop-down menu selections
  127.   Menu Off
  128.   If D$(Menu(0))=D$(1)  ! About Fractals
  129.     Read_again:
  130.     Cls
  131.     Print "   This program was originally written"
  132.     Print "by Tom Hudson and published in the"
  133.     Print "January, 1986 issue of 'ANALOG"
  134.     Print "Computing'.  Portions of this program"
  135.     Print "are Copyright 1989 by Tom Hudson,"
  136.     Print "ANALOG Computing, Blake Arnold, and"
  137.     Print "Phil Mast.  The program may not be"
  138.     Print "sold in any way, but may be freely"
  139.     Print "distributed as long as the copyright"
  140.     Print "notices remain intact."
  141.     Print "   I have taken the liberty to convert"
  142.     Print "Tom's math/drawing routines into GFA"
  143.     Print "Basic, and add a few features that"
  144.     Print "make the program a little easier to use."
  145.     Print "   Please refer to the included"
  146.     Print "documentation file for detailed"
  147.     Print "instructions on using the program."
  148.     Print
  149.     Print " - Blake Arnold (Delphi '1BLAKE')"
  150.     Print
  151.     Print "      Press any key to exit"
  152.     ' ******
  153.     Do
  154.       Exit If Inkey$<>""
  155.     Loop
  156.     Gosub Params
  157.   Endif
  158.   If D$(Menu(0))=D$(11)  ! Save Picture
  159.     Dum%=1
  160.     If Fractal!=False
  161.       Alert 3,"|No Fractal has been|drawn with these|parameters.     ",1,"Save |Abort",Dum%
  162.     Endif
  163.     If Dum%=1
  164.       Extender$=".PI1"
  165.       Choice%=0
  166.       Gosub Open_file
  167.     Endif
  168.   Endif
  169.   If D$(Menu(0))=D$(14)  ! Save Parameters
  170.     Extender$=".MBP"
  171.     Choice%=2
  172.     Gosub Open_file
  173.   Endif
  174.   If D$(Menu(0))=D$(17)  ! Load Parameters
  175.     Choice%=4
  176.     Extender$=".MBP"
  177.     Fractal!=False
  178.     Gosub Open_file
  179.   Endif
  180.   If D$(Menu(0))=D$(13)  ! Save Fractal
  181.     If Fractal!=True
  182.       Choice%=1
  183.       Extender$=".MBS"
  184.       Gosub Open_file
  185.     Else
  186.       Alert 3,"|No Fractal has been|drawn with these|parameters.     ",1,"Abort",Dum%
  187.     Endif
  188.   Endif
  189.   If D$(Menu(0))=D$(16)  ! Load Fractal
  190.     Fractal!=False
  191.     Choice%=3
  192.     Extender$=".MBS"  !  MBS - MandelBrot Set
  193.     Gosub Open_file
  194.   Endif
  195.   ' I can't forsee anyone wanting to stop drawing fratcals, but just in case..
  196.   If D$(Menu(0))=D$(19)  ! Quit
  197.     Alert 2,"| Quit Fractals? ",1,"Yes|No ",Dum%
  198.     If Dum%=1
  199.       ' Restore original color palette
  200.       For I%=0 To 15
  201.         Dpoke Contrl,14
  202.         Dpoke Contrl+2,0
  203.         Dpoke Contrl+6,4
  204.         Dpoke Intin,I%
  205.         Dpoke Intin+2,S_colr%(I%,0)
  206.         Dpoke Intin+4,S_colr%(I%,1)
  207.         Dpoke Intin+6,S_colr%(I%,2)
  208.         Vdisys
  209.       Next I%
  210.       Menu Kill
  211.       Menu Off
  212.       Cls
  213.       Edit
  214.     Endif
  215.   Endif
  216.   If D$(Menu(0))=D$(24)  ! Gradient
  217.     Alert 2,"|  Which Color?  ",1,"R|G|B",Palette%
  218.     Gosub Palette
  219.   Endif
  220.   If D$(Menu(0))=D$(22) ! Spectrum
  221.     Palette%=0
  222.     Gosub Palette
  223.   Endif
  224.   If D$(Menu(0))=D$(23) ! Yellow
  225.     Alert 2,"|  Positive or Negative?  ",1,"Pos.|Neg.",Palette%
  226.     Palette%=Palette%+3
  227.     Gosub Palette
  228.   Endif
  229.   If D$(Menu(0))=D$(25) ! System Default
  230.     For I%=0 To 15
  231.       Palette%=7
  232.       Dpoke Contrl,14
  233.       Dpoke Contrl+2,0
  234.       Dpoke Contrl+6,4
  235.       Dpoke Intin,I%
  236.       Dpoke Intin+2,S_colr%(I%,0)
  237.       Dpoke Intin+4,S_colr%(I%,1)
  238.       Dpoke Intin+6,S_colr%(I%,2)
  239.       Vdisys
  240.     Next I%
  241.     Gosub Mark_menu
  242.   Endif
  243.   If D$(Menu(0))=D$(27)  ! Draw it
  244.     Gosub Process
  245.     Gosub Hold_it
  246.   Endif
  247.   If D$(Menu(0))=D$(29)
  248.     Iterations!=False
  249.     Gosub Inp_data
  250.     Gosub Params
  251.   Endif
  252.   If D$(Menu(0))=D$(30)  !Iteration input
  253.     Iterations!=True
  254.     Gosub Inp_data
  255.     Gosub Params
  256.     Iterations!=False
  257.     Fractal!=False
  258.   Endif
  259.   If D$(Menu(0))=D$(31)  ! Defaults
  260.     Alert 2,"| Restore Defaults? ",2,"Yes|No",Dum%
  261.     Fractal!=False
  262.     If Dum%=1
  263.       Gosub Defaults
  264.     Endif
  265.   Endif
  266. Return
  267. Procedure Inp_data
  268.   ' ******* Map parameter input ********
  269.   Fractal!=False
  270.   Cls
  271.   If Iterations!=False
  272.     Print
  273.     Print
  274.     Print "Previous values:"
  275.     Print "Real Center : ";Ixs
  276.     Print "Real Range  : ";Rrange
  277.     Print "Imag. Center: ";Iys
  278.     Print "Imag. Range : ";Ye-Ys
  279.     Print "Iterations  : ";Climit%
  280.     Print
  281.     Print
  282.     Print "Enter new values:"
  283.     Input "Real Number Center";Ixs
  284.     '  Ixs=-0.75  !****  (default parameters)
  285.     Input "Real number range";Rrange
  286.     '  Rrange=3.25 !****
  287.     Input "Imaginary number center";Iys
  288.     '  Iys=0 !****
  289.     Input "Iteration limit";Climit%
  290.     '  climit=100 !****
  291.   Else
  292.     Print
  293.     Print
  294.     Print "Change iteration limit"
  295.     Print
  296.     Print "Previous iteration limit: ";Climit%
  297.     Input "New iteration limit";Climit%
  298.   Endif
  299. Return
  300. Procedure Params
  301.   Cls
  302.   Xs=Ixs-Rrange/2
  303.   Xe=Xs+Rrange
  304.   Xstep=(Xe-Xs)/319
  305.   Ys=Iys-(Rrange*0.77)/2
  306.   Ye=Ys+Rrange*0.77
  307.   Ystep=(Ye-Ys)/199
  308.   Cdivfac%=Climit%/16
  309.   Print At(1,6);"Mandelbrot Set Parameters:"
  310.   Print At(1,9);"Real Center : ";Ixs
  311.   Print At(1,10);"Real Range  : ";Rrange
  312.   Print At(1,11);"Imag. Center: ";Iys
  313.   Print At(1,12);"Imag. Range : ";Ye-Ys
  314.   Print At(1,13);"Iterations  : ";Climit%
  315.   Menu D$()
  316.   Gosub Mark_menu
  317.   On Menu  Gosub Set_options
  318. Return
  319. ' ********* Process the pixel map ********
  320. Procedure Process
  321.   ' what a mess!  Spaghetti code at it's best!
  322.   Menu Kill
  323.   Cls
  324.   Hidem
  325.   Fractal!=True
  326.   Pass%=1
  327.   Mark1:
  328.   Xp%=0
  329.   X=Xs
  330.   If Pass%=1
  331.     Xp%=1
  332.     X=X+Xstep
  333.   Endif
  334.   If Pass%=3
  335.     Xp%=1
  336.     X=X+Xstep
  337.   Endif
  338.   While Xp%<320
  339.     '    X=X+Xstep
  340.     X=X+2*Xstep
  341.     Yp%=199
  342.     Y=Ys
  343.     If (Pass%=2 Or Pass%=3)
  344.       Yp%=198
  345.       Y=Y+Ystep
  346.     Endif
  347.     While Yp%>-1
  348.       '      Y=Y+Ystep
  349.       Y=Y+2*Ystep
  350.       Az=0
  351.       Bz=0
  352.       Ac=X
  353.       Bc=Y
  354.       Count%=0
  355.       Size=0
  356.       While Count%<Climit% And Size<2
  357.         At=Az*Az-Bz*Bz
  358.         Bt=Az*Bz*2
  359.         Az=At+Ac
  360.         Bz=Bt+Bc
  361.         Tsiz=Az*Az+Bz*Bz
  362.         Size=Sqr(Tsiz)
  363.         Inc Count%
  364.       Wend
  365.       Pcolor%=Count%/Cdivfac%
  366.       If Pcolor%>15
  367.         Pcolor%=15
  368.       Endif
  369.       ' the following 2 REMs should be active if this is merged into GFA 2.x
  370.       Color Colrtable%(Pcolor%)  ! GFA 2.x only
  371.       Plot Xp%,Yp%              ! GFA 2.x only
  372.       ' else use this for GFA 3.x (it's a tiny bit faster)
  373.       ' PSET xp%,yp%,pcolor%    ! GFA 3.x only
  374.       Dec Yp%
  375.       Dec Yp%
  376.     Wend
  377.     Inc Xp%
  378.     Inc Xp%
  379.     If Mousek=2
  380.       Pass%=5  ! makes it jump out of the loop
  381.       Xp%=320
  382.     Endif
  383.   Wend
  384.   Inc Pass%
  385.   If Pass%<5
  386.     Goto Mark1
  387.   Endif
  388.   For I%=15 To 0 Step -1
  389.     Sound 1,I%,7,5
  390.     Pause 1
  391.   Next I%
  392.   Sget Screen1$
  393. Return
  394. ' ****************************************************
  395. Procedure Hold_it
  396.   Pause 30
  397.   Do
  398.     Hidem
  399.     If Mousek=1 And Fractal!=True
  400.       Defmouse "=7"
  401.       Gosub Magnify
  402.       Sget Screen1$
  403.       Goto Done
  404.     Endif
  405.     Exit If Mousek=2
  406.   Loop
  407.   Done:
  408.   Defmouse 0
  409.   Gosub Screenswap
  410.   Showm
  411. Return
  412. ' **********************************************
  413. Procedure Magnify
  414.   Showm
  415.   Defmouse 7
  416.   Print At(1,1);"◆◆";
  417.   Pause 30
  418.   Print At(1,1);"Center"
  419.   Do
  420.     ' Get "center" values
  421.     Micex=Mousex
  422.     Micey=Mousey
  423.     Exit If Mousek=1
  424.   Loop
  425.   Print At(1,1);"◆◆";
  426.   Pause 30
  427.   ' clear mouse clicks
  428.   Pause 30
  429.   Print At(1,1);"Range "
  430.   Do
  431.     ' Get "range" values
  432.     Micex2=Mousex
  433.     Micey2=Mousey
  434.     Exit If Mousek=1
  435.   Loop
  436.   Print At(1,1);"◆◆";
  437.   Pause 30
  438.   Gosub New_val
  439. Return
  440. Procedure New_val
  441.   ' this could be simplified, but it works like it is.
  442.   Pxlvalx=Rrange/319
  443.   Pxlvaly=Rrange*0.77/199
  444.   Rrange1=Rrange
  445.   Pxlrange=2*Abs(Micex-Micex2)
  446.   Xval=Ixs-Rrange/2
  447.   Rrange=Pxlrange*Pxlvalx
  448.   Ixs=Xval+(Pxlvalx*Micex)
  449.   Xs=Ixs-Rrange/2
  450.   Xe=Xs+Rrange
  451.   Xstep=(Xe-Xs)/319
  452.   Iys=Ye-(Pxlvaly*Micey)
  453.   Ys=Iys-(Rrange*0.77/2)
  454.   Ye=Ys+Rrange*0.77
  455.   Ystep=(Ye-Ys)/199
  456.   Boxy=Int(Abs(0.63*((Micex2-Micex)*2)))
  457.   ' looks tricky, eh?  It's not.. it's just quick & dirty
  458.   Color 1
  459.   Deffill 1,0,0
  460.   Box Micex-(Micex2-Micex),(Micey-Boxy/2),(Micex2),(Micey+Boxy/2)
  461.   Pause 200
  462.   Cdivfac%=Climit%/16
  463.   Fractal!=False
  464. Return
  465. Procedure Load_degas
  466.   ' This was hacked from an old P/D picture-display program
  467.   ' by Richard Noe, EAFB Alaska (5 Jan, 1986)
  468.   '
  469.   File$="FRACTAL1.PI1"
  470.   Bload File$,Xbios(2)-34
  471.   A%=Xbios(2)-32
  472.   For X=0 To 15
  473.     Sa%(X)=Dpeek(A%)
  474.     A%=A%+2
  475.   Next X
  476.   For X=0 To 15
  477.     A=Xbios(7,X,Sa%(X))
  478.   Next X
  479.   Pause P%*250
  480. Return
  481. '
  482. Procedure Res
  483.   If Xbios(4)<>0 Then
  484.     Alert 3,"You must be in |  Low rez ",1,"uh oh",Dummy%
  485.     Quit
  486.   Endif
  487. Return
  488. '
  489. Procedure Open_file
  490.   ' ooooooooooooooooooooooooooo-Open file-ooooooooooooooooooooooooo
  491.   ' straight out of Ultra-Graph (November, 1988 issue of ST-Log)..
  492.   ' of course, this _is_ a little overly complex for what we're doing here,
  493.   ' but it works like it is so..
  494.   On Error Gosub Disk_err
  495.   Drive$=Chr$(Gemdos(25)+65)
  496.   Filename$=""
  497.   If Dir$(0)<>""
  498.     Graphfil$=Drive$+":"+Dir$(0)+"\*"+Extender$
  499.   Else
  500.     Graphfil$=Drive$+":\*"+Extender$
  501.   Endif
  502.   Select:
  503.   Fileselect Graphfil$,"",Filename$
  504.   If Filename$<>""
  505.     If Filename$<>Drive$+":" And Right$(Filename$)<>"\"
  506.       Period%=Instr(Filename$,".")
  507.       If Period%=0
  508.         Filename$=Filename$+Extender$
  509.       Else
  510.         If Choice%<>3 And Choice%<>4
  511.           Filename$=Left$(Filename$,Period%-1)+Extender$
  512.         Endif
  513.       Endif
  514.       Backslash%=-1
  515.       Repeat
  516.         Dum%=Backslash%
  517.         Inc Dum%
  518.         Backslash%=Instr(Dum%,Filename$,"\")
  519.       Until Backslash%=0
  520.       Chdrive Asc(Left$(Filename$))-64
  521.       Path$=Mid$(Filename$,Instr(Filename$,"\"),Dum%-Instr(Filename$,"\")-1)
  522.       If Path$<>""
  523.         Chdir Path$
  524.       Else
  525.         Chdir "\"
  526.       Endif
  527.       Defmouse 2
  528.       If Choice%=0 Or Choice%=1 Or Choice%=2
  529.         Open "O",#1,Filename$
  530.         On Choice%+1 Gosub Degas_save,Save_screen,Save_params
  531.       Else
  532.         If Exist(Filename$)
  533.           If Choice%=3
  534.             Gosub Load_screen
  535.           Else
  536.             Gosub Load_params
  537.           Endif
  538.         Else
  539.           Alert 1,"|File not found",1,"OK",Dum%
  540.         Endif
  541.       Endif
  542.     Endif
  543.   Endif
  544.   Abort_open:
  545.   Close #1
  546.   Defmouse 0
  547.   On Error
  548. Return
  549. ' ssssssssssssssssssssssssss-Degas Save-sssssssssssssssssssssssss
  550. Procedure Degas_save
  551.   ' --- DEGAS file write ---
  552.   Degasheader$=Mki$(Res%)
  553.   For I%=0 To 15
  554.     Gosub Get_color
  555.     Degasheader$=Degasheader$+Mki$(Hue%)
  556.   Next I%
  557.   Bput #1,Varptr(Degasheader$),34
  558.   Bput #1,Varptr(Screen1$),32000
  559.   Close #1
  560. Return
  561. Procedure Disk_err
  562.   ' ----- Disk error procedure -----
  563.   Defmouse 0
  564.   ' If the disk was write protected GEM already gave them an alert box so skip this one
  565.   If Err<>-13
  566.     Alert 3,"  Disk Error.  | Operation aborted. ",1," Ok ",Dum%
  567.   Endif
  568.   Resume Abort_open
  569. Return
  570. Procedure Get_color
  571.   ' ----- Get colors -----
  572.   Dpoke Contrl,26
  573.   Dpoke Contrl+2,0
  574.   Dpoke Contrl+6,2
  575.   Dpoke Intin,Colrtable%(I%)
  576.   Dpoke Intin+2,1
  577.   Vdisys
  578.   Rgb%(0)=Dpeek(Intout+2)
  579.   Rgb%(1)=Dpeek(Intout+4)
  580.   Rgb%(2)=Dpeek(Intout+6)
  581.   For J%=0 To 2
  582.     Rgb%(J%)=Int(Rgb%(J%)/142)
  583.   Next J%
  584.   Hue%=Rgb%(0)*&H100+Rgb%(1)*&H10+Rgb%(2)
  585. Return
  586. ' ggggggggggggggggggggggggg-Graph Save-gggggggggggggggggggggggggg
  587. Procedure Save_params
  588.   Write #1,Ixs,Rrange,Iys,Climit%
  589.   Close #1
  590. Return
  591. ' RRRRRRRRRRRRRRRRRRRRRRR-Read in a Graph-RRRRRRRRRRRRRRRRRRRRRRRR
  592. Procedure Load_params
  593.   Open "I",#1,Filename$
  594.   Input #1,Ixs,Rrange,Iys,Climit%
  595.   Close #1
  596.   Gosub Convert_params
  597.   Gosub Params
  598. Return
  599. Procedure Convert_params
  600.   Xs=Ixs-Rrange/2
  601.   Xe=Xs+Rrange
  602.   Xstep=(Xe-Xs)/319
  603.   Ys=Iys-(Rrange*0.77)/2
  604.   Ye=Ys+Rrange*0.77
  605.   Ystep=(Ye-Ys)/199
  606.   Cdivfac%=Climit%/16
  607. Return
  608. Procedure Screenswap
  609.   If Scrn%=0   !If we are on the menu screen
  610.     Menu Kill
  611.     Menu Off
  612.     Sput Screen1$ !Return the graph screen
  613.     Scrn%=1
  614.     Gosub Hold_it
  615.   Else
  616.     Scrn%=0
  617.     Cls
  618.     Gosub Params !Reprint the menu screen
  619.     Pause 30
  620.   Endif
  621. Return
  622. ' ++++++++++++++++++++++++++++-Palette-++++++++++++++++++++++++++++
  623. Procedure Palette
  624.   If Palette%=1
  625.     Restore Red
  626.   Else
  627.     If Palette%=2
  628.       Restore Green
  629.     Else
  630.       If Palette%=3
  631.         Restore Blue
  632.       Else
  633.         If Palette%=4
  634.           Restore Yellow
  635.         Else
  636.           If Palette%=5
  637.             Restore Yellow_rev
  638.           Else
  639.             If Palette%=0
  640.               Restore Spectrum
  641.             Else
  642.               '              If Palette%=7
  643.               '              Restore Rainbow
  644.               '            Endif
  645.             Endif
  646.           Endif
  647.         Endif
  648.       Endif
  649.     Endif
  650.   Endif
  651.   For I%=0 To 15
  652.     Read Colr%
  653.     Setcolor I%,Colr%
  654.   Next I%
  655.   Yellow_rev:
  656.   Data &200,&210,&310,&410,&510,&610,&710,&720,&730,&740,&750,&760,&772,&774,&776,&000
  657.   Yellow:
  658.   Data &776,&774,&772,&760,&750,&740,&730,&720,&710,&610,&510,&410,&310,&210,&200,&000
  659.   Spectrum:
  660.   Data &715,&707,&507,&327,&007,&027,&057,&077,&075,&070,&571,&770,&750,&730,&700,&000
  661.   Red:
  662.   Data &755,&744,&733,&722,&711,&711,&700,&600,&600,&500,&400,&400,&300,&300,&201,&000
  663.   Green:
  664.   Data &575,&474,&373,&272,&171,&070,&060,&060,&050,&040,&040,&030,&030,&020,&010,&000
  665.   Blue:
  666.   Data &557,&447,&337,&227,&117,&117,&007,&006,&006,&005,&004,&004,&003,&003,&002,&000
  667.   Rainbow:
  668.   Data &774,&772,&750,&630,&700,&704,&707,&507,&335,&017,&047,&065,&074,&063,&070,&000
  669.   Gosub Mark_menu
  670. Return
  671. Procedure Mark_menu
  672.   If Palette%=0
  673.     Menu 22,1  ! 1 puts a check by the menu item
  674.     Menu 23,0  ! 0 removes a check
  675.     Menu 24,0
  676.     Menu 25,0
  677.   Endif
  678.   If Palette%=1 Or Palette%=2 Or Palette%=3
  679.     Menu 22,0
  680.     Menu 23,0
  681.     Menu 24,1
  682.     Menu 25,0
  683.   Endif
  684.   If Palette%=4
  685.     Menu 22,0
  686.     Menu 23,1
  687.     Menu 24,0
  688.     Menu 25,0
  689.   Endif
  690.   If Palette%=7
  691.     Menu 22,0
  692.     Menu 23,0
  693.     Menu 24,0
  694.     Menu 25,1
  695.   Endif
  696. Return
  697. Procedure Defaults
  698.   Ixs=-0.75
  699.   Rrange=3.25
  700.   Iys=0
  701.   Climit%=100
  702.   Gosub Params
  703. Return
  704. Procedure Save_screen
  705.   Write #1,Ixs,Rrange,Iys,Climit%  ! saves range values
  706.   Bput #1,Varptr(Screen1$),32000  ! saves the WHOLE screen to disk
  707.   Close #1
  708. Return
  709. Procedure Load_screen
  710.   Fractal!=True
  711.   Open "I",#1,Filename$
  712.   Input #1,Ixs,Rrange,Iys,Climit%
  713.   Bget #1,Varptr(Screen1$),32000
  714.   Close #1
  715.   Gosub Convert_params
  716.   Gosub Params
  717. Return
  718.