Editing callbacks in existing grf

Discussions about the technical aspects of graphics development, including NewGRF tools and utilities.

Moderator: Graphics Moderators

MildaIV
Engineer
Engineer
Posts: 52
Joined: 11 Nov 2005 09:07
Location: Czech Republic
Contact:

Editing callbacks in existing grf

Post by MildaIV » 18 Sep 2015 18:32

I want to add new planes to existing grf - av8_Aviators_Aircraft_Set. After few days of reading ttd wiki I decided to just start with something more simple :) - edit one of existing planes. I succesfully changed all action0 properties that I want. But many of them are modified by callbacks(running cost, speed, ...). So I am trying to decode those callbacks using wiki. The only thing I was succesfull are two first bytes - its action 2 and its airplane :( Can anybody guide me how to decode those callbacks?

Code: Select all

 6768 * 9	 02 03 00 01 01 00 00 00 00
 6769 * 9	 02 03 01 01 01 00 00 00 00
 6770 * 9	 02 03 03 01 01 01 00 01 00
 6771 * 9	 02 03 05 01 01 02 00 02 00
 6772 * 4	 01 03 01 01
 6773 sprites/pb_av8w.png  8bpp  658 17048   46   20  -23   -8 normal chunked
 6774 * 9	 02 03 0F 01 01 00 00 00 00
 6775 * 14	 02 03 0F 81 10 00 FF 01 01 00 21 21 0F 00
 6776 * 14	 02 03 0F 81 0C 00 FF 01 A7 80 23 23 0F 00
 6777 * 14	 02 03 25 81 44 08 FF 01 01 00 38 FF 05 00
 6778 * 14	 02 03 03 81 9E 00 FF 01 00 00 A0 FF 03 00
 6779 * 26	 02 03 20 81 E2 00 FF 04 03 00 0F 0F 00 00 12 12 25 00 15 15 01 00 16 16 01 00
 6780 * 26	 02 03 09 81 E2 00 FF 04 32 80 0D 0F C8 80 12 12 32 80 10 14 19 80 15 16 C8 80
 6781 * 14	 02 03 09 81 10 00 FF 01 09 00 0C 0C 20 00
 6782 * 18	 02 03 08 81 10 00 FF 02 4F 80 05 05 4E 80 01 01 20 00
 6783 * 18	 02 03 08 81 0C 00 FF 02 08 00 33 33 09 00 36 36 20 00
 6784 * 11	 02 03 21 81 7E 9A 00 FF 00 00 80
 6785 * 18	 02 03 21 81 1A 20 A3 \2sto 1A 00 01 01 21 00 00 00 21 00
 6786 * 14	 02 03 21 81 10 00 FF 01 21 00 0E 0E 08 00
 6787 * 14	 02 03 08 81 0C 00 FF 01 21 00 36 36 08 00
 6788 * 26	 02 03 20 81 F2 00 FF 04 AB 80 00 00 AC 80 01 01 AD 80 02 02 AE 80 03 03 00 84
 6789 * 16	 02 03 E3 85 7F 0A "@   " 00 01 00 00 00 80
 6790 * 17	 02 03 84 85 7F 0A 20 FF FF \2+ 1C 00 FF FF 00 00 80
 6791 * 18	 02 03 84 81 43 3C 0F \2+ 1C 00 FF 01 84 00 00 00 84 00
 6792 * 14	 02 03 E1 81 43 14 F0 01 84 00 00 00 84 00
 6793 * 22	 02 03 22 81 F2 00 03 03 E1 00 01 01 E2 00 02 02 E3 00 03 03 08 00
 6794 * 18	 02 03 08 81 0C 00 FF 02 20 00 19 19 22 00 2D 2D 08 00
 6795 * 14	 02 03 19 81 0C 00 FF 01 4B 80 15 15 08 00
 6796 * 13	 03 03 01 4E 02 FF 0F 00 00 08 00 19 00

Supercheese
Tycoon
Tycoon
Posts: 1660
Joined: 16 Dec 2007 22:24
Location: Idaho, USA

Re: Editing callbacks in existing grf

Post by Supercheese » 18 Sep 2015 20:33

Just create an NML override grf, much like this NARS override grf (source has some nice instructional comments). It'll be vastly easier than trying to mess around with NFO.

Helpful wiki documentation: http://newgrf-specs.tt-wiki.net/wiki/NM ... er_NewGRFs

Also if needed: http://www.tt-wiki.net/wiki/NMLTutorial
Eyecandy Road Vehicles | Fake Subways | Supercheese's NewObjects

"Fashions and cultures change, but steam trains shall always be majestic."
-Professor Hershel Layton

User avatar
Sylf
President
President
Posts: 958
Joined: 23 Nov 2010 21:25
Location: ::1

Re: Editing callbacks in existing grf

Post by Sylf » 18 Sep 2015 21:05

Those override grf actually modifies the properties of the existing vehicles in the given grf.
If you're just adding new vehicles, do you need to do anything with the existing grf, other than perhaps check if the other grf is loaded or not, and perhaps read the grf parameters given to the original grf?

User avatar
FooBar
Tycoon
Tycoon
Posts: 6559
Joined: 21 May 2007 11:47
Location: The Netherlands
Contact:

Re: Editing callbacks in existing grf

Post by FooBar » 18 Sep 2015 21:23

When only adding vehicles you can keep it fully independent. Makes life much more easier.

MildaIV
Engineer
Engineer
Posts: 52
Joined: 11 Nov 2005 09:07
Location: Czech Republic
Contact:

Re: Editing callbacks in existing grf

Post by MildaIV » 19 Sep 2015 07:01

Supercheese wrote:Just create an NML override grf, much like this NARS override grf (source has some nice instructional comments). It'll be vastly easier than trying to mess around with NFO.
That is interesting option. Problem is that I dont know what callbacks I should change.

MildaIV
Engineer
Engineer
Posts: 52
Joined: 11 Nov 2005 09:07
Location: Czech Republic
Contact:

Re: Editing callbacks in existing grf

Post by MildaIV » 19 Sep 2015 07:05

FooBar wrote:When only adding vehicles you can keep it fully independent. Makes life much more easier.
Thats final goal. But before that i want to understand what av8_Aviators_Aircraft_Set is doing at all. It does lot of things I dont even know about.

User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5391
Joined: 13 Sep 2004 13:21
Location: The Moon
Contact:

Re: Editing callbacks in existing grf

Post by PikkaBird » 19 Sep 2015 07:32

It's not that well commented, unfortunately. What do you want to change? Speed is in sprite 6780, running cost in sprite 6785 and non-passenger capacity 6795.

Code: Select all

 6768 * 9	 02 03 00 01 01 00 00 00 00
 6769 * 9	 02 03 01 01 01 00 00 00 00
 6770 * 9	 02 03 03 01 01 01 00 01 00
 6771 * 9	 02 03 05 01 01 02 00 02 00

   // menu
 6772 * 4	 01 03 01 01
 6773 SPRITES\aviator\buy\orville.pcx 10 10 09 40 60 -30 -22
 6774 * 9	 02 03 0F 01 01 00 00 00 00
 6775 * 14	 02 03 0F 81 10 00 FF 01 01 00 21 21 0F 00    // full sprite in news
 6776 * 14	 02 03 0F 81 0C 00 FF 01 A7 80 23 23 0F 00 // set text

// Var 2s. Orville (4e)

//height = ...
 6777 * 14	 02 03 25 81 44 08 FF 01
                                01 00 38 FF
                                05 00
 6778 * 14	 02 03 03 81 9E 00 FF 01 00 00 A0 FF 03 00 // takeoff altitude

// 08 - 09 = just landed, 00 - 0E = on the ground, 0D = taking off, 0F = climb out, 12 - cruising,
// 10 - 14 = approach(?), 15 = decending, 16 = braking on the runway
 6779 * 26	 02 03 20 81 E2 00 FF 04
                                   03 00 0F 0F
                                   00 00 12 12
                                   25 00 15 15
                                   01 00 16 16
                                   01 00

   // takeoff/circuit speed is (\b50)
  // landing speed is (\b25)
  // cruising speed is (\b200)
  //                                     v
 6780 * 26	 02 03 09 81 E2 00 FF 04 \b50 80 0D 0F // takeoff
                                         \b200 80 12 12 // cruise
                                         \b50 80 10 14 // circuit
                                         \b25 80 15 16 // land
                                         \b200 80
 6781 * 14	 02 03 09 81 10 00 FF 01 09 00 0C 0C 20 00 // speed

  // sound effects
 6782 * 18	 02 03 08 81 10 00 FF 02 4F 80 05 05 4E 80 01 01 20 00 // landing sound takeoff sound
 6783 * 18	 02 03 08 81 0C 00 FF 02 08 00 33 33 09 00 36 36 20 00

 // RUNNING COSTS (subroutine 9A)=============
 6784 * 11	 02 03 21 81 7E 9A 00 FF 00 00 80 // gogo gadget subroutine
  //                               vv
 6785 * 18	 02 03 21 81 1A 20 \b163 \2s 1A 00 \b01 01 21 00 00 00 21 00 // store the running cost in reg 01

 6786 * 14	 02 03 21 81 10 00 FF 01 21 00 0E 0E 08 00
 6787 * 14	 02 03 08 81 0C 00 FF 01 21 00 36 36 08 00 // cb36

   // colour refit =================================
   // refit cargo callbacks
 6788 * 26	 02 03 20 81 F2 00 FF 04 // texts
  AB 80 00 00
  AC 80 01 01
  AD 80 02 02
  AE 80 03 03
  00 84 


 6789 * 16	 02 03 E3 85 7F 0A 40 FF FF ff 00 01 00 00 00 80

// E2 alt colours

 6790 * 17	 02 03 84 85 7F 0A 20 FF FF \2+ 1C 00 FF FF 00 00 80
 6791 * 18	 02 03 84 81 43 3C 0F \2+ 1C 00 FF 01 84 00 00 00 84 00 // get the player 2cc colour (shifted)
 6792 * 14	 02 03 E1 81 43 14 F0 01 84 00 00 00 84 00 // get the player colour (shifted)


 6793 * 22	 02 03 22 81 F2 00 03 03 // colouration
  E1 00 01 01
  E2 00 02 02
  E3 00 03 03
  08 00

 6794 * 18	 02 03 08 81 0C 00 FF 02 20 00 19 19 22 00 2D 2D 08 00
// =================================================

  // load callback (75 units)
 6795 * 14	 02 03 19 81 0C 00 FF 01 \b75 80 15 15 08 00

 // action 3 Orville (4e)

 6796 * 13	 03 03 01 4e 02 FF 0F 00 00 08 00 19 00

MildaIV
Engineer
Engineer
Posts: 52
Joined: 11 Nov 2005 09:07
Location: Czech Republic
Contact:

Re: Editing callbacks in existing grf

Post by MildaIV » 19 Sep 2015 08:19

PikkaBird wrote:It's not that well commented, unfortunately. What do you want to change? Speed is in sprite 6780, running cost in sprite 6785 and non-passenger capacity 6795.
Thank you very much. Now I can try to change something. But still dont understand meaning of bytes. For exammple speed call back:
PikkaBird wrote:

Code: Select all

 
   // takeoff/circuit speed is (\b50)
  // landing speed is (\b25)
  // cruising speed is (\b200)
  //                                     v
 6780 * 26	 02 03 09 81 E2 00 FF 04 \b50 80 0D 0F // takeoff
                                         \b200 80 12 12 // cruise
                                         \b50 80 10 14 // circuit
                                         \b25 80 15 16 // land
                                         \b200 80
 6781 * 14	 02 03 09 81 10 00 FF 01 09 00 0C 0C 20 00 // speed

02 - action 2
03 - airplane
09 - ID of this callback - some magic number you choose, probably not important if you don't refer this callback later?
81 - wiki says <num-ent1> without any clue what it is
now Iam totally lost. I cant find any of the bytes followed in this table of the callbacks http://newgrf-specs.tt-wiki.net/wiki/Callbacks.

User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5391
Joined: 13 Sep 2004 13:21
Location: The Moon
Contact:

Re: Editing callbacks in existing grf

Post by PikkaBird » 19 Sep 2015 10:20

MildaIV wrote:81 - wiki says <num-ent1> without any clue what it is
You probably want to be looking at http://newgrf-specs.tt-wiki.net/wiki/VariationalAction2 rather than http://newgrf-specs.tt-wiki.net/wiki/Action2 . :)

Eddi
Tycoon
Tycoon
Posts: 7414
Joined: 17 Jan 2007 00:14

Re: Editing callbacks in existing grf

Post by Eddi » 19 Sep 2015 13:32

example:

Code: Select all

6780     Enumerated sprite ID. you don't have to fill this out, NFORenum will correct this (people generally put -1 here)
*        This is a Pseudo-Sprite
26       Length of the sprite in bytes, likewise this can be filled out by NFORenum
02       Action 2
03       Feature 3
09       ID (will be used at some place further down in another action 2 (or 3))
81       Type of the variable (Byte, Word, DWord. in this case, Byte)
E2       Variable you read (Movement state)
         see http://marcin.ttdpatch.net/sv1codec/TTD-locations.html#_VehicleArray, entry 62(+80)
00 FF    Varadjust (no shift, all bits)
04       4 options
\b50 80  return value 1 (highest bit must be 1 for callback results)
0D 0F    range 1
\b200 80 return value 2
12 12    range 2
\b50 80  return value 3
10 14    range 3
\b25 80  return value 4
15 16    range 4
\b200 80 default value
You might not exactly be interested in Ferion, but if you are, have fun :)

