The source code for Fractint is freely available.

Enhancements to it are appreciated.  If you want to add something to
Fractint and join the Stone Soup Group, please do!  To submit changes,
see "Contacting the Authors" in Fractint's online help.


Copyright Information:
======================

Some parts of the source are from the public domain and are not
copyrighted.

Some parts of the source bear explicit copyright notices from the
author and are subject to the conditions listed there by the author.

The remainder of the source (not already public domain, no explicit
author's copyright notice) is Copyright 1990, 1991 by the Stone Soup Group
(a loosely associated and ever-growing group of fanatic programmers).

The source code may be copied freely and may be used in other programs
under the following conditions:
  It may not be used in a commercial program which produces fractal images.
  Please credit the author (in general, credit Fractint and the Stone Soup
  Group) as the source of the code.


Distribution of modified versions of Fractint:
==============================================

If you enhance Fractint and want to distribute the results to others, the
preferred approach is to join the Stone Soup Group - send us your
enhancements and get your name in lights in future versions of Fractint.

We prefer that a modified Fractint executable program not be distributed to
others, but understand that you might want to give copies to friends.  This
is permitted, under the following conditions:
  o The modified executable has a different name than "fractint.exe".
  o The distribution includes a full unmodified copy of the corresponding
    original version of fraint.exe.  (The easiest way is to copy fraint.exe
    to yournew.exe, then "pkzip -a fraint.exe newfract.exe" to add your
    version, and perhaps add a read.me file to describe it.)
  o The heading displayed by the modified program clearly indicates that
    it is a non-standard release.  E.g. you might change the heading to
    say "Non-standard Fractint, Modified by John Doe".
  o All author credits and distribution information in the online help
    are unchanged (adding lines for your work is of course ok.)

The source code for a modified version of Fractint may not be distributed.
(This is because we don't want any chance of confusion over which version
of a source file is the official release.)


Compiling Fractint:
===================

See Setup_CodeBlocks.txt


Help System
===========

You'll need to set up the help files to get any online help from a modified
version of Fractint.

CodeBlocks is set up to compile HC.exe.

You don't need to understand the rest of this section unless you have a
problem.

The source for Fractint's help is in the files HELP.SRC, HELP2.SRC, HELP3.SRC,
HELP4.SRC, and HELP5.SRC.  The format of these files is described in HC.DOC.

The program HC.C ("help compiler") is used to convert the help text into
the form Fractint uses at run time.

Running "hc /c" compiles HELPx.SRC.  It produces the file HELPDEFS.H for
use when compiling Fractint, and the file FRACTINT.HLP.
Running "hc /a" appends the FRACTINT.HLP file to FRACTINT.EXE to make the
compiled help info available at run time.


Where the Goodies are
=====================

It has come to our attention that people who have no interest in fractals
at all have been wandering through the FRACTINT source code just to get at
some of the neat tricks buried therein.  Here are a few hints as to where
to look:

FRACTINT.C	- The main routine.  Nothing special here.
FRACTINT.H	- General Include file.  Nothing special here, either.
FRACTYPE.H	- Fractal type-specific Include file.

PROMPTS.C	- The full-screen prompting code (using support routines
		  in VIDEO.ASM)
CMDFILES.C	- Command line and sstools.ini parsing.

FRACTALS.C,	- Most of the fractal-specific code.  If you want to know
 CALCFRAC.C,	  how a fractal is calculated, look in here.  Specific
 FRACSUBR.C	  speed-em-up support for special fractal types is in:
 FRACSUBA.ASM
CALCMAND.ASM	- Mandelbrot/Julia set calculations.
NEWTON.ASM	- Newton calculations
LORENZ.C	- Attractor fractals and IFS
JB.C		- "Julibrot" fractal type calculations
TESTPT.C	- "Roll-your-own" fractal routine
MPMATH_C.C,	- Mark Peterson's "fast-math" support routines.
 MPMATH_A.ASM,	  (this stuff puts some of the routines supplied by your
 FPU387.ASM,	  favorite "C" compiler to shame!)
 FPU087.ASM,	  ...
 FMATH.H,	  ...
 MPMATH.H	  ...
PARSER.C	- The "type=formula" formula parser routines
LSYS.C		- L-Systems code

VIDEO.ASM	- Assembler code containing all of the video routines
		  (setting up the video, reading/writing pixels, zoom-box
		  code, color-cycling, graphics-to-text "help" switch,
		  ... with help from the routines below for special adapters:
LOADMAP.C	- Load .map files.
TARGA.C,	- TARGA Video Routines
 TARGA.H,	  ...
FR8514A.ASM	- 8514/A Routines
TPLUS.C 	- Targa+ video routines
 TPLUS.H	  ...
 TPLUS_A.ASM	  ...
HGCFRA.ASM	- Hercules Video Routines
DISKVID.C	- "DISK'RAM" video routines
YOURVID.C	- "Roll-your-own" video routines

GENERAL.ASM	- General assembler code having nothing to do with fractals.
		  Lots of the tricky stuff is in here, and many of the "C"
		  routines that perform tricky functions rely on support
		  code buried in here.	In particular, this routine has the:
			CPU, FPU Detectors
			Keyboard routines
			Mouse routines
			Expanded memory routines
			32-bit scaled integer multiply and divide routines

ENCODER.C	- GIF Encoder routine.
GIFVIEW.C,	- GIF Decoder routines.
 DECODER.C,
 TGAVIEW.C,	  (including a TARGA-format decoder currently used only for
 F16.C, 	  loading obsolete .tga format "Continuous Potential" files)
 TARGA_LC.H	  ...
LOADFILE.C	- Loads the Fractint parameter info from a GIF file.
 LOADFDOS.C	  subroutines for DOS Fractint only

LINE3D.C,	- 3D manipulation routines
 3D.C
PLOT3D		- 3D subroutines for LINE3D.C and LORENZ.C

ROTATE.C	- routines which "spin" the VGA video-DAC.
EDITPAL.C	- palette-editing mode

HELP.C		- HELP support
INTRO.C 	- title screen

ZOOM.C		- Zoombox manipulation.

PRINTER.C,	- The Printer Routines
 PRINTERA.ASM	  Data used by PRINTER.C

MISCRES.C	- Miscellaneous resident subroutines; nothing special.
MISCOVL.C	- Miscellaneous overlayed subroutines; includes <B>atch
		  command.
REALDOS.C	- Some subroutines isolated from Windows development work;
		  nothing special in here.

PORT.H		- Some portability stuff, nothing special here.

How things are set up
=====================
I've had to go through a lot of the code to figure out how things are set
up.  These are my rough notes, which I'm including in case they can help
someone else. -- Ken Shirriff

The control flow is very confusing.  Here are some details:

Each fractal type has an entry in the fractalspecific table in fractalp.c.
Entries that are not displayed are marked with an asterisk.  Each entry is
marked as int or not int, and either has a pointer to another entry
(tofloat) or NOFRACTAL.  If you select float and the type is int or vice
versa, you will end up with the tofloat type.  (e.g. If you select entry
MANDEL, and select floating point, you will get entry MANDELFP).  There are
also pointers tojulia and tomandel, which allow you to switch between mandel
and julia.  The four functions listed are curfractalspecific->orbitcalc,
curfractalspecific->per_pixel, curfractalspecific->per_image, and
curfractalspecific->calctype.

main calls calcfracinit.
calcfractint: this sets up curfractalspecific, which is the appropriate entry
	from the fractalspecific table.  This routine does the int/float
	conversion.

main calls calcfract, which calls timer, which calls perform_worklist
perform_worklist calls curfractalspecific->per_image, which is eg.  MandelSetup
MandelSetup: sets calctype to curfractalspecific->calctype, or for special
    cases (eg. decomposition) to StandardFractal

perform_worklist calls solidguess (or whatever drawing system)
solidguess calls *calctype for each pixel; calctype is eg. StandardFractal

StandardFractal calls curfractalspecific->per_pixel once, and then loops over
    each iteration calling curfractalspecific->orbitcalc.  These routines
    are eg.  mandel_per_pixel and JuliaFractal.



Here is the structure of the main routine:

main()
{
    initialize things
restorestart:
    if loading, look after specifying image
imagestart:
    while (adapter<0) {
	process keys from short main menu
    }

    while (1) {
	if (calc_status != 2 || showfile==0) {
	    initialize videoentry from videotable[adapter]
	    initialize size, color, etc. from videoentry
	    setvideomode()
	}
	if (showfile==0) {
	    load file
	}
	calcfracinit();
	save corners, zoom data
	if (showfile != 0) {
	    calcfract(); /* calculates the fractal until interrupted */
	}
resumeloop:
	if (no key pressed) {
	    set keypress = 13 to continue
	} else if (key pressed) {
	    check input key
	} else if (batch mode) {
	    look after batch key
	}

	process key from long menu
    }
}


How the video entries are managed:

get_video_mode(fractal_info): This routine is used to select a video mode
    to match a picture we're loading.  It loads vidtbl and then  tries to
    find a video mode that matches that in fractal_info.  Asks the user to
    select one if there's no good match.  Figures out how to reduce the image
    to fit the screen.

select_video_mode(curmode): This is the main-menu routine for the user to
    pick a video mode.  picks default video mode, lets user select mode
    from menu, copies entry to videoentry, puts entry in videotable if not
    there, calls update_fractint_cfg if key reassigned, returns key
    corresponding to mode

check_vidmode_key(option, keypress): if keypress corresponds to a videomode in
    videotable (for option 0) or vidtbl (for option 1) return the videomode
    index, else -1.

check_vidmode_keyname: converts ascii key name into key number

adapter_detect: checks for type of video (ega, cga, etc) and set video_type,
mode7text, textsafe.

load_videotable: reads the entries in fractint.cfg into vidtbl
    copies entries with an associated function key into videotable

load_fractint_cfg: reads video modes in fractint.cfg into vidtbl
    (or copies from videotable) if fractint.cfg missing or bad

update_fractint_cfg: writes the entry in videoentry into the fractint.cfg file.

vidtbl: contains the video modes from fractint.cfg
videotable: contains video modes with function keys; initialized in video.asm
video_type: contains type: hgc, egc, cga, mcga


Here is how the floating point modes are set up.
parser.c uses the MathTypes:
D_MATH: uses double precision routines, such as dStkMul, and FPUsincos
    This is used if we have a fpu.
L_MATH: uses integer math.  Routines such as lStkAdd.
