Skip to content

Commit

Permalink
rearranged FEATURE defines
Browse files Browse the repository at this point in the history
  • Loading branch information
Arsunt committed Sep 24, 2018
1 parent cbac739 commit 8d10d45
Show file tree
Hide file tree
Showing 12 changed files with 107 additions and 122 deletions.
36 changes: 17 additions & 19 deletions 3dsystem/3d_gen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@
#include "specific/hwr.h"
#include "global/vars.h"

#ifdef FEATURE_FOV_FIX
bool PsxFovEnabled;
#endif // FEATURE_FOV_FIX

// related to POLYTYPE enum
static void (__cdecl *PolyDrawRoutines[])(__int16 *) = {
draw_poly_gtmap, // gouraud shaded poly (texture)
Expand All @@ -45,7 +41,9 @@ static void (__cdecl *PolyDrawRoutines[])(__int16 *) = {
draw_scaled_spriteC // scaled sprite (texture + colorkey)
};

#ifdef FEATURE_FOG_DISTANCE
#ifdef FEATURE_VIEW_IMPROVED
bool PsxFovEnabled;

// view distance
double ViewDistanceFactor = 1.0;

Expand Down Expand Up @@ -80,7 +78,7 @@ int CalculateFogShade(int depth) {

return (depth - fogBegin) * 0x1FFF / (fogEnd - fogBegin);
}
#endif // FEATURE_FOG_DISTANCE
#endif // FEATURE_VIEW_IMPROVED

void phd_GenerateW2V(PHD_3DPOS *viewPos) {
int sx = phd_sin(viewPos->rotX);
Expand Down Expand Up @@ -572,23 +570,23 @@ __int16 *__cdecl calc_roomvert(__int16 *ptrObj, BYTE farClip) {
persp = FltPersp / zv;
depth = zv_int >> W2V_SHIFT;

#ifdef FEATURE_FOG_DISTANCE
#ifdef FEATURE_VIEW_IMPROVED
if( depth >= PhdViewDistance ) {
#else // !FEATURE_FOG_DISTANCE
#else // !FEATURE_VIEW_IMPROVED
if( depth >= DEPTHQ_END ) { // fog end
#endif // FEATURE_FOG_DISTANCE
#endif // FEATURE_VIEW_IMPROVED
PhdVBuf[i].g = 0x1FFF;
PhdVBuf[i].rhw = 0.0;
PhdVBuf[i].clip = farClip;
PhdVBuf[i].zv = FltFarZ;
} else {
#ifdef FEATURE_FOG_DISTANCE
#ifdef FEATURE_VIEW_IMPROVED
PhdVBuf[i].g += CalculateFogShade(depth);
#else // !FEATURE_FOG_DISTANCE
#else // !FEATURE_VIEW_IMPROVED
if( depth > DEPTHQ_START ) { // fog begin
PhdVBuf[i].g += depth - DEPTHQ_START;
}
#endif // FEATURE_FOG_DISTANCE
#endif // FEATURE_VIEW_IMPROVED
PhdVBuf[i].rhw = persp * FltRhwOPersp;
PhdVBuf[i].clip = 0;
PhdVBuf[i].zv = zv + baseZ;
Expand Down Expand Up @@ -694,25 +692,25 @@ void __cdecl phd_PrintPolyList(BYTE *surfacePtr) {
void __cdecl AlterFOV(__int16 fov) {
fov /= 2; // half fov angle

#ifdef FEATURE_FOV_FIX
#ifdef FEATURE_VIEW_IMPROVED
int fovWidth = PhdWinHeight*320/(PsxFovEnabled ? 200 : 240);
FltViewAspect = 1.0; // must always be 1.0 for unstretched view
PhdPersp = (fovWidth / 2) * phd_cos(fov) / phd_sin(fov);
#else // !FEATURE_FOV_FIX
#else // !FEATURE_VIEW_IMPROVED
PhdPersp = (PhdWinWidth / 2) * phd_cos(fov) / phd_sin(fov);
#endif // FEATURE_FOV_FIX
#endif // FEATURE_VIEW_IMPROVED

FltPersp = (float)PhdPersp;
FltRhwOPersp = RhwFactor / FltPersp;
FltPerspONearZ = FltPersp / FltNearZ;

#ifndef FEATURE_FOV_FIX // if feature is not defined!!!
#ifndef FEATURE_VIEW_IMPROVED // if feature is not defined!!!
double windowAspect = 4.0 / 3.0;
if( !SavedAppSettings.FullScreen && SavedAppSettings.AspectMode == AM_16_9 ) {
windowAspect = 16.0 / 9.0;
}
FltViewAspect = windowAspect / ((double)PhdWinWidth / (double)PhdWinHeight);
#endif // !FEATURE_FOV_FIX
#endif // !FEATURE_VIEW_IMPROVED
}

void __cdecl phd_SetNearZ(int nearZ) {
Expand Down Expand Up @@ -767,14 +765,14 @@ void __cdecl phd_InitWindow(__int16 x, __int16 y, int width, int height, int nea
PhdScreenWidth = screenWidth;
PhdScreenHeight = screenHeight;

#ifdef FEATURE_FOG_DISTANCE
#ifdef FEATURE_VIEW_IMPROVED
double baseDistance = (double)farZ;
farZ = (int)(baseDistance * ViewDistanceFactor);
FogBeginDepth = (int)(baseDistance * FogBeginFactor);
FogEndDepth = (int)(baseDistance * FogEndFactor);
WaterFogBeginDepth = (int)(baseDistance * WaterFogBeginFactor);
WaterFogEndDepth = (int)(baseDistance * WaterFogEndFactor);
#endif // FEATURE_FOG_DISTANCE
#endif // FEATURE_VIEW_IMPROVED

PhdNearZ = nearZ << W2V_SHIFT;
PhdFarZ = farZ << W2V_SHIFT;
Expand Down
14 changes: 7 additions & 7 deletions 3dsystem/scalespr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
#include "specific/output.h"
#include "global/vars.h"

#ifdef FEATURE_FOG_DISTANCE
#ifdef FEATURE_VIEW_IMPROVED
extern int CalculateFogShade(int depth);
#endif // FEATURE_FOG_DISTANCE
#endif // FEATURE_VIEW_IMPROVED

void __cdecl S_DrawSprite(DWORD flags, int x, int y, int z, __int16 spriteIdx, __int16 shade, __int16 scale) {
int xv, yv, zv, zp, depth;
Expand Down Expand Up @@ -102,20 +102,20 @@ void __cdecl S_DrawSprite(DWORD flags, int x, int y, int z, __int16 spriteIdx, _

if( CHK_ANY(flags, SPR_SHADE) ) { // shading required
depth = zv >> W2V_SHIFT;
#ifdef FEATURE_FOG_DISTANCE
#ifdef FEATURE_VIEW_IMPROVED
if( depth > PhdViewDistance )
return;

shade += CalculateFogShade(depth);
CLAMP(shade, 0, 0x1FFF);
#else // !FEATURE_FOG_DISTANCE
#else // !FEATURE_VIEW_IMPROVED
if( depth > DEPTHQ_START ) {
shade += depth - DEPTHQ_START;
if( shade > 0x1FFF ) {
return;
}
}
#endif // FEATURE_FOG_DISTANCE
#endif // FEATURE_VIEW_IMPROVED
} else {
shade = 0x1000;
}
Expand All @@ -126,9 +126,9 @@ void __cdecl S_DrawSprite(DWORD flags, int x, int y, int z, __int16 spriteIdx, _
void __cdecl S_DrawPickup(int sx, int sy, int scale, __int16 spriteIdx, __int16 shade) {
int x1, x2, y1, y2;

#ifdef FEATURE_SPRITE_SCALE_FIX
#ifdef FEATURE_HUD_IMPROVED
scale = GetRenderScale(scale);
#endif
#endif // FEATURE_HUD_IMPROVED

x1 = sx + (PhdSpriteInfo[spriteIdx].x1 * scale / PHD_ONE);
x2 = sx + (PhdSpriteInfo[spriteIdx].x2 * scale / PHD_ONE);
Expand Down
40 changes: 20 additions & 20 deletions game/health.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
#define AMMO_XPOS_PS (-16)
#define AMMO_YPOS_PS (64)

#ifdef FEATURE_HEALTHBAR_IMPROVED
#ifdef FEATURE_HUD_IMPROVED
extern bool PsxBarPosEnabled;
#endif // FEATURE_HEALTHBAR_IMPROVED
#endif // FEATURE_HUD_IMPROVED

BOOL __cdecl FlashIt() {
static int counter = 0;
Expand Down Expand Up @@ -65,23 +65,23 @@ void __cdecl DrawAssaultTimer() {
minutes = SaveGame.statistics.timer / 30 / 60;
sprintf(timeString, "%d:%02d.%d", minutes, seconds, deciseconds);

#ifdef FEATURE_FOV_FIX
#ifdef FEATURE_HUD_IMPROVED
scaleH = GetRenderScale(PHD_ONE);
scaleV = GetRenderScale(PHD_ONE);
xPos = PhdWinMaxX / 2 - GetRenderScale(50);
yPos = GetRenderScale(36);
d0 = GetRenderScale(20);
d1 = GetRenderScale(-6);
d2 = GetRenderScale(14);
#else // !FEATURE_FOV_FIX
#else // !FEATURE_HUD_IMPROVED
scaleH = PHD_ONE;
scaleV = PHD_ONE;
xPos = PhdWinMaxX / 2 - 50;
yPos = 36;
d0 = 20;
d1 = -6;
d2 = 14;
#endif // FEATURE_FOV_FIX
#endif // FEATURE_HUD_IMPROVED

for( char *str = timeString; *str != 0; ++str ) {
switch( *str ) {
Expand Down Expand Up @@ -143,19 +143,19 @@ void __cdecl DrawHealthBar(BOOL flashState) {
if( flashState == 0 ) {
S_DrawHealthBar(0);
} else {
#ifdef FEATURE_HEALTHBAR_IMPROVED
#ifdef FEATURE_HUD_IMPROVED
S_DrawHealthBar(PHD_ONE * hitPoints / 1000);
#else // !FEATURE_HEALTHBAR_IMPROVED
#else // !FEATURE_HUD_IMPROVED
S_DrawHealthBar(hitPoints / 10);
#endif // FEATURE_HEALTHBAR_IMPROVED
#endif // FEATURE_HUD_IMPROVED
}
}
else if( HealthBarTimer > 0 || hitPoints <= 0 || Lara_GunStatus == LGS_Ready ) {
#ifdef FEATURE_HEALTHBAR_IMPROVED
#ifdef FEATURE_HUD_IMPROVED
S_DrawHealthBar(PHD_ONE * hitPoints / 1000);
#else // !FEATURE_HEALTHBAR_IMPROVED
#else // !FEATURE_HUD_IMPROVED
S_DrawHealthBar(hitPoints / 10);
#endif // FEATURE_HEALTHBAR_IMPROVED
#endif // FEATURE_HUD_IMPROVED
}
}

Expand All @@ -171,11 +171,11 @@ void __cdecl DrawAirBar(BOOL flashState) {
if( air <= 450 && flashState == 0 ) {
S_DrawAirBar(0);
} else {
#ifdef FEATURE_HEALTHBAR_IMPROVED
#ifdef FEATURE_HUD_IMPROVED
S_DrawAirBar(PHD_ONE * air / 1800);
#else // !FEATURE_HEALTHBAR_IMPROVED
#else // !FEATURE_HUD_IMPROVED
S_DrawAirBar(100 * air / 1800);
#endif // FEATURE_HEALTHBAR_IMPROVED
#endif // FEATURE_HUD_IMPROVED
}
}

Expand Down Expand Up @@ -235,15 +235,15 @@ void __cdecl DrawAmmoInfo() {
MakeAmmoString(ammoString);

if( AmmoTextInfo == NULL ) {
#ifdef FEATURE_HEALTHBAR_IMPROVED
#ifdef FEATURE_HUD_IMPROVED
if( PsxBarPosEnabled ) {
AmmoTextInfo = T_Print(AMMO_XPOS_PS, AMMO_YPOS_PS, 0, ammoString);
} else {
AmmoTextInfo = T_Print(AMMO_XPOS_PC, AMMO_YPOS_PC, 0, ammoString);
}
#else // !FEATURE_HEALTHBAR_IMPROVED
#else // !FEATURE_HUD_IMPROVED
AmmoTextInfo = T_Print(AMMO_XPOS_PC, AMMO_YPOS_PC, 0, ammoString);
#endif // FEATURE_HEALTHBAR_IMPROVED
#endif // FEATURE_HUD_IMPROVED
T_RightAlign(AmmoTextInfo, 1);
} else {
T_ChangeText(AmmoTextInfo, ammoString);
Expand All @@ -262,11 +262,11 @@ void __cdecl DrawPickups(BOOL pickupState) {
if( time <= 0 || time >= 60 ) // 0..2 seconds
return;

#ifdef FEATURE_FOV_FIX
#ifdef FEATURE_HUD_IMPROVED
cellH = MIN(PhdWinWidth, PhdWinHeight*320/200) / 10;
#else // !FEATURE_FOV_FIX
#else // !FEATURE_HUD_IMPROVED
cellH = PhdWinWidth / 10;
#endif // FEATURE_FOV_FIX
#endif // FEATURE_HUD_IMPROVED
cellV = cellH * 2 / 3;

x = PhdWinWidth - cellH;
Expand Down
18 changes: 9 additions & 9 deletions game/invtext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,13 @@ void __cdecl Init_Requester(REQUEST_INFO *req) {

req->lpItemFlags1 = RequesterItemFlags1;
req->lpItemFlags2 = RequesterItemFlags2;
#ifdef FEATURE_FOV_FIX
#ifdef FEATURE_HUD_IMPROVED
req->renderWidth = GetRenderWidthDownscaled();
req->renderHeight = GetRenderHeightDownscaled();
#else // !FEATURE_FOV_FIX
#else // !FEATURE_HUD_IMPROVED
req->renderWidth = GetRenderWidth();
req->renderHeight = GetRenderHeight();
#endif // FEATURE_FOV_FIX
#endif // FEATURE_HUD_IMPROVED
}

void __cdecl Remove_Requester(REQUEST_INFO *req) {
Expand Down Expand Up @@ -171,13 +171,13 @@ int __cdecl Display_Requester(REQUEST_INFO *req, BOOL removeOnDeselect, BOOL isB
linesHeight = req->lineHeight * linesCount + 10;
linesOff = req->yPos - linesHeight;

#ifdef FEATURE_FOV_FIX
#ifdef FEATURE_HUD_IMPROVED
renderWidth = GetRenderWidthDownscaled();
renderHeight = GetRenderHeightDownscaled();
#else // !FEATURE_FOV_FIX
#else // !FEATURE_HUD_IMPROVED
renderWidth = GetRenderWidth();
renderHeight = GetRenderHeight();
#endif // FEATURE_FOV_FIX
#endif // FEATURE_HUD_IMPROVED

if( renderWidth != req->renderWidth || renderHeight != req->renderHeight ) {
Remove_Requester(req);
Expand Down Expand Up @@ -485,11 +485,11 @@ void __cdecl AddRequesterItem(REQUEST_INFO *req, const char *string1, DWORD flag

void __cdecl SetPCRequesterSize(REQUEST_INFO *req, int maxLines, __int16 yPos) {
req->yPos = yPos;
#ifdef FEATURE_FOV_FIX
#ifdef FEATURE_HUD_IMPROVED
req->visibleCount = GetRenderHeightDownscaled() / 2 / REQ_LN_HEIGHT;
#else // !FEATURE_FOV_FIX
#else // !FEATURE_HUD_IMPROVED
req->visibleCount = GetRenderHeight() / 2 / REQ_LN_HEIGHT;
#endif // FEATURE_FOV_FIX
#endif // FEATURE_HUD_IMPROVED
if( req->visibleCount > maxLines )
req->visibleCount = maxLines;
}
Expand Down
18 changes: 9 additions & 9 deletions game/text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,15 +251,15 @@ void __cdecl T_DrawTextBox(int sx, int sy, int z, int width, int height) {
int scaleH, scaleV;
int meshIdx = Objects[ID_TEXT_BOX].meshIndex;

#ifdef FEATURE_FOV_FIX
#ifdef FEATURE_HUD_IMPROVED
offset = GetRenderScale(4);
scaleH = GetRenderScale(PHD_ONE);
scaleV = GetRenderScale(PHD_ONE);
#else // !FEATURE_FOV_FIX
#else // !FEATURE_HUD_IMPROVED
offset = 4;
scaleH = PHD_ONE;
scaleV = PHD_ONE;
#endif // FEATURE_FOV_FIX
#endif // FEATURE_HUD_IMPROVED

x0 = sx + offset;
y0 = sy + offset;
Expand Down Expand Up @@ -493,31 +493,31 @@ void __cdecl T_DrawThisText(TEXT_STR_INFO *textInfo) {
}

DWORD __cdecl GetTextScaleH(DWORD baseScale) {
#ifdef FEATURE_FOV_FIX
#ifdef FEATURE_HUD_IMPROVED
return GetRenderScale(baseScale);
#else // !FEATURE_FOV_FIX
#else // !FEATURE_HUD_IMPROVED
DWORD renderWidth, renderScale;

renderWidth = GetRenderWidth();
CLAMPL(renderWidth, 640)

renderScale = renderWidth * PHD_ONE / 640;
return (baseScale / PHD_HALF) * (renderScale / PHD_HALF);
#endif // FEATURE_FOV_FIX
#endif // FEATURE_HUD_IMPROVED
}

DWORD __cdecl GetTextScaleV(DWORD baseScale) {
#ifdef FEATURE_FOV_FIX
#ifdef FEATURE_HUD_IMPROVED
return GetRenderScale(baseScale);
#else // !FEATURE_FOV_FIX
#else // !FEATURE_HUD_IMPROVED
DWORD renderHeight, renderScale;

renderHeight = GetRenderHeight();
CLAMPL(renderHeight, 480)

renderScale = renderHeight * PHD_ONE / 480;
return (baseScale / PHD_HALF) * (renderScale / PHD_HALF);
#endif // FEATURE_FOV_FIX
#endif // FEATURE_HUD_IMPROVED
}

/*
Expand Down
7 changes: 2 additions & 5 deletions global/features.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,14 @@

#define FEATURE_ASSAULT_SAVE
#define FEATURE_BACKGROUND_IMPROVED
#define FEATURE_FOG_DISTANCE
#define FEATURE_FOV_FIX
#define FEATURE_HEALTHBAR_IMPROVED
#define FEATURE_HUD_IMPROVED
#define FEATURE_JUMP_COLLISION_FIX
#define FEATURE_NOCD_DATA
#define FEATURE_PAULD_CDAUDIO
#define FEATURE_SCREENSHOT_IMPROVED
#define FEATURE_SCREENSHOT_KEY
#define FEATURE_SHADOW_IMPROVED
#define FEATURE_SPRITE_SCALE_FIX
#define FEATURE_VIDMODESORT
#define FEATURE_VIEW_IMPROVED
#define FEATURE_WINDOW_STYLE_FIX

#endif // FEATURES_H_INCLUDED
Loading

0 comments on commit 8d10d45

Please sign in to comment.