From cf07bb328deb71cf2dc602f435b5340b0b55a2e5 Mon Sep 17 00:00:00 2001 From: Franklin Wei Date: Fri, 5 Jan 2018 17:25:03 -0500 Subject: duke3d: further optimize audio mixing Rather than holding intermediate results as fixed-point, this converts them directly to normal integers (in the range of the PCM sample) while mixing, instead of waiting till the end to perform a separate shifting step. Also, this precalculates some constants in the reverb code. Change-Id: Ie04e444d145bc28ce67eef9ae0ead6d328acf28a --- apps/plugins/sdl/progs/duke3d/Engine/src/display.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'apps/plugins/sdl/progs/duke3d/Engine/src/display.c') diff --git a/apps/plugins/sdl/progs/duke3d/Engine/src/display.c b/apps/plugins/sdl/progs/duke3d/Engine/src/display.c index 3883803bce..501ffa411c 100644 --- a/apps/plugins/sdl/progs/duke3d/Engine/src/display.c +++ b/apps/plugins/sdl/progs/duke3d/Engine/src/display.c @@ -1368,9 +1368,13 @@ int VBE_setPalette(uint8_t *palettebuffer) memcpy(lastPalette, palettebuffer, 768); for (i = 0; i < 256; i++){ - sdlp->b = (Uint8) ((((float) *p++) / 63.0) * 255.0); - sdlp->g = (Uint8) ((((float) *p++) / 63.0) * 255.0); - sdlp->r = (Uint8) ((((float) *p++) / 63.0) * 255.0); + /* doesn't map perfectly */ + sdlp->b = (Uint8) (*p << 2) | (*p >> 4); + p++; + sdlp->g = (Uint8) (*p << 2) | (*p >> 4); + p++; + sdlp->r = (Uint8) (*p << 2) | (*p >> 4); + p++; sdlp->unused = *p++; /* This byte is unused in BUILD, too. */ sdlp++; } -- cgit v1.2.3