mirror of https://github.com/stella-emu/stella.git
First pass at adding the z26 'phosphor effect', which is used in 30Hz
ROMs to eliminate flicker. Right now is disabled by default, and when enabled only works in OpenGL mode. It's not yet configurable either, so it's either on or off. It looks like crap on ROMs that don't need it, but is really nice for those that do. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@947 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
24aa8c782f
commit
a4d5738767
|
@ -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: FrameBufferGL.cxx,v 1.43 2005-09-15 19:43:36 stephena Exp $
|
// $Id: FrameBufferGL.cxx,v 1.44 2006-01-10 02:09:33 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#ifdef DISPLAY_OPENGL
|
#ifdef DISPLAY_OPENGL
|
||||||
|
@ -231,7 +231,9 @@ void FrameBufferGL::drawMediaSource()
|
||||||
{
|
{
|
||||||
const uInt32 bufofs = bufofsY + x;
|
const uInt32 bufofs = bufofsY + x;
|
||||||
uInt8 v = currentFrame[bufofs];
|
uInt8 v = currentFrame[bufofs];
|
||||||
if(v != previousFrame[bufofs] || theRedrawTIAIndicator)
|
uInt8 w = previousFrame[bufofs];
|
||||||
|
|
||||||
|
if(v != w || theRedrawTIAIndicator)
|
||||||
{
|
{
|
||||||
// If we ever get to this point, we know the current and previous
|
// If we ever get to this point, we know the current and previous
|
||||||
// buffers differ. In that case, make sure the changes are
|
// buffers differ. In that case, make sure the changes are
|
||||||
|
@ -241,6 +243,7 @@ void FrameBufferGL::drawMediaSource()
|
||||||
// x << 1 is times 2 ( doubling width )
|
// x << 1 is times 2 ( doubling width )
|
||||||
const uInt32 pos = screenofsY + (x << 1);
|
const uInt32 pos = screenofsY + (x << 1);
|
||||||
buffer[pos] = buffer[pos+1] = (uInt16) myPalette[v];
|
buffer[pos] = buffer[pos+1] = (uInt16) myPalette[v];
|
||||||
|
// buffer[pos] = buffer[pos+1] = (uInt16) myAvgPalette[v][w];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.69 2006-01-08 02:28:03 stephena Exp $
|
// $Id: FrameBuffer.cxx,v 1.70 2006-01-10 02:09:34 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
@ -256,17 +256,38 @@ void FrameBuffer::pause(bool status)
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void FrameBuffer::setPalette(const uInt32* palette)
|
void FrameBuffer::setPalette(const uInt32* palette)
|
||||||
{
|
{
|
||||||
for(uInt32 i = 0; i < 256; ++i)
|
int i, j;
|
||||||
{
|
|
||||||
Uint8 r, g, b;
|
|
||||||
|
|
||||||
r = (Uint8) ((palette[i] & 0x00ff0000) >> 16);
|
// Set palette for normal fill
|
||||||
g = (Uint8) ((palette[i] & 0x0000ff00) >> 8);
|
for(i = 0; i < 256; ++i)
|
||||||
b = (Uint8) (palette[i] & 0x000000ff);
|
{
|
||||||
|
Uint8 r = (Uint8) ((palette[i] & 0x00ff0000) >> 16);
|
||||||
|
Uint8 g = (Uint8) ((palette[i] & 0x0000ff00) >> 8);
|
||||||
|
Uint8 b = (Uint8) (palette[i] & 0x000000ff);
|
||||||
|
|
||||||
myPalette[i] = mapRGB(r, g, b);
|
myPalette[i] = mapRGB(r, g, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set palette for phosphor effect
|
||||||
|
for(i = 0; i < 256; ++i)
|
||||||
|
{
|
||||||
|
for(j = 0; j < 256; ++j)
|
||||||
|
{
|
||||||
|
uInt8 ri = (uInt8) ((palette[i] & 0x00ff0000) >> 16);
|
||||||
|
uInt8 gi = (uInt8) ((palette[i] & 0x0000ff00) >> 8);
|
||||||
|
uInt8 bi = (uInt8) (palette[i] & 0x000000ff);
|
||||||
|
uInt8 rj = (uInt8) ((palette[j] & 0x00ff0000) >> 16);
|
||||||
|
uInt8 gj = (uInt8) ((palette[j] & 0x0000ff00) >> 8);
|
||||||
|
uInt8 bj = (uInt8) (palette[j] & 0x000000ff);
|
||||||
|
|
||||||
|
Uint8 r = (Uint8) getPhosphor(ri, rj);
|
||||||
|
Uint8 g = (Uint8) getPhosphor(gi, gj);
|
||||||
|
Uint8 b = (Uint8) getPhosphor(bi, bj);
|
||||||
|
|
||||||
|
myAvgPalette[i][j] = mapRGB(r, g, b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
theRedrawTIAIndicator = true;
|
theRedrawTIAIndicator = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -626,6 +647,17 @@ void FrameBuffer::drawString(const GUI::Font* font, const string& s,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
uInt8 FrameBuffer::getPhosphor(uInt8 c1, uInt8 c2)
|
||||||
|
{
|
||||||
|
int PHOSPHOR = 77; // FIXME - make this configurable
|
||||||
|
|
||||||
|
if(c2 > c1)
|
||||||
|
SWAP(c1, c2);
|
||||||
|
|
||||||
|
return ((c1 - c2) * PHOSPHOR)/100 + c2;
|
||||||
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
const uInt8 FrameBuffer::ourGUIColors[kNumColors-256][3] = {
|
const uInt8 FrameBuffer::ourGUIColors[kNumColors-256][3] = {
|
||||||
{ 104, 104, 104 }, // kColor
|
{ 104, 104, 104 }, // kColor
|
||||||
|
|
|
@ -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.60 2006-01-08 02:28:03 stephena Exp $
|
// $Id: FrameBuffer.hxx,v 1.61 2006-01-10 02:09:34 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#ifndef FRAMEBUFFER_HXX
|
#ifndef FRAMEBUFFER_HXX
|
||||||
|
@ -51,7 +51,7 @@ enum FrameStyle {
|
||||||
All GUI elements (ala ScummVM) are drawn here as well.
|
All GUI elements (ala ScummVM) are drawn here as well.
|
||||||
|
|
||||||
@author Stephen Anthony
|
@author Stephen Anthony
|
||||||
@version $Id: FrameBuffer.hxx,v 1.60 2006-01-08 02:28:03 stephena Exp $
|
@version $Id: FrameBuffer.hxx,v 1.61 2006-01-10 02:09:34 stephena Exp $
|
||||||
*/
|
*/
|
||||||
class FrameBuffer
|
class FrameBuffer
|
||||||
{
|
{
|
||||||
|
@ -191,7 +191,7 @@ class FrameBuffer
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Calculate the maximum window size that the current screen can hold.
|
Calculate the maximum window size that the current screen can hold.
|
||||||
Only works in X11/Win32 for now, otherwise always return 4.
|
If not supported by platform, always return 4.
|
||||||
*/
|
*/
|
||||||
uInt32 maxWindowSizeForScreen();
|
uInt32 maxWindowSizeForScreen();
|
||||||
|
|
||||||
|
@ -421,9 +421,12 @@ class FrameBuffer
|
||||||
// SDL initialization flags
|
// SDL initialization flags
|
||||||
uInt32 mySDLFlags;
|
uInt32 mySDLFlags;
|
||||||
|
|
||||||
// SDL palette
|
// SDL palette, with the first 256 colors representing normal fill
|
||||||
Uint32 myPalette[kNumColors];
|
Uint32 myPalette[kNumColors];
|
||||||
|
|
||||||
|
// SDL palette representing phosphor effect
|
||||||
|
Uint32 myAvgPalette[256][256];
|
||||||
|
|
||||||
// Indicates the current zoom level of the SDL screen
|
// Indicates the current zoom level of the SDL screen
|
||||||
uInt32 theZoomLevel;
|
uInt32 theZoomLevel;
|
||||||
|
|
||||||
|
@ -450,6 +453,16 @@ class FrameBuffer
|
||||||
*/
|
*/
|
||||||
void drawMessage();
|
void drawMessage();
|
||||||
|
|
||||||
|
/**
|
||||||
|
Used to calculate an averaged color for the 'phosphor' effect.
|
||||||
|
|
||||||
|
@param c1 Color 1
|
||||||
|
@param c2 Color 2
|
||||||
|
|
||||||
|
@return Averaged value of the two colors
|
||||||
|
*/
|
||||||
|
uInt8 getPhosphor(uInt8 c1, uInt8 c2);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Indicates the current framerate of the system
|
// Indicates the current framerate of the system
|
||||||
uInt32 myFrameRate;
|
uInt32 myFrameRate;
|
||||||
|
|
Loading…
Reference in New Issue