mirror of https://github.com/stella-emu/stella.git
Moved some more redundant code from the SDL child classes to the
parent class. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@229 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
eddc10294d
commit
8524727d42
|
@ -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: FrameBufferGL.cxx,v 1.12 2003-12-06 00:17:29 stephena Exp $
|
||||
// $Id: FrameBufferGL.cxx,v 1.13 2003-12-10 18:58:56 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <SDL.h>
|
||||
|
@ -86,24 +86,6 @@ bool FrameBufferGL::createScreen()
|
|||
return true;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void FrameBufferGL::setupPalette(float shade)
|
||||
{
|
||||
const uInt32* gamePalette = myMediaSource->palette();
|
||||
for(uInt32 i = 0; i < 256; ++i)
|
||||
{
|
||||
Uint8 r, g, b;
|
||||
|
||||
r = (Uint8) (((gamePalette[i] & 0x00ff0000) >> 16) * shade);
|
||||
g = (Uint8) (((gamePalette[i] & 0x0000ff00) >> 8) * shade);
|
||||
b = (Uint8) ((gamePalette[i] & 0x000000ff) * shade);
|
||||
|
||||
myPalette[i] = SDL_MapRGB(myTexture->format, r, g, b);
|
||||
}
|
||||
|
||||
theRedrawEntireFrameIndicator = true;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool FrameBufferGL::init()
|
||||
{
|
||||
|
@ -212,7 +194,7 @@ bool FrameBufferGL::init()
|
|||
|
||||
// Set up the palette *after* we know the color components
|
||||
// and the textures
|
||||
setupPalette(1.0);
|
||||
setupPalette();
|
||||
|
||||
// Show some OpenGL info
|
||||
if(myConsole->settings().getBool("showinfo"))
|
||||
|
|
|
@ -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: FrameBufferGL.hxx,v 1.6 2003-11-30 03:36:51 stephena Exp $
|
||||
// $Id: FrameBufferGL.hxx,v 1.7 2003-12-10 18:58:56 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef FRAMEBUFFER_GL_HXX
|
||||
|
@ -34,7 +34,7 @@ class MediaSource;
|
|||
This class implements an SDL OpenGL framebuffer.
|
||||
|
||||
@author Stephen Anthony
|
||||
@version $Id: FrameBufferGL.hxx,v 1.6 2003-11-30 03:36:51 stephena Exp $
|
||||
@version $Id: FrameBufferGL.hxx,v 1.7 2003-12-10 18:58:56 stephena Exp $
|
||||
*/
|
||||
class FrameBufferGL : public FrameBufferSDL
|
||||
{
|
||||
|
@ -64,12 +64,6 @@ class FrameBufferGL : public FrameBufferSDL
|
|||
*/
|
||||
virtual bool createScreen();
|
||||
|
||||
/**
|
||||
Set up the palette for a screen of any depth > 8.
|
||||
Scales the palette by 'shade'.
|
||||
*/
|
||||
virtual void setupPalette(float shade);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// The following methods are derived from 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: FrameBufferSDL.cxx,v 1.9 2003-12-04 22:22:53 stephena Exp $
|
||||
// $Id: FrameBufferSDL.cxx,v 1.10 2003-12-10 18:58:56 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <SDL.h>
|
||||
|
@ -36,7 +36,8 @@ FrameBufferSDL::FrameBufferSDL()
|
|||
theGrabMouseIndicator(false),
|
||||
theHideCursorIndicator(false),
|
||||
theAspectRatio(1.0),
|
||||
isFullscreen(false)
|
||||
isFullscreen(false),
|
||||
myPauseStatus(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -48,13 +49,34 @@ FrameBufferSDL::~FrameBufferSDL()
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void FrameBufferSDL::pauseEvent(bool status)
|
||||
{
|
||||
// Shade the palette to 75% normal value in pause mode
|
||||
if(status)
|
||||
setupPalette(0.75);
|
||||
else
|
||||
setupPalette(1.0);
|
||||
myPauseStatus = status;
|
||||
setupPalette();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void FrameBufferSDL::setupPalette()
|
||||
{
|
||||
// Shade the palette to 75% normal value in pause mode
|
||||
float shade = 1.0;
|
||||
if(myPauseStatus)
|
||||
shade = 0.75;
|
||||
|
||||
const uInt32* gamePalette = myMediaSource->palette();
|
||||
for(uInt32 i = 0; i < 256; ++i)
|
||||
{
|
||||
Uint8 r, g, b;
|
||||
|
||||
r = (Uint8) (((gamePalette[i] & 0x00ff0000) >> 16) * shade);
|
||||
g = (Uint8) (((gamePalette[i] & 0x0000ff00) >> 8) * shade);
|
||||
b = (Uint8) ((gamePalette[i] & 0x000000ff) * shade);
|
||||
|
||||
myPalette[i] = SDL_MapRGB(myScreen->format, r, g, b);
|
||||
}
|
||||
|
||||
theRedrawEntireFrameIndicator = true;
|
||||
}
|
||||
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void FrameBufferSDL::toggleFullscreen()
|
||||
{
|
||||
|
|
|
@ -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: FrameBufferSDL.hxx,v 1.8 2003-12-03 18:11:25 stephena Exp $
|
||||
// $Id: FrameBufferSDL.hxx,v 1.9 2003-12-10 18:58:56 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef FRAMEBUFFER_SDL_HXX
|
||||
|
@ -34,7 +34,7 @@
|
|||
the core FrameBuffer.
|
||||
|
||||
@author Stephen Anthony
|
||||
@version $Id: FrameBufferSDL.hxx,v 1.8 2003-12-03 18:11:25 stephena Exp $
|
||||
@version $Id: FrameBufferSDL.hxx,v 1.9 2003-12-10 18:58:56 stephena Exp $
|
||||
*/
|
||||
class FrameBufferSDL : public FrameBuffer
|
||||
{
|
||||
|
@ -97,6 +97,11 @@ class FrameBufferSDL : public FrameBuffer
|
|||
*/
|
||||
void setWindowAttributes();
|
||||
|
||||
/**
|
||||
Set up the palette for a screen of any depth > 8.
|
||||
*/
|
||||
void setupPalette();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// The following methods are derived from FrameBuffer.hxx
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
@ -116,12 +121,6 @@ class FrameBufferSDL : public FrameBuffer
|
|||
*/
|
||||
virtual bool createScreen() = 0;
|
||||
|
||||
/**
|
||||
Set up the palette for a screen of any depth > 8.
|
||||
Scales the palette by 'shade'.
|
||||
*/
|
||||
virtual void setupPalette(float shade) = 0;
|
||||
|
||||
protected:
|
||||
// The SDL video buffer
|
||||
SDL_Surface* myScreen;
|
||||
|
@ -155,6 +154,9 @@ class FrameBufferSDL : public FrameBuffer
|
|||
|
||||
// Indicates whether the game is currently in fullscreen
|
||||
bool isFullscreen;
|
||||
|
||||
// Indicates whether the emulation has paused
|
||||
bool myPauseStatus;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -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.4 2003-12-03 18:11:25 stephena Exp $
|
||||
// $Id: FrameBufferSoft.cxx,v 1.5 2003-12-10 18:58:56 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <SDL.h>
|
||||
|
@ -56,24 +56,6 @@ bool FrameBufferSoft::createScreen()
|
|||
return true;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void FrameBufferSoft::setupPalette(float shade)
|
||||
{
|
||||
const uInt32* gamePalette = myMediaSource->palette();
|
||||
for(uInt32 i = 0; i < 256; ++i)
|
||||
{
|
||||
Uint8 r, g, b;
|
||||
|
||||
r = (Uint8) (((gamePalette[i] & 0x00ff0000) >> 16) * shade);
|
||||
g = (Uint8) (((gamePalette[i] & 0x0000ff00) >> 8) * shade);
|
||||
b = (Uint8) ((gamePalette[i] & 0x000000ff) * shade);
|
||||
|
||||
myPalette[i] = SDL_MapRGB(myScreen->format, r, g, b);
|
||||
}
|
||||
|
||||
theRedrawEntireFrameIndicator = true;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool FrameBufferSoft::init()
|
||||
{
|
||||
|
@ -121,7 +103,7 @@ bool FrameBufferSoft::init()
|
|||
// Create the screen
|
||||
if(!createScreen())
|
||||
return false;
|
||||
setupPalette(1.0);
|
||||
setupPalette();
|
||||
|
||||
// Make sure that theUseFullScreenFlag sets up fullscreen mode correctly
|
||||
theGrabMouseIndicator = myConsole->settings().getBool("grabmouse");
|
||||
|
|
|
@ -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.hxx,v 1.1 2003-11-09 23:53:20 stephena Exp $
|
||||
// $Id: FrameBufferSoft.hxx,v 1.2 2003-12-10 18:58:56 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef FRAMEBUFFER_SOFT_HXX
|
||||
|
@ -35,7 +35,7 @@ class RectList;
|
|||
This class implements an SDL software framebuffer.
|
||||
|
||||
@author Stephen Anthony
|
||||
@version $Id: FrameBufferSoft.hxx,v 1.1 2003-11-09 23:53:20 stephena Exp $
|
||||
@version $Id: FrameBufferSoft.hxx,v 1.2 2003-12-10 18:58:56 stephena Exp $
|
||||
*/
|
||||
class FrameBufferSoft : public FrameBufferSDL
|
||||
{
|
||||
|
@ -59,12 +59,6 @@ class FrameBufferSoft : public FrameBufferSDL
|
|||
*/
|
||||
virtual bool createScreen();
|
||||
|
||||
/**
|
||||
Set up the palette for a screen of any depth > 8.
|
||||
Scales the palette by 'shade'.
|
||||
*/
|
||||
virtual void setupPalette(float shade);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// The following methods are derived from 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: mainSDL.cxx,v 1.66 2003-12-06 00:17:29 stephena Exp $
|
||||
// $Id: mainSDL.cxx,v 1.67 2003-12-10 18:58:56 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <fstream>
|
||||
|
@ -399,12 +399,12 @@ void handleEvents()
|
|||
else if(key == SDLK_f) // Ctrl-f toggles NTSC/PAL mode
|
||||
{
|
||||
theConsole->toggleFormat();
|
||||
theDisplay->setupPalette(1.0);
|
||||
theDisplay->setupPalette();
|
||||
}
|
||||
else if(key == SDLK_p) // Ctrl-p toggles different palettes
|
||||
{
|
||||
theConsole->togglePalette();
|
||||
theDisplay->setupPalette(1.0);
|
||||
theDisplay->setupPalette();
|
||||
}
|
||||
else if(key == SDLK_END) // Ctrl-End increases Width
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue