From cad4518d3021ae8ff810e7a90faf562f7d73572c Mon Sep 17 00:00:00 2001 From: Clownacy Date: Mon, 11 Feb 2019 14:42:24 +0000 Subject: [PATCH 1/5] Fixed some portability issues (tested on a Pi) --- Makefile | 4 +++- src/Generic.cpp | 2 +- src/PixTone.cpp | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 2f91fa1b..c5029dee 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,6 @@ endif ifeq ($(JAPANESE), 1) CXXFLAGS += -DJAPANESE - LIBS += -liconv ifeq ($(RELEASE), 1) FILENAME_DEF = releasejp else @@ -26,6 +25,9 @@ ifeq ($(WINDOWS), 1) ifeq ($(CONSOLE), 1) CXXFLAGS += -mconsole endif + ifeq ($(JAPANESE), 1) + LIBS += -liconv + endif CXXFLAGS += -DWINDOWS LIBS += -lkernel32 endif diff --git a/src/Generic.cpp b/src/Generic.cpp index 33f8b811..20bbe30e 100644 --- a/src/Generic.cpp +++ b/src/Generic.cpp @@ -16,7 +16,7 @@ bool GetCompileVersion(int *v1, int *v2, int *v3, int *v4) bool CheckFileExists(const char *name) { char path[PATH_LENGTH]; - sprintf(path, "%s\\%s", gModulePath, name); + sprintf(path, "%s/%s", gModulePath, name); FILE *file = fopen(path, "rb"); if (file) diff --git a/src/PixTone.cpp b/src/PixTone.cpp index ee7b3df0..33e82185 100644 --- a/src/PixTone.cpp +++ b/src/PixTone.cpp @@ -6,7 +6,7 @@ #include "WindowsWrapper.h" -static char gWaveModelTable[6][256]; +static signed char gWaveModelTable[6][256]; void MakeWaveTables(void) { From 9c7457f4e27922adaa709ceb1a3cca1555c429cd Mon Sep 17 00:00:00 2001 From: Clownacy Date: Mon, 11 Feb 2019 14:43:31 +0000 Subject: [PATCH 2/5] Tiny cleanup in Sound.cpp The samples are unsigned --- src/Sound.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Sound.cpp b/src/Sound.cpp index 00a9b052..20dce1ec 100644 --- a/src/Sound.cpp +++ b/src/Sound.cpp @@ -323,7 +323,7 @@ size_t MakePixToneObject(const PIXTONEPARAMETER *ptp, int ptp_num, int no) if (pcm_buffer[j] + mixed_pcm_buffer[j] - 0x100 < -0x7F) mixed_pcm_buffer[j] = 0; else if (pcm_buffer[j] + mixed_pcm_buffer[j] - 0x100 > 0x7F) - mixed_pcm_buffer[j] = -1; + mixed_pcm_buffer[j] = 0xFF; else mixed_pcm_buffer[j] += pcm_buffer[j] + -0x80; } From 9e976b37071816d55e3afb4d8fd4bc841150e9d2 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Mon, 11 Feb 2019 14:50:28 +0000 Subject: [PATCH 3/5] Fixed an inaccuracy in NPC104 (Frog) Whoops --- src/NpcAct100.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/NpcAct100.cpp b/src/NpcAct100.cpp index a9e2fbbc..48d81858 100644 --- a/src/NpcAct100.cpp +++ b/src/NpcAct100.cpp @@ -260,9 +260,9 @@ void ActNpc104(NPCHAR *npc) if (bJump) { if (gMC.x > npc->x) - npc->direct = 0; - else npc->direct = 2; + else + npc->direct = 0; npc->act_no = 10; npc->ani_no = 2; @@ -272,7 +272,7 @@ void ActNpc104(NPCHAR *npc) PlaySoundObject(30, 1); if (npc->direct == 0) - npc->xm = -0x200u; + npc->xm = -0x200; else npc->xm = 0x200; } From 1546e6ed4e74f0e9b353d5f82b8ed0d7b1f56856 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Mon, 11 Feb 2019 14:57:38 +0000 Subject: [PATCH 4/5] Remove opengl hint I'm just gonna guess that was accidentally included --- src/Main.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Main.cpp b/src/Main.cpp index ef45bc4c..326b9a4c 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -280,7 +280,6 @@ int main(int argc, char *argv[]) } //Create window - SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl"); gWindow = SDL_CreateWindow(lpWindowName, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, gWindowWidth, gWindowHeight, bFullscreen ? SDL_WINDOW_FULLSCREEN : 0); if (gWindow) From a5860afeb9114a7c905b8d23d54b88e674f28aba Mon Sep 17 00:00:00 2001 From: Clownacy Date: Mon, 11 Feb 2019 18:36:56 +0000 Subject: [PATCH 5/5] Added Makefile dependency generation, and did some cleanup --- Makefile | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index c5029dee..433c9099 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,14 @@ ifeq ($(RELEASE), 1) - CXXFLAGS := -O3 -s + CXXFLAGS = -O3 -s FILENAME_DEF = release else - CXXFLAGS := -O0 -g + CXXFLAGS = -O0 -g FILENAME_DEF = debug endif ifeq ($(JAPANESE), 1) CXXFLAGS += -DJAPANESE + ifeq ($(RELEASE), 1) FILENAME_DEF = releasejp else @@ -28,16 +29,17 @@ ifeq ($(WINDOWS), 1) ifeq ($(JAPANESE), 1) LIBS += -liconv endif + CXXFLAGS += -DWINDOWS LIBS += -lkernel32 endif -CXXFLAGS += `sdl2-config --cflags` `pkg-config freetype2 --cflags` +CXXFLAGS += `sdl2-config --cflags` `pkg-config freetype2 --cflags` -MMD -MP -MF $@.d LIBS += `sdl2-config --static-libs` `pkg-config freetype2 --libs` ifeq ($(STATIC), 1) -CXXFLAGS += -static -LIBS += -lharfbuzz -lfreetype -lbz2 -lpng -lz -lgraphite2 -lRpcrt4 -lDwrite -lusp10 + CXXFLAGS += -static + LIBS += -lharfbuzz -lfreetype -lbz2 -lpng -lz -lgraphite2 -lRpcrt4 -lDwrite -lusp10 endif # For an accurate result to the original's code, compile in alphabetical order @@ -188,27 +190,28 @@ ifneq ($(WINDOWS), 1) endif OBJECTS = $(addprefix obj/$(FILENAME)/, $(addsuffix .o, $(SOURCES))) +DEPENDENCIES = $(addprefix obj/$(FILENAME)/, $(addsuffix .o.d, $(SOURCES))) ifeq ($(WINDOWS), 1) -OBJECTS += obj/$(FILENAME)/win_icon.o + OBJECTS += obj/$(FILENAME)/win_icon.o endif all: build/$(FILENAME) build/$(FILENAME): $(OBJECTS) @mkdir -p $(@D) - @g++ $(CXXFLAGS) $^ -o $@ $(LIBS) + @$(CXX) $(CXXFLAGS) $^ -o $@ $(LIBS) @echo Finished compiling: $@ obj/$(FILENAME)/%.o: src/%.cpp @mkdir -p $(@D) - @echo Compiling $^ - @g++ $(CXXFLAGS) $^ -o $@ -c + @echo Compiling $< + @$(CXX) $(CXXFLAGS) $< -o $@ -c obj/$(FILENAME)/Resource.o: src/Resource.cpp $(addprefix src/Resource/, $(addsuffix .h, $(RESOURCES))) @mkdir -p $(@D) @echo Compiling $< - @g++ $(CXXFLAGS) $< -o $@ -c + @$(CXX) $(CXXFLAGS) $< -o $@ -c src/Resource/%.h: res/% obj/bin2h @mkdir -p $(@D) @@ -218,7 +221,9 @@ src/Resource/%.h: res/% obj/bin2h obj/bin2h: res/bin2h.c @mkdir -p $(@D) @echo Compiling $^ - @gcc -O3 -s -static $^ -o $@ + @$(CC) -O3 -s -static $^ -o $@ + +include $(wildcard $(DEPENDENCIES)) obj/$(FILENAME)/win_icon.o: res/ICON/ICON.rc res/ICON/0.ico res/ICON/ICON_MINI.ico @mkdir -p $(@D)