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
This commit is contained in:
stephena 2005-09-01 21:53:44 +00:00
parent e0490c08c7
commit d747650730
2 changed files with 60 additions and 6 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: 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 <SDL.h>
@ -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
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

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.92 2005-08-30 23:32:42 stephena Exp $
// $Id: EventHandler.cxx,v 1.93 2005-09-01 21:53:44 stephena Exp $
//============================================================================
#include <algorithm>
@ -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;