<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>
Date   : Tue, 26 Sep 2000 13:44:30 +0100
From   : "Rich Talbot-Watkins" <Richard_Watkins@...>
Subject: Re: Font Implosion / Explosions?

Yes, I understand the problem now - basically, how does the OS convert the
1bpp character bitmaps to a form which can be plotted in any bpp mode in any
foreground and background colour?

OK here's my take on this:

For 1bpp modes, one character line fits into one byte of screen memory.  For
2bpp or 4bpp modes, we are going to need 2 or 4 bytes respectively.  The idea
is that first we need to 'expand' the character bitmap data to fill all the
bits available for colours in these higher bpp modes.

So, for 1bpp modes:

* byte 0 of screen = byte of character line data (simple)

for 2bpp modes: [A = 1bpp character line data]

* byte 0 of screen = bits 4-7 of A, also copied into bits 0-3
* byte 1 of screen = bits 0-3 of A, also copied into bits 4-7

and for 4bpp modes: [A = 1bpp character line data]

* byte 0 of screen = bits 6-7 of A, also copied into 4-5, 2-3 and 0-1.
* byte 1 of screen = bits 4-5 of A, also copied into 6-7, 2-3 and 0-1.
* byte 2 of screen = bits 2-3 of A, also copied into 6-7, 4-5 and 0-1.
* byte 3 of screen = bits 0-1 of A, also copied into 6-7, 4-5 and 2-3.

As you can see, this is not very generic: I'd imagine the OS would have
separate code for these three cases, as I'm not quite sure how tables would
particularly help (unless they were very big).

Now we can plot the character in any mode with background colour 0, and
foreground colour 1, 3 or 15 (for 1bpp, 2bpp and 4bpp respectively).

In order to get different foreground and background colours, we do something
like the following little bit of pseudocode:

a = (scrndata EOR &FF) AND background
b = scrndata AND foreground
a = a OR b
write a to screen.

scrndata is the byte we just built.  Obviously we do this for all the bytes
which make up the character row in the screen mode we're in.

foreground and background are values which would set all the pixels in the
screen byte to be the desired colour.

With reference to the AUG as well, you should hopefully be able to make some
sense of all this!

I don't think a game like Chuckie Egg will be using OS routines to do this
kind of thing though - I think it's probably a more simple case of it stores
its sprites in a 1bpp format too (perhaps because the Spectrum version did)
and uses similar algorithms to those above to convert it into a monochrome
Mode 2 sprite.

cheers,
Rich :)
Rich Talbot-Watkins
Sony Computer Entertainment Europe, Cambridge.
Richard_Watkins@...
<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>