<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://pikka.users.tt-forums.net/wiki/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://pikka.users.tt-forums.net/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=130.102.0.176</id>
		<title>PikkaWiki - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="http://pikka.users.tt-forums.net/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=130.102.0.176"/>
		<link rel="alternate" type="text/html" href="http://pikka.users.tt-forums.net/wiki/index.php?title=Special:Contributions/130.102.0.176"/>
		<updated>2026-06-02T02:26:46Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.19.24</generator>

	<entry>
		<id>http://pikka.users.tt-forums.net/wiki/index.php?title=GRF_coding</id>
		<title>GRF coding</title>
		<link rel="alternate" type="text/html" href="http://pikka.users.tt-forums.net/wiki/index.php?title=GRF_coding"/>
				<updated>2007-05-28T05:10:53Z</updated>
		
		<summary type="html">&lt;p&gt;130.102.0.176: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Writing NFO for smarties.  Because you're not as dumb as you think you are.&lt;br /&gt;
&lt;br /&gt;
Okay, welcome to my basic tutorial for coding grf sets.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
==What you will need==&lt;br /&gt;
*A recent (ie, nightly) build of TTDPatch or, if you must, OpenTTD.&lt;br /&gt;
*[http://www.ttdpatch.net/grfcodec/ GRFCodec]&lt;br /&gt;
*[http://users.tt-forums.net/dalestan/nforenum/ NFORenum]&lt;br /&gt;
*A coder's text editor (preferably something more advanced than notepad, since you'll want to be doing some formatting to make your NFO readable.  NOT a rich text editor like wordpad).&lt;br /&gt;
*A graphics program of your choice that can manipulate .pcx and/or .png files.&lt;br /&gt;
*[http://wiki.ttdpatch.net/tiki-index.php?page=NewGraphicsSpecs The newgrf spec].&lt;br /&gt;
*A computer running Windows, and/or the ability to translate what I say in Windows-speak into the language of your operating system.  Creating and testing grfs on non-Windows systems may have additional challenges.&lt;br /&gt;
&lt;br /&gt;
==Getting set up==&lt;br /&gt;
*Install grfcodec into a directory under/near your TTD directory.&lt;br /&gt;
*Copy trg1r.grf to this directory (and, if you like, the other default grfs) and decompile them with grfcodec. ('''grfcodec -d trg1r.grf -p2''').&lt;br /&gt;
**Resist the temptation to decode any other grf and have a look at what comes out.  It will not be useful to you at this point.  Believe me.&lt;br /&gt;
*Install NFOrenum into &amp;lt;grfcodec directory&amp;gt;/SPRITES, which should have been created when you decoded trg1r.grf.&lt;br /&gt;
&lt;br /&gt;
And you're ready to go!&lt;br /&gt;
&lt;br /&gt;
==Getting started==&lt;br /&gt;
Every grf file comes from an NFO file; the NFO file is, in essence, the source code of the grf.  NFO files contain series of hex digits; however; don't let this put you off, as you can use comments, formatting, escape codes and quoted strings to make your NFO more human-readable.&lt;br /&gt;
&lt;br /&gt;
Let's begin your first NFO file.  Open your text editor and create a new file.  Save it in &amp;lt;grfcodec directory&amp;gt;/SPRITES as '''&amp;lt;filename&amp;gt;.nfo'''&lt;br /&gt;
&lt;br /&gt;
There are three things every NFO file must contain, other than the sprite lines that actually have data for vehicles or other features.  They are the header, sprite 0 and the action 8.&lt;br /&gt;
&lt;br /&gt;
===The header===&lt;br /&gt;
&lt;br /&gt;
The header tells grfcodec how to encode the NFO.  It looks like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// Automatically generated by GRFCODEC. Do not modify!&lt;br /&gt;
// (Info version 7)&lt;br /&gt;
// Format: spritenum pcxfile xpos ypos compression ysize xsize xrel yrel&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can copy and paste that, or alternatively you can let NFOrenum put the header in the first time you renum your file.&lt;br /&gt;
&lt;br /&gt;
===Sprite 0===&lt;br /&gt;
&lt;br /&gt;
This sprite follows after the header, and tells grfcodec the total sprite count.  NFOrenum will insert this sprite.&lt;br /&gt;
&lt;br /&gt;
===The action 8===&lt;br /&gt;
&lt;br /&gt;
''Read [http://wiki.ttdpatch.net/tiki-index.php?page=Action8 the wiki page]''&lt;br /&gt;
&lt;br /&gt;
The action 8 identifies your grf file.  It's like the title page of a book.&lt;br /&gt;
&lt;br /&gt;
An action 8 might look like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
1 * 1	 08 07 &amp;quot;JB01&amp;quot; &amp;quot;My first Newgrf&amp;quot; 00 &amp;quot;By Joe Bloggs&amp;quot; 00&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;quot;JB01&amp;quot; is the grfid.  It's important that every grf has a different ID: most grf authors use their intials for the first two characters.&lt;br /&gt;
&lt;br /&gt;
==Anatomy of an NFO==&lt;br /&gt;
&lt;br /&gt;
Asides from the header, sprite 0 and action 8, you need some sprites and psuedosprites that actually do something. &lt;br /&gt;
&lt;br /&gt;
*[[A vehicle (NFO)]]&lt;br /&gt;
*[[Example NFO files]]&lt;br /&gt;
&lt;br /&gt;
==Compiling the grf==&lt;br /&gt;
&lt;br /&gt;
Hopefully you can work out how to do this yourself.  However, here's a few tips:&lt;br /&gt;
&lt;br /&gt;
*Always renum your nfo file before compiling, and check for errors (search the file for '''!!''').  I use a batch file to renum and compile my NFO in one step.&lt;br /&gt;
*Don't worry about sprite numbers and lengths: NFOrenum will fix them up.&lt;br /&gt;
*Don't decompile your own grf files!  You'll wreck your NFO, stripping out all formatting and comments.&lt;br /&gt;
[[category:NFO]]&lt;/div&gt;</summary>
		<author><name>130.102.0.176</name></author>	</entry>

	<entry>
		<id>http://pikka.users.tt-forums.net/wiki/index.php?title=Sprite_templates</id>
		<title>Sprite templates</title>
		<link rel="alternate" type="text/html" href="http://pikka.users.tt-forums.net/wiki/index.php?title=Sprite_templates"/>
				<updated>2007-05-28T05:10:38Z</updated>
		
		<summary type="html">&lt;p&gt;130.102.0.176: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
==3==&lt;br /&gt;
[[image:333.png]]&lt;br /&gt;
===forwards===&lt;br /&gt;
 1 SPRITES\x.pcx 0 0 01 18 8 -3 -18&lt;br /&gt;
 2 SPRITES\x.pcx 16 0 09 16 20 -9 -11&lt;br /&gt;
 3 SPRITES\x.pcx 48 0 01 12 28 -4 -8&lt;br /&gt;
 4 SPRITES\x.pcx 96 0 09 16 20 1 -6&lt;br /&gt;
 5 SPRITES\x.pcx 128 0 01 18 8 -3 -8&lt;br /&gt;
 6 SPRITES\x.pcx 144 0 09 16 20 -19 -6&lt;br /&gt;
 7 SPRITES\x.pcx 176 0 01 12 28 -24 -8&lt;br /&gt;
 8 SPRITES\x.pcx 224 0 09 16 20 -9 -11&lt;br /&gt;
&lt;br /&gt;
==4==&lt;br /&gt;
[[image:444.png]]&lt;br /&gt;
===forwards===&lt;br /&gt;
 1 SPRITES\x.pcx 0 0 01 18 8 -3 -15&lt;br /&gt;
 2 SPRITES\x.pcx 16 0 09 16 20 -9 -11&lt;br /&gt;
 3 SPRITES\x.pcx 48 0 01 12 28 -6 -8&lt;br /&gt;
 4 SPRITES\x.pcx 96 0 09 16 20 -1 -7&lt;br /&gt;
 5 SPRITES\x.pcx 128 0 01 18 8 -3 -9&lt;br /&gt;
 6 SPRITES\x.pcx 144 0 09 16 20 -17 -7&lt;br /&gt;
 7 SPRITES\x.pcx 176 0 01 12 28 -22 -8&lt;br /&gt;
 8 SPRITES\x.pcx 224 0 09 16 20 -9 -11&lt;br /&gt;
&lt;br /&gt;
==5==&lt;br /&gt;
[[image:555.png]]&lt;br /&gt;
===forwards===&lt;br /&gt;
 1 SPRITES\x.pcx 0 0 01 18 8 -3 -13&lt;br /&gt;
 2 SPRITES\x.pcx 16 0 09 16 20 -11 -10&lt;br /&gt;
 3 SPRITES\x.pcx 48 0 01 12 28 -8 -8&lt;br /&gt;
 4 SPRITES\x.pcx 96 0 09 16 20 -1 -7&lt;br /&gt;
 5 SPRITES\x.pcx 128 0 01 18 8 -3 -7&lt;br /&gt;
 6 SPRITES\x.pcx 144 0 09 16 20 -17 -7&lt;br /&gt;
 7 SPRITES\x.pcx 176 0 01 12 28 -20 -8&lt;br /&gt;
 8 SPRITES\x.pcx 224 0 09 16 20 -7 -10&lt;br /&gt;
&lt;br /&gt;
==6==&lt;br /&gt;
[[image:666.png]]&lt;br /&gt;
===forwards===&lt;br /&gt;
 1 SPRITES\x.pcx 0 0 01 20 8 -3 -12&lt;br /&gt;
 2 SPRITES\x.pcx 16 0 09 16 20 -11 -10&lt;br /&gt;
 3 SPRITES\x.pcx 48 0 01 12 28 -10 -8&lt;br /&gt;
 4 SPRITES\x.pcx 96 0 09 16 20 -3 -8&lt;br /&gt;
 5 SPRITES\x.pcx 128 0 01 20 8 -3 -8&lt;br /&gt;
 6 SPRITES\x.pcx 144 0 09 16 20 -15 -8&lt;br /&gt;
 7 SPRITES\x.pcx 176 0 01 12 28 -18 -8&lt;br /&gt;
 8 SPRITES\x.pcx 224 0 09 16 20 -7 -10&lt;br /&gt;
===backwards===&lt;br /&gt;
 1 SPRITES\x.pcx 0 0 01 20 8 -3 -8&lt;br /&gt;
 2 SPRITES\x.pcx 16 0 09 16 20 -15 -8&lt;br /&gt;
 3 SPRITES\x.pcx 48 0 01 12 28 -18 -8&lt;br /&gt;
 4 SPRITES\x.pcx 96 0 09 16 20 -7 -10&lt;br /&gt;
 5 SPRITES\x.pcx 128 0 01 20 8 -3 -12&lt;br /&gt;
 6 SPRITES\x.pcx 144 0 09 16 20 -11 -10&lt;br /&gt;
 7 SPRITES\x.pcx 176 0 01 12 28 -10 -8&lt;br /&gt;
 8 SPRITES\x.pcx 224 0 09 16 20 -3 -8&lt;br /&gt;
===reversed at front===&lt;br /&gt;
 1 SPRITES\x.pcx 128 0 01 20 8 -3 -12&lt;br /&gt;
 2 SPRITES\x.pcx 144 0 09 16 20 -11 -10&lt;br /&gt;
 3 SPRITES\x.pcx 176 0 01 12 28 -10 -8&lt;br /&gt;
 4 SPRITES\x.pcx 224 0 09 16 20 -3 -8&lt;br /&gt;
 5 SPRITES\x.pcx 0 0 01 20 8 -3 -8&lt;br /&gt;
 6 SPRITES\x.pcx 16 0 09 16 20 -15 -8&lt;br /&gt;
 7 SPRITES\x.pcx 48 0 01 12 28 -18 -8&lt;br /&gt;
 8 SPRITES\x.pcx 96 0 09 16 20 -7 -10&lt;br /&gt;
&lt;br /&gt;
==7==&lt;br /&gt;
[[image:777.png]]&lt;br /&gt;
&lt;br /&gt;
==8==&lt;br /&gt;
[[image:888.png]]&lt;br /&gt;
&lt;br /&gt;
==9==&lt;br /&gt;
[[image:999.png]]&lt;br /&gt;
[[category:NFO]]&lt;/div&gt;</summary>
		<author><name>130.102.0.176</name></author>	</entry>

	<entry>
		<id>http://pikka.users.tt-forums.net/wiki/index.php?title=Category:NFO</id>
		<title>Category:NFO</title>
		<link rel="alternate" type="text/html" href="http://pikka.users.tt-forums.net/wiki/index.php?title=Category:NFO"/>
				<updated>2007-05-28T05:08:35Z</updated>
		
		<summary type="html">&lt;p&gt;130.102.0.176: New page: Zounds&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Zounds&lt;/div&gt;</summary>
		<author><name>130.102.0.176</name></author>	</entry>

	<entry>
		<id>http://pikka.users.tt-forums.net/wiki/index.php?title=A_vehicle_(NFO)</id>
		<title>A vehicle (NFO)</title>
		<link rel="alternate" type="text/html" href="http://pikka.users.tt-forums.net/wiki/index.php?title=A_vehicle_(NFO)"/>
				<updated>2007-05-28T05:08:10Z</updated>
		
		<summary type="html">&lt;p&gt;130.102.0.176: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is an explanation of how to code a vehicle.  You should have the [http://wiki.ttdpatch.net/tiki-index.php?page=NewGraphicsSpecs wiki] open while you read this, and refer to it.  I will gloss over a lot of things that are explained in detail there.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
==Basic layout==&lt;br /&gt;
The basic code structure for a vehicle in NFO is as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Real sprites (Action 1)&lt;br /&gt;
Action 2&lt;br /&gt;
VarAction 2s&lt;br /&gt;
Action 3&lt;br /&gt;
&lt;br /&gt;
Action 4&lt;br /&gt;
Action 0s&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*The real sprites are the graphics your vehicle will use.  See [http://wiki.ttdpatch.net/tiki-index.php?page=Action1 the wiki page].&lt;br /&gt;
&lt;br /&gt;
*The action 2 gives the graphics a label (a &amp;quot;cargoID&amp;quot;, although I prefer to think of it as an Action 2 ID).  See [http://wiki.ttdpatch.net/tiki-index.php?page=Action2Vehicles the wiki page].&lt;br /&gt;
&lt;br /&gt;
*The [[VarAction2]]s are decision-making code between the action 3 and the action 2 (nb: ''you read action 2 chains from the bottom up, starting with the action 3 and ending with a &amp;quot;real&amp;quot; action 2!'').  They can also be used to do all kinds of cool tricks with the use of callbacks.  Your first vehicle will probably not have any of these at all, but will simply have an action 3 pointing directly to a &amp;quot;real&amp;quot; action 2.&lt;br /&gt;
&lt;br /&gt;
*The action 3 is where you tell the vehicle what sprites to use.  See [http://wiki.ttdpatch.net/tiki-index.php?page=Action3 the wiki page].&lt;br /&gt;
&lt;br /&gt;
*The action 4 sets the name of the vehicle.  See [http://wiki.ttdpatch.net/tiki-index.php?page=Action4 the wiki page].&lt;br /&gt;
&lt;br /&gt;
*The action 0 sets the properties for the vehicle.   See [http://wiki.ttdpatch.net/tiki-index.php?page=Action0General the wiki page].&lt;br /&gt;
&lt;br /&gt;
==An example==&lt;br /&gt;
Here is an example of a simple train locomotive.  As you can see, it's quite heavily commented.  Don't be afraid to use a ''lot'' of comments to remind yourself what's where in your NFO.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;  &lt;br /&gt;
// My Locomotive (0C) -----------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
 1290 * 4	 01 00 01 08&lt;br /&gt;
 1604 SPRITES\myloco.pcx 0 0 01 24 8 -3 -12&lt;br /&gt;
 1605 SPRITES\myloco.pcx 16 0 09 17 22 -14 -9&lt;br /&gt;
 1606 SPRITES\myloco.pcx 48 0 01 12 32 -16 -8&lt;br /&gt;
 1607 SPRITES\myloco.pcx 96 0 09 17 22 -6 -9&lt;br /&gt;
 1608 SPRITES\myloco.pcx 128 0 01 24 8 -3 -12&lt;br /&gt;
 1609 SPRITES\myloco.pcx 144 0 09 17 22 -14 -9&lt;br /&gt;
 1610 SPRITES\myloco.pcx 176 0 01 12 32 -16 -8&lt;br /&gt;
 1611 SPRITES\myloco.pcx 224 0 09 17 22 -6 -9&lt;br /&gt;
&lt;br /&gt;
 1299 * 9	 02 00 AA 01 01 00 00 00 00&lt;br /&gt;
&lt;br /&gt;
 1303 * 10	 03 00 01 0C 00 AA&lt;br /&gt;
&lt;br /&gt;
 1304 * 23	 04 00 1F 01 0C &amp;quot;My Locomotive (Diesel)&amp;quot; 00&lt;br /&gt;
 1305 * 57	 00 00 17 01 0C&lt;br /&gt;
  12 FD&lt;br /&gt;
  00 \w1-1-1960    // introdate&lt;br /&gt;
  02 14            // reliability&lt;br /&gt;
  03 \b20          // vehicle life&lt;br /&gt;
  04 \b40          // class life&lt;br /&gt;
  0D 88            // running cost&lt;br /&gt;
  17 25            // purchase cost&lt;br /&gt;
  19 08            // engine type&lt;br /&gt;
  09 85 00         // speed&lt;br /&gt;
  16 \b98          // weight&lt;br /&gt;
  0B \w2000        // power&lt;br /&gt;
  1F 41            // Tractive effort&lt;br /&gt;
  1E 00            // callbacks&lt;br /&gt;
  27 02            // flags&lt;br /&gt;
  21 00            // shortened&lt;br /&gt;
  0E 30 4C 00 00   // run cost base&lt;br /&gt;
  05 00            // rail type&lt;br /&gt;
  06 04            // climate&lt;br /&gt;
  13 00            // doublehead&lt;br /&gt;
  14 00            // cargo&lt;br /&gt;
  15 00            // capacity&lt;br /&gt;
  08 00 // AI passenger&lt;br /&gt;
  18 20 // AI rank&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
[[category:NFO]]&lt;/div&gt;</summary>
		<author><name>130.102.0.176</name></author>	</entry>

	</feed>