#5829 - TurboHz - Fri May 09, 2003 3:31 pm
When I set the x position of an sprite to a negative number, the value wraps to the right, so -1 becomes 254. This is alright.
But the sprite disappears of the left side, instead of being partially shown, as I expected to happen. Is that normal? How can I achieve what I'm trying to do?
I mean having the sprite being (partially) shown until it's completely out of screen (by the left side).
#5831 - niltsair - Fri May 09, 2003 3:46 pm
You'll have to use 2 sprites, i'm affraid.
The screen can display 240 pixels width pixels.
The sprite use 255x255 coordinates.
So in order for your sprite to be showed partially to the right, the minimum is X(239). Assuming your sprite is 8x8, it means it'll cover from X(239-247) so you dont quite reach a X>(255).
So you'll need to do soemthing a bit like this :
1.Pos of Sprite X(235) (let's assuem it's 235)
2.OnScreen X= 240-235 = 5
3.PixelMissing = SizeSprite - 5
4.Create another sprite
5.Pos of new Sprite = -PixelMissing
Or the like, it's just on the top of my head. There might be another solution. The same will apply for the Y Coordinate, screen is 160pixels high, Sprite use 255Pixels Coordinates.
#5834 - Sweex - Fri May 09, 2003 4:39 pm
I haven't got any GBA documentation around but if I remember it right, then the X position register is not 8 bits, but 10 or 12. So maybe there is something wrong between your internal X position and the one that you set in the register?
(If you set it to -1/254 it will be somewhere outside the right side of the screen. It should be set to a bigger value to be shown partially on the left, lets say like 1023 or 4095...)
Shout out if this doesn't help you... I've got documentation at home...
#5835 - niltsair - Fri May 09, 2003 4:59 pm
He is able to display a sprite on the right side, partially.
You are right about X coord though, it use 1024pixels(10bits).
What he is unable to achieve, is to show, say half of it on the left, and the other half on the right. And this is because they use 1024pixels Coordinate while the screen can only display 240.
#5838 - TurboHz - Fri May 09, 2003 5:59 pm
Actually, I don't care about the right side of the screen... but how can I see if is there a sprite beyond 240, if that's the visible limit of the screen? I know it's there, 'cos VBA OAM viewer says so.
I'm just interested in the left side of the screen, so I think I won't need 2 sprites. The sprite is 32x32. And as soon as the first pixel leaves the screen by the left the whole sprite disappears.
The x coordinates for sprites are 9 bits.
Extracted from Cowbite specs:
"Note on coordinates: The values actually wrap around. To achieve a -1 x, use x = 511".
Well. Finally I found out what was wrong! I was masking to allow only 8 bits and since x coord has 9 bits.. well that's why -1 became 254 instead of 511. DOH!
thanx to you guys!