gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Beginners > Wierd Looking sprites, Please help!

#19595 - telamon - Thu Apr 22, 2004 4:39 pm

Hello i'm a newcomer to this forum and the gbadev scene. I've been following the tutorials over at http://gbajunkie.co.uk and I have now begun to write my own code. Everything seems to work fine except for my sprite :(

I've searched the forum for people with similiar problems and did find a couple of post actually. But the only clue to the solution was a binarie called "spritestripper.exe" wich is nolonger accessible at it's former host due to an outdated post .

So to better understand my problem i made a debug image so that i maybe could understand wich pixels had went astray.
[Images not permitted - Click here to view it]

It's originally a 16x16 sprite. It's a bit resized so that you can see it better.
As you can see it seems like no pixels are missing, but most of them are wierdly dislocated. The dislocation pattern seems quite symmetrical so it could be fixed with a function i suppose, maybe that is what spritestripper.exe was supposed to do. Also, the palette loads just fine so i can exclude that from the list of suspects.

Now over to my loading functions.
I've tried swapping my debug sprite with the original tutorial sprite in the original tutorial code, It gave me the same error.
So i put it aside and continued to write other stuff on my own project. Yesterday i included VBFS into my project as it seemed to be quite a nice solution. And thus i've changed my loading function.
Code:

The original Tutorial sprite loader using data in header files

          for(loop = 0; loop < 384; loop++)       //load 1st sprite image data
   {
      OAMData[loop] = pacanimData[loop];
   }

+------------------------------------------------------------+
 my current loading function using data stored VBFS
   gbfs_copy_obj(OAMData , dat , "cursor2.raw");     //load 1st sprite image data


Whatever loading routine i tried i got the same result wheter my image was stored in a header or a raw binarie file. So i drew the conclusion that my loading wasn't errorneous.

the sprite attributes setup looks like this, it's unchanged from the original tutorial:
Code:

   sprites[0].attribute0 = COLOR_256 | SQUARE | cursor.y; //setup sprite info, 256 colour, shape and y-coord
   sprites[0].attribute1 = SIZE_16 | cursor.x;            //size 16x16 and x-coord
   sprites[0].attribute2 = 0;                             //pointer to tile where sprite starts


I've tried converting my picture to either header or raw with following 3 programs:
gfx2gba
gifs2sprites
pcx2gba

everyone of them gave me the same result.
I've tried recreating the image and saving it with Photoshop, Paint Shop Pro and Graphics Gale to formats of PCX, BMP and GIF.
And then converting them. But alas still the same result.
So i'm about to exclude my ways of creation/conversion too.

Please help me solve this, thanks!

#19601 - sajiimori - Thu Apr 22, 2004 7:05 pm

Use VisualBoyAdvance's tools to look at the sprite data, and verify that it looks the same as the screenshot (keeping in mind that it will be divided into 8x8 characters). View it as a 16 color and 256 color image.

Output your data in a human-readable format and see for yourself if the data is right.

If you see incorrect data in VBA's sprite RAM viewer, and you can tell the converted file is correct, then post a complete program. Try to make it as short and simple as possible. Use only a single 16x16 image, no background, no unused code, etc.

#19604 - telamon - Thu Apr 22, 2004 7:14 pm

ok thanx. i'll trie that. I had the same result when my code was in cryo stage and only had 1 sprite and nothing else.
Heh forgot vba had that kind of tools, they are indeed handy in my current situation.
Forgot to mention that using gfx2gba to convert graphics works just fine for me doing backgrounddata but sprites somehow get messed up. Maybe i've done some miscalculations on where i should load my first sprite.
_________________
http://manifested.ath.cx

#19607 - telamon - Thu Apr 22, 2004 8:33 pm

OK , i did a new debug sprite, this time it was far easier to see what was wrong.
not that it's solved -_- , just wrong. take a look for yourselves.
[Images not permitted - Click here to view it]
ed: Fig1: The way it supposed to be. Fig2: saved image via VBA OAM browser

