Skip to content

Commit

Permalink
PSP: Use aspect correction checkbox instead of extra graphics modes
Browse files Browse the repository at this point in the history
  • Loading branch information
rsn8887 committed Jan 3, 2018
1 parent 50d79c5 commit 2314072
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 25 deletions.
37 changes: 16 additions & 21 deletions backends/platform/psp/display_manager.cpp
Expand Up @@ -35,6 +35,8 @@
#include "backends/platform/psp/pspkeyboard.h"
#include "backends/platform/psp/image_viewer.h"

#include "common/config-manager.h"

#define USE_DISPLAY_CALLBACK // to use callback for finishing the render
#include "backends/platform/psp/display_manager.h"

Expand All @@ -54,9 +56,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 },
{ "4:3 Aspect Ratio", "4:3 Aspect Ratio", ASPECT_RATIO_CORRECTION },
{ "Stretched Full Screen", "Stretched Full Screen", STRETCHED_FULL_SCREEN },
{ "Fit to Screen", "Fit to Screen", FIT_TO_SCREEN },
{ "Stretch to Screen", "Stretch to Screen", STRETCH_TO_SCREEN },
{0, 0, 0}
};

Expand Down Expand Up @@ -365,32 +366,26 @@ void DisplayManager::calculateScaleParams() {
_displayParams.screenOutput.height = _displayParams.screenSource.height;
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;
// else revert to fit to screen
case FIT_TO_SCREEN: { // maximize the height while keeping aspect ratio
float aspectRatio;

if (ConfMan.getBool("aspect_ratio")) {
aspectRatio = 4.0f / 3.0f;
} else {
aspectRatio = (float)_displayParams.screenSource.width / (float)_displayParams.screenSource.height;
}

_displayParams.screenOutput.height = PSP_SCREEN_HEIGHT; // always full 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) { // 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.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
case STRETCH_TO_SCREEN: // we simply stretch to the whole screen
_displayParams.screenOutput.width = PSP_SCREEN_WIDTH;
_displayParams.screenOutput.height = PSP_SCREEN_HEIGHT;
break;
Expand Down
7 changes: 3 additions & 4 deletions backends/platform/psp/display_manager.h
Expand Up @@ -105,9 +105,8 @@ class DisplayManager {
public:
enum GraphicsModeID { ///> Possible output formats onscreen
ORIGINAL_RESOLUTION,
KEEP_ASPECT_RATIO,
ASPECT_RATIO_CORRECTION,
STRETCHED_FULL_SCREEN
FIT_TO_SCREEN,
STRETCH_TO_SCREEN
};
DisplayManager() : _screen(0), _cursor(0), _overlay(0), _keyboard(0),
_imageViewer(0), _lastUpdateTime(0), _graphicsMode(0) {}
Expand All @@ -119,7 +118,7 @@ class DisplayManager {
bool setGraphicsMode(int mode);
bool setGraphicsMode(const char *name);
int getGraphicsMode() const { return _graphicsMode; }
uint32 getDefaultGraphicsMode() const { return KEEP_ASPECT_RATIO; }
uint32 getDefaultGraphicsMode() const { return FIT_TO_SCREEN; }
const OSystem::GraphicsMode* getSupportedGraphicsModes() const { return _supportedModes; }

// Setters for pointers
Expand Down
3 changes: 3 additions & 0 deletions backends/platform/psp/osys_psp.cpp
Expand Up @@ -64,6 +64,9 @@ OSystem_PSP::~OSystem_PSP() {}
void OSystem_PSP::initBackend() {
DEBUG_ENTER_FUNC();

ConfMan.registerDefault("aspect_ratio", false);
ConfMan.registerDefault("gfx_mode", "Fit to Screen");

// Instantiate real time clock
PspRtc::instance();

Expand Down
1 change: 1 addition & 0 deletions configure
Expand Up @@ -3231,6 +3231,7 @@ if test -n "$_host"; then
_port_mk="backends/platform/sdl/psp2/psp2.mk"
;;
psp)
append_var DEFINES "-DGUI_ONLY_FULLSCREEN"
_backend="psp"
_build_scalers=no
_mt32emu=no
Expand Down

0 comments on commit 2314072

Please sign in to comment.