cleaned up to be closer to original game

This commit is contained in:
aap 2019-07-03 13:13:55 +02:00
parent a91ea23924
commit 25865e68c4
10 changed files with 172 additions and 134 deletions

View File

@ -899,8 +899,8 @@ void CRadar::TransformRadarPointToRealWorldSpace(CVector2D &out, const CVector2D
// Radar space goes from -1.0 to 1.0 in x and y, top right is (1.0, 1.0) // Radar space goes from -1.0 to 1.0 in x and y, top right is (1.0, 1.0)
void CRadar::TransformRadarPointToScreenSpace(CVector2D &out, const CVector2D &in) void CRadar::TransformRadarPointToScreenSpace(CVector2D &out, const CVector2D &in)
{ {
// FIX: game doesn't scale RADAR_LEFT here // FIX? scale RADAR_LEFT here somehow
out.x = (in.x + 1.0f)*0.5f*SCREEN_SCALE_X(RADAR_WIDTH) + SCREEN_SCALE_X(RADAR_LEFT); out.x = (in.x + 1.0f)*0.5f*SCREEN_SCALE_X(RADAR_WIDTH) + RADAR_LEFT;
out.y = (1.0f - in.y)*0.5f*SCREEN_SCALE_Y(RADAR_HEIGHT) + SCREEN_SCALE_FROM_BOTTOM(RADAR_BOTTOM + RADAR_HEIGHT); out.y = (1.0f - in.y)*0.5f*SCREEN_SCALE_Y(RADAR_HEIGHT) + SCREEN_SCALE_FROM_BOTTOM(RADAR_BOTTOM + RADAR_HEIGHT);
} }

View File

@ -67,27 +67,37 @@ extern void **rwengine;
In theory should look good on any screen. In theory should look good on any screen.
*/ */
#define SCREEN_ASPECT_RATIO (CDraw::GetAspectRatio())
#define SCREENW (RsGlobal.maximumWidth)
#define SCREENH (RsGlobal.maximumHeight)
#define DEFAULT_SCREEN_WIDTH (640) #define DEFAULT_SCREEN_WIDTH (640)
#define DEFAULT_SCREEN_HEIGHT (448) #define DEFAULT_SCREEN_HEIGHT (448)
#define SCREEN_WIDTH float(RsGlobal.width) #define DEFAULT_ASPECT_RATIO (4.0f/3.0f)
#define SCREEN_HEIGHT float(RsGlobal.height)
#define SCREEN_STRETCH_X(a) float((a) * (SCREEN_WIDTH / float(DEFAULT_SCREEN_WIDTH)))
#define SCREEN_STRETCH_Y(a) float((a) * (SCREEN_HEIGHT / float(DEFAULT_SCREEN_HEIGHT)))
#define SCREEN_STRETCH_FROM_RIGHT(a) float(SCREEN_WIDTH - SCREEN_STRETCH_X(a))
#define SCREEN_STRETCH_FROM_BOTTOM(a) float(SCREEN_HEIGHT - SCREEN_STRETCH_Y(a))
#define SCREEN_MULTIPLIER (CDraw::GetScreenMult()) // game uses maximumWidth/Height, but this probably won't work
#define SCREEN_SCALE(a) float((a) * (4.0f / 3.0f) / SCREEN_ASPECT_RATIO) // with RW windowed mode
#define SCREEN_SCALE_X(a) SCREEN_SCALE(SCREEN_STRETCH_X(a) * SCREEN_MULTIPLIER) // TODO: get rid of one of the two
#define SCREEN_SCALE_Y(a) (SCREEN_STRETCH_Y(a) * SCREEN_MULTIPLIER) #define SCREENW (RsGlobal.width)
#define SCREENH (RsGlobal.height)
#define SCREEN_WIDTH ((float)RsGlobal.width)
#define SCREEN_HEIGHT ((float)RsGlobal.height)
#define SCREEN_ASPECT_RATIO (CDraw::GetAspectRatio())
// This scales from PS2 pixel coordinates to the real resolution
#define SCREEN_STRETCH_X(a) ((a) * (float) SCREEN_WIDTH / DEFAULT_SCREEN_WIDTH)
#define SCREEN_STRETCH_Y(a) ((a) * (float) SCREEN_HEIGHT / DEFAULT_SCREEN_HEIGHT)
#define SCREEN_STRETCH_FROM_RIGHT(a) (SCREEN_WIDTH - SCREEN_STRETCH_X(a))
#define SCREEN_STRETCH_FROM_BOTTOM(a) (SCREEN_HEIGHT - SCREEN_STRETCH_Y(a))
// This scales from PS2 pixel coordinates while optionally maintaining the aspect ratio
#define SCREEN_SCALE_X(a) SCREEN_SCALE_AR(SCREEN_STRETCH_X(a))
#define SCREEN_SCALE_Y(a) SCREEN_STRETCH_Y(a)
#define SCREEN_SCALE_FROM_RIGHT(a) (SCREEN_WIDTH - SCREEN_SCALE_X(a)) #define SCREEN_SCALE_FROM_RIGHT(a) (SCREEN_WIDTH - SCREEN_SCALE_X(a))
#define SCREEN_SCALE_FROM_BOTTOM(a) (SCREEN_HEIGHT - SCREEN_SCALE_Y(a)) #define SCREEN_SCALE_FROM_BOTTOM(a) (SCREEN_HEIGHT - SCREEN_SCALE_Y(a))
#ifdef ASPECT_RATIO_SCALE
#define SCREEN_SCALE_AR(a) ((a) * (4.0f / 3.0f) / SCREEN_ASPECT_RATIO)
#else
#define SCREEN_SCALE_AR(a) (a)
#endif
#include "math/Vector.h" #include "math/Vector.h"
#include "math/Vector2D.h" #include "math/Vector2D.h"
#include "math/Matrix.h" #include "math/Matrix.h"

View File

@ -62,20 +62,52 @@ enum Config {
NUMPICKUPS = 336, NUMPICKUPS = 336,
}; };
// We don't expect to compile for PS2 or Xbox // We don't expect to compile for PS2 or Xbox
// but it might be interesting for documentation purposes // but it might be interesting for documentation purposes
#define GTA_PC #define GTA_PC
//#define GTA_PS2 //#define GTA_PS2
//#define GTA_XBOX //#define GTA_XBOX
#define GTA3_1_1_PATCH // This enables things from the PS2 version on PC
#define USE_PS2_RAND #define GTA_PS2_STUFF
#define RANDOMSPLASH
#define CHATTYSPLASH // This is enabled for all released games.
//#define FIX_BUGS // any debug stuff that isn't left in any game is not in FINAL
//#define NO_CDCHECK //#define FINAL
#define NO_MOVIES
//#define USE_MY_DOCUMENTS // This is enabled for all released games except mobile
#define NASTY_GAME // any debug stuff that is only left in mobile, is not in MASTER
#define PS2_MATFX //#define MASTER
#if defined GTA_PS2
# define RANDOMSPLASH
#elif defined GTA_PC
# define GTA3_1_1_PATCH
# ifdef GTA_PS2_STUFF
# define USE_PS2_RAND
# define RANDOMSPLASH // use random splash as on PS2
# define PS2_MATFX
# endif
#elif defined GTA_XBOX
#endif
#ifdef MASTER
// only in master builds
#else
// not in master builds
#endif
#ifdef FINAL
// in all games
# define USE_MY_DOCUMENTS // use my documents directory for user files
#else
// not in any game
# define NASTY_GAME // nasty game for all languages
# define NO_MOVIES // disable intro videos
# define CHATTYSPLASH // print what the game is loading
#endif
#define FIX_BUGS // fix bugs in the game, TODO: use this more
#define KANGAROO_CHEAT #define KANGAROO_CHEAT
#define ASPECT_RATIO_SCALE

