Which numbers do what?

Discuss, get help with, or post new graphics for TTDPatch and OpenTTD, using the NewGRF system, here. Graphics for plain TTD also acceptable here.

Moderator: Graphics Moderators

Post Reply
User avatar
Hector-Lavoe
Engineer
Engineer
Posts: 15
Joined: 13 Jan 2014 21:15
Skype: the-hector-lavoe
Location: Yorkshire

Which numbers do what?

Post by Hector-Lavoe »

Hi so I'm messing around with some tools and have somehow managed to edit a .grf, rename some stuff and even edit the textues. I have looked at the wiki and I'm finding it hard to understand what numbers do what here, I want to know how to change the positioning of the sprites and also stats of the busses, you know, speed, capacity etc. This is what I am working with, I used the .grf Bob's British Busses as a base for my testing.

0 * 4 35 03 00 00
1 * 27 08 06 "HRES" 01 00 "H Readmans European Set" 00 00
2 * 21 04 01 1F 01 00 "Bristol RE" 00
3 * 36 00 01 0F 01 00 00 54 33 03 32 04 32 06 0F 07 0A 08 80 09 63 0F 48 10 00 11 63 12 1A 13 0B 14 20
19 04 1C 02
4 * 6 01 01 01 FF 08 00
5 sprites/hres00.png 8bpp 98 8 8 20 -3 -12 normal
6 sprites/hres00.png 8bpp 114 8 16 19 -12 -9 normal
7 sprites/hres00.png 8bpp 146 8 20 16 -6 -10 normal
8 sprites/hres00.png 8bpp 178 8 16 19 -3 -10 normal
9 sprites/hres00.png 8bpp 210 8 8 20 -3 -12 normal
10 sprites/hres00.png 8bpp 226 8 16 19 -12 -8 normal
11 sprites/hres00.png 8bpp 258 8 20 16 -5 -9 normal
12 sprites/hres00.png 8bpp 290 8 16 19 -3 -9 normal
13 * 9 02 01 01 01 01 00 00 00 00
14 * 6 01 01 01 FF 01 00
15 sprites/hres00.png 8bpp 354 8 20 16 -10 -10 normal
16 * 9 02 01 11 01 01 00 00 00 00
17 * 7 00 01 01 01 00 0E FF
18 * 10 03 01 01 00 01 FF 11 00 01 00
19 * 29 04 01 1F 01 01 "Bristol VR" 00
20 * 36 00 01 0F 01 01 00 E2 3B 03 32 04 14 06 0F 07 0A 08 A0 09 63 0F 39 10 00 11 63 12 1A 13 0B 14 20
19 04 1C 02
21 * 6 01 01 01 FF 08 00
22 sprites/hres00.png 8bpp 482 8 8 20 -3 -12 normal
23 sprites/hres00.png 8bpp 498 8 16 19 -12 -9 normal
24 sprites/hres00.png 8bpp 530 8 20 16 -6 -10 normal
25 sprites/hres00.png 8bpp 562 8 16 19 -3 -10 normal
26 sprites/hres00.png 8bpp 594 8 8 20 -3 -12 normal
27 sprites/hres00.png 8bpp 610 8 16 19 -12 -8 normal
28 sprites/hres00.png 8bpp 642 8 20 16 -5 -9 normal
29 sprites/hres00.png 8bpp 674 8 16 19 -3 -9 normal
30 * 9 02 01 01 01 01 00 00 00 00
31 * 6 01 01 01 FF 01 00
32 sprites/hres00.png 8bpp 738 8 20 16 -10 -10 normal
33 * 9 02 01 11 01 01 00 00 00 00
34 * 7 00 01 01 01 01 0E FF
35 * 10 03 01 01 01 01 FF 11 00 01 00

As you can see I have figures some out.
Hej allesammen.
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4763
Joined: 09 Sep 2007 05:03
Location: home

Re: Which numbers do what?

Post by Alberth »

The usual approach is to look for the source code of a grf, find the number there, and then rebuild the grf.

To avoid getting very confused, always change the GRF ID and preferably the displayed text as well, so you can check which version is in each file. The license of a GRF tells you your rights and duties in the formal sense, a PM to the original author is generally nice too.
Being a retired OpenTTD developer does not mean I know what I am doing.
User avatar
wallyweb
Tycoon
Tycoon
Posts: 6102
Joined: 27 Nov 2004 15:05
Location: Canada

