#117826 - pmcc - Wed Feb 07, 2007 10:31 pm
Hey,
I started homebrew development a few days ago and I'm stuck on sprites. Like the title of this thread says, my sprite is not showing up on my DS / Dualis / no$gba but IT DOES in desmume...I'm trying to figure out what's wrong with my code and it's driving me crazy for 2 days now :).
I'm using devkitPro and libnds.
Here's some portions of my code :
Well...like I said it shows up perfectly on desmume. I've checked first sprite entry in dualis and everything is ok (size, colors, etc) but it doesn't display the sprite preview...
Kudos to anyone that can help me on this one !
Thanks.
_________________
www.gotrooted.net
I started homebrew development a few days ago and I'm stuck on sprites. Like the title of this thread says, my sprite is not showing up on my DS / Dualis / no$gba but IT DOES in desmume...I'm trying to figure out what's wrong with my code and it's driving me crazy for 2 days now :).
I'm using devkitPro and libnds.
Here's some portions of my code :
Code: |
powerON(POWER_ALL_2D); // Map vram, one bg and sprite banks for each core vramSetMainBanks(VRAM_A_MAIN_BG, VRAM_B_MAIN_SPRITE, VRAM_C_SUB_BG, VRAM_D_SUB_SPRITE); // Set video mode to mode 0 (0,1,2,3 -> text) with sprites support eng.SetVideoMode(MODE_0_2D | DISPLAY_SPR_ACTIVE | DISPLAY_SPR_1D_LAYOUT); eng.SetSubVideoMode(MODE_0_2D | DISPLAY_SPR_ACTIVE | DISPLAY_SPR_1D_LAYOUT); // Enable main and sub background 1 eng.EnableBackground(1); eng.EnableSubBackground(1); // Load palette into memory eng.LoadPalette(tilesetPal); eng.LoadSubPalette(tilesetPal); // Set main background 1 eng.SetBackgroundTileBase(1, 0); eng.SetBackgroundMapBase(1, 30); eng.SetBackgroundColors(1, BG_COLOR_256); // Set sub background 1 eng.SetSubBackgroundTileBase(1, 1); eng.SetSubBackgroundMapBase(1, 31); eng.SetSubBackgroundColors(1, BG_COLOR_256); // Copy our tiles data into memory where the hardware is expecting them dmaCopy(tilesetTiles, (void*)CHAR_BASE_BLOCK(0), sizeof (tilesetTiles)); dmaCopy(tilesetTiles, (void*)CHAR_BASE_BLOCK_SUB(1), sizeof (tilesetTiles)); // Copy one half of the map in each screen memory for (int i = 0; i < 768; ++i) { ((u16*)SCREEN_BASE_BLOCK(30))[i] = test_map[i]; ((u16*)SCREEN_BASE_BLOCK_SUB(31))[i] = test_map[i + 768]; } eng.InitOAM(); // temp code... SpriteEntry* sprites = eng.GetSprites(); sprites[0].attribute[0] = ATTR0_COLOR_16 | ATTR0_SQUARE | OBJ_Y(50); sprites[0].attribute[1] = ATTR1_SIZE_8 | OBJ_X(50); // temp code... for (int i = 0; i < sizeof (ballPal); ++i) { SPRITE_PALETTE[i] = ballPal[i]; } for (int i = 0; i < sizeof (ballTiles); ++i) { SPRITE_GFX[i] = ballTiles[i]; } while(1) { swiWaitForVBlank(); dmaCopy(eng.GetSprites(), OAM, 1024); dmaCopy(eng.GetSubSprites(), OAM_SUB, 1024); } void CEngine::InitOAM() { m_sprites = new SpriteEntry[128]; m_spritesRotation = reinterpret_cast<SpriteRotation*>(m_sprites); m_spritesSub = new SpriteEntry[128]; m_spritesRotationSub = reinterpret_cast<SpriteRotation*>(m_spritesSub); for (int i = 0; i < 128; ++i) { m_sprites[i].attribute[0] = ATTR0_DISABLED; m_sprites[i].attribute[1] = 0; m_sprites[i].attribute[2] = 0; m_spritesSub[i].attribute[0] = ATTR0_DISABLED; m_spritesSub[i].attribute[1] = 0; m_spritesSub[i].attribute[2] = 0; } for (int i = 0; i < 32; ++i) { m_spritesRotation[i].hdx = 256; m_spritesRotation[i].hdy = 0; m_spritesRotation[i].vdx = 0; m_spritesRotation[i].vdy = 256; m_spritesRotationSub[i].hdx = 256; m_spritesRotationSub[i].hdy = 0; m_spritesRotationSub[i].vdx = 0; m_spritesRotationSub[i].vdy = 256; } } |
Well...like I said it shows up perfectly on desmume. I've checked first sprite entry in dualis and everything is ok (size, colors, etc) but it doesn't display the sprite preview...
Kudos to anyone that can help me on this one !
Thanks.
_________________
www.gotrooted.net