From 368d2f3279b474056e888dcccea234f32614b506 Mon Sep 17 00:00:00 2001
From: Fire-Head <Fire-Head@users.noreply.github.com>
Date: Fri, 8 Jan 2021 19:31:48 +0300
Subject: [PATCH] bb .ini hello defines

---
 src/core/Radar.cpp    | 15 +++------------
 src/core/Radar.h      | 18 ++++++++++++++++++
 src/core/common.h     |  6 +-----
 src/core/config.h     |  4 ++++
 src/core/re3.cpp      | 12 ------------
 src/render/Draw.cpp   | 20 +-------------------
 src/render/Draw.h     | 15 ---------------
 src/render/Hud.cpp    | 12 ++----------
 src/render/Sprite.cpp |  9 ++++-----
 9 files changed, 33 insertions(+), 78 deletions(-)

diff --git a/src/core/Radar.cpp b/src/core/Radar.cpp
index f8227bf7..816da6b9 100644
--- a/src/core/Radar.cpp
+++ b/src/core/Radar.cpp
@@ -1297,21 +1297,12 @@ void CRadar::TransformRadarPointToScreenSpace(CVector2D &out, const CVector2D &i
 	} else
 #endif
 	{
-#ifdef ASPECT_RATIO_SCALE
-// The values are from an early screenshot taken before R* broke radar
-#define _RADAR_WIDTH ((CDraw::ms_bFixRadar)  ? (82.0f) : (RADAR_WIDTH))
-#define _RADAR_HEIGHT ((CDraw::ms_bFixRadar) ? (82.0f) : (RADAR_HEIGHT))
-#else
-#define _RADAR_WIDTH RADAR_WIDTH
-#define _RADAR_HEIGHT RADAR_HEIGHT
-#endif
-
 #ifdef FIX_BUGS
-		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) + SCREEN_SCALE_X(RADAR_LEFT);
 #else
-		out.x = (in.x + 1.0f) * 0.5f * SCREEN_SCALE_X(_RADAR_WIDTH) + RADAR_LEFT;
+		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);
+		out.y = (1.0f - in.y) * 0.5f * SCREEN_SCALE_Y(RADAR_HEIGHT) + SCREEN_SCALE_FROM_BOTTOM(RADAR_BOTTOM + RADAR_HEIGHT);
 	}
 }
 
diff --git a/src/core/Radar.h b/src/core/Radar.h
index 5caf5bbb..725c8351 100644
--- a/src/core/Radar.h
+++ b/src/core/Radar.h
@@ -91,8 +91,26 @@ VALIDATE_SIZE(sRadarTrace, 0x30);
 #else
 #define RADAR_BOTTOM (47.0f)
 #endif
+
+#ifdef FIX_RADAR
+/*
+	The values are from an early screenshot taken before R* broke radar
+*/
+#define RADAR_WIDTH (82.0f)
+#define RADAR_HEIGHT (82.0f)
+#else
+/*
+	broken since forever, someone tried to fix size for 640x512(PAL)
+		http://aap.rockstarvision.com/pics/gta3/ps2screens/gta3_interface.jpg
+	but failed:
+		http://aap.rockstarvision.com/pics/gta3/artwork/gta3_artwork_16.jpg
+	most likely the guy used something like this:
+		int y = 82 * (640.0/512.0)/(640.0/480.0);
+		int x = y * (640.0/512.0);
+*/
 #define RADAR_WIDTH (94.0f)
 #define RADAR_HEIGHT (76.0f)
+#endif
 
 class CRadar
 {
diff --git a/src/core/common.h b/src/core/common.h
index 44d94370..5767b087 100644
--- a/src/core/common.h
+++ b/src/core/common.h
@@ -121,7 +121,7 @@ inline uint32 ldb(uint32 p, uint32 s, uint32 w)
 #include "skeleton.h"
 #include "Draw.h"
 
-#if defined(ASPECT_RATIO_SCALE)
+#if defined(PROPER_SCALING) || defined(PS2_HUD)
 	#ifdef FORCE_PC_SCALING
 		#define DEFAULT_SCREEN_WIDTH  (640)
 		#define DEFAULT_SCREEN_HEIGHT (448)
@@ -176,10 +176,6 @@ 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)
 #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)
