home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 5
/
DATAFILE_PDCD5.iso
/
utilities
/
t
/
texturegnd
/
Docs
/
Extensions
< prev
next >
Wrap
Text File
|
1996-11-30
|
26KB
|
676 lines
Language Extensions
===================
1.0 Introduction
2.0 The RMStore directory
3.0 Structure
4.0 Resources
5.0 Coding
6.0 Calling internal commands
1.0 Introduction
~~~~~~~~~~~~~~~~
This document describes how to write language-extensions to the texture
generation language used in the Texture Garden program, reasons why you might
be interested in doing this and information about installing other people's
extension modules.
Commands may be included, but functions (refer to the "Language" file for the
differences between these) may not currently be implemented by third parties.
Example source code using the BASIC assembler is available. It is no longer
commonly distributed with the main TG archive (for reasons of space), and
the entire source code for Texture Garden's Kernel is also available.
Although this code is distributed as freeware (i.e. copyright is retained)
the author expresses every intention of approving use of my code where it is
incorporated into modules intended for my program, so please do not hesitate
to steal and butcher it; if this was objected to no source code would have
been distributed.
2.0 The RMStore directory
~~~~~~~~~~~~~~~~~~~~~~~~~
This is a directory immediately inside the "!TexturGdn" directory. The
location is usually "<TextureGdn$Dir>.RMStore". The precise location is held
in the system variable <TextureGdnRMStore$Dir> which is usually set up in the
!Run file.
This directory should always contain a text file called "Index". This file
has a simple format:
Any line starting with a "|" is considered to be a comment. The end of the
file is marked by the "End" token. Any other lines are considered as paths
from <TextureGdnRMStore$Dir> to files containing language extensions.
The file "Kernel" should always be present in the directory. It contains all
the commands implemented as the core of the language. There may also be
other files.
The files may be of any type. Conventionally, they are "Modules"
(Type &FFA). Though they are not loaded as such by the program this enables
them to conveniently contain a version number and help text.
When adding extension modules to the program the relevant file should be
added to the "RMStore" directory and the twig of its path inserted into the
"Index" file.
3.0 Structure
~~~~~~~~~~~~~
Language extensions should all conform to the following structure:
Bytes: Description...
&0000-&002B Header (Undefined bytes)
&002C-&XXXX Command Table index
&XXXX-&YYYY Command Table
&YYYY-&ZZZZ Command code
The Command Table index has the following format:
Offset bytes: Description...
&0000 Command index entry 0
&000C Command index entry 1
&0018 Command index entry 2
- -
n x &C Command index entry n
- -
&UUUU End of table marker.
The End of table marker is represented by the three consecutive words
-1,-1 and -1.
Command index entry n consists of three words
Word 0: Offset from start of file to the text of command n.
Word 1: Offset from start of file to the entry point of the code to perform
the command.
Word 2: Various flags
The Various flags are considered as &ABCDEFGH where &A is the number of
parameters the command accepts (0-15), &B is a code advising how the command
should be treated by the mutator (the "Mutation Options"), and &CDEFGH
contain other miscellaneous bit-flags to mark specific command types.
These bit-flags have the following meanings:
&000003 : (Reserved)
&00000C : See immediately below:
&4 : Command ends an indentation
&8 : Command starts an indentation
&0000F0 : (Reserved)
&00FF00 : As follows:
&0C00 : Command is an "endif" (Reserved)
&0200 : Command starts mutation (Reserved)
&0300 : Command stops mutation (Reserved)
&0400 : Command is a "Define" (Reserved)
&0500 : Command is a "Goto" (Reserved)
&0600 : Command is a "Call" (Reserved)
&0700 : Command is a "Return" (Reserved)
&0800 : Command is an "End" (Reserved)
&0900 : Command is an "If" (Reserved)
&0A00 : Command is an "Then" (Reserved)
&0B00 : Command is an "Else" (Reserved)
&0100 : Command is a "comment" ("|") (Reserved)
&0D00 : Command ends the colour definition (Reserved)
&0E00 : Command starts the colour definition (Reserved)
&0F00 : Command is a "CreateOneDiensionalFilter" (Reserved)
&1000 : Command is a "CreateTwoDiensionalFilter" (Reserved)
&1100 : Command is an "Until" (Reserved)
&1200 : Command is a "Resize" (Reserved)
&1300 : Command is a "ResizeSprite" (Reserved)
&1400 : Command is a "MakeSprite" (Reserved)
&1500 : Command is an "AddToSprite" (Reserved)
&1600 : Command is a "MakeVirtualSprite" (Reserved)
&1700 - &FF00 For expansion (Reserved)
&FF0000 : Bits all for expansion and must be zero (Reserved)
"Reserved" means that most users should not need to mess with it.
The "Command Table" contains the entries pointed to by word 0 of the Command
index entry. These are mixed case strings terminated by a single ASCII 13
character. They need not be word aligned.
The "Command code" contains the code pointed to by word 1 of the Command
index entry. These are ARM code subroutines called at the appropriate moment
in the generation of the textures. Any workspace may also be stored here,
rather than claimed from the system, if it is small enough. The location of
the "Command code" relative to the "Command table" is arbitrary.
Mutation Options
~~~~~~~~~~~~~~~~
This specifies how any following parameters are treated by the mutator.
0 - Completely ignore.
1 - Treat as unsigned 16-bit logarithmic number (reserved for functions)
2 - Very occasionally add or subtract one (used for "Shear")
3 - Occasionally completely randomize (used for "Seed")
4 - Treat as unsigned 16-bit logarithmic number
5 - Treat as a SetColour command...
6 - Treat as a DefineLightSource command.
7 - Reserved...
4.0 Resources
~~~~~~~~~~~~~
When a code fragment is called in the generation of a texture it may interact
with the main program and share its data in a number of ways.
On entry to the routine the following register conventions are used:
R14 - return address
R13 - system stack
R12 - pointer to Texture Garden main data structure
R11 - pointer to current point in texture program execution
On exit R0 - R10, R12 and R14 may be corrupted. R11 should normally be
incremented to the start of the next expected command. R13 should normally
be preserved in the normal manner.
R11 contains a pointer to the next item in the texture program's execution.
This will always be the next item after the code representing the currently
called command. Note that the program is not held internally as a textfile,
but in an internal format.
Each command, parameter or function is coded for by one word. Parameters are
coded for by their values. Commands and functions are coded bu an internal
number, the complete details of which are not specified, but which always has
bit 31 set. The end of the file is coded as -1. This need not normally be
checked for.
R12 contains a pointer to a data structure which has the following structure:
Brief list:
Routines
~~~~~~~~
&0000 : TG_getrnd - routine returning 32bit random number in R3
&0004 : TG_getrnd2 - routine returning 32bit random number in R3
&0008 : TG_getparameter - routine returning the value of the next parameter
&000C : TG_cstable - location of sin and cosine table.
&0010 : TG_astable - location of arcsin table.
&0014 : TG_forstac - location of stack of for addresses
&0018 : TG_forcoun - location of stack of for addresses
&001C : TG_itisthecodebank - location of 16 words of ARM code for "Combine"
&0020 : TG_onedimensionalfixsta - routine to start