home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 22 / AACD 22.iso / AACD / Graphics / FlashMandel / Sources / Modules / MandelPPC.P < prev   
Encoding:
Text File  |  2001-05-20  |  2.8 KB  |  86 lines

  1. ************************************************************************
  2. **            Written by Dino Papararo            23-Apr-2001
  3. **
  4. **  FUNCTION
  5. **
  6. **    MandelPPC -- perform Z = Z^2 + C iteration.
  7. **
  8. **  SYNOPSIS
  9. **
  10. **    ULONG MandelPPC (ULONG Iterations,long double Cre,long double Cim)
  11. **
  12. **
  13. **  This function tests if a point belongs or not at mandelbrot's set
  14. **
  15. **  Optimized for pipelines of PPC processors.
  16. **
  17. **  r3:Iterations
  18. **  f1:Cre f2:Cim f3:Zr f4:Zi f5:Tmp1/Zr2 f6:Tmp2/Zi2 f7:Dist f8:MaxDist
  19. *************************************************************************
  20.  
  21.  
  22.                 include powerpc/ppcmacros.i
  23.                 include powerpc/powerpc.i
  24.  
  25.                 xref _PowerPCBase
  26.  
  27.                 xdef _MandelPPC
  28.  
  29.  
  30.                 section code
  31.  
  32.                 cpu POWERPC
  33.  
  34. _MandelPPC
  35.  
  36.                  prolog             ; start
  37.  
  38.                  lf     f8,Radius   ; MaxDist = Radius
  39.                  fmr    f4,f2       ; Zi = Cim
  40.                  fmr    f3,f1       ; Zr = Cre
  41.  
  42.                  mtctr  r3          ; Load Iterations into counter
  43.  
  44. ************************************************************************
  45. * HAAGE&PARTNER PPC ASM function is the fastest I have ever seen and
  46. * without any pipeline wait state for the maximum speeed on PPC.
  47. * Recoded by Dino Papararo with small changes.
  48. ************************************************************************
  49. *
  50. *                 fsub   f8,f8,f1    ; MaxDist = Radius - Cre
  51. *.Loop
  52. *                 fmsub  f6,f4,f4,f1 ; Tmp2 = Zi^2 - Cre
  53. *                 fadd   f5,f3,f3    ; Tmp1 = 2 * Zr
  54. *                 fmadd  f7,f3,f3,f6 ; Dist = Zr^2 + Tmp2
  55. *                 fmsub  f3,f3,f3,f6 ; Zr = Zr^2 - Tmp2
  56. *                 fmadd  f4,f4,f5,f2 ; Zi = Tmp1 * Zi + Cim
  57. *                 fcmpu  f7,f8       ; if Dist > MaxDist and
  58. *                 bdnzf+ GT,.Loop    ; Iterations != 0 goto Loop
  59. *
  60. ************************************************************************
  61. * Dino Papararo MandelBrot PPC ASM function for rendering Mandelbrot set
  62. * a bit slower than HAAGE&PARTNER one, but simplest, more elegant and
  63. * without any pipeline wait state too :-))
  64.  
  65. .Loop
  66.                  fmul   f6,f4,f4    ; zi2 = zi * zi
  67.                  fadd   f4,f4,f4    ; zi = zi + zi
  68.                  fmadd  f7,f3,f3,f6 ; dist = zr * zr + zi2
  69.                  fmsub  f5,f3,f3,f6 ; zr = zr * zr - zi2
  70.                  fmadd  f4,f3,f4,f2 ; zi = zr * zi + Cim
  71.                  fadd   f3,f5,f1    ; zr += Cre
  72.                  fcmpu  f7,f8       ; compare dist with radius
  73.                  bdnzf+ GT,.Loop    ; if maxdist > radius or --iterations != 0 goto Loop
  74. ************************************************************************
  75.  
  76.  
  77. .End
  78.  
  79.                  mfctr  r3          ; Store Iterations from counter
  80.  
  81.                  epilog             ; end
  82.  
  83.  
  84.                 section data
  85.  
  86. Radius          dc.d   4.0