home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 4 / DATAFILE_PDCD4.iso / utilities / utilsf / fractulus / !Fractulus / Docs / Cores next >
Encoding:
Text File  |  1994-11-08  |  3.6 KB  |  103 lines

  1. HOW TO WRITE YOUR OWN CORE
  2. --------------------------
  3.  
  4.  
  5. This section is of interest for programmers only. It deals with the
  6. interface Fractulus provides for its core processes.
  7.  
  8. The core does the actual processing of a fractal. Since there are a
  9. lot of algorithms that produce quite nice fractals I chose to offer
  10. facilities to run Fractulus with different cores.
  11.  
  12. A core has to be relocatable! Furthermore the current buffer holding
  13. the core is fixed to 4K, so a core must not be any larger. If this
  14. means a great drawback to you, mail me about it. Personally I think
  15. 4K for the core should suffice easily enough.
  16.  
  17. A core file has the following format:
  18.  
  19. Byte#
  20. 0   : offset from start of file to entrypoint (i.e. the address Fractulus
  21.       should BL to).
  22. 4   : unique algorithm ID. The idea is to give each type of algorithm
  23.       its own ID. This prevents you from loading a fractal into fractulus
  24.       and zooming into it but getting only rubbish because the current
  25.       core produces altogether different results.
  26.       Algorithm IDs don't have to be unique. If someone wrote a fixed
  27.       point standard mandelbrot core for non-FPA machines it should get
  28.       the same algorithm ID as the mandelbrot core included in this
  29.       version (algorithm IDs allocated so far see later).
  30. 8-15: preserved for future expansion, set to zero.
  31. 16  : Core program.
  32.  
  33. Prior to calling the core (BL to entrypoint) Fractulus sets up the following
  34. registers:
  35. R0:  width (i.e. resolution x)
  36. R1:  height (i.e. resolution y)
  37. R2:  current y-position [0..height-1]; y=0 means top line
  38. R3:  current x-position [0..width-1];  x=0 means leftmost column
  39. R4:  pointer to begin of current line in sprite.
  40. R5:  IterMax
  41. R6:  IterPoll
  42. R7:  LineAdd (value to add to R4 after a line has been finished)
  43. R12: ^parameters
  44.  
  45. F0:  current REAL
  46. F1:  current IMAGINARY
  47. F7:  delta REAL
  48.  
  49. parameters is a chunk of memory containing further data:
  50. Byte#
  51. 0:   (int) width
  52. 4:   (int) height
  53. 8:   (int) current y
  54. 12:  (int) current x
  55. 16:  ^^SpriteArea (you should not normally use this. NEVER WRITE TO THIS ADDRESS!)
  56. 20:  (int) IterMax
  57. 24:  (int) IterPoll
  58. 28:  (int) LineAdd
  59. 32:  (float, extended) current REAL
  60. 44:  (float, extended) current IMAGINARY
  61. 56:  (float, extended) delta REAL
  62. 68:  (float, extended) delta IMAGINARY
  63. 80:  (float, extended) min(REAL)
  64.  
  65. You may change any registers you want except for R12.
  66. On exit the program has to set R2,R3 to new y/x pos and F0,F1 to new
  67. REAL/IMAGINARY.
  68. The sprite is 8bpp, so each pixel represents one byte. You should write to
  69. the sprite with STRB Ri,[R4,R3] (i.e. begin current line + current pos x) and,
  70. after completing a line, add R7 to R4 (and load current REAL = F0 from [R12,#80]).
  71. When the fractal is finished (i.e. current y = R2  ==  height = R1) you must
  72. set R2 to -1 and exit.
  73.  
  74. IterPoll should be dealt with as follows: decrease in the iterations loop by one
  75. with each loop. After the Iterations loop is finished you should check if it has
  76. become less or equal to zero and exit if so, otherwise continue.
  77.  
  78. That should suffice for you to write your own core. In case it's not mail me about
  79. it.
  80.  
  81.  
  82. ALGORITHM IDs
  83. -------------
  84.  
  85. Algorithm IDs allocated so far:
  86.  
  87. mandelbrot: 0       (z = z^2 + pos)
  88. mandel3:    1       (z = z^3 + pos)
  89. mandel4:    2       (z = z^4 + pos)
  90. mandel5:    3       (z = z^5 + pos)
  91. mandel6:    4       (z = z^6 + pos)
  92. julia:      16      (z = z^2 + c)
  93.  
  94. Any cores using the same algorithms (but different implementations) should use
  95. the same IDs.
  96. If you create a new algorithm you should mail me about it, telling me the
  97. algorithm you used so I can allocate you an ID to preserve consistency with
  98. other people's cores.
  99.  
  100.  
  101.  
  102. Andreas Dehmel
  103.