Some palette/framebuffer updates, and some work on making pause state

be in only one class (vs. spread over three like it is now).  I'm
sure the code is broken on every platform but Linux; I'll get to it.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1065 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2006-03-24 19:59:52 +00:00
parent 8fa78c60c3
commit f89d7d71e3
9 changed files with 100 additions and 81 deletions

View File

@ -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.58 2006-03-18 00:00:30 stephena Exp $
// $Id: FrameBufferGL.cxx,v 1.59 2006-03-24 19:59:52 stephena Exp $
//============================================================================
#ifdef DISPLAY_OPENGL
@ -343,7 +343,7 @@ void FrameBufferGL::drawMediaSource()
// are drawn in postFrameUpdate()
myDirtyFlag = true;
buffer[pos] = buffer[pos+1] = (uInt16) myPalette[v];
buffer[pos] = buffer[pos+1] = (uInt16) myDefTIAPalette[v];
}
pos += 2;
}
@ -370,8 +370,8 @@ void FrameBufferGL::drawMediaSource()
uInt8 v = currentFrame[bufofs];
uInt8 w = previousFrame[bufofs];
buffer[pos++] = (uInt16) myAvgPalette[v][w];
buffer[pos++] = (uInt16) myAvgPalette[v][w];
buffer[pos++] = (uInt16) myAvgTIAPalette[v][w];
buffer[pos++] = (uInt16) myAvgTIAPalette[v][w];
}
bufofsY += width;
screenofsY += myTexture->w;
@ -454,7 +454,7 @@ void FrameBufferGL::hLine(uInt32 x, uInt32 y, uInt32 x2, OverlayColor color)
{
uInt16* buffer = (uInt16*) myTexture->pixels + y * myTexture->w + x;
while(x++ <= x2)
*buffer++ = (uInt16) myPalette[color];
*buffer++ = (uInt16) myGUIPalette[color];
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -463,7 +463,7 @@ void FrameBufferGL::vLine(uInt32 x, uInt32 y, uInt32 y2, OverlayColor color)
uInt16* buffer = (uInt16*) myTexture->pixels + y * myTexture->w + x;
while(y++ <= y2)
{
*buffer = (uInt16) myPalette[color];
*buffer = (uInt16) myGUIPalette[color];
buffer += myTexture->w;
}
}
@ -479,7 +479,7 @@ void FrameBufferGL::fillRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h,
tmp.y = y;
tmp.w = w;
tmp.h = h;
SDL_FillRect(myTexture, &tmp, myPalette[color]);
SDL_FillRect(myTexture, &tmp, myGUIPalette[color]);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -512,7 +512,7 @@ void FrameBufferGL::drawChar(const GUI::Font* FONT, uInt8 chr,
for(int x = 0; x < w; ++x, mask >>= 1)
{
if(ptr & mask)
buffer[x] = (uInt16) myPalette[color];
buffer[x] = (uInt16) myGUIPalette[color];
}
buffer += myTexture->w;
}
@ -530,7 +530,7 @@ void FrameBufferGL::drawBitmap(uInt32* bitmap, Int32 tx, Int32 ty,
for(int x = 0; x < 8; ++x, mask >>= 4)
{
if(bitmap[y] & mask)
buffer[x] = (uInt16) myPalette[color];
buffer[x] = (uInt16) myGUIPalette[color];
}
buffer += myTexture->w;
}

View File

