Get palette index of a sprite pixel

Post Reply
ex-peluo
Posts: 19
Joined: Wed Apr 15, 2009 10:44 pm

Get palette index of a sprite pixel

Post by ex-peluo » Sun Apr 19, 2009 2:08 am

Hi, I'm trying to get palette index of a sprite. SpriteMapping_1D_128 means sprite are saved in "squares" of 8x8 pixels each one. I have a pointer to the sprite allocation in Vram. If I want to get palette index for pixel (1,9) (first row, column nine), i must get it using pointer[64] isn't i?? (Is the element 65, but array index begins at 0 8) )
I don't know i am mistaken. Can somebody help me??
If this is correct, I have a second problem. In animated simple sprite example, sprite information is stored in a u16 collection of data, but this data is copied to Vram using a u8 pointer. If palette made of 256 colors, i need a u8 type to save a number between 0 and 255. Why in that example take tiles of sprite with a u16 (for 0 to 256 palette index) and after that copy it using a u8 pointer?. Thanks

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

Re: Get palette index of a sprite pixel

Post by Sylus101 » Sun Apr 19, 2009 6:15 am

It'd be more like pixel 0,8 but yes, that would be the 64th index value. I learned about this while writing a sprite drawing app, so I'm sure this is correct with a 1D format of sprites.

oamAllocateGfx returns a u16 pointer because the value stored is a vram memory address and vram memory addresses are 16 bit values. There's no problem in the dmaCopy because the pointer to the source, 8 bit values, and pointer to the destination don't have to be the same size/type.
-Sylus "Not Stylus..." McFrederickson

Come visit my web site.

ex-peluo
Posts: 19
Joined: Wed Apr 15, 2009 10:44 pm

Re: Get palette index of a sprite pixel

Post by ex-peluo » Sun Apr 19, 2009 2:27 pm

Thanks to solve my doubt. I were trying to show in the screen the index of a pixel and I use an u16 pointer, but this makes m show 16 bits, so i get the value of two pixels together :S. Now it works well, i get the pixel position with an u8* and show its value with an u8. Thanks !!!!

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 2 guests