Page 1 of 1

Question about Action-A

Posted: 10 Sep 2007 11:46
by mikeel
hi to all
i'm trying to understand how grfs work, but i have a problem.
in action-a, according to the manual, the last two values represent the first-sprite:

Code: Select all

<first-sprite>	W	Number of first sprite in this set
but where i can find this number?
(for example if i want replace a building)
thanks
mikeel

Re: Question about Action-A

Posted: 10 Sep 2007 13:15
by mph
i think this is what you mean-
you decode trg1r.grf - that is the main graphics file for most of the graphics in the game-
you then get trg1r.nfo and trg1r.pcx
open the pcx file - and there will be lots of sprites- each with a number above them- and that is the sprite number.
a set of sprites is a set of consecutive sprites- if you want to replace a certain building- find the sprite or set of sprites in the pcx file, and the first sprite number is what you want.

i hope i understood correctly- i too am only learning-

Re: Question about Action-A

Posted: 10 Sep 2007 14:04
by mikeel
well i don't think that is the little number above the sprites becouse it is a decimal value.
the action-A requires instead two hex values:
in the example of the manual
3 * 5 0A 01 0C 3A 08
where
3A 08 <first-sprite>: First Sprite of the set (3A 08 - Farms)
but in the pcx file the first sprite of the farm is 2108

Re: Question about Action-A

Posted: 10 Sep 2007 14:34
by mph
yes- the little number above the sprite is a decimal number.

the action a reqires this number in hexidecimal in little endian format i believe.

in the wiki-on the actionA page- it says in the table that the element- <first-sprite>, which is the number of the first sprite in the set, has size w.
size w means that
This parameter is a two-byte word, specified in little-endian byte order
from this page- http://wiki.ttdpatch.net/tiki-index.php ... nsDetailed

so you take the decimal sprite number from the trg1r.pcx file and convert this do hexidecimal. the windows calculator can do this.
taking an example i have done- to replace the fences on the railway tracks.
first sprite number is 1301 in decimal

convert to hexidecimal - giving 515.
make this a two byte word- 05 15
put in little endian- 15 05

and that is what you use in the actionA


i hope this is what you mean. and that im explaining it ok!

edit- you may be confused- the first sprite for the farm is 2106 not 2108. which in hexidecimal put in little endian is 3A 08

Re: Question about Action-A: Answered

Posted: 10 Sep 2007 17:40
by mikeel
I was getting crazy becouse i didn't realize that i have to switch the two values in little endian :oops: ... thanks

Re: Question about Action-A

Posted: 10 Sep 2007 17:51
by minime
Why not just save yourself the trouble and use those handy little escape sequences? Then you can just write the decimal number and not have to worry about endianness.

Re: Question about Action-A

Posted: 10 Sep 2007 18:12
by mikeel
i haven't understand... what are the "little escape sequences"?

Re: Question about Action-A

Posted: 10 Sep 2007 19:20
by minime
Read the documentation - in particular the part of section "Byte Order" that begins with
wiki wrote:In Info version 7 and later (supported by grfcodec version 0.9.9 and later), grfcodec can do some of this work for you...