diff options
Diffstat (limited to 'src/render')
-rw-r--r-- | src/render/Draw.cpp | 34 | ||||
-rw-r--r-- | src/render/Draw.h | 20 | ||||
-rw-r--r-- | src/render/Hud.cpp | 16 | ||||
-rw-r--r-- | src/render/SpecialFX.cpp | 5 | ||||
-rw-r--r-- | src/render/SpecialFX.h | 17 | ||||
-rw-r--r-- | src/render/Sprite.cpp | 66 |
6 files changed, 94 insertions, 64 deletions
diff --git a/src/render/Draw.cpp b/src/render/Draw.cpp index 90875299..922d96d4 100644 --- a/src/render/Draw.cpp +++ b/src/render/Draw.cpp @@ -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 diff --git a/src/render/Draw.h b/src/render/Draw.h index 1fcb5212..3349c6c9 100644 --- a/src/render/Draw.h +++ b/src/render/Draw.h @@ -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 }; diff --git a/src/render/Hud.cpp b/src/render/Hud.cpp index 83e62ba0..e5a44221 100644 --- a/src/render/Hud.cpp +++ b/src/render/Hud.cpp @@ -300,10 +300,10 @@ void CHud::Draw() /* DrawAmmo */ - int16 AmmoAmount = CWeaponInfo::GetWeaponInfo(FindPlayerPed()->GetWeapon()->m_eWeaponType)->m_nAmountofAmmunition; - int32 AmmoInClip = CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_weapons[CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_currentWeapon].m_nAmmoInClip; - int32 TotalAmmo = CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_weapons[CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_currentWeapon].m_nAmmoTotal; - int32 Ammo, Clip; + uint32 AmmoAmount = CWeaponInfo::GetWeaponInfo(FindPlayerPed()->GetWeapon()->m_eWeaponType)->m_nAmountofAmmunition; + uint32 AmmoInClip = CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_weapons[CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_currentWeapon].m_nAmmoInClip; + uint32 TotalAmmo = CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_weapons[CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_currentWeapon].m_nAmmoTotal; + uint32 Ammo, Clip; if (AmmoAmount <= 1 || AmmoAmount >= 1000) sprintf(sTemp, "%d", TotalAmmo); @@ -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(); @@ -1359,7 +1359,7 @@ void CHud::SetHelpMessage(wchar *message, bool quick) CMessages::InsertPlayerControlKeysInString(m_HelpMessage); for (int i = 0; i < 256; i++) { - m_LastHelpMessage[i] = message[i]; + m_LastHelpMessage[i] = 0; } m_HelpMessageState = 0; @@ -1443,7 +1443,7 @@ STARTPATCHES InjectHook(0x5048F0, &CHud::Initialise, PATCH_JUMP); InjectHook(0x504CC0, &CHud::ReInitialise, PATCH_JUMP); InjectHook(0x50A250, &CHud::SetBigMessage, PATCH_JUMP); - //InjectHook(0x5051E0, &CHud::SetHelpMessage, PATCH_JUMP); + InjectHook(0x5051E0, &CHud::SetHelpMessage, PATCH_JUMP); InjectHook(0x50A210, &CHud::SetMessage, PATCH_JUMP); InjectHook(0x50A320, &CHud::SetPagerMessage, PATCH_JUMP); InjectHook(0x505290, &CHud::SetVehicleName, PATCH_JUMP); diff --git a/src/render/SpecialFX.cpp b/src/render/SpecialFX.cpp index 32923b12..a0731b1c 100644 --- a/src/render/SpecialFX.cpp +++ b/src/render/SpecialFX.cpp @@ -5,3 +5,8 @@ WRAPPER void CSpecialFX::Render(void) { EAXJMP(0x518DC0); } WRAPPER void CMotionBlurStreaks::RegisterStreak(int32 id, uint8 r, uint8 g, uint8 b, CVector p1, CVector p2) { EAXJMP(0x519460); } + + +CBulletTrace (&CBulletTraces::aTraces)[16] = *(CBulletTrace(*)[16])*(uintptr*)0x72B1B8; + +WRAPPER void CBulletTraces::Init(void) { EAXJMP(0x518DE0); } diff --git a/src/render/SpecialFX.h b/src/render/SpecialFX.h index 1a1a4c1e..1035b315 100644 --- a/src/render/SpecialFX.h +++ b/src/render/SpecialFX.h @@ -11,3 +11,20 @@ class CMotionBlurStreaks public: static void RegisterStreak(int32 id, uint8 r, uint8 g, uint8 b, CVector p1, CVector p2); }; + +struct CBulletTrace +{ + CVector m_vecInf; + CVector m_vecSup; + bool m_bInUse; + uint8 m_framesInUse; + uint8 m_lifeTime; +}; + +class CBulletTraces +{ +public: + static CBulletTrace (&aTraces)[16]; + + static void Init(void); +}; diff --git a/src/render/Sprite.cpp b/src/render/Sprite.cpp index 57a8a22f..d917117a 100644 --- a/src/render/Sprite.cpp +++ b/src/render/Sprite.cpp @@ -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; |