Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Town Y value reported by var 80 is inconsistent on different map sizes #7149

Closed
PikkaBird opened this issue Jan 31, 2019 · 4 comments
Closed

Town Y value reported by var 80 is inconsistent on different map sizes #7149

PikkaBird opened this issue Jan 31, 2019 · 4 comments

Comments

@PikkaBird
Copy link

@PikkaBird PikkaBird commented Jan 31, 2019

Town var 80 is the XY of the town. On a 256x256 map, the variable returns the expected values. On all map sizes, the X value in the low byte appears to work correctly (town X position truncated to a byte).

On larger or smaller maps, however, the Y value becomes erratic. On larger map sizes, it multiplies, and can take an overflow from the X coordinate. On smaller map sizes, it halves, with odd values underflowing into the X coordinate. The behaviour seems to be the same whether the variable is accessed as the high byte of var 80, or as var 81.

A test newgrf is attached. The reported values from var 80 are stored in the persistent town registers - to view them, inspect a test house then click the "parent" button.

image3
Doubled Y value on 512x map
image5
Halved Y value (with underflow) on 128x map
testhouse.zip

@Eddi-z

This comment has been minimized.

Copy link
Contributor

@Eddi-z Eddi-z commented Jan 31, 2019

Var 80 is not part of the specs, and the meaning has diverged a bit from the original TTD meaning. So i don't think this is technically a bug, but the behavior might need better documentation.

@PikkaBird

This comment has been minimized.

Copy link
Author

@PikkaBird PikkaBird commented Jan 31, 2019

Okay, I think I understand how it works now. I'll experiment.

@Eddi-z

This comment has been minimized.

Copy link
Contributor

@Eddi-z Eddi-z commented Jan 31, 2019

Basically, you need to read out the "X" bits from "Patch Var 13" and then recreate the TileX/TileY functions, this will be correct for all map sizes (smaller or bigger)

@PeterN

This comment has been minimized.

Copy link
Member

@PeterN PeterN commented Jan 31, 2019

This is an internal data variable which requires masking to get the data as required, and is working as expected.

@PeterN PeterN closed this Jan 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.