It seems like it draws the horizontal row until it reaches the middle and then it continues drawing the data on the next row. What's more confuseing is that when it reaches the vertical middle it jumps over to the upper right section and continues to draw that block, It's as if it's drawing 4 small pictures
Code:

some ascii art:
| 1:1 | 1:2 |
| 2:1 | 2:2 |


First it draws the 1:1 block then 1:2 and continues with 2:1 .

Can this problem be somehow related to the doublebuffering? Since all my problems can be divided by 2.

I apologize if i misunderstood your directions sajimori. I'm a bit afraid of rewriteing the code as i don't have a clue of how to make an alternate way of accomplishing this.
_________________
http://manifested.ath.cx

#19608 - niltsair - Thu Apr 22, 2004 8:58 pm

The problem is that you're not using the right ouput parameters with your tool. It currently output the sprite as a simple bitmap (whole line by line). But they should actually be stored differently. Your image should be subdivided in 8x8pixels blocks. Check the correct parameters for this, since I don't know them offhand, with your sprite converter.

Here's an example of how it get sub divided
Code:
[b]From[/b]
0123456789ABCDEF
1111111111111111
2222222222222222
3333333333333333
4444444444444444
5555555555555555
6666666666666666
7777777777777777
8888888888888888
9999999999999999
AAAAAAAAAAAAAAAA
BBBBBBBBBBBBBBBB
CCCCCCCCCCCCCCCC
DDDDDDDDDDDDDDDD
EEEEEEEEEEEEEEEE
FFFFFFFFFFFFFFFF
[b]To[/b]

01234567 | 89ABCDEF
11111111 | 11111111
22222222 | 22222222
33333333 | 33333333
44444444 | 44444444
55555555 |55555555
66666666 |66666666
77777777 |77777777
----------------
88888888 | 88888888
99999999 | 99999999
AAAAAAAA | AAAAAAAA
BBBBBBBB | BBBBBBBB
CCCCCCCC | CCCCCCCC
DDDDDDDD | DDDDDDDD
EEEEEEEE | EEEEEEEE
FFFFFFFF | FFFFFFFF

In Memory:
01234567
11111111
22222222
33333333
44444444
55555555
66666666
77777777
89ABCDEF
11111111
22222222
33333333
44444444
55555555
66666666
77777777
88888888
99999999
AAAAAAAA
BBBBBBBB
CCCCCCCC
DDDDDDDD
EEEEEEEE
FFFFFFFF

_________________
-Inside every large program is a small program struggling to get out. (Hoare's Law of Large Programs)
-The man who can smile when things go wrong has thought of someone he can blame it on. (Nixon's Theorem)


Last edited by niltsair on Thu Apr 22, 2004 9:07 pm; edited 2 times in total

#19609 - telamon - Thu Apr 22, 2004 9:03 pm

Wow thanks alot! now i have a clue about where to look! =)
_________________
http://manifested.ath.cx

#19612 - telamon - Thu Apr 22, 2004 9:41 pm

Yep it worked =) with a little assistance from LordGraga.
the gfx2gba faq does actually mention this.
http://www.ohnehirn.de/tools/readme.txt
it's the -t flag
_________________
http://manifested.ath.cx

#20700 - ThePhoenix - Sat May 15, 2004 12:14 pm

I was just wondering how you DO transparency :P

#20706 - yaustar - Sat May 15, 2004 1:32 pm

depends on the tool. With gif2sprite, as you convert it to a gif, just set the colour you want to be transpereant to be transparent as a gif. Most often then not it be the first colour in the palette
_________________
[Blog] [Portfolio]

#20708 - telamon - Sat May 15, 2004 1:39 pm

The transparency depends on the first color in your palette. If you're not converting from gif , then just fire the pic up in paintshop pro or some other software that lets you edit your palette manually. I usually set my first color to #FF00FF , that eyehurting pink color i suppose. And ofcourse if you did't set the first color to pink before you begun makeing your pic you will probably have some pink pixels. You better get rid of those :)
_________________
http://manifested.ath.cx