mirror of https://github.com/stella-emu/stella.git
Pre-process 24-bit pixel colour info for software rendering in UI
and normal TIA modes. Phosphor TIA mode is still done the old way, since I'd have to create a 192KB lookup table otherwise. Hopefully this will speed up 24-bit rendering in most cases, but I still can't confirm as I'm testing in VirtualBox, which itself is emulating 24-bit colour mode. In the last commit, I mentioned I could possibly speed things up a little. This is it (and likely as far as I can go). git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1671 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
968853c646
commit
b2c6f6fbfd
|
@ -13,7 +13,7 @@
|
||||||
// See the file "license" for information on usage and redistribution of
|
// See the file "license" for information on usage and redistribution of
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// 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 <sstream>
|
#include <sstream>
|
||||||
|
@ -210,20 +210,9 @@ void FrameBufferSoft::drawTIA(bool fullRedraw)
|
||||||
|
|
||||||
if(v != w || fullRedraw)
|
if(v != w || fullRedraw)
|
||||||
{
|
{
|
||||||
uInt8 a, b, c;
|
uInt8 a = myDefPalette24[v][0],
|
||||||
uInt32 pixel = myDefPalette[v];
|
b = myDefPalette24[v][1],
|
||||||
if(SDL_BYTEORDER == SDL_LIL_ENDIAN)
|
c = myDefPalette24[v][2];
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
while(xstride--)
|
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
|
// 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* buffer = (uInt8*)getBasePtr(tx + bbx, ty + desc.ascent - bby - bbh);
|
||||||
|
|
||||||
uInt8 a, b, c;
|
uInt8 a = myFB.myDefPalette24[color][0],
|
||||||
uInt32 pixel = myFB.myDefPalette[color];
|
b = myFB.myDefPalette24[color][1],
|
||||||
if(SDL_BYTEORDER == SDL_LIL_ENDIAN)
|
c = myFB.myDefPalette24[color][2];
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(int y = 0; y < bbh; y++, buffer += myPitch)
|
for(int y = 0; y < bbh; y++, buffer += myPitch)
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
// See the file "license" for information on usage and redistribution of
|
// See the file "license" for information on usage and redistribution of
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// 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 <algorithm>
|
#include <algorithm>
|
||||||
|
@ -510,7 +510,6 @@ uInt32 FrameBuffer::tiaPixel(uInt32 idx) const
|
||||||
return (!myUsePhosphor ? myDefPalette[c] : myAvgPalette[c][p]);
|
return (!myUsePhosphor ? myDefPalette[c] : myAvgPalette[c][p]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void FrameBuffer::setTIAPalette(const uInt32* palette)
|
void FrameBuffer::setTIAPalette(const uInt32* palette)
|
||||||
{
|
{
|
||||||
|
@ -524,6 +523,18 @@ void FrameBuffer::setTIAPalette(const uInt32* palette)
|
||||||
Uint8 b = palette[i] & 0xff;
|
Uint8 b = palette[i] & 0xff;
|
||||||
|
|
||||||
myDefPalette[i] = mapRGB(r, g, b);
|
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
|
// Set palette for phosphor effect
|
||||||
|
@ -553,12 +564,25 @@ void FrameBuffer::setTIAPalette(const uInt32* palette)
|
||||||
void FrameBuffer::setUIPalette(const uInt32* palette)
|
void FrameBuffer::setUIPalette(const uInt32* palette)
|
||||||
{
|
{
|
||||||
// Set palette for GUI
|
// 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 r = (palette[i] >> 16) & 0xff;
|
||||||
Uint8 g = (palette[i] >> 8) & 0xff;
|
Uint8 g = (palette[i] >> 8) & 0xff;
|
||||||
Uint8 b = palette[i] & 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;
|
myIdx = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
// See the file "license" for information on usage and redistribution of
|
// See the file "license" for information on usage and redistribution of
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// 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
|
#ifndef FRAMEBUFFER_HXX
|
||||||
|
@ -91,7 +91,7 @@ enum {
|
||||||
into FBSurfaces), are in turn drawn here as well.
|
into FBSurfaces), are in turn drawn here as well.
|
||||||
|
|
||||||
@author Stephen Anthony
|
@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
|
class FrameBuffer
|
||||||
{
|
{
|
||||||
|
@ -425,8 +425,12 @@ class FrameBuffer
|
||||||
|
|
||||||
// TIA palettes for normal and phosphor modes
|
// TIA palettes for normal and phosphor modes
|
||||||
// 'myDefPalette' also contains the UI palette
|
// '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 myDefPalette[256+kNumColors];
|
||||||
Uint32 myAvgPalette[256][256];
|
Uint32 myAvgPalette[256][256];
|
||||||
|
Uint8 myDefPalette24[256+kNumColors][3];
|
||||||
|
|
||||||
// Names of the TIA filters that can be used for this framebuffer
|
// Names of the TIA filters that can be used for this framebuffer
|
||||||
StringMap myTIAFilters;
|
StringMap myTIAFilters;
|
||||||
|
@ -563,7 +567,7 @@ class FrameBuffer
|
||||||
FrameBuffer type.
|
FrameBuffer type.
|
||||||
|
|
||||||
@author Stephen Anthony
|
@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()
|
// Text alignment modes for drawString()
|
||||||
enum TextAlignment {
|
enum TextAlignment {
|
||||||
|
|
Loading…
Reference in New Issue