GraphicsManager::GraphicsManager() { _sprite_identifier = 0; _object_char_bb = (uint16_t*)CharBaseBlock(4); _background_char_bb = (uint16_t*)CharBaseBlock(BG_CHAR_BLOCK); SetupGraphics(); }
/* the main function */ int main( ) { int x = 0, y = 0; /* we set the mode to mode 0 with background 0 turned on*/ *REG_DISPCNT = MODE_0 | BG0_ENABLE; /* set up background 0 */ REG_BG0_PTR = BG_COLOR256 | TEXTBG_SIZE_256x256 | (31 << SCREEN_SHIFT) | WRAPAROUND; /* load the palette into background palette memory */ dma_memcpy((void*) test_palette, (void*) BG_PALETTE_MEMORY, 256, DMA_32_NOW); /* load the tile image into tile memory */ dma_memcpy((void*) test_data, (void*) CharBaseBlock(0), (test_width * test_height), DMA_16_NOW); /* copy the tile map itself into memory */ unsigned short* bg0map =(unsigned short*)ScreenBaseBlock(31); dma_memcpy((void*)testmap, (void*)bg0map, 1024, DMA_32_NOW); /* we now loop forever displaying the image */ while (1) { //D-pad moves background if(!(BUTTONS & BUTTON_LEFT)) x--; if(!(BUTTONS & BUTTON_RIGHT)) x++; if(!(BUTTONS & BUTTON_UP)) y--; if(!(BUTTONS & BUTTON_DOWN)) y++; // //wait for vertical refresh WaitVBlank(); //use hardware background scrolling REG_BG0VOFS = y ; REG_BG0HOFS = x ; int n; for(n = 0; n < 4000; n++); } }