Re: Which numbers do what?

Post by wallyweb »

Hector-Lavoe wrote:Hi so I'm messing around with some tools and have somehow managed to edit a .grf, rename some stuff and even edit the textues. I have looked at the wiki and I'm finding it hard to understand what numbers do what here, I want to know how to change the positioning of the sprites and also stats of the busses, you know, speed, capacity etc. This is what I am working with, I used the .grf Bob's British Busses as a base for my testing.
Before we get into this, we should know what you have to work with. The code described in the NewGRF Specifications wiki is called NFO. It is written in Assembly language using hexadecimal notation.If you are familiar with the terms "assembly language" and "hexadecimal notation", then we can move on to the next level of assistance.
michael blunck
Tycoon
Tycoon
Posts: 5948
Joined: 27 Apr 2005 07:09
Contact:

Re: Which numbers do what?

Post by michael blunck »

Hector-Lavoe wrote: I have looked at the wiki and I'm finding it hard to understand what numbers do what here, I want to know how to change the positioning of the sprites and also stats of the busses, you know, speed, capacity etc.
In general, the nfo docs should be comprehensible, at least with regards to your questions (sprite positioning and vehicle stats).

Sprite positioning happens here:

Code: Select all

5 sprites/hres00.png 8bpp 98 8 8 20 -3 -12 normal
Last two numbers (those negative ones) are used to position the sprite in x (-3) and y (-12). You should use the sprite aligner tool in the game to get it positioned correctly.

Vehicle stats are defined in your "action 0":

Code: Select all

3 * 36 00 01 0F 01 00 00 54 33 03 32 04 32 06 0F 07 0A 08 80 09 63 0F 48 10 00 11 63 12 1A 13 0B 14 20
19 04 1C 02
Structured a bit like this:

Code: Select all

3 * 36 00 01 0F 01 00 // define 15 properties for roadveh-ID = 00
00 54 33 // date of introduction = 1-1-1920 + 13140 days -> ~1956 (plus random amount)
03 32 // vehicle life in years = 50
04 32 // model life in years = 50
06 0F // climate availability = all climates
07 0A // load amount = 10 units
08 80 // speed in mph*3.2 = 128
09 63 // running cost factor = 99
0F 48 // capacity = 72
10 00 // cargo type = passengers
11 63 // cost factor = 99
12 1A // sound effect = 26 (bus horn)
13 0B // power in 10 hp = 11 -> 110 hp
14 20 // weight in 1/4 tons = 32 -> 8 tons
19 04 // air drag coefficient = 4
1C 02 // vehicle flags = use two company colors
it should be more understandable.

HTH
Michael
Image
connieconf
Engineer
Engineer
Posts: 1
Joined: 05 Jul 2017 21:50

Re: Which numbers do what?

Post by connieconf »

wallyweb wrote:
Hector-Lavoe wrote:Hi so I'm messing around with some tools and have somehow managed to edit a .grf, rename some stuff and even edit the textues. I have looked at the wiki and I'm finding it hard to understand what numbers do what here, I want to know how to change the positioning of the sprites and also stats of the busses, you know, speed, capacity etc. This is what I am working with, I used the .grf Bob's British Busses as a base for my testing.
Before we get into this, we should know what you have to work with. The code described in the NewGRF Specifications wiki is called NFO. It is written in Assembly language using hexadecimal notation.If you are familiar with the terms "assembly language" and "hexadecimal notation", then we can move on to the next level of assistance.
Hello, I am not familiar with assembly language, but I have heard of hexadecimal notation, and after some searching, I think I understand it. Is it possible to help me?
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4763
Joined: 09 Sep 2007 05:03
Location: home

Re: Which numbers do what?

Post by Alberth »

I think I understand it. Is it possible to help me?
Try asking a question about NFO or hexadecimal numbers
Being a retired OpenTTD developer does not mean I know what I am doing.
User avatar
Bob_Mackenzie
Chairman
Chairman
Posts: 823
Joined: 25 Mar 2010 13:36

Re: Which numbers do what?

Post by Bob_Mackenzie »

I wrote this 5 years ago using GRFmaker (if that still exists) - anyway I have attached the GRF code if it helps?
Attachments
BBBw.GRF
(94.03 KiB) Downloaded 63 times
Post Reply

Return to “Graphics Development”

Who is online

Users browsing this forum: 3iff, Google Adsense [Bot] and 23 guests