ref: 3cdb969ceda035309253a017f5448f3ae0eb463b
parent: 38d26187f451951c9562d32c3c06aa72e6456c28
author: Tanguy Fautre <[email protected]>
date: Sun May 3 11:16:17 EDT 2020
Fix ghost pixels in status bar (e.g. ammount count) at certain resolutions.
--- a/Engine/src/fixedPoint_math.h
+++ b/Engine/src/fixedPoint_math.h
@@ -59,7 +59,24 @@
}
static inline int scale (int32_t input1, int32_t input2, int32_t input3)
{
- return (int)(mul32_64(input1,input2)/(int64_t)input3);
+ return (int)(mul32_64(input1,input2) /(int64_t)input3);
+}
+static inline int scaleup(int32_t input1, int32_t input2, int32_t input3)
+{
+ // tanguyf: 2020-05-03: when patchstatusbar() is called, it can sometimes not clear the entire area,
+ // leaving ghost pixels from the previous frame at certain resolutions (e.g. ammo counter leaving the bottom part of the previous
+ // digits).
+ //
+ // This does not append when the Y resolution is a multiple of 200 (from 320x200) and therefore the division has no remainder.
+ // Although not all non-multiple-of-200 resolutions seem to exhibit the problem.
+ //
+ // I believe this is caused by division round-down vs round-up, and other inconsistencies in the engine
+ // (keep in mind that 4K resolution did not exist when this engine was created). But verifying it in a consistent manner
+ // would take quite a while.
+ //
+ // This is my attempt at fixing the problem, by making patchstatusbar() use round-up division here to always clear
+ // the boundary pixels in case the division has a remainder.
+ return (int)((mul32_64(input1, input2) + input3 - 1) / (int64_t)input3);
}
static inline int mulscale (int32_t input1, int32_t input2, int32_t input3)
{
--- a/Game/src/game.c
+++ b/Game/src/game.c
@@ -101,7 +101,7 @@
{ \
rotatesprite(0,(200-34)<<16,65536L,0,BOTTOMSTATUSBAR,4,0,10+16+64+128, \
scale(x1,xdim,320),scale(y1,ydim,200), \
- scale(x2,xdim,320)-1,scale(y2,ydim,200)-1); \
+ scaleup(x2,xdim,320)-1,scaleup(y2,ydim,200)-1); \
}
void newint24( int errval, int ax, int bp, int si );
--- a/README.md
+++ b/README.md
@@ -23,10 +23,6 @@
* Fixed visual regressions introduced by previous ports.
* Removed +35K lines of obsolete, unused methods, and other dead code paths (mostly from Game).
-### Known Issues
-
-* Engine: Pixel imprecision when rendering health/ammo numbers in the status bar, leaving ghost pixels.
-
## Requirements
An original copy of [Duke Nukem 3D](https://3drealms.com/catalog/duke-nukem-3d_27/). Specifically the DUKE3D.GRP file from the original CD in binary working directory.
@@ -52,7 +48,7 @@
```
Here we do not use vcpkg but instead rely on the distro packages for SDL2 libraries. Unfortunately vcpkg SDL2 (and mixer) still depends on several local development packages to be installed, plus the MIDI subsystem is not correctly configured.
-**MacOS X (Clang Makefile)** [![MacOS X CI Status](https://github.com/GPSnoopy/BelgianChocolateDuke3D/workflows/MacOS%20X%20CI/badge.svg)](https://github.com/GPSnoopy/BelgianChocolateDuke3D/actions?query=workflow%3A%22MacOS+X+CI%22)
+**macOS (Clang Makefile)** [![macOS CI Status](https://github.com/GPSnoopy/BelgianChocolateDuke3D/workflows/MacOS%20X%20CI/badge.svg)](https://github.com/GPSnoopy/BelgianChocolateDuke3D/actions?query=workflow%3A%22MacOS+X+CI%22)
```
> ./vcpkg_macosx.sh
> ./build_macosx.sh
@@ -73,9 +69,9 @@
> SDL_SOUNDFONTS=WeedsGM3.sf2 SDL_FORCE_SOUNDFONTS=1 ./ChocoDuke3D.64
```
-**MacOS X**
+**macOS**
-Out of the box, MIDI music will play fine on MacOS X (thanks to [vcpkg PR #10201](https://github.com/microsoft/vcpkg/pull/10201)).
+Out of the box, MIDI music will play fine on macOS (thanks to [vcpkg PR #10201](https://github.com/microsoft/vcpkg/pull/10201)).
## Contributors