diff --git a/src/core/config.h b/src/core/config.h
index a9bb1a17..3d5ef281 100644
--- a/src/core/config.h
+++ b/src/core/config.h
@@ -241,6 +241,7 @@ enum Config {
 //# define HARDCODED_MODEL_FLAGS	// sets the flags enabled above from hardcoded model names.
 				// NB: keep this enabled unless your map IDEs have these flags baked in
 #define ASPECT_RATIO_SCALE	// Not just makes everything scale with aspect ratio, also adds support for all aspect ratios
+#define PROPER_SCALING		// use original DEFAULT_SCREEN_WIDTH/DEFAULT_SCREEN_HEIGHT from PS2 instead of PC(R* changed HEIGHT here to make radar look better, but broke other hud elements aspect ratio).
 #define DEFAULT_NATIVE_RESOLUTION	// Set default video mode to your native resolution (fixes Windows 10 launch)
 #define USE_TXD_CDIMAGE		// generate and load textures from txd.img
 #define PS2_ALPHA_TEST		// emulate ps2 alpha test 
@@ -254,6 +255,8 @@ enum Config {
 #define SCREEN_DROPLETS			// neo water droplets
 #endif
 
+#define FIX_SPRITES	// fix sprites aspect ratio(moon, coronas, particle etc)
+
 #ifndef EXTENDED_COLOURFILTER
 #undef SCREEN_DROPLETS		// we need the backbuffer for this effect
 #endif
@@ -282,6 +285,7 @@ enum Config {
 #define HUD_ENHANCEMENTS	// Adjusts some aspects to make the HUD look/behave a little bit better.
 // #define BETA_SLIDING_TEXT
 #define TRIANGULAR_BLIPS	// height indicating triangular radar blips, as in VC
+#define FIX_RADAR			// use radar size from early version before R* broke it
 // #define XBOX_SUBTITLES	// the infamous outlines
 #define RADIO_OFF_TEXT
 #define PC_MENU
diff --git a/src/core/re3.cpp b/src/core/re3.cpp
index 14457db4..87244e2a 100644
--- a/src/core/re3.cpp
+++ b/src/core/re3.cpp
@@ -214,12 +214,6 @@ void LoadINISettings()
 	CustomPipes::LightmapMult = CheckAndReadIniFloat("CustomPipesValues", "LightmapMult", CustomPipes::LightmapMult);
 	CustomPipes::GlossMult = CheckAndReadIniFloat("CustomPipesValues", "GlossMult", CustomPipes::GlossMult);
 #endif
-
-#ifdef ASPECT_RATIO_SCALE
-	CDraw::ms_nScalingMode = CheckAndReadIniInt("Draw", "ScalingMode", CDraw::ms_nScalingMode);
-	CDraw::ms_bFixRadar    = CheckAndReadIniInt("Draw", "FixRadar", CDraw::ms_bFixRadar);
-	CDraw::ms_bFixSprites  = CheckAndReadIniInt("Draw", "FixSpritesAspectRatio", CDraw::ms_bFixSprites);
-#endif
 }
 
 void SaveINISettings()
@@ -259,12 +253,6 @@ void SaveINISettings()
 	CheckAndSaveIniFloat("CustomPipesValues", "GlossMult", CustomPipes::GlossMult, changed);
 #endif
 
-#ifdef ASPECT_RATIO_SCALE
-	CheckAndSaveIniInt("Draw", "ScalingMode", CDraw::ms_nScalingMode, changed);
-	CheckAndSaveIniInt("Draw", "FixRadar", CDraw::ms_bFixRadar, changed);
-	CheckAndSaveIniInt("Draw", "FixSpritesAspectRatio", CDraw::ms_bFixSprites, changed);
-#endif
-
 	if (changed)
 		cfg.write_file("re3.ini");
 }
diff --git a/src/render/Draw.cpp b/src/render/Draw.cpp
index 42015176..fcd5d18f 100644
--- a/src/render/Draw.cpp
+++ b/src/render/Draw.cpp
@@ -20,12 +20,6 @@ uint8 CDraw::FadeRed;
 uint8 CDraw::FadeGreen;
 uint8 CDraw::FadeBlue;
 
-#ifdef ASPECT_RATIO_SCALE
-int32 CDraw::ms_nScalingMode = SCL_PS2;
-int32 CDraw::ms_bFixRadar = true;
-int32 CDraw::ms_bFixSprites = true;
-#endif
-
 float
 CDraw::FindAspectRatio(void)
 {
@@ -81,16 +75,4 @@ CDraw::SetFOV(float fov)
 		ms_fScaledFOV = fov;
 #endif
 	ms_fFOV = fov;
-}
-
-#ifdef ASPECT_RATIO_SCALE
-float CDraw::ScaleY(float y)
-{
-	switch ( ms_nScalingMode )
-	{
-		case SCL_PC: return y * ((float)DEFAULT_SCREEN_HEIGHT/SCREEN_HEIGHT_NTSC);
-		default:
-			return y;
-	}
-}
-#endif
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/src/render/Draw.h b/src/render/Draw.h
index bd97f76f..45f7906f 100644
--- a/src/render/Draw.h
+++ b/src/render/Draw.h
@@ -14,12 +14,6 @@ enum eAspectRatio
 	AR_MAX,
 };
 
