shithub: zelda3

Download patch

ref: e4febafd54534a2c548371b55424559c0bfd4c7f
parent: 8bee71746f3ebf285976e16f88ddb2aed03e09f1
author: hgdagon <[email protected]>
date: Tue Oct 25 08:40:20 EDT 2022

A few changes for MSYS2 (#164)

Compilation on Windows with MSYS2
add STBI_NO_THREAD_LOCALS definition
Simpler SDL handling

--- a/Makefile
+++ b/Makefile
@@ -4,25 +4,38 @@
 OBJS:=$(SRCS:%.c=%.o)
 PYTHON:=/usr/bin/env python3
 CFLAGS:=$(if $(CFLAGS),$(CFLAGS),-O2 -Werror)
-
 CFLAGS:=${CFLAGS} $(shell sdl2-config --cflags) -DSYSTEM_VOLUME_MIXER_AVAILABLE=0
-LDFLAGS:=${LDFLAGS} $(shell sdl2-config --libs) -lm
 
+ifeq (${OS},Windows_NT)
+    WINDRES:=windres
+    RES:=zelda3.res
+    SDLFLAGS:=-Wl,-Bstatic $(shell sdl2-config --static-libs)
+else
+    SDLFLAGS:=$(shell sdl2-config --libs) -lm
+endif
+
 .PHONY: all clean clean_obj clean_gen
 
 all: $(TARGET_EXEC) tables/zelda3_assets.dat
-$(TARGET_EXEC): $(OBJS)
-	$(CC) $(OBJS) -o $@ $(LDFLAGS)
+$(TARGET_EXEC): $(OBJS) $(RES)
+	$(CC) $^ -o $@ $(LDFLAGS) $(SDLFLAGS)
 %.o : %.c
 	$(CC) -c $(CFLAGS) $< -o $@
 
+$(RES): platform/win32/zelda3.rc
+	@echo "Generating Windows resources"
+	@$(WINDRES) $< -O coff -o $@
+
 tables/zelda3_assets.dat: tables/dialogue.txt
-	cd tables; $(PYTHON) compile_resources.py ../$(ROM)
+	@echo "Compiling game resources"
+	@cd tables; $(PYTHON) compile_resources.py ../$(ROM)
 tables/dialogue.txt:
-	cd tables; $(PYTHON) extract_resources.py ../$(ROM)
+	@echo "Extracting game resources"
+	@cd tables; $(PYTHON) extract_resources.py ../$(ROM)
 
 clean: clean_obj clean_gen
 clean_obj:
-	$(RM) $(OBJS) $(TARGET_EXEC)
+	@$(RM) $(OBJS) $(TARGET_EXEC)
 clean_gen:
-	$(RM) tables/zelda3_assets.dat
+	@$(RM) $(RES) tables/zelda3_assets.dat tables/*.txt tables/*.png tables/sprites/*.png tables/*.yaml
+	@rm -rf tables/__pycache__ tables/dungeon tables/img tables/overworld tables/sound
--- a/glsl_shader.c
+++ b/glsl_shader.c
@@ -7,6 +7,7 @@
 #include <assert.h>
 #include <string.h>
 #define STB_IMAGE_IMPLEMENTATION
+#define STBI_NO_THREAD_LOCALS
 #define STBI_ONLY_PNG
 #define STBI_MAX_DIMENSIONS 4096
 #define STBI_NO_FAILURE_STRINGS