Advertisement
zephyrtronium

plugin low-level format

Dec 22nd, 2011
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. source files are always encoded in utf-8
  2. identifiers for variables not special may include any unicode characters in groups Lu, Ll, Lt, Lm, Lo, Nd, as well as _
  3. a token comprised only of digits is never treated as an identifier
  4. eight registers are available as variables
  5. special variables include >v (VVAR), >x (FTx), >y, >z, >c, <x (FPx), <y, <z, <c, >ma (TMa), >mb, ... >ml, >0 (register 0), ... >7
  6.  
  7.  
  8. operation summary:
  9. (register manipulation)
  10. set v x - set v to immediate (floating-point) value x
  11. copy d s - set d to contents of s
  12. swap v w - switch contents of v and w (is this actually useful?)
  13.  
  14. (binary operators)
  15. add d v w - set d to v+w
  16. sub d v w - set d to v-w
  17. mul d v w - set d to v*w
  18. div d v w - set d to v/w
  19. mod d v w - set d to v%w
  20. polar r t x y - set r to hypot(y, x) and t to atan2(y, x)
  21. rect x y r t - set x to r*cos(t) and y to r*sin(t)
  22. pow d v w - set d to pow(v, w)
  23. atan2 d v w - set d to atan2(w, v)
  24. hypot d v w - set d to hypot(v, w)
  25.  
  26. (ternary)
  27. spherical r t p x y z - set r to sqrt(x*x+y*y+z*z), t to atan2(y, x), and p to acos(z/sqrt(x*x+y*y+z*z))
  28. rect3d x y z r t p - set x to r*cos(t)*sin(p), y to r*sin(t)*sin(p), and z to r*cos(p)
  29. fma d x y z - set d to x*y+z
  30.  
  31. (unary)
  32. neg d v - d = -v
  33. acos d v - d = acos(v)
  34. asin d v - arcsine
  35. atan d v - arctangent
  36. cos d v - cosine
  37. cosh d v - hyperbolic cosine
  38. sin d v - sine
  39. sinh d v - hyperbolic sine
  40. tan d v - tangent
  41. tanh d v - hyperbolic tangent
  42. exp d v - exponential (e to the power of v)
  43. ln d v - natural logarithm
  44. sqrt d v - square root
  45. ceil d v - ceiling
  46. abs d v - absolute value
  47. floor d v - floor
  48.  
  49. (shortcuts)
  50. addtoxy v w - add v to <x and w to <y
  51. addtoxyz u v w - add u to <x, v to <y, and w to <z
  52. vaddtoxy v w - fma >v * {v, w} into <x and <y, respectively
  53. vaddtoxyz u v w - fma >v * {u, v, w} into <x, <y, <z, respectively
  54.  
  55. (control flow)
  56. beq v w n - branch forward n operations if v == w
  57. bne v w n - branch forward n operations if v != w
  58. bgt v w n - v > w
  59. ble v w n - v <= w
  60. bge v w n - v >= w
  61. blt v w n - v < w
  62. end - exit the function
  63.  
  64. (randomness)
  65. randint d - set d to a random integer in [0, RAND_MAX]
  66. random d - set d to a random real in [0, 1)
  67. randintr d v w - set d to a random integer in [v, w]
  68. randomr d v w - set d to a random real in [v, w)
  69.  
  70. it is guaranteed that for each operation, the assignment to the destination register is the last thing to occur.
  71.  
  72. particular dot directives include:
  73. .name <variation name> - set the name of the variation; same rules as for identifiers
  74. .3d - indicate that the variation writes to FPx
  75. .dc - indicate that the variation writes to TC
  76. .vars {int | real | range | cyclic} <name> <init> [, ...] - list variables
  77. .privs {int | real} <name> [= <init>] [...] - private vars
  78. .prep - indicate an init() method
  79. .case <expr> - use the following to the next .case or .calc as the calc() method when expr evaluates to true. a .calc section must exist if any .case sections do.
  80. .calc - indicate start of calc() method. this is used as the default case; if the interpreter does not understand expressions, it will treat all cases as false and therefore always use .calc.
  81.  
  82. .name spherivoid // variation name is spherivoid
  83. .3d // 3d variation
  84. .vars real spherivoid_radius 0 // like VAR_REAL(spherivoid_radius, 0.0)
  85. .calc // calculate method
  86. spherical >0 >1 >2 >x >y >z // set registers 0-2 to spherical coordinates of input
  87. add >0 >0 spherivoid_radius // add spherivoid_radius to radius in-place
  88. rect3d >0 >1 >2 >0 >1 >2 // convert spherical coordinates to rectangular in-place
  89. vaddtoxyz >0 >1 >2 // add coordinates scaled by >v to output
  90. end
  91.  
  92. .name julian
  93. .vars int julian_power 2, real julian_dist 1
  94. .privs int absn, real cn
  95. .prep // init() method
  96. abs absn julian_power
  97. div >0 julian_dist julian_power
  98. set >1 0.5
  99. mul cn >0 >1
  100. end
  101. .calc
  102. atan2 >0 >x >y
  103. set >1 0
  104. randintr >1 >1 absn
  105. set >2 6.283185308 // 2pi
  106. fma >0 >1 >2 >0 // 2pi * randint + theta
  107. div >0 julian_power >0 // (2pi * randint + theta) / power
  108. mul >1 >x >x // sqr(x)
  109. fma >1 >y >y >1 // sqr(x) + sqr(y)
  110. pow >1 >1 cn // pow(sqr(x)+sqr(y), cn)
  111. mul >1 >1 >v // vvar * pow(sqr(x)+sqr(y), cn)
  112. rect >0 >1 >0 >1
  113. addtoxy >0 >1
  114. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement