diff --git a/stella/src/common/FrameBufferSoft.cxx b/stella/src/common/FrameBufferSoft.cxx index e6dc6cca6..f0fc11600 100644 --- a/stella/src/common/FrameBufferSoft.cxx +++ b/stella/src/common/FrameBufferSoft.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: FrameBufferSoft.cxx,v 1.95 2009-02-05 23:22:54 stephena Exp $ +// $Id: FrameBufferSoft.cxx,v 1.96 2009-02-06 23:53:34 stephena Exp $ //============================================================================ #include @@ -210,20 +210,9 @@ void FrameBufferSoft::drawTIA(bool fullRedraw) if(v != w || fullRedraw) { - uInt8 a, b, c; - uInt32 pixel = myDefPalette[v]; - if(SDL_BYTEORDER == SDL_LIL_ENDIAN) - { - a = (pixel & myFormat->Bmask) >> myFormat->Bshift; - b = (pixel & myFormat->Gmask) >> myFormat->Gshift; - c = (pixel & myFormat->Rmask) >> myFormat->Rshift; - } - else - { - a = (pixel & myFormat->Rmask) >> myFormat->Rshift; - b = (pixel & myFormat->Gmask) >> myFormat->Gshift; - c = (pixel & myFormat->Bmask) >> myFormat->Bshift; - } + uInt8 a = myDefPalette24[v][0], + b = myDefPalette24[v][1], + c = myDefPalette24[v][2]; while(xstride--) { @@ -638,20 +627,9 @@ void FBSurfaceSoft::drawChar(const GUI::Font* font, uInt8 chr, // Get buffer position where upper-left pixel of the character will be drawn uInt8* buffer = (uInt8*)getBasePtr(tx + bbx, ty + desc.ascent - bby - bbh); - uInt8 a, b, c; - uInt32 pixel = myFB.myDefPalette[color]; - if(SDL_BYTEORDER == SDL_LIL_ENDIAN) - { - a = (pixel & myFB.myFormat->Bmask) >> myFB.myFormat->Bshift; - b = (pixel & myFB.myFormat->Gmask) >> myFB.myFormat->Gshift; - c = (pixel & myFB.myFormat->Rmask) >> myFB.myFormat->Rshift; - } - else - { - a = (pixel & myFB.myFormat->Rmask) >> myFB.myFormat->Rshift; - b = (pixel & myFB.myFormat->Gmask) >> myFB.myFormat->Gshift; - c = (pixel & myFB.myFormat->Bmask) >> myFB.myFormat->Bshift; - } + uInt8 a = myFB.myDefPalette24[color][0], + b = myFB.myDefPalette24[color][1], + c = myFB.myDefPalette24[color][2]; for(int y = 0; y < bbh; y++, buffer += myPitch) { diff --git a/stella/src/emucore/FrameBuffer.cxx b/stella/src/emucore/FrameBuffer.cxx index a12aa8b71..fd7d7c243 100644 --- a/stella/src/emucore/FrameBuffer.cxx +++ b/stella/src/emucore/FrameBuffer.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: FrameBuffer.cxx,v 1.164 2009-02-01 22:17:09 stephena Exp $ +// $Id: FrameBuffer.cxx,v 1.165 2009-02-06 23:53:34 stephena Exp $ //============================================================================ #include @@ -510,7 +510,6 @@ uInt32 FrameBuffer::tiaPixel(uInt32 idx) const return (!myUsePhosphor ? myDefPalette[c] : myAvgPalette[c][p]); } - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void FrameBuffer::setTIAPalette(const uInt32* palette) { @@ -524,6 +523,18 @@ void FrameBuffer::setTIAPalette(const uInt32* palette) Uint8 b = palette[i] & 0xff; myDefPalette[i] = mapRGB(r, g, b); + if(SDL_BYTEORDER == SDL_LIL_ENDIAN) + { + myDefPalette24[i][0] = b; + myDefPalette24[i][1] = g; + myDefPalette24[i][2] = r; + } + else + { + myDefPalette24[i][0] = r; + myDefPalette24[i][1] = g; + myDefPalette24[i][2] = b; + } } // Set palette for phosphor effect @@ -553,12 +564,25 @@ void FrameBuffer::setTIAPalette(const uInt32* palette) void FrameBuffer::setUIPalette(const uInt32* palette) { // Set palette for GUI - for(int i = 0; i < kNumColors-256; ++i) + for(int i = 0, j = 256; i < kNumColors-256; ++i, ++j) { Uint8 r = (palette[i] >> 16) & 0xff; Uint8 g = (palette[i] >> 8) & 0xff; Uint8 b = palette[i] & 0xff; - myDefPalette[i+256] = mapRGB(r, g, b); + + myDefPalette[j] = mapRGB(r, g, b); + if(SDL_BYTEORDER == SDL_LIL_ENDIAN) + { + myDefPalette24[j][0] = b; + myDefPalette24[j][1] = g; + myDefPalette24[j][2] = r; + } + else + { + myDefPalette24[j][0] = r; + myDefPalette24[j][1] = g; + myDefPalette24[j][2] = b; + } } } @@ -1078,7 +1102,7 @@ void FrameBuffer::VideoModeList::set(const GraphicsMode& gfxmode) } } - // Finally, just pick the lowes video mode + // Finally, just pick the lowest video mode myIdx = 0; } diff --git a/stella/src/emucore/FrameBuffer.hxx b/stella/src/emucore/FrameBuffer.hxx index fd9b74f45..d6f854142 100644 --- a/stella/src/emucore/FrameBuffer.hxx +++ b/stella/src/emucore/FrameBuffer.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: FrameBuffer.hxx,v 1.117 2009-01-24 17:32:29 stephena Exp $ +// $Id: FrameBuffer.hxx,v 1.118 2009-02-06 23:53:34 stephena Exp $ //============================================================================ #ifndef FRAMEBUFFER_HXX @@ -91,7 +91,7 @@ enum { into FBSurfaces), are in turn drawn here as well. @author Stephen Anthony - @version $Id: FrameBuffer.hxx,v 1.117 2009-01-24 17:32:29 stephena Exp $ + @version $Id: FrameBuffer.hxx,v 1.118 2009-02-06 23:53:34 stephena Exp $ */ class FrameBuffer { @@ -425,8 +425,12 @@ class FrameBuffer // TIA palettes for normal and phosphor modes // 'myDefPalette' also contains the UI palette + // The '24' version of myDefPalette is used in 24-bit colour mode, + // eliminates having to deal with endian and shift issues + // Phosphor mode doesn't have a corresponding Uint32 myDefPalette[256+kNumColors]; Uint32 myAvgPalette[256][256]; + Uint8 myDefPalette24[256+kNumColors][3]; // Names of the TIA filters that can be used for this framebuffer StringMap myTIAFilters; @@ -563,7 +567,7 @@ class FrameBuffer FrameBuffer type. @author Stephen Anthony - @version $Id: FrameBuffer.hxx,v 1.117 2009-01-24 17:32:29 stephena Exp $ + @version $Id: FrameBuffer.hxx,v 1.118 2009-02-06 23:53:34 stephena Exp $ */ // Text alignment modes for drawString() enum TextAlignment {