some cleanup

svn-id: r22753
This commit is contained in:
Joost Peters 2006-05-29 18:06:02 +00:00
parent e4e145b5bc
commit e1844e485f
2 changed files with 96 additions and 156 deletions

View file

@ -80,43 +80,35 @@ OSystem_PSP::~OSystem_PSP() {
if (_mouseBuf) free(_mouseBuf); if (_mouseBuf) free(_mouseBuf);
} }
bool OSystem_PSP::hasFeature(Feature f) bool OSystem_PSP::hasFeature(Feature f) {
{
return false; return false;
} }
void OSystem_PSP::setFeatureState(Feature f, bool enable) void OSystem_PSP::setFeatureState(Feature f, bool enable) {
{
} }
bool OSystem_PSP::getFeatureState(Feature f) bool OSystem_PSP::getFeatureState(Feature f) {
{
return false; return false;
} }
const OSystem::GraphicsMode* OSystem_PSP::getSupportedGraphicsModes() const const OSystem::GraphicsMode* OSystem_PSP::getSupportedGraphicsModes() const {
{
return s_supportedGraphicsModes; return s_supportedGraphicsModes;
} }
int OSystem_PSP::getDefaultGraphicsMode() const int OSystem_PSP::getDefaultGraphicsMode() const {
{
return -1; return -1;
} }
bool OSystem_PSP::setGraphicsMode(int mode) bool OSystem_PSP::setGraphicsMode(int mode) {
{
return true; return true;
} }
bool OSystem_PSP::setGraphicsMode(const char *name) bool OSystem_PSP::setGraphicsMode(const char *name) {
{
return true; return true;
} }
int OSystem_PSP::getGraphicsMode() const int OSystem_PSP::getGraphicsMode() const {
{
return -1; return -1;
} }
@ -240,29 +232,24 @@ void OSystem_PSP::setShakePos(int shakeOffset) {
_shakePos = shakeOffset; _shakePos = shakeOffset;
} }
void OSystem_PSP::showOverlay () void OSystem_PSP::showOverlay() {
{
_overlayVisible = true; _overlayVisible = true;
} }
void OSystem_PSP::hideOverlay () void OSystem_PSP::hideOverlay() {
{
PSPDebugTrace("OSystem_PSP::hideOverlay called\n"); PSPDebugTrace("OSystem_PSP::hideOverlay called\n");
_overlayVisible = false; _overlayVisible = false;
} }
void OSystem_PSP::clearOverlay () void OSystem_PSP::clearOverlay() {
{
PSPDebugTrace("clearOverlay\n"); PSPDebugTrace("clearOverlay\n");
bzero(_overlayBuffer, _overlayWidth * _overlayHeight * sizeof(OverlayColor)); bzero(_overlayBuffer, _overlayWidth * _overlayHeight * sizeof(OverlayColor));
} }
void OSystem_PSP::grabOverlay (OverlayColor *buf, int pitch) void OSystem_PSP::grabOverlay(OverlayColor *buf, int pitch) {
{
} }
void OSystem_PSP::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) void OSystem_PSP::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) {
{
PSPDebugTrace("copyRectToOverlay\n"); PSPDebugTrace("copyRectToOverlay\n");
//Clip the coordinates //Clip the coordinates
@ -302,30 +289,25 @@ void OSystem_PSP::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, i
} }
} }
int16 OSystem_PSP::getOverlayWidth() int16 OSystem_PSP::getOverlayWidth() {
{
return _overlayWidth; return _overlayWidth;
} }
int16 OSystem_PSP::getOverlayHeight() int16 OSystem_PSP::getOverlayHeight() {
{
return _overlayHeight; return _overlayHeight;
} }
OverlayColor OSystem_PSP::RGBToColor(uint8 r, uint8 g, uint8 b) OverlayColor OSystem_PSP::RGBToColor(uint8 r, uint8 g, uint8 b) {
{
return (((r >> 3) & 0x1F) | (((g >> 3) & 0x1F) << 5) | (((b >> 3) & 0x1F) << 10 ) ) | 0x8000; return (((r >> 3) & 0x1F) | (((g >> 3) & 0x1F) << 5) | (((b >> 3) & 0x1F) << 10 ) ) | 0x8000;
} }
void OSystem_PSP::colorToRGB(OverlayColor color, uint8 &r, uint8 &g, uint8 &b) void OSystem_PSP::colorToRGB(OverlayColor color, uint8 &r, uint8 &g, uint8 &b) {
{
r = ((color & 0x1F) << 3); r = ((color & 0x1F) << 3);
g = (((color >> 5) & 0x1F) << 3); g = (((color >> 5) & 0x1F) << 3);
b = (((color >> 10) & 0x1F) << 3); b = (((color >> 10) & 0x1F) << 3);
} }
OverlayColor OSystem_PSP::ARGBToColor(uint8 a, uint8 r, uint8 g, uint8 b) OverlayColor OSystem_PSP::ARGBToColor(uint8 a, uint8 r, uint8 g, uint8 b) {
{
OverlayColor color = RGBToColor(r, g, b); OverlayColor color = RGBToColor(r, g, b);
if(a == 255) if(a == 255)
@ -334,8 +316,7 @@ OverlayColor OSystem_PSP::ARGBToColor(uint8 a, uint8 r, uint8 g, uint8 b)
return color; return color;
} }
void OSystem_PSP::colorToARGB(OverlayColor color, uint8 &a, uint8 &r, uint8 &g, uint8 &b) void OSystem_PSP::colorToARGB(OverlayColor color, uint8 &a, uint8 &r, uint8 &g, uint8 &b) {
{
colorToRGB(color, r, g, b); colorToRGB(color, r, g, b);
if(color & 0x8000) if(color & 0x8000)
a = 255; a = 255;
@ -343,13 +324,11 @@ void OSystem_PSP::colorToARGB(OverlayColor color, uint8 &a, uint8 &r, uint8 &g,
a = 0; a = 0;
} }
void OSystem_PSP::grabPalette(byte *colors, uint start, uint num) void OSystem_PSP::grabPalette(byte *colors, uint start, uint num) {
{
uint i; uint i;
uint16 color; uint16 color;
for(i=start; i < start+num; i++) for (i = start; i < start + num; i++) {
{
color = _palette[i]; color = _palette[i];
*colors++ = ((color & 0x1F) << 3); *colors++ = ((color & 0x1F) << 3);
*colors++ = (((color >> 5) & 0x1F) << 3); *colors++ = (((color >> 5) & 0x1F) << 3);
@ -530,7 +509,6 @@ uint32 OSystem_PSP::getMillis() {
} }
void OSystem_PSP::delayMillis(uint msecs) { void OSystem_PSP::delayMillis(uint msecs) {
sceKernelDelayThread(1); // Sleep thread for 1 millionth of a second to allow callback threads to run
SDL_Delay(msecs); SDL_Delay(msecs);
} }

View file

@ -114,13 +114,9 @@ OSystem_PSP_GU::OSystem_PSP_GU() {
_graphicMode = STRETCHED_480X272; _graphicMode = STRETCHED_480X272;
_keySelected = 1; _keySelected = 1;
_keyboardMode = 0; _keyboardMode = 0;
//_graphicMode = CENTERED_435X272;
//_graphicMode = CENTERED_320X200;
//_graphicMode = CENTERED_362X272;
} }
OSystem_PSP_GU::~OSystem_PSP_GU() OSystem_PSP_GU::~OSystem_PSP_GU() {
{
free(keyboard_symbols_shift); free(keyboard_symbols_shift);
free(keyboard_symbols); free(keyboard_symbols);
free(keyboard_letters_shift); free(keyboard_letters_shift);
@ -155,25 +151,20 @@ void OSystem_PSP_GU::initSize(uint width, uint height) {
sceKernelDcacheWritebackAll(); sceKernelDcacheWritebackAll();
} }
int OSystem_PSP_GU::getDefaultGraphicsMode() const int OSystem_PSP_GU::getDefaultGraphicsMode() const {
{
return STRETCHED_480X272; return STRETCHED_480X272;
} }
bool OSystem_PSP_GU::setGraphicsMode(int mode) bool OSystem_PSP_GU::setGraphicsMode(int mode) {
{
_graphicMode = mode; _graphicMode = mode;
return true; return true;
} }
bool OSystem_PSP_GU::setGraphicsMode(const char *name) bool OSystem_PSP_GU::setGraphicsMode(const char *name) {
{
int i = 0; int i = 0;
while(s_supportedGraphicsModes[i].name) while(s_supportedGraphicsModes[i].name) {
{ if(!strcmpi(s_supportedGraphicsModes[i].name, name)) {
if(!strcmpi(s_supportedGraphicsModes[i].name, name))
{
_graphicMode = s_supportedGraphicsModes[i].id; _graphicMode = s_supportedGraphicsModes[i].id;
return true; return true;
} }
@ -183,8 +174,7 @@ bool OSystem_PSP_GU::setGraphicsMode(const char *name)
return false; return false;
} }
int OSystem_PSP_GU::getGraphicsMode() const int OSystem_PSP_GU::getGraphicsMode() const {
{
return _graphicMode; return _graphicMode;
} }
@ -225,8 +215,7 @@ void OSystem_PSP_GU::setPalette(const byte *colors, uint start, uint num) {
} }
void OSystem_PSP_GU::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) void OSystem_PSP_GU::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) {
{
//Clip the coordinates //Clip the coordinates
if (x < 0) { if (x < 0) {
w += x; w += x;
@ -275,9 +264,7 @@ void OSystem_PSP_GU::copyRectToScreen(const byte *buf, int pitch, int x, int y,
} }
} }
void void OSystem_PSP_GU::updateScreen() {
OSystem_PSP_GU::updateScreen()
{
float scale; float scale;
sceGuStart(0,list); sceGuStart(0,list);
@ -300,24 +287,23 @@ OSystem_PSP_GU::updateScreen()
struct Vertex* vertices = (struct Vertex*)sceGuGetMemory(2 * sizeof(struct Vertex)); struct Vertex* vertices = (struct Vertex*)sceGuGetMemory(2 * sizeof(struct Vertex));
vertices[0].u = 0.5; vertices[0].v = 0.5; vertices[0].u = 0.5; vertices[0].v = 0.5;
vertices[1].u = _screenWidth-0.5; vertices[1].v = _screenHeight-0.5; vertices[1].u = _screenWidth - 0.5; vertices[1].v = _screenHeight - 0.5;
switch(_graphicMode) switch(_graphicMode) {
{
case CENTERED_320X200: case CENTERED_320X200:
vertices[0].x = (PSP_SCREEN_WIDTH-320)/2; vertices[0].y = (PSP_SCREEN_HEIGHT-200)/2; vertices[0].z = 0; vertices[0].x = (PSP_SCREEN_WIDTH - 320) / 2; vertices[0].y = (PSP_SCREEN_HEIGHT - 200) / 2; vertices[0].z = 0;
vertices[1].x = PSP_SCREEN_WIDTH-(PSP_SCREEN_WIDTH-320)/2; vertices[1].y = PSP_SCREEN_HEIGHT-(PSP_SCREEN_HEIGHT-200)/2; vertices[1].z = 0; vertices[1].x = PSP_SCREEN_WIDTH - (PSP_SCREEN_WIDTH - 320) / 2; vertices[1].y = PSP_SCREEN_HEIGHT - (PSP_SCREEN_HEIGHT - 200) / 2; vertices[1].z = 0;
break; break;
case CENTERED_435X272: case CENTERED_435X272:
vertices[0].x = (PSP_SCREEN_WIDTH-435)/2; vertices[0].y = 0; vertices[0].z = 0; vertices[0].x = (PSP_SCREEN_WIDTH - 435) / 2; vertices[0].y = 0; vertices[0].z = 0;
vertices[1].x = PSP_SCREEN_WIDTH-(PSP_SCREEN_WIDTH-435)/2; vertices[1].y = PSP_SCREEN_HEIGHT; vertices[1].z = 0; vertices[1].x = PSP_SCREEN_WIDTH - (PSP_SCREEN_WIDTH - 435) / 2; vertices[1].y = PSP_SCREEN_HEIGHT; vertices[1].z = 0;
break; break;
case STRETCHED_480X272: case STRETCHED_480X272:
vertices[0].x = 0; vertices[0].y = 0; vertices[0].z = 0; vertices[0].x = 0; vertices[0].y = 0; vertices[0].z = 0;
vertices[1].x = PSP_SCREEN_WIDTH; vertices[1].y = PSP_SCREEN_HEIGHT; vertices[1].z = 0; vertices[1].x = PSP_SCREEN_WIDTH; vertices[1].y = PSP_SCREEN_HEIGHT; vertices[1].z = 0;
break; break;
case CENTERED_362X272: case CENTERED_362X272:
vertices[0].x = (PSP_SCREEN_WIDTH-362)/2; vertices[0].y = 0; vertices[0].z = 0; vertices[0].x = (PSP_SCREEN_WIDTH - 362) / 2; vertices[0].y = 0; vertices[0].z = 0;
vertices[1].x = PSP_SCREEN_WIDTH-(PSP_SCREEN_WIDTH-362)/2; vertices[1].y = PSP_SCREEN_HEIGHT; vertices[1].z = 0; vertices[1].x = PSP_SCREEN_WIDTH - (PSP_SCREEN_WIDTH - 362) / 2; vertices[1].y = PSP_SCREEN_HEIGHT; vertices[1].z = 0;
break; break;
} }
@ -326,25 +312,23 @@ OSystem_PSP_GU::updateScreen()
vertices[1].y += _shakePos; vertices[1].y += _shakePos;
} }
sceGuDrawArray(GU_SPRITES,GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_2D,2,0,vertices); sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_2D, 2, 0, vertices);
if(_screenWidth==640) if(_screenWidth == 640) {
{
sceGuTexImage(0, 512, 512, _screenWidth, _offscreen+512); sceGuTexImage(0, 512, 512, _screenWidth, _offscreen+512);
vertices[0].u = 512 + 0.5; vertices[1].v = _screenHeight - 0.5; vertices[0].u = 512 + 0.5; vertices[1].v = _screenHeight - 0.5;
vertices[0].x += (vertices[1].x-vertices[0].x)*511/640; vertices[0].y = 0; vertices[0].z = 0; vertices[0].x += (vertices[1].x - vertices[0].x) * 511 / 640; vertices[0].y = 0; vertices[0].z = 0;
sceGuDrawArray(GU_SPRITES,GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_2D,2,0,vertices); sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_2D, 2, 0, vertices);
} }
// draw overlay // draw overlay
if(_overlayVisible) if(_overlayVisible) {
{
vertices[0].x = 0; vertices[0].y = 0; vertices[0].z = 0; vertices[0].x = 0; vertices[0].y = 0; vertices[0].z = 0;
vertices[1].x = PSP_SCREEN_WIDTH; vertices[1].y = PSP_SCREEN_HEIGHT; vertices[1].z = 0; vertices[1].x = PSP_SCREEN_WIDTH; vertices[1].y = PSP_SCREEN_HEIGHT; vertices[1].z = 0;
vertices[0].u = 0.5; vertices[0].v = 0.5; vertices[0].u = 0.5; vertices[0].v = 0.5;
vertices[1].u = _overlayWidth-0.5; vertices[1].v = _overlayHeight-0.5; vertices[1].u = _overlayWidth - 0.5; vertices[1].v = _overlayHeight - 0.5;
sceGuTexMode(GU_PSM_5551, 0, 0, 0); // 16-bit image sceGuTexMode(GU_PSM_5551, 0, 0, 0); // 16-bit image
sceGuAlphaFunc(GU_GREATER,0,0xff); sceGuAlphaFunc(GU_GREATER, 0, 0xff);
sceGuEnable(GU_ALPHA_TEST); sceGuEnable(GU_ALPHA_TEST);
if (_overlayWidth > 320) if (_overlayWidth > 320)
sceGuTexImage(0, 512, 512, _overlayWidth, _overlayBuffer); sceGuTexImage(0, 512, 512, _overlayWidth, _overlayBuffer);
@ -354,18 +338,16 @@ OSystem_PSP_GU::updateScreen()
sceGuTexFunc(GU_TFX_MODULATE, GU_TCC_RGBA); sceGuTexFunc(GU_TFX_MODULATE, GU_TCC_RGBA);
sceGuDrawArray(GU_SPRITES,GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_2D,2,0,vertices); sceGuDrawArray(GU_SPRITES,GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_2D,2,0,vertices);
// need to render twice for textures > 512 // need to render twice for textures > 512
if( _overlayWidth > 512) if( _overlayWidth > 512) {
{ sceGuTexImage(0, 512, 512, _overlayWidth, _overlayBuffer + 512);
sceGuTexImage(0, 512, 512, _overlayWidth, _overlayBuffer+512);
vertices[0].u = 512 + 0.5; vertices[1].v = _overlayHeight - 0.5; vertices[0].u = 512 + 0.5; vertices[1].v = _overlayHeight - 0.5;
vertices[0].x = PSP_SCREEN_WIDTH*512/640; vertices[0].y = 0; vertices[0].z = 0; vertices[0].x = PSP_SCREEN_WIDTH * 512 / 640; vertices[0].y = 0; vertices[0].z = 0;
sceGuDrawArray(GU_SPRITES,GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_2D,2,0,vertices); sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_2D, 2, 0, vertices);
} }
} }
// draw mouse // draw mouse
if (_mouseVisible) if (_mouseVisible) {
{
sceGuTexMode(GU_PSM_T8, 0, 0, 0); // 8-bit image sceGuTexMode(GU_PSM_T8, 0, 0, 0); // 8-bit image
sceGuClutMode(GU_PSM_5551, 0, 0xff, 0); sceGuClutMode(GU_PSM_5551, 0, 0xff, 0);
sceGuClutLoad(32, mouseClut); // upload 32*8 entries (256) sceGuClutLoad(32, mouseClut); // upload 32*8 entries (256)
@ -375,72 +357,67 @@ OSystem_PSP_GU::updateScreen()
sceGuTexFunc(GU_TFX_MODULATE, GU_TCC_RGBA); sceGuTexFunc(GU_TFX_MODULATE, GU_TCC_RGBA);
vertices[0].u = 0.5; vertices[0].v = 0.5; vertices[0].u = 0.5; vertices[0].v = 0.5;
vertices[1].u = _mouseWidth-0.5; vertices[1].v = _mouseHeight-0.5; vertices[1].u = _mouseWidth - 0.5; vertices[1].v = _mouseHeight - 0.5;
//adjust cursor position //adjust cursor position
int mX = _mouseX - _mouseHotspotX; int mX = _mouseX - _mouseHotspotX;
int mY = _mouseY - _mouseHotspotY; int mY = _mouseY - _mouseHotspotY;
if(_overlayVisible) if(_overlayVisible) {
{
float scalex, scaley; float scalex, scaley;
scalex = (float)PSP_SCREEN_WIDTH/_overlayWidth; scalex = (float)PSP_SCREEN_WIDTH /_overlayWidth;
scaley = (float)PSP_SCREEN_HEIGHT/_overlayHeight; scaley = (float)PSP_SCREEN_HEIGHT /_overlayHeight;
vertices[0].x = mX*scalex; vertices[0].y = mY*scaley; vertices[0].z = 0; vertices[0].x = mX * scalex; vertices[0].y = mY * scaley; vertices[0].z = 0;
vertices[1].x = vertices[0].x+_mouseWidth*scalex; vertices[1].y = vertices[0].y + _mouseHeight*scaley; vertices[0].z = 0; vertices[1].x = vertices[0].x + _mouseWidth * scalex; vertices[1].y = vertices[0].y + _mouseHeight * scaley; vertices[0].z = 0;
} } else
else switch(_graphicMode) {
switch(_graphicMode)
{
case CENTERED_320X200: case CENTERED_320X200:
vertices[0].x = (PSP_SCREEN_WIDTH-320)/2+mX; vertices[0].y = (PSP_SCREEN_HEIGHT-200)/2+mY; vertices[0].z = 0; vertices[0].x = (PSP_SCREEN_WIDTH - 320) / 2 + mX; vertices[0].y = (PSP_SCREEN_HEIGHT - 200) / 2 + mY; vertices[0].z = 0;
vertices[1].x = vertices[0].x+_mouseWidth; vertices[1].y = vertices[0].y + _mouseHeight; vertices[1].z = 0; vertices[1].x = vertices[0].x+_mouseWidth; vertices[1].y = vertices[0].y + _mouseHeight; vertices[1].z = 0;
break; break;
case CENTERED_435X272: case CENTERED_435X272:
{ {
scale = 435.0f/_screenWidth; scale = 435.0f / _screenWidth;
vertices[0].x = (PSP_SCREEN_WIDTH-435)/2 +mX*scale; vertices[0].y = mY*scale; vertices[0].z = 0; vertices[0].x = (PSP_SCREEN_WIDTH - 435) / 2 + mX * scale; vertices[0].y = mY * scale; vertices[0].z = 0;
vertices[1].x = vertices[0].x+_mouseWidth*scale; vertices[1].y = vertices[0].y + _mouseHeight*scale; vertices[0].z = 0; vertices[1].x = vertices[0].x + _mouseWidth * scale; vertices[1].y = vertices[0].y + _mouseHeight * scale; vertices[0].z = 0;
} }
break; break;
case CENTERED_362X272: case CENTERED_362X272:
{ {
float scalex, scaley; float scalex, scaley;
scalex = 362.0f/_screenWidth; scalex = 362.0f / _screenWidth;
scaley = 272.0f/_screenHeight; scaley = 272.0f / _screenHeight;
vertices[0].x = (PSP_SCREEN_WIDTH-362)/2 +mX*scalex; vertices[0].y = mY*scaley; vertices[0].z = 0; vertices[0].x = (PSP_SCREEN_WIDTH - 362) / 2 + mX * scalex; vertices[0].y = mY * scaley; vertices[0].z = 0;
vertices[1].x = vertices[0].x+_mouseWidth*scalex; vertices[1].y = vertices[0].y + _mouseHeight*scaley; vertices[0].z = 0; vertices[1].x = vertices[0].x + _mouseWidth * scalex; vertices[1].y = vertices[0].y + _mouseHeight * scaley; vertices[0].z = 0;
} }
break; break;
case STRETCHED_480X272: case STRETCHED_480X272:
{ {
float scalex, scaley; float scalex, scaley;
scalex = (float)PSP_SCREEN_WIDTH/_screenWidth; scalex = (float)PSP_SCREEN_WIDTH / _screenWidth;
scaley = (float)PSP_SCREEN_HEIGHT/_screenHeight; scaley = (float)PSP_SCREEN_HEIGHT / _screenHeight;
vertices[0].x = mX*scalex; vertices[0].y = mY*scaley; vertices[0].z = 0; vertices[0].x = mX * scalex; vertices[0].y = mY * scaley; vertices[0].z = 0;
vertices[1].x = vertices[0].x+_mouseWidth*scalex; vertices[1].y = vertices[0].y + _mouseHeight*scaley; vertices[0].z = 0; vertices[1].x = vertices[0].x + _mouseWidth * scalex; vertices[1].y = vertices[0].y + _mouseHeight * scaley; vertices[0].z = 0;
} }
break; break;
} }
sceGuDrawArray(GU_SPRITES,GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_2D,2,0,vertices); sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_2D, 2, 0, vertices);
} }
if(_keyboardVisible) if(_keyboardVisible) {
{
sceGuTexMode(GU_PSM_T8, 0, 0, 0); // 8-bit image sceGuTexMode(GU_PSM_T8, 0, 0, 0); // 8-bit image
sceGuClutMode(GU_PSM_4444, 0, 0xff, 0); sceGuClutMode(GU_PSM_4444, 0, 0xff, 0);
sceGuClutLoad(32, kbClut); // upload 32*8 entries (256) sceGuClutLoad(32, kbClut); // upload 32*8 entries (256)
sceGuDisable(GU_ALPHA_TEST); sceGuDisable(GU_ALPHA_TEST);
sceGuEnable(GU_BLEND); sceGuEnable(GU_BLEND);
sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0); sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0);
switch(_keyboardMode) switch(_keyboardMode) {
{
case 0: case 0:
sceGuTexImage(0, 512, 512, 480, keyboard_letters); sceGuTexImage(0, 512, 512, 480, keyboard_letters);
break; break;
@ -484,8 +461,7 @@ bool OSystem_PSP_GU::pollEvent(Event &event) {
uint32 buttonsChanged = pad.Buttons ^ _prevButtons; uint32 buttonsChanged = pad.Buttons ^ _prevButtons;
if ((buttonsChanged & PSP_CTRL_SELECT) || (pad.Buttons & PSP_CTRL_SELECT)) if ((buttonsChanged & PSP_CTRL_SELECT) || (pad.Buttons & PSP_CTRL_SELECT)) {
{
if( !(pad.Buttons & PSP_CTRL_SELECT) ) if( !(pad.Buttons & PSP_CTRL_SELECT) )
_keyboardVisible = !_keyboardVisible; _keyboardVisible = !_keyboardVisible;
_prevButtons = pad.Buttons; _prevButtons = pad.Buttons;
@ -501,8 +477,7 @@ bool OSystem_PSP_GU::pollEvent(Event &event) {
if ( (buttonsChanged & PSP_CTRL_LTRIGGER) && !(pad.Buttons & PSP_CTRL_LTRIGGER)) if ( (buttonsChanged & PSP_CTRL_LTRIGGER) && !(pad.Buttons & PSP_CTRL_LTRIGGER))
_keyboardMode ^= SYMBOLS; _keyboardMode ^= SYMBOLS;
if ( (buttonsChanged & PSP_CTRL_LEFT) && !(pad.Buttons & PSP_CTRL_LEFT)) if ( (buttonsChanged & PSP_CTRL_LEFT) && !(pad.Buttons & PSP_CTRL_LEFT)) {
{
event.kbd.flags = 0; event.kbd.flags = 0;
event.kbd.ascii = 0; event.kbd.ascii = 0;
event.kbd.keycode = SDLK_LEFT; event.kbd.keycode = SDLK_LEFT;
@ -510,8 +485,7 @@ bool OSystem_PSP_GU::pollEvent(Event &event) {
return true; return true;
} }
if ( (buttonsChanged & PSP_CTRL_RIGHT) && !(pad.Buttons & PSP_CTRL_RIGHT)) if ( (buttonsChanged & PSP_CTRL_RIGHT) && !(pad.Buttons & PSP_CTRL_RIGHT)) {
{
event.kbd.flags = 0; event.kbd.flags = 0;
event.kbd.ascii = 0; event.kbd.ascii = 0;
event.kbd.keycode = SDLK_RIGHT; event.kbd.keycode = SDLK_RIGHT;
@ -519,8 +493,7 @@ bool OSystem_PSP_GU::pollEvent(Event &event) {
return true; return true;
} }
if ( (buttonsChanged & PSP_CTRL_UP) && !(pad.Buttons & PSP_CTRL_UP)) if ( (buttonsChanged & PSP_CTRL_UP) && !(pad.Buttons & PSP_CTRL_UP)) {
{
event.kbd.flags = 0; event.kbd.flags = 0;
event.kbd.ascii = 0; event.kbd.ascii = 0;
event.kbd.keycode = SDLK_UP; event.kbd.keycode = SDLK_UP;
@ -528,8 +501,7 @@ bool OSystem_PSP_GU::pollEvent(Event &event) {
return true; return true;
} }
if ( (buttonsChanged & PSP_CTRL_DOWN) && !(pad.Buttons & PSP_CTRL_DOWN)) if ( (buttonsChanged & PSP_CTRL_DOWN) && !(pad.Buttons & PSP_CTRL_DOWN)) {
{
event.kbd.flags = 0; event.kbd.flags = 0;
event.kbd.ascii = 0; event.kbd.ascii = 0;
event.kbd.keycode = SDLK_DOWN; event.kbd.keycode = SDLK_DOWN;
@ -538,27 +510,22 @@ bool OSystem_PSP_GU::pollEvent(Event &event) {
} }
// compute nub direction // compute nub direction
//
x = pad.Lx-128; x = pad.Lx-128;
y = pad.Ly-128; y = pad.Ly-128;
_kbdClut[_keySelected] = 0xf888; _kbdClut[_keySelected] = 0xf888;
if(x*x + y*y > 10000) if(x*x + y*y > 10000) {
{
nub_angle = atan2(y, x); nub_angle = atan2(y, x);
_keySelected = (int)(1+(M_PI+nub_angle)*30/(2*M_PI)); _keySelected = (int)(1 + (M_PI + nub_angle) * 30 / (2 * M_PI));
_keySelected -= 2; _keySelected -= 2;
if(_keySelected < 1) if(_keySelected < 1)
_keySelected += 30; _keySelected += 30;
_kbdClut[_keySelected] = 0xffff; _kbdClut[_keySelected] = 0xffff;
if (buttonsChanged & PSP_CTRL_CROSS) if (buttonsChanged & PSP_CTRL_CROSS) {
{
event.type = (pad.Buttons & PSP_CTRL_CROSS) ? OSystem::EVENT_KEYDOWN : OSystem::EVENT_KEYUP; event.type = (pad.Buttons & PSP_CTRL_CROSS) ? OSystem::EVENT_KEYDOWN : OSystem::EVENT_KEYUP;
if(_keySelected >26) if(_keySelected > 26) {
{
event.kbd.flags = 0; event.kbd.flags = 0;
switch(_keySelected) switch(_keySelected) {
{
case 27: case 27:
event.kbd.ascii = ' '; event.kbd.ascii = ' ';
event.kbd.keycode = SDLK_SPACE; event.kbd.keycode = SDLK_SPACE;
@ -576,11 +543,8 @@ bool OSystem_PSP_GU::pollEvent(Event &event) {
event.kbd.keycode = SDLK_RETURN; event.kbd.keycode = SDLK_RETURN;
break; break;
} }
} } else {
else switch( _keyboardMode) {
{
switch( _keyboardMode)
{
case 0: case 0:
event.kbd.flags = 0; event.kbd.flags = 0;
event.kbd.ascii = 'a'+_keySelected-1; event.kbd.ascii = 'a'+_keySelected-1;
@ -592,16 +556,14 @@ bool OSystem_PSP_GU::pollEvent(Event &event) {
event.kbd.flags = KBD_SHIFT; event.kbd.flags = KBD_SHIFT;
break; break;
case SYMBOLS: case SYMBOLS:
if(_keySelected < 21) if (_keySelected < 21) {
{
event.kbd.flags = 0; event.kbd.flags = 0;
event.kbd.ascii = kbd_ascii[_keySelected-1]; event.kbd.ascii = kbd_ascii[_keySelected-1];
event.kbd.keycode = kbd_code[ _keySelected-1]; event.kbd.keycode = kbd_code[ _keySelected-1];
} }
break; break;
case (SYMBOLS|CAPS_LOCK): case (SYMBOLS|CAPS_LOCK):
if(_keySelected < 21) if(_keySelected < 21) {
{
event.kbd.flags = 0; event.kbd.flags = 0;
event.kbd.ascii = kbd_ascii_cl[_keySelected-1]; event.kbd.ascii = kbd_ascii_cl[_keySelected-1];
event.kbd.keycode = kbd_code_cl[ _keySelected-1]; event.kbd.keycode = kbd_code_cl[ _keySelected-1];