Tile Map Help

edited July 2008 in Development
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
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

  • edited July 2008
    So... WHEN we will se a playable demo ?
  • edited July 2008
    aowen wrote: »
    If anyone wants to resurrect that Zelda clone then I'd be prepared to pass on my code, since my finished project will be released under GPL 2.

    C'mon, somebody? I've got the graphics sitting in stasis*

    *on my C drive.
  • edited July 2008
    Ooooh. I won't be around this weekend, but I'll fire off some of the graphics at the beginning of next week. Any format you'd prefer them in?
Sign In or Register to comment.