Problem with images

Post Reply
Tong80
Posts: 4
Joined: Thu Oct 29, 2009 1:16 pm

Problem with images

Post by Tong80 » Thu Oct 29, 2009 1:22 pm

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

Sylus101
Posts: 179
Joined: Wed Dec 24, 2008 5:08 am

Re: Problem with images

Post by Sylus101 » Thu Oct 29, 2009 3:09 pm

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
-Sylus "Not Stylus..." McFrederickson

Come visit my web site.

Tong80
Posts: 4
Joined: Thu Oct 29, 2009 1:16 pm

Re: Problem with images

Post by Tong80 » Thu Oct 29, 2009 4:11 pm

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 :)

User avatar
vuurrobin
Posts: 219
Joined: Fri Jul 11, 2008 8:49 pm
Location: The Netherlands
Contact:

Re: Problem with images

Post by vuurrobin » Thu Oct 29, 2009 4:34 pm

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.

Tong80
Posts: 4
Joined: Thu Oct 29, 2009 1:16 pm

Re: Problem with images

Post by Tong80 » Thu Oct 29, 2009 4:44 pm

That was it!
Many thanks, i wasted so many hours on this problem!

acehs
Posts: 1
Joined: Wed Dec 09, 2009 8:40 am

Re: Problem with images

Post by acehs » Wed Dec 09, 2009 11:30 am

nice one , the same problems I've seen.

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests