Sprite Scaling option

This commit is contained in:
Fire-Head 2020-12-29 20:24:16 +03:00
parent 40b90618ef
commit 224e805fe4
11 changed files with 106 additions and 17 deletions

Binary file not shown.

View File

@ -141,6 +141,10 @@ int8 CMenuManager::m_nPrefsMSAALevel = 0;
int8 CMenuManager::m_nDisplayMSAALevel = 0;
#endif
#ifdef ASPECT_RATIO_SCALE
int32 CMenuManager::m_PrefsSpriteScalingMode = 0;
#endif
#ifdef NO_ISLAND_LOADING
int8 CMenuManager::m_PrefsIslandLoading = ISLAND_LOADING_LOW;
#endif
@ -1455,9 +1459,18 @@ CMenuManager::Draw()
case AR_4_3:
sprintf(asciiTemp, "4:3");
break;
case AR_5_4:
sprintf(asciiTemp, "5:4");
break;
case AR_16_10:
sprintf(asciiTemp, "16:10");
break;
case AR_16_9:
sprintf(asciiTemp, "16:9");
break;
case AR_21_9:
sprintf(asciiTemp, "21:9");
break;
}
AsciiToUnicode(asciiTemp, unicodeTemp);
@ -5221,12 +5234,12 @@ CMenuManager::ProcessButtonPresses(void)
case MENUACTION_WIDESCREEN:
if (changeValueBy > 0) {
m_PrefsUseWideScreen++;
if (m_PrefsUseWideScreen > 2)
if (m_PrefsUseWideScreen > AR_MAX-1)
m_PrefsUseWideScreen = 0;
} else {
m_PrefsUseWideScreen--;
if (m_PrefsUseWideScreen < 0)
m_PrefsUseWideScreen = 2;
m_PrefsUseWideScreen = AR_MAX-1;
}
DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0);
SaveSettings();

View File

