void PA_LoadRotBgMap(u8 screen, u8 bg_select, void* bg_map, u8 bg_size) { s16 charset = -1; u8 charsetok = 0; u8 blocksize = rotbg_place[bg_size]; u8 i; u8 tempsize; rotbg_size[screen][bg_select] = bg_size; // Save rot bg size (values 0-3 for 128, 256, 512 and 1024) PA_DeleteMap(screen, bg_select); while ((charset < 31 ) && (!charsetok)) { ++charset; tempsize = blocksize; for(i = 0; i < blocksize; i++) { if (charblocks[screen][charset + i] == 0) { // Si on a de la place... --tempsize; } } charsetok = !tempsize; // Si on a trouvé suffisament de blocs, on peut continuer } PA_BgInfo[screen][bg_select].mapchar = charset; // On place la map à un endroit précis... PA_BgInfo[screen][bg_select].mapsize = blocksize; DMA_Copy(bg_map, (void*)ScreenBaseBlock(screen, charset), rotbg_sizes[bg_size], DMA_16NOW); for (i = 0; i < blocksize; i++) charblocks[screen][charset + i] = 1; // Les blocs sont occupés }
/* 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++); } }
unsigned short angle = 0; int mapLeft = 0, mapRight = 255, screenLeft = 0, screenRight = 239, nextColumn = 0, prevColumn = 0; int mapTop = 0, mapBottom = 255, screenTop = 0, screenBottom = 159, nextRow = 0, prevRow = 0; int moveRight = 0, moveLeft = 0, moveDown = 0, moveUp = 0; int prevX, prevY ,spaceX, spaceY, movedLeft, movedRight, movedUp, movedDown, rotate, numSprites, numAffSprites, affIndex, currentLeftX_C, currentRightX_C, currentTopY_C, currentBottomY_C, numEnemies, mx, my; int laserOffset = 3; int laserYOffset = 4; int counterFixedPointX = 0; int counterFixedPointY = 0; int timeSeed, randSet, enemiesKilled; int DtoROffset = 180/PI; unsigned short* bg0map =(unsigned short*)ScreenBaseBlock(31); SpriteHandler sprites[128]; Sprite Sprites[128]; OBJ_AFFINE *const obj_aff_buffer = (OBJ_AFFINE*)Sprites; void CopyColumnToBackground(int column, int copyToColumn, int topRow, int bottomRow, const unsigned short* source, unsigned short* dest, int sourceColumns) { int row; column /= 8; copyToColumn %= 32; topRow /= 8; bottomRow /= 8;
void GraphicsManager::DisplayTile(uint16_t x, uint16_t y, uint8_t tile, uint16_t screenBB) { uint16_t* ScreenBB = (uint16_t*)ScreenBaseBlock(screenBB); ScreenBB[x + (32 * y)] = tile; }