Tile Map Help
I've got a 256x256 map. This is split into 64 chunks of 32x32. Each cell takes up one byte so only four chunks are held in memory at any given time. Assume the chunks
are held in memory in sequence as ABCD, starting at 0xF000.
I have an 11x11 view window, with the player at the center. If I specify the x and y co-ordinates of the top left cell of my view window, what's the quickest way of calculating where each cell's tile is held in memory? Sorting the data so that it is arranged sequentially is not an option unless it can be done very quickly.
...
Solved it. Just add 992 if x>31 and 32 if y>31. Multiply y*32. Add x+y = offset to cell. It means I have to look up each cell individually, but it should be pretty fast as it's only 121 cells.
A | B --+-- C | D
are held in memory in sequence as ABCD, starting at 0xF000.
I have an 11x11 view window, with the player at the center. If I specify the x and y co-ordinates of the top left cell of my view window, what's the quickest way of calculating where each cell's tile is held in memory? Sorting the data so that it is arranged sequentially is not an option unless it can be done very quickly.
...
Solved it. Just add 992 if x>31 and 32 if y>31. Multiply y*32. Add x+y = offset to cell. It means I have to look up each cell individually, but it should be pretty fast as it's only 121 cells.
Post edited by chev on
Comments
C'mon, somebody? I've got the graphics sitting in stasis*
*on my C drive.