Page 1 of 1

Sprite tiles are scrambled

Posted: Mon Aug 13, 2012 4:22 pm
by DayTripperID
Can someone check this code and see what I did wrong? It is a 32 by 32 sprite, converted with wingrit to 4bpp.

Code: Select all

include <nds.h>
include "sprite.h"

int main(){

    vramSetBankB(VRAM_B_MAIN_SPRITE);
    videoSetMode(MODE_0_2D);

    OamState *oam = &oamMain;
    oamInit(oam, SpriteMapping_1D_32, false);

    u16* gfx = oamAllocateGfx(oam, SpriteSize_32x32, SpriteColorFormat_16Color);

    oamSet (oam,                                 //oam
	        0,                                     //id
                0,                                     //x
	        0,                                     //y
                0,                                     //priority
                0,                                     //palette_alpha
                SpriteSize_32x32,               //size
                SpriteColorFormat_16Color,  //format
                gfx,                                 //gfxOffset
                -1,                                  //affine index 
                false,                               //sizeDouble
                false,                               //hide
                false,                               //hflip
                false,                               //vflip
                false);                              //mosaic
                      
			
     dmaCopy(spriteTiles, oamGetGfxPtr(oam, 0), sizeof(spriteTiles));
     dmaCopy(spritePal, SPRITE_PALETTE, sizeof(spritePal));

     while(true){
     swiWaitForVBlank();
     oamUpdate(oam);
     }
}
Here is a screenshot.
[img]
http://postimage.org/image/tdwqziu3p/e332470c/
[/img]
The sprite is the jumbled mess with the light blue background. I turned off its transparency to better illustrate the shape.

It SHOULD look like this:
[img]
http://postimage.org/image/ixl8axkh1/7caa177c/
[/img]

Any help is greatly appreciated! :D

Re: Sprite tiles are scrambled

Posted: Wed Aug 15, 2012 10:31 pm
by mtheall
Your code works fine for me. You must be exporting your graphics incorrectly. Did you make sure to export as tiled and not bitmapped?

Re: Sprite tiles are scrambled

Posted: Thu Aug 16, 2012 8:21 pm
by DayTripperID
Fixed. I had map data included in the export. Worked perfectly when I re exported the png.