#21881 - faz99 - Tue Jun 08, 2004 7:28 pm
Hey,
I'm stuck on drawing onto backgrounds (Or rather the map data) in backgrounds that don't rotate.
If this has been asked before then direct me because i searched around...
I can get rotation backgrounds working fine they aren't so bad since the map is a linear array..
But according to The Pern Project:
"Unfortunately text backgrounds are not quite as simple. Size 0 (256x256) and size 2(256x512) still work as linear arrays but size 1 and 3 are broken into separate blocks."
But when i try to treat a size 0 map as a linear array on a text background, i just don't get the same outcome that i get when i do this with a rotational background.
I know it has to be something simple but i don't know what, frustrating stuff :)
Here's my code:
I got most of this code from various tutorials around, so i just left all their comments in.
This is practically the same code i used for the rotational backgrounds except these changed..
bg2.number=1 => bg2.number=2
TEXTBG_SIZE... => ROTBG_SIZE...
And then i changed the key input so that is increments y_scroll instead of DX.
So.. What the hell's the problem? o_O
_________________
\(^_^)/
I'm stuck on drawing onto backgrounds (Or rather the map data) in backgrounds that don't rotate.
If this has been asked before then direct me because i searched around...
I can get rotation backgrounds working fine they aren't so bad since the map is a linear array..
But according to The Pern Project:
"Unfortunately text backgrounds are not quite as simple. Size 0 (256x256) and size 2(256x512) still work as linear arrays but size 1 and 3 are broken into separate blocks."
But when i try to treat a size 0 map as a linear array on a text background, i just don't get the same outcome that i get when i do this with a rotational background.
I know it has to be something simple but i don't know what, frustrating stuff :)
Here's my code:
Code: |
#include "gba.h" #include "dispcnt.h" #include "tilesetup.h" #include "tiles.h" #include "tilemap.c" #include "keypad.h" Bg bg2; //wait for the screen to stop drawing void WaitForVsync() { while((volatile u16)REG_VCOUNT != 160){} } int main() { int index = 0; //generic loop variables u16 loop; u16* temp; //temporary storage pointer //set mode 2 and enable sprites and 1d mapping SetMode(MODE_1); bg2.number = 1; //background number 0-3 bg2.charBaseBlock = 0; bg2.screenBaseBlock = 28; //map data position on 2Kb boundary bg2.colorMode = BG_COLOR_256; //256-colour background bg2.size = TEXTBG_SIZE_256x256; //size of map bg2.mosaic = 0; //not enabled bg2.x_scroll = 0; //scrolling variables bg2.y_scroll = 0; bg2.wraparound = WRAPAROUND; //Point to correct tile and map data, update the Background and Display registers accordingly EnableBackground(&bg2); for(loop = 0; loop < 256; loop++) BGPaletteMem[loop] = tilesPalette[loop]; //load the background palette into memory for(loop = 0; loop < tiles_WIDTH * tiles_HEIGHT /2; loop++) //load tile image data bg2.tileData[loop] = tilesData[loop]; //load the map image data temp = (u16*)tilemap; for(loop = 0; loop < 32 * 32 /2; loop++) bg2.mapData[loop] = temp[loop]; //Main Game loop while(1) { WaitForVsync(); //waits for the screen to stop drawing UpdateBackground(&bg2); //make sure registers are updated if anything changes e.g. scrolling if (!(REG_P1 & KEY_UP)) bg2.y_scroll += 1; } return(0); } |
I got most of this code from various tutorials around, so i just left all their comments in.
This is practically the same code i used for the rotational backgrounds except these changed..
bg2.number=1 => bg2.number=2
TEXTBG_SIZE... => ROTBG_SIZE...
And then i changed the key input so that is increments y_scroll instead of DX.
So.. What the hell's the problem? o_O
_________________
\(^_^)/