User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9292
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Editing callbacks in existing grf

Post by planetmaker » 19 Sep 2015 19:02

MildaIV wrote:I want to add new planes to existing grf
For that use case you better make your own add-on NewGRF with your own planes. You then can make your life a bit easier and write that in NML rather than the rather cryptic NFO

http://newgrf-specs.tt-wiki.net/wiki/NML:Vehicles
http://www.tt-wiki.net/wiki/NMLTutorial
and see WAS for actual aircraft code: http://dev.openttdcoop.org/projects/worldairlinersset/

MildaIV
Engineer
Engineer
Posts: 52
Joined: 11 Nov 2005 09:07
Location: Czech Republic
Contact:

Re: Editing callbacks in existing grf

Post by MildaIV » 20 Sep 2015 14:35

Eddi wrote:example:

Code: Select all

6780     Enumerated sprite ID. you don't have to fill this out, NFORenum will correct this (people generally put -1 here)
*        This is a Pseudo-Sprite
26       Length of the sprite in bytes, likewise this can be filled out by NFORenum
02       Action 2
03       Feature 3
09       ID (will be used at some place further down in another action 2 (or 3))
81       Type of the variable (Byte, Word, DWord. in this case, Byte)
E2       Variable you read (Movement state)
         see http://marcin.ttdpatch.net/sv1codec/TTD-locations.html#_VehicleArray, entry 62(+80)
