Merge branch 'master' into feature/improveNonNpcCharNpcFiles
This commit is contained in:
commit
4ab849f4ef
4 changed files with 33 additions and 10 deletions
|
@ -262,8 +262,26 @@ 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 ""
|
||||
CMAKE_ARGS
|
||||
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
|
||||
-DCMAKE_BUILD_TYPE=Release
|
||||
-DCMAKE_CONFIGURATION_TYPES=Release
|
||||
)
|
||||
|
||||
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(OUT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/Resource")
|
||||
|
@ -271,8 +289,8 @@ foreach(FILENAME IN LISTS RESOURCES)
|
|||
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()
|
||||
|
|
11
Makefile
11
Makefile
|
@ -1,3 +1,6 @@
|
|||
NATIVECC = cc
|
||||
NATIVECXX = c++
|
||||
|
||||
ifeq ($(RELEASE), 1)
|
||||
CXXFLAGS = -O3 -flto
|
||||
LDFLAGS = -s
|
||||
|
@ -179,7 +182,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
|
||||
|
@ -204,12 +207,12 @@ ifeq ($(WINDOWS), 1)
|
|||
endif
|
||||
|
||||
all: $(BUILD_DIR)/$(FILENAME)
|
||||
@echo Finished
|
||||
|
||||
$(BUILD_DIR)/$(FILENAME): $(OBJECTS)
|
||||
@mkdir -p $(@D)
|
||||
@echo Linking
|
||||
@echo Linking $@
|
||||
@$(CXX) $(CXXFLAGS) $(LDFLAGS) $^ -o $@ $(LIBS)
|
||||
@echo Finished compiling: $@
|
||||
|
||||
obj/$(BUILD_DIR)/$(FILENAME)/%.o: src/%.cpp
|
||||
@mkdir -p $(@D)
|
||||
|
@ -229,7 +232,7 @@ 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))
|
||||
|
||||
|
|
|
@ -29,3 +29,5 @@ if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
install(TARGETS bin2h RUNTIME)
|
||||
|
|
|
@ -169,7 +169,7 @@ void SOUNDBUFFER::Mix(float *buffer, size_t frames)
|
|||
const float sample2 = ((looping || (((size_t)samplePosition) + 1) < size) ? data[(((size_t)samplePosition) + 1) % size] : 128.0f);
|
||||
|
||||
//Interpolate sample
|
||||
const float subPos = (float)std::fmod(samplePosition, 1.0);
|
||||
const float subPos = (float)fmod(samplePosition, 1.0);
|
||||
const float sampleA = sample1 + (sample2 - sample1) * subPos;
|
||||
|
||||
//Convert sample to float32
|
||||
|
@ -186,7 +186,7 @@ void SOUNDBUFFER::Mix(float *buffer, size_t frames)
|
|||
{
|
||||
if (looping)
|
||||
{
|
||||
samplePosition = std::fmod(samplePosition, size);
|
||||
samplePosition = fmod(samplePosition, size);
|
||||
looped = true;
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Add table
Reference in a new issue