tuxanci2-engine
Game engine for tuxanci2
Log | Files | Refs | README | LICENSE
commit ef9331fb7207d479bdb4e56eea56e621ab348ebf
parent 82ead357a7725a67d4451be04df1b9a849a601f4
Author: Connor Thomson <connor@gnufault.org>
Date:   Sun, 18 Oct 2026 18:17:15 -0700

Add TA_DISABLE_BILINEAR_FILTERING flag

Diffstat:
MMakefile | 16+++++++++++++++-
Msrc/ta_image.c | 18+++++++++++++++---
2 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile @@ -28,6 +28,10 @@ endif CFLAGS := -march=$(MARCH) -mtune=$(MARCH) -m$(BITS) $(ARCH_DEFINE) -I$(INCLUDE_DIR) -I$(BUILD_DIR) -std=$(CSTD) $(FLAGS) +ifeq ($(TA_DISABLE_BILINEAR_FILTERING),true) +CFLAGS += -DTA_DISABLE_BILINEAR_FILTERING +endif + ARFLAGS := rcs SRCS := $(shell find $(SRC_DIR) -type f -name '*.c') @@ -59,6 +63,14 @@ $(BUILD_DIR)/%.o: $(SRC_DIR)/%.c | $(BUILD_DIR) mkdir -p $(dir $@) $(CC) $(CFLAGS) -c $< -o $@ +TA_IMAGE_FILTER_CONFIG := $(BUILD_DIR)/ta_image_filtering.config + +$(TA_IMAGE_FILTER_CONFIG): FORCE | $(BUILD_DIR) + @printf '%s\n' '$(if $(filter true,$(TA_DISABLE_BILINEAR_FILTERING)),disabled,enabled)' > $@.tmp + @if ! cmp -s $@.tmp $@; then mv $@.tmp $@; else rm $@.tmp; fi + +$(BUILD_DIR)/ta_image.o: $(TA_IMAGE_FILTER_CONFIG) + $(BUILD_DIR)/%.o: $(BUILD_DIR)/%.c mkdir -p $(dir $@) $(CC) $(CFLAGS) -c $< -o $@ @@ -69,4 +81,6 @@ $(CONFIG_HEADER): | $(BUILD_DIR) clean: rm -rf $(BUILD_DIR) -.PHONY: all clean +FORCE: + +.PHONY: all clean FORCE diff --git a/src/ta_image.c b/src/ta_image.c @@ -337,11 +337,16 @@ ta_bool ta_image_draw(const ta_uint8 *data, ta_uint32 length, float x, float y, continue; } - ta_uint64 source_y_position = ((ta_uint64)(2 * (ta_uint64)image_y + 1) * image->height * 128) / pixel_height; ta_uint32 source_y0; ta_uint32 source_y1; ta_uint32 fraction_y; - + + #ifdef TA_DISABLE_BILINEAR_FILTERING + source_y0 = (ta_uint32)((ta_uint64)image_y * image->height / pixel_height); + source_y1 = source_y0; + fraction_y = 0; + #else + ta_uint64 source_y_position = ((ta_uint64)(2 * (ta_uint64)image_y + 1) * image->height * 128) / pixel_height; if (source_y_position <= 128) { source_y0 = 0; source_y1 = 0; @@ -359,6 +364,7 @@ ta_bool ta_image_draw(const ta_uint8 *data, ta_uint32 length, float x, float y, source_y1 = source_y0 + 1; } } +#endif for (ta_uint32 image_x = 0; image_x < pixel_width; image_x++) { ta_uint64 screen_x = (ta_uint64)pixel_x + image_x; @@ -367,11 +373,16 @@ ta_bool ta_image_draw(const ta_uint8 *data, ta_uint32 length, float x, float y, continue; } - ta_uint64 source_x_position = ((ta_uint64)(2 * (ta_uint64)image_x + 1) * image->width * 128) / pixel_width; ta_uint32 source_x0; ta_uint32 source_x1; ta_uint32 fraction_x; +#ifdef TA_DISABLE_BILINEAR_FILTERING + source_x0 = (ta_uint32)((ta_uint64)image_x * image->width / pixel_width); + source_x1 = source_x0; + fraction_x = 0; +#else + ta_uint64 source_x_position = ((ta_uint64)(2 * (ta_uint64)image_x + 1) * image->width * 128) / pixel_width; if (source_x_position <= 128) { source_x0 = 0; source_x1 = 0; @@ -389,6 +400,7 @@ ta_bool ta_image_draw(const ta_uint8 *data, ta_uint32 length, float x, float y, source_x1 = source_x0 + 1; } } +#endif ta_uint32 weight_x0 = 256 - fraction_x; ta_uint32 weight_y0 = 256 - fraction_y;