Page 1 of 1

Problem with images

Posted: Thu Oct 29, 2009 1:22 pm
by Tong80
Hello,

I have a problem with 16x16 images.

I am doing the following:

Code: Select all

		videoSetModeSub(MODE_0_2D);
		vramSetBankD(VRAM_D_SUB_SPRITE);
		oamInit(&oamSub, SpriteMapping_1D_32, false);
		
		u16* gfx = oamAllocateGfx(&oamSub, SpriteSize_16x16, SpriteColorFormat_256Color);
		
		dmaCopy(tweedeePal, SPRITE_PALETTE_SUB, 512);
		dmaCopyHalfWords(2,tweedeeTiles+(32*(8*0)), gfx, 16*16);
while(true)
{
		oamSet(&oamSub, //main graphics engine context
			0,           //oam index (0 to 127)  
			5, 5,   //x and y pixle location of the sprite
			0,                    //priority, lower renders last (on top)
			0,					  //this is the palette index if multiple palettes or the alpha value if bmp sprite	
			SpriteSize_16x16,     
			SpriteColorFormat_256Color, 
			gfx,                  //pointer to the loaded graphics
			-1,                  //sprite rotation data  
			false,               //double the size when rotating?
			false,			//hide the sprite?
			false, false, //vflip, hflip
			false	//apply mosaic
			);
		swiWaitForVBlank();
		oamUpdate(&oamSub);
}
The 16x16 picture i am loding is a part of a much bigger picture. But when i run this, i get a 16x16 picture of half the picture i wanted and half the next picture :S

What am i doing wrong? I think it is something with the dmaCopy, but i don't know what. I tried to use dmaCopy, dmaCopyWord and dmaCopyHalfWord but they all gave me the same strange output :S.

Image
This picture shows the problem.

I used grit to convert the image tweedee.png.

Code: Select all

-m!
-gB8
#metatile
-Mh4
-Mw4

Re: Problem with images

Posted: Thu Oct 29, 2009 3:09 pm
by Sylus101
What you're running into is the fact that sprite graphics are tiled. When you do what you're doing here, you're getting these blocks from your image:

Image

Re: Problem with images

Posted: Thu Oct 29, 2009 4:11 pm
by Tong80
Is there an easy solution to get the one image i want?
Or is the easiest way to just copy the first part and then change the pointer to the lower half of the image and copy that part?

Thanks for your response :)

Re: Problem with images

Posted: Thu Oct 29, 2009 4:34 pm
by vuurrobin

Code: Select all

#metatile
-Mh4
-Mw4
your metatiles are 2*2 'normal' tiles, but here you say that a metatile is 4*4 'normal' tiles.

if you change this to 2*2, then I think that the problem will be fixed.

Re: Problem with images

Posted: Thu Oct 29, 2009 4:44 pm
by Tong80
That was it!
Many thanks, i wasted so many hours on this problem!

Re: Problem with images

Posted: Wed Dec 09, 2009 11:30 am
by acehs
nice one , the same problems I've seen.