From d74765073020032a6d3582bc7cc085d8cde9604a Mon Sep 17 00:00:00 2001 From: stephena Date: Thu, 1 Sep 2005 21:53:44 +0000 Subject: [PATCH] Added PSP patches submitted by Aetna with some modifications. Patch includes optimized framebuffer rendering, and mapping of PSP specfic SDL codes to Stella events. PSP developers, please test this code. I don't have a PSP, so I can't test it myself. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@759 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- stella/src/common/FrameBufferSoft.cxx | 33 ++++++++++++++++++++++++++- stella/src/emucore/EventHandler.cxx | 33 +++++++++++++++++++++++---- 2 files changed, 60 insertions(+), 6 deletions(-) diff --git a/stella/src/common/FrameBufferSoft.cxx b/stella/src/common/FrameBufferSoft.cxx index 2336cdce3..3a3001475 100644 --- a/stella/src/common/FrameBufferSoft.cxx +++ b/stella/src/common/FrameBufferSoft.cxx @@ -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.36 2005-08-25 15:19:17 stephena Exp $ +// $Id: FrameBufferSoft.cxx,v 1.37 2005-09-01 21:53:44 stephena Exp $ //============================================================================ #include @@ -136,6 +136,34 @@ bool FrameBufferSoft::createScreen() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void FrameBufferSoft::drawMediaSource() { +#ifdef PSP + MediaSource& mediasrc = myOSystem->console().mediaSource(); + + SDL_LockSurface(myScreen); + + uInt8* currentFrame = mediasrc.currentFrameBuffer(); + + uInt32 width = mediasrc.width(); + uInt32 height = mediasrc.height(); + + register uInt32* buffer = (uInt32*) myScreen->pixels; + register uInt32 y; + + for(y = 0; y < height; ++y ) + { + const uInt32 bufofsY = y * width; + const uInt32 screenofsY = y * (myScreen->pitch >> 3); + + register uInt32 x; + for(x = 0; x < width; ++x ) + { + const uInt32 off = screenofsY + x << 1; + buffer[off] = buffer[off + 1] = myPalette[currentFrame[bufofsY + x]]; + } + } + + SDL_UnlockSurface(myScreen); +#else MediaSource& mediasrc = myOSystem->console().mediaSource(); uInt8* currentFrame = mediasrc.currentFrameBuffer(); @@ -283,11 +311,13 @@ void FrameBufferSoft::drawMediaSource() myRectList->add(&temp); SDL_FillRect(myScreen, &temp, myPalette[active.color]); } +#endif } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void FrameBufferSoft::preFrameUpdate() { +#ifndef PSP // Start a new rectlist on each display update myRectList->start(); @@ -296,6 +326,7 @@ void FrameBufferSoft::preFrameUpdate() for(unsigned int i = 0; i < myOverlayRectList->numRects(); ++i) myRectList->add(&dirtyOverlayRects[i]); myOverlayRectList->start(); +#endif } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/stella/src/emucore/EventHandler.cxx b/stella/src/emucore/EventHandler.cxx index 6252fc6b4..ecb37caab 100644 --- a/stella/src/emucore/EventHandler.cxx +++ b/stella/src/emucore/EventHandler.cxx @@ -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.92 2005-08-30 23:32:42 stephena Exp $ +// $Id: EventHandler.cxx,v 1.93 2005-09-01 21:53:44 stephena Exp $ //============================================================================ #include @@ -43,13 +43,19 @@ #endif #ifdef MAC_OSX -extern "C" { -void handleMacOSXKeypress(int key); -} + extern "C" { + void handleMacOSXKeypress(int key); + } #endif #define JOY_DEADZONE 3200 +#ifdef PSP + #define JOYMOUSE_LEFT_BUTTON 2 +#else + #define JOYMOUSE_LEFT_BUTTON 0 +#endif + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - EventHandler::EventHandler(OSystem* osystem) : myOSystem(osystem), @@ -983,7 +989,7 @@ void EventHandler::handleMouseWarp(uInt8 stick, uInt8 axis, Int16 value) void EventHandler::handleJoyEvent(uInt8 stick, uInt32 code, uInt8 state) { // Joystick button zero acts as left mouse button and cannot be remapped - if(myState != S_EMULATE && code == 0) + if(myState != S_EMULATE && code == JOYMOUSE_LEFT_BUTTON) { // This button acts as mouse button zero, and can never be remapped SDL_MouseButtonEvent mouseEvent; @@ -1380,6 +1386,23 @@ void EventHandler::setDefaultJoymap() myJoyTable[i + kJAxisRight] = Event::JoystickZeroRight; myJoyTable[i + 0] = Event::JoystickZeroFire; +#ifdef PSP + myJoyTable[i + 0] = Event::TakeSnapshot; // Triangle + myJoyTable[i + 1] = Event::LoadState; // Circle + myJoyTable[i + 2] = Event::JoystickZeroFire; // Cross + myJoyTable[i + 3] = Event::SaveState; // Square + myJoyTable[i + 4] = Event::MenuMode; // Left trigger + myJoyTable[i + 5] = Event::CmdMenuMode; // Right trigger +// myJoyTable[i + 6] = Event::NoType // Down +// myJoyTable[i + 7] = Event::NoType // Left +// myJoyTable[i + 8] = Event::NoType // Up +// myJoyTable[i + 9] = Event::NoType // Right + myJoyTable[i + 10] = Event::ConsoleSelect; // Select + myJoyTable[i + 11] = Event::ConsoleReset; // Start + myJoyTable[i + 12] = Event::NoType; // Home + myJoyTable[i + 13] = Event::NoType; // Hold +#endif + // Right joystick i = 1 * kNumJoyButtons; myJoyTable[i + kJAxisUp] = Event::JoystickOneUp;