<?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=Bennythen00b</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=Bennythen00b"/>
		<link rel="alternate" type="text/html" href="http://pikka.users.tt-forums.net/wiki/index.php?title=Special:Contributions/Bennythen00b"/>
		<updated>2026-04-16T05:33:59Z</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>2009-04-12T06:12:22Z</updated>
		
		<summary type="html">&lt;p&gt;Bennythen00b: I added a better description of how to decompile a .grf file.&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. (Open a new document in Notepad and copy paste this line into it: '''grfcodec -d trg1r.grf -p2'''. Save the document as *Whatever you want*.bat. The name isn't important, but remember the &amp;quot;.bat&amp;quot; Now double click the document you just made.).&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>Bennythen00b</name></author>	</entry>

	</feed>