View File

@ -48,13 +48,7 @@
#include "RpAnimBlend.h" #include "RpAnimBlend.h"
#include "Frontend.h" #include "Frontend.h"
#define DEFAULT_VIEWWINDOW (tan(CDraw::GetFOV() * (360.0f / PI))) #define DEFAULT_VIEWWINDOW (tan(DEGTORAD(CDraw::GetFOV() * 0.5f)))
#ifdef WIDE_SCREEN
#define DEFAULT_ASPECTRATIO (16.0f/9.0f)
#else
#define DEFAULT_ASPECTRATIO (4.0f/3.0f)
#endif
GlobalScene &Scene = *(GlobalScene*)0x726768; GlobalScene &Scene = *(GlobalScene*)0x726768;
@ -100,6 +94,10 @@ InitialiseGame(void)
void void
Idle(void *arg) Idle(void *arg)
{ {
#ifdef ASPECT_RATIO_SCALE
CDraw::SetAspectRatio(CDraw::FindAspectRatio());
#endif
CTimer::Update(); CTimer::Update();
CSprite2d::InitPerFrame(); CSprite2d::InitPerFrame();
CFont::InitPerFrame(); CFont::InitPerFrame();
@ -160,9 +158,8 @@ Idle(void *arg)
Render2dStuff(); Render2dStuff();
}else{ }else{
float viewWindow = tan(DEGTORAD(CDraw::GetFOV() * 0.5f)); float viewWindow = DEFAULT_VIEWWINDOW;
CDraw::CalculateAspectRatio(); CameraSize(Scene.camera, nil, viewWindow, DEFAULT_ASPECT_RATIO);
CameraSize(Scene.camera, nil, viewWindow, SCREEN_ASPECT_RATIO);
CVisibilityPlugins::SetRenderWareCamera(Scene.camera); CVisibilityPlugins::SetRenderWareCamera(Scene.camera);
RwCameraClear(Scene.camera, &gColourTop, rwCAMERACLEARZ); RwCameraClear(Scene.camera, &gColourTop, rwCAMERACLEARZ);
if(!RsCameraBeginUpdate(Scene.camera)) if(!RsCameraBeginUpdate(Scene.camera))
@ -170,7 +167,9 @@ Idle(void *arg)
} }
RenderMenus(); RenderMenus();
#ifndef FINAL
PrintGameVersion(); PrintGameVersion();
#endif
DoFade(); DoFade();
Render2dStuffAfterFade(); Render2dStuffAfterFade();
CCredits::Render(); CCredits::Render();
@ -183,6 +182,10 @@ Idle(void *arg)
void void
FrontendIdle(void) FrontendIdle(void)
{ {
#ifdef ASPECT_RATIO_SCALE
CDraw::SetAspectRatio(CDraw::FindAspectRatio());
#endif
CTimer::Update(); CTimer::Update();
CSprite2d::SetRecipNearClip(); CSprite2d::SetRecipNearClip();
CSprite2d::InitPerFrame(); CSprite2d::InitPerFrame();
@ -193,9 +196,8 @@ FrontendIdle(void)
if(RsGlobal.quit) if(RsGlobal.quit)
return; return;
float viewWindow = tan(DEGTORAD(CDraw::GetFOV() * 0.5f)); float viewWindow = DEFAULT_VIEWWINDOW;
CDraw::CalculateAspectRatio(); CameraSize(Scene.camera, nil, viewWindow, DEFAULT_ASPECT_RATIO);
CameraSize(Scene.camera, nil, viewWindow, SCREEN_ASPECT_RATIO);
CVisibilityPlugins::SetRenderWareCamera(Scene.camera); CVisibilityPlugins::SetRenderWareCamera(Scene.camera);
RwCameraClear(Scene.camera, &gColourTop, rwCAMERACLEARZ); RwCameraClear(Scene.camera, &gColourTop, rwCAMERACLEARZ);
if(!RsCameraBeginUpdate(Scene.camera)) if(!RsCameraBeginUpdate(Scene.camera))
@ -203,7 +205,9 @@ FrontendIdle(void)
DefinedState(); DefinedState();
RenderMenus(); RenderMenus();
#ifndef FINAL
PrintGameVersion(); PrintGameVersion();
#endif
DoFade(); DoFade();
Render2dStuffAfterFade(); Render2dStuffAfterFade();
CFont::DrawFonts(); CFont::DrawFonts();
@ -216,9 +220,7 @@ DoRWStuffStartOfFrame(int16 TopRed, int16 TopGreen, int16 TopBlue, int16 BottomR
CRGBA TopColor(TopRed, TopGreen, TopBlue, Alpha); CRGBA TopColor(TopRed, TopGreen, TopBlue, Alpha);
CRGBA BottomColor(BottomRed, BottomGreen, BottomBlue, Alpha); CRGBA BottomColor(BottomRed, BottomGreen, BottomBlue, Alpha);
float viewWindow = tan(DEGTORAD(CDraw::GetFOV() * 0.5f)); CameraSize(Scene.camera, nil, DEFAULT_VIEWWINDOW, SCREEN_ASPECT_RATIO);
CDraw::CalculateAspectRatio();
CameraSize(Scene.camera, nil, viewWindow, SCREEN_ASPECT_RATIO);
CVisibilityPlugins::SetRenderWareCamera(Scene.camera); CVisibilityPlugins::SetRenderWareCamera(Scene.camera);
RwCameraClear(Scene.camera, &gColourTop, rwCAMERACLEARZ); RwCameraClear(Scene.camera, &gColourTop, rwCAMERACLEARZ);
@ -236,9 +238,7 @@ DoRWStuffStartOfFrame(int16 TopRed, int16 TopGreen, int16 TopBlue, int16 BottomR
bool bool
DoRWStuffStartOfFrame_Horizon(int16 TopRed, int16 TopGreen, int16 TopBlue, int16 BottomRed, int16 BottomGreen, int16 BottomBlue, int16 Alpha) DoRWStuffStartOfFrame_Horizon(int16 TopRed, int16 TopGreen, int16 TopBlue, int16 BottomRed, int16 BottomGreen, int16 BottomBlue, int16 Alpha)
{ {
float viewWindow = tan(DEGTORAD(CDraw::GetFOV() * 0.5f)); CameraSize(Scene.camera, nil, DEFAULT_VIEWWINDOW, SCREEN_ASPECT_RATIO);
CDraw::CalculateAspectRatio();
CameraSize(Scene.camera, nil, viewWindow, SCREEN_ASPECT_RATIO);
CVisibilityPlugins::SetRenderWareCamera(Scene.camera); CVisibilityPlugins::SetRenderWareCamera(Scene.camera);
RwCameraClear(Scene.camera, &gColourTop, rwCAMERACLEARZ); RwCameraClear(Scene.camera, &gColourTop, rwCAMERACLEARZ);
@ -782,7 +782,7 @@ AppEventHandler(RsEvent event, void *param)
{ {
CameraSize(Scene.camera, (RwRect *)param, CameraSize(Scene.camera, (RwRect *)param,
DEFAULT_VIEWWINDOW, DEFAULT_ASPECTRATIO); DEFAULT_VIEWWINDOW, DEFAULT_ASPECT_RATIO);
return rsEVENTPROCESSED; return rsEVENTPROCESSED;
} }

View File

@ -4,8 +4,9 @@
#include "Frontend.h" #include "Frontend.h"
#include "Camera.h" #include "Camera.h"
float CDraw::ms_fAspectRatio; #ifdef ASPECT_RATIO_SCALE
float CDraw::ms_fScreenMultiplier; float CDraw::ms_fAspectRatio = DEFAULT_ASPECT_RATIO;
#endif
float &CDraw::ms_fNearClipZ = *(float*)0x8E2DC4; float &CDraw::ms_fNearClipZ = *(float*)0x8E2DC4;
float &CDraw::ms_fFarClipZ = *(float*)0x9434F0; float &CDraw::ms_fFarClipZ = *(float*)0x9434F0;
@ -16,26 +17,25 @@ uint8 &CDraw::FadeRed = *(uint8*)0x95CD90;
uint8 &CDraw::FadeGreen = *(uint8*)0x95CD71; uint8 &CDraw::FadeGreen = *(uint8*)0x95CD71;
uint8 &CDraw::FadeBlue = *(uint8*)0x95CD53; uint8 &CDraw::FadeBlue = *(uint8*)0x95CD53;
void float
CDraw::CalculateAspectRatio() CDraw::FindAspectRatio(void)
{ {
SetScreenMult(DEFAULT_SCALE);
if(FrontEndMenuManager.m_PrefsUseWideScreen) if(FrontEndMenuManager.m_PrefsUseWideScreen)
ms_fAspectRatio = 16.0f/9.0f; return 16.0f/9.0f;
else 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(hFOV/2) = tan(vFOV/2)*aspectRatio
// => tan(vFOV/2) = tan(hFOV/2)/aspectRatio // => tan(vFOV/2) = tan(hFOV/2)/aspectRatio
float ar1 = 4.0/3.0; float ar1 = DEFAULT_ASPECT_RATIO;
float ar2 = w/h; float ar2 = GetAspectRatio();
hfov = DEGTORAD(hfov); hfov = DEGTORAD(hfov);
float vfov = atan(tan(hfov/2) / ar1) *2; float vfov = atan(tan(hfov/2) / ar1) *2;
hfov = atan(tan(vfov/2) * ar2) *2; hfov = atan(tan(vfov/2) * ar2) *2;
@ -45,9 +45,11 @@ static float hFov2vFov(float hfov)
void void
CDraw::SetFOV(float fov) CDraw::SetFOV(float fov)
{ {
// TODO: fix FOV here or somewhere else? #ifdef ASPECT_RATIO_SCALE
// ms_fFOV = hFov2vFov(fov); ms_fFOV = ConvertFOV(fov);
#else
ms_fFOV = fov; ms_fFOV = fov;
#endif
} }
STARTPATCHES STARTPATCHES

View File

@ -1,16 +1,18 @@
#pragma once #pragma once
#define HUD_SCALE 0.8f
#define DEFAULT_SCALE 1.0f
class CDraw class CDraw
{ {
private: private:
static float &ms_fNearClipZ; static float &ms_fNearClipZ;
static float &ms_fFarClipZ; static float &ms_fFarClipZ;
static float &ms_fFOV; 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_fAspectRatio;
static float ms_fScreenMultiplier; #endif
public: public:
static uint8 &FadeValue; static uint8 &FadeValue;
@ -26,8 +28,12 @@ public:
static void SetFOV(float fov); static void SetFOV(float fov);
static float GetFOV(void) { return ms_fFOV; } 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 float GetAspectRatio(void) { return ms_fAspectRatio; }
static void SetScreenMult(float mult) { ms_fScreenMultiplier = mult; }; static void SetAspectRatio(float ratio) { ms_fAspectRatio = ratio; }
static float GetScreenMult(void) { return ms_fScreenMultiplier; }; #else
static float GetAspectRatio(void) { return FindAspectRatio(); }
#endif
}; };

View File

@ -787,8 +787,8 @@ void CHud::Draw()
if (m_ItemToFlash == ITEM_RADAR && CTimer::GetFrameCounter() & 8 || m_ItemToFlash != ITEM_RADAR) { if (m_ItemToFlash == ITEM_RADAR && CTimer::GetFrameCounter() & 8 || m_ItemToFlash != ITEM_RADAR) {
CRadar::DrawMap(); 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));
// FIX: game doesn't scale RADAR_LEFT here // FIX? scale RADAR_LEFT here somehow
rect.Translate(SCREEN_SCALE_X(RADAR_LEFT), SCREEN_SCALE_FROM_BOTTOM(RADAR_BOTTOM + RADAR_HEIGHT)); rect.Translate(RADAR_LEFT, SCREEN_SCALE_FROM_BOTTOM(RADAR_BOTTOM + RADAR_HEIGHT));
rect.Grow(4.0f); rect.Grow(4.0f);
Sprites[HUD_RADARDISC].Draw(rect, CRGBA(0, 0, 0, 255)); Sprites[HUD_RADARDISC].Draw(rect, CRGBA(0, 0, 0, 255));
CRadar::DrawBlips(); CRadar::DrawBlips();

View File

@ -16,7 +16,7 @@ CSprite::CalcHorizonCoors(void)
CVector p = TheCamera.GetPosition() + CVector(TheCamera.CamFrontXNorm, TheCamera.CamFrontYNorm, 0.0f)*3000.0f; CVector p = TheCamera.GetPosition() + CVector(TheCamera.CamFrontXNorm, TheCamera.CamFrontYNorm, 0.0f)*3000.0f;
p.z = 0.0f; p.z = 0.0f;
p = TheCamera.m_viewMatrix * p; p = TheCamera.m_viewMatrix * p;
return p.y * RsGlobal.maximumHeight / p.z; return p.y * SCREEN_HEIGHT / p.z;
} }
bool 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::GetNearClipZ() + 1.0f) return false;
if(out->z >= CDraw::GetFarClipZ() && farclip) return false; if(out->z >= CDraw::GetFarClipZ() && farclip) return false;
float recip = 1.0f/out->z; float recip = 1.0f/out->z;
out->x *= RsGlobal.maximumWidth * recip; out->x *= SCREEN_WIDTH * recip;
out->y *= RsGlobal.maximumHeight * recip; out->y *= SCREEN_HEIGHT * recip;
// What is this? size? // What is this? size?
*outw = 70.0f/CDraw::GetFOV(); *outw = 70.0f/CDraw::GetFOV();
*outh = 70.0f/CDraw::GetFOV(); *outh = 70.0f/CDraw::GetFOV();
*outw *= RsGlobal.maximumWidth * recip; *outw *= SCREEN_WIDTH * recip;
*outh *= RsGlobal.maximumHeight * recip; *outh *= SCREEN_HEIGHT * recip;
return true; 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); us[i] = -xs[i] / (2.0f*w);
xs[i] = 0.0f; xs[i] = 0.0f;
} }
if(xs[i] > RsGlobal.maximumWidth){ if(xs[i] > SCREEN_WIDTH){
us[i] = 1.0f - (xs[i]-RsGlobal.maximumWidth) / (2.0f*w); us[i] = 1.0f - (xs[i]-SCREEN_WIDTH) / (2.0f*w);
xs[i] = RsGlobal.maximumWidth; xs[i] = SCREEN_WIDTH;
} }
if(ys[i] < 0.0f){ if(ys[i] < 0.0f){
vs[i] = -ys[i] / (2.0f*h); vs[i] = -ys[i] / (2.0f*h);
ys[i] = 0.0f; ys[i] = 0.0f;
} }
if(ys[i] > RsGlobal.maximumHeight){ if(ys[i] > SCREEN_HEIGHT){
vs[i] = 1.0f - (ys[i]-RsGlobal.maximumHeight) / (2.0f*h); vs[i] = 1.0f - (ys[i]-SCREEN_HEIGHT) / (2.0f*h);
ys[i] = RsGlobal.maximumHeight; 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 // No clipping, just culling
if(xs[0] < 0.0f && xs[1] < 0.0f && xs[2] < 0.0f && xs[3] < 0.0f) return; 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(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 && if(xs[0] > SCREEN_WIDTH && xs[1] > SCREEN_WIDTH &&
xs[2] > RsGlobal.maximumWidth && xs[3] > RsGlobal.maximumWidth) return; xs[2] > SCREEN_WIDTH && xs[3] > SCREEN_WIDTH) return;
if(ys[0] > RsGlobal.maximumHeight && ys[1] > RsGlobal.maximumHeight && if(ys[0] > SCREEN_HEIGHT && ys[1] > SCREEN_HEIGHT &&
ys[2] > RsGlobal.maximumHeight && ys[3] > RsGlobal.maximumHeight) return; ys[2] > SCREEN_HEIGHT && ys[3] > SCREEN_HEIGHT) return;
float screenz = m_f2DNearScreenZ + float screenz = m_f2DNearScreenZ +
(z-CDraw::GetNearClipZ())*(m_f2DFarScreenZ-m_f2DNearScreenZ)*CDraw::GetFarClipZ() / (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); us[i] = -xs[i] / (2.0f*w);
xs[i] = 0.0f; xs[i] = 0.0f;
} }
if(xs[i] > RsGlobal.maximumWidth){ if(xs[i] > SCREEN_WIDTH){
us[i] = 1.0f - (xs[i]-RsGlobal.maximumWidth) / (2.0f*w); us[i] = 1.0f - (xs[i]-SCREEN_WIDTH) / (2.0f*w);
xs[i] = RsGlobal.maximumWidth; xs[i] = SCREEN_WIDTH;
} }
if(ys[i] < 0.0f){ if(ys[i] < 0.0f){
vs[i] = -ys[i] / (2.0f*h); vs[i] = -ys[i] / (2.0f*h);
ys[i] = 0.0f; ys[i] = 0.0f;
} }
if(ys[i] > RsGlobal.maximumHeight){ if(ys[i] > SCREEN_HEIGHT){
vs[i] = 1.0f - (ys[i]-RsGlobal.maximumHeight) / (2.0f*h); vs[i] = 1.0f - (ys[i]-SCREEN_HEIGHT) / (2.0f*h);
ys[i] = RsGlobal.maximumHeight; ys[i] = SCREEN_HEIGHT;
} }
} }
@ -283,10 +283,10 @@ CSprite::RenderBufferedOneXLUSprite_Rotate_Dimension(float x, float y, float z,
// No clipping, just culling // No clipping, just culling
if(xs[0] < 0.0f && xs[1] < 0.0f && xs[2] < 0.0f && xs[3] < 0.0f) return; 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(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 && if(xs[0] > SCREEN_WIDTH && xs[1] > SCREEN_WIDTH &&
xs[2] > RsGlobal.maximumWidth && xs[3] > RsGlobal.maximumWidth) return; xs[2] > SCREEN_WIDTH && xs[3] > SCREEN_WIDTH) return;
if(ys[0] > RsGlobal.maximumHeight && ys[1] > RsGlobal.maximumHeight && if(ys[0] > SCREEN_HEIGHT && ys[1] > SCREEN_HEIGHT &&
ys[2] > RsGlobal.maximumHeight && ys[3] > RsGlobal.maximumHeight) return; ys[2] > SCREEN_HEIGHT && ys[3] > SCREEN_HEIGHT) return;
float screenz = m_f2DNearScreenZ + float screenz = m_f2DNearScreenZ +
(z-CDraw::GetNearClipZ())*(m_f2DFarScreenZ-m_f2DNearScreenZ)*CDraw::GetFarClipZ() / (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 // No clipping, just culling
if(xs[0] < 0.0f && xs[1] < 0.0f && xs[2] < 0.0f && xs[3] < 0.0f) return; 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(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 && if(xs[0] > SCREEN_WIDTH && xs[1] > SCREEN_WIDTH &&
xs[2] > RsGlobal.maximumWidth && xs[3] > RsGlobal.maximumWidth) return; xs[2] > SCREEN_WIDTH && xs[3] > SCREEN_WIDTH) return;
if(ys[0] > RsGlobal.maximumHeight && ys[1] > RsGlobal.maximumHeight && if(ys[0] > SCREEN_HEIGHT && ys[1] > SCREEN_HEIGHT &&
ys[2] > RsGlobal.maximumHeight && ys[3] > RsGlobal.maximumHeight) return; ys[2] > SCREEN_HEIGHT && ys[3] > SCREEN_HEIGHT) return;
float screenz = m_f2DNearScreenZ + float screenz = m_f2DNearScreenZ +
(z-CDraw::GetNearClipZ())*(m_f2DFarScreenZ-m_f2DNearScreenZ)*CDraw::GetFarClipZ() / (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 // No clipping, just culling
if(xs[0] < 0.0f && xs[1] < 0.0f && xs[2] < 0.0f && xs[3] < 0.0f) return; 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(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 && if(xs[0] > SCREEN_WIDTH && xs[1] > SCREEN_WIDTH &&
xs[2] > RsGlobal.maximumWidth && xs[3] > RsGlobal.maximumWidth) return; xs[2] > SCREEN_WIDTH && xs[3] > SCREEN_WIDTH) return;
if(ys[0] > RsGlobal.maximumHeight && ys[1] > RsGlobal.maximumHeight && if(ys[0] > SCREEN_HEIGHT && ys[1] > SCREEN_HEIGHT &&
ys[2] > RsGlobal.maximumHeight && ys[3] > RsGlobal.maximumHeight) return; ys[2] > SCREEN_HEIGHT && ys[3] > SCREEN_HEIGHT) return;
// Colour factors, cx/y is the direction in which colours change from rgb1 to rgb2 // 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; cf[0] = (cx*(-c-s) + cy*(-c+s))*0.5f + 0.5f;

View File

@ -626,9 +626,7 @@ psInitialise(void)
C_PcSave::SetSaveDirectory(_psGetUserFilesFolder()); C_PcSave::SetSaveDirectory(_psGetUserFilesFolder());
#ifndef NASTY_GAME
InitialiseLanguage(); InitialiseLanguage();
#endif
FrontEndMenuManager.LoadSettings(); FrontEndMenuManager.LoadSettings();
@ -1262,7 +1260,7 @@ UINT GetBestRefreshRate(UINT width, UINT height, UINT depth)
ASSERT(d3d != nil); ASSERT(d3d != nil);
INT refreshRate = -1; UINT refreshRate = INT_MAX;
D3DFORMAT format; D3DFORMAT format;
if ( depth == 32 ) if ( depth == 32 )
@ -1284,12 +1282,9 @@ UINT GetBestRefreshRate(UINT width, UINT height, UINT depth)
{ {
if ( mode.RefreshRate == 0 ) if ( mode.RefreshRate == 0 )
return 0; return 0;
#pragma warning( push )
#pragma warning( disable : 4018)
if ( mode.RefreshRate < refreshRate && mode.RefreshRate >= 60 ) if ( mode.RefreshRate < refreshRate && mode.RefreshRate >= 60 )
refreshRate = mode.RefreshRate; refreshRate = mode.RefreshRate;
#pragma warning( pop )
} }
} }
@ -1540,8 +1535,6 @@ CommandLineToArgv(RwChar *cmdLine, RwInt32 *argCount)
*/ */
void InitialiseLanguage() void InitialiseLanguage()
{ {
#pragma warning( push )
#pragma warning( disable : 4302)
WORD primUserLCID = PRIMARYLANGID(GetSystemDefaultLCID()); WORD primUserLCID = PRIMARYLANGID(GetSystemDefaultLCID());
WORD primSystemLCID = PRIMARYLANGID(GetUserDefaultLCID()); WORD primSystemLCID = PRIMARYLANGID(GetUserDefaultLCID());
WORD primLayout = PRIMARYLANGID((DWORD)GetKeyboardLayout(0)); WORD primLayout = PRIMARYLANGID((DWORD)GetKeyboardLayout(0));
@ -1549,7 +1542,6 @@ void InitialiseLanguage()
WORD subUserLCID = SUBLANGID(GetSystemDefaultLCID()); WORD subUserLCID = SUBLANGID(GetSystemDefaultLCID());
WORD subSystemLCID = SUBLANGID(GetUserDefaultLCID()); WORD subSystemLCID = SUBLANGID(GetUserDefaultLCID());
WORD subLayout = SUBLANGID((DWORD)GetKeyboardLayout(0)); WORD subLayout = SUBLANGID((DWORD)GetKeyboardLayout(0));
#pragma warning( pop )
if ( primUserLCID == LANG_GERMAN if ( primUserLCID == LANG_GERMAN
|| primSystemLCID == LANG_GERMAN || primSystemLCID == LANG_GERMAN
@ -1574,6 +1566,12 @@ void InitialiseLanguage()
|| subLayout == SUBLANG_ENGLISH_AUS ) || subLayout == SUBLANG_ENGLISH_AUS )
CGame::noProstitutes = true; CGame::noProstitutes = true;
#ifdef NASTY_GAME
CGame::nastyGame = true;
CMenuManager::m_PrefsAllowNastyGame = true;
CGame::noProstitutes = false;
#endif
int32 lang; int32 lang;
switch ( primSystemLCID ) switch ( primSystemLCID )
@ -2420,12 +2418,8 @@ void _InputInitialiseJoys()
} }
} }
#pragma warning( push ) void _InputAddJoyStick(LPDIRECTINPUTDEVICE8 lpDevice, INT num)
#pragma warning( disable : 4700)
HRESULT _InputAddJoyStick(LPDIRECTINPUTDEVICE8 lpDevice, INT num)
{ {
HRESULT hr;
DIDEVICEOBJECTINSTANCE objInst; DIDEVICEOBJECTINSTANCE objInst;
objInst.dwSize = sizeof( DIDEVICEOBJECTINSTANCE ); objInst.dwSize = sizeof( DIDEVICEOBJECTINSTANCE );
@ -2445,7 +2439,7 @@ HRESULT _InputAddJoyStick(LPDIRECTINPUTDEVICE8 lpDevice, INT num)
if ( SUCCEEDED( lpDevice->GetObjectInfo( &objInst, DIJOFS_X, DIPH_BYOFFSET ) ) ) if ( SUCCEEDED( lpDevice->GetObjectInfo( &objInst, DIJOFS_X, DIPH_BYOFFSET ) ) )
{ {
if( FAILED( lpDevice->SetProperty( DIPROP_RANGE, (LPCDIPROPHEADER)&range ) ) ) if( FAILED( lpDevice->SetProperty( DIPROP_RANGE, (LPCDIPROPHEADER)&range ) ) )
return S_FALSE; return;
else else
; ;
} }
@ -2457,7 +2451,7 @@ HRESULT _InputAddJoyStick(LPDIRECTINPUTDEVICE8 lpDevice, INT num)
if ( SUCCEEDED( lpDevice->GetObjectInfo( &objInst, DIJOFS_Y, DIPH_BYOFFSET ) ) ) if ( SUCCEEDED( lpDevice->GetObjectInfo( &objInst, DIJOFS_Y, DIPH_BYOFFSET ) ) )
{ {
if( FAILED( lpDevice->SetProperty( DIPROP_RANGE, (LPCDIPROPHEADER)&range ) ) ) if( FAILED( lpDevice->SetProperty( DIPROP_RANGE, (LPCDIPROPHEADER)&range ) ) )
return S_FALSE; return;
else else
; ;
} }
@ -2469,7 +2463,7 @@ HRESULT _InputAddJoyStick(LPDIRECTINPUTDEVICE8 lpDevice, INT num)
if ( SUCCEEDED( lpDevice->GetObjectInfo( &objInst, DIJOFS_Z, DIPH_BYOFFSET ) ) ) if ( SUCCEEDED( lpDevice->GetObjectInfo( &objInst, DIJOFS_Z, DIPH_BYOFFSET ) ) )
{ {
if( FAILED( lpDevice->SetProperty( DIPROP_RANGE, (LPCDIPROPHEADER)&range ) ) ) if( FAILED( lpDevice->SetProperty( DIPROP_RANGE, (LPCDIPROPHEADER)&range ) ) )
return S_FALSE; return;
else else
AllValidWinJoys.m_aJoys[num].m_bHasAxisZ = true; // z rightStickPos.x AllValidWinJoys.m_aJoys[num].m_bHasAxisZ = true; // z rightStickPos.x
} }
@ -2481,15 +2475,12 @@ HRESULT _InputAddJoyStick(LPDIRECTINPUTDEVICE8 lpDevice, INT num)
if ( SUCCEEDED( lpDevice->GetObjectInfo( &objInst, DIJOFS_RZ, DIPH_BYOFFSET ) ) ) if ( SUCCEEDED( lpDevice->GetObjectInfo( &objInst, DIJOFS_RZ, DIPH_BYOFFSET ) ) )
{ {
if( FAILED( lpDevice->SetProperty( DIPROP_RANGE, (LPCDIPROPHEADER)&range ) ) ) if( FAILED( lpDevice->SetProperty( DIPROP_RANGE, (LPCDIPROPHEADER)&range ) ) )
return S_FALSE; return;
else else
AllValidWinJoys.m_aJoys[num].m_bHasAxisR = true; // r rightStickPos.y AllValidWinJoys.m_aJoys[num].m_bHasAxisR = true; // r rightStickPos.y
} }
} }
return hr;
} }
#pragma warning( pop )
HRESULT _InputAddJoys() HRESULT _InputAddJoys()
{ {
@ -2973,9 +2964,7 @@ void _InputTranslateShiftKeyUpDown(RsKeyCodes *rs)
} }
} }
#pragma warning( push ) BOOL _InputTranslateShiftKey(RsKeyCodes *rs, UINT key, BOOLEAN bDown)
#pragma warning( disable : 4805)
BOOL _InputTranslateShiftKey(RsKeyCodes *rs, UINT key, bool bDown)
{ {
*rs = rsNULL; *rs = rsNULL;
switch ( key ) switch ( key )
@ -3002,7 +2991,6 @@ BOOL _InputTranslateShiftKey(RsKeyCodes *rs, UINT key, bool bDown)
return TRUE; return TRUE;
} }
#pragma warning( pop )
BOOL _InputIsExtended(INT flag) BOOL _InputIsExtended(INT flag)
{ {

View File

@ -63,14 +63,14 @@ HRESULT _InputInitialise();
HRESULT _InputInitialiseMouse(); HRESULT _InputInitialiseMouse();
HRESULT CapturePad(RwInt32 padID); HRESULT CapturePad(RwInt32 padID);
void _InputInitialiseJoys(); void _InputInitialiseJoys();
HRESULT _InputAddJoyStick(LPDIRECTINPUTDEVICE8 lpDevice, INT num); void _InputAddJoyStick(LPDIRECTINPUTDEVICE8 lpDevice, INT num);
HRESULT _InputAddJoys(); HRESULT _InputAddJoys();
HRESULT _InputGetMouseState(DIMOUSESTATE2 *state); HRESULT _InputGetMouseState(DIMOUSESTATE2 *state);
void _InputShutdown(); void _InputShutdown();
BOOL CALLBACK _InputEnumDevicesCallback( const DIDEVICEINSTANCE* pdidInstance, VOID* pContext ); BOOL CALLBACK _InputEnumDevicesCallback( const DIDEVICEINSTANCE* pdidInstance, VOID* pContext );
BOOL _InputTranslateKey(RsKeyCodes *rs, UINT flag, UINT key); BOOL _InputTranslateKey(RsKeyCodes *rs, UINT flag, UINT key);
void _InputTranslateShiftKeyUpDown(RsKeyCodes *rs);; void _InputTranslateShiftKeyUpDown(RsKeyCodes *rs);;
BOOL _InputTranslateShiftKey(RsKeyCodes *rs, UINT key, bool bDown); BOOL _InputTranslateShiftKey(RsKeyCodes *rs, UINT key, BOOLEAN bDown);
BOOL _InputIsExtended(INT flag); BOOL _InputIsExtended(INT flag);
void InitialiseLanguage(); void InitialiseLanguage();