Skip to content

Commit

Permalink
Fixed a bug where pickup sprites were cropped by the floor if Z-Buffe…
Browse files Browse the repository at this point in the history
…r is enabled.
  • Loading branch information
Arsunt committed Aug 1, 2020
1 parent cb0b2ec commit f749a67
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 1 deletion.
16 changes: 16 additions & 0 deletions 3dsystem/scalespr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
extern int CalculateFogShade(int depth);
#endif // FEATURE_VIEW_IMPROVED

#ifdef FEATURE_VIDEOFX_IMPROVED
DWORD PickupItemMode = 1;
#endif // FEATURE_VIDEOFX_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;
int x1, y1, x2, y2;
Expand Down Expand Up @@ -70,6 +74,18 @@ void __cdecl S_DrawSprite(DWORD flags, int x, int y, int z, __int16 spriteIdx, _
x2 = PhdSpriteInfo[spriteIdx].x2;
y2 = PhdSpriteInfo[spriteIdx].y2;

#ifdef FEATURE_VIDEOFX_IMPROVED
if( PickupItemMode == 1 && CHK_ALL(flags, SPR_ITEM|SPR_ABS) ) {
if( y1 < y2 ) {
y1 -= y2;
y2 = 0;
} else {
y2 -= y1;
y1 = 0;
}
}
#endif // FEATURE_VIDEOFX_IMPROVED

if( CHK_ANY(flags, SPR_SCALE) ) { // scaling required
x1 = (x1 * scale) << (W2V_SHIFT - 8);
y1 = (y1 * scale) << (W2V_SHIFT - 8);
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed a rare game crash occurring when you explode an enemy with a grenade launcher.
- Fixed incorrect sorting of 3D polygons if Z-Buffer is turned off or the software renderer is used.
- Fixed a bug due to which the skybox was not drawn in some rooms.
- Fixed a bug where pickup sprites were cropped by the floor if Z-Buffer is enabled. Some pickup items are slightly raised (optional fix).

### TR2Main bugfixes
- Background capture is optimized even more, now it is 3-4 times faster than v0.8.2. No lags anymore (broken since v0.8.0).
Expand Down
3 changes: 2 additions & 1 deletion game/draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,8 @@ void __cdecl DrawSpriteItem(ITEM_INFO *item) {

obj = &Objects[item->objectID];

S_DrawSprite(SPR_ABS | SPR_SHADE | (obj->semi_transparent ? SPR_SEMITRANS : 0),
// NOTE: SPR_ITEM is not presented in the original game
S_DrawSprite(SPR_ITEM | SPR_ABS | SPR_SHADE | (obj->semi_transparent ? SPR_SEMITRANS : 0),
item->pos.x, item->pos.y, item->pos.z,
obj->meshIndex - item->frameNumber,
LsAdder + 0x1000, 0);
Expand Down
1 change: 1 addition & 0 deletions global/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ typedef struct {
#define SPR_BLEND_SUB (0x40000000)
#define SPR_BLEND_QRT (SPR_BLEND_ADD|SPR_BLEND_SUB)
#define SPR_BLEND (SPR_BLEND_QRT)
#define SPR_ITEM (0x80000000)

// Item flags
#define IFL_INVISIBLE (0x0100)
Expand Down
1 change: 1 addition & 0 deletions specific/registry.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
#define REG_ALPHABLEND_MODE "AlphaBlendMode"
#define REG_INVTEXTBOX_MODE "InvTextBoxMode"
#define REG_HEALTHBAR_MODE "HealthBarMode"
#define REG_PICKUPITEM_MODE "PickupItemMode"
#define REG_SCREENSHOT_FORMAT "ScreenshotFormat"

// BOOL value names
Expand Down
2 changes: 2 additions & 0 deletions specific/smain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ extern DWORD ShadowMode;
extern DWORD AlphaBlendMode;
extern DWORD ReflectionMode;
extern DWORD ReflectionBlur;
extern DWORD PickupItemMode;
extern bool CustomWaterColorEnabled;
#endif // FEATURE_VIDEOFX_IMPROVED

Expand Down Expand Up @@ -551,6 +552,7 @@ void __cdecl S_LoadSettings() {
GetRegistryDwordValue(REG_ALPHABLEND_MODE, &AlphaBlendMode, 0);
GetRegistryDwordValue(REG_REFLECTION_MODE, &ReflectionMode, 0);
GetRegistryDwordValue(REG_REFLECTION_BLUR, &ReflectionBlur, 2);
GetRegistryDwordValue(REG_PICKUPITEM_MODE, &PickupItemMode, 1);
GetRegistryBoolValue(REG_CUSTOM_WATER_COLOR, &CustomWaterColorEnabled, false);
CLAMPG(AlphaBlendMode, 2);
CLAMPG(ReflectionMode, 2);
Expand Down

0 comments on commit f749a67

Please sign in to comment.