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. If someone wrote a fixed
- point standard mandelbrot core for non-FPA machines it should get
- the same algorithm ID as the mandelbrot core included in this
- version (algorithm IDs allocated so far see later).
- 8-15: preserved 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)
- 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)
-
- You may change any registers you want except for R12.
- On exit the program has to set R2,R3 to new y/x pos and F0,F1 to new
- REAL/IMAGINARY.
- The sprite is 8bpp, so each pixel represents one byte. You should write to
- the sprite with STRB Ri,[R4,R3] (i.e. begin current line + current pos x) and,
- after completing a line, add R7 to R4 (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: decrease in the iterations loop by one
- with each loop. After the Iterations loop is finished you should check if it has
- become less or equal to zero and exit if so, otherwise continue.
-
- 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)
-
- 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
-