#164150 - ZachG - Wed Oct 22, 2008 4:58 am
I have a 512x512 pixel (64x64 tile) background that I'm filling in with tiles. Because the screen on the DS is 256x192, I have to do some scrolling to move from different parts of my background.
The problem I'm having is conceptualizing (1) how to do buffering of tiles, and (2) how to copy over the tiles to be buffered.
Lets say my sprite is at a position where I want the buffering to begin. I use my BGx_X0 register to scroll the background to match the player's relative position on my tile array. If I want to begin buffering the next set of tiles, I see only two real options of how to alter my array:
My array:
0,0 0,1 0,2 ... 0,n
1,0
2,0
...
m,0
1) If I were to try to keep the buffer on the very right edge my array, which would be all of the [k*(n-1)] tiles where k is the "row" I'm currently on, I would have to copy over 0,1 to 0,0, 0,2 to 0,1, and so on. The problem with doing that is it seems that I won't be using the BGx_X0 register, which is integral to scrolling.
2) If I were to say that it should buffer lets say 10 tiles from the current position of the player in both directions (i.e. if my player in the 10th vertical column, it would load tiles for the 0 column and 20th column. If I moved to the 11th column, it would load tiles for the 1st and 21st column.), I would be able to alter my BGx_X0 kinda. I know the DS hardware does automatic looping of tiles (i.e. If my tiles are 256x256 pixels and I want to go right one pixel, it'll show the 256th pixels on the left side of my screen, followed by the 0, the 1, and the 255th on the right side), but it seems kinda weird that once I reach the point where it starts again (i.e. I'm on the 64th tile, I then want to loop back around to the 1st, so I set BGx_XO from 512 to 0.) I set it back to 0.
I'm just making a simple horizontal platformer. I haven't been able to find anything on the theory behind regular tiled backgrounds, aside from Tonc, and how to do buffering.
The problem I'm having is conceptualizing (1) how to do buffering of tiles, and (2) how to copy over the tiles to be buffered.
Lets say my sprite is at a position where I want the buffering to begin. I use my BGx_X0 register to scroll the background to match the player's relative position on my tile array. If I want to begin buffering the next set of tiles, I see only two real options of how to alter my array:
My array:
0,0 0,1 0,2 ... 0,n
1,0
2,0
...
m,0
1) If I were to try to keep the buffer on the very right edge my array, which would be all of the [k*(n-1)] tiles where k is the "row" I'm currently on, I would have to copy over 0,1 to 0,0, 0,2 to 0,1, and so on. The problem with doing that is it seems that I won't be using the BGx_X0 register, which is integral to scrolling.
2) If I were to say that it should buffer lets say 10 tiles from the current position of the player in both directions (i.e. if my player in the 10th vertical column, it would load tiles for the 0 column and 20th column. If I moved to the 11th column, it would load tiles for the 1st and 21st column.), I would be able to alter my BGx_X0 kinda. I know the DS hardware does automatic looping of tiles (i.e. If my tiles are 256x256 pixels and I want to go right one pixel, it'll show the 256th pixels on the left side of my screen, followed by the 0, the 1, and the 255th on the right side), but it seems kinda weird that once I reach the point where it starts again (i.e. I'm on the 64th tile, I then want to loop back around to the 1st, so I set BGx_XO from 512 to 0.) I set it back to 0.
I'm just making a simple horizontal platformer. I haven't been able to find anything on the theory behind regular tiled backgrounds, aside from Tonc, and how to do buffering.