#19283 - darknet - Fri Apr 16, 2004 3:47 am
I am writing a game that is a bunch of mini-games all independent of each other and work through a main driver program.
I successfully wrote a breakout clone and a gradius clone in that order. Both use Harbours (the GBA book) DMAFastCopy function to load in the tiled backgrounds.
When I finished the Breakout clone (before I began writing the gradius clone), the background loaded up just fine. Then I wrote the gradius clone and THAT background loads up fine as well. However, now the tiles in the breakout clone are corrupt (and I didnt change that code whatsoever from when it was working!)
So since I use the same DMA copy function in both, I am assuming that I may have to reset the DMA registers or somehow clear it for BOTH minigames to work? Here's some of the code I've mentioned...
The DMAFastCopy function:
and the code that Breakout uses to load its background:
and the code that Gradius uses to load its background:
Once again, the Breakout worked just fine before I wrote the gradius game. The gradius one works fine now but the breakout one has corrupt tiles.
I actually run the entire project through a main.cpp that simply switches appropiately between the two games' start functions. Selecting the two also involves switching to mode 3 and displaying a menu, if that may have anything to do with it. I wrote both games as if the other did not exist.
I hope I asked my question clearly, thanks very very much for reading and any reply is greatly appreciated.
-Mike
I successfully wrote a breakout clone and a gradius clone in that order. Both use Harbours (the GBA book) DMAFastCopy function to load in the tiled backgrounds.
When I finished the Breakout clone (before I began writing the gradius clone), the background loaded up just fine. Then I wrote the gradius clone and THAT background loads up fine as well. However, now the tiles in the breakout clone are corrupt (and I didnt change that code whatsoever from when it was working!)
So since I use the same DMA copy function in both, I am assuming that I may have to reset the DMA registers or somehow clear it for BOTH minigames to work? Here's some of the code I've mentioned...
The DMAFastCopy function:
Code: |
void DMAFastCopy(void* source, void* destination, unsigned int count, unsigned int mode) { if(mode == DMA_16NOW || mode == DMA_32NOW) { REG_DMA3DAD = (unsigned int)destination; REG_DMA3SAD = (unsigned int)source; REG_DMA3CNT = count | mode; } } |
and the code that Breakout uses to load its background:
Code: |
//copy the palette into the background palette memory DMAFastCopy((void*)boback_Palette, (void*)BGPaletteMem, 256, DMA_16NOW); //now copy the tile images into tile memory DMAFastCopy((void*)background_Tiles, (void*)charBaseBlock(0), 65088/4, DMA_32NOW); //Finally, draw the background's map. DMAFastCopy((void*)background_Map, (void*)bgOneMap, 1024, DMA_32NOW); |
and the code that Gradius uses to load its background:
Code: |
//copy the palette into the background palette memory DMAFastCopy((void*)defenderMap_Palette, (void*)BGPaletteMem, 256, DMA_16NOW); //now copy the tile images into tile memory DMAFastCopy((void*)defenderMap_Tiles, (void*)charBaseBlock(0), 6848/4, DMA_32NOW); //Finally, draw the background's map. DMAFastCopy((void*)defenderMap_Map, (void*)bgOneDefendMap, 1024, DMA_32NOW); |
Once again, the Breakout worked just fine before I wrote the gradius game. The gradius one works fine now but the breakout one has corrupt tiles.
I actually run the entire project through a main.cpp that simply switches appropiately between the two games' start functions. Selecting the two also involves switching to mode 3 and displaying a menu, if that may have anything to do with it. I wrote both games as if the other did not exist.
I hope I asked my question clearly, thanks very very much for reading and any reply is greatly appreciated.
-Mike