From fcaddc6252ccfe3b29108ae3408a1bb4bea684f9 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Mon, 20 May 2019 15:03:15 +0100 Subject: [PATCH 01/15] Added a missing #include to Draw.cpp --- src/Draw.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Draw.cpp b/src/Draw.cpp index 44c28157..10eb49bf 100644 --- a/src/Draw.cpp +++ b/src/Draw.cpp @@ -1,5 +1,8 @@ #include #include +#ifdef WINDOWS +#include +#endif #include #ifdef WINDOWS From aa44e7ca49617b45d654cd5dae8f422dd1bfc9e6 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Tue, 21 May 2019 16:56:44 +0100 Subject: [PATCH 02/15] Reduce the size of bin2h-generated .h files The Japanese font went from 50MB to 25MB. --- src/misc/bin2h.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/misc/bin2h.c b/src/misc/bin2h.c index 287d68cb..e1995344 100644 --- a/src/misc/bin2h.c +++ b/src/misc/bin2h.c @@ -65,17 +65,17 @@ int main(int argc, char *argv[]) setvbuf(out_file, NULL, _IOFBF, 0x10000); - fprintf(out_file, "#pragma once\n\nconst unsigned char r%s[0x%lX] = {\n\t", filename, in_file_size); + fprintf(out_file, "#pragma once\n\nstatic const unsigned char r%s[0x%lX] = {\n\t", filename, in_file_size); for (i = 0; i < in_file_size - 1; ++i) { - if (i % 16 == 15) - fprintf(out_file, "0x%02X,\n\t", *in_file_pointer++); + if (i % 32 == 32-1) + fprintf(out_file, "%d,\n\t", *in_file_pointer++); else - fprintf(out_file, "0x%02X, ", *in_file_pointer++); + fprintf(out_file, "%d,", *in_file_pointer++); } - fprintf(out_file, "0x%02X\n};\n", *in_file_pointer++); + fprintf(out_file, "%d\n};\n", *in_file_pointer++); fclose(out_file); free(in_file_buffer); From 609d54916beef1fa692060a383bb9b180cf5f0d1 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Wed, 22 May 2019 00:29:16 +0000 Subject: [PATCH 03/15] Renamed debug builds to 'CSE2_debug' and 'DoConfig_debug' Makes a bit more sense than 'CSE2d' and 'DoConfigd' --- .gitignore | 8 ++++---- CMakeLists.txt | 4 ++-- DoConfig/CMakeLists.txt | 4 ++-- Makefile | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 440e8458..048e86c3 100644 --- a/.gitignore +++ b/.gitignore @@ -16,13 +16,13 @@ msvc2003/devilution/compare.asm # Exclude build output on Linux (exclude normally produced executable files and out files) build_en/CSE2 -build_en/CSE2d +build_en/CSE2_debug build_en/DoConfig -build_en/DoConfigd +build_en/DoConfig_debug build_jp/CSE2 -build_jp/CSE2d +build_jp/CSE2_debug build_jp/DoConfig -build_jp/DoConfigd +build_jp/DoConfig_debug build_en/*.out build_jp/*.out diff --git a/CMakeLists.txt b/CMakeLists.txt index b62868ed..949f10e8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -294,9 +294,9 @@ set_target_properties(CSE2 PROPERTIES CXX_EXTENSIONS OFF ) -# Name debug builds "CSE2d", to distinguish them +# Name debug builds "CSE2_debug", to distinguish them set_target_properties(CSE2 PROPERTIES - DEBUG_OUTPUT_NAME "CSE2d" + DEBUG_OUTPUT_NAME "CSE2_debug" ) # Send executable to the build_en/build_jp directory diff --git a/DoConfig/CMakeLists.txt b/DoConfig/CMakeLists.txt index 6c1d9776..443d6477 100644 --- a/DoConfig/CMakeLists.txt +++ b/DoConfig/CMakeLists.txt @@ -10,8 +10,8 @@ project(DoConfig LANGUAGES CXX) add_executable(DoConfig "DoConfig.cpp" "icon.rc") -# Name debug builds "DoConfigd", to distinguish them -set_target_properties(CSE2 PROPERTIES DEBUG_OUTPUT_NAME "DoConfigd") +# Name debug builds "DoConfig_debug", to distinguish them +set_target_properties(CSE2 PROPERTIES DEBUG_OUTPUT_NAME "DoConfig_debug") # Windows tweak if(WIN32) diff --git a/Makefile b/Makefile index 6d86c2d4..52c81047 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ ifeq ($(RELEASE), 1) FILENAME_DEF = CSE2 else CXXFLAGS = -Og -g3 - FILENAME_DEF = CSE2d + FILENAME_DEF = CSE2_debug endif ifeq ($(JAPANESE), 1) From 21cef10e4b738b50d351cacf0f7d1897abdf6858 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Thu, 23 May 2019 11:10:11 +0000 Subject: [PATCH 04/15] Fixed incorrect debug executable names --- DoConfig/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DoConfig/CMakeLists.txt b/DoConfig/CMakeLists.txt index 443d6477..7b5f71ad 100644 --- a/DoConfig/CMakeLists.txt +++ b/DoConfig/CMakeLists.txt @@ -11,7 +11,7 @@ project(DoConfig LANGUAGES CXX) add_executable(DoConfig "DoConfig.cpp" "icon.rc") # Name debug builds "DoConfig_debug", to distinguish them -set_target_properties(CSE2 PROPERTIES DEBUG_OUTPUT_NAME "DoConfig_debug") +set_target_properties(DoConfig PROPERTIES DEBUG_OUTPUT_NAME "DoConfig_debug") # Windows tweak if(WIN32) From 7db42b0b725f1b8cd37f1e40596875933c4133cb Mon Sep 17 00:00:00 2001 From: Clownacy Date: Thu, 23 May 2019 11:36:41 +0000 Subject: [PATCH 05/15] Set bin2h to C90 in the CMake file Done to match the Makefile --- CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 949f10e8..59b3eab4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -264,6 +264,13 @@ endif() # Magic to convert resources to header files add_executable(bin2h "src/misc/bin2h.c") + +set_target_properties(bin2h PROPERTIES + C_STANDARD 90 + C_STANDARD_REQUIRED ON + C_EXTENSIONS OFF +) + if(MSVC) target_compile_definitions(bin2h PRIVATE _CRT_SECURE_NO_WARNINGS) # Shut up those stupid warnings endif() From d1b71b9fce7c975f97816f3982eec3f900644394 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Thu, 23 May 2019 14:04:21 +0000 Subject: [PATCH 06/15] Add some more widescreen/tallscreen fixes to Frame.cpp Like I said in the TODO, this *really* needs to be moved to the enhanced branch --- src/Frame.cpp | 108 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 103 insertions(+), 5 deletions(-) diff --git a/src/Frame.cpp b/src/Frame.cpp index f50c17be..bf36440b 100644 --- a/src/Frame.cpp +++ b/src/Frame.cpp @@ -16,7 +16,7 @@ void MoveFrame3() short map_w, map_l; GetMapData(0, &map_w, &map_l); -#if WINDOW_WIDTH != 320 || WINDOW_HEIGHT != 240 // TODO - Really need to make this a compiler flag +#if WINDOW_WIDTH != 320 || WINDOW_HEIGHT != 240 // TODO - Really need to make this a compiler flag (also, should probably move this stuff to the enhanced branch) if (g_GameFlags & 8) { // Use the original camera boundaries during the credits @@ -126,15 +126,64 @@ void SetFramePosition(int fx, int fy) gFrame.y = fy; // Keep in bounds +#if WINDOW_WIDTH != 320 || WINDOW_HEIGHT != 240 + if (g_GameFlags & 8) + { + // Use the original camera boundaries during the credits + if (gFrame.x / 0x200 < 0) + gFrame.x = 0; + if (gFrame.y / 0x200 < 0) + gFrame.y = 0; + + if (gFrame.x > ((map_w - 1) * 0x10 - 320) * 0x200) + gFrame.x = ((map_w - 1) * 0x10 - 320) * 0x200; + if (gFrame.y > ((map_l - 1) * 0x10 - 240) * 0x200) + gFrame.y = ((map_l - 1) * 0x10 - 240) * 0x200; + + gFrame.x -= ((WINDOW_WIDTH - 320) / 2) * 0x200; + gFrame.y -= ((WINDOW_HEIGHT - 240) / 2) * 0x200; + } + else + { + // Widescreen/tallscreen-safe behaviour + if (map_w * 0x10 < WINDOW_WIDTH) + { + gFrame.x = -((WINDOW_WIDTH - map_w * 0x10) * 0x200 / 2); + } + else + { + if (gFrame.x / 0x200 < 0) + gFrame.x = 0; + + if (gFrame.x > ((map_w - 1) * 0x10 - WINDOW_WIDTH) * 0x200) + gFrame.x = ((map_w - 1) * 0x10 - WINDOW_WIDTH) * 0x200; + } + + if (map_l * 0x10 < WINDOW_HEIGHT) + { + gFrame.y = -((WINDOW_HEIGHT - map_l * 0x10) * 0x200 / 2); + } + else + { + if (gFrame.y / 0x200 < 0) + gFrame.y = 0; + + if (gFrame.y > ((map_l - 1) * 0x10 - WINDOW_HEIGHT) * 0x200) + gFrame.y = ((map_l - 1) * 0x10 - WINDOW_HEIGHT) * 0x200; + } + } +#else + // Vanilla behaviour if (gFrame.x / 0x200 < 0) gFrame.x = 0; if (gFrame.y / 0x200 < 0) gFrame.y = 0; - if (gFrame.x > ((((map_w - 1) * 0x10) - WINDOW_WIDTH)) * 0x200) + if (gFrame.x > (((map_w - 1) * 0x10) - WINDOW_WIDTH) * 0x200) gFrame.x = (((map_w - 1) * 0x10) - WINDOW_WIDTH) * 0x200; - if (gFrame.y > ((((map_l - 1) * 0x10) - WINDOW_HEIGHT)) * 0x200) + if (gFrame.y > (((map_l - 1) * 0x10) - WINDOW_HEIGHT) * 0x200) gFrame.y = (((map_l - 1) * 0x10) - WINDOW_HEIGHT) * 0x200; +#endif } void SetFrameMyChar() @@ -150,15 +199,64 @@ void SetFrameMyChar() gFrame.y = mc_y - (WINDOW_HEIGHT << 8); // Keep in bounds +#if WINDOW_WIDTH != 320 || WINDOW_HEIGHT != 240 + if (g_GameFlags & 8) + { + // Use the original camera boundaries during the credits + if (gFrame.x / 0x200 < 0) + gFrame.x = 0; + if (gFrame.y / 0x200 < 0) + gFrame.y = 0; + + if (gFrame.x > ((map_w - 1) * 0x10 - 320) * 0x200) + gFrame.x = ((map_w - 1) * 0x10 - 320) * 0x200; + if (gFrame.y > ((map_l - 1) * 0x10 - 240) * 0x200) + gFrame.y = ((map_l - 1) * 0x10 - 240) * 0x200; + + gFrame.x -= ((WINDOW_WIDTH - 320) / 2) * 0x200; + gFrame.y -= ((WINDOW_HEIGHT - 240) / 2) * 0x200; + } + else + { + // Widescreen/tallscreen-safe behaviour + if (map_w * 0x10 < WINDOW_WIDTH) + { + gFrame.x = -((WINDOW_WIDTH - map_w * 0x10) * 0x200 / 2); + } + else + { + if (gFrame.x / 0x200 < 0) + gFrame.x = 0; + + if (gFrame.x > ((map_w - 1) * 0x10 - WINDOW_WIDTH) * 0x200) + gFrame.x = ((map_w - 1) * 0x10 - WINDOW_WIDTH) * 0x200; + } + + if (map_l * 0x10 < WINDOW_HEIGHT) + { + gFrame.y = -((WINDOW_HEIGHT - map_l * 0x10) * 0x200 / 2); + } + else + { + if (gFrame.y / 0x200 < 0) + gFrame.y = 0; + + if (gFrame.y > ((map_l - 1) * 0x10 - WINDOW_HEIGHT) * 0x200) + gFrame.y = ((map_l - 1) * 0x10 - WINDOW_HEIGHT) * 0x200; + } + } +#else + // Vanilla behaviour if (gFrame.x / 0x200 < 0) gFrame.x = 0; if (gFrame.y / 0x200 < 0) gFrame.y = 0; - if (gFrame.x > ((((map_w - 1) * 0x10) - WINDOW_WIDTH)) * 0x200) + if (gFrame.x > (((map_w - 1) * 0x10) - WINDOW_WIDTH) * 0x200) gFrame.x = (((map_w - 1) * 0x10) - WINDOW_WIDTH) * 0x200; - if (gFrame.y > ((((map_l - 1) * 0x10) - WINDOW_HEIGHT)) * 0x200) + if (gFrame.y > (((map_l - 1) * 0x10) - WINDOW_HEIGHT) * 0x200) gFrame.y = (((map_l - 1) * 0x10) - WINDOW_HEIGHT) * 0x200; +#endif } void SetFrameTargetMyChar(int wait) From a4248b13e2a4541ddf278f8617d2ce727507713e Mon Sep 17 00:00:00 2001 From: Clownacy Date: Thu, 23 May 2019 14:15:30 +0000 Subject: [PATCH 07/15] Fix broken stage centring --- src/Frame.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Frame.cpp b/src/Frame.cpp index bf36440b..42b62038 100644 --- a/src/Frame.cpp +++ b/src/Frame.cpp @@ -41,7 +41,7 @@ void MoveFrame3() // Widescreen/tallscreen-safe behaviour if (map_w * 0x10 < WINDOW_WIDTH) { - gFrame.x = -((WINDOW_WIDTH - map_w * 0x10) * 0x200 / 2); + gFrame.x = -(((WINDOW_WIDTH - map_w * 0x10) * 0x200) / 2); } else { @@ -56,7 +56,7 @@ void MoveFrame3() if (map_l * 0x10 < WINDOW_HEIGHT) { - gFrame.y = -((WINDOW_HEIGHT - map_l * 0x10) * 0x200 / 2); + gFrame.y = -(((WINDOW_HEIGHT - map_l * 0x10) * 0x200) / 2); } else { @@ -148,7 +148,7 @@ void SetFramePosition(int fx, int fy) // Widescreen/tallscreen-safe behaviour if (map_w * 0x10 < WINDOW_WIDTH) { - gFrame.x = -((WINDOW_WIDTH - map_w * 0x10) * 0x200 / 2); + gFrame.x = -(((WINDOW_WIDTH - map_w * 0x10) * 0x200) / 2); } else { @@ -161,7 +161,7 @@ void SetFramePosition(int fx, int fy) if (map_l * 0x10 < WINDOW_HEIGHT) { - gFrame.y = -((WINDOW_HEIGHT - map_l * 0x10) * 0x200 / 2); + gFrame.y = -(((WINDOW_HEIGHT - map_l * 0x10) * 0x200) / 2); } else { @@ -221,7 +221,7 @@ void SetFrameMyChar() // Widescreen/tallscreen-safe behaviour if (map_w * 0x10 < WINDOW_WIDTH) { - gFrame.x = -((WINDOW_WIDTH - map_w * 0x10) * 0x200 / 2); + gFrame.x = -(((WINDOW_WIDTH - map_w * 0x10) * 0x200) / 2); } else { @@ -234,7 +234,7 @@ void SetFrameMyChar() if (map_l * 0x10 < WINDOW_HEIGHT) { - gFrame.y = -((WINDOW_HEIGHT - map_l * 0x10) * 0x200 / 2); + gFrame.y = -(((WINDOW_HEIGHT - map_l * 0x10) * 0x200) / 2); } else { From 43958d27717ce27042b87462dd954abc58e6a7d7 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Thu, 23 May 2019 14:28:44 +0000 Subject: [PATCH 08/15] ...For real, this time --- src/Frame.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Frame.cpp b/src/Frame.cpp index 42b62038..eb1d71af 100644 --- a/src/Frame.cpp +++ b/src/Frame.cpp @@ -41,7 +41,7 @@ void MoveFrame3() // Widescreen/tallscreen-safe behaviour if (map_w * 0x10 < WINDOW_WIDTH) { - gFrame.x = -(((WINDOW_WIDTH - map_w * 0x10) * 0x200) / 2); + gFrame.x = -(((WINDOW_WIDTH - (map_w - 1) * 0x10) * 0x200) / 2); } else { @@ -56,7 +56,7 @@ void MoveFrame3() if (map_l * 0x10 < WINDOW_HEIGHT) { - gFrame.y = -(((WINDOW_HEIGHT - map_l * 0x10) * 0x200) / 2); + gFrame.y = -(((WINDOW_HEIGHT - (map_l - 1) * 0x10) * 0x200) / 2); } else { @@ -148,7 +148,7 @@ void SetFramePosition(int fx, int fy) // Widescreen/tallscreen-safe behaviour if (map_w * 0x10 < WINDOW_WIDTH) { - gFrame.x = -(((WINDOW_WIDTH - map_w * 0x10) * 0x200) / 2); + gFrame.x = -(((WINDOW_WIDTH - (map_w - 1) * 0x10) * 0x200) / 2); } else { @@ -161,7 +161,7 @@ void SetFramePosition(int fx, int fy) if (map_l * 0x10 < WINDOW_HEIGHT) { - gFrame.y = -(((WINDOW_HEIGHT - map_l * 0x10) * 0x200) / 2); + gFrame.y = -(((WINDOW_HEIGHT - (map_l - 1) * 0x10) * 0x200) / 2); } else { @@ -221,7 +221,7 @@ void SetFrameMyChar() // Widescreen/tallscreen-safe behaviour if (map_w * 0x10 < WINDOW_WIDTH) { - gFrame.x = -(((WINDOW_WIDTH - map_w * 0x10) * 0x200) / 2); + gFrame.x = -(((WINDOW_WIDTH - (map_w - 1) * 0x10) * 0x200) / 2); } else { @@ -234,7 +234,7 @@ void SetFrameMyChar() if (map_l * 0x10 < WINDOW_HEIGHT) { - gFrame.y = -(((WINDOW_HEIGHT - map_l * 0x10) * 0x200) / 2); + gFrame.y = -(((WINDOW_HEIGHT - (map_l - 1) * 0x10) * 0x200) / 2); } else { From 5b89a3197603e9d16d3b198288dbb6622b7ecc94 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Thu, 23 May 2019 19:41:37 +0100 Subject: [PATCH 09/15] Split bin2h to its own CMake file Also added warnings to its part of the Makefile --- CMakeLists.txt | 12 +----------- Makefile | 4 ++-- bin2h/CMakeLists.txt | 31 +++++++++++++++++++++++++++++++ {src/misc => bin2h}/bin2h.c | 0 4 files changed, 34 insertions(+), 13 deletions(-) create mode 100644 bin2h/CMakeLists.txt rename {src/misc => bin2h}/bin2h.c (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 59b3eab4..ce750588 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -263,17 +263,7 @@ elseif(NOT WIN32) endif() # Magic to convert resources to header files -add_executable(bin2h "src/misc/bin2h.c") - -set_target_properties(bin2h PROPERTIES - C_STANDARD 90 - C_STANDARD_REQUIRED ON - C_EXTENSIONS OFF -) - -if(MSVC) - target_compile_definitions(bin2h PRIVATE _CRT_SECURE_NO_WARNINGS) # Shut up those stupid warnings -endif() +add_subdirectory("bin2h") foreach(FILENAME IN LISTS RESOURCES) set(IN_DIR "${CMAKE_CURRENT_SOURCE_DIR}/res") set(OUT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/Resource") diff --git a/Makefile b/Makefile index 52c81047..f03e0e10 100644 --- a/Makefile +++ b/Makefile @@ -226,10 +226,10 @@ src/Resource/%.h: res/% obj/bin2h @echo Converting $< @obj/bin2h $< $@ -obj/bin2h: src/misc/bin2h.c +obj/bin2h: bin2h/bin2h.c @mkdir -p $(@D) @echo Compiling $^ - @$(CC) -O3 -s -std=c90 $^ -o $@ + @$(CC) -O3 -s -std=c90 -Wall -Wextra -pedantic $^ -o $@ include $(wildcard $(DEPENDENCIES)) diff --git a/bin2h/CMakeLists.txt b/bin2h/CMakeLists.txt new file mode 100644 index 00000000..f2b1ce9d --- /dev/null +++ b/bin2h/CMakeLists.txt @@ -0,0 +1,31 @@ +cmake_minimum_required(VERSION 3.7.2) + +if((${CMAKE_VERSION} VERSION_EQUAL 3.9) OR (${CMAKE_VERSION} VERSION_GREATER 3.9)) + cmake_policy(SET CMP0069 NEW) +endif() + +project(bin2h LANGUAGES C) + +add_executable(bin2h "bin2h.c") + +set_target_properties(bin2h PROPERTIES + C_STANDARD 90 + C_STANDARD_REQUIRED ON + C_EXTENSIONS OFF +) + +# MSVC tweak +if(MSVC) + target_compile_definitions(bin2h PRIVATE _CRT_SECURE_NO_WARNINGS) # Shut up those stupid warnings +endif() + +# Enable link-time optimisation if available +if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") + if((${CMAKE_VERSION} VERSION_EQUAL 3.9) OR (${CMAKE_VERSION} VERSION_GREATER 3.9)) + include(CheckIPOSupported) + check_ipo_supported(RESULT result) + if(result) + set_target_properties(bin2h PROPERTIES INTERPROCEDURAL_OPTIMIZATION TRUE) + endif() + endif() +endif() diff --git a/src/misc/bin2h.c b/bin2h/bin2h.c similarity index 100% rename from src/misc/bin2h.c rename to bin2h/bin2h.c From 50897e8ceb41f2183c74a30d647256ed6de34d8e Mon Sep 17 00:00:00 2001 From: Clownacy Date: Thu, 23 May 2019 21:29:32 +0100 Subject: [PATCH 10/15] Move DoConfig_debug naming to the root CMakeLists.txt --- CMakeLists.txt | 7 ++++--- DoConfig/CMakeLists.txt | 3 --- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ce750588..9fb63af5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -292,9 +292,7 @@ set_target_properties(CSE2 PROPERTIES ) # Name debug builds "CSE2_debug", to distinguish them -set_target_properties(CSE2 PROPERTIES - DEBUG_OUTPUT_NAME "CSE2_debug" -) +set_target_properties(CSE2 PROPERTIES DEBUG_OUTPUT_NAME "CSE2_debug") # Send executable to the build_en/build_jp directory set_target_properties(CSE2 PROPERTIES @@ -369,6 +367,9 @@ endif() add_subdirectory("DoConfig") +# Name debug builds "DoConfig_debug", to distinguish them +set_target_properties(DoConfig PROPERTIES DEBUG_OUTPUT_NAME "DoConfig_debug") + # Send executable to the build_en/build_jp directory set_target_properties(DoConfig PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${BUILD_DIRECTORY} diff --git a/DoConfig/CMakeLists.txt b/DoConfig/CMakeLists.txt index 7b5f71ad..a2973d94 100644 --- a/DoConfig/CMakeLists.txt +++ b/DoConfig/CMakeLists.txt @@ -10,9 +10,6 @@ project(DoConfig LANGUAGES CXX) add_executable(DoConfig "DoConfig.cpp" "icon.rc") -# Name debug builds "DoConfig_debug", to distinguish them -set_target_properties(DoConfig PROPERTIES DEBUG_OUTPUT_NAME "DoConfig_debug") - # Windows tweak if(WIN32) set_target_properties(DoConfig PROPERTIES WIN32_EXECUTABLE YES) # Disable the console window From 5933a1201e25ab2eff8e32a1a241b8429f8ebce9 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Fri, 24 May 2019 09:34:55 +0100 Subject: [PATCH 11/15] Shut up a warning GCC was giving bin2h --- bin2h/bin2h.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin2h/bin2h.c b/bin2h/bin2h.c index e1995344..11c1de1e 100644 --- a/bin2h/bin2h.c +++ b/bin2h/bin2h.c @@ -29,7 +29,7 @@ int main(int argc, char *argv[]) filename_pointer = (last_path_seperator == NULL) ? argv[1] : last_path_seperator + 1; dot = strchr(filename_pointer, '.'); - filename_length = (dot == NULL) ? strlen(filename_pointer) : dot - filename_pointer; + filename_length = (dot == NULL) ? strlen(filename_pointer) : (size_t)(dot - filename_pointer); filename = malloc(filename_length + 1); memcpy(filename, filename_pointer, filename_length); From d2b5872c95e7c0970fdf81e16397ab497763b89b Mon Sep 17 00:00:00 2001 From: Clownacy Date: Fri, 24 May 2019 10:07:30 +0100 Subject: [PATCH 12/15] Weeded out some bool usage Cave Story was written in C89. No bools. I've left in Sound.cpp's though, since that's written in C++98 currently. --- src/Back.cpp | 2 +- src/Draw.cpp | 64 ++++++++++++++++++++++---------------------- src/Draw.h | 2 +- src/Font.cpp | 4 ++- src/Input.cpp | 14 +++++----- src/Input.h | 20 +++++++------- src/Main.cpp | 36 ++++++++++++------------- src/Organya.cpp | 38 +++++++++++++------------- src/Organya.h | 10 ++++--- src/Sound.cpp | 8 +++--- src/Sound.h | 4 ++- src/WindowsWrapper.h | 2 +- 12 files changed, 107 insertions(+), 97 deletions(-) diff --git a/src/Back.cpp b/src/Back.cpp index 37b6e5c9..7bdcc960 100644 --- a/src/Back.cpp +++ b/src/Back.cpp @@ -250,7 +250,7 @@ void PutFront(int fx, int fy) // Draw black bars if (!(g_GameFlags & 8)) // Detect if credits are running { - const bool fromFocus = (gStageNo == 31); // Get if we should only draw around a 320x240 area of the focus point + const BOOL fromFocus = (gStageNo == 31); // Get if we should only draw around a 320x240 area of the focus point // Get focus rect int focusX = gFrame.x + (WINDOW_WIDTH << 8) - (320 << 8); diff --git a/src/Draw.cpp b/src/Draw.cpp index 10eb49bf..58ec6af3 100644 --- a/src/Draw.cpp +++ b/src/Draw.cpp @@ -30,8 +30,8 @@ struct SURFACE { - bool in_use; - bool needs_updating; + BOOL in_use; + BOOL needs_updating; SDL_Surface *surface; SDL_Texture *texture; }; @@ -43,7 +43,7 @@ RECT grcGame = {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT}; RECT grcFull = {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT}; int magnification; -bool fullscreen; +BOOL fullscreen; SURFACE surf[SURFACE_ID_MAX]; @@ -55,7 +55,7 @@ BOOL Flip_SystemTask(int hWnd) { (void)hWnd; - while (true) + while (TRUE) { if (!SystemTask()) return FALSE; @@ -102,17 +102,17 @@ BOOL StartDirectDraw(int lMagnification, int lColourDepth) { case 0: magnification = 1; - fullscreen = false; + fullscreen = FALSE; break; case 1: magnification = 2; - fullscreen = false; + fullscreen = FALSE; break; case 2: magnification = 2; - fullscreen = true; + fullscreen = TRUE; SDL_SetWindowFullscreen(gWindow, SDL_WINDOW_FULLSCREEN); break; } @@ -132,7 +132,7 @@ void EndDirectDraw() ReleaseSurface(i); } -static bool IsEnableBitmap(SDL_RWops *fp) +static BOOL IsEnableBitmap(SDL_RWops *fp) { char str[16]; const char *extra_text = "(C)Pixel"; @@ -152,7 +152,7 @@ void ReleaseSurface(int s) { SDL_DestroyTexture(surf[s].texture); SDL_FreeSurface(surf[s].surface); - surf[s].in_use = false; + surf[s].in_use = FALSE; } } @@ -172,7 +172,7 @@ BOOL MakeSurface_Generic(int bxsize, int bysize, Surface_Ids surf_no, BOOL bSyst } else { - if (surf[surf_no].in_use == true) + if (surf[surf_no].in_use == TRUE) { printf("Tried to create drawable surface at occupied slot (%d)\n", surf_no); } @@ -197,7 +197,7 @@ BOOL MakeSurface_Generic(int bxsize, int bysize, Surface_Ids surf_no, BOOL bSyst } else { - surf[surf_no].in_use = true; + surf[surf_no].in_use = TRUE; success = TRUE; } } @@ -234,9 +234,9 @@ static void FlushSurface(Surface_Ids surf_no) SDL_UnlockTexture(surf[surf_no].texture); } -static bool LoadBitmap(SDL_RWops *fp, Surface_Ids surf_no, bool create_surface) +static BOOL LoadBitmap(SDL_RWops *fp, Surface_Ids surf_no, BOOL create_surface) { - bool success = false; + BOOL success = FALSE; if (surf_no >= SURFACE_ID_MAX) { @@ -258,15 +258,15 @@ static bool LoadBitmap(SDL_RWops *fp, Surface_Ids surf_no, bool create_surface) } else { - if (create_surface == false || MakeSurface_Generic(surface->w, surface->h, surf_no, FALSE)) + if (create_surface == FALSE || MakeSurface_Generic(surface->w, surface->h, surf_no, FALSE)) { if (magnification == 1) { SDL_Rect dst_rect = {0, 0, surface->w, surface->h}; SDL_BlitSurface(surface, NULL, surf[surf_no].surface, &dst_rect); - surf[surf_no].needs_updating = true; + surf[surf_no].needs_updating = TRUE; printf(" ^ Successfully loaded\n"); - success = true; + success = TRUE; } else { @@ -304,9 +304,9 @@ static bool LoadBitmap(SDL_RWops *fp, Surface_Ids surf_no, bool create_surface) } SDL_FreeSurface(converted_surface); - surf[surf_no].needs_updating = true; + surf[surf_no].needs_updating = TRUE; printf(" ^ Successfully loaded\n"); - success = true; + success = TRUE; } } } @@ -321,7 +321,7 @@ static bool LoadBitmap(SDL_RWops *fp, Surface_Ids surf_no, bool create_surface) return success; } -static BOOL LoadBitmap_File(const char *name, Surface_Ids surf_no, bool create_surface) +static BOOL LoadBitmap_File(const char *name, Surface_Ids surf_no, BOOL create_surface) { char path[PATH_LENGTH]; SDL_RWops *fp; @@ -358,7 +358,7 @@ static BOOL LoadBitmap_File(const char *name, Surface_Ids surf_no, bool create_s return FALSE; } -static BOOL LoadBitmap_Resource(const char *res, Surface_Ids surf_no, bool create_surface) +static BOOL LoadBitmap_Resource(const char *res, Surface_Ids surf_no, BOOL create_surface) { size_t size; const unsigned char *data = FindResource(res, "BITMAP", &size); @@ -381,22 +381,22 @@ static BOOL LoadBitmap_Resource(const char *res, Surface_Ids surf_no, bool creat BOOL MakeSurface_File(const char *name, Surface_Ids surf_no) { - return LoadBitmap_File(name, surf_no, true); + return LoadBitmap_File(name, surf_no, TRUE); } BOOL MakeSurface_Resource(const char *res, Surface_Ids surf_no) { - return LoadBitmap_Resource(res, surf_no, true); + return LoadBitmap_Resource(res, surf_no, TRUE); } BOOL ReloadBitmap_File(const char *name, Surface_Ids surf_no) { - return LoadBitmap_File(name, surf_no, false); + return LoadBitmap_File(name, surf_no, FALSE); } BOOL ReloadBitmap_Resource(const char *res, Surface_Ids surf_no) { - return LoadBitmap_Resource(res, surf_no, false); + return LoadBitmap_Resource(res, surf_no, FALSE); } static SDL_Rect RectToSDLRect(RECT *rect) @@ -434,18 +434,18 @@ void BackupSurface(Surface_Ids surf_no, RECT *rect) SDL_Rect frameRect = RectToSDLRectScaled(rect); SDL_BlitSurface(surface, &frameRect, surf[surf_no].surface, &frameRect); - surf[surf_no].needs_updating = true; + surf[surf_no].needs_updating = TRUE; // Free surface SDL_FreeSurface(surface); } -static void DrawBitmap(RECT *rcView, int x, int y, RECT *rect, Surface_Ids surf_no, bool transparent) +static void DrawBitmap(RECT *rcView, int x, int y, RECT *rect, Surface_Ids surf_no, BOOL transparent) { if (surf[surf_no].needs_updating) { FlushSurface(surf_no); - surf[surf_no].needs_updating = false; + surf[surf_no].needs_updating = FALSE; } // Get SDL_Rects @@ -470,12 +470,12 @@ static void DrawBitmap(RECT *rcView, int x, int y, RECT *rect, Surface_Ids surf_ void PutBitmap3(RECT *rcView, int x, int y, RECT *rect, Surface_Ids surf_no) // Transparency { - DrawBitmap(rcView, x, y, rect, surf_no, true); + DrawBitmap(rcView, x, y, rect, surf_no, TRUE); } void PutBitmap4(RECT *rcView, int x, int y, RECT *rect, Surface_Ids surf_no) // No Transparency { - DrawBitmap(rcView, x, y, rect, surf_no, false); + DrawBitmap(rcView, x, y, rect, surf_no, FALSE); } void Surface2Surface(int x, int y, RECT *rect, int to, int from) @@ -485,7 +485,7 @@ void Surface2Surface(int x, int y, RECT *rect, int to, int from) SDL_Rect frameRect = RectToSDLRectScaled(rect); SDL_BlitSurface(surf[from].surface, &frameRect, surf[to].surface, &rcSet); - surf[to].needs_updating = true; + surf[to].needs_updating = TRUE; } unsigned long GetCortBoxColor(unsigned long col) @@ -517,7 +517,7 @@ void CortBox2(RECT *rect, unsigned long col, Surface_Ids surf_no) const unsigned char col_green = (unsigned char)((col >> 8) & 0xFF); const unsigned char col_blue = (unsigned char)((col >> 16) & 0xFF); SDL_FillRect(surf[surf_no].surface, &destRect, SDL_MapRGB(surf[surf_no].surface->format, col_red, col_green, col_blue)); - surf[surf_no].needs_updating = true; + surf[surf_no].needs_updating = TRUE; } #ifdef WINDOWS @@ -638,7 +638,7 @@ void PutText(int x, int y, const char *text, unsigned long color) void PutText2(int x, int y, const char *text, unsigned long color, Surface_Ids surf_no) { DrawText(gFont, (unsigned char*)surf[surf_no].surface->pixels, surf[surf_no].surface->pitch, surf[surf_no].surface->w, surf[surf_no].surface->h, x * magnification, y * magnification, color, text, strlen(text)); - surf[surf_no].needs_updating = true; + surf[surf_no].needs_updating = TRUE; } void EndTextObject() diff --git a/src/Draw.h b/src/Draw.h index 4542f4b9..0ee159e7 100644 --- a/src/Draw.h +++ b/src/Draw.h @@ -10,7 +10,7 @@ extern RECT grcGame; extern RECT grcFull; extern int magnification; -extern bool fullscreen; +extern BOOL fullscreen; typedef enum Surface_Ids { diff --git a/src/Font.cpp b/src/Font.cpp index 915cd499..b4f3da70 100644 --- a/src/Font.cpp +++ b/src/Font.cpp @@ -11,6 +11,8 @@ #include FT_LCD_FILTER_H #include FT_BITMAP_H +#include "WindowsWrapper.h" + #include "File.h" // Uncomment for that authentic pre-Windows Vista feel @@ -39,7 +41,7 @@ typedef struct FontObject FT_Face face; unsigned char *data; #ifndef DISABLE_FONT_ANTIALIASING - bool lcd_mode; + BOOL lcd_mode; #endif CachedGlyph *glyph_list_head; } FontObject; diff --git a/src/Input.cpp b/src/Input.cpp index 0c6e936a..af9fb9af 100644 --- a/src/Input.cpp +++ b/src/Input.cpp @@ -26,7 +26,7 @@ void ReleaseDirectInput() } } -bool InitDirectInput() +BOOL InitDirectInput() { // Open first available joystick SDL_InitSubSystem(SDL_INIT_JOYSTICK); @@ -40,10 +40,10 @@ bool InitDirectInput() break; } - return true; + return TRUE; } -bool GetJoystickStatus(JOYSTICK_STATUS *pStatus) +BOOL GetJoystickStatus(JOYSTICK_STATUS *pStatus) { // Clear status memset(pStatus, 0, sizeof(JOYSTICK_STATUS)); @@ -64,13 +64,13 @@ bool GetJoystickStatus(JOYSTICK_STATUS *pStatus) for (int button = 0; button < numButtons; button++) pStatus->bButton[button] = SDL_JoystickGetButton(joystick, button) != 0; - return true; + return TRUE; } - return false; + return FALSE; } -bool ResetJoystickStatus() +BOOL ResetJoystickStatus() { - return true; + return TRUE; } diff --git a/src/Input.h b/src/Input.h index 2e5ff41b..973edecf 100644 --- a/src/Input.h +++ b/src/Input.h @@ -1,18 +1,20 @@ #pragma once -extern bool gbUseJoystick; +#include "WindowsWrapper.h" + +extern BOOL gbUseJoystick; extern int gJoystickButtonTable[8]; struct JOYSTICK_STATUS { - bool bLeft; - bool bRight; - bool bUp; - bool bDown; - bool bButton[32]; + BOOL bLeft; + BOOL bRight; + BOOL bUp; + BOOL bDown; + BOOL bButton[32]; }; void ReleaseDirectInput(); -bool InitDirectInput(); -bool GetJoystickStatus(JOYSTICK_STATUS *pStatus); -bool ResetJoystickStatus(); +BOOL InitDirectInput(); +BOOL GetJoystickStatus(JOYSTICK_STATUS *pStatus); +BOOL ResetJoystickStatus(); diff --git a/src/Main.cpp b/src/Main.cpp index df5d9921..ba1f6f58 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -33,10 +33,10 @@ char gDataPath[PATH_LENGTH]; int gJoystickButtonTable[8]; int ghWnd; // Placeholder until we restore the WinAPI code -bool gbUseJoystick = false; -bool bFps = false; +BOOL gbUseJoystick = FALSE; +BOOL bFps = FALSE; -bool bActive = true; +BOOL bActive = TRUE; #ifdef JAPANESE const char *lpWindowName = "洞窟物語エンジン2"; @@ -68,7 +68,7 @@ void PutFramePerSecound() int GetFramePerSecound() { unsigned int current_tick; - static bool need_new_base_tick = true; + static BOOL need_new_base_tick = TRUE; static int frames_this_second; static int current_frame; static int base_tick; @@ -76,7 +76,7 @@ int GetFramePerSecound() if (need_new_base_tick) { base_tick = SDL_GetTicks(); - need_new_base_tick = false; + need_new_base_tick = FALSE; } current_tick = SDL_GetTicks(); @@ -299,7 +299,7 @@ int main(int argc, char *argv[]) StartDirectDraw(2, colourDepth); - fullscreen = true; + fullscreen = TRUE; SDL_ShowCursor(0); break; } @@ -313,7 +313,7 @@ int main(int argc, char *argv[]) { // Check debug things if (CheckFileExists("fps")) - bFps = true; + bFps = TRUE; #ifndef WINDOWS // Load icon @@ -359,7 +359,7 @@ int main(int argc, char *argv[]) if (config.bJoystick && InitDirectInput()) { ResetJoystickStatus(); - gbUseJoystick = true; + gbUseJoystick = TRUE; } // Initialize stuff @@ -390,7 +390,7 @@ void InactiveWindow() { if (bActive) { - bActive = false; + bActive = FALSE; StopOrganyaMusic(); SleepNoise(); } @@ -402,7 +402,7 @@ void ActiveWindow() { if (!bActive) { - bActive = true; + bActive = TRUE; StopOrganyaMusic(); PlayOrganyaMusic(); ResetNoise(); @@ -446,10 +446,10 @@ void JoystickProc() gKey &= ~key; \ break; -bool SystemTask() +BOOL SystemTask() { // Handle window events - bool focusGained = true; + BOOL focusGained = TRUE; while (SDL_PollEvent(NULL) || !focusGained) { @@ -459,19 +459,19 @@ bool SystemTask() switch (event.type) { case SDL_QUIT: - return false; + return FALSE; break; case SDL_WINDOWEVENT: switch (event.window.event) { case SDL_WINDOWEVENT_FOCUS_GAINED: - focusGained = true; + focusGained = TRUE; ActiveWindow(); break; case SDL_WINDOWEVENT_FOCUS_LOST: - focusGained = false; + focusGained = FALSE; InactiveWindow(); break; @@ -552,7 +552,7 @@ bool SystemTask() DO_KEY_PRESS(KEY_PLUS) case SDL_SCANCODE_F5: - gbUseJoystick = false; + gbUseJoystick = FALSE; break; default: @@ -621,7 +621,7 @@ bool SystemTask() DO_KEY_PRESS(KEY_PLUS) case SDLK_F5: - gbUseJoystick = false; + gbUseJoystick = FALSE; break; } break; @@ -633,5 +633,5 @@ bool SystemTask() if (gbUseJoystick) JoystickProc(); - return true; + return TRUE; } diff --git a/src/Organya.cpp b/src/Organya.cpp index a57aa12e..55568d07 100644 --- a/src/Organya.cpp +++ b/src/Organya.cpp @@ -30,9 +30,9 @@ MUSICINFO info; int gTrackVol[MAXTRACK]; int gOrgVolume = 100; -bool bFadeout = false; +BOOL bFadeout = FALSE; -bool OrganyaNoteAlloc(unsigned short alloc) +BOOL OrganyaNoteAlloc(unsigned short alloc) { for(int j = 0; j < MAXTRACK; j++) { @@ -51,7 +51,7 @@ bool OrganyaNoteAlloc(unsigned short alloc) } } - return false; + return FALSE; } for(int i = 0; i < alloc; i++) @@ -72,7 +72,7 @@ bool OrganyaNoteAlloc(unsigned short alloc) //this->track = 0; - return true; + return FALSE; } void OrganyaReleaseNote() @@ -109,7 +109,7 @@ OCTWAVE oct_wave[8] = { { 8,128, 32 }, //7 Oct }; -bool MakeSoundObject8(signed char *wavep, signed char track, signed char pipi) +BOOL MakeSoundObject8(signed char *wavep, signed char track, signed char pipi) { for (int j = 0; j < 8; j++) { @@ -150,7 +150,7 @@ bool MakeSoundObject8(signed char *wavep, signed char track, signed char pipi) } } - return true; + return TRUE; } //Playing melody tracks @@ -272,17 +272,17 @@ BOOL InitWaveData100() } //Create org wave -bool MakeOrganyaWave(signed char track, signed char wave_no, signed char pipi) +BOOL MakeOrganyaWave(signed char track, signed char wave_no, signed char pipi) { if(wave_no > 99) { printf("WARNING: track %d has out-of-range wave_no %d\n", track, wave_no); - return false; + return FALSE; } ReleaseOrganyaObject(track); MakeSoundObject8(wave_data[wave_no], track, pipi); - return true; + return TRUE; } //Dram @@ -525,14 +525,14 @@ void LoadOrganya(const char *name) SetPlayPointer(0); //Set as loaded - info.loaded = true; + info.loaded = TRUE; } void SetOrganyaPosition(unsigned int x) { SetPlayPointer(x); gOrgVolume = 100; - bFadeout = false; + bFadeout = FALSE; } unsigned int GetOrganyaPosition() @@ -546,15 +546,15 @@ void PlayOrganyaMusic() OrganyaStartTimer(info.wait); } -bool ChangeOrganyaVolume(signed int volume) +BOOL ChangeOrganyaVolume(signed int volume) { if (volume >= 0 && volume <= 100) { gOrgVolume = volume; - return true; + return TRUE; } - return false; + return FALSE; } void StopOrganyaMusic() @@ -573,12 +573,12 @@ void StopOrganyaMusic() void SetOrganyaFadeout() { - bFadeout = true; + bFadeout = TRUE; } //Org timer SDL_Thread *OrganyaTimer = NULL; -bool bEndTimer = false; +BOOL bEndTimer = FALSE; int OrganyaPlayTimer(void *ptr) { @@ -587,7 +587,7 @@ int OrganyaPlayTimer(void *ptr) //Set time for next step to play Uint32 NextTick = SDL_GetTicks() + info.wait; - while (bEndTimer == false) + while (bEndTimer == FALSE) { if (info.loaded) { @@ -615,13 +615,13 @@ int OrganyaPlayTimer(void *ptr) void OrganyaStartTimer(unsigned int wait) { OrganyaEndTimer(); - bEndTimer = false; + bEndTimer = FALSE; OrganyaTimer = SDL_CreateThread(OrganyaPlayTimer, "OrganyaPlayTimer", (void*)NULL); } void OrganyaEndTimer() { - bEndTimer = true; //Tell thread to end + bEndTimer = TRUE; //Tell thread to end SDL_WaitThread(OrganyaTimer, NULL); //Wait for thread to end OrganyaTimer = NULL; } diff --git a/src/Organya.h b/src/Organya.h index 75b53d3a..78fdc55d 100644 --- a/src/Organya.h +++ b/src/Organya.h @@ -1,5 +1,7 @@ #pragma once +#include "WindowsWrapper.h" + //Below are Organya song data structures struct NOTELIST { NOTELIST *from; //Previous address @@ -26,8 +28,8 @@ struct TRACKDATA { //Unique information held in songs struct MUSICINFO { unsigned short wait; - bool loaded; - bool playing; + BOOL loaded; + BOOL playing; unsigned char line; //Number of lines in one measure unsigned char dot; //Number of dots per line unsigned short alloc_note; //Number of allocated notes @@ -36,14 +38,14 @@ struct MUSICINFO { TRACKDATA tdata[16]; }; -bool MakeOrganyaWave(signed char track, signed char wave_no, signed char pipi); +BOOL MakeOrganyaWave(signed char track, signed char wave_no, signed char pipi); void OrganyaPlayData(); void SetPlayPointer(long x); void LoadOrganya(const char *name); void SetOrganyaPosition(unsigned int x); unsigned int GetOrganyaPosition(); void PlayOrganyaMusic(); -bool ChangeOrganyaVolume(signed int volume); +BOOL ChangeOrganyaVolume(signed int volume); void StopOrganyaMusic(); void SetOrganyaFadeout(); void OrganyaStartTimer(unsigned int wait); diff --git a/src/Sound.cpp b/src/Sound.cpp index 9d2e6526..2fb0c828 100644 --- a/src/Sound.cpp +++ b/src/Sound.cpp @@ -8,6 +8,8 @@ #include +#include "WindowsWrapper.h" + #include "Organya.h" #include "PixTone.h" @@ -219,7 +221,7 @@ void AudioCallback(void *userdata, Uint8 *stream, int len) //Sound things SOUNDBUFFER* lpSECONDARYBUFFER[SOUND_NO]; -bool InitDirectSound() +BOOL InitDirectSound() { //Init sound SDL_InitSubSystem(SDL_INIT_AUDIO); @@ -240,7 +242,7 @@ bool InitDirectSound() if (audioDevice == 0) { printf("Failed to open audio device\nSDL Error: %s\n", SDL_GetError()); - return false; + return FALSE; } //Unpause audio device @@ -248,7 +250,7 @@ bool InitDirectSound() //Start organya StartOrganya(); - return true; + return TRUE; } void EndDirectSound() diff --git a/src/Sound.h b/src/Sound.h index 3eeb732d..8803644c 100644 --- a/src/Sound.h +++ b/src/Sound.h @@ -2,6 +2,8 @@ #include +#include "WindowsWrapper.h" + #include "PixTone.h" class SOUNDBUFFER @@ -91,7 +93,7 @@ enum MUSIC_IDS #define SOUND_NO 0x100 extern SOUNDBUFFER* lpSECONDARYBUFFER[SOUND_NO]; -bool InitDirectSound(); +BOOL InitDirectSound(); void EndDirectSound(); void PlaySoundObject(int no, int mode); void ChangeSoundFrequency(int no, unsigned long rate); diff --git a/src/WindowsWrapper.h b/src/WindowsWrapper.h index 09ee401c..8feb6218 100644 --- a/src/WindowsWrapper.h +++ b/src/WindowsWrapper.h @@ -35,4 +35,4 @@ struct RECT int bottom; }; -bool SystemTask(); +BOOL SystemTask(); From 0fb147aa0d43277c6420681d69b76f0262d06788 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Wed, 29 May 2019 18:49:09 +0000 Subject: [PATCH 13/15] Change the sound buffer size to a power of 2 Turns out giving SDL2 a non-power-of-2 buffer size crashes it in Emscripten. --- src/Sound.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Sound.cpp b/src/Sound.cpp index 2fb0c828..d4f22320 100644 --- a/src/Sound.cpp +++ b/src/Sound.cpp @@ -16,9 +16,9 @@ #define FREQUENCY 44100 #ifdef RASPBERRY_PI -#define STREAM_SIZE 0x400 +#define STREAM_SIZE 0x400 // Larger buffer to prevent stutter #else -#define STREAM_SIZE (FREQUENCY / 200) +#define STREAM_SIZE 0x100 // FREQUENCY/200 rounded to the nearest power of 2 (SDL2 *needs* a power-of-2 buffer size) #endif #define clamp(x, y, z) (((x) > (z)) ? (z) : ((x) < (y)) ? (y) : (x)) From c80b593a3f32b5fcb81b227cfe9f46de7a80a4f6 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Thu, 6 Jun 2019 18:44:28 +0000 Subject: [PATCH 14/15] Some #include fixes Finally figured out how to get include-what-you-use working --- DoConfig/DoConfig.cpp | 7 +++++-- src/Back.cpp | 2 ++ src/BossIronH.cpp | 1 + src/BossPress.cpp | 1 + src/BulHit.cpp | 4 ---- src/Config.cpp | 1 - src/Draw.cpp | 1 - src/Ending.h | 2 ++ src/Fade.cpp | 1 - src/Font.cpp | 1 - src/Frame.cpp | 2 -- src/Game.cpp | 5 ++--- src/Input.cpp | 4 ---- src/Main.cpp | 1 - src/Map.cpp | 1 + src/MiniMap.cpp | 1 - src/MycParam.cpp | 2 ++ src/NpcAct020.cpp | 1 - src/NpcAct040.cpp | 1 - src/NpcAct060.cpp | 2 +- src/NpcAct100.cpp | 2 -- src/NpcAct120.cpp | 1 - src/NpcAct140.cpp | 1 - src/NpcAct160.cpp | 1 - src/NpcAct200.cpp | 1 - src/NpcAct220.cpp | 3 --- src/NpcAct240.cpp | 1 - src/NpcAct260.cpp | 1 - src/NpcAct280.cpp | 1 - src/NpcAct300.cpp | 1 - src/NpcAct320.cpp | 4 ++-- src/NpcAct340.cpp | 2 +- src/NpcTbl.cpp | 1 - src/NpcTbl.h | 1 - src/Organya.cpp | 6 +----- src/PixTone.cpp | 1 - src/SelStage.cpp | 1 + src/Shoot.cpp | 2 ++ src/Sound.cpp | 9 ++++----- src/Stage.cpp | 1 - src/ValueView.cpp | 1 - 41 files changed, 28 insertions(+), 55 deletions(-) diff --git a/DoConfig/DoConfig.cpp b/DoConfig/DoConfig.cpp index 185ca7b6..d8cae819 100644 --- a/DoConfig/DoConfig.cpp +++ b/DoConfig/DoConfig.cpp @@ -5,14 +5,17 @@ * http://sam.zoy.org/wtfpl/COPYING for more details. */ #include -#include #include -#include #include "FL/Fl.H" #include "FL/Fl_Window.H" #include "FL/Fl_Radio_Round_Button.H" #include "FL/Fl_Choice.H" #include "FL/Fl_Check_Button.H" +#include +#include +#include +#include +#include #define MAGIC "DOUKUTSU20041206" #define FONT "Courier New" diff --git a/src/Back.cpp b/src/Back.cpp index 7bdcc960..71832cf4 100644 --- a/src/Back.cpp +++ b/src/Back.cpp @@ -1,9 +1,11 @@ #include "Back.h" +#include #include #include "WindowsWrapper.h" +#include "CommonDefines.h" #include "Draw.h" #include "File.h" #include "Frame.h" diff --git a/src/BossIronH.cpp b/src/BossIronH.cpp index c76ec3c0..6ad2f238 100644 --- a/src/BossIronH.cpp +++ b/src/BossIronH.cpp @@ -6,6 +6,7 @@ #include "Frame.h" #include "Game.h" #include "MyChar.h" +#include "NpChar.h" #include "Sound.h" void ActBossChar_Ironhead(void) diff --git a/src/BossPress.cpp b/src/BossPress.cpp index 5412b46e..f9b62b6c 100644 --- a/src/BossPress.cpp +++ b/src/BossPress.cpp @@ -5,6 +5,7 @@ #include "Boss.h" #include "Game.h" #include "Map.h" +#include "NpChar.h" #include "Sound.h" void ActBossChar_Press(void) diff --git a/src/BulHit.cpp b/src/BulHit.cpp index df8330a2..91db2033 100644 --- a/src/BulHit.cpp +++ b/src/BulHit.cpp @@ -1,13 +1,9 @@ #include "BulHit.h" -#include -#include - #include "Bullet.h" #include "Caret.h" #include "Game.h" #include "Map.h" -#include "MyChar.h" #include "NpChar.h" #include "Sound.h" diff --git a/src/Config.cpp b/src/Config.cpp index 909948e3..732466be 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -8,7 +8,6 @@ #include "Config.h" #include "File.h" #include "Tags.h" -#include "Types.h" static const char* const config_filename = "Config.dat"; // Not the original name static const char* const config_magic = "DOUKUTSU20041206"; // Not the original name diff --git a/src/Draw.cpp b/src/Draw.cpp index 58ec6af3..b5834958 100644 --- a/src/Draw.cpp +++ b/src/Draw.cpp @@ -26,7 +26,6 @@ #include "Font.h" #include "Resource.h" #include "Tags.h" -#include "Types.h" struct SURFACE { diff --git a/src/Ending.h b/src/Ending.h index 4a745ce4..04dea864 100644 --- a/src/Ending.h +++ b/src/Ending.h @@ -2,6 +2,8 @@ #include "WindowsWrapper.h" +#include "CommonDefines.h" + struct CREDIT { int size; diff --git a/src/Fade.cpp b/src/Fade.cpp index 403a4e0e..9c5986bc 100644 --- a/src/Fade.cpp +++ b/src/Fade.cpp @@ -6,7 +6,6 @@ #include "WindowsWrapper.h" #include "Draw.h" -#include "Game.h" #define FADE_WIDTH (((WINDOW_WIDTH - 1) / 16) + 1) #define FADE_HEIGHT (((WINDOW_HEIGHT - 1) / 16) + 1) diff --git a/src/Font.cpp b/src/Font.cpp index b4f3da70..4ce46010 100644 --- a/src/Font.cpp +++ b/src/Font.cpp @@ -2,7 +2,6 @@ #include #include -#include #include #include diff --git a/src/Frame.cpp b/src/Frame.cpp index eb1d71af..be669d89 100644 --- a/src/Frame.cpp +++ b/src/Frame.cpp @@ -1,7 +1,5 @@ #include "Frame.h" -#include - #include "Boss.h" #include "CommonDefines.h" #include "Game.h" diff --git a/src/Game.cpp b/src/Game.cpp index cca03ae1..0c38875d 100644 --- a/src/Game.cpp +++ b/src/Game.cpp @@ -1,8 +1,7 @@ #include "Game.h" -#include +#include #include -#include #include @@ -15,6 +14,7 @@ #include "BulHit.h" #include "Bullet.h" #include "Caret.h" +#include "CommonDefines.h" #include "Draw.h" #include "Ending.h" #include "Escape.h" @@ -35,7 +35,6 @@ #include "NpChar.h" #include "NpcHit.h" #include "NpcTbl.h" -#include "Organya.h" #include "Profile.h" #include "SelStage.h" #include "Shoot.h" diff --git a/src/Input.cpp b/src/Input.cpp index af9fb9af..5c663171 100644 --- a/src/Input.cpp +++ b/src/Input.cpp @@ -7,10 +7,6 @@ #include "WindowsWrapper.h" -#include "CommonDefines.h" -#include "Tags.h" -#include "Types.h" - #define JOYSTICK_DEADZONE 10000 SDL_Joystick *joystick; // This was probably a name that was given by Simon, but it fits the rest of Pixel's names so it's fine. diff --git a/src/Main.cpp b/src/Main.cpp index ba1f6f58..6ad3e25c 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -21,7 +21,6 @@ #include "Resource.h" #include "Sound.h" #include "Triangle.h" -#include "Types.h" // These two are defined in Draw.cpp. This is a bit of a hack. extern SDL_Window *gWindow; diff --git a/src/Map.cpp b/src/Map.cpp index 94bec202..25decba2 100644 --- a/src/Map.cpp +++ b/src/Map.cpp @@ -1,6 +1,7 @@ #include "Map.h" #include +#include #include #include diff --git a/src/MiniMap.cpp b/src/MiniMap.cpp index f444580b..ce3f4ea1 100644 --- a/src/MiniMap.cpp +++ b/src/MiniMap.cpp @@ -7,7 +7,6 @@ #include "CommonDefines.h" #include "Draw.h" #include "Escape.h" -#include "Game.h" #include "KeyControl.h" #include "Main.h" #include "Map.h" diff --git a/src/MycParam.cpp b/src/MycParam.cpp index 62527be8..ede5fcdb 100644 --- a/src/MycParam.cpp +++ b/src/MycParam.cpp @@ -1,5 +1,7 @@ #include "MycParam.h" +#include + #include "SDL.h" #include "WindowsWrapper.h" diff --git a/src/NpcAct020.cpp b/src/NpcAct020.cpp index 84156504..f7bc6f6d 100644 --- a/src/NpcAct020.cpp +++ b/src/NpcAct020.cpp @@ -2,7 +2,6 @@ #include "WindowsWrapper.h" -#include "Back.h" #include "Caret.h" #include "Game.h" #include "Frame.h" diff --git a/src/NpcAct040.cpp b/src/NpcAct040.cpp index b9002563..dad7b9ef 100644 --- a/src/NpcAct040.cpp +++ b/src/NpcAct040.cpp @@ -2,7 +2,6 @@ #include "WindowsWrapper.h" -#include "Back.h" #include "Caret.h" #include "CommonDefines.h" #include "Game.h" diff --git a/src/NpcAct060.cpp b/src/NpcAct060.cpp index b57049c3..8c4589a4 100644 --- a/src/NpcAct060.cpp +++ b/src/NpcAct060.cpp @@ -2,8 +2,8 @@ #include "WindowsWrapper.h" -#include "Back.h" #include "CommonDefines.h" +#include "Draw.h" #include "Flash.h" #include "Frame.h" #include "Game.h" diff --git a/src/NpcAct100.cpp b/src/NpcAct100.cpp index ce481c4c..12203beb 100644 --- a/src/NpcAct100.cpp +++ b/src/NpcAct100.cpp @@ -2,7 +2,6 @@ #include "WindowsWrapper.h" -#include "Back.h" #include "Bullet.h" #include "Caret.h" #include "Frame.h" @@ -10,7 +9,6 @@ #include "MyChar.h" #include "NpChar.h" #include "Sound.h" -#include "Triangle.h" // Grate void ActNpc100(NPCHAR *npc) diff --git a/src/NpcAct120.cpp b/src/NpcAct120.cpp index 2e0ba946..8a419708 100644 --- a/src/NpcAct120.cpp +++ b/src/NpcAct120.cpp @@ -2,7 +2,6 @@ #include "WindowsWrapper.h" -#include "Back.h" #include "Bullet.h" #include "Caret.h" #include "Frame.h" diff --git a/src/NpcAct140.cpp b/src/NpcAct140.cpp index a2c78e43..afb1cf92 100644 --- a/src/NpcAct140.cpp +++ b/src/NpcAct140.cpp @@ -2,7 +2,6 @@ #include "WindowsWrapper.h" -#include "Back.h" #include "Bullet.h" #include "Caret.h" #include "CommonDefines.h" diff --git a/src/NpcAct160.cpp b/src/NpcAct160.cpp index f723aec4..83cb51a3 100644 --- a/src/NpcAct160.cpp +++ b/src/NpcAct160.cpp @@ -2,7 +2,6 @@ #include "WindowsWrapper.h" -#include "Back.h" #include "Caret.h" #include "CommonDefines.h" #include "Frame.h" diff --git a/src/NpcAct200.cpp b/src/NpcAct200.cpp index 80db74aa..a458b70e 100644 --- a/src/NpcAct200.cpp +++ b/src/NpcAct200.cpp @@ -2,7 +2,6 @@ #include "WindowsWrapper.h" -#include "Back.h" #include "Bullet.h" #include "Caret.h" #include "Frame.h" diff --git a/src/NpcAct220.cpp b/src/NpcAct220.cpp index b177be2d..f099dc43 100644 --- a/src/NpcAct220.cpp +++ b/src/NpcAct220.cpp @@ -2,10 +2,7 @@ #include "WindowsWrapper.h" -#include "Back.h" -#include "Bullet.h" #include "Caret.h" -#include "Frame.h" #include "Game.h" #include "MyChar.h" #include "NpChar.h" diff --git a/src/NpcAct240.cpp b/src/NpcAct240.cpp index e9f94375..98567704 100644 --- a/src/NpcAct240.cpp +++ b/src/NpcAct240.cpp @@ -2,7 +2,6 @@ #include "WindowsWrapper.h" -#include "Back.h" #include "Caret.h" #include "Frame.h" #include "Game.h" diff --git a/src/NpcAct260.cpp b/src/NpcAct260.cpp index f27f0188..eeaa4000 100644 --- a/src/NpcAct260.cpp +++ b/src/NpcAct260.cpp @@ -2,7 +2,6 @@ #include "WindowsWrapper.h" -#include "Back.h" #include "Caret.h" #include "Frame.h" #include "Game.h" diff --git a/src/NpcAct280.cpp b/src/NpcAct280.cpp index 791061b5..296dd084 100644 --- a/src/NpcAct280.cpp +++ b/src/NpcAct280.cpp @@ -2,7 +2,6 @@ #include "WindowsWrapper.h" -#include "Back.h" #include "Boss.h" #include "Frame.h" #include "Game.h" diff --git a/src/NpcAct300.cpp b/src/NpcAct300.cpp index 0427951d..095e2a86 100644 --- a/src/NpcAct300.cpp +++ b/src/NpcAct300.cpp @@ -4,7 +4,6 @@ #include "WindowsWrapper.h" -#include "Back.h" #include "Boss.h" #include "Bullet.h" #include "Caret.h" diff --git a/src/NpcAct320.cpp b/src/NpcAct320.cpp index 17b4d610..f2b3877d 100644 --- a/src/NpcAct320.cpp +++ b/src/NpcAct320.cpp @@ -1,8 +1,9 @@ #include "NpcAct.h" +#include + #include "WindowsWrapper.h" -#include "Back.h" #include "Bullet.h" #include "Caret.h" #include "Frame.h" @@ -12,7 +13,6 @@ #include "MyChar.h" #include "NpChar.h" #include "Sound.h" -#include "Triangle.h" // Curly (carried, shooting) void ActNpc320(NPCHAR *npc) diff --git a/src/NpcAct340.cpp b/src/NpcAct340.cpp index 6b1ad3f2..d40b3e4c 100644 --- a/src/NpcAct340.cpp +++ b/src/NpcAct340.cpp @@ -2,9 +2,9 @@ #include "WindowsWrapper.h" -#include "Back.h" #include "Caret.h" #include "CommonDefines.h" +#include "Draw.h" #include "Flash.h" #include "Flags.h" #include "Frame.h" diff --git a/src/NpcTbl.cpp b/src/NpcTbl.cpp index 9f9409a3..a6c64440 100644 --- a/src/NpcTbl.cpp +++ b/src/NpcTbl.cpp @@ -3,7 +3,6 @@ #include #include #include -#include #include "WindowsWrapper.h" diff --git a/src/NpcTbl.h b/src/NpcTbl.h index 121cc711..b61455a9 100644 --- a/src/NpcTbl.h +++ b/src/NpcTbl.h @@ -2,7 +2,6 @@ #include "WindowsWrapper.h" -#include "Draw.h" #include "NpChar.h" struct NPC_TBL_RECT diff --git a/src/Organya.cpp b/src/Organya.cpp index 55568d07..6b885b04 100644 --- a/src/Organya.cpp +++ b/src/Organya.cpp @@ -4,16 +4,12 @@ #include #include -#include -#include -#include +#include "SDL.h" #include "WindowsWrapper.h" -#include "CommonDefines.h" #include "Resource.h" #include "Sound.h" -#include "Tags.h" #define PANDUMMY 0xFF #define VOLDUMMY 0xFF diff --git a/src/PixTone.cpp b/src/PixTone.cpp index 02b3da2a..760a3c13 100644 --- a/src/PixTone.cpp +++ b/src/PixTone.cpp @@ -1,7 +1,6 @@ #include "PixTone.h" #include -#include #include #include "WindowsWrapper.h" diff --git a/src/SelStage.cpp b/src/SelStage.cpp index 1664e6eb..aa4d3a02 100644 --- a/src/SelStage.cpp +++ b/src/SelStage.cpp @@ -4,6 +4,7 @@ #include "WindowsWrapper.h" +#include "CommonDefines.h" #include "Draw.h" #include "Escape.h" #include "KeyControl.h" diff --git a/src/Shoot.cpp b/src/Shoot.cpp index 8955e670..c2babebf 100644 --- a/src/Shoot.cpp +++ b/src/Shoot.cpp @@ -1,5 +1,7 @@ #include "Shoot.h" +#include "WindowsWrapper.h" + #include "ArmsItem.h" #include "Bullet.h" #include "Caret.h" diff --git a/src/Sound.cpp b/src/Sound.cpp index d4f22320..2be03cb0 100644 --- a/src/Sound.cpp +++ b/src/Sound.cpp @@ -1,12 +1,11 @@ #include "Sound.h" -#include -#include +#include #include -#include -#include +#include +#include -#include +#include "SDL.h" #include "WindowsWrapper.h" diff --git a/src/Stage.cpp b/src/Stage.cpp index c8424bb6..744026ff 100644 --- a/src/Stage.cpp +++ b/src/Stage.cpp @@ -18,7 +18,6 @@ #include "MyChar.h" #include "NpChar.h" #include "Organya.h" -#include "Tags.h" #include "TextScr.h" #include "ValueView.h" diff --git a/src/ValueView.cpp b/src/ValueView.cpp index 41ea45e9..bb629f6c 100644 --- a/src/ValueView.cpp +++ b/src/ValueView.cpp @@ -3,7 +3,6 @@ #include "WindowsWrapper.h" #include "Draw.h" -#include "Game.h" #include "ValueView.h" #define VALUEVIEW_MAX 0x10 From 44094b103e5df0857ef0267c388b972705b60050 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Thu, 6 Jun 2019 18:51:44 +0000 Subject: [PATCH 15/15] -> "SDL.h" The SDL devs recommend this: https://wiki.libsdl.org/FAQDevelopment#Do_I_.23include_.3CSDL.h.3E_or_.3CSDL.2FSDL.h.3E.3F --- src/Input.cpp | 2 +- src/Main.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Input.cpp b/src/Input.cpp index 5c663171..a26e4ef0 100644 --- a/src/Input.cpp +++ b/src/Input.cpp @@ -3,7 +3,7 @@ #include #include -#include +#include "SDL.h" #include "WindowsWrapper.h" diff --git a/src/Main.cpp b/src/Main.cpp index 6ad3e25c..ec5c9eb7 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -4,7 +4,7 @@ #include #include -#include +#include "SDL.h" #include "WindowsWrapper.h"