Repository navigation
Add an opt-in hq4x pixel filter (desktop and browser) - #89
Open
sspilleman wants to merge 1 commit into
Open
sspilleman wants to merge 1 commit into
sspilleman wants to merge 1 commit into
Conversation
Advanced options get a "PIXEL FILTER: OFF/HQ4X" entry, saved as pixelFilter in ADVANCED.CFG. OFF stays the default, so the game looks the same unless the player turns it on. hq4x blends colors, so every frame is converted with the current palette before it's filtered. Fades, the dimmed menu palette and color flashes keep working. The 1280x800 result is drawn with linear sampling. The filter is only offered on desktop (macOS, Windows, Linux) and in the browser, where it has been tested. The SDL2 console ports (PS2, PS3, Vita, Wii U, Switch) and the backends without the filter (SDL1, PSP, null) hide the menu entry. On PS2 the 1280x800 texture wouldn't fit in video memory. The filter comes from github.com/grom358/hqx (LGPL 2.1 or later), vendored in src/lib/hqx/. Its 64 MB YUV lookup table is replaced by on-demand conversion, and an undefined negative double to uint32_t cast that breaks the output on ARM is fixed. src/sdl2/video.c includes hq4x.c directly, so the ports' build files need no changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds PIXEL FILTER: OFF / HQ4X to Advanced options, saved as
pixelFilterinADVANCED.CFG. OFF stays the default, so the game looks exactly the same unless the player turns it on.src/lib/hqx/(LGPL 2.1 or later, compatible with GPLv3; licence and README included). Two changes, both marked in the code:uint32_t, which is undefined behavior and gives wrong output on ARM. The output now matches upstream's intended (x86) result byte for byte.src/sdl2/video.c#includeshq4x.c, so none of the ports' build files need changes.Screenshots
The same demo frame on macOS, with the filter OFF and on HQ4X:
Full window (2560x1600)
OFF
HQ4X
Testing
-umode, so it can't affect game logic.🤖 Generated with Claude Code