256colour Translucency


Eek. Reencoding to 5bit would be a bit useless, since all the sprites in my game are 4bit. o.o

I suppose I could add 4096 bytes per sprite animation set that needs transparency, but what about sprites that need both solid colours and translucency? The way I see it I could do this:

Use all 16 colours in the palette for the sprite (gives me one more colour to work with!) and create a 2bit mask for transparency:
0 = Don't draw this pixel.
1 = Draw this pixel translucent.
2 = Draw this pixel in full.
3 = WASTED VALUE (I seriously don't know how to use this bit)

and on loading the sprite, it loads up into an array parallel to the spritedata, so that:

Code:
if (sprite.maskdata[i] ==0)  i++;
else if (sprite.maskdata[i] ==1) DrawPixelTranslucent (sprite.spritedata[i], x,y); i++;
else if (sprite.maskdata[i] ==2) DrawPixel (sprite.spritedata[i], x,y); i++;

4096+1280 (640*2. Maskdata will take up as much space as spritedata) bytes definately isn't enough to slow down the cache with swapping, so... awesome ensues. I suppose when reading an array, it's loaded into the cache, and arrays which are >16k would require constant swapping? Or am I totally clueless to how the cache works?

Well, now that I've sorted that out, I must go program it! Rawr!
 
Back
Top