WedNESday wrote:
THAT HAPPY FACE IS AN 8! lol
There's a "disable smilies in this post" checkbox for just that thing ;P
But anyway... I use lookup tables to avoid some math during rendering. Here's some snippits from my code.
Lookup tables built once on startup:
Code:
s32 i;
for(i = 0; i < 0x0400; i++)
{
nAttrSft[i] = (u8)(((i >> 4) & 0x04) | ((i ) & 0x02) );
nAttrOft[i] = (u16)(((i >> 2) & 0x07) | ((i >> 4) & 0x38) | 0x03C0 );
}
nAttrSft is the number of times you have to shift the attribute byte right in order to get the 2 desired bits in the LSB positions. It will always be either 0, 2, 4, or 6
nAttrOft is the offset of the desired attribute byte (0x3C0 - 0x3FF)
used during rendering with the following.
'namepage' is a pointer to the proper nametable.
Code:
ad = nPPUAddr & 0x3FF;
at = ((namepage[nAttrOft[ad]] >> nAttrSft[ad]) & 3) << 2;
'at' is the final desired attribute data... 0x00, 0x04, 0x08, or 0x0C