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.

Graphics > Transparency in software

#11158 - regularkid - Sat Sep 27, 2003 6:52 pm

I'm drawing stuff to the screen in mode 4 (256 color palettized) without the use of sprites (just straight up video buffer access). However, I would like to do transparency as well, but I don't want it to be horrendously slow. So first off, my drawing code will be in RAM using ARM assembly. However, it will still be slow if I use an 'if' for every pixel to check if it is palette index 0 before drawing it. I was thinking I could use a masking technique, but that would require loading the pixel currently already in the video buffer and then doing some sort of bitwise operations on it using the pixel I want to draw, which might just be as slow as an 'if'. Anyone have any ideas on how to do quick transparency in code? Thanks!
_________________
- RegularKid

#11159 - tepples - Sat Sep 27, 2003 7:11 pm

For each sprite cel, store the positions all the horizontal lines of opaque pixels and blit just those. Take an example from the Allegro library's RLE Sprite mechanism. For mode 4, you're still going to have to do bitwise operations because 1. byte writes don't work and 2. unaligned writes don't work.

Is there a specific reason preventing you from using hardware sprites?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.