Get station length over 16

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

Moderator: Graphics Moderators

Post Reply
idioty
Engineer
Engineer
Posts: 59
Joined: 21 Jun 2010 11:54

Get station length over 16

Post by idioty »

I need every third field from south. How do you can get back platform length over 16?
I use this:

Code: Select all

00 * 00	02 04 D2
			81 49						// 81 lower byte, 49 type
			80							// shift & modulo
			F0							// mask
			01							// add
			03							// mod with 3
			01							// 1 variation
			0E 00 00 00					// 00 0E if min 00 and max 00
			0D 00						// else 00 0D
It works if lenght lower than 17, but does'nt work if greather.
So, how can I get back every third filed?

I read in "Variational Action2 Stations" the lenght info is 4 bit, but I need 1 byte to get correct lenght.
Sorry my bad english, I don't speak english!
michael blunck
Tycoon
Tycoon
Posts: 5948
Joined: 27 Apr 2005 07:09
Contact:

Re: Get station length over 16

Post by michael blunck »

idioty wrote: I need every third field from south. How do you can get back platform length over 16?
I use this:

Code: Select all

00 * 00	02 04 D2
			81 49						// 81 lower byte, 49 type
			80							// shift & modulo
			F0							// mask
			01							// add
			03							// mod with 3
			01							// 1 variation
			0E 00 00 00					// 00 0E if min 00 and max 00
			0D 00						// else 00 0D
Looks like an advanced varaction2, but it is ill-formed. In the <operator> field you´d have to set bit5.
idioty wrote: I read in "Variational Action2 Stations" the lenght info is 4 bit, but I need 1 byte to get correct lenght.
That´s not possible, since in <xTNLcCpP> there´s only 4 bits per value.

regards
Michael
Image
idioty
Engineer
Engineer
Posts: 59
Joined: 21 Jun 2010 11:54

Re: Get station length over 16

Post by idioty »

This is not Advanced Variational Action2.

Code: Select all

	00 * 00	02 04 D2				// <action> <feature> <set-id>
			81 49						// <type> <variable>
			80							// <shift-num>
			F0							// <and-mask>
			01							// <add-val>
			03							// <modulo-val>
			01							// <nvar>
			0F 00 00 00				// <set-id> <low-range> <high-range>
			0E 00						// <default>
I wrote this basis of VariationalAction2: http://newgrf-specs.tt-wiki.net/wiki/Va ... #varadjust
And of corse it works with less than 17 lenght platforms.
Sorry my bad english, I don't speak english!
michael blunck
Tycoon
Tycoon
Posts: 5948
Joined: 27 Apr 2005 07:09
Contact:

Re: Get station length over 16

Post by michael blunck »

idioty wrote: This is not Advanced Variational Action2.
Sorry. Didn´t see a shift-and-add-modulo adjustment for a long time. :cool:

In any way, since all values read from var49 (<xTNLcCpP>) are 4 bit, you can´t get a correct result >16 (i.e. 0) from any of it. It´ll always be truncated to 4 bits. E.g., a length of "20" -> "10100" would be truncated to "0100", i.e. "4".

The problem is with the transition between "1111" (length = 15) and the (truncated) length for 16 (1<0000>):

Code: Select all

...
1101	0001	0xD1	209	2
1110	0001	0xE1	225	0
1111	0001	0xF1	241	1

0000	0001	0x01	1	 1
0001	0001	0x11	17	2
0010	0001	0x21	33	0
...
BTW, even without trying to add an extra "1" in your code, i.e. "81 49 84 0F 00 03 ... " instead (or adding any other value), the problem will persist.


BTW2, take a look here.

regards
Michael
Image
idioty
Engineer
Engineer
Posts: 59
Joined: 21 Jun 2010 11:54

Re: Get station length over 16

Post by idioty »

Sorry, I forget this topic...

I tried everything, but the result of mod is always 0 if the position is greather than 15.
Sorry my bad english, I don't speak english!
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 33 guests