@ -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.50 2006-03-18 00:00:30 stephena Exp $
// $Id: FrameBufferSoft.cxx,v 1.51 2006-03-24 19:59:52 stephena Exp $
//============================================================================
#include <SDL.h>
@ -220,7 +220,7 @@ void FrameBufferSoft::drawMediaSource()
temp.h = active.height * screenMultiple;
myRectList->add(&temp);
SDL_FillRect(myScreen, &temp, myPalette[active.color]);
SDL_FillRect(myScreen, &temp, myDefTIAPalette[active.color]);
++activeIndex;
}
@ -238,7 +238,7 @@ void FrameBufferSoft::drawMediaSource()
temp.h = active.height * screenMultiple;
myRectList->add(&temp);
SDL_FillRect(myScreen, &temp, myPalette[active.color]);
SDL_FillRect(myScreen, &temp, myDefTIAPalette[active.color]);
}
// We can now make the current rectangles into the active rectangles
@ -263,7 +263,7 @@ void FrameBufferSoft::drawMediaSource()
temp.h = active.height * screenMultiple;
myRectList->add(&temp);
SDL_FillRect(myScreen, &temp, myPalette[active.color]);
SDL_FillRect(myScreen, &temp, myDefTIAPalette[active.color]);
}
break; // case 0
}
@ -296,8 +296,8 @@ void FrameBufferSoft::drawMediaSource()
while(xstride--)
{
buffer[pos++] = (uInt16) myAvgPalette[v][w];
buffer[pos++] = (uInt16) myAvgPalette[v][w];
buffer[pos++] = (uInt16) myAvgTIAPalette[v][w];
buffer[pos++] = (uInt16) myAvgTIAPalette[v][w];
}
}
screenofsY += myPitch;
@ -335,14 +335,14 @@ void FrameBufferSoft::drawMediaSource()
uInt8 r, g, b;
if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
{
uInt32 pixel = myAvgPalette[v][w];
uInt32 pixel = myAvgTIAPalette[v][w];
b = pixel & 0xff;
g = (pixel & 0xff00) >> 8;
r = (pixel & 0xff0000) >> 16;
}
else
{
uInt32 pixel = myAvgPalette[v][w];
uInt32 pixel = myAvgTIAPalette[v][w];
r = pixel & 0xff;
g = (pixel & 0xff00) >> 8;
b = (pixel & 0xff0000) >> 16;
@ -389,8 +389,8 @@ void FrameBufferSoft::drawMediaSource()
while(xstride--)
{
buffer[pos++] = (uInt32) myAvgPalette[v][w];
buffer[pos++] = (uInt32) myAvgPalette[v][w];
buffer[pos++] = (uInt32) myAvgTIAPalette[v][w];
buffer[pos++] = (uInt32) myAvgTIAPalette[v][w];
}
}
screenofsY += myPitch;
@ -496,7 +496,7 @@ void FrameBufferSoft::hLine(uInt32 x, uInt32 y, uInt32 x2, OverlayColor color)
tmp.y = y * theZoomLevel;
tmp.w = (x2 - x + 1) * theZoomLevel;
tmp.h = theZoomLevel;
SDL_FillRect(myScreen, &tmp, myPalette[color]);
SDL_FillRect(myScreen, &tmp, myGUIPalette[color]);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -509,7 +509,7 @@ void FrameBufferSoft::vLine(uInt32 x, uInt32 y, uInt32 y2, OverlayColor color)
tmp.y = y * theZoomLevel;
tmp.w = theZoomLevel;
tmp.h = (y2 - y + 1) * theZoomLevel;
SDL_FillRect(myScreen, &tmp, myPalette[color]);
SDL_FillRect(myScreen, &tmp, myGUIPalette[color]);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -523,7 +523,7 @@ void FrameBufferSoft::fillRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h,
tmp.y = y * theZoomLevel;
tmp.w = w * theZoomLevel;
tmp.h = h * theZoomLevel;
SDL_FillRect(myScreen, &tmp, myPalette[color]);
SDL_FillRect(myScreen, &tmp, myGUIPalette[color]);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -559,7 +559,7 @@ void FrameBufferSoft::drawChar(const GUI::Font* FONT, uInt8 chr,
rect.x = (x + xorig) * theZoomLevel;
rect.y = (y + yorig) * theZoomLevel;
rect.w = rect.h = theZoomLevel;
SDL_FillRect(myScreen, &rect, myPalette[color]);
SDL_FillRect(myScreen, &rect, myGUIPalette[color]);
}
}
}
@ -581,7 +581,7 @@ void FrameBufferSoft::drawBitmap(uInt32* bitmap, Int32 xorig, Int32 yorig,
rect.x = (x + xorig) * theZoomLevel;
rect.y = (y + yorig) * theZoomLevel;
rect.w = rect.h = theZoomLevel;
SDL_FillRect(myScreen, &rect, myPalette[color]);
SDL_FillRect(myScreen, &rect, myGUIPalette[color]);
}
}
}

View File