-enum eSpriteScalingMode 
-{
-	SCL_PC,
-	SCL_PS2,
-};
-
 class CDraw
 {
 private:
@@ -40,11 +34,6 @@ public:
 	static uint8 FadeRed;
 	static uint8 FadeGreen;
 	static uint8 FadeBlue;
-#ifdef ASPECT_RATIO_SCALE
-	static int32 ms_nScalingMode;
-	static int32 ms_bFixRadar;
-	static int32 ms_bFixSprites;
-#endif
 
 	static void SetNearClipZ(float nearclip) { ms_fNearClipZ = nearclip; }
 	static float GetNearClipZ(void) { return ms_fNearClipZ; }
@@ -67,8 +56,4 @@ public:
 #else
 	static float GetAspectRatio(void) { return FindAspectRatio(); }
 #endif
-
-#ifdef ASPECT_RATIO_SCALE
-	static float ScaleY(float y);
-#endif
 };
diff --git a/src/render/Hud.cpp b/src/render/Hud.cpp
index 84146fba..ae7b7eb3 100644
--- a/src/render/Hud.cpp
+++ b/src/render/Hud.cpp
@@ -1059,18 +1059,10 @@ void CHud::Draw()
 		/*
 			DrawRadar
 		*/
-#ifdef ASPECT_RATIO_SCALE
-// The values are from an early screenshot taken before R* broke radar
-#define _RADAR_WIDTH ((CDraw::ms_bFixRadar)  ? (82.0f) : (RADAR_WIDTH))
-#define _RADAR_HEIGHT ((CDraw::ms_bFixRadar) ? (82.0f) : (RADAR_HEIGHT))
-#else
-#define _RADAR_WIDTH RADAR_WIDTH
-#define _RADAR_HEIGHT RADAR_HEIGHT
-#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));
-			rect.Translate(SCREEN_SCALE_X_FIX(RADAR_LEFT), SCREEN_SCALE_FROM_BOTTOM(RADAR_BOTTOM + _RADAR_HEIGHT));
+			CRect rect(0.0f, 0.0f, SCREEN_SCALE_X(RADAR_WIDTH), SCREEN_SCALE_Y(RADAR_HEIGHT));
+			rect.Translate(SCREEN_SCALE_X_FIX(RADAR_LEFT), SCREEN_SCALE_FROM_BOTTOM(RADAR_BOTTOM + RADAR_HEIGHT));
 
 #ifdef PS2_HUD
 	#ifdef FIX_BUGS
diff --git a/src/render/Sprite.cpp b/src/render/Sprite.cpp
index 390737f3..c31c75d2 100644
--- a/src/render/Sprite.cpp
+++ b/src/render/Sprite.cpp
@@ -37,13 +37,12 @@ CSprite::CalcScreenCoors(const RwV3d &in, RwV3d *out, float *outw, float *outh,
 	// this is used to scale correctly if you zoom in with sniper rifle
 	float fovScale = fov / CDraw::GetFOV();
 
+#ifdef FIX_SPRITES
+	*outw = fovScale * recip * SCREEN_HEIGHT;
+#else
 	*outw = fovScale * SCREEN_SCALE_AR(recip) * SCREEN_WIDTH;
-	*outh = fovScale * recip * SCREEN_HEIGHT;
-	
-#ifdef ASPECT_RATIO_SCALE
-	if ( CDraw::ms_bFixSprites )
-		*outw = fovScale * recip * SCREEN_HEIGHT;
 #endif
+	*outh = fovScale * recip * SCREEN_HEIGHT;
 
 	return true;
 }