Merge pull request #82 from Clownacy/master

Cleanup, bugfixes, accuracy, build overhaul
This commit is contained in:
Cucky 2019-06-21 11:59:26 -04:00 committed by GitHub
commit 95cf124ee3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
932 changed files with 557 additions and 463 deletions

29
.gitignore vendored
View file

@ -4,35 +4,14 @@
# Exclude converted resource files
src/Resource
# Exclude .dat and .rec files in build directories (avoid Config.dat, 290.rec and others)
build_en/*.dat
build_en/*.rec
build_jp/*.dat
build_jp/*.rec
# Exclude build output directory
/game
# Exclude devilution-comparer assembly output
Exclude devilution-comparer assembly output
msvc2003/devilution/orig.asm
msvc2003/devilution/compare.asm
# Exclude build output on Linux (exclude normally produced executable files and out files)
build_en/CSE2
build_en/CSE2_debug
build_en/DoConfig
build_en/DoConfig_debug
build_jp/CSE2
build_jp/CSE2_debug
build_jp/DoConfig
build_jp/DoConfig_debug
build_en/*.out
build_jp/*.out
# Exclude PE executables in the build folder (and .exe.manifest files)
build_en/*.exe
build_en/*.exe.manifest
build_jp/*.exe
build_jp/*.exe.manifest
# Exclude the (recommended) CMake build directory
Exclude the (recommended) CMake build directory
build/*
# Exclude MSVC IntelliSense database

View file

@ -4,6 +4,9 @@ if((${CMAKE_VERSION} VERSION_EQUAL 3.9) OR (${CMAKE_VERSION} VERSION_GREATER 3.9
cmake_policy(SET CMP0069 NEW)
endif()
set(BUILD_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/game")
set(ASSETS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/assets")
option(JAPANESE "Enable the Japanese-language build" OFF)
option(FIX_BUGS "Fix certain bugs (see src/Bug Fixes.txt)" OFF)
option(NONPORTABLE "Enable bits of code that aren't portable, but are what the original game used" OFF)
@ -221,11 +224,11 @@ set(RESOURCES
# Handle options
if(JAPANESE)
set(BUILD_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/build_jp")
set(DATA_DIRECTORY "${ASSETS_DIRECTORY}/data_jp")
list(APPEND RESOURCES "BITMAP/pixel_jp.bmp")
target_compile_definitions(CSE2 PRIVATE JAPANESE)
else()
set(BUILD_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/build_en")
set(DATA_DIRECTORY "${ASSETS_DIRECTORY}/data_en")
list(APPEND RESOURCES "BITMAP/pixel.bmp")
endif()
@ -243,7 +246,7 @@ endif()
# Make some tweaks if we're targetting Windows
if(WIN32)
target_sources(CSE2 PRIVATE "res/ICON/ICON.rc")
target_sources(CSE2 PRIVATE "${ASSETS_DIRECTORY}/resources/ICON/ICON.rc")
target_compile_definitions(CSE2 PRIVATE WINDOWS)
set_target_properties(CSE2 PROPERTIES WIN32_EXECUTABLE YES) # Disable the console window
else()
@ -262,17 +265,37 @@ elseif(NOT WIN32)
list(APPEND RESOURCES "FONT/cour.ttf")
endif()
# Magic to convert resources to header files
add_subdirectory("bin2h")
# Build bin2h externally, so it isn't cross-compiled when CSE2 is (Emscripten)
include(ExternalProject)
ExternalProject_Add(bin2h
SOURCE_DIR "${CMAKE_SOURCE_DIR}/bin2h"
DOWNLOAD_COMMAND ""
UPDATE_COMMAND ""
BUILD_BYPRODUCTS "<INSTALL_DIR>/bin/bin2h"
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
-DCMAKE_BUILD_TYPE=Release
INSTALL_COMMAND
${CMAKE_COMMAND} --build . --config Release --target install
)
ExternalProject_Get_Property(bin2h INSTALL_DIR)
add_executable(bin2h_tool IMPORTED)
add_dependencies(bin2h_tool bin2h)
set_target_properties(bin2h_tool PROPERTIES IMPORTED_LOCATION "${INSTALL_DIR}/bin/bin2h")
# Convert resources to header files
foreach(FILENAME IN LISTS RESOURCES)
set(IN_DIR "${CMAKE_CURRENT_SOURCE_DIR}/res")
set(IN_DIR "${ASSETS_DIRECTORY}/resources")
set(OUT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/Resource")
get_filename_component(DIRECTORY "${FILENAME}" DIRECTORY)
add_custom_command(
OUTPUT "${OUT_DIR}/${FILENAME}.h"
COMMAND ${CMAKE_COMMAND} -E make_directory "${OUT_DIR}/${DIRECTORY}"
COMMAND bin2h "${IN_DIR}/${FILENAME}" "${OUT_DIR}/${FILENAME}.h"
DEPENDS bin2h "${IN_DIR}/${FILENAME}"
COMMAND bin2h_tool "${IN_DIR}/${FILENAME}" "${OUT_DIR}/${FILENAME}.h"
DEPENDS bin2h_tool "${IN_DIR}/${FILENAME}"
)
target_sources(CSE2 PRIVATE "${OUT_DIR}/${FILENAME}.h")
endforeach()
@ -303,6 +326,12 @@ set_target_properties(CSE2 PROPERTIES
RUNTIME_OUTPUT_DIRECTORY_DEBUG ${BUILD_DIRECTORY}
)
# Copy data folder to build directory
add_custom_command(TARGET CSE2 POST_BUILD
COMMAND ${CMAKE_COMMAND} -E remove_directory "${BUILD_DIRECTORY}/data"
COMMAND ${CMAKE_COMMAND} -E copy_directory "${DATA_DIRECTORY}" "${BUILD_DIRECTORY}/data"
)
# 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))
@ -361,6 +390,7 @@ else()
target_link_libraries(CSE2 freetype)
endif()
##
# DoConfig
##

View file

@ -5,14 +5,17 @@
* http://sam.zoy.org/wtfpl/COPYING for more details. */
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <cstring>
#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 <FL/Fl_Button.H>
#include <FL/Fl_Group.H>
#include <FL/Fl_Menu_Item.H>
#include <FL/Fl_Round_Button.H>
#include <FL/Enumerations.H>
#define MAGIC "DOUKUTSU20041206"
#define FONT "Courier New"

View file

@ -1,3 +1,9 @@
NATIVECC = cc
NATIVECXX = c++
BUILD_DIRECTORY = game
ASSETS_DIRECTORY = assets
ifeq ($(RELEASE), 1)
CXXFLAGS = -O3 -flto
LDFLAGS = -s
@ -8,11 +14,11 @@ else
endif
ifeq ($(JAPANESE), 1)
BUILD_DIR = build_jp
DATA_DIRECTORY = $(ASSETS_DIRECTORY)/data_jp
CXXFLAGS += -DJAPANESE
else
BUILD_DIR = build_en
DATA_DIRECTORY = $(ASSETS_DIRECTORY)/data_en
endif
FILENAME ?= $(FILENAME_DEF)
@ -179,7 +185,7 @@ RESOURCES = \
ORG/White.org \
ORG/XXXX.org \
ORG/Zonbie.org \
WAVE/Wave.dat \
WAVE/Wave.dat
ifeq ($(JAPANESE), 1)
RESOURCES += BITMAP/pixel_jp.bmp
@ -196,32 +202,37 @@ ifneq ($(WINDOWS), 1)
RESOURCES += ICON/ICON_MINI.bmp
endif
OBJECTS = $(addprefix obj/$(BUILD_DIR)/$(FILENAME)/, $(addsuffix .o, $(SOURCES)))
DEPENDENCIES = $(addprefix obj/$(BUILD_DIR)/$(FILENAME)/, $(addsuffix .o.d, $(SOURCES)))
OBJECTS = $(addprefix obj/$(FILENAME)/, $(addsuffix .o, $(SOURCES)))
DEPENDENCIES = $(addprefix obj/$(FILENAME)/, $(addsuffix .o.d, $(SOURCES)))
ifeq ($(WINDOWS), 1)
OBJECTS += obj/$(BUILD_DIR)/$(FILENAME)/win_icon.o
OBJECTS += obj/$(FILENAME)/win_icon.o
endif
all: $(BUILD_DIR)/$(FILENAME)
all: $(BUILD_DIRECTORY)/$(FILENAME) $(BUILD_DIRECTORY)/data
@echo Finished
$(BUILD_DIR)/$(FILENAME): $(OBJECTS)
$(BUILD_DIRECTORY)/data: $(DATA_DIRECTORY)
@mkdir -p $(@D)
@echo Linking
@rm -rf $(BUILD_DIRECTORY)/data
@cp -r $(DATA_DIRECTORY) $(BUILD_DIRECTORY)/data
$(BUILD_DIRECTORY)/$(FILENAME): $(OBJECTS)
@mkdir -p $(@D)
@echo Linking $@
@$(CXX) $(CXXFLAGS) $(LDFLAGS) $^ -o $@ $(LIBS)
@echo Finished compiling: $@
obj/$(BUILD_DIR)/$(FILENAME)/%.o: src/%.cpp
obj/$(FILENAME)/%.o: src/%.cpp
@mkdir -p $(@D)
@echo Compiling $<
@$(CXX) $(CXXFLAGS) $< -o $@ -c
obj/$(BUILD_DIR)/$(FILENAME)/Resource.o: src/Resource.cpp $(addprefix src/Resource/, $(addsuffix .h, $(RESOURCES)))
obj/$(FILENAME)/Resource.o: src/Resource.cpp $(addprefix src/Resource/, $(addsuffix .h, $(RESOURCES)))
@mkdir -p $(@D)
@echo Compiling $<
@$(CXX) $(CXXFLAGS) $< -o $@ -c
src/Resource/%.h: res/% obj/bin2h
src/Resource/%.h: $(ASSETS_DIRECTORY)/resources/% obj/bin2h
@mkdir -p $(@D)
@echo Converting $<
@obj/bin2h $< $@
@ -229,11 +240,11 @@ src/Resource/%.h: res/% obj/bin2h
obj/bin2h: bin2h/bin2h.c
@mkdir -p $(@D)
@echo Compiling $^
@$(CC) -O3 -s -std=c90 -Wall -Wextra -pedantic $^ -o $@
@$(NATIVECC) -O3 -s -std=c90 -Wall -Wextra -pedantic $^ -o $@
include $(wildcard $(DEPENDENCIES))
obj/$(BUILD_DIR)/$(FILENAME)/win_icon.o: res/ICON/ICON.rc res/ICON/0.ico res/ICON/ICON_MINI.ico
obj/$(FILENAME)/win_icon.o: $(ASSETS_DIRECTORY)/resources/ICON/ICON.rc $(ASSETS_DIRECTORY)/resources/ICON/0.ico $(ASSETS_DIRECTORY)/resources/ICON/ICON_MINI.ico
@mkdir -p $(@D)
@windres $< $@

