<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://newgrf-specs.tt-wiki.net/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Emperor+Jake</id>
	<title>GRFSpecs - User contributions [en-gb]</title>
	<link rel="self" type="application/atom+xml" href="https://newgrf-specs.tt-wiki.net/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Emperor+Jake"/>
	<link rel="alternate" type="text/html" href="https://newgrf-specs.tt-wiki.net/wiki/Special:Contributions/Emperor_Jake"/>
	<updated>2026-05-14T06:58:09Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://newgrf-specs.tt-wiki.net/index.php?title=NML:Spritelayout&amp;diff=2667</id>
		<title>NML:Spritelayout</title>
		<link rel="alternate" type="text/html" href="https://newgrf-specs.tt-wiki.net/index.php?title=NML:Spritelayout&amp;diff=2667"/>
		<updated>2011-10-03T03:22:58Z</updated>

		<summary type="html">&lt;p&gt;Emperor Jake: /* Recolouring */  Spelling error&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{NMLNavBlocksyntax}}&lt;br /&gt;
&lt;br /&gt;
Stations, houses, industry tiles, objects, and airport tiles use spritelayouts to define layouts how sprites are supposed to be arranged on a tile. A &amp;lt;code style=&amp;quot;color:darkgreen&amp;quot;&amp;gt;spritelayout&amp;lt;/code&amp;gt; can combine multiple sprites into one entity, which represents everything that is to be drawn on a particular tile. A simple example to illustrate how it works:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:blue&amp;quot;&amp;gt;&lt;br /&gt;
 spritelayout airport_building1 {&lt;br /&gt;
 	ground { sprite: GROUNDSPRITE_NORMAL; }&lt;br /&gt;
 	childsprite {&lt;br /&gt;
 		sprite: spr_small_dirt_ne; // custom spriteset&lt;br /&gt;
 		always_draw: 1; // also draw in transparent mode&lt;br /&gt;
 	}&lt;br /&gt;
 	building {&lt;br /&gt;
 		sprite: 0xA67; // reuse this existing base set sprite&lt;br /&gt;
 		xoffset: 0x0F;&lt;br /&gt;
 		xextent: 1;&lt;br /&gt;
 		zextent: 6;&lt;br /&gt;
 		recolour_mode: RECOLOUR_REMAP;&lt;br /&gt;
 		palette: PALETTE_USE_DEFAULT;&lt;br /&gt;
 	}&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The sprite layout is composed of one or more sprites. Each sprite is defined by a &amp;lt;code style=&amp;quot;color:darkgreen&amp;quot;&amp;gt;ground&amp;lt;/code&amp;gt;, &amp;lt;code style=&amp;quot;color:darkgreen&amp;quot;&amp;gt;building&amp;lt;/code&amp;gt; or &amp;lt;code style=&amp;quot;color:darkgreen&amp;quot;&amp;gt;childsprite&amp;lt;/code&amp;gt; block. What block to use depends on how the sprite is to be placed on the tile.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code style=&amp;quot;color:darkgreen&amp;quot;&amp;gt;ground&amp;lt;/code&amp;gt; sprites are drawn at the base of the tile, like grass and concrete, rails etc. in normal TTD. With a few exceptions (e.g. when using custom foundations), you should always provide a ground sprite, even when the building above fully covers it. This because in transparent mode, the building becomes invisible. A tile can only have one ground sprite.&lt;br /&gt;
* &amp;lt;code style=&amp;quot;color:darkgreen&amp;quot;&amp;gt;building&amp;lt;/code&amp;gt; sprites are drawn on top of the ground sprite. To determine their location and drawing order (what goes in front of what), they have a 3D bounding box.&lt;br /&gt;
* With &amp;lt;code style=&amp;quot;color:darkgreen&amp;quot;&amp;gt;childsprite&amp;lt;/code&amp;gt;(s), you can effectively compose sprites from multiple parts. When placing these after a building sprite, they will use the same bounding box as the previous building sprite. When placing them before the first building sprite, they will have no bounding box, as if they would use the &#039;bounding box&#039; of the ground tile. Multiple childsprites may be used per ground / building sprite.&lt;br /&gt;
&lt;br /&gt;
The sprite order is genrally determined by the sprite sorter, that evaluates the bounding box (see below) of each sprite. Child sprites are always part of the building (or ground) sprite that precedes them. In the GUI, sprites are always drawn in the order specified in the layout, so be sure to get this correct for spritelayouts that are to be displayed there.&lt;br /&gt;
&lt;br /&gt;
Per sprite, a number of parameters may be set. These are listed below. Unless otherwise indicated, each may have a value that is dependant on &#039;&#039;&#039;variables, parameters or registers&#039;&#039;&#039;. Accessed variables are always in the &amp;lt;code style=&amp;quot;color:darkgreen&amp;quot;&amp;gt;SELF&amp;lt;/code&amp;gt; scope. Accessing variables inside the purchase list is &#039;&#039;&#039;not&#039;&#039;&#039; supported, make sure that layouts accessed from there do not use them. Using variables and parameters, it&#039;s possible to create wildly differing looks with few spritelayouts.&lt;br /&gt;
&lt;br /&gt;
===Sprite===&lt;br /&gt;
&lt;br /&gt;
The most important parameter is &amp;lt;code style=&amp;quot;color:darkgreen&amp;quot;&amp;gt;sprite&amp;lt;/code&amp;gt;, this determines the actual sprite to be drawn. If you set this to a number, a TTD sprite will be drawn, usually from the base set. Pre-defined constants for some base set sprites are:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code style=&amp;quot;color:darkgreen&amp;quot;&amp;gt;GROUNDSPRITE_NORMAL (a)&amp;lt;/code&amp;gt; default terrain type for that climate (temperate, toyland: normal, arctic: without snow, tropical: rainforest).&lt;br /&gt;
* &amp;lt;code style=&amp;quot;color:darkgreen&amp;quot;&amp;gt;GROUNDSPRITE_DESERT (a)&amp;lt;/code&amp;gt; desert tile&lt;br /&gt;
* &amp;lt;code style=&amp;quot;color:darkgreen&amp;quot;&amp;gt;GROUNDSPRITE_SNOW (a)&amp;lt;/code&amp;gt; snowy ground tile&lt;br /&gt;
* &amp;lt;code style=&amp;quot;color:darkgreen&amp;quot;&amp;gt;GROUNDSPRITE_CONCRETE&amp;lt;/code&amp;gt; concrete ground tile&lt;br /&gt;
* &amp;lt;code style=&amp;quot;color:darkgreen&amp;quot;&amp;gt;GROUNDSPRITE_WATER&amp;lt;/code&amp;gt; flat water tile&lt;br /&gt;
* &amp;lt;code style=&amp;quot;color:darkgreen&amp;quot;&amp;gt;GROUNDSPRITE_CLEARED (a)&amp;lt;/code&amp;gt; ground tile that has just been bulldozed (with brown colour)&lt;br /&gt;
&lt;br /&gt;
(a) These constants can be used for sprites on flat ground. There are also equivalent sprites for sloped ground, however. These sprites follow the initial ground sprite, the [[NML:Builtin functions|builtin function]] &amp;lt;code style=&amp;quot;color:darkgreen&amp;quot;&amp;gt;slope_to_sprite_offset(&#039;&#039;slope&#039;&#039;)&amp;lt;/code&amp;gt; may be used to compute the required offset. Refer to the reference on [[NML:List of tile slopes|slopes]] or the [[#Example_.28advanced.29_Spritelayout|example]] below.&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can set the value to (the name of) a [[NML:Spriteset|spriteset]], to provide a custom sprite. When the value is just a spriteset identifier, a sprite from that set will be selected depending on the construction stage, see below. All spritesets used in a layout &#039;&#039;&#039;must&#039;&#039;&#039; have the same number of sprites, due to a restriction in the NFO format. If you supply an argument (e.g. &amp;lt;code style=&amp;quot;color:darkgreen&amp;quot;&amp;gt;sprite: some_sprite_set(2);&amp;lt;/code&amp;gt;), the corresponding sprite from the sprite set will be used, with an argument of 0 corresponding to the first sprite. Note that the argument may also be variable, so you could e.g. use &amp;lt;code style=&amp;quot;color:darkgreen&amp;quot;&amp;gt;sprite: some_set(construction_state);&amp;lt;/code&amp;gt; to use the construction state to select the sprite (as is the default). If the spriteset has labels defined, you can use these labels in the argument expression.&lt;br /&gt;
&lt;br /&gt;
* For stations, objects and airport tiles, there are no construction stages, so the first sprite from the set is used always.&lt;br /&gt;
* For houses and industry tiles, sprite chosen depends on the construction stage and the number of sprites available.&lt;br /&gt;
** If there is only one sprite in the set, it is used always.&lt;br /&gt;
** If there are two sprites, one is used during construction (stages 0-2) and one for the finished building (stage 3)&lt;br /&gt;
** If there are three sprites, one is used for the beginning of construction (stage 0), one for the other construction stages (stages 1-2) and one for the finished building (stage 3).&lt;br /&gt;
** If there are four sprites, one is used for each construction stage.&lt;br /&gt;
** Sprites after the first four are always ignored.&lt;br /&gt;
&lt;br /&gt;
===Recolouring===&lt;br /&gt;
&lt;br /&gt;
Next, you have the option to apply recolouring, i.e. to change the colours of the sprite. This is done via the following attributes:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code style=&amp;quot;color:darkgreen&amp;quot;&amp;gt;recolour_mode&amp;lt;/code&amp;gt;: This must be compile-time constant. Available recolour modes are:&lt;br /&gt;
** &amp;lt;code style=&amp;quot;color:darkgreen&amp;quot;&amp;gt;RECOLOUR_NONE&amp;lt;/code&amp;gt;: Use no colour translation (default)&lt;br /&gt;
** &amp;lt;code style=&amp;quot;color:darkgreen&amp;quot;&amp;gt;RECOLOUR_REMAP&amp;lt;/code&amp;gt;: Use a colour translation table as defined by &amp;lt;code style=&amp;quot;color:darkgreen&amp;quot;&amp;gt;palette&amp;lt;/code&amp;gt;. This tables maps all colours of the sprite to a new colour.&lt;br /&gt;
** &amp;lt;code style=&amp;quot;color:darkgreen&amp;quot;&amp;gt;RECOLOUR_TRANSPARENT&amp;lt;/code&amp;gt;: Draw the sprite in transparant mode, using a colour translation table as defined by &amp;lt;code style=&amp;quot;color:darkgreen&amp;quot;&amp;gt;palette&amp;lt;/code&amp;gt;. Normally the palette will be set to PALETTE_TO_TRANSPARANT to draw all underlying colours somewhat darker. Note that the selected palette is applied to the colours of the underlying sprite, whatever that happens to be. The supplied sprite is only used to determine what pixels to recolour.&lt;br /&gt;
* &amp;lt;code style=&amp;quot;color:darkgreen&amp;quot;&amp;gt;palette&amp;lt;/code&amp;gt;: This defines the palette which is used for the colour translation. It may only (and must!) be set when &amp;lt;code style=&amp;quot;color:darkgreen&amp;quot;&amp;gt;recolour_mode&amp;lt;/code&amp;gt; is set to &amp;lt;code style=&amp;quot;color:darkgreen&amp;quot;&amp;gt;RECOLOUR_REMAP&amp;lt;/code&amp;gt; or &amp;lt;code style=&amp;quot;color:darkgreen&amp;quot;&amp;gt;RECOLOUR_TRANSPARENT&amp;lt;/code&amp;gt;. The available values are the same as for &amp;lt;code style=&amp;quot;color:darkgreen&amp;quot;&amp;gt;sprite&amp;lt;/code&amp;gt;, i.e. you can use either a default sprite or a sprite from a sprite set. In this case, however, the referenced sprite must not be a real sprite, but a [[NML:Recolour sprites|recolour sprite]]. For available default recolour sprites, see the appendix on [[NML:List of default colour translation palettes|available palettes]].&lt;br /&gt;
&lt;br /&gt;
===Display yes/no===&lt;br /&gt;
&lt;br /&gt;
The following attributes allow configuring whether the sprite will be displayed or not.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code style=&amp;quot;color:darkgreen&amp;quot;&amp;gt;hide_sprite&amp;lt;/code&amp;gt;: If set to 1, this sprite will not be drawn at all. Default is 0. If a building sprite is not drawn, all child sprites that share its bounding box are not drawn either. Setting this to a constant value makes little sense, but you can use this to enable/disable drawing certain sprites at runtime depending on certain conditions.&lt;br /&gt;
* &amp;lt;code style=&amp;quot;color:darkgreen&amp;quot;&amp;gt;always_draw&amp;lt;/code&amp;gt;: This must be a compile-time-constant. If set to 1, this sprite will also be drawn when the user has enabled transparant mode. The default value is 0. This is not available for ground sprites (those are drawn always), but it is for child sprites that share their bounding box with the ground sprite.&lt;br /&gt;
&lt;br /&gt;
===Positioning===&lt;br /&gt;
&lt;br /&gt;
How to position the sprite depends on the type of sprite:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code style=&amp;quot;color:darkgreen&amp;quot;&amp;gt;ground&amp;lt;/code&amp;gt;: Ground sprites cannot be positioned.&lt;br /&gt;
* &amp;lt;code style=&amp;quot;color:darkgreen&amp;quot;&amp;gt;building&amp;lt;/code&amp;gt;: A three-dimensional bounding box may be defined. The X-axis runs from top-right to bottom-left and the Y-axis from top-left to bottom-right. The Z axis is vertical. All units are relative to the tile, with a tile being 16 units in the X and Y directions. Extending the bounding box over the edges of a tile is possible, but not recommended as it may lead to glitches. To define the bounding box, the following attributes can be used:&lt;br /&gt;
** &amp;lt;code style=&amp;quot;color:darkgreen&amp;quot;&amp;gt;xoffset&amp;lt;/code&amp;gt;: Offset from the northwestern edge to the start of the bounding box (X).&lt;br /&gt;
** &amp;lt;code style=&amp;quot;color:darkgreen&amp;quot;&amp;gt;yoffset&amp;lt;/code&amp;gt;: Offset from the northeastern edge to the start of the bounding box (Y).&lt;br /&gt;
** &amp;lt;code style=&amp;quot;color:darkgreen&amp;quot;&amp;gt;zoffset&amp;lt;/code&amp;gt;: Offset from the lowest tile corner (with foundation added) to the start of the bounding box (Z).&lt;br /&gt;
** &amp;lt;code style=&amp;quot;color:darkgreen&amp;quot;&amp;gt;xextent&amp;lt;/code&amp;gt;: Size of the bounding box, in the X-direction. Must be a compile-time constant.&lt;br /&gt;
** &amp;lt;code style=&amp;quot;color:darkgreen&amp;quot;&amp;gt;yextent&amp;lt;/code&amp;gt;: Size of the bounding box, in the Y-direction. Must be a compile-time constant.&lt;br /&gt;
** &amp;lt;code style=&amp;quot;color:darkgreen&amp;quot;&amp;gt;zextent&amp;lt;/code&amp;gt;: Size of the bounding box, in the Z-direction. Must be a compile-time constant.  Default values are 0, 0, 0, 16, 16, 16, respectively. In NewGRF developer mode in OpenTTD, it&#039;s possible to view the bounding boxes of all sprites by pressing Ctrl+B.&lt;br /&gt;
* &amp;lt;code style=&amp;quot;color:darkgreen&amp;quot;&amp;gt;childsprite&amp;lt;/code&amp;gt;: Child sprites may be positioned relative to their &#039;parent&#039; sprite that defines the bounding box. &amp;lt;code style=&amp;quot;color:darkgreen&amp;quot;&amp;gt;xoffset&amp;lt;/code&amp;gt; and &amp;lt;code style=&amp;quot;color:darkgreen&amp;quot;&amp;gt;yoffset&amp;lt;/code&amp;gt; may be set to specify an offset in pixels between the origin of the parent and child sprite. When the parent sprite is the ground sprite, TTDPatch does not support offsets other than 0,0. Note that all child sprites should fit inside the bounding box of the parent sprite to avoid visual glitches.&lt;br /&gt;
&lt;br /&gt;
===Example (advanced) Spritelayout===&lt;br /&gt;
&lt;br /&gt;
OpenTTD 1.2 (r22723) allows for nice shorthands in defining multiple views, e.g. for different slopes: Spritelayout can have parameters and may use variables and temporary storage inside of a layout. A common usage for such parametrized spritelayout is taking care of the tile slope and ground type as illustrated in this example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:blue&amp;quot;&amp;gt;&lt;br /&gt;
 spritelayout company_land_layout {&lt;br /&gt;
 	ground {&lt;br /&gt;
 		// normal ground sprite - always draw&lt;br /&gt;
 		sprite: LOAD_TEMP(0) + LOAD_TEMP(1);&lt;br /&gt;
 	}&lt;br /&gt;
 	childsprite {&lt;br /&gt;
 		// company-coloured border - always draw&lt;br /&gt;
 		sprite:        cc_frame(LOAD_TEMP(0));&lt;br /&gt;
 		always_draw:   1;&lt;br /&gt;
 		recolour_mode: RECOLOUR_REMAP;&lt;br /&gt;
 		palette:       PALETTE_USE_DEFAULT;&lt;br /&gt;
 	}&lt;br /&gt;
 	childsprite {&lt;br /&gt;
 		// again the normal ground sprite. Thus in non-transparent view&lt;br /&gt;
 		// only the normal ground sprite is shown. In transparent view&lt;br /&gt;
 		// this acts as sprite which darkens the other two sprites via&lt;br /&gt;
 		// a translation to transparency.&lt;br /&gt;
 		sprite: LOAD_TEMP(0) + LOAD_TEMP(1);&lt;br /&gt;
 	}&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 // A pseudo-switch which sets the temporary parameters for the sprite layout, storing the sprite number&lt;br /&gt;
 // which belongs to the terrain type and the corresponding offset due to the tile slope&lt;br /&gt;
 switch (FEAT_OBJECTS, SELF, company_land_terrain_switch, [&lt;br /&gt;
 			// We store the offset into the spriteset due to the tile slope into the 1st temporary variable&lt;br /&gt;
 			STORE_TEMP(slope_to_sprite_offset(tile_slope), 0),&lt;br /&gt;
 &lt;br /&gt;
 			// We store the offset to the flat groundsprite we use into the 2nd temporary variable&lt;br /&gt;
 			STORE_TEMP(GROUNDSPRITE_NORMAL, 1),&lt;br /&gt;
 			STORE_TEMP(terrain_type == TILETYPE_DESERT      ? GROUNDSPRITE_DESERT : LOAD_TEMP(1), 1),&lt;br /&gt;
 			STORE_TEMP(terrain_type == TILETYPE_SNOW        ? GROUNDSPRITE_SNOW   : LOAD_TEMP(1), 1),&lt;br /&gt;
 &lt;br /&gt;
 			1&lt;br /&gt;
 			]) {&lt;br /&gt;
 	company_land_layout;&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Emperor Jake</name></author>
	</entry>
	<entry>
		<id>https://newgrf-specs.tt-wiki.net/index.php?title=NML:Recolour_sprites&amp;diff=2646</id>
		<title>NML:Recolour sprites</title>
		<link rel="alternate" type="text/html" href="https://newgrf-specs.tt-wiki.net/index.php?title=NML:Recolour_sprites&amp;diff=2646"/>
		<updated>2011-09-11T08:56:32Z</updated>

		<summary type="html">&lt;p&gt;Emperor Jake: Made this page more useful&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{NMLNavBlocksyntax}}&lt;br /&gt;
&lt;br /&gt;
Recolour sprites are special sprites that are used to recolour other sprites, for example to apply company colours. It&#039;s basically a remapping of the colour table.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;color:blue&amp;quot;&amp;gt;&lt;br /&gt;
 recolour_sprite {&lt;br /&gt;
 	0xC6: 0x28;&lt;br /&gt;
 	0xC7: 0xF5;&lt;br /&gt;
 	0xC8..0xCD: 0x0A..0x0F;&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above example will remap colour 0xC6 as 0x28, 0xC7 as 0xF5 and the range 0xC8 to 0xCD to the colours 0x0A..0x0F. This is one of the company colour recolour sprites defined in the baseset. Please note that in NML every recolour sprite will use the DOS palette. If your actual graphics files use the windows palette, nmlc will silently convert the recolour sprite to the windows palette before writing it to the output file.&lt;br /&gt;
&lt;br /&gt;
With the following table you can find out the colour indices in the DOS palette (left). &lt;br /&gt;
&lt;br /&gt;
[[File:TTD_Palettes.png]]&lt;/div&gt;</summary>
		<author><name>Emperor Jake</name></author>
	</entry>
</feed>