home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 108 / gp2demo.iso / editor / acorn / TEXTURE / TEXTURE.ZIP / Docs / Extensions < prev    next >
Encoding:
Text File  |  1996-11-21  |  25.3 KB  |  674 lines

  1.  
  2.                         Language Extensions
  3.                         ===================
  4.  
  5. 1.0 Introduction
  6. 2.0 The RMStore directory
  7. 3.0 Structure
  8. 4.0 Resources
  9. 5.0 Coding
  10. 6.0 Calling internal commands
  11.  
  12. 1.0 Introduction
  13. ~~~~~~~~~~~~~~~~
  14. This document describes how to write language-extensions to the texture
  15. generation language used in the Texture Garden program, reasons why you might
  16. be interested in doing this and information about installing other people's
  17. extension modules.
  18.  
  19. Commands may be included, but functions (refer to the "Language" file for the
  20. differences between these) may not currently be implemented by third parties.
  21.  
  22. Example source code using the BASIC assembler is available.  Although this
  23. code is distributed as freeware (i.e. copyright is retained) the author
  24. expresses every intention of approving use of my code where it is
  25. incorporated into modules intended for my program, so please do not hesitate
  26. to steal and butcher it; if this was objected to no source code would have
  27. been distributed.
  28.  
  29. 2.0 The RMStore directory
  30. ~~~~~~~~~~~~~~~~~~~~~~~~~
  31. This is a directory immediately inside the "!TexturGdn" directory.  The
  32. location is usually "<TextureGdn$Dir>.RMStore".  The precise location is held
  33. in the system variable <TextureGdnRMStore$Dir> which is usually set up in the
  34. !Run file.
  35.  
  36. This directory should always contain a text file called "Index".  This file
  37. has a simple format:
  38.  
  39. Any line starting with a "|" is considered to be a comment. The end of the
  40. file is marked by the "End" token. Any other lines are considered as paths
  41. from <TextureGdnRMStore$Dir> to files containing language extensions.
  42.  
  43. The file "Kernel" should always be present in the directory.  It contains all
  44. the commands implemented as the core of the language.  There may also be
  45. other files.
  46.  
  47. The files may be of any type.  Conventionally, they are "Modules"
  48. (Typeá&FFA).  Though they are not loaded as such by the program this enables
  49. them to conveniently contain a version number and help text.
  50.  
  51. When adding extension modules to the program the relevant file should be
  52. added to the "RMStore" directory and the twig of its path inserted into the
  53. "Index" file.
  54.  
  55. 3.0 Structure
  56. ~~~~~~~~~~~~~
  57. Language extensions should all conform to the following structure:
  58.  
  59. Bytes:        Description...
  60. &0000-&002B   Header (Undefined bytes)
  61. &002C-&XXXX   Command Table index
  62. &XXXX-&YYYY   Command Table
  63. &YYYY-&ZZZZ   Command code
  64.  
  65. The Command Table index has the following format:
  66.  
  67. Offset bytes: Description...
  68. &0000           Command index entry 0
  69. &000C          Command index entry 1
  70. &0018          Command index entry 2
  71. -             -
  72. n x &C        Command index entry n
  73. -             -
  74. &UUUU         End of table marker.
  75.  
  76. The End of table marker is represented by the three consecutive words 
  77. -1,-1 and -1.
  78.  
  79. Command index entry n consists of three words
  80.  
  81. Word 0: Offset from start of file to the text of command n.
  82. Word 1: Offset from start of file to the entry point of the code to perform
  83.         the command.
  84. Word 2: Various flags
  85.  
  86. The Various flags are considered as &ABCDEFGH where &A is the number of
  87. parameters the command accepts (0-15), &B is a code advising how the command
  88. should be treated by the mutator (the "Mutation Options"), and &CDEFGH
  89. contain other miscellaneous bit-flags to mark specific command types.
  90.  
  91. These bit-flags have the following meanings:
  92.  
  93. &000003 :                                           (Reserved)
  94. &00000C : See immediately below:
  95.      &4 : Command ends an indentation
  96.      &8 : Command starts an indentation
  97. &0000F0 :                                           (Reserved)
  98. &00FF00 : As follows:
  99.   &0C00 : Command is an "endif"                     (Reserved)
  100.   &0200 : Command starts mutation                   (Reserved)
  101.   &0300 : Command stops  mutation                   (Reserved)
  102.   &0400 : Command is a  "Define"                    (Reserved)
  103.   &0500 : Command is a  "Goto"                      (Reserved)
  104.   &0600 : Command is a  "Call"                      (Reserved)
  105.   &0700 : Command is a  "Return"                    (Reserved)
  106.   &0800 : Command is an "End"                         (Reserved)
  107.   &0900 : Command is an "If"                         (Reserved)
  108.   &0A00 : Command is an "Then"                      (Reserved)
  109.   &0B00 : Command is an "Else"                      (Reserved)
  110.   &0100 : Command is a  "comment" ("|")             (Reserved)
  111.   &0D00 : Command ends the colour definition        (Reserved)
  112.   &0E00 : Command starts the colour definition      (Reserved)
  113.   &0F00 : Command is a  "CreateOneDiensionalFilter" (Reserved)
  114.   &1000 : Command is a  "CreateTwoDiensionalFilter" (Reserved)
  115.   &1100 : Command is an "Until"                     (Reserved)
  116.   &1200 : Command is a  "Resize"                    (Reserved)
  117.   &1300 : Command is a  "ResizeSprite"              (Reserved)
  118.   &1400 : Command is a  "MakeSprite"                (Reserved)
  119.   &1500 : Command is an "AddToSprite"               (Reserved)
  120.   &1600 : Command is a  "MakeVirtualSprite"         (Reserved)
  121.   &1700 - &FF00 For expansion                       (Reserved)
  122. &FF0000 : Bits all for expansion and must be zero   (Reserved)
  123.  
  124. "Reserved" means that most users should not need to mess with it.
  125.  
  126. The "Command Table" contains the entries pointed to by word 0 of the Command
  127. index entry.  These are mixed case strings terminated by a single ASCII 13
  128. character.  They need not be word aligned.
  129.  
  130. The "Command code" contains the code pointed to by word 1 of the Command
  131. index entry.  These are ARM code subroutines called at the appropriate moment
  132. in the generation of the textures.  Any workspace may also be stored here,
  133. rather than claimed from the system, if it is small enough.  The location of
  134. the "Command code" relative to the "Command table" is arbitrary.
  135.  
  136. Mutation Options
  137. ~~~~~~~~~~~~~~~~
  138. This specifies how any following parameters are treated by the mutator.
  139. 0 - Completely ignore.
  140. 1 - Treat as unsigned 16-bit logarithmic number (reserved for functions)
  141. 2 - Very occasionally add or subtract one (used for "Shear")
  142. 3 - Occasionally completely randomize (used for "Seed")
  143. 4 - Treat as unsigned 16-bit logarithmic number
  144. 5 - Treat as a SetColour command...
  145. 6 - Treat as a DefineLightSource command.
  146. 7 - Reserved...
  147.  
  148. 4.0 Resources
  149. ~~~~~~~~~~~~~
  150. When a code fragment is called in the generation of a texture it may interact
  151. with the main program and share its data in a number of ways.
  152.  
  153. On entry to the routine the following register conventions are used:
  154.  
  155. R14 - return address
  156. R13 - system stack
  157. R12 - pointer to Texture Garden main data structure
  158. R11 - pointer to current point in texture program execution
  159.  
  160. On exit R0 - R10, R12 and R14 may be corrupted.  R11 should normally be
  161. incremented to the start of the next expected command.  R13 should normally
  162. be preserved in the normal manner.
  163.  
  164. R11 contains a pointer to the next item in the texture program's execution.
  165. This will always be the next item after the code representing the currently
  166. called command.  Note that the program is not held internally as a textfile,
  167. but in an internal format.
  168.  
  169. Each command, parameter or function is coded for by one word.  Parameters are
  170. coded for by their values.  Commands and functions are coded bu an internal
  171. number, the complete details of which are not specified, but which always has
  172. bit 31 set.  The end of the file is coded as -1.  This need not normally be
  173. checked for.
  174.  
  175. R12 contains a pointer to a data structure which has the following structure:
  176.  
  177. Brief list:
  178.  
  179. Routines
  180. ~~~~~~~~
  181. &0000 : TG_getrnd - routine returning 32bit random number in R3
  182. &0004 : TG_getrnd2 - routine returning 32bit random number in R3
  183. &0008 : TG_getparameter - routine returning the value of the next parameter
  184. &000C : TG_cstable - location of sin and cosine table.
  185. &0010 : TG_astable - location of arcsin table.
  186. &0014 : TG_forstac - location of stack of for addresses
  187. &0018 : TG_forcoun - location of stack of for addresses
  188. &001C : TG_itisthecodebank - location of 16 words of ARM code for "Combine"
  189. &0020 : TG_onedimensionalfixsta - routine to start one-dimensional routines
  190. &0024 : TG_onedimensionalfixend - routine to end one-dimensional routines
  191. &0028 : TG_colourconversion - routine to perform conversion from 24-bit
  192. &002C : TG_mcheap_get - allocate memory from heap
  193. &0030 : TG_mcheap_release - deallocate memory in heap
  194. &0034 : TG_reporterror - routine to report texture errors to the user
  195. &0038 : TG_executesinglecommand - Single command execution routine
  196. &003C : TG_convertcommandname - Converts pointer to command name
  197. &0040 : TG_miscop - perform a variety of operations.
  198. &0044 : Reserved
  199.  
  200. Data
  201. ~~~~
  202. &0048 : TG_mainworkspaceaddress - the two-dimensional buffer
  203. &004C : TG_totalsize - the size of the two-dimensional buffer
  204. &0050 : TG_totalsizeminusone - the size of the two-dimensional buffer - 1
  205. &0054 : TG_powertwo - Log to the base two of the size of the main buffer
  206. &0058 : TG_powertwo_1D - Log to the base two of the 1D buffer size (10).
  207. &005C : TG_dat - temp storage (4 bytes)
  208. &0060 : TG_stack_temp - temp storage (4 bytes)
  209. &0064 : TG_cnd - temp storage (4 bytes)
  210. &0068 : TG_scrapaddress - address of temp storage (at least &800 bytes.)
  211. &006C : TG_actualphase - Current phase to be used in FFTs
  212. &0070 : TG_actualnoise - Amplitude of noise to be filtered
  213. &0074 : TG_cosamag - Cosine artefacts magnitude
  214. &0078 : TG_sinamag - Sine artefacts magnitude
  215. &007C : TG_precultflags - flags for FFT
  216. &0080 : TG_tempb - temp storage (4 bytes)
  217. &0084 : TG_tempb2 - temp storage (4 bytes)
  218. &0088 : TG_onedeebuffertwo - the secondary two-dimensional buffer
  219. &008C : TG_onedeebufferone - the primary two-dimensional buffer
  220. &0090 : TG_onedeebuffer - the two-dimensional buffer
  221. &0094 : TG_forcntr - the depth of the current for nesting
  222. &0098 : TG_dithering - Dithering
  223. &009C : TG_ditheringOne - DitheringOne
  224. &00A0 : TG_ditheringTwo - DitheringTwo
  225. &00A4 : TG_resultoftestpar - internal communications
  226. &00A8 : TG_resultoftestparP4 - internal communications
  227. &00AC : TG_seed - Seed (Low word)
  228. &00B0 : TG_seedP4 - Seed (High word)
  229. &00B4 : TG_seedTwo - Seed Two (Low word)
  230. &00B8 : TG_seedTwoP4 - Seed Two (High word)
  231. &00BC : TG_aframesmem% - Number of current animation frame
  232. &00C0 : TG_aframetype% - Address of table of 1024 nibbles animation type
  233. &00C4 : TG_areweanimating - Flag
  234. &00C8 : TG_blockmem% - address of a temp storage bank
  235. &00CC : TG_block2mem% - address of a temp storage bank
  236. &00D0 : TG_spriteaddress - address of the current sprite
  237. &00D4 : TG_spritearea - address of the main sprite area
  238. &00D8 : TG_spritepaladdress - address of the current palette sprite
  239. &00DC : TG_spriteXoriginal - used in resizing sprite
  240. &00E0 : TG_spriteYoriginal - used in resizing sprite
  241. &00E4 : TG_spriteXactual - used in resizing sprite
  242. &00E8 : TG_spriteYactual - used in resizing sprite
  243. &00EC : TG_modenumber - Number of current mode
  244. &00F0 : TG_log2BPP - Log to the base two of the number of bits per pixel
  245. &00F4 : TG_XEigenFactor - The X Eigen Factor of the mode
  246. &00F8 : TG_YEigenFactor - The Y Eigen Factor of the mode
  247. &00FC : TG_cmd_ifmem - Number to detect "If"s with
  248. &0100 : TG_cmd_elsemem - Number to detect "Else"s with
  249. &0104 : TG_cmd_endifmem - Number to detect "Endif"s with
  250. &0108 : TG_cmd_define - Number to detect "Define"s with
  251. &010C : TG_cmd_ifyetq - Flag to detect if there has been an if on the line
  252. &0110 : TG_colourmapcorrupt - Set if TG_colourconversion has been called
  253. &0114 : TG_AddressOfSolidBlock - Address of last DefineSolidBlock command
  254. &0118 : TG_memorystoreone - Address of claimed memory to be released
  255. &011C : TG_memorystoretwo - Address of claimed memory to be released
  256. &0120 : TG_FirstDefinition - zero of address of first "Define" command
  257. &0124 : TG_CallStackMem - Not used
  258. &0128 : TG_customresize - Set if resizing is not done with "ResizeSprite"
  259. &012C : TG_percentage - Reflects the hourglass percentage
  260. &0130 : TG_red - The red component of the current colour (0-&FFFF)
  261. &0134 : TG_green - The green component of the current colour (0-&FFFF)
  262. &0138 : TG_blue - The blue component of the current colour (0-&FFFF)
  263. &013C : TG_lstable - The address of the light source table
  264. &0140 : TG_lscounter - The number of light sources defined so far
  265. &0144 : TG_Xresize - \ The values of the last parameters passed to
  266. &0148 : TG_Yresize - / either Resize or ResizeBumpMap
  267. &014C : TG_registered - 0 if the Freeware version is in use (read only)
  268.  
  269. Those "Routines" in the above list which may be called can be reached by
  270. using the following code:
  271.  
  272. MOV    R14,PC
  273. LDR    PC,[R12,#<TG_routineoffset>]
  274.  
  275. In the examples this is a macro called "calltg".
  276.  
  277. Descriptive list:
  278.  
  279. Routines
  280. ~~~~~~~~
  281. TG_getrnd (&0000)
  282.   Entry : none
  283.   Exit  : corrupts R4 returns 32bit random number in R3.
  284.  
  285. TG_getrnd2 (&0004)
  286.   Entry : none
  287.   Exit  : corrupts R0 returns 32bit random number in R3.
  288.   Notes : This command uses a different seed to the one above.
  289.  
  290. TG_getparameter (&0008)
  291.   Entry : R11 points to current mark in program.
  292.   Exit  : R10 returns the value of the next parameter.
  293.           R11 updated to point to next point in program.
  294.  
  295. TG_cstable (&000C)
  296. Location of sin and cosine table.  2048 words, format as follows:
  297.   Word0    : Cosine(2*PI/1024 x 0) x 2^15
  298.   Word1    :   Sine(2*PI/1024 x 0) x 2^15
  299.   Word2    : Cosine(2*PI/1024 x 1) x 2^15
  300.   Word3    :   Sine(2*PI/1024 x 1) x 2^15
  301.   Word4    : Cosine(2*PI/1024 x 2) x 2^15
  302.   Word5    :   Sine(2*PI/1024 x 2) x 2^15
  303.   ...      : ...
  304.   Word2046 : Cosine(2*PI/1024 x 1023) x 2^15
  305.   Word2047 :   Sine(2*PI/1024 x 1023) x 2^15
  306.  
  307. TG_astable (&0010)
  308.   Arcsin table.  256 bytes.
  309.  
  310. TG_forstac (&0014)
  311.   Location of stack of for addresses.
  312.  
  313. TG_forcoun (&0018)
  314.   Location of stack of for addresses.
  315.  
  316. TG_itisthecodebank (&001C)
  317.   Location of 16 words of ARM code for "Combine"
  318.   The words are as follows:
  319.  
  320.     &0 : CMP   A,#&10000
  321.     &1 : MOVS  A,A,LSR #16
  322.     &2 : MOVS  A,A,LSL #16
  323.     &3 : EorS  A,A,#&8000
  324.     &4 : ADDS  A,A,9
  325.     &5 : CMP   A,9
  326.     &6 : SUBS  A,A,9
  327.     &7 : MOVCS A,#&10000
  328.     &8 : RSBCS A,A,#&20000
  329.     &9 : RSBMI A,A,#&0
  330.     &A : MOVMI A,#&0
  331.     &B : MOVCC A,9
  332.     &C : MOVCS A,9
  333.     &D : SUBCS A,A,#1
  334.     &E : MOVS  A,A,LSR #1
  335.     &F : MULS  A,9,A
  336.  
  337. TG_onedimensionalfixsta (&0020)
  338.   Routine to start one-dimensional routines.
  339.  
  340. TG_onedimensionalfixend (&0024)
  341.   Routine to end one-dimensional routines.
  342.  
  343. TG_colourconversion (&0028)
  344.   Routine to perform conversion of the palette from 24-bit colour in the
  345.   format &RRGGBBXX to a series of bytes representing the colour number of
  346.   the colour for the mode.
  347.  
  348. TG_mcheap_get (&002C)
  349.   This allocates memory from Texture Garden's heap
  350.   Entry : R0 contains number of bytes requested.
  351.   Exit  : R0 : 0 (an error has occurred (V is also set), or...
  352.           R0 : contains a pointer to the memory.
  353.           R1 - R7 corrupted.
  354.  
  355.   Note: this routine returns an error by setting the V flag and setting R0
  356.         to 0.
  357.  
  358. TG_mcheap_release (&0030) 
  359.   This deallocates memory which has been previously allocated from Texture
  360.   Garden's heap.
  361.   Entry : R0 contains a pointer to the memory.
  362.   Exit  : R0 : 0 : an error has occurred (V is also set), or...
  363.           R0 : 1 : sucessful.
  364.           R1 - R7 corrupted.
  365.  
  366.   Note: this routine returns an error by setting the V flag and setting R0
  367.         to 0.
  368.  
  369. TG_reporterror (&0034)
  370.   Entry : R0 points to the error string
  371.   Exit  : *** This routine does not return ***
  372.  
  373. TG_executesinglecommand (&0038) - Single command execution routine.
  374.   Entry : R11 points to the command to be executed.
  375.   Exit  : R0 - R10 and R12 are corrupted.  R11 points to immediately after
  376.           the command.
  377.  
  378. TG_convertcommandname (&003C) - Converts pointer to command name.
  379.   Entry : R0 points to the command to be converted.
  380.   Exit  : R0 contains the corresponding internal command code.
  381.  
  382. TG_miscop (&0040) - Performs a variety of miscellaneous operations.
  383.   Entry : R0 contains the reason code, see the following list:
  384.   
  385.   Entry : R0 = 0;
  386.     Allocate memory for another two dimensional buffer, if required and
  387.     return a pointer to it in R10.
  388.   Exit : R0 to R9 are corrupted.
  389.   
  390.   Entry : R0 = 1;
  391.     Allocate memory for a virtual sprite if required and return a pointer to
  392.     it in R10.
  393.   Exit : R0 to R9 are corrupted.
  394.   
  395.   Entry : R0 = 2; R1,R2,R3 are as "OS_SpriteOp" with R0 = &22E.
  396.     Delete columns from an existing sprite.  This is equivalent to
  397.     XOS_SpriteOp with R0 = &22E, except that it does not produce errors when
  398.     applied to deep sprites on pre-RISC OS 3.5 machines.
  399.   Exit : R10 is are corrupted.
  400.   
  401.   Entry : R0 = 3;
  402.     Allocate memory for a virtual palette sprite if required and return a
  403.     pointer to it in R10.
  404.   Exit : R0 to R9 are corrupted.
  405.   
  406. All other TG_miscop reason codes are reserved.
  407.  
  408. 5.0 Coding
  409. ~~~~~~~~~~
  410. Example source (in the BASIC assembler) should be available in the
  411. "Library.Source.Extra" file and the "Library.Source.Kernel" file.  The latter
  412. may not be present in the distribution you have received, but should be in
  413. all registered versions.
  414.  
  415. If a command takes longer than about 0.2 seconds, then it should check the
  416. escape key at regular intervals (using an INKEY(minus) equivalent) and
  417. terminate if it is pressed.
  418.  
  419. On entry to its routine, a command usually starts by getting its relevant
  420. parameters.  These should always be checked to see if they are functions, and
  421. evaluated if this is the case.  It is recommended that the following code be
  422. used to get each one:
  423.  
  424. LDR    R10,[R11],#4
  425. TST    R10,#&80000000
  426. MOVNE  R14,PC
  427. LDRNE  PC,[R12,#TG_getparameter]
  428.  
  429. This is used so frequently that it really cries out to be a macro. 
  430. "getrecursiveparam" is its name in the examples.
  431.  
  432. The "Routine" TG_getparameter will normally preserve R0-R7, R12 and R13.  R8
  433. and R9 may be corrupted.  R10 contains the returned result of the function. 
  434. R11 is updated to point to the next word of interest.
  435.  
  436. Another command which will be used frequently relates to the implementation
  437. of the "combination type" commands.  Programmers may implement these in
  438. whatever manner they choose.  The author finds them to be best implemented
  439. using the following self-modifying code for speed, though this may cause a
  440. speed penalty for those with StrongARM chips.
  441.  
  442. In my routines, the following functions are used.
  443.  
  444. DEFFNgetaddparam(alse%)   ... corrupts R0-R3
  445. [OPT Pass%
  446.         LDR    0,[C,#TG_itisthecodebank]
  447.         ADR    1,alse%
  448.         And    2,R10,#&F
  449.         LDR    3,[0,2,ASL #2]
  450.         STR    3,[1]
  451.         MOV    R10,R10,LSR #4
  452.         And    2,R10,#&F
  453.         LDR    3,[0,2,ASL #2]
  454.         STR    3,[1,#4]
  455.         MOV    R10,R10,LSR #4
  456.         And    2,R10,#&F
  457.         LDR    3,[0,2,ASL #2]
  458.         STR    3,[1,#8]
  459.         MOV    R10,R10,LSR #4
  460.         And    2,R10,#&F
  461.         LDR    3,[0,2,ASL #2]
  462.         STR    3,[1,#12]
  463.         
  464.         MOV    0,#1
  465.         ADD    2,1,#12
  466.         SWI    &2006E ; REM XOS_SynchroniseCodeAreas
  467. ]
  468. = Pass%
  469.  
  470. DEFFNfourwords
  471. [OPT Pass%
  472.         MOV    R10,R10
  473.         MOV    R10,R10
  474.         MOV    R10,R10
  475.         MOV    R10,R10
  476. ]
  477. = Pass%
  478.  
  479. These are called as follows...
  480.  
  481. .command_entry
  482. ...
  483. OPT    FNgetrecursiveparam           ...see above
  484. OPT    FNgetaddparam(code_insertion)
  485. ...
  486. .code_insertion
  487. OPT    FNfourwords
  488. ...
  489.  
  490. The two values to be combined should be held in R9 (old) and R10 (new value)
  491. when "code_insertion" is reached.  The data table at TG_itisthecodebank
  492. contains the following pieces of code:
  493.  
  494. CMP    A,#&10000   ; 0
  495. MOVS   A,A,LSR #16 ; 1
  496. MOVS   A,A,LSL #16 ; 2
  497. EorS   A,A,#&8000  ; 3
  498. ADDS   A,A,9       ; 4
  499. CMP    A,9         ; 5
  500. SUBS   A,A,9       ; 6
  501. MOVCS  A,#&10000   ; 7
  502. RSBCS  A,A,#&20000 ; 8
  503. RSBMI  A,A,#&0     ; 9
  504. MOVMI  A,#&0       ; A
  505. MOVCC  A,9         ; B
  506. MOVCS  A,9         ; C
  507. SUBCS  A,A,#1      ; D
  508. MOVS   A,A,LSR #1  ; E
  509. MULS   A,9,A       ; F
  510.  
  511. Examination of FNgetaddparam should reveal that four values from the above
  512. table are taken according to the value of the four nibbles of the given
  513. parameter and stored at "code_insertion", least-significant nibble first.
  514.  
  515. 6.0 Calling internal commands
  516. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  517. "TG_executesinglecommand" and "TG_convertcommandname" may be used by commands
  518. to call other commands directly.  This is done in a crude manner,
  519. constructing the command in memory, and then setting the command pointer to
  520. point to it and then calling Texture Garden.
  521.  
  522. "TG_convertcommandname" should be used to convert the command name to a
  523. command code.  This step is important, as command codes are not guaranteed
  524. to be the same across different instantiations of the program, and they
  525. depend on which extension modules are loaded.  They only need to be
  526. calculated once each time Texture Garden is run.
  527.  
  528. Commands should be stored in memory locally and followed by any parameters.
  529. Commands may be of any case, and may be abbreviated by using the "."
  530. character (however, using this feature is very bad practise).  
  531. After the command codes and their parameters are all placed into consecutive
  532. words of memory, the current value of the command pointer (usually in R11)
  533. should then be saved, the location of the command to be executed should be
  534. loaded into R11 and "TG_executesinglecommand" should be called.
  535. Then the command pointer should be recovered from wherever it was saved.
  536.  
  537. Note: "TG_executesinglecommand" executes one command only.  The command
  538. should not be a comment or one of "If", "Then" or "Else"; the functionality
  539. of these may be mimicked manually.
  540.  
  541. Expression evaluation may be performed using a similar method, ie. set up the
  542. expression in coded form in memory, store R11, set R11 to point to the
  543. expression, and then use FNgetrecursiveparam (or its equivalent macro - see
  544. above) to evaluate it, restoring R11 afterwards.
  545.  
  546. The only functions in Texture Garden that currently use this functionality
  547. are the "SlowRotate" commands.  These use the "TwoDimensionalPoint" function
  548. to help them with their anti-aliasing.
  549.  
  550. In principle, any commonly used subroutine may be more efficiently
  551. implemented as a hard-wired command using this technique.
  552.  
  553. Because "TG_convertcommandname" performs a slow lookup, a number of common
  554. expression evaluation functions are assigned particular code numbers.
  555.  
  556. The following command names are guaranteed to be given numbers as follows:
  557.  
  558. &80000000 - "UnknownCommand" ; please do not use.
  559. &80000001 - "Combine"
  560. &80000002 - "ScaledSignedMultiply"
  561. &80000003 - "SignedMultiply"
  562. &80000004 - "PartlyScaledSignedMultiply"
  563. &80000005 - "PartlyScaledMultiply"
  564. &80000006 - "Divide"
  565. &80000007 - "Eor"
  566. &80000008 - "And"
  567. &80000009 - "Or"
  568. &8000000A - "LogicalShiftLeft"
  569. &8000000B - "LogicalShiftRight"
  570. &8000000C - "ArithmeticShiftLeft"
  571. &8000000D - "ArithmeticShiftRight"
  572. &8000000E - "Absolute"
  573. &8000000F - "Variable"
  574. &80000010 - "Random"
  575. &80000011 - "SimpleAddition"
  576. &80000012 - "UnboundedAddition"
  577. &80000013 - "CeilingAddition"
  578. &80000014 - "HalvingAddition"
  579. &80000015 - "SimpleSubtraction"
  580. &80000016 - "UnboundedSubtraction"
  581. &80000017 - "FloorSubtraction"
  582. &80000018 - "HalvingSubtraction"
  583. &80000019 - "Maximise"
  584. &8000001A - "Minimise"
  585. &8000001B - "Overwrite"
  586. &8000001C - "PositiveOverwrite"
  587. &8000001D - "Preserve"
  588. &8000001E - "Multiplication"
  589. &8000001F - "ScaledMultiplication"
  590. &80000020 - "Zeroise"
  591. &80000021 - "True"
  592. &80000022 - "False"
  593. &80000023 - "Zero"
  594. &80000024 - "Ninety"
  595. &80000025 - "OneHundredAndEighty"
  596. &80000026 - "TwoHundredandSeventy"
  597. &80000027 - "FloydSteinberg"
  598. &80000028 - "IsLessThan"
  599. &80000029 - "IsGreaterThan"
  600. &8000002A - "IsLessThanOrEqualTo"
  601. &8000002B - "IsGreaterThanOrEqualTo"
  602. &8000002C - "SignedIsLessThan"
  603. &8000002D - "SignedIsGreaterThan"
  604. &8000002E - "SignedIsLessThanOrEqualTo"
  605. &8000002F - "SignedIsGreaterThanOrEqualTo"
  606. &80000030 - "IsEqualTo"
  607. &80000031 - "IsNotEqualTo"
  608. &80000032 - "Sin"
  609. &80000033 - "Cos"
  610. &80000034 - "SignedSin"
  611. &80000035 - "SignedCos"
  612. &80000036 - "SquareRoot"
  613. &80000037 - "Noise"
  614. &80000038 - "PinkNoise"
  615. &80000039 - "QuickNoise"
  616. &8000003A - "BandpassNoise"
  617. &8000003B - "BandpassQuickNoise"
  618. &8000003C - "FractalNoise"
  619. &8000003D - "ShiftedSymmetricNoise"
  620. &8000003E - "ShiftedSymmetricPinkNoise"
  621. &8000003F - "ShiftedNoise"
  622. &80000040 - "ShiftedPinkNoise"
  623. &80000041 - "ShiftedSymmetricQuickNoise"
  624. &80000042 - "ShiftedQuickNoise"
  625. &80000043 - "ShiftedSymmetricFractalNoise"
  626. &80000044 - "ShiftedFractalNoise"
  627. &80000045 - "TwoDimensionalPoint"
  628. &80000046 - "QuickTwoDimensionalPoint"
  629. &80000047 - "OneDimensionalPoint"
  630. &80000048 - "QuickOneDimensionalPoint"
  631. &80000049 - "OneDimensionalPointOne"
  632. &8000004A - "QuickOneDimensionalPointOne"
  633. &8000004B - "OneDimensionalPointTwo"
  634. &8000004C - "QuickOneDimensionalPointTwo"
  635. &8000004D - "X"
  636. &8000004E - "Y"
  637. &8000004F - "Z"
  638. &80000050 - "Size"
  639. &80000051 - "LogSize"
  640. &80000052 - "LogBitsPerPixel"
  641. &80000053 - "AnimationType"
  642. &80000054 - "AnimationFrameNumber"
  643. &80000055 - "Add"
  644. &80000056 - "Subtract"
  645. &80000057 - "Maximise"
  646. &80000058 - "Minimise"
  647. &80000059 - "Multiply"
  648. &8000005A - "RGB"
  649. &8000005B - "HSV"
  650. &8000005C - "CIE"
  651. &8000005D - ... reserved.
  652.  
  653. These functions all preserve R0-R7 and return their value in R10, updating
  654. R11 according to the number of parameters they take.  They operate by
  655. evaluating their parameters in a recursive fashion.
  656.  
  657. X-, Y- and Z-based functions are expecting to find their values in R2, R3 and
  658. R4 respectively, and they depend upon this for their operation.
  659. Functions which fit into this category include those from "Noise" to
  660. "ShiftedFractalNoise" as well as the more obvious "X", "Y" and "Z".  These
  661. functions will not return sensible vaules unless R2, R3 and R4 are set up
  662. probably before they are called.
  663.  
  664. In general, different copies of Texture Garden will use different coding
  665. schemes for the numbers they assign to their commands.  It is recommended
  666. that you do not rely on the numbers given to commands (apart from those
  667. explicitly mentioned in the list above) as being constant, though within
  668. any given instantiation of Texture Garden, they will not change, so commands
  669. only need to be looked up once.
  670.  
  671. More information relating to writing extension modes is contained in the rest
  672. of the documentation, notably the "Distribute", "Language" and "Technical"
  673. files.
  674.