diff --git a/stella/src/psp/FrameBufferPSP.cxx b/stella/src/psp/FrameBufferPSP.cxx new file mode 100644 index 000000000..fd87db198 --- /dev/null +++ b/stella/src/psp/FrameBufferPSP.cxx @@ -0,0 +1,119 @@ +//============================================================================ +// +// SSSS tt lll lll +// SS SS tt ll ll +// SS tttttt eeee ll ll aaaa +// SSSS tt ee ee ll ll aa +// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" +// SS SS tt ee ll ll aa aa +// SSSS ttt eeeee llll llll aaaaa +// +// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team +// +// See the file "license" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +// +// $Id: FrameBufferPSP.cxx,v 1.1 2005-09-18 14:35:59 optixx Exp $ +//============================================================================ + +#include +#include +#include + +#include "Console.hxx" +#include "FrameBufferPSP.hxx" +#include "MediaSrc.hxx" +#include "Settings.hxx" +#include "OSystem.hxx" +#include "Font.hxx" +#include "GuiUtils.hxx" + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +FrameBufferPSP::FrameBufferPSP(OSystem* osystem) + : FrameBufferSoft(osystem) +{ +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +FrameBufferPSP::~FrameBufferPSP() +{ + delete myRectList; + delete myOverlayRectList; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool FrameBufferPSP::initSubsystem() +{ + // Set up the rectangle list to be used in the dirty update + delete myRectList; + myRectList = new RectList(); + delete myOverlayRectList; + myOverlayRectList = new RectList(); + +#ifdef PSP_DEBUG + fprintf(stdout, "FrameBufferPSP::initSubsystem\n"); +#endif + if(!myRectList || !myOverlayRectList) + { + cerr << "ERROR: Unable to get memory for SDL rects" << endl; + return false; + } + + // Create the screen + if(!createScreen()) + return false; + + // Show some info + 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; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool FrameBufferPSP::createScreen() +{ + myScreenDim.x = myScreenDim.y = 0; + + myScreenDim.w = myBaseDim.w; + myScreenDim.h = myBaseDim.h; + + // In software mode, the image and screen dimensions are always the same + myImageDim = myScreenDim; + if (mySDLFlags & SDL_HWSURFACE ) + { + /* double buff is broken */ + mySDLFlags = SDL_HWSURFACE; + myScreenDim.w = myDesktopDim.w; + myScreenDim.h = myDesktopDim.w; +#ifdef PSP_DEBUG + fprintf(stdout, "FrameBufferPSP::createScreen Hardware Mode " + "myScreenDim.w='%i' myScreenDim.h='%i'\n", + myScreenDim.w,myScreenDim.h); +#endif +} + else +{ +#ifdef PSP_DEBUG + fprintf(stdout, "FrameBufferPSP::createScreen Software Mode " + "myScreenDim.w='%i' myScreenDim.h='%i'\n", + myScreenDim.w,myScreenDim.h); +#endif +} + + myScreen = SDL_SetVideoMode(myScreenDim.w, myScreenDim.h, 0, mySDLFlags); + if(myScreen == NULL) + { + fprintf(stdout,"ERROR: Unable to open SDL window: %s\n",SDL_GetError()); + return false; + } + myOSystem->eventHandler().refreshDisplay(); + + return true; +} + diff --git a/stella/src/psp/FrameBufferPSP.hxx b/stella/src/psp/FrameBufferPSP.hxx new file mode 100644 index 000000000..c75838aac --- /dev/null +++ b/stella/src/psp/FrameBufferPSP.hxx @@ -0,0 +1,68 @@ +//============================================================================ +// +// SSSS tt lll lll +// SS SS tt ll ll +// SS tttttt eeee ll ll aaaa +// SSSS tt ee ee ll ll aa +// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" +// SS SS tt ee ll ll aa aa +// SSSS ttt eeeee llll llll aaaaa +// +// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team +// +// See the file "license" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +// +// $Id: FrameBufferPSP.hxx,v 1.1 2005-09-18 14:35:59 optixx Exp $ +//============================================================================ + +#ifndef FRAMEBUFFER_PSP_HXX +#define FRAMEBUFFER_PSP_HXX + + + +#include "Font.hxx" +#include "bspf.hxx" +#include "GuiUtils.hxx" +#include "FrameBufferSoft.hxx" + + +/** + This class implements an SDL software framebuffer. + + @author Stephen Anthony + @version $Id: FrameBufferPSP.hxx,v 1.1 2005-09-18 14:35:59 optixx Exp $ +*/ +class FrameBufferPSP : public FrameBufferSoft +{ + public: + /** + Creates a new software framebuffer + */ + FrameBufferPSP(OSystem* osystem); + + /** + Destructor + */ + virtual ~FrameBufferPSP(); + + ////////////////////////////////////////////////////////////////////// + // The following methods are derived from FrameBuffer.hxx + ////////////////////////////////////////////////////////////////////// + /** + This method is called to initialize software video mode. + Return false if any operation fails, otherwise return true. + */ + virtual bool initSubsystem(); + + /** + This method is called whenever the screen needs to be recreated. + It updates the global screen variable. + */ + virtual bool createScreen(); + + +}; + + +#endif diff --git a/stella/src/psp/module.mk b/stella/src/psp/module.mk index 06921040a..15261f84a 100644 --- a/stella/src/psp/module.mk +++ b/stella/src/psp/module.mk @@ -3,8 +3,8 @@ MODULE := src/psp MODULE_OBJS := \ src/psp/FSNodePSP.o \ src/psp/OSystemPSP.o \ - src/psp/SettingsPSP.o - + src/psp/SettingsPSP.o \ + src/psp/FrameBufferPSP.o MODULE_DIRS += \ src/psp