From 414e76fd94edf6861977dc8a84d888d7236da732 Mon Sep 17 00:00:00 2001 From: Christian Gmeiner Date: Fri, 11 Sep 2009 21:00:57 +0200 Subject: also write color informations - we have a working < 5 bpp spu encoder now --- spuencoder.c | 19 ++++++++++++++++++- spuencoder.h | 1 + 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/spuencoder.c b/spuencoder.c index 13b4832..80ecc57 100644 --- a/spuencoder.c +++ b/spuencoder.c @@ -142,6 +142,21 @@ void cSpuEncoder::writeNibble(uint8_t val) } } +void cSpuEncoder::writeColorAndAlpha(sSection &sec, bool withCMD) +{ + if (withCMD) { + spu[written++] = CMD_SET_COLOR; + } + spu[written++] = (sec.colIndex[0] << 4) | (sec.colIndex[1] & 0x0f); + spu[written++] = (sec.colIndex[2] << 4) | (sec.colIndex[3] & 0x0f); + + if (withCMD) { + spu[written++] = CMD_SET_ALPHA; + } + spu[written++] = (opacity[sec.colIndex[3]] << 4) | (opacity[sec.colIndex[2]] & 0x0f); + spu[written++] = (opacity[sec.colIndex[1]] << 4) | (opacity[sec.colIndex[0]] & 0x0f); +} + void cSpuEncoder::generateColorPalette() { // we need to convert the color we get from @@ -228,7 +243,8 @@ void cSpuEncoder::generateSpuData(bool topAndBottom) throw (char const* ) spu[written++] = bottomStart >> 8; spu[written++] = bottomStart & 0xff; - // TODO write color-> palette index and alpha data + // write color-> palette index and alpha data for the first region + writeColorAndAlpha(regions.front()->sections[0], true); // 0xff: end sequence spu[written++] = 0xff; @@ -317,3 +333,4 @@ void cSpuEncoder::rle4colors() } } } + diff --git a/spuencoder.h b/spuencoder.h index dbeb833..7ef0b10 100644 --- a/spuencoder.h +++ b/spuencoder.h @@ -66,6 +66,7 @@ private: tColor palcolors[16]; void writeNibble(uint8_t val); + void writeColorAndAlpha(sSection &sec, bool withCMD); void generateColorPalette(); void generateSpuData(bool topAndBottom) throw (char const* ); -- cgit v1.2.3