Sunday, 12 July 2015

Bitplane-mode/"attached" sprites working in multi-colour mode

... but not in mono-mode.

In the last couple of posts I have written about my plan for having a bitplane mode for sprites. What this means is that a sprite can be set to modify the colour of the pixels it touches instead of just painting with its own colour(s).

This can be used to do a few different things.  First, you can set the bitplane mode on one or more sprites, and have them modify the colours of a "normal mode" sprite, so that only the appearance of the first sprite will change (assuming you make the bitplane-mode sprite(s) only have bits set inside the first sprite).  But you can also have sprites that all have the bitplane mode enabled, in which case they will modify the colour of the character/bitmap/background pixels behind them instead.  This is what I do here, but lets do things in order.

First, I enabled a couple of 64x100 pixel sprites, using $0400-$07ff as the data source. I spaced them slightly.  Because bitplane sprite mode currently only works in multi-colour mode, I have put the sprites in multi-colour mode, and so we can see the three colours in each sprite (white, red, black and pink), of which two are in common (black and pink):

Next I turn on bitplane mode for one of the sprites: Now we can see that it is modifying the colours behind it, whether those colours are from a sprite or from the rest of the display.

The extra colours are all the result of fiddling with a couple of the bits in the colour.
Now if we enable bitplane mode on both those sprites, we can see the same thing happening, but with more of the bits being fiddled, so we can see more colours where the two sprites overlap:

Okay, so using random junk for the sprites isn't really the best demonstration, so I filled the sprites with solid data, and did much the same thing:

Remember that the above display is all on a blue background, with only yellow text.  All other colours are the result of having the two bitplane mode sprites over the top modifying the colours.  One is modifying bits 0 and 1, and the other is modifying bits 2 and 3.  If I had more time I could have animated them to show the effect better. Another day.

Each sprite in bitplane mode will modify a specific bit or bits in the pixel colour. In mono mode (hires sprites), the bit is the number of the sprite. In multi-colour mode, it is a pair of bits, with sprite 0 modifying bits 0 and 1, sprite 1 bits 2 and 3, sprite 4 bits 0 and 1 again and so on.

Next step is to get it working for mono/hires sprites. I think I have found the bug, and am resynthesising it now. I was reading the wrong bit from the sprite colour data vector, which was always zero.  This came about because I use the same 128-bit vector for mono and multi-colour sprites, and just pad the upper bit of each two-bit colour select in mono/hires mode.  Hopefully in a few days I will have an updated post showing hires bitplane mode sprites, and perhaps after that I will write some simple little demo that has an animated set of bitplane mode sprites that causes an area of the screen to be dimmed or something like that.

No comments:

Post a Comment