home *** CD-ROM | disk | FTP | other *** search
- HOW TO WRITE YOUR OWN CORE
- --------------------------
-
-
- This section is of interest for programmers only. It deals with the
- interface Fractulus provides for its core processes.
-
- The core does the actual processing of a fractal. Since there are a
- lot of algorithms that produce quite nice fractals I chose to offer
- facilities to run Fractulus with different cores.
-
- A core has to be relocatable! Furthermore the current buffer holding
- the core is fixed to 4K, so a core must not be any larger. If this
- means a great drawback to you, mail me about it. Personally I think
- 4K for the core should suffice easily enough.
-
- A core file has the following format:
-
- Byte#
- 0 : offset from start of file to entrypoint (i.e. the address Fractulus
- should BL to).
- 4 : unique algorithm ID. The idea is to give each type of algorithm
- its own ID. This prevents you from loading a fractal into Fractulus
- and zooming into it but getting only rubbish because the current
- core produces altogether different results.
- Algorithm IDs don't have to be unique among cores (only regarding
- algorithms). fix32 e.g. has the same ID as mandelbrot (algorithm IDs
- allocated so far see later).
- 8 : (since v0.10) Core flags. Meaning of bits when set:
- 0: core can deal with 16bpp sprites.
- 1: core can deal with 32bpp sprites.
- 2: core uses extension words.
- 3-31: reserved for future expansion, set to zero.
- 12-15: reserved for future expansion, set to zero.
- 16 : Core program.
-
- Prior to calling the core (BL to entrypoint) Fractulus sets up the following
- registers:
- R0: width (i.e. resolution x)
- R1: height (i.e. resolution y)
- R2: current y-position [0..height-1]; y=0 means top line
- R3: current x-position [0..width-1]; x=0 means leftmost column
- R4: pointer to begin of current line in sprite.
- R5: IterMax
- R6: IterPoll
- R7: LineAdd (value to add to R4 after a line has been finished)
- R8: (since v0.10) ld(bpp)-3, i.e. 0 for 8bpp, 1 for 16bpp, 2 for 32bpp
- R12: ^parameters
-
- F0: current REAL
- F1: current IMAGINARY
- F7: delta REAL
-
- parameters is a chunk of memory containing further data:
- Byte#
- 0: (int) width
- 4: (int) height
- 8: (int) current y
- 12: (int) current x
- 16: ^^SpriteArea (you should not normally use this. NEVER WRITE TO THIS ADDRESS!)
- 20: (int) IterMax
- 24: (int) IterPoll
- 28: (int) LineAdd
- 32: (float, extended) current REAL
- 44: (float, extended) current IMAGINARY
- 56: (float, extended) delta REAL
- 68: (float, extended) delta IMAGINARY
- 80: (float, extended) min(REAL)
-
- The following since v0.10:
- 92: (float, extended) ext1
- 104: (float, extended) ext2
- 116: (int) ld(bpp)-3 (see above)
-
- You may change any registers you want except for R12 and R13.
- On exit the program has to set R2,R3 to new y/x pos and F0,F1 to new
- REAL/IMAGINARY. Return address is passed to the core in R14.
-
- After completing a line, add R7 to R4 (bpp are already taken into account in R7!)
- and load current REAL = F0 from [R12,#80].
- When the fractal is finished (i.e. current y = R2 == height = R1) you must
- set R2 to -1 and exit.
-
- IterPoll should be dealt with as follows: after the iterations loop subtract the
- number of iterations from it. Before starting on a new position you should
- check if it has become less or equal than zero and exit if so, otherwise continue.
-
-
- Colours:
- --------
-
- The colours used in truecolour sprites are quite different from the ones used with
- 8bpp. My motivation was to give a maximum number of colours without ludicrously
- high iteration values. If you want to know my colours mail me and I'll give you
- the algorithm I use.
- EACH CORE *MUST* SUPPORT 8BPP MODES!
-
-
- That should suffice for you to write your own core. In case it's not mail me about
- it.
-
-
- ALGORITHM IDs
- -------------
-
- Algorithm IDs allocated so far:
-
- mandelbrot: 0 (z = z^2 + pos)
- mandel3: 1 (z = z^3 + pos)
- mandel4: 2 (z = z^4 + pos)
- mandel5: 3 (z = z^5 + pos)
- mandel6: 4 (z = z^6 + pos)
- julia: 16 (z = z^2 + c)
- crazy32: 32 (z = z^2 + pos, beautiful fixpoint-errors!)
- dragon: 64 (z = c*z*(1-z) )
- Where c is the complex number obtained from the extension words.
-
- Any cores using the same algorithms (but different implementations) should use
- the same IDs.
- If you create a new algorithm you should mail me about it, telling me the
- algorithm you used so I can allocate you an ID to preserve consistency with
- other people's cores.
-
-
-
- Andreas Dehmel
-