Embedded Templates
~~~~~~~~~~~~~~~~~~

For small programs, it's irritating to have a separate templates file
hanging around.  Separate files aren't necessary for sprites or messages,
so templates become rather annoying.  An `embedded template' is a
position-independent in-memory representation of a window template which
has had some extra information added to make it particularly easy to
construct a real window definition.  (The idea of adding relocation
offsets is admittedly based on the Toolbox resource format.)  This
trivial library unpacks embedded templates.

The format of an embedded template is (I think) as follows:

Offset	  Size		Value

   0	    4		Offset to window definition ($w$)
   4	    4		Offset to indirected data ($i$)
   8	    4		Offset to limit of the template ($l$)
  12	$w - 12$	Relocation directives

 $w$	 $i - w$	Template window definition (as in template files)

 $i$	 $l - i$	Initialisation strings for indirected icons and
 			window titles.  This will be copied literally
			into the application's indirected data space.

Each relocation directive consists of a single word; the top four bits of
a relocation directive determine the `type'; the bottom twenty-eight bits
give the `offset'.

Currently defined types are:

Type	Meaning

  0	Add the address of the indirected data area to the word at the
		given offset into the window definition.
  1	Store the `window sprite area' in the word at the given offset
  		into the window definition.
  2	Store the `icon sprite area' in the word at the given offset
  		into the window definition.

Embedded templates are not meant to be built by hand.  Instead, the
programs `templAOF' and `resGen' will build AOF files containing embedded
template defintions from standard template files.  These can be linked
into applications and modules.

--
[mdw]