@ -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: EventHandler.cxx,v 1.155 2006-03-18 00:00:30 stephena Exp $
// $Id: EventHandler.cxx,v 1.156 2006-03-24 19:59:52 stephena Exp $
//============================================================================
#include <sstream>
@ -162,8 +162,7 @@ void EventHandler::reset(State state)
myPauseFlag = false;
myQuitFlag = false;
myOSystem->frameBuffer().pause(myPauseFlag);
myOSystem->sound().mute(myPauseFlag);
pause(false);
myEvent->clear();
if(myState == S_LAUNCHER)
@ -216,6 +215,16 @@ void EventHandler::refreshDisplay(bool forceUpdate)
// cerr << " ==> State change = " << myState << endl;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::pause(bool status)
{
cerr << "EventHandler::pause(): " << status << endl;
myPauseFlag = status;
myOSystem->frameBuffer().handlePause(myPauseFlag);
myOSystem->sound().mute(myPauseFlag);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::setupJoysticks()
{
@ -1167,11 +1176,7 @@ void EventHandler::handleEvent(Event::Type event, int state)
case Event::Pause:
if(state)
{
myPauseFlag = !myPauseFlag;
myOSystem->frameBuffer().pause(myPauseFlag);
myOSystem->sound().mute(myPauseFlag);
}
pause(!myPauseFlag);
return;
case Event::LauncherMode:

View File

@ -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: EventHandler.hxx,v 1.81 2006-03-18 00:00:30 stephena Exp $
// $Id: EventHandler.hxx,v 1.82 2006-03-24 19:59:52 stephena Exp $
//============================================================================
#ifndef EVENTHANDLER_HXX
@ -107,7 +107,7 @@ struct JoyMouse {
mapping can take place.
@author Stephen Anthony
@version $Id: EventHandler.hxx,v 1.81 2006-03-18 00:00:30 stephena Exp $
@version $Id: EventHandler.hxx,v 1.82 2006-03-24 19:59:52 stephena Exp $
*/
class EventHandler
{
@ -215,19 +215,24 @@ class EventHandler
void refreshDisplay(bool forceUpdate = false);
/**
This method indicates whether a pause event has been received.
This method pauses the entire emulator.
*/
inline bool doPause() { return myPauseFlag; }
void pause(bool status);
/**
This method indicates whether a quit event has been received.
This method indicates whether a pause event has been received.
*/
inline bool doQuit() { return myQuitFlag; }
inline bool isPaused() { return myPauseFlag; }
/**
This method indicates that the system should terminate.
*/
inline void quit() { handleEvent(Event::Quit, 1); }
void quit() { handleEvent(Event::Quit, 1); }
/**
This method indicates whether a quit event has been received.
*/
inline bool isQuit() { return myQuitFlag; }
/**
Save state to explicit state number (debugger uses this)

View File

@ -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.83 2006-03-19 18:17:48 stephena Exp $
// $Id: FrameBuffer.cxx,v 1.84 2006-03-24 19:59:52 stephena Exp $
//============================================================================
#include <sstream>
@ -122,8 +122,8 @@ void FrameBuffer::initialize(const string& title, uInt32 width, uInt32 height,
myOSystem->eventHandler().refreshDisplay();
// Set palette for GUI
for(int i = 0; i < kNumColors-256; i++)
myPalette[i+256] = mapRGB(ourGUIColors[i][0], ourGUIColors[i][1], ourGUIColors[i][2]);
for(int i = 0; i < kNumColors; i++)
myGUIPalette[i] = mapRGB(ourGUIColors[i][0], ourGUIColors[i][1], ourGUIColors[i][2]);
// Set emulation palette if a console exists
// Used when entering/exiting debugger
@ -333,46 +333,53 @@ inline void FrameBuffer::drawMessage()
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBuffer::pause(bool status)
void FrameBuffer::handlePause(bool status)
{
cerr << "FrameBuffer::handlePause(): " << status << endl;
myPauseStatus = status;
// Enable the paused palette
if(&myOSystem->console())
{
enablePhosphor(myOSystem->console().properties().get(Display_Phosphor) == "YES");
setPalette(myOSystem->console().mediaSource().palette());
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBuffer::setPalette(const uInt32* palette)
{
// Account for pause mode
float shade = myPauseStatus ? 0.65 : 1.0;
int i, j;
// Set palette for normal fill
for(i = 0; i < 256; ++i)
{
Uint8 r = (Uint8) ((palette[i] & 0x00ff0000) >> 16);
Uint8 g = (Uint8) ((palette[i] & 0x0000ff00) >> 8);
Uint8 b = (Uint8) (palette[i] & 0x000000ff);
Uint8 r = (Uint8) (((palette[i] & 0x00ff0000) >> 16) * shade);
Uint8 g = (Uint8) (((palette[i] & 0x0000ff00) >> 8) * shade);
Uint8 b = (Uint8) ((palette[i] & 0x000000ff) * shade);
myPalette[i] = mapRGB(r, g, b);
myDefTIAPalette[i] = mapRGB(r, g, b);
}
// Set palette for phosphor effect
if(myUsePhosphor)
for(i = 0; i < 256; ++i)
{
for(i = 0; i < 256; ++i)
for(j = 0; j < 256; ++j)
{
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 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);
Uint8 r = (Uint8) (getPhosphor(ri, rj) * shade);
Uint8 g = (Uint8) (getPhosphor(gi, gj) * shade);
Uint8 b = (Uint8) (getPhosphor(bi, bj) * shade);
myAvgPalette[i][j] = mapRGB(r, g, b);
}
myAvgTIAPalette[i][j] = mapRGB(r, g, b);
}
}
@ -726,7 +733,7 @@ uInt8 FrameBuffer::getPhosphor(uInt8 c1, uInt8 c2)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const uInt8 FrameBuffer::ourGUIColors[kNumColors-256][3] = {
const uInt8 FrameBuffer::ourGUIColors[kNumColors][3] = {
{ 104, 104, 104 }, // kColor
{ 0, 0, 0 }, // kBGColor
{ 64, 64, 64 }, // kShadowColor

View File

@ -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.67 2006-03-19 18:17:48 stephena Exp $
// $Id: FrameBuffer.hxx,v 1.68 2006-03-24 19:59:52 stephena Exp $
//============================================================================
#ifndef FRAMEBUFFER_HXX
@ -70,7 +70,7 @@ enum MessagePosition {
All GUI elements (ala ScummVM) are drawn here as well.
@author Stephen Anthony
@version $Id: FrameBuffer.hxx,v 1.67 2006-03-19 18:17:48 stephena Exp $
@version $Id: FrameBuffer.hxx,v 1.68 2006-03-24 19:59:52 stephena Exp $
*/
class FrameBuffer
{
@ -150,12 +150,11 @@ class FrameBuffer
inline const uInt32 imageHeight() { return myImageDim.h; }
/**
Sets the pause status. While pause is selected, the
MediaSource will not be updated.
Handle the pause event; currently this updates the palette.
@param status Toggle pause based on status
@param status Whether pause has been enabled or disabled
*/
void pause(bool status);
void handlePause(bool status);
/**
Indicates that the TIA area is dirty, and certain areas need
@ -453,11 +452,12 @@ class FrameBuffer
// SDL initialization flags
uInt32 mySDLFlags;
// SDL palette, with the first 256 colors representing normal fill
Uint32 myPalette[kNumColors];
// TIA palettes for normal and phosphor modes
Uint32 myDefTIAPalette[256];
Uint32 myAvgTIAPalette[256][256];
// SDL palette representing phosphor effect
Uint32 myAvgPalette[256][256];
// GUI palette, derived from 'ourGUIColors'
Uint32 myGUIPalette[kNumColors];
// Indicates the current zoom level of the SDL screen
uInt32 theZoomLevel;
@ -481,7 +481,7 @@ class FrameBuffer
int myPhosphorBlend;
// Table of RGB values for GUI elements
static const uInt8 ourGUIColors[kNumColors-256][3];
static const uInt8 ourGUIColors[kNumColors][3];
private:
/**

View File

@ -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: OSystem.cxx,v 1.65 2006-03-22 15:12:02 stephena Exp $
// $Id: OSystem.cxx,v 1.66 2006-03-24 19:59:52 stephena Exp $
//============================================================================
#include <cassert>
@ -230,6 +230,8 @@ void OSystem::toggleFrameBuffer()
else // a driver that doesn't exist was requested, so use software mode
video = "soft";
myEventHandler->handleEvent(Event::Pause, 0);
// Update the settings and create the framebuffer
mySettings->setString("video", video);
createFrameBuffer(true); // show onscreen message

View File

@ -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: GuiUtils.hxx,v 1.22 2006-02-22 17:38:04 stephena Exp $
// $Id: GuiUtils.hxx,v 1.23 2006-03-24 19:59:52 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -29,14 +29,14 @@
Probably not very neat, but at least it works ...
@author Stephen Anthony
@version $Id: GuiUtils.hxx,v 1.22 2006-02-22 17:38:04 stephena Exp $
@version $Id: GuiUtils.hxx,v 1.23 2006-03-24 19:59:52 stephena Exp $
*/
#define kScrollBarWidth 9
// Colors indices to use for the various GUI elements
enum OverlayColor {
kColor = 256, // The rest of the enumerations will continue from 256
kColor,
kBGColor,
kShadowColor,
kHiliteColor,

View File

@ -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: OSystemUNIX.cxx,v 1.18 2006-03-17 23:06:28 stephena Exp $
// $Id: OSystemUNIX.cxx,v 1.19 2006-03-24 19:59:52 stephena Exp $
//============================================================================
#include <SDL.h>
@ -88,7 +88,7 @@ void OSystemUNIX::mainLoop()
for(;;)
{
// Exit if the user wants to quit
if(myEventHandler->doQuit())
if(myEventHandler->isQuit())
break;
startTime = getTicks();
@ -121,7 +121,7 @@ void OSystemUNIX::mainLoop()
for(;;)
{
// Exit if the user wants to quit
if(myEventHandler->doQuit())
if(myEventHandler->isQuit())
break;
startTime = getTicks();