Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
some cleanup
  • Loading branch information
aap committed Jun 16, 2019
1 parent bb52654 commit 2a207af49a922fe65bb3e69489aa3e075b72c3e3
Showing with 167 additions and 167 deletions.
  1. +2 −2 src/Radar.cpp
  2. +5 −1 src/common.h
  3. +4 −8 src/main.cpp
  4. +8 −9 src/render/Draw.cpp
  5. +148 −147 src/render/Hud.cpp
@@ -38,8 +38,8 @@ void CRadar::DrawMap() {
} }


void CRadar::TransformRadarPointToScreenSpace(CVector2D *out, CVector2D *in) { void CRadar::TransformRadarPointToScreenSpace(CVector2D *out, CVector2D *in) {
out->x = in->x * SCREEN_STRETCH_X(47.0f) + SCREEN_STRETCH_X(47.0f + 20.0f); out->x = in->x * HUD_STRETCH_X(47.0f) + HUD_STRETCH_X(47.0f + 20.0f);
out->y = (SCREEN_STRETCH_Y(76.0f)) * 0.5f + RsGlobal.height - (SCREEN_STRETCH_Y(123.0f)) - in->y * (SCREEN_STRETCH_Y(76.0f)) * 0.5f; out->y = (HUD_STRETCH_Y(76.0f)) * 0.5f + SCREEN_HEIGHT - (HUD_STRETCH_Y(123.0f)) - in->y * (HUD_STRETCH_Y(76.0f)) * 0.5f;
} }


STARTPATCHES STARTPATCHES
@@ -70,11 +70,15 @@ extern void **rwengine;
#define DEFAULT_SCREEN_HEIGHT (448) #define DEFAULT_SCREEN_HEIGHT (448)
#define SCREEN_WIDTH Float(RsGlobal.width) #define SCREEN_WIDTH Float(RsGlobal.width)
#define SCREEN_HEIGHT Float(RsGlobal.height) #define SCREEN_HEIGHT Float(RsGlobal.height)
#define SCREEN_STRETCH_X(a) Float((a) * (SCREEN_WIDTH / Float(DEFAULT_SCREEN_WIDTH))) * Float((1.3333334f) / (SCREEN_ASPECT_RATIO)) #define SCREEN_STRETCH_X(a) Float((a) * (SCREEN_WIDTH / Float(DEFAULT_SCREEN_WIDTH)))
#define SCREEN_STRETCH_X_AR(a) Float((a) * (SCREEN_WIDTH / Float(DEFAULT_SCREEN_WIDTH)) * (4.0/3.0f)/SCREEN_ASPECT_RATIO)
#define SCREEN_STRETCH_Y(a) Float((a) * (SCREEN_HEIGHT / Float(DEFAULT_SCREEN_HEIGHT))) #define SCREEN_STRETCH_Y(a) Float((a) * (SCREEN_HEIGHT / Float(DEFAULT_SCREEN_HEIGHT)))
#define SCREEN_FROM_RIGHT(a) Float(SCREEN_WIDTH - SCREEN_STRETCH_X(a)) #define SCREEN_FROM_RIGHT(a) Float(SCREEN_WIDTH - SCREEN_STRETCH_X(a))
#define SCREEN_FROM_BOTTOM(a) Float(SCREEN_HEIGHT - SCREEN_STRETCH_Y(a)) #define SCREEN_FROM_BOTTOM(a) Float(SCREEN_HEIGHT - SCREEN_STRETCH_Y(a))


#define HUD_STRETCH_X SCREEN_STRETCH_X_AR
#define HUD_STRETCH_Y SCREEN_STRETCH_Y

struct GlobalScene struct GlobalScene
{ {
RpWorld *world; RpWorld *world;
@@ -86,7 +86,6 @@ RwRGBA gColourTop;
void void
Idle(void *arg) Idle(void *arg)
{ {
CDraw::CalculateAspectRatio();
CTimer::Update(); CTimer::Update();
CSprite2d::InitPerFrame(); CSprite2d::InitPerFrame();
CFont::InitPerFrame(); CFont::InitPerFrame();
@@ -141,7 +140,7 @@ Idle(void *arg)
Render2dStuff(); Render2dStuff();
}else{ }else{
float viewWindow = tan(DEGTORAD(CDraw::GetFOV() * 0.5f)); float viewWindow = tan(DEGTORAD(CDraw::GetFOV() * 0.5f));
// ASPECT CDraw::CalculateAspectRatio();
CameraSize(Scene.camera, nil, viewWindow, SCREEN_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);
@@ -162,7 +161,6 @@ Idle(void *arg)
void void
FrontendIdle(void) FrontendIdle(void)
{ {
CDraw::CalculateAspectRatio();
CTimer::Update(); CTimer::Update();
CSprite2d::SetRecipNearClip(); CSprite2d::SetRecipNearClip();
CSprite2d::InitPerFrame(); CSprite2d::InitPerFrame();
@@ -174,7 +172,7 @@ FrontendIdle(void)
return; return;


float viewWindow = tan(DEGTORAD(CDraw::GetFOV() * 0.5f)); float viewWindow = tan(DEGTORAD(CDraw::GetFOV() * 0.5f));
// ASPECT CDraw::CalculateAspectRatio();
CameraSize(Scene.camera, nil, viewWindow, SCREEN_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);
@@ -192,12 +190,11 @@ FrontendIdle(void)
bool bool
DoRWStuffStartOfFrame(int16 TopRed, int16 TopGreen, int16 TopBlue, int16 BottomRed, int16 BottomGreen, int16 BottomBlue, int16 Alpha) DoRWStuffStartOfFrame(int16 TopRed, int16 TopGreen, int16 TopBlue, int16 BottomRed, int16 BottomGreen, int16 BottomBlue, int16 Alpha)
{ {
CDraw::CalculateAspectRatio();
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)); float viewWindow = tan(DEGTORAD(CDraw::GetFOV() * 0.5f));
// ASPECT CDraw::CalculateAspectRatio();
CameraSize(Scene.camera, nil, viewWindow, SCREEN_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);
@@ -216,9 +213,8 @@ 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)
{ {
CDraw::CalculateAspectRatio();
float viewWindow = tan(DEGTORAD(CDraw::GetFOV() * 0.5f)); float viewWindow = tan(DEGTORAD(CDraw::GetFOV() * 0.5f));
// ASPECT CDraw::CalculateAspectRatio();
CameraSize(Scene.camera, nil, viewWindow, SCREEN_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);
@@ -15,16 +15,15 @@ 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 CDraw::CalculateAspectRatio() { void
if (FrontEndMenuManager.m_PrefsUseWideScreen) { CDraw::CalculateAspectRatio()
ms_fAspectRatio = 1.7777778f; {
} if(FrontEndMenuManager.m_PrefsUseWideScreen)
else if (TheCamera.m_WideScreenOn) { ms_fAspectRatio = 16.0f/9.0f;
else if(TheCamera.m_WideScreenOn)
ms_fAspectRatio = 1.25f; ms_fAspectRatio = 1.25f;
} else
else { ms_fAspectRatio = 4.0f/3.0f;
ms_fAspectRatio = 1.3333334f;
}
} }


static float hFov2vFov(float hfov) static float hFov2vFov(float hfov)

0 comments on commit 2a207af

Please sign in to comment.