Page 1 of 1

Get palette index of a sprite pixel

Posted: Sun Apr 19, 2009 2:08 am
by ex-peluo
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

Re: Get palette index of a sprite pixel

Posted: Sun Apr 19, 2009 6:15 am
by Sylus101
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.

Re: Get palette index of a sprite pixel

Posted: Sun Apr 19, 2009 2:27 pm
by ex-peluo
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 !!!!