#34314 - arock99 - Mon Jan 17, 2005 6:28 pm
Hello,
Although I'm not new to programming in general (I have been doing various things for over 10 years now) pretty much everything i'm doing now is being learned as I go for GBA Development.
I have written code to scroll though a Mode 0 Map and using someone else's already generated .h header file everything looks and works ok. When I try and use a .h header file I generate by using either pcx2gba or pcx2sprite I get garbled graphics. What tool should I be using? I use pcx2gba and pcx2sprite by dragging and dropping the pcx file on to them.
I'm using photoshop and am using an indexed pcx file as per the tutorials.
Here is my main function:
int main() {
int xBg = 0, yBg = 0;//start x,y position of screen in map
unsigned short* bg0map =(unsigned short*)ScreenBaseBlock(31);//Create a pointer to background 0 tilemap buffer
REG_BG0CNT = BG_COLOR256 | TEXTBG_SIZE_256x256 | (31 << SCREEN_SHIFT) | WRAPAROUND;//set up background 0
SetMode(0 | BG0_ENABLE);//set video mode 0 with background 0
DMAFastCopy((void*)bgPalette, (void*)BGPaletteMem,256, DMA_16NOW);//copy the palette into the background palette memory
DMAFastCopy((void*)bgData, (void*)CharBaseBlock(0),sizeof(bgData)/4, DMA_32NOW);//copy the tile images into the tile memory
DMAFastCopy((void*)lvlMap, (void*)bg0map, 512, DMA_32NOW);//copy the tile map into background 0
while (1) {
while(REG_VCOUNT < 160); //wait for the start of VBLANK
//D-pad moves background
if(!(BUTTONS & BUTTON_LEFT)) xBg--;
if(!(BUTTONS & BUTTON_RIGHT)) xBg++;
if(!(BUTTONS & BUTTON_UP)) yBg--;
if(!(BUTTONS & BUTTON_DOWN)) yBg++;
REG_BG0HOFS = xBg; //x position of start of background
REG_BG0VOFS = yBg; //y position of start of background
while(REG_VCOUNT > 160); //wait for end of VBLANK
}
return 0;
}
Although I'm not new to programming in general (I have been doing various things for over 10 years now) pretty much everything i'm doing now is being learned as I go for GBA Development.
I have written code to scroll though a Mode 0 Map and using someone else's already generated .h header file everything looks and works ok. When I try and use a .h header file I generate by using either pcx2gba or pcx2sprite I get garbled graphics. What tool should I be using? I use pcx2gba and pcx2sprite by dragging and dropping the pcx file on to them.
I'm using photoshop and am using an indexed pcx file as per the tutorials.
Here is my main function:
int main() {
int xBg = 0, yBg = 0;//start x,y position of screen in map
unsigned short* bg0map =(unsigned short*)ScreenBaseBlock(31);//Create a pointer to background 0 tilemap buffer
REG_BG0CNT = BG_COLOR256 | TEXTBG_SIZE_256x256 | (31 << SCREEN_SHIFT) | WRAPAROUND;//set up background 0
SetMode(0 | BG0_ENABLE);//set video mode 0 with background 0
DMAFastCopy((void*)bgPalette, (void*)BGPaletteMem,256, DMA_16NOW);//copy the palette into the background palette memory
DMAFastCopy((void*)bgData, (void*)CharBaseBlock(0),sizeof(bgData)/4, DMA_32NOW);//copy the tile images into the tile memory
DMAFastCopy((void*)lvlMap, (void*)bg0map, 512, DMA_32NOW);//copy the tile map into background 0
while (1) {
while(REG_VCOUNT < 160); //wait for the start of VBLANK
//D-pad moves background
if(!(BUTTONS & BUTTON_LEFT)) xBg--;
if(!(BUTTONS & BUTTON_RIGHT)) xBg++;
if(!(BUTTONS & BUTTON_UP)) yBg--;
if(!(BUTTONS & BUTTON_DOWN)) yBg++;
REG_BG0HOFS = xBg; //x position of start of background
REG_BG0VOFS = yBg; //y position of start of background
while(REG_VCOUNT > 160); //wait for end of VBLANK
}
return 0;
}