mirror of https://github.com/stella-emu/stella.git
Make sure screen is cleared when switching modes; hopefully this will fix
the problem with the GP2X port. Removed SDL_FillRect() calls in OpenGL GUI drawing, since the extra function calls are only slowing things down when we can access the pixels directly. Made return/enter key activate the currently selected button in the ROM launcher instead of always starting a ROM. This was confusing when the 'Quit' button was highlighted and pressing enter started a ROM. Now pressing enter in such a case will actually do 'quit'. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@963 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
d06a92762b
commit
d75868d33d
|
@ -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.51 2006-01-14 23:50:43 stephena Exp $
|
||||
// $Id: FrameBufferGL.cxx,v 1.52 2006-01-15 16:31:00 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifdef DISPLAY_OPENGL
|
||||
|
@ -248,11 +248,6 @@ bool FrameBufferGL::initSubsystem()
|
|||
<< endl;
|
||||
}
|
||||
|
||||
// Precompute the GUI palette
|
||||
// We abuse the concept of 'enum' by referring directly to the integer values
|
||||
for(uInt8 i = 0; i < kNumColors-256; i++)
|
||||
myPalette[i+256] = mapRGB(ourGUIColors[i][0], ourGUIColors[i][1], ourGUIColors[i][2]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -306,9 +301,7 @@ bool FrameBufferGL::createScreen()
|
|||
|
||||
// Make sure any old parts of the screen are erased
|
||||
// Do it for both buffers!
|
||||
p_glClear(GL_COLOR_BUFFER_BIT);
|
||||
SDL_GL_SwapBuffers();
|
||||
p_glClear(GL_COLOR_BUFFER_BIT);
|
||||
cls();
|
||||
|
||||
myOSystem->eventHandler().refreshDisplay();
|
||||
|
||||
|
@ -459,27 +452,20 @@ void FrameBufferGL::toggleFilter()
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void FrameBufferGL::hLine(uInt32 x, uInt32 y, uInt32 x2, OverlayColor color)
|
||||
{
|
||||
SDL_Rect tmp;
|
||||
|
||||
// Horizontal line
|
||||
tmp.x = x;
|
||||
tmp.y = y;
|
||||
tmp.w = x2 - x + 1;
|
||||
tmp.h = 1;
|
||||
SDL_FillRect(myTexture, &tmp, myPalette[color]);
|
||||
uInt16* buffer = (uInt16*) myTexture->pixels + y * myTexture->w + x;
|
||||
while(x++ <= x2)
|
||||
*buffer++ = (uInt16) myPalette[color];
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void FrameBufferGL::vLine(uInt32 x, uInt32 y, uInt32 y2, OverlayColor color)
|
||||
{
|
||||
SDL_Rect tmp;
|
||||
|
||||
// Vertical line
|
||||
tmp.x = x;
|
||||
tmp.y = y;
|
||||
tmp.w = 1;
|
||||
tmp.h = y2 - y + 1;
|
||||
SDL_FillRect(myTexture, &tmp, myPalette[color]);
|
||||
uInt16* buffer = (uInt16*) myTexture->pixels + y * myTexture->w + x;
|
||||
while(y++ <= y2)
|
||||
{
|
||||
*buffer = (uInt16) myPalette[color];
|
||||
buffer += myTexture->w;
|
||||
}
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -498,7 +484,7 @@ void FrameBufferGL::fillRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h,
|
|||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void FrameBufferGL::drawChar(const GUI::Font* FONT, uInt8 chr,
|
||||
uInt32 xorig, uInt32 yorig, OverlayColor color)
|
||||
uInt32 tx, uInt32 ty, OverlayColor color)
|
||||
{
|
||||
GUI::Font* font = (GUI::Font*) FONT;
|
||||
|
||||
|
@ -517,44 +503,36 @@ void FrameBufferGL::drawChar(const GUI::Font* FONT, uInt8 chr,
|
|||
const uInt16* tmp = font->desc().bits + (font->desc().offset ?
|
||||
font->desc().offset[chr] : (chr * h));
|
||||
|
||||
SDL_Rect rect;
|
||||
for(int y = 0; y < h; y++)
|
||||
uInt16* buffer = (uInt16*) myTexture->pixels + ty * myTexture->w + tx;
|
||||
for(int y = 0; y < h; ++y)
|
||||
{
|
||||
const uInt16 buffer = *tmp++;
|
||||
const uInt16 ptr = *tmp++;
|
||||
uInt16 mask = 0x8000;
|
||||
|
||||
for(int x = 0; x < w; x++, mask >>= 1)
|
||||
for(int x = 0; x < w; ++x, mask >>= 1)
|
||||
{
|
||||
if ((buffer & mask) != 0)
|
||||
{
|
||||
rect.x = x + xorig;
|
||||
rect.y = y + yorig;
|
||||
rect.w = rect.h = 1;
|
||||
SDL_FillRect(myTexture, &rect, myPalette[color]);
|
||||
}
|
||||
if(ptr & mask)
|
||||
buffer[x] = (uInt16) myPalette[color];
|
||||
}
|
||||
buffer += myTexture->w;
|
||||
}
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void FrameBufferGL::drawBitmap(uInt32* bitmap, Int32 xorig, Int32 yorig,
|
||||
OverlayColor color, Int32 h)
|
||||
void FrameBufferGL::drawBitmap(uInt32* bitmap, Int32 tx, Int32 ty,
|
||||
OverlayColor color, Int32 h)
|
||||
{
|
||||
SDL_Rect rect;
|
||||
for(int y = 0; y < h; y++)
|
||||
uInt16* buffer = (uInt16*) myTexture->pixels + ty * myTexture->w + tx;
|
||||
|
||||
for(int y = 0; y < h; ++y)
|
||||
{
|
||||
uInt32 mask = 0xF0000000;
|
||||
|
||||
for(int x = 0; x < 8; x++, mask >>= 4)
|
||||
for(int x = 0; x < 8; ++x, mask >>= 4)
|
||||
{
|
||||
if(bitmap[y] & mask)
|
||||
{
|
||||
rect.x = x + xorig;
|
||||
rect.y = y + yorig;
|
||||
rect.w = rect.h = 1;
|
||||
SDL_FillRect(myTexture, &rect, myPalette[color]);
|
||||
}
|
||||
buffer[x] = (uInt16) myPalette[color];
|
||||
}
|
||||
buffer += myTexture->w;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -583,6 +561,14 @@ void FrameBufferGL::enablePhosphor(bool enable)
|
|||
myPhosphorBlend = myOSystem->settings().getInt("ppblend");
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void FrameBufferGL::cls()
|
||||
{
|
||||
p_glClear(GL_COLOR_BUFFER_BIT);
|
||||
SDL_GL_SwapBuffers();
|
||||
p_glClear(GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool FrameBufferGL::createTextures()
|
||||
{
|
||||
|
|
|
@ -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.28 2006-01-14 22:29:34 stephena Exp $
|
||||
// $Id: FrameBufferGL.hxx,v 1.29 2006-01-15 16:31:00 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef FRAMEBUFFER_GL_HXX
|
||||
|
@ -37,7 +37,7 @@ class GUI::Font;
|
|||
This class implements an SDL OpenGL framebuffer.
|
||||
|
||||
@author Stephen Anthony
|
||||
@version $Id: FrameBufferGL.hxx,v 1.28 2006-01-14 22:29:34 stephena Exp $
|
||||
@version $Id: FrameBufferGL.hxx,v 1.29 2006-01-15 16:31:00 stephena Exp $
|
||||
*/
|
||||
class FrameBufferGL : public FrameBuffer
|
||||
{
|
||||
|
@ -198,10 +198,15 @@ class FrameBufferGL : public FrameBuffer
|
|||
virtual void addDirtyRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h);
|
||||
|
||||
/**
|
||||
Enable/disable phosphor effect
|
||||
Enable/disable phosphor effect.
|
||||
*/
|
||||
virtual void enablePhosphor(bool enable);
|
||||
|
||||
/**
|
||||
Completely erase contents of the screen.
|
||||
*/
|
||||
virtual void cls();
|
||||
|
||||
private:
|
||||
bool createTextures();
|
||||
|
||||
|
|
|
@ -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.42 2006-01-12 16:23:36 stephena Exp $
|
||||
// $Id: FrameBufferSoft.cxx,v 1.43 2006-01-15 16:31:01 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <SDL.h>
|
||||
|
@ -68,11 +68,6 @@ bool FrameBufferSoft::initSubsystem()
|
|||
if(myOSystem->settings().getBool("showinfo"))
|
||||
cout << "Video rendering: Software mode" << endl << endl;
|
||||
|
||||
// Precompute the GUI palette
|
||||
// We abuse the concept of 'enum' by referring directly to the integer values
|
||||
for(uInt8 i = 0; i < kNumColors-256; i++)
|
||||
myPalette[i+256] = mapRGB(ourGUIColors[i][0], ourGUIColors[i][1], ourGUIColors[i][2]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -638,6 +633,15 @@ void FrameBufferSoft::enablePhosphor(bool enable)
|
|||
myRenderType = kSoftZoom;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void FrameBufferSoft::cls()
|
||||
{
|
||||
if(myScreen)
|
||||
{
|
||||
SDL_FillRect(myScreen, NULL, 0);
|
||||
SDL_UpdateRect(myScreen, 0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
RectList::RectList(Uint32 size)
|
||||
|
|
|
@ -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.28 2006-01-12 16:23:36 stephena Exp $
|
||||
// $Id: FrameBufferSoft.hxx,v 1.29 2006-01-15 16:31:01 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.28 2006-01-12 16:23:36 stephena Exp $
|
||||
@version $Id: FrameBufferSoft.hxx,v 1.29 2006-01-15 16:31:01 stephena Exp $
|
||||
*/
|
||||
class FrameBufferSoft : public FrameBuffer
|
||||
{
|
||||
|
@ -187,10 +187,15 @@ class FrameBufferSoft : public FrameBuffer
|
|||
virtual void addDirtyRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h);
|
||||
|
||||
/**
|
||||
Enable/disable phosphor effect
|
||||
Enable/disable phosphor effect.
|
||||
*/
|
||||
virtual void enablePhosphor(bool enable);
|
||||
|
||||
/**
|
||||
Completely erase contents of the screen.
|
||||
*/
|
||||
virtual void cls();
|
||||
|
||||
protected:
|
||||
// Used in the dirty update of the SDL surface
|
||||
RectList* myRectList;
|
||||
|
|
|
@ -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.75 2006-01-14 23:55:23 stephena Exp $
|
||||
// $Id: FrameBuffer.cxx,v 1.76 2006-01-15 16:31:01 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <sstream>
|
||||
|
@ -87,16 +87,7 @@ void FrameBuffer::initialize(const string& title, uInt32 width, uInt32 height,
|
|||
return;
|
||||
}
|
||||
setWindowIcon();
|
||||
|
||||
// Erase contents of previous screen
|
||||
/* cls();
|
||||
if(myScreen)
|
||||
{
|
||||
cerr << "clear screen: w = " << myScreen->w << ", height = " << myScreen->h << endl;
|
||||
SDL_FillRect(myScreen, NULL, 0);
|
||||
SDL_UpdateRect(myScreen, 0, 0, 0, 0);
|
||||
}
|
||||
*/
|
||||
cls();
|
||||
|
||||
// Query the desktop size
|
||||
// This is really the job of SDL
|
||||
|
@ -131,6 +122,10 @@ cerr << "clear screen: w = " << myScreen->w << ", height = " << myScreen->h << e
|
|||
// Initialize video subsystem
|
||||
initSubsystem();
|
||||
|
||||
// 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]);
|
||||
|
||||
// Set emulation palette if a console exists
|
||||
// Used when entering/exiting debugger
|
||||
#ifdef DEVELOPER_SUPPORT
|
||||
|
|
|
@ -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.63 2006-01-11 13:25:20 stephena Exp $
|
||||
// $Id: FrameBuffer.hxx,v 1.64 2006-01-15 16:31:01 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef FRAMEBUFFER_HXX
|
||||
|
@ -51,7 +51,7 @@ enum FrameStyle {
|
|||
All GUI elements (ala ScummVM) are drawn here as well.
|
||||
|
||||
@author Stephen Anthony
|
||||
@version $Id: FrameBuffer.hxx,v 1.63 2006-01-11 13:25:20 stephena Exp $
|
||||
@version $Id: FrameBuffer.hxx,v 1.64 2006-01-15 16:31:01 stephena Exp $
|
||||
*/
|
||||
class FrameBuffer
|
||||
{
|
||||
|
@ -394,10 +394,15 @@ class FrameBuffer
|
|||
virtual void addDirtyRect(uInt32 x, uInt32 y, uInt32 w, uInt32 h) = 0;
|
||||
|
||||
/**
|
||||
Enable/disable phosphor effect
|
||||
Enable/disable phosphor effect.
|
||||
*/
|
||||
virtual void enablePhosphor(bool enable) = 0;
|
||||
|
||||
/**
|
||||
Completely erase contents of the screen.
|
||||
*/
|
||||
virtual void cls() = 0;
|
||||
|
||||
protected:
|
||||
// The parent system for the framebuffer
|
||||
OSystem* myOSystem;
|
||||
|
|
|
@ -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.37 2006-01-08 20:55:54 stephena Exp $
|
||||
// $Id: LauncherDialog.cxx,v 1.38 2006-01-15 16:31:01 stephena Exp $
|
||||
//
|
||||
// Based on code from ScummVM - Scumm Interpreter
|
||||
// Copyright (C) 2002-2004 The ScummVM project
|
||||
|
@ -381,6 +381,8 @@ void LauncherDialog::handleKeyDown(int ascii, int keycode, int modifiers)
|
|||
break;
|
||||
|
||||
case ' ': // Used to activate currently focused button
|
||||
case '\n':
|
||||
case '\r':
|
||||
Dialog::handleKeyDown(ascii, keycode, modifiers);
|
||||
break;
|
||||
|
||||
|
|
Loading…
Reference in New Issue