[nfo] Checking ranges with industry tile var 43...

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

Moderator: Graphics Moderators

Post Reply
User avatar
andythenorth
Tycoon
Tycoon
Posts: 5705
Joined: 31 Mar 2007 14:23
Location: Lost in Music

[nfo] Checking ranges with industry tile var 43...

Post by andythenorth »

I am testing the fields patch from frosch....
http://devs.openttd.org/~frosch/texts/farmtiles.txt
http://devs.openttd.org/~frosch/diffs/c ... tiles.diff

Tiles created as 'field tiles' by this patch support industry tile var 43 (XY offsets from north tile of industry, in format 00yxYYXX, with signed values).

I have used var 43 a lot to check specific tile locations in industry layouts. However I am having a problem understanding how to check ranges correctly. For example, dividing into quadrants of +XX +YY, +XX -YY, -XX +YY, -XX -YY.

I think I can see why this doesn't work, but I can't see what should work.

Code: Select all

-1 * 0 02 09 C1 //layout 1
	85 43 //check relative position (00yx[YYXX])
	00 FF FF //don't shift, don't mask
	\b4 //number of ranges to check (number of tiles) [range: XX YY  XX YY]
          \wx00   00 00  79 79
          \wx01   00 80  79 FF
          \wx02   80 00  FF 79
          \wx03   80 80  FF FF
	\wx04 //00 01  00 01 <default>
I'm sure it's easy, but I have brain fail about it. All I can think of at the moment is grabbing a byte instead of a word to check XX and YY in branching varaction 2s :|
User avatar
OzTrans
Tycoon
Tycoon
Posts: 1714
Joined: 04 Mar 2005 01:07

Re: [nfo] Checking ranges with industry tile var 43...

Post by OzTrans »

...
Last edited by OzTrans on 04 Feb 2012 00:32, edited 1 time in total.
Eddi
Tycoon
Tycoon
Posts: 8289
Joined: 17 Jan 2007 00:14

Re: [nfo] Checking ranges with industry tile var 43...

Post by Eddi »

in order to check quadrants, you need to nest two varaction 2

like this:
id 1 - mask sign bit of Y - if <0 jump to id 2 - if >=0 jump to id 3
id 2 - mask sign bit of X - if <0 jump to id 4 - if >=0 jump to id 5
id 3 - mask sign bit of X - if <0 jump to id 6 - if >=0 jump to id 7
id 4 - handle quadrant X<0, Y<0
id 5 - handle quadrant X>=0, Y<0
id 6 - handle quadrant X<0, Y>=0
id 7 - handle quadrant X>=0, Y>=0

[in NFO, you'd write these backwards]

[edit]
alternatively, you can mask both the sign bits of X and Y with the mask \wx1010, and then branch off the values \wx1010, \wx1000, \wx0010, \wx0000 [same order as above] but this is less expandable if you want to move the origin...
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 13 guests