00 FF    Varadjust (no shift, all bits)
04       4 options
\b50 80  return value 1 (highest bit must be 1 for callback results)
0D 0F    range 1
\b200 80 return value 2
12 12    range 2
\b50 80  return value 3
10 14    range 3
\b25 80  return value 4
15 16    range 4
\b200 80 default value
Ty, now I understand whole line with exception of return values. I changed them. As I dont know how this values are transformed to speed in km/h i just copied ones from diferent Airplane
orig 6780 * 26 02 03 09 81 E2 00 FF 04 32 80 0D 0F C8 80 12 12 32 80 10 14 19 80 15 16 C8 80
new 6780 * 26 02 03 09 81 E2 00 FF 04 1C 80 0D 0F 46 80 12 12 1C 80 10 14 14 80 15 16 46 80

But speed of plane remain same in game :(

Edit: Speed is probably encoded by this (incomplete) table http://dev.openttdcoop.org/projects/wor ... le_of_Info

User avatar
FooBar
Tycoon
Tycoon
Posts: 6559
Joined: 21 May 2007 11:47
Location: The Netherlands
Contact:

Re: Editing callbacks in existing grf

Post by FooBar » 20 Sep 2015 14:48

You did re-encode the GRF and made sure you weren't loading the old version ingame, right?

MildaIV
Engineer
Engineer
Posts: 52
Joined: 11 Nov 2005 09:07
Location: Czech Republic
Contact:

Re: Editing callbacks in existing grf

Post by MildaIV » 20 Sep 2015 15:10

FooBar wrote:You did re-encode the GRF and made sure you weren't loading the old version ingame, right?
Renamed plane to be sure that I am useing modified one.

MildaIV
Engineer
Engineer
Posts: 52
Joined: 11 Nov 2005 09:07
Location: Czech Republic
Contact:

Re: Editing callbacks in existing grf

Post by MildaIV » 20 Sep 2015 16:27

Got it, my fail. Block I have edited belongs to nex plane, because these callbacks are before name of the plane.

MildaIV
Engineer
Engineer
Posts: 52
Joined: 11 Nov 2005 09:07
Location: Czech Republic
Contact:

Re: Editing callbacks in existing grf

Post by MildaIV » 20 Sep 2015 17:41

I have successfuly changed speed, runing cost. Still can't find range. There's no 1F property, and no mention about range callback in pikkabirds post. Also 0A property is overwriten by some callback, which I can't found.

User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5391
Joined: 13 Sep 2004 13:21
Location: The Moon
Contact:

Re: Editing callbacks in existing grf

Post by PikkaBird » 21 Sep 2015 01:58

Ranges in av8 (for the non-generational aircraft) are set en bloc in sprites 8210-8213. This particular aircraft already has the longest range in the set, 4096 tiles.

MildaIV
Engineer
Engineer
Posts: 52
Joined: 11 Nov 2005 09:07
Location: Czech Republic
Contact:

Re: Editing callbacks in existing grf

Post by MildaIV » 03 Oct 2015 08:15

I successfully modified some small planes to planes Iam using in game like Vickers Vanguard or Boeing 757. After that I slightly changed some airplanes to be more realistic(ie. small increase in pax count for Widebodies, increasing capacity of Boeing 727 to 116 passangers, decreasing its range a little, ...). But still I am not able to change any properties of planes with upgrades like Boeing 737 or 747(ie decrease range of original 737 and increase pax count for 747). Also adding new upgrade would be nice, but probably too complicated (B727-200A upgrade for B727).

Eddi
Tycoon
Tycoon
Posts: 7414
Joined: 17 Jan 2007 00:14

Re: Editing callbacks in existing grf

Post by Eddi » 04 Oct 2015 12:43

these "upgrades" really should be split into separate vehicles...
You might not exactly be interested in Ferion, but if you are, have fun :)

User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5391
Joined: 13 Sep 2004 13:21
Location: The Moon
Contact:

Re: Editing callbacks in existing grf

Post by PikkaBird » 05 Oct 2015 02:39

Eddi wrote:these "upgrades" really should be split into separate vehicles...
The main reason for the generational aircraft in Av8 was the small number of vehicle IDs available in TTDPatch.

If anyone wants to take the Av8 sprites and use them for their own aircraft set (as WAS does) they should feel free. Alternatively, when I get a moment, I'll set up a patreon account so you can bribe me to update av8 myself. ;)

Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 1 guest