@ -636,6 +636,9 @@ public:
static int8 m_nDisplayMSAALevel;
#endif
#ifdef ASPECT_RATIO_SCALE
static int32 m_PrefsSpriteScalingMode;
#endif
enum LANGUAGE
{
LANGUAGE_AMERICAN,

View File

@ -83,6 +83,12 @@
#define INVERT_PAD_SELECTOR
#endif
#ifdef ASPECT_RATIO_SCALE
#define HUD_ASPECT_RATIO_SELECTOR MENUACTION_CFO_SELECT, "FEC_SCL", { new CCFOSelect((int8*)&CMenuManager::m_PrefsSpriteScalingMode, "HudAspectRatio", SpriteScalingModes, ARRAY_SIZE(SpriteScalingModes), false, nil) },
#else
#define HUD_ASPECT_RATIO_SELECTOR
#endif
const char *filterNames[] = { "FEM_NON", "FEM_SIM", "FEM_NRM", "FEM_MOB" };
const char *vehPipelineNames[] = { "FED_MFX", "FED_NEO" };
const char *off_on[] = { "FEM_OFF", "FEM_ON" };
@ -342,6 +348,15 @@ wchar* DetectJoystickDraw(bool* disabled, bool userHovering) {
}
#endif
#ifdef ASPECT_RATIO_SCALE
const char* SpriteScalingModes[] =
{
"FEM_PC",
"FEM_PS2",
"FEM_AUT"
};
#endif
CMenuScreenCustom aScreens[MENUPAGES] = {
// MENUPAGE_NONE = 0
{ "", MENUPAGE_DISABLED, MENUPAGE_DISABLED, nil, nil, },
@ -396,6 +411,7 @@ CMenuScreenCustom aScreens[MENUPAGES] = {
#endif
MENUACTION_SUBTITLES, "FED_SUB", { nil, SAVESLOT_NONE, MENUPAGE_DISPLAY_SETTINGS },
MENUACTION_WIDESCREEN, "FED_WIS", { nil, SAVESLOT_NONE, MENUPAGE_DISPLAY_SETTINGS },
HUD_ASPECT_RATIO_SELECTOR
MENUACTION_SCREENRES, "FED_RES", { nil, SAVESLOT_NONE, MENUPAGE_DISPLAY_SETTINGS },
VIDEOMODE_SELECTOR
MULTISAMPLING_SELECTOR
@ -827,6 +843,7 @@ CMenuScreenCustom aScreens[MENUPAGES] = {
MENUACTION_SCREENRES, "FED_RES", { nil, SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS },
MENUACTION_WIDESCREEN, "FED_WIS", { nil, SAVESLOT_NONE, MENUPAGE_GRAPHICS_SETTINGS },
HUD_ASPECT_RATIO_SELECTOR
VIDEOMODE_SELECTOR
MENUACTION_FRAMESYNC, "FEM_VSC", { nil, SAVESLOT_NONE, MENUPAGE_DISPLAY_SETTINGS },
MENUACTION_FRAMELIMIT, "FEM_FRM", { nil, SAVESLOT_NONE, MENUPAGE_DISPLAY_SETTINGS },

View File

@ -1297,10 +1297,16 @@ void CRadar::TransformRadarPointToScreenSpace(CVector2D &out, const CVector2D &i
} else
#endif
{
#ifdef FIX_BUGS
out.x = (in.x + 1.0f) * 0.5f * SCREEN_SCALE_X(RADAR_WIDTH) + SCREEN_SCALE_X(RADAR_LEFT);
#ifdef ASPECT_RATIO_SCALE
#define _RADAR_WIDTH ((CMenuManager::m_PrefsSpriteScalingMode==SCL_AUTO) ? (RADAR_HEIGHT) : (RADAR_WIDTH))
#else
out.x = (in.x + 1.0f) * 0.5f * SCREEN_SCALE_X(RADAR_WIDTH) + RADAR_LEFT;
#define _RADAR_WIDTH RADAR_WIDTH
#endif
#ifdef FIX_BUGS
out.x = (in.x + 1.0f) * 0.5f * SCREEN_SCALE_X(_RADAR_WIDTH) + SCREEN_SCALE_X(RADAR_LEFT);
#else
out.x = (in.x + 1.0f) * 0.5f * SCREEN_SCALE_X(_RADAR_WIDTH) + RADAR_LEFT;
#endif
out.y = (1.0f - in.y) * 0.5f * SCREEN_SCALE_Y(RADAR_HEIGHT) + SCREEN_SCALE_FROM_BOTTOM(RADAR_BOTTOM + RADAR_HEIGHT);
}

View File

@ -116,7 +116,7 @@ inline uint32 ldb(uint32 p, uint32 s, uint32 w)
#include "skeleton.h"
#include "Draw.h"
#if defined(USE_PROPER_SCALING)
#if defined(ASPECT_RATIO_SCALE)
#ifdef FORCE_PC_SCALING
#define DEFAULT_SCREEN_WIDTH (640)
#define DEFAULT_SCREEN_HEIGHT (448)
@ -150,8 +150,8 @@ inline uint32 ldb(uint32 p, uint32 s, uint32 w)
#define SCREEN_HEIGHT ((float)RsGlobal.height)
#endif
#define SCREEN_HEIGHT_PAL (512)
#define SCREEN_HEIGHT_NTSC (448)
#define SCREEN_HEIGHT_PAL ((float)512)
#define SCREEN_HEIGHT_NTSC ((float)448)
#define SCREEN_ASPECT_RATIO (CDraw::GetAspectRatio())
#define SCREEN_VIEWWINDOW (Tan(DEGTORAD(CDraw::GetScaledFOV() * 0.5f)))
@ -170,8 +170,11 @@ inline uint32 ldb(uint32 p, uint32 s, uint32 w)
#ifdef ASPECT_RATIO_SCALE
#define SCREEN_SCALE_AR(a) ((a) * DEFAULT_ASPECT_RATIO / SCREEN_ASPECT_RATIO)
extern float ScaleAndCenterX(float x);
#define SCALE_AND_CENTER_X(x) ScaleAndCenterX(x)
#define SCALE_AND_CENTER_X(x) ((SCREEN_WIDTH == DEFAULT_SCREEN_WIDTH) ? (x) : (SCREEN_WIDTH - SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH)) / 2 + SCREEN_SCALE_X((x)))
#ifndef FORCE_PC_SCALING
#undef SCREEN_SCALE_Y
#define SCREEN_SCALE_Y(a) CDraw::ScaleY(SCREEN_STRETCH_Y(a))
#endif
#else
#define SCREEN_SCALE_AR(a) (a)
#define SCALE_AND_CENTER_X(x) SCREEN_STRETCH_X(x)

View File

@ -35,8 +35,14 @@ CDraw::FindAspectRatio(void)
default:
case AR_4_3:
return 4.0f / 3.0f;
case AR_5_4:
return 5.0f / 4.0f;
case AR_16_10:
return 16.0f / 10.0f;
case AR_16_9:
return 16.0f / 9.0f;
case AR_21_9:
return 21.0f / 9.0f;
};
#endif
}
@ -72,12 +78,13 @@ CDraw::SetFOV(float fov)
}
#ifdef ASPECT_RATIO_SCALE
float
ScaleAndCenterX(float x)
float CDraw::ScaleY(float y)
{
if (SCREEN_WIDTH == DEFAULT_SCREEN_WIDTH)
return x;
else
return (SCREEN_WIDTH - SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH)) / 2 + SCREEN_SCALE_X(x);
switch ( CMenuManager::m_PrefsSpriteScalingMode )
{
case SCL_PC: return y * ((float)DEFAULT_SCREEN_HEIGHT/SCREEN_HEIGHT_NTSC);
default:
return y;
}
}
#endif

