Discussion about software development for the old-school Gameboys, ranging from the "Gray brick" to Gameboy Color
(Launched in 2008)
You are not logged in.
Well I was playing with sprite flags, and as I'm not a very skilled programer I found some difficulties.
/* Sprite properties bits (0x00) PALETTE NUBER 0x0_ // being "_" = 0-7 FLIPX 0x20 FLIPY 0x40 BEHIND BKG 0x80 */ //gbdk usage set_sprite_prop(spritenumber,0x00);
Now I want sprite 0 to use palette 1 and flip it around X axis:
set_sprite_prop(0,0x01); set_sprite_prop(0,0x20);
That will reset the palette to 0 so:
set_sprite_prop(0,0x21);
That flips it and sets palette 1, so I can mix the flip x and palette properties just fine.
Then imagine I want to set the sprite behind the last 3 colours of the bkg palettes:
set_sprite_prop(0,0x21); set_sprite_prop(0,0x81);
I just can't do it this way, because the flip x flag will be reset to 0, so the sprite will go behind the bkg, but with wrong flip.
What's the proper way to add these properties? Do I have to use assembly to mix them?.
Last edited by Mills (2017-09-29 11:03:59)
Offline
I believe this is what you're after:
set_sprite_prop(0,0xA1);
0x01 + 0x20 + 0x80 = 0xA1
Offline
tbsp wrote:
I believe this is what you're after:
Code:
set_sprite_prop(0,0xA1);0x01 + 0x20 + 0x80 = 0xA1
I was about to try that, But I din't think it wiould work that way (it worked).
Thanks.
Offline
It would be 0x01 | 0x20 | 0x80 rather than "+" (0x21 | 0x81 == 0xA1, 0x21 | 0x81 = 0xA2 != 0xA1). Hope you see the point.
(His answer is still right, in this case)
Offline
Sure, if you're trying to combine 0x21 and 0x81 that's true. | is certainly a more robust way to think about it.
Offline