From cb0b2ec7662c9de1e1c2e81dc2d9cf68956241a0 Mon Sep 17 00:00:00 2001 From: Michael Chaban Date: Sat, 1 Aug 2020 15:41:43 +0300 Subject: [PATCH] Revert "Hybrid Sorted Z-Buffered mode" This reverts commits - 464e654f2e806f077d7642949deb9e1ab57dbe2d - f7ffd9f6573ce509c3c8796f45496faf7f2bcfd1 - 7d1e37082bfa205ed43d883fa859da90b6d1bf71 - 497bb9d4011d8bda007383137a5dd9ddb00ca4f0 --- 3dsystem/3d_gen.cpp | 30 +++++------------------------- 3dsystem/3dinsert.cpp | 12 ++---------- CHANGELOG.md | 2 -- global/types.h | 4 ---- specific/hwr.cpp | 42 ------------------------------------------ specific/hwr.h | 4 ---- specific/output.cpp | 25 ++----------------------- 7 files changed, 9 insertions(+), 110 deletions(-) diff --git a/3dsystem/3d_gen.cpp b/3dsystem/3d_gen.cpp index 8a1353d..0594e27 100644 --- a/3dsystem/3d_gen.cpp +++ b/3dsystem/3d_gen.cpp @@ -587,25 +587,10 @@ void __cdecl S_InsertBackground(__int16 *ptrObj) { if( SavedAppSettings.RenderMode == RM_Hardware ) { HWR_EnableZBuffer(false, false); } -#ifdef FEATURE_VIDEOFX_IMPROVED - if( SavedAppSettings.RenderMode == RM_Hardware - && SavedAppSettings.ZBuffer - && !SavedAppSettings.DontSortPrimitives ) - { - // NOTE: just draw background unsorted right now with ZBuffer disabled - ptrObj = InsertObjectGT4_ZBuffered(ptrObj+1, *ptrObj, ST_FarZ); - ptrObj = InsertObjectGT3_ZBuffered(ptrObj+1, *ptrObj, ST_FarZ); - ptrObj = InsertObjectG4_ZBuffered(ptrObj+1, *ptrObj, ST_FarZ); - ptrObj = InsertObjectG3_ZBuffered(ptrObj+1, *ptrObj, ST_FarZ); - } - else -#endif // FEATURE_VIDEOFX_IMPROVED - { - ptrObj = ins_objectGT4(ptrObj+1, *ptrObj, ST_FarZ); - ptrObj = ins_objectGT3(ptrObj+1, *ptrObj, ST_FarZ); - ptrObj = ins_objectG4(ptrObj+1, *ptrObj, ST_FarZ); - ptrObj = ins_objectG3(ptrObj+1, *ptrObj, ST_FarZ); - } + ptrObj = ins_objectGT4(ptrObj+1, *ptrObj, ST_FarZ); + ptrObj = ins_objectGT3(ptrObj+1, *ptrObj, ST_FarZ); + ptrObj = ins_objectG4(ptrObj+1, *ptrObj, ST_FarZ); + ptrObj = ins_objectG3(ptrObj+1, *ptrObj, ST_FarZ); if( SavedAppSettings.RenderMode == RM_Hardware ) { HWR_EnableZBuffer(true, true); } @@ -1022,12 +1007,7 @@ void __cdecl phd_InitWindow(__int16 x, __int16 y, int width, int height, int nea ins_trans_quad = InsertTransQuad; } else if( SavedAppSettings.RenderMode == RM_Hardware ) { -#ifdef FEATURE_VIDEOFX_IMPROVED - if( SavedAppSettings.ZBuffer && SavedAppSettings.DontSortPrimitives ) -#else // !FEATURE_VIDEOFX_IMPROVED - if( SavedAppSettings.ZBuffer ) -#endif // !FEATURE_VIDEOFX_IMPROVED - { + if( SavedAppSettings.ZBuffer ) { ins_objectGT3 = InsertObjectGT3_ZBuffered; ins_objectGT4 = InsertObjectGT4_ZBuffered; ins_objectG3 = InsertObjectG3_ZBuffered; diff --git a/3dsystem/3dinsert.cpp b/3dsystem/3dinsert.cpp index a66f423..034ab5f 100644 --- a/3dsystem/3dinsert.cpp +++ b/3dsystem/3dinsert.cpp @@ -99,14 +99,6 @@ static double CalculatePolyZ(SORTTYPE sortType, double z0, double z1, double z2, CLAMPL(zv, z1); CLAMPL(zv, z2); if( z3 > 0.0 ) CLAMPL(zv, z3); -#ifdef FEATURE_VIDEOFX_IMPROVED - if( SavedAppSettings.RenderMode == RM_Hardware - && SavedAppSettings.ZBuffer - && !SavedAppSettings.DontSortPrimitives ) - { - zv = ( z3 > 0.0 ) ? (zv*4.0 + z0+z1+z2+z3)/8.0 : (zv*3.0 + z0+z1+z2)/6.0; - } -#endif // FEATURE_VIDEOFX_IMPROVED break; case ST_FarZ : @@ -2471,7 +2463,7 @@ void __cdecl InsertSprite_Sorted(int z, int x0, int y0, int x1, int y1, int spri bool isShadeEffectBackup = IsShadeEffect; IsShadeEffect = false; #ifdef FEATURE_VIDEOFX_IMPROVED - short polyType = POLY_Z_IGNORE | POLY_HWR_WGTmap; + short polyType = POLY_HWR_WGTmap; if( CHK_ANY(flags, SPR_TINT) ) { GlobalTint = RGBA_SETALPHA(flags, 0xFF); } @@ -2482,7 +2474,7 @@ void __cdecl InsertSprite_Sorted(int z, int x0, int y0, int x1, int y1, int spri POLY_HWR_WGTmapSub, POLY_HWR_WGTmapQrt, }; - polyType = POLY_Z_IGNORE | blend[(flags & SPR_BLEND) >> 29]; + polyType = blend[(flags & SPR_BLEND) >> 29]; } InsertClippedPoly_Textured(nPoints, (float)z, polyType, PhdSpriteInfo[spriteIdx].texPage); GlobalTint = 0; diff --git a/CHANGELOG.md b/CHANGELOG.md index 3123dea..93af0a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,8 +47,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added Dozy cheat on *O* key (cheat flag in *"TOMBPC.DAT"* file required). It gives fly mode and full health, use *Shift* key to disable it. - Lara has golden skin while in Dozy mode (hardware renderer and reflection feature required). - SFX number limit increased from 256 to 370. -- Z-Buffered mode is improved. Now every polygon is sorted and Z-Buffered, but sprites ignore Z-Buffer, so they're rendered properly, as if Z-Buffer was disabled. -- The "Don't sort transparent polys"* setting from the *"Advanced"* tab has been redesigned to disable the new Z-Buffered mode, instead of just messing the transparent polys (it is recommended to keep this setting unchecked anyway). - Added automatic cdaudio.dat fix for PaulD's CD Audio solution, if some track has wrong parameters (like in the Steam version). ### The original game bugfixes diff --git a/global/types.h b/global/types.h index a22ee45..3b076b6 100644 --- a/global/types.h +++ b/global/types.h @@ -230,10 +230,6 @@ typedef struct { #define IFL_REVERSE (0x4000) #define IFL_CLEARBODY (0x8000) -// HWR poly sort flags -#define POLY_TYPEMASK (0x7FFF) -#define POLY_Z_IGNORE (0x8000) - // Glow tint colors #define GLOW_FLARE_COLOR (0xFF8080) // Flare #define GLOW_PISTOL_COLOR (0x3F380F) // Pistol/Magnums/Uzi gunfire diff --git a/specific/hwr.cpp b/specific/hwr.cpp index 406dfa2..d700d3b 100644 --- a/specific/hwr.cpp +++ b/specific/hwr.cpp @@ -224,11 +224,7 @@ void __cdecl HWR_BeginScene() { D3DDev->BeginScene(); } -#ifdef FEATURE_VIDEOFX_IMPROVED -void __cdecl HWR_DrawPolyList(int pass) { -#else // FEATURE_VIDEOFX_IMPROVED void __cdecl HWR_DrawPolyList() { -#endif // FEATURE_VIDEOFX_IMPROVED DWORD alphaState; UINT16 *bufPtr; UINT16 polyType, texPage, vtxCount; @@ -239,44 +235,6 @@ void __cdecl HWR_DrawPolyList() { bufPtr = (UINT16 *)SortBuffer[i]._0; polyType = *(bufPtr++); -#ifdef FEATURE_VIDEOFX_IMPROVED - if( pass == 1 || pass == 2 ) { - bool zCheck = !CHK_ANY(polyType, POLY_Z_IGNORE); - bool zWrite = false; - bool noBlend = false; - switch( polyType & POLY_TYPEMASK ) { - case POLY_HWR_GTmap: - case POLY_HWR_gouraud: - case POLY_HWR_line: -#ifdef FEATURE_HUD_IMPROVED - case POLY_HWR_healthbar: - case POLY_HWR_airbar: -#endif // FEATURE_HUD_IMPROVED - zWrite = true; - noBlend = true; - break; - case POLY_HWR_WGTmap: - zWrite = false; - noBlend = true; - break; - } - // NOTE: noBlend sprites and zWrite polys are drawn in 1st pass. - // Same sprites are rendered one more time in 2nd pass, but with all other polys. - if( pass == 1 ) { - bool conditon = noBlend && (zWrite || !zCheck); - if( !conditon ) { - continue; // for other polys we need 2nd pass - } - } else { - if( zWrite ) { - continue; // we've drawn all zWrite polys in 1st pass - } - zCheck = true; // zCheck is always enabled for 2nd pass - } - HWR_EnableZBuffer(zWrite, zCheck); - } - polyType &= POLY_TYPEMASK; -#endif // FEATURE_VIDEOFX_IMPROVED #ifdef FEATURE_HUD_IMPROVED if( polyType == POLY_HWR_healthbar || polyType == POLY_HWR_airbar ) { UINT16 x0 = *(bufPtr++); diff --git a/specific/hwr.h b/specific/hwr.h index 917431d..b3f86e2 100644 --- a/specific/hwr.h +++ b/specific/hwr.h @@ -35,11 +35,7 @@ void __cdecl HWR_TexSource(HWR_TEXHANDLE texSource); // 0x0044D2A0 void __cdecl HWR_EnableColorKey(bool state); // 0x0044D2D0 void __cdecl HWR_EnableZBuffer(bool ZWriteEnable, bool ZEnable); // 0x0044D320 void __cdecl HWR_BeginScene(); // 0x0044D3B0 -#ifdef FEATURE_VIDEOFX_IMPROVED -void __cdecl HWR_DrawPolyList(int pass); // 0x0044D3E0 -#else // FEATURE_VIDEOFX_IMPROVED void __cdecl HWR_DrawPolyList(); // 0x0044D3E0 -#endif // FEATURE_VIDEOFX_IMPROVED void __cdecl HWR_LoadTexturePages(int pagesCount, LPVOID pagesBuffer, RGB888 *palette); // 0x0044D560 void __cdecl HWR_FreeTexturePages(); // 0x0044D5F0 void __cdecl HWR_GetPageHandles(); // 0x0044D640 diff --git a/specific/output.cpp b/specific/output.cpp index f38cf7f..9a25e1f 100644 --- a/specific/output.cpp +++ b/specific/output.cpp @@ -191,21 +191,10 @@ void __cdecl S_OutputPolyList() { } } else { // Hardware renderer -#ifdef FEATURE_VIDEOFX_IMPROVED - // NOTE: DontSortPrimitives option is redesigned to affect opaque only polygons - phd_SortPolyList(); - if( SavedAppSettings.ZBuffer && !SavedAppSettings.DontSortPrimitives ) { - HWR_DrawPolyList(1); - HWR_DrawPolyList(2); - } else { - HWR_DrawPolyList(0); - } -#else // !FEATURE_VIDEOFX_IMPROVED if( !SavedAppSettings.ZBuffer || !SavedAppSettings.DontSortPrimitives ) { phd_SortPolyList(); } HWR_DrawPolyList(); -#endif // !FEATURE_VIDEOFX_IMPROVED D3DDev->EndScene(); } } @@ -629,12 +618,7 @@ void __cdecl S_DrawHealthBar(int percent) { IsShadeEffect = false; if( HealthBarMode != 0 && SavedAppSettings.RenderMode == RM_Hardware ) { -#ifdef FEATURE_VIDEOFX_IMPROVED - if( SavedAppSettings.ZBuffer && SavedAppSettings.DontSortPrimitives ) -#else // FEATURE_VIDEOFX_IMPROVED - if( SavedAppSettings.ZBuffer ) -#endif // FEATURE_VIDEOFX_IMPROVED - { + if( SavedAppSettings.ZBuffer ) { PSX_DrawHealthBar(x0, y0, x1, y1, bar, pixel); } else { PSX_InsertHealthBar(x0, y0, x1, y1, bar, pixel); @@ -707,12 +691,7 @@ void __cdecl S_DrawAirBar(int percent) { IsShadeEffect = false; if( HealthBarMode != 0 && SavedAppSettings.RenderMode == RM_Hardware ) { -#ifdef FEATURE_VIDEOFX_IMPROVED - if( SavedAppSettings.ZBuffer && SavedAppSettings.DontSortPrimitives ) -#else // FEATURE_VIDEOFX_IMPROVED - if( SavedAppSettings.ZBuffer ) -#endif // FEATURE_VIDEOFX_IMPROVED - { + if( SavedAppSettings.ZBuffer ) { PSX_DrawAirBar(x0, y0, x1, y1, bar, pixel); } else { PSX_InsertAirBar(x0, y0, x1, y1, bar, pixel);