View file

@ -6,7 +6,7 @@ Cave Story Engine 2 is a decompilation of Cave Story, ported from DirectX to SDL
## Dependencies
*Note: if these are not found, they will be built locally (CMake only)*
*Note: with CMake, if these are not found, they will be built locally*
* SDL2
* FreeType
@ -18,7 +18,7 @@ Cave Story Engine 2 is a decompilation of Cave Story, ported from DirectX to SDL
This project primarily uses CMake, allowing it to be built with a range of compilers.
In this directory, create a directory called 'build', then switch to the command-line (Visual Studio users should open the [Developer Command Prompt](https://docs.microsoft.com/en-us/dotnet/framework/tools/developer-command-prompt-for-vs)) and `cd` into it. After that, generate the files for your build system with:
In this folder, create another folder called 'build', then switch to the command-line (Visual Studio users should open the [Developer Command Prompt](https://docs.microsoft.com/en-us/dotnet/framework/tools/developer-command-prompt-for-vs)) and `cd` into it. After that, generate the files for your build system with:
```
cmake .. -DCMAKE_BUILD_TYPE=Release
@ -38,13 +38,13 @@ cmake --build . --config Release
If you're a Visual Studio user, you can open the generated `CSE2.sln` file instead.
Once built, the executables can be found in `build_en` or `build_jp`, depending on the selected language.
Once built, the executables and assets can be found in the newly-generated `game` folder.
### Makefile (deprecated)
*Note: this requires pkg-config*
Run 'make' in the base directory, preferably with some of the following settings:
Run 'make' in this folder, preferably with some of the following settings:
* `RELEASE=1` - Compile a release build (optimised, stripped, etc.)
* `STATIC=1` - Produce a statically-linked executable (good for Windows builds, so you don't need to bundle DLL files)
@ -56,7 +56,7 @@ Run 'make' in the base directory, preferably with some of the following settings
### Visual Studio .NET 2003
Project files for Visual Studio .NET 2003 are available in the 'msvc2003' directory.
Project files for Visual Studio .NET 2003 are available in the 'msvc2003' folder.
Visual Studio .NET 2003 was used by Pixel to create the original `Doukutsu.exe`, so these project files allow us to check the accuracy of the decompilation by comparing the generated assembly code to that of the original executable.

View file

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 31 KiB

View file

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

View file

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

View file

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 38 KiB

View file

Before

Width:  |  Height:  |  Size: 69 KiB

After

Width:  |  Height:  |  Size: 69 KiB

View file

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View file

Before

Width:  |  Height:  |  Size: 134 B

After

Width:  |  Height:  |  Size: 134 B

View file

Before

Width:  |  Height:  |  Size: 6.4 KiB

After

Width:  |  Height:  |  Size: 6.4 KiB

View file

Before

Width:  |  Height:  |  Size: 638 B

After

Width:  |  Height:  |  Size: 638 B

View file

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 38 KiB

View file

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 38 KiB

View file

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 38 KiB

View file

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View file

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View file

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 30 KiB

View file

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View file

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

View file

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 38 KiB

View file

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View file

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View file

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 38 KiB

View file

Before

Width:  |  Height:  |  Size: 59 KiB

After

Width:  |  Height:  |  Size: 59 KiB

View file

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

View file

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View file

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View file

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View file

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

View file

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 30 KiB

View file

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 38 KiB

View file

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View file

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View file

Before

Width:  |  Height:  |  Size: 7.6 KiB

After

Width:  |  Height:  |  Size: 7.6 KiB

View file

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 38 KiB

View file

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 38 KiB

View file

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

View file

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

View file

Before

Width:  |  Height:  |  Size: 76 KiB

After

Width:  |  Height:  |  Size: 76 KiB

View file

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

View file

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 38 KiB

View file

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

View file

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

View file

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 38 KiB

View file

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 38 KiB

Some files were not shown because too many files have changed in this diff Show more