Sprite tiles are scrambled

Post Reply
DayTripperID
Posts: 22
Joined: Tue Aug 07, 2012 8:57 pm

Sprite tiles are scrambled

Post by DayTripperID » Mon Aug 13, 2012 4:22 pm

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

mtheall
Posts: 210
Joined: Thu Feb 03, 2011 10:47 pm

Re: Sprite tiles are scrambled

Post by mtheall » Wed Aug 15, 2012 10:31 pm

Your code works fine for me. You must be exporting your graphics incorrectly. Did you make sure to export as tiled and not bitmapped?

DayTripperID
Posts: 22
Joined: Tue Aug 07, 2012 8:57 pm

Re: Sprite tiles are scrambled

Post by DayTripperID » Thu Aug 16, 2012 8:21 pm

Fixed. I had map data included in the export. Worked perfectly when I re exported the png.

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests