NFO Foundations

From TTWiki
Jump to navigationJump to search

The fundamental files that control your new graphics are the .nfo and the .pcx file. The .pcx file contains the actual drawings, and the .nfo file the instructions what to do with them.

To get started

To draw a new train, you first need a base from which to start working. Since you probably aren't familiar with all the intricacies yet, it's best to copy one of TTD's vehicles and then draw your own graphics. Basically, you follow these steps:

  1. Extract TTD's trg1r.grf (or trg1.grf for the DOS version or ogfx1_base.grf when using OpenGFX)
  2. Look through trg1r.pcx (TTD) or ogfx1_base.grf (OpenGFX) for a vehicle similar to the one you're going to make
  3. Copy the corresponding data from the .nfo file into your own file
  4. Encode and decode again your own file

Now to look at these steps in a bit more details. If you de-compiled OpenGFX's file, use the appropriate filenames instead in the subsequent text.

1. Extract TTD's trg1r.grf / OpenGFX's ogfx1_base.grf

First of all, you need to download grfcodec and unzip it into your TTD folder. Then you open a DOS command window. If you are using Windows 2000 or Windows XP you can open a DOS command window by typing cmd in the execute option in the start menu. When you see the command window run grfcodec like this:

cd C:\TTD
grfcodec -d trg1r.grf

Obviously, change C:\TTD to point to your TTD directory. If you're using the DOS version of TTD, use trg1.grf instead of trg1r.grf.

This will make a new folder called sprites, and will put trg1r.pcx and trg1r.nfo in it.

You can also use GRFWizard with grfcodec. It will add a user interface to grfcodec. Just follow the options in the wizard to decode a .grf file, it will also add a sprites folder and generate the .nfo and .pcx files.

2. Look through trg1r.pcx / ogfx1_base.pcx

You now open trg1r.pcx from the sprites folder. There are many graphics programs to view and edit .pcx files.

Look for a vehicle that is similar to the one you want to make. For example, if you want to make a train engine with 8 views, you can use the SH 125. So you go looking for its graphics in trg1r.pcx. For the SH 125, you'll find them at numbers 2941 to 2948 (those are the little numbers above the images). Write down those numbers. For example, this is what it might look like:


3. Copy the corresponding data from the .nfo file into your own file

So now that we know what sprites to base the graphics on, we need to copy those into a new file. Open the trg1r.nfo file in a text editor, for example Notepad. Also, open another .nfo file for your own graphics, say for example "mytrain.nfo".

Now, copy and paste the first three lines beginning with "//" to your mytrain.nfo file. While they may look like comments, they are actually important.

In the next step, find the lines beginning with the sprite numbers you're written down in the previous step. In the example above, we'd find the lines with numbers 2941 to 2948. Copy those eight (or however many) lines to your mytrain.nfo file as well.

4. Encode and decode again your own file

Now we want to make our own .grf file. Unfortunately, grfcodec is a bit picky and will complain loudly if your lines are not numbered properly. To make grfcodec shut up, you have to go through your .nfo file, and change the numbers at the beginning of the lines to go from 0 to 7 (nforenum can do that for you).

At this point, your .nfo file should look something like this:

// Automatically generated by GRFCODEC. Do not modify!
// (Info version 6)
// Format: spritenum pcxfile xpos ypos compression ysize xsize xrel yrel
 0 C:\TTD\SPRITES\trg1.pcx 530 10664 01 18 8 -3 -10
 1 C:\TTD\SPRITES\trg1.pcx 546 10664 09 15 20 -14 -6
 2 C:\TTD\SPRITES\trg1.pcx 578 10664 01 12 28 -14 -6
 3 C:\TTD\SPRITES\trg1.pcx 626 10664 09 16 20 -4 -8
 4 C:\TTD\SPRITES\trg1.pcx 658 10664 01 18 8 -3 -10
 5 C:\TTD\SPRITES\trg1.pcx 674 10664 09 16 20 -14 -7
 6 C:\TTD\SPRITES\trg1.pcx 706 10664 01 12 28 -14 -6
 7 C:\TTD\SPRITES\trg1.pcx 754 10664 09 15 20 -4 -7

Now run grfcodec again, first to encode and then to decode your file. This creates mytrain.pcx and changes your .nfo to refer to that copy of the sprites:

grfcodec -e mytrain.grf
grfcodec -d mytrain.grf -p 2

Leave off the "-p 2" if you're working with the DOS graphics instead of the Windows graphics.

Good job!

Now you have your own mytrain.grf file with the corresponding mytrain.nfo and mytrain.pcx files. We'll use this as a base for making these graphics TTDPatch compatible.

Note that you can't yet take your mytrain.grf file and put it in TTDPatch's newgrfw.cfg file yet, because it doesn't have the necessary information to allow TTDPatch to know what to do with it.

However, you can go ahead and edit the graphics in mytrain.pcx to your liking and make them look like your train.

Once you're ready, go on to the next section.