In a previous post I asked some details about how to render a map for a side scroller. From that thread, the topic of interleaving data was mentioned. For metatile data, the concept is great and make accessing the data a lot more easier. Now I was thinking, can I apply this concept for map data too?
Since it's a side scroller, the map data is organized by column of metatile. One way that come to my mind for interleaving data is to have 2 LUT: one for the high and low address of the column. I have 7 metatile per column. So instead to try to find the adress of the metatile by multiplying by 7 the metatile column index, I would just use the column index and use both LUT to get the address of the data and maybe put it in a zero page variable like this:
The pro is that you can access data very fast and have up to 256 metatile column before passing a page boundary. The con is that you now have 2 extra byte per metatile column. but I guess for the simplicity and speed gained, it may be worth it.
Does it all make sense or I'm trying to think too hard?
Since it's a side scroller, the map data is organized by column of metatile. One way that come to my mind for interleaving data is to have 2 LUT: one for the high and low address of the column. I have 7 metatile per column. So instead to try to find the adress of the metatile by multiplying by 7 the metatile column index, I would just use the column index and use both LUT to get the address of the data and maybe put it in a zero page variable like this:
Code:
ldx zpColumnIndex
lda (zpMapDataAdrHi),x
sta zpCurrentColumnDataAdr
lda (zpMapDataAdrLo),x
sta zpCurrentColumnDataAdr + 1
lda (zpMapDataAdrHi),x
sta zpCurrentColumnDataAdr
lda (zpMapDataAdrLo),x
sta zpCurrentColumnDataAdr + 1
The pro is that you can access data very fast and have up to 256 metatile column before passing a page boundary. The con is that you now have 2 extra byte per metatile column. but I guess for the simplicity and speed gained, it may be worth it.
Does it all make sense or I'm trying to think too hard?