#17823 - GunterPete - Mon Mar 15, 2004 2:50 pm
Hi there,
I've written a CLevel class, allowing me to gather all the information for each level of a Mode7 game. The game looks like this:
[Images not permitted - Click here to view it]
This CLevel class includes a pointer to the tile data, to the map data (sky and floor), the levels palette and a pallete used for a copper bar effect to be loaded into the transparent colour every HBlank.
Here are the member variables:
A method of the class is loadLvlIntoMemory, which loads all this information into the relevant areas of GBA memory:
This seems to work fine the first time it is called. However whenever I try and switch levels, the map information is loaded in, but the tile and palette information isn't. Do I somehow need to clear the memory before reinitialising it? Am I just doing something genuinely very stupid? (this isn't at all unlikely).
The full project can be found at http://tbhl.theonering.net/petegunter/downloads/Jetpack.zip if anyones willing to take a look for me. In this code, level 1 is loaded when you hit L, and level 2 is (not :P) loaded when you hit R.
Kind regards,
-Pete Gunter
I've written a CLevel class, allowing me to gather all the information for each level of a Mode7 game. The game looks like this:
[Images not permitted - Click here to view it]
This CLevel class includes a pointer to the tile data, to the map data (sky and floor), the levels palette and a pallete used for a copper bar effect to be loaded into the transparent colour every HBlank.
Here are the member variables:
Code: |
private: const u16* m_ppalBackground; //Pointer to levels pallette const u16* m_pbmpMapTiles; //Pointer to levels map tiles const u8* m_pmapFloor; //Pointer to levels floor map const u8* m_pmapSky; //Pointer to levels sky map const u16* m_ppalCopper; //Pointer to pallete used for copper bar effect FIXED m_gravity; //FIXED :16 value of acceleration due to gravity |
A method of the class is loadLvlIntoMemory, which loads all this information into the relevant areas of GBA memory:
Code: |
//Loads the map information into memory which includes: // Load level palletes (map and copper bar) // Level Tile Data (Char base block(0)) // Bg 1 (Text) map data, Sky (Screen Base Block(30)) // Bg 2 (Rotation) map data, Floor (Screen Base Block(31)) // Gravity, fixed :16 into gGrav; // void CLevel::loadLvlIntoMemory(void) { /* Load in the palette data */ //Load in background pallete DMA_Copy(3,(void*)m_ppalBackground,(void*)BGPaletteMem,256,DMA_16NOW); //Load in the copper barpallete DMA_Copy(3,(void*)m_ppalCopper,(void*)gpalCopper,160,DMA_16NOW); /* Load in the tile data */ //Level tiles DMA_Copy(3,(void*)m_pbmpMapTiles,(void*)CharBaseBlock(0),8190,DMA_16NOW); /* Load in the text background data */ //Temporary pointers to map data u16* bg1map =(u16*)ScreenBaseBlock(30); int x=0,y=0; //iterating vars for(y = 0; y < 32; y++) //loop through all 32x32 tiles { for(x = 0; x < 32; x++) { //*** BG 1 Sky //First tile (Hiword) bg1map[x + y*32] = m_pmapSky[x + y*32]; } } /* Load in the rotation background data */ //Temporary pointer to map data u16* bg2map =(u16*)ScreenBaseBlock(31); for(y = 0; y < 32; y++) //loop through all 32x32 tiles { for(x = 0; x < 16; x++) { //*** BG 2 Floor //First tile (Hiword) bg2map[x + (y*16)] = (u16) ( ((u8)m_pmapFloor[(x*2) + y*32]) //Next tile (Loword) +((u8)m_pmapFloor[(x*2)+1 + y*32]<<8) ); } } } |
This seems to work fine the first time it is called. However whenever I try and switch levels, the map information is loaded in, but the tile and palette information isn't. Do I somehow need to clear the memory before reinitialising it? Am I just doing something genuinely very stupid? (this isn't at all unlikely).
The full project can be found at http://tbhl.theonering.net/petegunter/downloads/Jetpack.zip if anyones willing to take a look for me. In this code, level 1 is loaded when you hit L, and level 2 is (not :P) loaded when you hit R.
Kind regards,
-Pete Gunter