Permalink
Browse files

PSP: Fix bug #10239: PSP port incorrect 4:3 aspect ratio

This is based on a patch supplied by dam-soft. A new graphics mode is
added to the PSP port. The graphics mode is called '4:3 Aspect Ratio'
and fixes the incorrect AR. The older modes are also still present and
behave as before.
  • Loading branch information...
digitall authored and rsn8887 committed Dec 27, 2017
1 parent 45891ae commit a3d2c5268768bff0bed06aff00d97704c88bb337
Showing with 23 additions and 9 deletions.
  1. +21 −8 backends/platform/psp/display_manager.cpp
  2. +2 −1 backends/platform/psp/display_manager.h
@@ -55,7 +55,8 @@ uint32 __attribute__((aligned(16))) MasterGuRenderer::_displayList[2048];
const OSystem::GraphicsMode DisplayManager::_supportedModes[] = {
{ "Original Resolution", "Original Resolution", ORIGINAL_RESOLUTION },
{ "Keep Aspect Ratio", "Keep Aspect Ratio", KEEP_ASPECT_RATIO },
{ "Full Screen", "Full Screen", STRETCHED_FULL_SCREEN },
{ "4:3 Aspect Ratio", "4:3 Aspect Ratio", ASPECT_RATIO_CORRECTION },
{ "Stretched Full Screen", "Stretched Full Screen", STRETCHED_FULL_SCREEN },
{0, 0, 0}
};
@@ -358,23 +359,35 @@ void DisplayManager::calculateScaleParams() {
switch (_graphicsMode) {
case ORIGINAL_RESOLUTION:
// check if we can fit the original resolution inside the screen
if ((_displayParams.screenSource.width < PSP_SCREEN_WIDTH) &&
(_displayParams.screenSource.height < PSP_SCREEN_HEIGHT)) {
if ((_displayParams.screenSource.width <= PSP_SCREEN_WIDTH) &&
(_displayParams.screenSource.height <= PSP_SCREEN_HEIGHT)) {
_displayParams.screenOutput.width = _displayParams.screenSource.width;
_displayParams.screenOutput.height = _displayParams.screenSource.height;
} else { // revert to stretch to fit
_displayParams.screenOutput.width = PSP_SCREEN_WIDTH;
_displayParams.screenOutput.height = PSP_SCREEN_HEIGHT;
break;
}
break;
// else revert to keep aspect ratio
case KEEP_ASPECT_RATIO: { // maximize the height while keeping aspect ratio
float aspectRatio = (float)_displayParams.screenSource.width / (float)_displayParams.screenSource.height;
_displayParams.screenOutput.height = PSP_SCREEN_HEIGHT; // always full height
_displayParams.screenOutput.width = (uint32)(PSP_SCREEN_HEIGHT * aspectRatio);
if (_displayParams.screenOutput.width > PSP_SCREEN_WIDTH) // we can't have wider than the screen
if (_displayParams.screenOutput.width > PSP_SCREEN_WIDTH) { // shrink if wider than screen
_displayParams.screenOutput.height = (uint32) (((float) PSP_SCREEN_HEIGHT * (float) PSP_SCREEN_WIDTH) / (float) _displayParams.screenOutput.width);
_displayParams.screenOutput.width = PSP_SCREEN_WIDTH;
}
}
break;
case ASPECT_RATIO_CORRECTION: { // maximize the height while forcing 4:3 aspect ratio
float aspectRatio = 4.0f / 3.0f;
_displayParams.screenOutput.height = PSP_SCREEN_HEIGHT; // always full height
_displayParams.screenOutput.width = (uint32)(PSP_SCREEN_HEIGHT * aspectRatio);
if (_displayParams.screenOutput.width > PSP_SCREEN_WIDTH) { // // shrink if wider than screen
_displayParams.screenOutput.height = (uint32) (((float) PSP_SCREEN_HEIGHT * (float) PSP_SCREEN_WIDTH) / (float) _displayParams.screenOutput.width);
_displayParams.screenOutput.width = PSP_SCREEN_WIDTH;
}
}
break;
case STRETCHED_FULL_SCREEN: // we simply stretch to the whole screen
@@ -106,6 +106,7 @@ class DisplayManager {
enum GraphicsModeID { ///> Possible output formats onscreen
ORIGINAL_RESOLUTION,
KEEP_ASPECT_RATIO,
ASPECT_RATIO_CORRECTION,
STRETCHED_FULL_SCREEN
};
DisplayManager() : _screen(0), _cursor(0), _overlay(0), _keyboard(0),
@@ -118,7 +119,7 @@ class DisplayManager {
bool setGraphicsMode(int mode);
bool setGraphicsMode(const char *name);
int getGraphicsMode() const { return _graphicsMode; }
uint32 getDefaultGraphicsMode() const { return STRETCHED_FULL_SCREEN; }
uint32 getDefaultGraphicsMode() const { return KEEP_ASPECT_RATIO; }
const OSystem::GraphicsMode* getSupportedGraphicsModes() const { return _supportedModes; }
// Setters for pointers

0 comments on commit a3d2c52

Please sign in to comment.