View File

@ -5,9 +5,21 @@ enum eAspectRatio
// Make sure these work the same as FrontEndMenuManager.m_PrefsUseWideScreen
// without widescreen support
AR_4_3,
AR_5_4,
AR_16_10,
AR_16_9,
AR_21_9,
AR_AUTO,
AR_MAX,
};
enum eSpriteScalingMode
{
SCL_PC,
SCL_PS2,
SCL_AUTO,
};
class CDraw
@ -52,4 +64,8 @@ public:
#else
static float GetAspectRatio(void) { return FindAspectRatio(); }
#endif
#ifdef ASPECT_RATIO_SCALE
static float ScaleY(float y);
#endif
};

View File

@ -1186,9 +1186,14 @@ void CHud::Draw()
/*
DrawRadar
*/
#ifdef ASPECT_RATIO_SCALE
#define _RADAR_WIDTH ((CMenuManager::m_PrefsSpriteScalingMode==SCL_AUTO) ? (RADAR_HEIGHT) : (RADAR_WIDTH))
#else
#define _RADAR_WIDTH RADAR_WIDTH
#endif
if (m_ItemToFlash == ITEM_RADAR && CTimer::GetFrameCounter() & 8 || m_ItemToFlash != ITEM_RADAR) {
CRadar::DrawMap();
CRect rect(0.0f, 0.0f, SCREEN_SCALE_X(RADAR_WIDTH), SCREEN_SCALE_Y(RADAR_HEIGHT));
CRect rect(0.0f, 0.0f, SCREEN_SCALE_X(_RADAR_WIDTH), SCREEN_SCALE_Y(RADAR_HEIGHT));
#ifdef FIX_BUGS
rect.Translate(SCREEN_SCALE_X(RADAR_LEFT), SCREEN_SCALE_FROM_BOTTOM(RADAR_BOTTOM + RADAR_HEIGHT));
#else

View File

@ -5,6 +5,10 @@
#include "Camera.h"
#include "Sprite.h"
#ifdef ASPECT_RATIO_SCALE
#include "Frontend.h"
#endif
float CSprite::m_f2DNearScreenZ;
float CSprite::m_f2DFarScreenZ;
float CSprite::m_fRecipNearClipPlane;
@ -35,6 +39,11 @@ CSprite::CalcScreenCoors(const RwV3d &in, RwV3d *out, float *outw, float *outh,
*outw = fovScale * SCREEN_SCALE_AR(recip) * SCREEN_WIDTH;
*outh = fovScale * recip * SCREEN_HEIGHT;
#ifdef ASPECT_RATIO_SCALE
if ( CMenuManager::m_PrefsSpriteScalingMode==SCL_AUTO )
*outw = fovScale * recip * SCREEN_HEIGHT;
#endif
return true;
}

View File

@ -8058,12 +8058,22 @@ NEO
[FEM_PS2]
PS2
[FEM_PC]
PC
[FEM_XBX]
XBOX
[FEM_AUT]
AUTO
[FEC_IVP]
INVERT PAD VERTICALLY
[FEC_SCL]
SPRITE SCALING MODE
{ end of file }
[DUMMY]