mirror of
https://github.com/halpz/re3.git
synced 2025-07-03 06:10:43 +00:00
cleaned up to be closer to original game
This commit is contained in:
@ -4,8 +4,9 @@
|
||||
#include "Frontend.h"
|
||||
#include "Camera.h"
|
||||
|
||||
float CDraw::ms_fAspectRatio;
|
||||
float CDraw::ms_fScreenMultiplier;
|
||||
#ifdef ASPECT_RATIO_SCALE
|
||||
float CDraw::ms_fAspectRatio = DEFAULT_ASPECT_RATIO;
|
||||
#endif
|
||||
|
||||
float &CDraw::ms_fNearClipZ = *(float*)0x8E2DC4;
|
||||
float &CDraw::ms_fFarClipZ = *(float*)0x9434F0;
|
||||
@ -16,26 +17,25 @@ uint8 &CDraw::FadeRed = *(uint8*)0x95CD90;
|
||||
uint8 &CDraw::FadeGreen = *(uint8*)0x95CD71;
|
||||
uint8 &CDraw::FadeBlue = *(uint8*)0x95CD53;
|
||||
|
||||
void
|
||||
CDraw::CalculateAspectRatio()
|
||||
float
|
||||
CDraw::FindAspectRatio(void)
|
||||
{
|
||||
SetScreenMult(DEFAULT_SCALE);
|
||||
|
||||
if(FrontEndMenuManager.m_PrefsUseWideScreen)
|
||||
ms_fAspectRatio = 16.0f/9.0f;
|
||||
return 16.0f/9.0f;
|
||||
else
|
||||
ms_fAspectRatio = 4.0f/3.0f;
|
||||
return 4.0f/3.0f;
|
||||
}
|
||||
|
||||
static float hFov2vFov(float hfov)
|
||||
// convert a 4:3 hFOV to vFOV,
|
||||
// then convert that vFOV to hFOV for our aspect ratio,
|
||||
// i.e. HOR+
|
||||
float
|
||||
CDraw::ConvertFOV(float hfov)
|
||||
{
|
||||
float w = SCREENW;
|
||||
float h = SCREENH;
|
||||
|
||||
// => tan(hFOV/2) = tan(vFOV/2)*aspectRatio
|
||||
// => tan(vFOV/2) = tan(hFOV/2)/aspectRatio
|
||||
float ar1 = 4.0/3.0;
|
||||
float ar2 = w/h;
|
||||
float ar1 = DEFAULT_ASPECT_RATIO;
|
||||
float ar2 = GetAspectRatio();
|
||||
hfov = DEGTORAD(hfov);
|
||||
float vfov = atan(tan(hfov/2) / ar1) *2;
|
||||
hfov = atan(tan(vfov/2) * ar2) *2;
|
||||
@ -45,9 +45,11 @@ static float hFov2vFov(float hfov)
|
||||
void
|
||||
CDraw::SetFOV(float fov)
|
||||
{
|
||||
// TODO: fix FOV here or somewhere else?
|
||||
// ms_fFOV = hFov2vFov(fov);
|
||||
#ifdef ASPECT_RATIO_SCALE
|
||||
ms_fFOV = ConvertFOV(fov);
|
||||
#else
|
||||
ms_fFOV = fov;
|
||||
#endif
|
||||
}
|
||||
|
||||
STARTPATCHES
|
||||
|
@ -1,16 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#define HUD_SCALE 0.8f
|
||||
#define DEFAULT_SCALE 1.0f
|
||||
|
||||
class CDraw
|
||||
{
|
||||
private:
|
||||
static float &ms_fNearClipZ;
|
||||
static float &ms_fFarClipZ;
|
||||
static float &ms_fFOV;
|
||||
static float ms_fLODDistance; // unused
|
||||
|
||||
#ifdef ASPECT_RATIO_SCALE
|
||||
// we use this variable to scale a lot of 2D elements
|
||||
// so better cache it
|
||||
static float ms_fAspectRatio;
|
||||
static float ms_fScreenMultiplier;
|
||||
#endif
|
||||
|
||||
public:
|
||||
static uint8 &FadeValue;
|
||||
@ -26,8 +28,12 @@ public:
|
||||
static void SetFOV(float fov);
|
||||
static float GetFOV(void) { return ms_fFOV; }
|
||||
|
||||
static void CalculateAspectRatio();
|
||||
static float FindAspectRatio(void);
|
||||
#ifdef ASPECT_RATIO_SCALE
|
||||
static float ConvertFOV(float fov);
|
||||
static float GetAspectRatio(void) { return ms_fAspectRatio; }
|
||||
static void SetScreenMult(float mult) { ms_fScreenMultiplier = mult; };
|
||||
static float GetScreenMult(void) { return ms_fScreenMultiplier; };
|
||||
static void SetAspectRatio(float ratio) { ms_fAspectRatio = ratio; }
|
||||
#else
|
||||
static float GetAspectRatio(void) { return FindAspectRatio(); }
|
||||
#endif
|
||||
};
|
||||
|
@ -787,8 +787,8 @@ void CHud::Draw()
|
||||
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));
|
||||
// FIX: game doesn't scale RADAR_LEFT here
|
||||
rect.Translate(SCREEN_SCALE_X(RADAR_LEFT), SCREEN_SCALE_FROM_BOTTOM(RADAR_BOTTOM + RADAR_HEIGHT));
|
||||
// FIX? scale RADAR_LEFT here somehow
|
||||
rect.Translate(RADAR_LEFT, SCREEN_SCALE_FROM_BOTTOM(RADAR_BOTTOM + RADAR_HEIGHT));
|
||||
rect.Grow(4.0f);
|
||||
Sprites[HUD_RADARDISC].Draw(rect, CRGBA(0, 0, 0, 255));
|
||||
CRadar::DrawBlips();
|
||||
|
@ -16,7 +16,7 @@ CSprite::CalcHorizonCoors(void)
|
||||
CVector p = TheCamera.GetPosition() + CVector(TheCamera.CamFrontXNorm, TheCamera.CamFrontYNorm, 0.0f)*3000.0f;
|
||||
p.z = 0.0f;
|
||||
p = TheCamera.m_viewMatrix * p;
|
||||
return p.y * RsGlobal.maximumHeight / p.z;
|
||||
return p.y * SCREEN_HEIGHT / p.z;
|
||||
}
|
||||
|
||||
bool
|
||||
@ -27,13 +27,13 @@ CSprite::CalcScreenCoors(const RwV3d &in, RwV3d *out, float *outw, float *outh,
|
||||
if(out->z <= CDraw::GetNearClipZ() + 1.0f) return false;
|
||||
if(out->z >= CDraw::GetFarClipZ() && farclip) return false;
|
||||
float recip = 1.0f/out->z;
|
||||
out->x *= RsGlobal.maximumWidth * recip;
|
||||
out->y *= RsGlobal.maximumHeight * recip;
|
||||
out->x *= SCREEN_WIDTH * recip;
|
||||
out->y *= SCREEN_HEIGHT * recip;
|
||||
// What is this? size?
|
||||
*outw = 70.0f/CDraw::GetFOV();
|
||||
*outh = 70.0f/CDraw::GetFOV();
|
||||
*outw *= RsGlobal.maximumWidth * recip;
|
||||
*outh *= RsGlobal.maximumHeight * recip;
|
||||
*outw *= SCREEN_WIDTH * recip;
|
||||
*outh *= SCREEN_HEIGHT * recip;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -99,17 +99,17 @@ CSprite::RenderOneXLUSprite(float x, float y, float z, float w, float h, uint8 r
|
||||
us[i] = -xs[i] / (2.0f*w);
|
||||
xs[i] = 0.0f;
|
||||
}
|
||||
if(xs[i] > RsGlobal.maximumWidth){
|
||||
us[i] = 1.0f - (xs[i]-RsGlobal.maximumWidth) / (2.0f*w);
|
||||
xs[i] = RsGlobal.maximumWidth;
|
||||
if(xs[i] > SCREEN_WIDTH){
|
||||
us[i] = 1.0f - (xs[i]-SCREEN_WIDTH) / (2.0f*w);
|
||||
xs[i] = SCREEN_WIDTH;
|
||||
}
|
||||
if(ys[i] < 0.0f){
|
||||
vs[i] = -ys[i] / (2.0f*h);
|
||||
ys[i] = 0.0f;
|
||||
}
|
||||
if(ys[i] > RsGlobal.maximumHeight){
|
||||
vs[i] = 1.0f - (ys[i]-RsGlobal.maximumHeight) / (2.0f*h);
|
||||
ys[i] = RsGlobal.maximumHeight;
|
||||
if(ys[i] > SCREEN_HEIGHT){
|
||||
vs[i] = 1.0f - (ys[i]-SCREEN_HEIGHT) / (2.0f*h);
|
||||
ys[i] = SCREEN_HEIGHT;
|
||||
}
|
||||
}
|
||||
|
||||
@ -169,10 +169,10 @@ CSprite::RenderOneXLUSprite_Rotate_Aspect(float x, float y, float z, float w, fl
|
||||
// No clipping, just culling
|
||||
if(xs[0] < 0.0f && xs[1] < 0.0f && xs[2] < 0.0f && xs[3] < 0.0f) return;
|
||||
if(ys[0] < 0.0f && ys[1] < 0.0f && ys[2] < 0.0f && ys[3] < 0.0f) return;
|
||||
if(xs[0] > RsGlobal.maximumWidth && xs[1] > RsGlobal.maximumWidth &&
|
||||
xs[2] > RsGlobal.maximumWidth && xs[3] > RsGlobal.maximumWidth) return;
|
||||
if(ys[0] > RsGlobal.maximumHeight && ys[1] > RsGlobal.maximumHeight &&
|
||||
ys[2] > RsGlobal.maximumHeight && ys[3] > RsGlobal.maximumHeight) return;
|
||||
if(xs[0] > SCREEN_WIDTH && xs[1] > SCREEN_WIDTH &&
|
||||
xs[2] > SCREEN_WIDTH && xs[3] > SCREEN_WIDTH) return;
|
||||
if(ys[0] > SCREEN_HEIGHT && ys[1] > SCREEN_HEIGHT &&
|
||||
ys[2] > SCREEN_HEIGHT && ys[3] > SCREEN_HEIGHT) return;
|
||||
|
||||
float screenz = m_f2DNearScreenZ +
|
||||
(z-CDraw::GetNearClipZ())*(m_f2DFarScreenZ-m_f2DNearScreenZ)*CDraw::GetFarClipZ() /
|
||||
@ -221,17 +221,17 @@ CSprite::RenderBufferedOneXLUSprite(float x, float y, float z, float w, float h,
|
||||
us[i] = -xs[i] / (2.0f*w);
|
||||
xs[i] = 0.0f;
|
||||
}
|
||||
if(xs[i] > RsGlobal.maximumWidth){
|
||||
us[i] = 1.0f - (xs[i]-RsGlobal.maximumWidth) / (2.0f*w);
|
||||
xs[i] = RsGlobal.maximumWidth;
|
||||
if(xs[i] > SCREEN_WIDTH){
|
||||
us[i] = 1.0f - (xs[i]-SCREEN_WIDTH) / (2.0f*w);
|
||||
xs[i] = SCREEN_WIDTH;
|
||||
}
|
||||
if(ys[i] < 0.0f){
|
||||
vs[i] = -ys[i] / (2.0f*h);
|
||||
ys[i] = 0.0f;
|
||||
}
|
||||
if(ys[i] > RsGlobal.maximumHeight){
|
||||
vs[i] = 1.0f - (ys[i]-RsGlobal.maximumHeight) / (2.0f*h);
|
||||
ys[i] = RsGlobal.maximumHeight;
|
||||
if(ys[i] > SCREEN_HEIGHT){
|
||||
vs[i] = 1.0f - (ys[i]-SCREEN_HEIGHT) / (2.0f*h);
|
||||
ys[i] = SCREEN_HEIGHT;
|
||||
}
|
||||
}
|
||||
|
||||
@ -283,10 +283,10 @@ CSprite::RenderBufferedOneXLUSprite_Rotate_Dimension(float x, float y, float z,
|
||||
// No clipping, just culling
|
||||
if(xs[0] < 0.0f && xs[1] < 0.0f && xs[2] < 0.0f && xs[3] < 0.0f) return;
|
||||
if(ys[0] < 0.0f && ys[1] < 0.0f && ys[2] < 0.0f && ys[3] < 0.0f) return;
|
||||
if(xs[0] > RsGlobal.maximumWidth && xs[1] > RsGlobal.maximumWidth &&
|
||||
xs[2] > RsGlobal.maximumWidth && xs[3] > RsGlobal.maximumWidth) return;
|
||||
if(ys[0] > RsGlobal.maximumHeight && ys[1] > RsGlobal.maximumHeight &&
|
||||
ys[2] > RsGlobal.maximumHeight && ys[3] > RsGlobal.maximumHeight) return;
|
||||
if(xs[0] > SCREEN_WIDTH && xs[1] > SCREEN_WIDTH &&
|
||||
xs[2] > SCREEN_WIDTH && xs[3] > SCREEN_WIDTH) return;
|
||||
if(ys[0] > SCREEN_HEIGHT && ys[1] > SCREEN_HEIGHT &&
|
||||
ys[2] > SCREEN_HEIGHT && ys[3] > SCREEN_HEIGHT) return;
|
||||
|
||||
float screenz = m_f2DNearScreenZ +
|
||||
(z-CDraw::GetNearClipZ())*(m_f2DFarScreenZ-m_f2DNearScreenZ)*CDraw::GetFarClipZ() /
|
||||
@ -335,10 +335,10 @@ CSprite::RenderBufferedOneXLUSprite_Rotate_Aspect(float x, float y, float z, flo
|
||||
// No clipping, just culling
|
||||
if(xs[0] < 0.0f && xs[1] < 0.0f && xs[2] < 0.0f && xs[3] < 0.0f) return;
|
||||
if(ys[0] < 0.0f && ys[1] < 0.0f && ys[2] < 0.0f && ys[3] < 0.0f) return;
|
||||
if(xs[0] > RsGlobal.maximumWidth && xs[1] > RsGlobal.maximumWidth &&
|
||||
xs[2] > RsGlobal.maximumWidth && xs[3] > RsGlobal.maximumWidth) return;
|
||||
if(ys[0] > RsGlobal.maximumHeight && ys[1] > RsGlobal.maximumHeight &&
|
||||
ys[2] > RsGlobal.maximumHeight && ys[3] > RsGlobal.maximumHeight) return;
|
||||
if(xs[0] > SCREEN_WIDTH && xs[1] > SCREEN_WIDTH &&
|
||||
xs[2] > SCREEN_WIDTH && xs[3] > SCREEN_WIDTH) return;
|
||||
if(ys[0] > SCREEN_HEIGHT && ys[1] > SCREEN_HEIGHT &&
|
||||
ys[2] > SCREEN_HEIGHT && ys[3] > SCREEN_HEIGHT) return;
|
||||
|
||||
float screenz = m_f2DNearScreenZ +
|
||||
(z-CDraw::GetNearClipZ())*(m_f2DFarScreenZ-m_f2DNearScreenZ)*CDraw::GetFarClipZ() /
|
||||
@ -388,10 +388,10 @@ CSprite::RenderBufferedOneXLUSprite_Rotate_2Colours(float x, float y, float z, f
|
||||
// No clipping, just culling
|
||||
if(xs[0] < 0.0f && xs[1] < 0.0f && xs[2] < 0.0f && xs[3] < 0.0f) return;
|
||||
if(ys[0] < 0.0f && ys[1] < 0.0f && ys[2] < 0.0f && ys[3] < 0.0f) return;
|
||||
if(xs[0] > RsGlobal.maximumWidth && xs[1] > RsGlobal.maximumWidth &&
|
||||
xs[2] > RsGlobal.maximumWidth && xs[3] > RsGlobal.maximumWidth) return;
|
||||
if(ys[0] > RsGlobal.maximumHeight && ys[1] > RsGlobal.maximumHeight &&
|
||||
ys[2] > RsGlobal.maximumHeight && ys[3] > RsGlobal.maximumHeight) return;
|
||||
if(xs[0] > SCREEN_WIDTH && xs[1] > SCREEN_WIDTH &&
|
||||
xs[2] > SCREEN_WIDTH && xs[3] > SCREEN_WIDTH) return;
|
||||
if(ys[0] > SCREEN_HEIGHT && ys[1] > SCREEN_HEIGHT &&
|
||||
ys[2] > SCREEN_HEIGHT && ys[3] > SCREEN_HEIGHT) return;
|
||||
|
||||
// Colour factors, cx/y is the direction in which colours change from rgb1 to rgb2
|
||||
cf[0] = (cx*(-c-s) + cy*(-c+s))*0.5f + 0.5f;
|
||||
|
Reference in New Issue
Block a user