Separated the UI palette from emulation palette, and reworked color

definitions so that it's clearer which palette should be used.

Added 1x TIA emulation surface creation to FrameBuffer.  Certain parts
of the codebase need access to this (debugger, snapshot in 1x mode, etc).
Related to this, viewing the TIA emulation in the debugger now works again.

Still todo is fix color handling in PromptWidget (which I just broke).


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1594 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2009-01-03 15:44:13 +00:00
parent b19344c77f
commit e3b07007d4
24 changed files with 236 additions and 135 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.130 2009-01-01 18:13:35 stephena Exp $
// $Id: FrameBufferGL.cxx,v 1.131 2009-01-03 15:44:12 stephena Exp $
//============================================================================
#ifdef DISPLAY_OPENGL
@ -569,26 +569,26 @@ FBSurfaceGL::~FBSurfaceGL()
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FBSurfaceGL::hLine(uInt32 x, uInt32 y, uInt32 x2, int color)
void FBSurfaceGL::hLine(uInt32 x, uInt32 y, uInt32 x2, UIColor color)
{
uInt16* buffer = (uInt16*) myTexture->pixels + y * myPitch + x;
while(x++ <= x2)
*buffer++ = (uInt16) myFB.myDefPalette[color];
*buffer++ = (uInt16) myFB.myUIPalette[color];
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FBSurfaceGL::vLine(uInt32 x, uInt32 y, uInt32 y2, int color)
void FBSurfaceGL::vLine(uInt32 x, uInt32 y, uInt32 y2, UIColor color)
{
uInt16* buffer = (uInt16*) myTexture->pixels + y * myPitch + x;
while(y++ <= y2)
{
*buffer = (uInt16) myFB.myDefPalette[color];
*buffer = (uInt16) myFB.myUIPalette[color];
buffer += myPitch;
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FBSurfaceGL::fillRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, int color)
void FBSurfaceGL::fillRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, UIColor color)
{
// Fill the rectangle
SDL_Rect tmp;
@ -596,12 +596,26 @@ void FBSurfaceGL::fillRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, int color)
tmp.y = y;
tmp.w = w;
tmp.h = h;
SDL_FillRect(myTexture, &tmp, myFB.myDefPalette[color]);
SDL_FillRect(myTexture, &tmp, myFB.myUIPalette[color]);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FBSurfaceGL::fillTIARect(uInt32 x, uInt32 y, uInt32 w, uInt32 h,
int c1, int c2)
{
// Fill the rectangle
SDL_Rect tmp;
tmp.x = x;
tmp.y = y;
tmp.w = w;
tmp.h = h;
SDL_FillRect(myTexture, &tmp,
(c2 == -1 ? myFB.myDefPalette[c1] : myFB.myAvgPalette[c1][c2]));
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FBSurfaceGL::drawChar(const GUI::Font* font, uInt8 chr,
uInt32 tx, uInt32 ty, int color)
uInt32 tx, uInt32 ty, UIColor color)
{
const FontDesc& desc = font->desc();
@ -642,7 +656,7 @@ void FBSurfaceGL::drawChar(const GUI::Font* font, uInt8 chr,
for(int x = 0; x < bbw; x++, mask >>= 1)
if(ptr & mask)
buffer[x] = (uInt16) myFB.myDefPalette[color];
buffer[x] = (uInt16) myFB.myUIPalette[color];
buffer += myPitch;
}
@ -650,7 +664,7 @@ void FBSurfaceGL::drawChar(const GUI::Font* font, uInt8 chr,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FBSurfaceGL::drawBitmap(uInt32* bitmap, uInt32 tx, uInt32 ty,
int color, uInt32 h)
UIColor color, uInt32 h)
{
uInt16* buffer = (uInt16*) myTexture->pixels + ty * myPitch + tx;
@ -659,7 +673,7 @@ void FBSurfaceGL::drawBitmap(uInt32* bitmap, uInt32 tx, uInt32 ty,
uInt32 mask = 0xF0000000;
for(uInt32 x = 0; x < 8; ++x, mask >>= 4)
if(bitmap[y] & mask)
buffer[x] = (uInt16) myFB.myDefPalette[color];
buffer[x] = (uInt16) myFB.myUIPalette[color];
buffer += myPitch;
}

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.hxx,v 1.68 2009-01-01 18:13:35 stephena Exp $
// $Id: FrameBufferGL.hxx,v 1.69 2009-01-03 15:44:12 stephena Exp $
//============================================================================
#ifndef FRAMEBUFFER_GL_HXX
@ -35,7 +35,7 @@ class FBSurfaceGL;
This class implements an SDL OpenGL framebuffer.
@author Stephen Anthony
@version $Id: FrameBufferGL.hxx,v 1.68 2009-01-01 18:13:35 stephena Exp $
@version $Id: FrameBufferGL.hxx,v 1.69 2009-01-03 15:44:12 stephena Exp $
*/
class FrameBufferGL : public FrameBuffer
{
@ -176,7 +176,7 @@ class FrameBufferGL : public FrameBuffer
A surface suitable for OpenGL rendering mode.
@author Stephen Anthony
@version $Id: FrameBufferGL.hxx,v 1.68 2009-01-01 18:13:35 stephena Exp $
@version $Id: FrameBufferGL.hxx,v 1.69 2009-01-03 15:44:12 stephena Exp $
*/
class FBSurfaceGL : public FBSurface
{
@ -188,11 +188,12 @@ class FBSurfaceGL : public FBSurface
uInt32 scaleWidth, uInt32 scaleHeight);
virtual ~FBSurfaceGL();
void hLine(uInt32 x, uInt32 y, uInt32 x2, int color);
void vLine(uInt32 x, uInt32 y, uInt32 y2, int color);
void fillRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, int color);
void drawChar(const GUI::Font* font, uInt8 c, uInt32 x, uInt32 y, int color);
void drawBitmap(uInt32* bitmap, uInt32 x, uInt32 y, int color, uInt32 h = 8);
void hLine(uInt32 x, uInt32 y, uInt32 x2, UIColor color);
void vLine(uInt32 x, uInt32 y, uInt32 y2, UIColor color);
void fillRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, UIColor color);
void fillTIARect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, int c1, int c2);
void drawChar(const GUI::Font* font, uInt8 c, uInt32 x, uInt32 y, UIColor color);
void drawBitmap(uInt32* bitmap, uInt32 x, uInt32 y, UIColor color, uInt32 h = 8);
void drawBytes(uInt8* data, uInt32 x, uInt32 y, uInt32 rowbytes);
void drawSurface(const FBSurface* surface, uInt32 x, uInt32 y);
void addDirtyRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h);

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.89 2009-01-01 18:13:35 stephena Exp $
// $Id: FrameBufferSoft.cxx,v 1.90 2009-01-03 15:44:12 stephena Exp $
//============================================================================
#include <sstream>
@ -222,7 +222,7 @@ void FrameBufferSoft::drawMediaSource(bool fullRedraw)
}
myTiaDirty = true;
}
else // try to eliminate multply whereever possible
else // try to eliminate multiply whereever possible
pos += xstride + xstride + xstride + xstride + xstride + xstride;
}
screenofsY += myPitch;
@ -533,7 +533,7 @@ FBSurfaceSoft::~FBSurfaceSoft()
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FBSurfaceSoft::hLine(uInt32 x, uInt32 y, uInt32 x2, int color)
void FBSurfaceSoft::hLine(uInt32 x, uInt32 y, uInt32 x2, UIColor color)
{
// Horizontal line
SDL_Rect tmp;
@ -541,11 +541,11 @@ void FBSurfaceSoft::hLine(uInt32 x, uInt32 y, uInt32 x2, int color)
tmp.y = y + myYOffset;
tmp.w = x2 - x + 1;
tmp.h = 1;
SDL_FillRect(mySurface, &tmp, myFB.myDefPalette[color]);
SDL_FillRect(mySurface, &tmp, myFB.myUIPalette[color]);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FBSurfaceSoft::vLine(uInt32 x, uInt32 y, uInt32 y2, int color)
void FBSurfaceSoft::vLine(uInt32 x, uInt32 y, uInt32 y2, UIColor color)
{
// Vertical line
SDL_Rect tmp;
@ -553,11 +553,11 @@ void FBSurfaceSoft::vLine(uInt32 x, uInt32 y, uInt32 y2, int color)
tmp.y = y + myYOffset;
tmp.w = 1;
tmp.h = y2 - y + 1;
SDL_FillRect(mySurface, &tmp, myFB.myDefPalette[color]);
SDL_FillRect(mySurface, &tmp, myFB.myUIPalette[color]);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FBSurfaceSoft::fillRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, int color)
void FBSurfaceSoft::fillRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, UIColor color)
{
// Fill the rectangle
SDL_Rect tmp;
@ -565,12 +565,26 @@ void FBSurfaceSoft::fillRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, int color)
tmp.y = y + myYOffset;
tmp.w = w;
tmp.h = h;
SDL_FillRect(mySurface, &tmp, myFB.myDefPalette[color]);
SDL_FillRect(mySurface, &tmp, myFB.myUIPalette[color]);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FBSurfaceSoft::fillTIARect(uInt32 x, uInt32 y, uInt32 w, uInt32 h,
int c1, int c2)
{
// Fill the rectangle
SDL_Rect tmp;
tmp.x = x + myXOffset;
tmp.y = y + myYOffset;
tmp.w = w;
tmp.h = h;
SDL_FillRect(mySurface, &tmp,
(c2 == -1 ? myFB.myDefPalette[c1] : myFB.myAvgPalette[c1][c2]));
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FBSurfaceSoft::drawChar(const GUI::Font* font, uInt8 chr,
uInt32 tx, uInt32 ty, int color)
uInt32 tx, uInt32 ty, UIColor color)
{
// TODO - test this in 16-bit, and re-write 24-bit
const FontDesc& desc = font->desc();
@ -617,7 +631,7 @@ void FBSurfaceSoft::drawChar(const GUI::Font* font, uInt8 chr,
for(int x = 0; x < bbw; x++, mask >>= 1)
if(ptr & mask)
buffer[x] = (uInt16) myFB.myDefPalette[color];
buffer[x] = (uInt16) myFB.myUIPalette[color];
buffer += myPitch;
}
@ -677,7 +691,7 @@ void FBSurfaceSoft::drawChar(const GUI::Font* font, uInt8 chr,
for(int x = 0; x < bbw; x++, mask >>= 1)
if(ptr & mask)
buffer[x] = (uInt32) myFB.myDefPalette[color];
buffer[x] = (uInt32) myFB.myUIPalette[color];
buffer += myPitch;
}
@ -690,7 +704,7 @@ void FBSurfaceSoft::drawChar(const GUI::Font* font, uInt8 chr,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FBSurfaceSoft::drawBitmap(uInt32* bitmap, uInt32 tx, uInt32 ty,
int color, uInt32 h)
UIColor color, uInt32 h)
{
SDL_Rect rect;
rect.y = ty + myYOffset;
@ -702,7 +716,7 @@ void FBSurfaceSoft::drawBitmap(uInt32* bitmap, uInt32 tx, uInt32 ty,
for(uInt32 x = 0; x < 8; x++, mask >>= 4)
{
if(bitmap[y] & mask)
SDL_FillRect(mySurface, &rect, myFB.myDefPalette[color]);
SDL_FillRect(mySurface, &rect, myFB.myUIPalette[color]);
rect.x++;
}

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.hxx,v 1.61 2009-01-01 18:13:35 stephena Exp $
// $Id: FrameBufferSoft.hxx,v 1.62 2009-01-03 15:44:13 stephena Exp $
//============================================================================
#ifndef FRAMEBUFFER_SOFT_HXX
@ -32,7 +32,7 @@ class RectList;
This class implements an SDL software framebuffer.
@author Stephen Anthony
@version $Id: FrameBufferSoft.hxx,v 1.61 2009-01-01 18:13:35 stephena Exp $
@version $Id: FrameBufferSoft.hxx,v 1.62 2009-01-03 15:44:13 stephena Exp $
*/
class FrameBufferSoft : public FrameBuffer
{
@ -166,7 +166,7 @@ class FrameBufferSoft : public FrameBuffer
A surface suitable for software rendering mode.
@author Stephen Anthony
@version $Id: FrameBufferSoft.hxx,v 1.61 2009-01-01 18:13:35 stephena Exp $
@version $Id: FrameBufferSoft.hxx,v 1.62 2009-01-03 15:44:13 stephena Exp $
*/
class FBSurfaceSoft : public FBSurface
{
@ -175,11 +175,12 @@ class FBSurfaceSoft : public FBSurface
uInt32 w, uInt32 h, bool isBase);
virtual ~FBSurfaceSoft();
void hLine(uInt32 x, uInt32 y, uInt32 x2, int color);
void vLine(uInt32 x, uInt32 y, uInt32 y2, int color);
void fillRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, int color);
void drawChar(const GUI::Font* font, uInt8 c, uInt32 x, uInt32 y, int color);
void drawBitmap(uInt32* bitmap, uInt32 x, uInt32 y, int color, uInt32 h = 8);
void hLine(uInt32 x, uInt32 y, uInt32 x2, UIColor color);
void vLine(uInt32 x, uInt32 y, uInt32 y2, UIColor color);
void fillRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, UIColor color);
void fillTIARect(uInt32 x, uInt32 y, uInt32 w, uInt32 h, int c1, int c2);
void drawChar(const GUI::Font* font, uInt8 c, uInt32 x, uInt32 y, UIColor color);
void drawBitmap(uInt32* bitmap, uInt32 x, uInt32 y, UIColor color, uInt32 h = 8);
void drawBytes(uInt8* data, uInt32 x, uInt32 y, uInt32 rowbytes);
void drawSurface(const FBSurface* surface, uInt32 x, uInt32 y);
void addDirtyRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h);

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: ColorWidget.cxx,v 1.10 2009-01-01 18:13:35 stephena Exp $
// $Id: ColorWidget.cxx,v 1.11 2009-01-03 15:44:13 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -73,5 +73,5 @@ void ColorWidget::drawWidget(bool hilite)
s.vLine(_x + _w - 1, _y, _y +_h - 1, kShadowColor);
// Show the currently selected color
s.fillRect(_x+1, _y+1, _w-2, _h-1, _color);
s.fillTIARect(_x+1, _y+1, _w-2, _h-1, _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: DataGridWidget.cxx,v 1.15 2009-01-01 18:13:35 stephena Exp $
// $Id: DataGridWidget.cxx,v 1.16 2009-01-03 15:44:13 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -521,7 +521,7 @@ void DataGridWidget::drawWidget(bool hilite)
buffer = _valueStringList[pos];
deltax = 0;
int color = kTextColor;
UIColor color = kTextColor;
if(_changedList[pos])
{
s.fillRect(x - 3, y - 1, _colWidth-1, _rowHeight-1, kDbgChangedColor);

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: PromptWidget.cxx,v 1.26 2009-01-01 18:13:35 stephena Exp $
// $Id: PromptWidget.cxx,v 1.27 2009-01-03 15:44:13 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -101,7 +101,7 @@ PromptWidget::~PromptWidget()
void PromptWidget::drawWidget(bool hilite)
{
//cerr << "PromptWidget::drawWidget\n";
int fgcolor, bgcolor;
UIColor fgcolor, bgcolor;
FBSurface& s = _boss->dialog().surface();
@ -117,10 +117,10 @@ void PromptWidget::drawWidget(bool hilite)
if(c & (1 << 17)) { // inverse video flag
fgcolor = _bgcolor;
bgcolor = (c & 0x1ffff) >> 8;
//FIXME bgcolor = (c & 0x1ffff) >> 8;
s.fillRect(x, y, _kConsoleCharWidth, _kConsoleCharHeight, bgcolor);
} else {
fgcolor = c >> 8;
//FIXME fgcolor = c >> 8;
}
s.drawChar(&instance().consoleFont(), c & 0x7f, x, y, fgcolor);
x += _kConsoleCharWidth;
@ -804,10 +804,10 @@ void PromptWidget::putcharIntern(int c)
// don't print or advance cursor
// there are only 128 TIA colors, but
// OverlayColor contains 256 of them
_textcolor = (c & 0x7f) << 1;
//FIXME _textcolor = 0;//FIXME(c & 0x7f) << 1;
}
else if(c < ' ') { // More colors (the regular GUI ones)
_textcolor = c + 0x100;
//FIXME _textcolor = c + 0x100;
}
else if(c == 0x7f) { // toggle inverse video (DEL char)
_inverse = !_inverse;

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: TiaOutputWidget.cxx,v 1.22 2009-01-01 18:13:35 stephena Exp $
// $Id: TiaOutputWidget.cxx,v 1.23 2009-01-03 15:44:13 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -139,9 +139,7 @@ void TiaOutputWidget::handleCommand(CommandSender* sender, int cmd, int data, in
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TiaOutputWidget::drawWidget(bool hilite)
{
/*
// FIXME - check if we're in 'greyed out mode' and act accordingly
instance().frameBuffer().refresh();
instance().frameBuffer().drawMediaSource();
*/
// FIXME - maybe 'greyed out mode' should be done here, not in the TIA class
const FBSurface* tia = instance().frameBuffer().smallTIASurface();
dialog().surface().drawSurface(tia, 0, 0);
}

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: TiaZoomWidget.cxx,v 1.20 2009-01-01 18:13:35 stephena Exp $
// $Id: TiaZoomWidget.cxx,v 1.21 2009-01-03 15:44:13 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -230,7 +230,7 @@ void TiaZoomWidget::drawWidget(bool hilite)
{
for(x = myXoff, col = 0; x < myNumCols+myXoff; ++x, col += width)
{
s.fillRect(_x + col + 2, _y + row + 2, width, height,
s.fillTIARect(_x + col + 2, _y + row + 2, width, height,
currentFrame[y*pitch + x]);
}
}

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: TogglePixelWidget.cxx,v 1.9 2009-01-01 18:13:35 stephena Exp $
// $Id: TogglePixelWidget.cxx,v 1.10 2009-01-03 15:44:13 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -30,7 +30,7 @@
TogglePixelWidget::TogglePixelWidget(GuiObject* boss, const GUI::Font& font,
int x, int y, int cols, int rows)
: ToggleWidget(boss, font, x, y, cols, rows),
_pixelColor(kBGColor)
_pixelColor(0)
{
_type = kTogglePixelWidget;
@ -141,7 +141,7 @@ void TogglePixelWidget::drawWidget(bool hilite)
// Either draw the pixel in given color, or erase (show background)
if(_stateList[pos])
s.fillRect(x - 3, y - 1, _colWidth-1, _rowHeight-1, _pixelColor);
s.fillTIARect(x - 3, y - 1, _colWidth-1, _rowHeight-1, _pixelColor);
else
s.fillRect(x - 3, y - 1, _colWidth-1, _rowHeight-1, kBGColor);
}

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.152 2009-01-01 18:13:35 stephena Exp $
// $Id: FrameBuffer.cxx,v 1.153 2009-01-03 15:44:13 stephena Exp $
//============================================================================
#include <algorithm>
@ -47,7 +47,8 @@ FrameBuffer::FrameBuffer(OSystem* osystem)
myPhosphorBlend(77),
myInitializedCount(0),
myPausedCount(0),
mySurfaceCount(0)
mySurfaceCount(0),
mySmallTiaSurface(NULL)
{
myMsg.surface = myStatsMsg.surface = NULL;
myMsg.surfaceID = myStatsMsg.surfaceID = -1;
@ -139,6 +140,10 @@ bool FrameBuffer::initialize(const string& title, uInt32 width, uInt32 height)
myMsg.surface = surface(myMsg.surfaceID);
}
// Create surface for 1x TIA mode
if(mySmallTiaSurface == NULL)
mySmallTiaSurface = surface(allocateSurface(320, 260));
// Finally, show some information about the framebuffer,
// but only on the first initialization
if(myInitializedCount == 1 && myOSystem->settings().getBool("showinfo"))
@ -247,7 +252,7 @@ void FrameBuffer::update()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBuffer::showMessage(const string& message, MessagePosition position,
int color)
UIColor color)
{
// Erase old messages on the screen
if(myMsg.counter > 0)
@ -477,6 +482,35 @@ void FrameBuffer::resetSurfaces()
iter->second->reload();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const FBSurface* FrameBuffer::smallTIASurface()
{
// This method isn't terribly fast, as it does a complete draw each time
// it's called and doesn't use direct pixel access
// Do not use it in time-sensitive situations
if(&myOSystem->console())
{
const MediaSource& src = myOSystem->console().mediaSource();
mySmallTiaSurface->setWidth(src.width() << 1); // should always be 320
mySmallTiaSurface->setHeight(src.height()); // can be up to 260
uInt8* currentFrame = src.currentFrameBuffer();
uInt8* previousFrame = src.previousFrameBuffer();
for(uInt32 y = 0; y < src.height(); ++y)
{
for(uInt32 x = 0; x < src.width(); ++x)
{
mySmallTiaSurface->fillTIARect(x + x, y, 2, 1,
currentFrame[y*160+x],
myUsePhosphor ? previousFrame[y*160+x] : -1);
}
}
}
return mySmallTiaSurface;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBuffer::setTIAPalette(const uInt32* palette)
{
@ -519,12 +553,12 @@ 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; i < kNumUIColors; ++i)
{
Uint8 r = (palette[i] >> 16) & 0xff;
Uint8 g = (palette[i] >> 8) & 0xff;
Uint8 b = palette[i] & 0xff;
myDefPalette[i+256] = mapRGB(r, g, b);
myUIPalette[i] = mapRGB(r, g, b);
}
}
@ -1059,7 +1093,7 @@ void FrameBuffer::VideoModeList::print()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FBSurface::box(uInt32 x, uInt32 y, uInt32 w, uInt32 h,
int colorA, int colorB)
UIColor colorA, UIColor colorB)
{
hLine(x + 1, y, x + w - 2, colorA);
hLine(x, y + 1, x + w - 1, colorA);
@ -1074,7 +1108,7 @@ void FBSurface::box(uInt32 x, uInt32 y, uInt32 w, uInt32 h,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FBSurface::frameRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h,
int color, FrameStyle style)
UIColor color, FrameStyle style)
{
switch(style)
{
@ -1111,7 +1145,7 @@ void FBSurface::frameRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FBSurface::drawString(const GUI::Font* font, const string& s,
int x, int y, int w,
int color, TextAlignment align,
UIColor color, TextAlignment align,
int deltax, bool useEllipsis)
{
const int leftX = x, rightX = x + 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: FrameBuffer.hxx,v 1.111 2009-01-01 18:13:35 stephena Exp $
// $Id: FrameBuffer.hxx,v 1.112 2009-01-03 15:44:13 stephena Exp $
//============================================================================
#ifndef FRAMEBUFFER_HXX
@ -56,8 +56,8 @@ enum MessagePosition {
};
// Colors indices to use for the various GUI elements
enum {
kColor = 256,
enum UIColor {
kColor,
kBGColor,
kShadowColor,
kTextColor,
@ -78,7 +78,7 @@ enum {
kDbgChangedColor,
kDbgChangedTextColor,
kDbgColorHi,
kNumColors
kNumUIColors
};
@ -91,7 +91,7 @@ enum {
turn drawn here as well.
@author Stephen Anthony
@version $Id: FrameBuffer.hxx,v 1.111 2009-01-01 18:13:35 stephena Exp $
@version $Id: FrameBuffer.hxx,v 1.112 2009-01-03 15:44:13 stephena Exp $
*/
class FrameBuffer
{
@ -133,7 +133,7 @@ class FrameBuffer
*/
void showMessage(const string& message,
MessagePosition position = kBottomCenter,
int color = kTextColorHi);
UIColor color = kTextColorHi);
/**
Toggles showing or hiding framerate statistics.
@ -172,6 +172,19 @@ class FrameBuffer
*/
FBSurface* surface(int id) const;
/**
Returns a surface representing the TIA image in 1x mode without
any postprocessing (aka, no filtering, scanlines, etc) sized at
maximum 320 x 260 pixels. The phosphor effect *is* applied when
necessary, though. This is useful for those parts of the codebase
that need an unfiltered TIA image (snapshots in 1x mode, debugger,
etc). Note that if a console hasn't been created when this
method is called, a blank surface is returned.
@return A pointer to a valid TIA surface.
*/
const FBSurface* smallTIASurface();
/**
Returns the current dimensions of the framebuffer image.
Note that this will take into account the current scaling (if any)
@ -291,7 +304,10 @@ class FrameBuffer
virtual BufferType type() const = 0;
/**
This method is called to get the specified scanline data.
This method is called to get the specified scanline data from the
viewable FrameBuffer area. Note that this isn't the same as any
internal surfaces that may be in use; it should return the actual
data as it is currently seen onscreen.
@param row The row we are looking for
@param data The actual pixel data (in bytes)
@ -406,8 +422,11 @@ class FrameBuffer
// Amount to blend when using phosphor effect
int myPhosphorBlend;
// UI palette
Uint32 myUIPalette[kNumUIColors];
// TIA palettes for normal and phosphor modes
Uint32 myDefPalette[256+kNumColors];
Uint32 myDefPalette[256];
Uint32 myAvgPalette[256][256];
// Names of the TIA filters that can be used for this framebuffer
@ -513,7 +532,7 @@ class FrameBuffer
string text;
int counter;
int x, y, w, h;
uInt32 color;
UIColor color;
FBSurface* surface;
int surfaceID;
bool enabled;
@ -530,6 +549,11 @@ class FrameBuffer
map<int,FBSurface*> mySurfaceList;
int mySurfaceCount;
// A surface representing TIA emulation in 1x mode
// The parent FrameBuffer class (ie, this class) is responsible for
// initializing and deleting this surface
FBSurface* mySmallTiaSurface;
// Holds static strings for the remap menu (emulation and menu events)
static GraphicsMode ourGraphicsModes[GFX_NumModes];
};
@ -544,7 +568,7 @@ class FrameBuffer
FrameBuffer type.
@author Stephen Anthony
@version $Id: FrameBuffer.hxx,v 1.111 2009-01-01 18:13:35 stephena Exp $
@version $Id: FrameBuffer.hxx,v 1.112 2009-01-03 15:44:13 stephena Exp $
*/
// Text alignment modes for drawString()
enum TextAlignment {
@ -579,7 +603,7 @@ class FBSurface
@param x2 The second x coordinate
@param color The color of the line
*/
virtual void hLine(uInt32 x, uInt32 y, uInt32 x2, int color) = 0;
virtual void hLine(uInt32 x, uInt32 y, uInt32 x2, UIColor color) = 0;
/**
This method should be called to draw a vertical line.
@ -589,19 +613,34 @@ class FBSurface
@param y2 The second y coordinate
@param color The color of the line
*/
virtual void vLine(uInt32 x, uInt32 y, uInt32 y2, int color) = 0;
virtual void vLine(uInt32 x, uInt32 y, uInt32 y2, UIColor color) = 0;
/**
This method should be called to draw a filled rectangle.
This method should be called to draw a filled rectangle using the
UI palette.
@param x The x coordinate
@param y The y coordinate
@param w The width of the area
@param h The height of the area
@param color The color of the area
@param color
*/
virtual void fillRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h,
int color) = 0;
UIColor color) = 0;
/**
This method should be called to draw a filled rectangle using the
TIA palette(s).
@param x The x coordinate
@param y The y coordinate
@param w The width of the area
@param h The height of the area
@param c1 Indices into the relevant TIA palettes
@param c2 Indices into the relevant TIA palettes
*/
virtual void fillTIARect(uInt32 x, uInt32 y, uInt32 w, uInt32 h,
int c1, int c2 = -1) = 0;
/**
This method should be called to draw the specified character.
@ -613,7 +652,7 @@ class FBSurface
@param color The color of the character
*/
virtual void drawChar(const GUI::Font* font, uInt8 c, uInt32 x, uInt32 y,
int color) = 0;
UIColor color) = 0;
/**
This method should be called to draw the bitmap image.
@ -624,7 +663,7 @@ class FBSurface
@param color The color of the character
@param h The height of the data image
*/
virtual void drawBitmap(uInt32* bitmap, uInt32 x, uInt32 y, int color,
virtual void drawBitmap(uInt32* bitmap, uInt32 x, uInt32 y, UIColor color,
uInt32 h = 8) = 0;
/**
@ -722,7 +761,7 @@ class FBSurface
@param colorB Darker color for inside line.
*/
void box(uInt32 x, uInt32 y, uInt32 w, uInt32 h,
int colorA, int colorB);
UIColor colorA, UIColor colorB);
/**
This method should be called to draw a framed rectangle.
@ -735,7 +774,7 @@ class FBSurface
@param color The color of the surrounding frame
*/
void frameRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h,
int color, FrameStyle style = kSolidLine);
UIColor color, FrameStyle style = kSolidLine);
/**
This method should be called to draw the specified string.
@ -752,7 +791,7 @@ class FBSurface
@param useEllipsis Whether to use '...' when the string is too long
*/
void drawString(const GUI::Font* font, const string& str, int x, int y, int w,
int color, TextAlignment align = kTextAlignLeft,
UIColor color, TextAlignment align = kTextAlignLeft,
int deltax = 0, bool useEllipsis = true);
};

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.139 2009-01-01 22:44:14 stephena Exp $
// $Id: OSystem.cxx,v 1.140 2009-01-03 15:44:13 stephena Exp $
//============================================================================
#include <cassert>
@ -871,7 +871,7 @@ void OSystem::queryVideoHardware()
kDbgChangedTextColor Text color for changed cells
kDbgColorHi Highlighted color in debugger data cells
*/
uInt32 OSystem::ourGUIColors[kNumUIPalettes][kNumColors-256] = {
uInt32 OSystem::ourGUIColors[kNumUIPalettes][kNumUIColors] = {
// Standard
{ 0x686868, 0x000000, 0x404040, 0x000000, 0x62a108, 0x9f0000,
0xc9af7c, 0xf0f0cf, 0xc80000,

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.hxx,v 1.70 2009-01-01 22:44:14 stephena Exp $
// $Id: OSystem.hxx,v 1.71 2009-01-03 15:44:13 stephena Exp $
//============================================================================
#ifndef OSYSTEM_HXX
@ -56,7 +56,7 @@ typedef Common::Array<Resolution> ResolutionList;
other objects belong.
@author Stephen Anthony
@version $Id: OSystem.hxx,v 1.70 2009-01-01 22:44:14 stephena Exp $
@version $Id: OSystem.hxx,v 1.71 2009-01-03 15:44:13 stephena Exp $
*/
class OSystem
{
@ -521,7 +521,7 @@ class OSystem
TimingInfo myTimingInfo;
// Table of RGB values for GUI elements
static uInt32 ourGUIColors[kNumUIPalettes][kNumColors-256];
static uInt32 ourGUIColors[kNumUIPalettes][kNumUIColors];
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: TIA.cxx,v 1.95 2009-01-01 18:13:37 stephena Exp $
// $Id: TIA.cxx,v 1.96 2009-01-03 15:44:13 stephena Exp $
//============================================================================
//#define DEBUG_HMOVE
@ -527,13 +527,15 @@ void TIA::update()
uInt32 totalClocks = (mySystem->cycles() * 3) - myClockWhenFrameStarted;
myCurrentScanline = totalClocks / 228;
if(myPartialFrameFlag) {
// grey out old frame contents
if(!myFrameGreyed) greyOutFrame();
if(myPartialFrameFlag)
{
// Grey out old frame contents
if(!myFrameGreyed)
greyOutFrame();
myFrameGreyed = true;
} else {
endFrame();
}
else
endFrame();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

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: AboutDialog.cxx,v 1.27 2009-01-01 18:13:38 stephena Exp $
// $Id: AboutDialog.cxx,v 1.28 2009-01-03 15:44:13 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -195,7 +195,7 @@ void AboutDialog::displayInfo()
{
const char *str = dscStr[i].c_str();
TextAlignment align = kTextAlignCenter;
int color = kTextColor;
UIColor color = kTextColor;
while (str[0] == '\\')
{

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: EditableWidget.cxx,v 1.29 2009-01-01 18:13:38 stephena Exp $
// $Id: EditableWidget.cxx,v 1.30 2009-01-03 15:44:13 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -187,9 +187,7 @@ void EditableWidget::drawCaret()
if (!_editable || !isVisible() || !_boss->isVisible() || !_hasFocus)
return;
GUI::Rect editRect = getEditRect();
int color = kTextColorHi;
const GUI::Rect& editRect = getEditRect();
int x = editRect.left;
int y = editRect.top;
@ -199,7 +197,7 @@ void EditableWidget::drawCaret()
y += _y;
FBSurface& s = _boss->dialog().surface();
s.vLine(x, y+2, y + editRect.height() - 3, color);
s.vLine(x, y+2, y + editRect.height() - 3, kTextColorHi);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

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: LauncherDialog.cxx,v 1.94 2009-01-02 01:50:03 stephena Exp $
// $Id: LauncherDialog.cxx,v 1.95 2009-01-03 15:44:13 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -84,7 +84,7 @@ LauncherDialog::LauncherDialog(OSystem* osystem, DialogContainer* parent,
// Before we add the list, we need to know the size of the RomInfoWidget
int romWidth = 0;
int romSize = instance().settings().getInt("romviewer");
if(romSize > 1 && w >= 1000 && h >= 800)
if(romSize > 1 && w >= 1000 && h >= 760)
romWidth = 660;
else if(romSize > 0 && w >= 640 && h >= 480)
romWidth = 365;

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: StringListWidget.cxx,v 1.12 2009-01-01 18:13:39 stephena Exp $
// $Id: StringListWidget.cxx,v 1.13 2009-01-03 15:44:13 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -61,7 +61,7 @@ void StringListWidget::drawWidget(bool hilite)
// Draw the list items
for (i = 0, pos = _currentPos; i < _rows && pos < len; i++, pos++)
{
const int textColor = (_selectedItem == pos && _editMode)
const UIColor textColor = (_selectedItem == pos && _editMode)
? kColor : kTextColor;
const int y = _y + 2 + _fontHeight * i;

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: TabWidget.cxx,v 1.33 2009-01-01 18:13:39 stephena Exp $
// $Id: TabWidget.cxx,v 1.34 2009-01-03 15:44:13 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -252,7 +252,7 @@ void TabWidget::loadConfig()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TabWidget::box(int x, int y, int width, int height,
int colorA, int colorB, bool omitBottom)
UIColor colorA, UIColor colorB, bool omitBottom)
{
//cerr << "TabWidget::box\n";
FBSurface& s = _boss->dialog().surface();
@ -294,8 +294,8 @@ void TabWidget::drawWidget(bool hilite)
int i, x = _x + kTabLeftOffset;
for (i = 0; i < (int)_tabs.size(); ++i)
{
int fontcolor = _tabs[i].enabled ? kTextColor : kColor;
int boxcolor = (i == _activeTab) ? kColor : kShadowColor;
UIColor fontcolor = _tabs[i].enabled ? kTextColor : kColor;
UIColor boxcolor = (i == _activeTab) ? kColor : kShadowColor;
int yOffset = (i == _activeTab) ? 0 : 2;
box(x, _y + yOffset, _tabWidth, _tabHeight - yOffset, boxcolor, boxcolor, (i == _activeTab));
s.drawString(_font, _tabs[i].title, x + kTabPadding,

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: TabWidget.hxx,v 1.21 2009-01-01 18:13:39 stephena Exp $
// $Id: TabWidget.hxx,v 1.22 2009-01-03 15:44:13 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -91,7 +91,7 @@ class TabWidget : public Widget, public CommandSender
private:
void box(int x, int y, int width, int height,
int colorA, int colorB, bool omitBottom);
UIColor colorA, UIColor colorB, bool omitBottom);
void updateActiveTab();
};

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: UIDialog.cxx,v 1.17 2009-01-01 18:13:39 stephena Exp $
// $Id: UIDialog.cxx,v 1.18 2009-01-03 15:44:13 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -96,7 +96,7 @@ UIDialog::UIDialog(OSystem* osystem, DialogContainer* parent,
ypos += lineHeight + 4;
// Launcher font
pwidth = font.getStringWidth("2x (1000x800)");
pwidth = font.getStringWidth("2x (1000x760)");
items.clear();
items.push_back("Small", "small");
items.push_back("Large", "large");
@ -110,7 +110,7 @@ UIDialog::UIDialog(OSystem* osystem, DialogContainer* parent,
items.clear();
items.push_back("Off", "0");
items.push_back("1x (640x480) ", "1");
items.push_back("2x (1000x800)", "2");
items.push_back("2x (1000x760)", "2");
myRomViewerPopup =
new PopUpWidget(myTab, font, xpos, ypos+1, pwidth, lineHeight, items,
"ROM Info viewer: ", lwidth);

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: Widget.cxx,v 1.59 2009-01-01 18:13:39 stephena Exp $
// $Id: Widget.cxx,v 1.60 2009-01-03 15:44:13 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -517,7 +517,7 @@ void CheckboxWidget::drawWidget(bool hilite)
if(_state)
{
unsigned int* img = _fillRect ? checked_img_o : checked_img_x;
int color = _fillRect ? kWidFrameColor : kCheckColor;
UIColor color = _fillRect ? kWidFrameColor : kCheckColor;
s.drawBitmap(img, _x + 3, _y + _boxY + 3, 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: Widget.hxx,v 1.64 2009-01-01 18:13:39 stephena Exp $
// $Id: Widget.hxx,v 1.65 2009-01-03 15:44:13 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -83,7 +83,7 @@ enum {
This is the base class for all widgets.
@author Stephen Anthony
@version $Id: Widget.hxx,v 1.64 2009-01-01 18:13:39 stephena Exp $
@version $Id: Widget.hxx,v 1.65 2009-01-03 15:44:13 stephena Exp $
*/
class Widget : public GuiObject
{
@ -135,10 +135,10 @@ class Widget : public GuiObject
virtual const GUI::Font* font() { return _font; }
void setTextColor(int color) { _textcolor = color; }
void setTextColorHi(int color) { _textcolorhi = color; }
void setBGColor(int color) { _bgcolor = color; }
void setBGColorHi(int color) { _bgcolorhi = color; }
void setTextColor(UIColor color) { _textcolor = color; }
void setTextColorHi(UIColor color) { _textcolorhi = color; }
void setBGColor(UIColor color) { _bgcolor = color; }
void setBGColorHi(UIColor color) { _bgcolorhi = color; }
virtual void loadConfig() {}
@ -166,10 +166,10 @@ class Widget : public GuiObject
bool _hasFocus;
int _fontWidth;
int _fontHeight;
int _bgcolor;
int _bgcolorhi;
int _textcolor;
int _textcolorhi;
UIColor _bgcolor;
UIColor _bgcolorhi;
UIColor _textcolor;
UIColor _textcolorhi;
public:
static Widget* findWidgetInChain(Widget* start, int x, int y);
@ -266,7 +266,7 @@ class CheckboxWidget : public ButtonWidget
bool _fillRect;
bool _drawBox;
int _fillColor;
UIColor _fillColor;
private:
int _boxY;