Untabify every single file

YOLO.

This is a repeat of #642. As before, I just did

    rg -l '\t' | xargs -n 1 sed -i -e 's/\t/    /g'

inside the desktop_version/ folder.
This commit is contained in:
Misa
2021-09-06 18:56:39 -07:00
parent b3f437fe55
commit c64fd89325
42 changed files with 29096 additions and 29096 deletions
+212 -212
View File
@@ -20,332 +20,332 @@ option(OFFICIAL_BUILD "Compile an official build of the game" OFF)
option(MAKEANDPLAY "Compile a version of the game without the main campaign (provided for convenience; consider modifying MakeAndPlay.h instead" OFF)
if(OFFICIAL_BUILD AND NOT MAKEANDPLAY)
set(STEAM ON)
set(GOG ON)
set(STEAM ON)
set(GOG ON)
endif()
if(${CMAKE_VERSION} VERSION_LESS "3.1.3")
message(WARNING "Your CMake version is too old; set -std=c90 -std=c++98 yourself!")
message(WARNING "Your CMake version is too old; set -std=c90 -std=c++98 yourself!")
else()
set(CMAKE_C_STANDARD 90)
set(CMAKE_C_EXTENSIONS OFF)
set(CMAKE_C_STANDARD 90)
set(CMAKE_C_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD 98)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD 98)
set(CMAKE_CXX_EXTENSIONS OFF)
endif()
# Architecture Flags
if(APPLE)
# Wow, Apple is a huge jerk these days huh?
set(OSX_10_9_SDK_PATH /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk)
if(NOT CMAKE_OSX_SYSROOT)
if(IS_DIRECTORY ${OSX_10_9_SDK_PATH})
set(CMAKE_OSX_SYSROOT ${OSX_10_9_SDK_PATH})
else()
message(WARNING "CMAKE_OSX_SYSROOT not set and macOS 10.9 SDK not found! Using default one.")
endif()
endif()
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.9)
link_directories(/usr/local/lib)
add_compile_options(-Werror=partial-availability)
# Wow, Apple is a huge jerk these days huh?
set(OSX_10_9_SDK_PATH /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk)
if(NOT CMAKE_OSX_SYSROOT)
if(IS_DIRECTORY ${OSX_10_9_SDK_PATH})
set(CMAKE_OSX_SYSROOT ${OSX_10_9_SDK_PATH})
else()
message(WARNING "CMAKE_OSX_SYSROOT not set and macOS 10.9 SDK not found! Using default one.")
endif()
endif()
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.9)
link_directories(/usr/local/lib)
add_compile_options(-Werror=partial-availability)
endif()
project(VVVVVV)
if(APPLE)
message(STATUS "Using macOS SDK at ${CMAKE_OSX_SYSROOT}")
message(STATUS "Using macOS SDK at ${CMAKE_OSX_SYSROOT}")
endif()
# RPATH
if(NOT WIN32)
if(APPLE)
set(BIN_LIBROOT "osx")
set(BIN_RPATH "@executable_path/osx")
elseif(CMAKE_SIZEOF_VOID_P MATCHES "8")
set(BIN_LIBROOT "lib64")
set(BIN_RPATH "\$ORIGIN/lib64")
else()
set(BIN_LIBROOT "lib")
set(BIN_RPATH "\$ORIGIN/lib")
endif()
set(CMAKE_SKIP_BUILD_RPATH TRUE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
set(CMAKE_INSTALL_RPATH ${BIN_RPATH})
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
if(APPLE)
set(BIN_LIBROOT "osx")
set(BIN_RPATH "@executable_path/osx")
elseif(CMAKE_SIZEOF_VOID_P MATCHES "8")
set(BIN_LIBROOT "lib64")
set(BIN_RPATH "\$ORIGIN/lib64")
else()
set(BIN_LIBROOT "lib")
set(BIN_RPATH "\$ORIGIN/lib")
endif()
set(CMAKE_SKIP_BUILD_RPATH TRUE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
set(CMAKE_INSTALL_RPATH ${BIN_RPATH})
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
endif()
# Source Lists
set(VVV_SRC
src/BinaryBlob.cpp
src/BlockV.cpp
src/Ent.cpp
src/Entity.cpp
src/FileSystemUtils.cpp
src/Finalclass.cpp
src/Game.cpp
src/Graphics.cpp
src/GraphicsResources.cpp
src/GraphicsUtil.cpp
src/Input.cpp
src/KeyPoll.cpp
src/Labclass.cpp
src/Logic.cpp
src/Map.cpp
src/Music.cpp
src/Otherlevel.cpp
src/preloader.cpp
src/Render.cpp
src/RenderFixed.cpp
src/Screen.cpp
src/Script.cpp
src/Scripts.cpp
src/SoundSystem.cpp
src/Spacestation2.cpp
src/TerminalScripts.cpp
src/Textbox.cpp
src/Tower.cpp
src/UtilityClass.cpp
src/WarpClass.cpp
src/XMLUtils.cpp
src/main.cpp
src/DeferCallbacks.c
src/GlitchrunnerMode.c
src/Network.c
src/ThirdPartyDeps.c
src/Vlogging.c
src/Xoshiro.c
../third_party/physfs/extras/physfsrwops.c
src/BinaryBlob.cpp
src/BlockV.cpp
src/Ent.cpp
src/Entity.cpp
src/FileSystemUtils.cpp
src/Finalclass.cpp
src/Game.cpp
src/Graphics.cpp
src/GraphicsResources.cpp
src/GraphicsUtil.cpp
src/Input.cpp
src/KeyPoll.cpp
src/Labclass.cpp
src/Logic.cpp
src/Map.cpp
src/Music.cpp
src/Otherlevel.cpp
src/preloader.cpp
src/Render.cpp
src/RenderFixed.cpp
src/Screen.cpp
src/Script.cpp
src/Scripts.cpp
src/SoundSystem.cpp
src/Spacestation2.cpp
src/TerminalScripts.cpp
src/Textbox.cpp
src/Tower.cpp
src/UtilityClass.cpp
src/WarpClass.cpp
src/XMLUtils.cpp
src/main.cpp
src/DeferCallbacks.c
src/GlitchrunnerMode.c
src/Network.c
src/ThirdPartyDeps.c
src/Vlogging.c
src/Xoshiro.c
../third_party/physfs/extras/physfsrwops.c
)
if(NOT CUSTOM_LEVEL_SUPPORT STREQUAL "DISABLED")
list(APPEND VVV_SRC src/CustomLevels.cpp)
if(NOT CUSTOM_LEVEL_SUPPORT STREQUAL "NO_EDITOR")
LIST(APPEND VVV_SRC src/Editor.cpp)
endif()
list(APPEND VVV_SRC src/CustomLevels.cpp)
if(NOT CUSTOM_LEVEL_SUPPORT STREQUAL "NO_EDITOR")
LIST(APPEND VVV_SRC src/Editor.cpp)
endif()
endif()
if(STEAM)
list(APPEND VVV_SRC src/SteamNetwork.c)
list(APPEND VVV_SRC src/SteamNetwork.c)
endif()
if(GOG)
list(APPEND VVV_SRC src/GOGNetwork.c)
list(APPEND VVV_SRC src/GOGNetwork.c)
endif()
# Executable information
if(WIN32)
add_executable(VVVVVV WIN32 ${VVV_SRC} icon.rc)
add_executable(VVVVVV WIN32 ${VVV_SRC} icon.rc)
else()
add_executable(VVVVVV ${VVV_SRC})
add_executable(VVVVVV ${VVV_SRC})
endif()
# Include Directories
if(BUNDLE_DEPENDENCIES)
target_include_directories(
VVVVVV PRIVATE
src
../third_party/tinyxml2
../third_party/physfs
../third_party/physfs/extras
../third_party/lodepng
../third_party/utfcpp/source
)
target_include_directories(
VVVVVV PRIVATE
src
../third_party/tinyxml2
../third_party/physfs
../third_party/physfs/extras
../third_party/lodepng
../third_party/utfcpp/source
)
else()
target_include_directories(
VVVVVV PRIVATE
src
../third_party/lodepng
../third_party/physfs/extras
)
target_include_directories(
VVVVVV PRIVATE
src
../third_party/lodepng
../third_party/physfs/extras
)
endif()
if(MAKEANDPLAY)
target_compile_definitions(VVVVVV PRIVATE -DMAKEANDPLAY)
target_compile_definitions(VVVVVV PRIVATE -DMAKEANDPLAY)
endif()
if(STEAM)
target_compile_definitions(VVVVVV PRIVATE -DSTEAM_NETWORK)
target_compile_definitions(VVVVVV PRIVATE -DSTEAM_NETWORK)
endif()
if(GOG)
target_compile_definitions(VVVVVV PRIVATE -DGOG_NETWORK)
target_compile_definitions(VVVVVV PRIVATE -DGOG_NETWORK)
endif()
set(XML2_SRC
../third_party/tinyxml2/tinyxml2.cpp
../third_party/tinyxml2/tinyxml2.cpp
)
set(PFS_SRC
../third_party/physfs/physfs.c
../third_party/physfs/physfs_archiver_dir.c
../third_party/physfs/physfs_archiver_unpacked.c
../third_party/physfs/physfs_archiver_zip.c
../third_party/physfs/physfs_byteorder.c
../third_party/physfs/physfs_unicode.c
../third_party/physfs/physfs_platform_posix.c
../third_party/physfs/physfs_platform_unix.c
../third_party/physfs/physfs_platform_windows.c
../third_party/physfs/physfs_platform_haiku.cpp
../third_party/physfs/physfs.c
../third_party/physfs/physfs_archiver_dir.c
../third_party/physfs/physfs_archiver_unpacked.c
../third_party/physfs/physfs_archiver_zip.c
../third_party/physfs/physfs_byteorder.c
../third_party/physfs/physfs_unicode.c
../third_party/physfs/physfs_platform_posix.c
../third_party/physfs/physfs_platform_unix.c
../third_party/physfs/physfs_platform_windows.c
../third_party/physfs/physfs_platform_haiku.cpp
)
if(APPLE)
# Are you noticing a pattern with this Apple crap yet?
set(PFS_SRC ${PFS_SRC} ../third_party/physfs/physfs_platform_apple.m)
# Are you noticing a pattern with this Apple crap yet?
set(PFS_SRC ${PFS_SRC} ../third_party/physfs/physfs_platform_apple.m)
endif()
set(PNG_SRC ../third_party/lodepng/lodepng.c)
if(NOT OFFICIAL_BUILD)
# Add interim commit hash and its date to the build
# Add interim commit hash and its date to the build
# find_package sets GIT_FOUND and GIT_EXECUTABLE
find_package(Git)
# find_package sets GIT_FOUND and GIT_EXECUTABLE
find_package(Git)
if(GIT_FOUND)
# These filenames have to be qualified, because when we run
# the CMake script, its work dir gets set to the build folder
set(VERSION_INPUT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/src/Version.h.in)
set(VERSION_OUTPUT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/src/Version.h.out)
if(GIT_FOUND)
# These filenames have to be qualified, because when we run
# the CMake script, its work dir gets set to the build folder
set(VERSION_INPUT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/src/Version.h.in)
set(VERSION_OUTPUT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/src/Version.h.out)
add_custom_target(
GenerateVersion ALL
# This BYPRODUCTS line is required for this to be ran every time
BYPRODUCTS ${VERSION_OUTPUT_FILE}
COMMAND ${CMAKE_COMMAND}
# These args have to be passed through, otherwise the script can't see them
# Also, these args have to come BEFORE `-P`! (Otherwise it fails with an unclear error)
-DGIT_EXECUTABLE=${GIT_EXECUTABLE}
-DINPUT_FILE=${VERSION_INPUT_FILE}
-DOUTPUT_FILE=${VERSION_OUTPUT_FILE}
-P ${CMAKE_CURRENT_SOURCE_DIR}/version.cmake
)
add_custom_target(
GenerateVersion ALL
# This BYPRODUCTS line is required for this to be ran every time
BYPRODUCTS ${VERSION_OUTPUT_FILE}
COMMAND ${CMAKE_COMMAND}
# These args have to be passed through, otherwise the script can't see them
# Also, these args have to come BEFORE `-P`! (Otherwise it fails with an unclear error)
-DGIT_EXECUTABLE=${GIT_EXECUTABLE}
-DINPUT_FILE=${VERSION_INPUT_FILE}
-DOUTPUT_FILE=${VERSION_OUTPUT_FILE}
-P ${CMAKE_CURRENT_SOURCE_DIR}/version.cmake
)
add_dependencies(VVVVVV GenerateVersion)
add_dependencies(VVVVVV GenerateVersion)
# This lets Version.h know that Version.h.out exists
add_definitions(-DVERSION_H_OUT_EXISTS)
endif()
# This lets Version.h know that Version.h.out exists
add_definitions(-DVERSION_H_OUT_EXISTS)
endif()
endif()
# Build options
if(ENABLE_WARNINGS)
# The weird syntax is due to CMake generator expressions.
# Saves quite a few lines and boilerplate at the price of readability.
target_compile_options(VVVVVV PRIVATE
$<$<OR:$<CXX_COMPILER_ID:GNU>,$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:
-Wall -Wpedantic $<$<BOOL:${ENABLE_WERROR}>:-Werror>>
$<$<CXX_COMPILER_ID:MSVC>:
/W4 $<$<BOOL:${ENABLE_WERROR}>:/WX>>)
# The weird syntax is due to CMake generator expressions.
# Saves quite a few lines and boilerplate at the price of readability.
target_compile_options(VVVVVV PRIVATE
$<$<OR:$<CXX_COMPILER_ID:GNU>,$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:
-Wall -Wpedantic $<$<BOOL:${ENABLE_WERROR}>:-Werror>>
$<$<CXX_COMPILER_ID:MSVC>:
/W4 $<$<BOOL:${ENABLE_WERROR}>:/WX>>)
endif()
if(CUSTOM_LEVEL_SUPPORT STREQUAL "NO_EDITOR")
add_definitions(-DNO_EDITOR)
add_definitions(-DNO_EDITOR)
elseif(CUSTOM_LEVEL_SUPPORT STREQUAL "DISABLED")
add_definitions(-DNO_CUSTOM_LEVELS -DNO_EDITOR)
add_definitions(-DNO_CUSTOM_LEVELS -DNO_EDITOR)
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(SUPPORTS_IMPLICIT_FALLTHROUGH TRUE)
set(SUPPORTS_IMPLICIT_FALLTHROUGH TRUE)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0)
set(SUPPORTS_IMPLICIT_FALLTHROUGH TRUE)
else()
set(SUPPORTS_IMPLICIT_FALLTHROUGH FALSE)
endif()
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0)
set(SUPPORTS_IMPLICIT_FALLTHROUGH TRUE)
else()
set(SUPPORTS_IMPLICIT_FALLTHROUGH FALSE)
endif()
else()
set(SUPPORTS_IMPLICIT_FALLTHROUGH FALSE)
set(SUPPORTS_IMPLICIT_FALLTHROUGH FALSE)
endif()
if(SUPPORTS_IMPLICIT_FALLTHROUGH)
target_compile_options(VVVVVV PRIVATE -Werror=implicit-fallthrough)
target_compile_options(VVVVVV PRIVATE -Werror=implicit-fallthrough)
endif()
if(MSVC)
# Disable MSVC warnings about implicit conversion
target_compile_options(VVVVVV PRIVATE /wd4244)
# Disable MSVC warnings about implicit conversion
target_compile_options(VVVVVV PRIVATE /wd4244)
endif()
if(MSVC)
# Disable exceptions
string(REGEX REPLACE "/EH[a-z]+" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
# Disable exceptions
string(REGEX REPLACE "/EH[a-z]+" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
# Disable RTTI
string(REGEX REPLACE "/GR" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-")
# Disable RTTI
string(REGEX REPLACE "/GR" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-")
else()
# Disable exceptions
string(REGEX REPLACE "-fexceptions" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions")
# Disable exceptions
string(REGEX REPLACE "-fexceptions" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions")
# Disable RTTI
string(REGEX REPLACE "-frtti" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
# Disable RTTI
string(REGEX REPLACE "-frtti" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
endif()
# Unfortunately, it doesn't seem like distros package LodePNG
add_library(lodepng-static STATIC ${PNG_SRC})
target_compile_definitions(lodepng-static PRIVATE
-DLODEPNG_NO_COMPILE_ALLOCATORS
-DLODEPNG_NO_COMPILE_DISK
-DLODEPNG_NO_COMPILE_ENCODER
-DLODEPNG_NO_COMPILE_ALLOCATORS
-DLODEPNG_NO_COMPILE_DISK
-DLODEPNG_NO_COMPILE_ENCODER
)
if(BUNDLE_DEPENDENCIES)
add_library(tinyxml2-static STATIC ${XML2_SRC})
add_library(physfs-static STATIC ${PFS_SRC})
target_compile_definitions(physfs-static PRIVATE
-DPHYSFS_SUPPORTS_DEFAULT=0 -DPHYSFS_SUPPORTS_ZIP=1
)
add_library(tinyxml2-static STATIC ${XML2_SRC})
add_library(physfs-static STATIC ${PFS_SRC})
target_compile_definitions(physfs-static PRIVATE
-DPHYSFS_SUPPORTS_DEFAULT=0 -DPHYSFS_SUPPORTS_ZIP=1
)
# PhysFS needs some extensions...
if(${CMAKE_VERSION} VERSION_GREATER "3.1.3"
OR ${CMAKE_VERSION} VERSION_EQUAL "3.1.3")
set_property(TARGET physfs-static PROPERTY C_EXTENSIONS ON)
endif()
# PhysFS needs some extensions...
if(${CMAKE_VERSION} VERSION_GREATER "3.1.3"
OR ${CMAKE_VERSION} VERSION_EQUAL "3.1.3")
set_property(TARGET physfs-static PROPERTY C_EXTENSIONS ON)
endif()
target_link_libraries(VVVVVV physfs-static tinyxml2-static lodepng-static)
target_link_libraries(VVVVVV physfs-static tinyxml2-static lodepng-static)
else()
find_package(utf8cpp CONFIG)
find_package(utf8cpp CONFIG)
target_link_libraries(VVVVVV physfs tinyxml2 utf8cpp lodepng-static)
target_link_libraries(VVVVVV physfs tinyxml2 utf8cpp lodepng-static)
endif()
# SDL2 Dependency (Detection pulled from FAudio)
if(DEFINED SDL2_INCLUDE_DIRS AND DEFINED SDL2_LIBRARIES)
message(STATUS "Using pre-defined SDL2 variables SDL2_INCLUDE_DIRS and SDL2_LIBRARIES")
target_include_directories(VVVVVV SYSTEM PRIVATE "$<BUILD_INTERFACE:${SDL2_INCLUDE_DIRS}>")
target_link_libraries(VVVVVV ${SDL2_LIBRARIES})
message(STATUS "Using pre-defined SDL2 variables SDL2_INCLUDE_DIRS and SDL2_LIBRARIES")
target_include_directories(VVVVVV SYSTEM PRIVATE "$<BUILD_INTERFACE:${SDL2_INCLUDE_DIRS}>")
target_link_libraries(VVVVVV ${SDL2_LIBRARIES})
elseif (EMSCRIPTEN)
message(STATUS "Using Emscripten SDL2")
target_compile_options(VVVVVV PUBLIC -sUSE_SDL=2 -sUSE_SDL_MIXER=2)
target_link_libraries(VVVVVV -sUSE_SDL=2 -sUSE_SDL_MIXER=2)
message(STATUS "Using Emscripten SDL2")
target_compile_options(VVVVVV PUBLIC -sUSE_SDL=2 -sUSE_SDL_MIXER=2)
target_link_libraries(VVVVVV -sUSE_SDL=2 -sUSE_SDL_MIXER=2)
else()
# Only try to autodetect if both SDL2 variables aren't explicitly set
find_package(SDL2 CONFIG)
if(TARGET SDL2::SDL2)
message(STATUS "Using TARGET SDL2::SDL2")
target_link_libraries(VVVVVV SDL2::SDL2 SDL2_mixer)
elseif(TARGET SDL2)
message(STATUS "Using TARGET SDL2")
target_link_libraries(VVVVVV SDL2 SDL2_mixer)
else()
message(STATUS "No TARGET SDL2::SDL2, or SDL2, using variables")
find_path(SDL2_MIXER_INCLUDE_DIRS NAMES SDL_mixer.h PATH_SUFFIXES SDL2)
target_include_directories(VVVVVV SYSTEM PRIVATE "$<BUILD_INTERFACE:${SDL2_INCLUDE_DIRS}>" ${SDL2_MIXER_INCLUDE_DIRS})
target_link_libraries(VVVVVV ${SDL2_LIBRARIES} SDL2_mixer)
endif()
# Only try to autodetect if both SDL2 variables aren't explicitly set
find_package(SDL2 CONFIG)
if(TARGET SDL2::SDL2)
message(STATUS "Using TARGET SDL2::SDL2")
target_link_libraries(VVVVVV SDL2::SDL2 SDL2_mixer)
elseif(TARGET SDL2)
message(STATUS "Using TARGET SDL2")
target_link_libraries(VVVVVV SDL2 SDL2_mixer)
else()
message(STATUS "No TARGET SDL2::SDL2, or SDL2, using variables")
find_path(SDL2_MIXER_INCLUDE_DIRS NAMES SDL_mixer.h PATH_SUFFIXES SDL2)
target_include_directories(VVVVVV SYSTEM PRIVATE "$<BUILD_INTERFACE:${SDL2_INCLUDE_DIRS}>" ${SDL2_MIXER_INCLUDE_DIRS})
target_link_libraries(VVVVVV ${SDL2_LIBRARIES} SDL2_mixer)
endif()
endif()
# Yes, more Apple Crap
if(APPLE)
find_library(FOUNDATION NAMES Foundation)
find_library(IOKIT NAMES IOKit)
target_link_libraries(VVVVVV objc ${IOKIT} ${FOUNDATION})
find_library(FOUNDATION NAMES Foundation)
find_library(IOKIT NAMES IOKit)
target_link_libraries(VVVVVV objc ${IOKIT} ${FOUNDATION})
endif()
# But hey, also some Haiku crap
if(HAIKU)
find_library(BE_LIBRARY be)
find_library(ROOT_LIBRARY root)
target_link_libraries(VVVVVV ${BE_LIBRARY} ${ROOT_LIBRARY})
find_library(BE_LIBRARY be)
find_library(ROOT_LIBRARY root)
target_link_libraries(VVVVVV ${BE_LIBRARY} ${ROOT_LIBRARY})
endif()
if(EMSCRIPTEN)
target_compile_options(VVVVVV PUBLIC -sFORCE_FILESYSTEM=1)
# 256MB is enough for everybody
target_link_libraries(VVVVVV -sFORCE_FILESYSTEM=1 -sTOTAL_MEMORY=256MB)
target_compile_options(VVVVVV PUBLIC -sFORCE_FILESYSTEM=1)
# 256MB is enough for everybody
target_link_libraries(VVVVVV -sFORCE_FILESYSTEM=1 -sTOTAL_MEMORY=256MB)
endif()
+87 -87
View File
@@ -12,136 +12,136 @@
binaryBlob::binaryBlob(void)
{
numberofHeaders = 0;
SDL_zeroa(m_headers);
SDL_zeroa(m_memblocks);
numberofHeaders = 0;
SDL_zeroa(m_headers);
SDL_zeroa(m_memblocks);
}
#ifdef VVV_COMPILEMUSIC
void binaryBlob::AddFileToBinaryBlob(const char* _path)
{
long size;
char * memblock;
long size;
char * memblock;
FILE *file = fopen(_path, "rb");
if (file != NULL)
{
fseek(file, 0, SEEK_END);
size = ftell(file);
fseek(file, 0, SEEK_SET);
FILE *file = fopen(_path, "rb");
if (file != NULL)
{
fseek(file, 0, SEEK_END);
size = ftell(file);
fseek(file, 0, SEEK_SET);
memblock = (char*) SDL_malloc(size);
if (memblock == NULL)
{
VVV_exit(1);
}
fread(memblock, 1, size, file);
memblock = (char*) SDL_malloc(size);
if (memblock == NULL)
{
VVV_exit(1);
}
fread(memblock, 1, size, file);
fclose(file);
fclose(file);
vlog_info("The complete file size: %li", size);
vlog_info("The complete file size: %li", size);
m_memblocks[numberofHeaders] = memblock;
for (int i = 0; _path[i]; i += 1)
{
m_headers[numberofHeaders].name[i] = _path[i];
}
m_memblocks[numberofHeaders] = memblock;
for (int i = 0; _path[i]; i += 1)
{
m_headers[numberofHeaders].name[i] = _path[i];
}
m_headers[numberofHeaders].valid = true;
m_headers[numberofHeaders].size = size;
numberofHeaders += 1;
}
else
{
vlog_info("Unable to open file");
}
m_headers[numberofHeaders].valid = true;
m_headers[numberofHeaders].size = size;
numberofHeaders += 1;
}
else
{
vlog_info("Unable to open file");
}
}
void binaryBlob::writeBinaryBlob(const char* _name)
{
FILE *file = fopen(_name, "wb");
if (file != NULL)
{
fwrite((char*) &m_headers, 1, sizeof(m_headers), file);
FILE *file = fopen(_name, "wb");
if (file != NULL)
{
fwrite((char*) &m_headers, 1, sizeof(m_headers), file);
for (int i = 0; i < numberofHeaders; i += 1)
{
fwrite(m_memblocks[i], 1, m_headers[i].size, file);
}
for (int i = 0; i < numberofHeaders; i += 1)
{
fwrite(m_memblocks[i], 1, m_headers[i].size, file);
}
fclose(file);
}
else
{
vlog_info("Unable to open new file for writing. Feels bad.");
}
fclose(file);
}
else
{
vlog_info("Unable to open new file for writing. Feels bad.");
}
}
#endif
bool binaryBlob::unPackBinary(const char* name)
{
return FILESYSTEM_loadBinaryBlob(this, name);
return FILESYSTEM_loadBinaryBlob(this, name);
}
void binaryBlob::clear(void)
{
for (size_t i = 0; i < SDL_arraysize(m_headers); i += 1)
{
SDL_free(m_memblocks[i]);
}
SDL_zeroa(m_memblocks);
SDL_zeroa(m_headers);
for (size_t i = 0; i < SDL_arraysize(m_headers); i += 1)
{
SDL_free(m_memblocks[i]);
}
SDL_zeroa(m_memblocks);
SDL_zeroa(m_headers);
}
int binaryBlob::getIndex(const char* _name)
{
for (size_t i = 0; i < SDL_arraysize(m_headers); i += 1)
{
if (SDL_strcmp(_name, m_headers[i].name) == 0 && m_headers[i].valid)
{
return i;
}
}
return -1;
for (size_t i = 0; i < SDL_arraysize(m_headers); i += 1)
{
if (SDL_strcmp(_name, m_headers[i].name) == 0 && m_headers[i].valid)
{
return i;
}
}
return -1;
}
int binaryBlob::getSize(int _index)
{
if (!INBOUNDS_ARR(_index, m_headers))
{
vlog_error("getSize() out-of-bounds!");
return 0;
}
return m_headers[_index].size;
if (!INBOUNDS_ARR(_index, m_headers))
{
vlog_error("getSize() out-of-bounds!");
return 0;
}
return m_headers[_index].size;
}
char* binaryBlob::getAddress(int _index)
{
if (!INBOUNDS_ARR(_index, m_memblocks))
{
vlog_error("getAddress() out-of-bounds!");
return NULL;
}
return m_memblocks[_index];
if (!INBOUNDS_ARR(_index, m_memblocks))
{
vlog_error("getAddress() out-of-bounds!");
return NULL;
}
return m_memblocks[_index];
}
bool binaryBlob::nextExtra(size_t* start)
{
size_t* idx;
size_t* idx;
if (start == NULL)
{
return false;
}
if (start == NULL)
{
return false;
}
for (idx = start; *idx < SDL_arraysize(m_headers); *idx += 1)
{
if (m_headers[*idx].valid
for (idx = start; *idx < SDL_arraysize(m_headers); *idx += 1)
{
if (m_headers[*idx].valid
#define FOREACH_TRACK(_, track_name) && SDL_strcmp(m_headers[*idx].name, "data/" track_name) != 0
TRACK_NAMES(_)
) {
return true;
}
}
return false;
TRACK_NAMES(_)
) {
return true;
}
}
return false;
}
+33 -33
View File
@@ -7,59 +7,59 @@
// #define VVV_COMPILEMUSIC
#define TRACK_NAMES(blob) \
FOREACH_TRACK(blob, "music/0levelcomplete.ogg") \
FOREACH_TRACK(blob, "music/1pushingonwards.ogg") \
FOREACH_TRACK(blob, "music/2positiveforce.ogg") \
FOREACH_TRACK(blob, "music/3potentialforanything.ogg") \
FOREACH_TRACK(blob, "music/4passionforexploring.ogg") \
FOREACH_TRACK(blob, "music/5intermission.ogg") \
FOREACH_TRACK(blob, "music/6presentingvvvvvv.ogg") \
FOREACH_TRACK(blob, "music/7gamecomplete.ogg") \
FOREACH_TRACK(blob, "music/8predestinedfate.ogg") \
FOREACH_TRACK(blob, "music/9positiveforcereversed.ogg") \
FOREACH_TRACK(blob, "music/10popularpotpourri.ogg") \
FOREACH_TRACK(blob, "music/11pipedream.ogg") \
FOREACH_TRACK(blob, "music/12pressurecooker.ogg") \
FOREACH_TRACK(blob, "music/13pacedenergy.ogg") \
FOREACH_TRACK(blob, "music/14piercingthesky.ogg") \
FOREACH_TRACK(blob, "music/predestinedfatefinallevel.ogg")
FOREACH_TRACK(blob, "music/0levelcomplete.ogg") \
FOREACH_TRACK(blob, "music/1pushingonwards.ogg") \
FOREACH_TRACK(blob, "music/2positiveforce.ogg") \
FOREACH_TRACK(blob, "music/3potentialforanything.ogg") \
FOREACH_TRACK(blob, "music/4passionforexploring.ogg") \
FOREACH_TRACK(blob, "music/5intermission.ogg") \
FOREACH_TRACK(blob, "music/6presentingvvvvvv.ogg") \
FOREACH_TRACK(blob, "music/7gamecomplete.ogg") \
FOREACH_TRACK(blob, "music/8predestinedfate.ogg") \
FOREACH_TRACK(blob, "music/9positiveforcereversed.ogg") \
FOREACH_TRACK(blob, "music/10popularpotpourri.ogg") \
FOREACH_TRACK(blob, "music/11pipedream.ogg") \
FOREACH_TRACK(blob, "music/12pressurecooker.ogg") \
FOREACH_TRACK(blob, "music/13pacedenergy.ogg") \
FOREACH_TRACK(blob, "music/14piercingthesky.ogg") \
FOREACH_TRACK(blob, "music/predestinedfatefinallevel.ogg")
struct resourceheader
{
char name[48];
int start_UNUSED;
int size;
bool valid;
char name[48];
int start_UNUSED;
int size;
bool valid;
};
class binaryBlob
{
public:
binaryBlob(void);
binaryBlob(void);
#ifdef VVV_COMPILEMUSIC
void AddFileToBinaryBlob(const char* _path);
void AddFileToBinaryBlob(const char* _path);
void writeBinaryBlob(const char* _name);
void writeBinaryBlob(const char* _name);
#endif
bool unPackBinary(const char* _name);
bool unPackBinary(const char* _name);
int getIndex(const char* _name);
int getIndex(const char* _name);
int getSize(int _index);
int getSize(int _index);
bool nextExtra(size_t* start);
bool nextExtra(size_t* start);
char* getAddress(int _index);
char* getAddress(int _index);
void clear(void);
void clear(void);
static const int max_headers = 128;
static const int max_headers = 128;
int numberofHeaders;
resourceheader m_headers[max_headers];
char* m_memblocks[max_headers];
int numberofHeaders;
resourceheader m_headers[max_headers];
char* m_memblocks[max_headers];
};
+83 -83
View File
@@ -2,102 +2,102 @@
blockclass::blockclass(void)
{
clear();
clear();
}
void blockclass::clear(void)
{
type = 0;
trigger = 0;
type = 0;
trigger = 0;
xp = 0;
yp = 0;
wp = 0;
hp = 0;
rect.x = xp;
rect.y = yp;
rect.w = wp;
rect.h = hp;
xp = 0;
yp = 0;
wp = 0;
hp = 0;
rect.x = xp;
rect.y = yp;
rect.w = wp;
rect.h = hp;
r = 0;
g = 0;
b = 0;
r = 0;
g = 0;
b = 0;
/* std::strings get initialized automatically, but this is */
/* in case this function gets called again after construction */
script.clear();
prompt.clear();
/* std::strings get initialized automatically, but this is */
/* in case this function gets called again after construction */
script.clear();
prompt.clear();
}
void blockclass::rectset(const int xi, const int yi, const int wi, const int hi)
{
rect.x = xi;
rect.y = yi;
rect.w = wi;
rect.h = hi;
rect.x = xi;
rect.y = yi;
rect.w = wi;
rect.h = hi;
}
void blockclass::setblockcolour( std::string col )
{
if (col == "cyan")
{
r = 164;
g = 164;
b = 255;
}
else if (col == "red")
{
r = 255;
g = 60;
b = 60;
}
else if (col == "green")
{
r = 144;
g = 255;
b = 144;
}
else if (col == "yellow")
{
r = 255;
g = 255;
b = 134;
}
else if (col == "blue")
{
r = 95;
g = 95;
b = 255;
}
else if (col == "purple")
{
r = 255;
g = 134;
b = 255;
}
else if (col == "white")
{
r = 244;
g = 244;
b = 244;
}
else if (col == "gray")
{
r = 174;
g = 174;
b = 174;
}
else if (col == "orange")
{
r = 255;
g = 130;
b = 20;
}
else
{
//use a gray
r = 174;
g = 174;
b = 174;
}
if (col == "cyan")
{
r = 164;
g = 164;
b = 255;
}
else if (col == "red")
{
r = 255;
g = 60;
b = 60;
}
else if (col == "green")
{
r = 144;
g = 255;
b = 144;
}
else if (col == "yellow")
{
r = 255;
g = 255;
b = 134;
}
else if (col == "blue")
{
r = 95;
g = 95;
b = 255;
}
else if (col == "purple")
{
r = 255;
g = 134;
b = 255;
}
else if (col == "white")
{
r = 244;
g = 244;
b = 244;
}
else if (col == "gray")
{
r = 174;
g = 174;
b = 174;
}
else if (col == "orange")
{
r = 255;
g = 130;
b = 20;
}
else
{
//use a gray
r = 174;
g = 174;
b = 174;
}
}
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -3,7 +3,7 @@
#include <SDL.h>
#define rn( rx, ry) ((rx) + ((ry) * 100))
#define rn( rx, ry) ((rx) + ((ry) * 100))
class entclass
{
+17 -17
View File
@@ -148,62 +148,62 @@ void entityclass::generateswnwave( int t )
game.swnstate = 9;
game.swndelay = 8;
}
else if (game.swntimer <= 300) //less than 10 seconds
else if (game.swntimer <= 300) //less than 10 seconds
{
game.swnstate = 6;
game.swndelay = 12;
}
else if (game.swntimer <= 360) //less than 12 seconds
else if (game.swntimer <= 360) //less than 12 seconds
{
game.swnstate = 5+game.swnstate2;
game.swndelay = 15;
}
else if (game.swntimer <= 420) //less than 14 seconds
else if (game.swntimer <= 420) //less than 14 seconds
{
game.swnstate = 7+game.swnstate2;
game.swndelay = 15;
}
else if (game.swntimer <= 480) //less than 16 seconds
else if (game.swntimer <= 480) //less than 16 seconds
{
game.swnstate = 5+game.swnstate2;
game.swndelay = 15;
}
else if (game.swntimer <= 540) //less than 18 seconds
else if (game.swntimer <= 540) //less than 18 seconds
{
game.swnstate = 7+game.swnstate2;
game.swndelay = 15;
}
else if (game.swntimer <= 600) //less than 20 seconds
else if (game.swntimer <= 600) //less than 20 seconds
{
game.swnstate = 5+game.swnstate2;
game.swndelay = 15;
}
else if (game.swntimer <= 900) //less than 30 seconds
else if (game.swntimer <= 900) //less than 30 seconds
{
game.swnstate = 4;
game.swndelay = 20;
}
else if (game.swntimer <= 1050) //less than 35 seconds
else if (game.swntimer <= 1050) //less than 35 seconds
{
game.swnstate = 3;
game.swndelay = 10;
}
else if (game.swntimer <= 1200) //less than 40 seconds
else if (game.swntimer <= 1200) //less than 40 seconds
{
game.swnstate = 3;
game.swndelay = 20;
}
else if (game.swntimer <= 1500) //less than 50 seconds
else if (game.swntimer <= 1500) //less than 50 seconds
{
game.swnstate = 2;
game.swndelay = 10;
}
else if (game.swntimer <= 1650) //less than 55 seconds
else if (game.swntimer <= 1650) //less than 55 seconds
{
game.swnstate = 1;
game.swndelay = 15;
}
else if (game.swntimer <= 1800) //less than 60 seconds
else if (game.swntimer <= 1800) //less than 60 seconds
{
game.swnstate = 1;
game.swndelay = 25;
@@ -2778,8 +2778,8 @@ bool entityclass::updateentities( int i )
if (entities[i].state == 1)
{
//happy!
if (INBOUNDS_VEC(k, entities) && entities[k].rule == 6) entities[k].tile = 0;
if (INBOUNDS_VEC(k, entities) && entities[k].rule == 7) entities[k].tile = 6;
if (INBOUNDS_VEC(k, entities) && entities[k].rule == 6) entities[k].tile = 0;
if (INBOUNDS_VEC(k, entities) && entities[k].rule == 7) entities[k].tile = 6;
//Stay close to the hero!
int j = getplayer();
if (INBOUNDS_VEC(j, entities) && entities[j].xp > entities[i].xp + 5)
@@ -3060,7 +3060,7 @@ bool entityclass::updateentities( int i )
entities[i].para = 30;
}
}
else if (entities[i].life == 1)
else if (entities[i].life == 1)
{
//Stand around for a bit
entities[i].para--;
@@ -3096,7 +3096,7 @@ bool entityclass::updateentities( int i )
entities[i].para = 30;
}
}
else if (entities[i].life == 3)
else if (entities[i].life == 3)
{
//Stand around for a bit
entities[i].para--;
@@ -3688,7 +3688,7 @@ void entityclass::animateentities( int _i )
{
entities[_i].drawframe ++;
//if (game.gravitycontrol == 1) {
// entities[_i].drawframe += 6;
// entities[_i].drawframe += 6;
//}
}
+1 -1
View File
@@ -4,7 +4,7 @@
enum
{
GAMEMODE, TITLEMODE, CLICKTOSTART, FOCUSMODE, MAPMODE, TELEPORTERMODE, GAMECOMPLETE, GAMECOMPLETE2, EDITORMODE, PRELOADER
GAMEMODE, TITLEMODE, CLICKTOSTART, FOCUSMODE, MAPMODE, TELEPORTERMODE, GAMECOMPLETE, GAMECOMPLETE2, EDITORMODE, PRELOADER
};
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -8,7 +8,7 @@
int32_t GOG_init(void)
{
return 0;
return 0;
}
void GOG_shutdown(void)
@@ -25,7 +25,7 @@ void GOG_unlockAchievement(const char *name)
int32_t GOG_getAchievementProgress(const char *name)
{
return 0;
return 0;
}
void GOG_setAchievementProgress(const char *name, int32_t stat)
+6 -6
View File
@@ -1396,7 +1396,7 @@ void Game::updatestate(void)
case 80:
//Used to return to menu from the game
if(graphics.fademode == 1) state++;
if(graphics.fademode == 1) state++;
break;
case 81:
quittomenu();
@@ -1457,7 +1457,7 @@ void Game::updatestate(void)
break;
case 83:
frames--;
if(graphics.fademode == 1) state++;
if(graphics.fademode == 1) state++;
break;
case 84:
quittomenu();
@@ -1534,7 +1534,7 @@ void Game::updatestate(void)
case 96:
//Used to return to gravitron to game
if(graphics.fademode == 1) state++;
if(graphics.fademode == 1) state++;
break;
case 97:
returntolab();
@@ -1941,7 +1941,7 @@ void Game::updatestate(void)
#endif
case 1014:
frames--;
if(graphics.fademode == 1) state++;
if(graphics.fademode == 1) state++;
break;
case 1015:
#if !defined(NO_CUSTOM_LEVELS)
@@ -2571,7 +2571,7 @@ void Game::updatestate(void)
break;
case 3100:
if(graphics.fademode == 1) state++;
if(graphics.fademode == 1) state++;
break;
case 3101:
quittomenu();
@@ -2815,7 +2815,7 @@ void Game::updatestate(void)
state++;
break;
case 3521:
if(graphics.fademode == 1) state++;
if(graphics.fademode == 1) state++;
break;
case 3522:
copyndmresults();
File diff suppressed because it is too large Load Diff
+228 -228
View File
@@ -15,350 +15,350 @@
class Graphics
{
public:
void init(void);
void destroy(void);
void init(void);
void destroy(void);
void create_buffers(const SDL_PixelFormat* fmt);
void destroy_buffers(void);
void create_buffers(const SDL_PixelFormat* fmt);
void destroy_buffers(void);
GraphicsResources grphx;
GraphicsResources grphx;
int bfontlen(uint32_t ch);
int font_idx(uint32_t ch);
int bfontlen(uint32_t ch);
int font_idx(uint32_t ch);
bool Makebfont(void);
bool Makebfont(void);
void drawhuetile(int x, int y, int t);
void huetilesetcol(int t);
Uint32 bigchunkygetcol(int t);
void drawhuetile(int x, int y, int t);
void huetilesetcol(int t);
Uint32 bigchunkygetcol(int t);
void drawgravityline(int t);
void drawgravityline(int t);
bool MakeTileArray(void);
bool MakeTileArray(void);
bool MakeSpriteArray(void);
bool MakeSpriteArray(void);
bool maketelearray(void);
bool maketelearray(void);
void drawcoloredtile(int x, int y, int t, int r, int g, int b);
void drawcoloredtile(int x, int y, int t, int r, int g, int b);
void drawmenu(int cr, int cg, int cb, bool levelmenu = false);
void drawmenu(int cr, int cg, int cb, bool levelmenu = false);
void processfade(void);
void setfade(const int amount);
void processfade(void);
void setfade(const int amount);
void drawfade(void);
void drawfade(void);
void setwarprect(int a, int b, int c, int d);
void setwarprect(int a, int b, int c, int d);
void createtextboxreal(
const std::string& t,
int xp,
int yp,
int r,
int g,
int b,
bool flipme
);
void createtextbox(
const std::string& t,
int xp,
int yp,
int r,
int g,
int b
);
void createtextboxflipme(
const std::string& t,
int xp,
int yp,
int r,
int g,
int b
);
void createtextboxreal(
const std::string& t,
int xp,
int yp,
int r,
int g,
int b,
bool flipme
);
void createtextbox(
const std::string& t,
int xp,
int yp,
int r,
int g,
int b
);
void createtextboxflipme(
const std::string& t,
int xp,
int yp,
int r,
int g,
int b
);
void textboxcenterx(void);
void textboxcenterx(void);
int textboxwidth(void);
int textboxwidth(void);
void textboxmoveto(int xo);
void textboxmoveto(int xo);
void textboxcentery(void);
void textboxcentery(void);
void textboxadjust(void);
void textboxadjust(void);
void addline(const std::string& t);
void addline(const std::string& t);
void textboxtimer(int t);
void textboxtimer(int t);
void textboxremove(void);
void textboxremove(void);
void textboxremovefast(void);
void textboxremovefast(void);
void textboxactive(void);
void textboxactive(void);
void drawtextbox(int x, int y, int w, int h, int r, int g, int b);
void drawtextbox(int x, int y, int w, int h, int r, int g, int b);
void drawpixeltextbox(int x, int y, int w, int h, int r, int g, int b);
void drawpixeltextbox(int x, int y, int w, int h, int r, int g, int b);
void drawcrewman(int x, int y, int t, bool act, bool noshift =false);
void drawcrewman(int x, int y, int t, bool act, bool noshift =false);
int crewcolour(const int t);
int crewcolour(const int t);
void cutscenebars(void);
void cutscenebarstimer(void);
void setbars(const int position);
void cutscenebars(void);
void cutscenebarstimer(void);
void setbars(const int position);
void drawpartimage(int t, int xp, int yp, int wp, int hp);
void drawpartimage(int t, int xp, int yp, int wp, int hp);
void drawimage(int t, int xp, int yp, bool cent=false);
void drawimage(int t, int xp, int yp, bool cent=false);
void drawimagecol(int t, int xp, int yp, int r, int g, int b, bool cent= false);
void drawimagecol(int t, int xp, int yp, int r, int g, int b, bool cent= false);
void updatetextboxes(void);
void drawgui(void);
void updatetextboxes(void);
void drawgui(void);
void drawsprite(int x, int y, int t, int r, int g, int b);
void drawsprite(int x, int y, int t, Uint32 c);
void drawsprite(int x, int y, int t, int r, int g, int b);
void drawsprite(int x, int y, int t, Uint32 c);
void printcrewname(int x, int y, int t);
void printcrewname(int x, int y, int t);
void printcrewnamestatus(int x, int y, int t);
void printcrewnamestatus(int x, int y, int t);
void printcrewnamedark(int x, int y, int t);
void printcrewnamedark(int x, int y, int t);
void map_tab(int opt, const std::string& text, bool selected = false);
void map_tab(int opt, const std::string& text, bool selected = false);
void map_option(int opt, int num_opts, const std::string& text, bool selected = false);
void map_option(int opt, int num_opts, const std::string& text, bool selected = false);
void do_print(int x, int y, const std::string& text, int r, int g, int b, int a, int scale);
void do_print(int x, int y, const std::string& text, int r, int g, int b, int a, int scale);
void Print(int _x, int _y, const std::string& _s, int r, int g, int b, bool cen = false);
void Print(int _x, int _y, const std::string& _s, int r, int g, int b, bool cen = false);
void PrintAlpha(int _x, int _y, const std::string& _s, int r, int g, int b, int a, bool cen = false);
void PrintAlpha(int _x, int _y, const std::string& _s, int r, int g, int b, int a, bool cen = false);
bool next_wrap(size_t* start, size_t* len, const char* str, int maxwidth);
bool next_wrap(size_t* start, size_t* len, const char* str, int maxwidth);
bool next_wrap_s(char buffer[], size_t buffer_size, size_t* start, const char* str, int maxwidth);
bool next_wrap_s(char buffer[], size_t buffer_size, size_t* start, const char* str, int maxwidth);
void PrintWrap(int x, int y, const char* str, int r, int g, int b, bool cen, int linespacing, int maxwidth);
void PrintWrap(int x, int y, const char* str, int r, int g, int b, bool cen, int linespacing, int maxwidth);
void bprint(int x, int y, const std::string& t, int r, int g, int b, bool cen = false);
void bprint(int x, int y, const std::string& t, int r, int g, int b, bool cen = false);
void bprintalpha(int x, int y, const std::string& t, int r, int g, int b, int a, bool cen = false);
void bprintalpha(int x, int y, const std::string& t, int r, int g, int b, int a, bool cen = false);
int len(const std::string& t);
void bigprint( int _x, int _y, const std::string& _s, int r, int g, int b, bool cen = false, int sc = 2 );
void bigbprint(int x, int y, const std::string& s, int r, int g, int b, bool cen = false, int sc = 2);
void drawspritesetcol(int x, int y, int t, int c);
int len(const std::string& t);
void bigprint( int _x, int _y, const std::string& _s, int r, int g, int b, bool cen = false, int sc = 2 );
void bigbprint(int x, int y, const std::string& s, int r, int g, int b, bool cen = false, int sc = 2);
void drawspritesetcol(int x, int y, int t, int c);
void flashlight(void);
void screenshake(void);
void updatescreenshake(void);
void flashlight(void);
void screenshake(void);
void updatescreenshake(void);
int screenshake_x;
int screenshake_y;
int screenshake_x;
int screenshake_y;
void render(void);
void renderwithscreeneffects(void);
void renderfixedpre(void);
void renderfixedpost(void);
void render(void);
void renderwithscreeneffects(void);
void renderfixedpre(void);
void renderfixedpost(void);
bool Hitest(SDL_Surface* surface1, point p1, SDL_Surface* surface2, point p2);
bool Hitest(SDL_Surface* surface1, point p1, SDL_Surface* surface2, point p2);
void drawentities(void);
void drawentities(void);
void drawentity(const int i, const int yoff);
void drawentity(const int i, const int yoff);
void drawtrophytext(void);
void drawtrophytext(void);
void bigrprint(int x, int y, const std::string& t, int r, int g, int b, bool cen = false, float sc = 2);
void bigbrprint(int x, int y, const std::string& t, int r, int g, int b, bool cen = false, float sc = 2);
void bigrprint(int x, int y, const std::string& t, int r, int g, int b, bool cen = false, float sc = 2);
void bigbrprint(int x, int y, const std::string& t, int r, int g, int b, bool cen = false, float sc = 2);
void drawtele(int x, int y, int t, Uint32 c);
void drawtele(int x, int y, int t, Uint32 c);
Uint32 getRGBA(Uint8 r, Uint8 g, Uint8 b, Uint8 a);
Uint32 getRGBA(Uint8 r, Uint8 g, Uint8 b, Uint8 a);
Uint32 getRGB(Uint8 r, Uint8 g, Uint8 b);
Uint32 getRGB(Uint8 r, Uint8 g, Uint8 b);
Uint32 getBGR(Uint8 r, Uint8 g, Uint8 b);
Uint32 getBGR(Uint8 r, Uint8 g, Uint8 b);
Uint32 getRGB(Uint32 _col);
Uint32 getRGB(Uint32 _col);
Uint32 RGBflip(Uint8 r, Uint8 g, Uint8 b);
Uint32 RGBflip(Uint8 r, Uint8 g, Uint8 b);
Uint32 RGBf(int r, int g, int b);
Uint32 RGBf(int r, int g, int b);
void setcolreal(Uint32 t);
void setcolreal(Uint32 t);
void drawbackground(int t);
void updatebackground(int t);
void drawbackground(int t);
void updatebackground(int t);
#ifndef NO_CUSTOM_LEVELS
bool shouldrecoloroneway(const int tilenum, const bool mounted);
bool shouldrecoloroneway(const int tilenum, const bool mounted);
#endif
void drawtile3( int x, int y, int t, int off, int height_subtract = 0 );
void drawtile2( int x, int y, int t );
void drawtile( int x, int y, int t );
void drawtowertile( int x, int y, int t );
void drawtowertile3( int x, int y, int t, TowerBG& bg_obj );
void drawtile3( int x, int y, int t, int off, int height_subtract = 0 );
void drawtile2( int x, int y, int t );
void drawtile( int x, int y, int t );
void drawtowertile( int x, int y, int t );
void drawtowertile3( int x, int y, int t, TowerBG& bg_obj );
void drawmap(void);
void drawmap(void);
void drawforetile(int x, int y, int t);
void drawforetile(int x, int y, int t);
void drawforetile2(int x, int y, int t);
void drawforetile2(int x, int y, int t);
void drawforetile3(int x, int y, int t, int off);
void drawforetile3(int x, int y, int t, int off);
void drawrect(int x, int y, int w, int h, int r, int g, int b);
void drawrect(int x, int y, int w, int h, int r, int g, int b);
void drawtowermap(void);
void drawtowermap(void);
void drawtowerspikes(void);
void drawtowerspikes(void);
bool onscreen(int t);
bool onscreen(int t);
bool reloadresources(void);
bool reloadresources(void);
#ifndef NO_CUSTOM_LEVELS
bool tiles1_mounted;
bool tiles2_mounted;
bool minimap_mounted;
bool tiles1_mounted;
bool tiles2_mounted;
bool minimap_mounted;
#endif
void menuoffrender(void);
void menuoffrender(void);
void drawtowerbackground(const TowerBG& bg_obj);
void updatetowerbackground(TowerBG& bg_obj);
void drawtowerbackground(const TowerBG& bg_obj);
void updatetowerbackground(TowerBG& bg_obj);
void setcol(int t);
void drawfinalmap(void);
void setcol(int t);
void drawfinalmap(void);
colourTransform ct;
colourTransform ct;
int rcol;
int rcol;
int m;
int m;
std::vector <SDL_Surface*> images;
std::vector <SDL_Surface*> images;
std::vector <SDL_Surface*> tele;
std::vector <SDL_Surface*> tiles;
std::vector <SDL_Surface*> tiles2;
std::vector <SDL_Surface*> tiles3;
std::vector <SDL_Surface*> entcolours;
std::vector <SDL_Surface*> sprites;
std::vector <SDL_Surface*> flipsprites;
std::vector <SDL_Surface*> bfont;
std::vector <SDL_Surface*> flipbfont;
std::vector <SDL_Surface*> tele;
std::vector <SDL_Surface*> tiles;
std::vector <SDL_Surface*> tiles2;
std::vector <SDL_Surface*> tiles3;
std::vector <SDL_Surface*> entcolours;
std::vector <SDL_Surface*> sprites;
std::vector <SDL_Surface*> flipsprites;
std::vector <SDL_Surface*> bfont;
std::vector <SDL_Surface*> flipbfont;
bool flipmode;
bool setflipmode;
bool notextoutline;
//buffer objects. //TODO refactor buffer objects
SDL_Surface* backBuffer;
Screen* screenbuffer;
SDL_Surface* menubuffer;
SDL_Surface* foregroundBuffer;
SDL_Surface* tempBuffer;
SDL_Surface* warpbuffer;
SDL_Surface* warpbuffer_lerp;
bool flipmode;
bool setflipmode;
bool notextoutline;
//buffer objects. //TODO refactor buffer objects
SDL_Surface* backBuffer;
Screen* screenbuffer;
SDL_Surface* menubuffer;
SDL_Surface* foregroundBuffer;
SDL_Surface* tempBuffer;
SDL_Surface* warpbuffer;
SDL_Surface* warpbuffer_lerp;
TowerBG towerbg;
TowerBG titlebg;
TowerBG towerbg;
TowerBG titlebg;
SDL_Rect bfont_rect;
SDL_Rect tiles_rect;
SDL_Rect sprites_rect;
SDL_Rect images_rect;
SDL_Rect bg_rect;
SDL_Rect line_rect;
SDL_Rect tele_rect;
SDL_Rect towerbuffer_rect;
SDL_Rect bfont_rect;
SDL_Rect tiles_rect;
SDL_Rect sprites_rect;
SDL_Rect images_rect;
SDL_Rect bg_rect;
SDL_Rect line_rect;
SDL_Rect tele_rect;
SDL_Rect towerbuffer_rect;
SDL_Rect foot_rect;
SDL_Rect prect;
SDL_Rect footerrect;
SDL_Surface* footerbuffer;
SDL_Rect foot_rect;
SDL_Rect prect;
SDL_Rect footerrect;
SDL_Surface* footerbuffer;
int linestate, linedelay;
int backoffset;
bool backgrounddrawn, foregrounddrawn;
int linestate, linedelay;
int backoffset;
bool backgrounddrawn, foregrounddrawn;
int menuoffset;
int oldmenuoffset;
bool resumegamemode;
int menuoffset;
int oldmenuoffset;
bool resumegamemode;
SDL_Rect warprect;
SDL_Rect warprect;
int crewframe;
int crewframedelay;
int crewframe;
int crewframedelay;
int fademode;
int fadeamount;
int oldfadeamount;
int fadebars[15];
int ingame_fademode;
int fademode;
int fadeamount;
int oldfadeamount;
int fadebars[15];
int ingame_fademode;
bool trinketcolset;
int trinketr, trinketg, trinketb;
bool trinketcolset;
int trinketr, trinketg, trinketb;
std::vector <textboxclass> textbox;
std::vector <textboxclass> textbox;
bool showcutscenebars;
int cutscenebarspos;
int oldcutscenebarspos;
bool showcutscenebars;
int cutscenebarspos;
int oldcutscenebarspos;
static const int numstars = 50;
SDL_Rect stars[numstars];
int starsspeed[numstars];
static const int numstars = 50;
SDL_Rect stars[numstars];
int starsspeed[numstars];
static const int numbackboxes = 18;
int spcol, spcoldel;
SDL_Rect backboxes[numbackboxes];
int backboxvx[numbackboxes];
int backboxvy[numbackboxes];
float backboxint[numbackboxes];
static const int numbackboxes = 18;
int spcol, spcoldel;
SDL_Rect backboxes[numbackboxes];
int backboxvx[numbackboxes];
int backboxvy[numbackboxes];
float backboxint[numbackboxes];
int warpskip, warpfcol, warpbcol;
int warpskip, warpfcol, warpbcol;
bool translucentroomname;
bool translucentroomname;
std::map<int, int> font_positions;
std::map<int, int> font_positions;
SDL_Surface* ghostbuffer;
SDL_Surface* ghostbuffer;
float inline lerp(const float v0, const float v1)
{
return v0 + alpha * (v1 - v0);
}
float alpha;
float inline lerp(const float v0, const float v1)
{
return v0 + alpha * (v1 - v0);
}
float alpha;
Uint32 col_crewred;
Uint32 col_crewyellow;
Uint32 col_crewgreen;
Uint32 col_crewcyan;
Uint32 col_crewblue;
Uint32 col_crewpurple; //actually pink
Uint32 col_crewinactive;
Uint32 col_clock;
Uint32 col_trinket;
int col_tr;
int col_tg;
int col_tb;
void updatetitlecolours(void);
Uint32 col_crewred;
Uint32 col_crewyellow;
Uint32 col_crewgreen;
Uint32 col_crewcyan;
Uint32 col_crewblue;
Uint32 col_crewpurple; //actually pink
Uint32 col_crewinactive;
Uint32 col_clock;
Uint32 col_trinket;
int col_tr;
int col_tg;
int col_tb;
void updatetitlecolours(void);
bool kludgeswnlinewidth;
bool kludgeswnlinewidth;
Uint32 crewcolourreal(int t);
Uint32 crewcolourreal(int t);
char error[128];
char error_title[128]; /* for SDL_ShowSimpleMessageBox */
char error[128];
char error_title[128]; /* for SDL_ShowSimpleMessageBox */
};
#ifndef GRAPHICS_DEFINITION
+114 -114
View File
@@ -6,140 +6,140 @@
// Used to load PNG data
extern "C"
{
extern unsigned lodepng_decode24(
unsigned char** out,
unsigned* w,
unsigned* h,
const unsigned char* in,
size_t insize
);
extern unsigned lodepng_decode32(
unsigned char** out,
unsigned* w,
unsigned* h,
const unsigned char* in,
size_t insize
);
extern unsigned lodepng_decode24(
unsigned char** out,
unsigned* w,
unsigned* h,
const unsigned char* in,
size_t insize
);
extern unsigned lodepng_decode32(
unsigned char** out,
unsigned* w,
unsigned* h,
const unsigned char* in,
size_t insize
);
}
static SDL_Surface* LoadImage(const char *filename, bool noBlend = true, bool noAlpha = false)
{
//Temporary storage for the image that's loaded
SDL_Surface* loadedImage = NULL;
//The optimized image that will be used
SDL_Surface* optimizedImage = NULL;
//Temporary storage for the image that's loaded
SDL_Surface* loadedImage = NULL;
//The optimized image that will be used
SDL_Surface* optimizedImage = NULL;
unsigned char *data;
unsigned int width, height;
unsigned char *data;
unsigned int width, height;
unsigned char *fileIn;
size_t length;
FILESYSTEM_loadAssetToMemory(filename, &fileIn, &length, false);
if (fileIn == NULL)
{
SDL_assert(0 && "Image file missing!");
return NULL;
}
if (noAlpha)
{
lodepng_decode24(&data, &width, &height, fileIn, length);
}
else
{
lodepng_decode32(&data, &width, &height, fileIn, length);
}
FILESYSTEM_freeMemory(&fileIn);
unsigned char *fileIn;
size_t length;
FILESYSTEM_loadAssetToMemory(filename, &fileIn, &length, false);
if (fileIn == NULL)
{
SDL_assert(0 && "Image file missing!");
return NULL;
}
if (noAlpha)
{
lodepng_decode24(&data, &width, &height, fileIn, length);
}
else
{
lodepng_decode32(&data, &width, &height, fileIn, length);
}
FILESYSTEM_freeMemory(&fileIn);
loadedImage = SDL_CreateRGBSurfaceFrom(
data,
width,
height,
noAlpha ? 24 : 32,
width * (noAlpha ? 3 : 4),
0x000000FF,
0x0000FF00,
0x00FF0000,
noAlpha ? 0x00000000 : 0xFF000000
);
loadedImage = SDL_CreateRGBSurfaceFrom(
data,
width,
height,
noAlpha ? 24 : 32,
width * (noAlpha ? 3 : 4),
0x000000FF,
0x0000FF00,
0x00FF0000,
noAlpha ? 0x00000000 : 0xFF000000
);
if (loadedImage != NULL)
{
optimizedImage = SDL_ConvertSurfaceFormat(
loadedImage,
SDL_PIXELFORMAT_ABGR8888, // FIXME: Format? -flibit
0
);
SDL_FreeSurface( loadedImage );
SDL_free(data);
if (noBlend)
{
SDL_SetSurfaceBlendMode(optimizedImage, SDL_BLENDMODE_BLEND);
}
return optimizedImage;
}
else
{
SDL_free(data);
vlog_error("Image not found: %s", filename);
SDL_assert(0 && "Image not found! See stderr.");
return NULL;
}
if (loadedImage != NULL)
{
optimizedImage = SDL_ConvertSurfaceFormat(
loadedImage,
SDL_PIXELFORMAT_ABGR8888, // FIXME: Format? -flibit
0
);
SDL_FreeSurface( loadedImage );
SDL_free(data);
if (noBlend)
{
SDL_SetSurfaceBlendMode(optimizedImage, SDL_BLENDMODE_BLEND);
}
return optimizedImage;
}
else
{
SDL_free(data);
vlog_error("Image not found: %s", filename);
SDL_assert(0 && "Image not found! See stderr.");
return NULL;
}
}
void GraphicsResources::init(void)
{
im_tiles = LoadImage("graphics/tiles.png");
im_tiles2 = LoadImage("graphics/tiles2.png");
im_tiles3 = LoadImage("graphics/tiles3.png");
im_entcolours = LoadImage("graphics/entcolours.png");
im_sprites = LoadImage("graphics/sprites.png");
im_flipsprites = LoadImage("graphics/flipsprites.png");
im_bfont = LoadImage("graphics/font.png");
im_teleporter = LoadImage("graphics/teleporter.png");
im_tiles = LoadImage("graphics/tiles.png");
im_tiles2 = LoadImage("graphics/tiles2.png");
im_tiles3 = LoadImage("graphics/tiles3.png");
im_entcolours = LoadImage("graphics/entcolours.png");
im_sprites = LoadImage("graphics/sprites.png");
im_flipsprites = LoadImage("graphics/flipsprites.png");
im_bfont = LoadImage("graphics/font.png");
im_teleporter = LoadImage("graphics/teleporter.png");
im_image0 = LoadImage("graphics/levelcomplete.png", false);
im_image1 = LoadImage("graphics/minimap.png", true, true);
im_image2 = LoadImage("graphics/covered.png", true, true);
im_image3 = LoadImage("graphics/elephant.png");
im_image4 = LoadImage("graphics/gamecomplete.png", false);
im_image5 = LoadImage("graphics/fliplevelcomplete.png", false);
im_image6 = LoadImage("graphics/flipgamecomplete.png", false);
im_image7 = LoadImage("graphics/site.png", false);
im_image8 = LoadImage("graphics/site2.png");
im_image9 = LoadImage("graphics/site3.png");
im_image10 = LoadImage("graphics/ending.png");
im_image11 = LoadImage("graphics/site4.png");
im_image12 = LoadImage("graphics/minimap.png");
im_image0 = LoadImage("graphics/levelcomplete.png", false);
im_image1 = LoadImage("graphics/minimap.png", true, true);
im_image2 = LoadImage("graphics/covered.png", true, true);
im_image3 = LoadImage("graphics/elephant.png");
im_image4 = LoadImage("graphics/gamecomplete.png", false);
im_image5 = LoadImage("graphics/fliplevelcomplete.png", false);
im_image6 = LoadImage("graphics/flipgamecomplete.png", false);
im_image7 = LoadImage("graphics/site.png", false);
im_image8 = LoadImage("graphics/site2.png");
im_image9 = LoadImage("graphics/site3.png");
im_image10 = LoadImage("graphics/ending.png");
im_image11 = LoadImage("graphics/site4.png");
im_image12 = LoadImage("graphics/minimap.png");
}
void GraphicsResources::destroy(void)
{
#define CLEAR(img) \
SDL_FreeSurface(img); \
img = NULL;
SDL_FreeSurface(img); \
img = NULL;
CLEAR(im_tiles);
CLEAR(im_tiles2);
CLEAR(im_tiles3);
CLEAR(im_entcolours);
CLEAR(im_sprites);
CLEAR(im_flipsprites);
CLEAR(im_bfont);
CLEAR(im_teleporter);
CLEAR(im_tiles);
CLEAR(im_tiles2);
CLEAR(im_tiles3);
CLEAR(im_entcolours);
CLEAR(im_sprites);
CLEAR(im_flipsprites);
CLEAR(im_bfont);
CLEAR(im_teleporter);
CLEAR(im_image0);
CLEAR(im_image1);
CLEAR(im_image2);
CLEAR(im_image3);
CLEAR(im_image4);
CLEAR(im_image5);
CLEAR(im_image6);
CLEAR(im_image7);
CLEAR(im_image8);
CLEAR(im_image9);
CLEAR(im_image10);
CLEAR(im_image11);
CLEAR(im_image12);
CLEAR(im_image0);
CLEAR(im_image1);
CLEAR(im_image2);
CLEAR(im_image3);
CLEAR(im_image4);
CLEAR(im_image5);
CLEAR(im_image6);
CLEAR(im_image7);
CLEAR(im_image8);
CLEAR(im_image9);
CLEAR(im_image10);
CLEAR(im_image11);
CLEAR(im_image12);
#undef CLEAR
}
+7 -7
View File
@@ -1013,49 +1013,49 @@ static void menuactionpress(void)
case Menu::unlockmenutrials:
switch (game.currentmenuoption)
{
case 0: //unlock 1
case 0: //unlock 1
game.unlock[9] = true;
game.unlocknotify[9] = true;
music.playef(11);
game.createmenu(Menu::unlockmenutrials, true);
game.savestatsandsettings_menu();
break;
case 1: //unlock 2
case 1: //unlock 2
game.unlock[10] = true;
game.unlocknotify[10] = true;
music.playef(11);
game.createmenu(Menu::unlockmenutrials, true);
game.savestatsandsettings_menu();
break;
case 2: //unlock 3
case 2: //unlock 3
game.unlock[11] = true;
game.unlocknotify[11] = true;
music.playef(11);
game.createmenu(Menu::unlockmenutrials, true);
game.savestatsandsettings_menu();
break;
case 3: //unlock 4
case 3: //unlock 4
game.unlock[12] = true;
game.unlocknotify[12] = true;
music.playef(11);
game.createmenu(Menu::unlockmenutrials, true);
game.savestatsandsettings_menu();
break;
case 4: //unlock 5
case 4: //unlock 5
game.unlock[13] = true;
game.unlocknotify[13] = true;
music.playef(11);
game.createmenu(Menu::unlockmenutrials, true);
game.savestatsandsettings_menu();
break;
case 5: //unlock 6
case 5: //unlock 6
game.unlock[14] = true;
game.unlocknotify[14] = true;
music.playef(11);
game.createmenu(Menu::unlockmenutrials, true);
game.savestatsandsettings_menu();
break;
case 6: //back
case 6: //back
//back
music.playef(11);
game.returnmenu();
+377 -377
View File
@@ -13,464 +13,464 @@
int inline KeyPoll::getThreshold(void)
{
switch (sensitivity)
{
case 0:
return 28000;
case 1:
return 16000;
case 2:
return 8000;
case 3:
return 4000;
case 4:
return 2000;
}
switch (sensitivity)
{
case 0:
return 28000;
case 1:
return 16000;
case 2:
return 8000;
case 3:
return 4000;
case 4:
return 2000;
}
return 8000;
return 8000;
}
KeyPoll::KeyPoll(void)
{
xVel = 0;
yVel = 0;
// 0..5
sensitivity = 2;
xVel = 0;
yVel = 0;
// 0..5
sensitivity = 2;
keybuffer="";
leftbutton=0; rightbutton=0; middlebutton=0;
mx=0; my=0;
resetWindow = 0;
pressedbackspace=false;
keybuffer="";
leftbutton=0; rightbutton=0; middlebutton=0;
mx=0; my=0;
resetWindow = 0;
pressedbackspace=false;
linealreadyemptykludge = false;
linealreadyemptykludge = false;
isActive = true;
isActive = true;
}
void KeyPoll::enabletextentry(void)
{
keybuffer="";
SDL_StartTextInput();
keybuffer="";
SDL_StartTextInput();
}
void KeyPoll::disabletextentry(void)
{
SDL_StopTextInput();
SDL_StopTextInput();
}
bool KeyPoll::textentry(void)
{
return SDL_IsTextInputActive() == SDL_TRUE;
return SDL_IsTextInputActive() == SDL_TRUE;
}
void KeyPoll::toggleFullscreen(void)
{
if (graphics.screenbuffer != NULL)
{
graphics.screenbuffer->toggleFullScreen();
}
if (graphics.screenbuffer != NULL)
{
graphics.screenbuffer->toggleFullScreen();
}
keymap.clear(); /* we lost the input due to a new window. */
if (GlitchrunnerMode_less_than_or_equal(Glitchrunner2_2))
{
game.press_left = false;
game.press_right = false;
game.press_action = true;
game.press_map = false;
}
keymap.clear(); /* we lost the input due to a new window. */
if (GlitchrunnerMode_less_than_or_equal(Glitchrunner2_2))
{
game.press_left = false;
game.press_right = false;
game.press_action = true;
game.press_map = false;
}
}
static int changemousestate(
int timeout,
const bool show,
const bool hide
int timeout,
const bool show,
const bool hide
) {
int prev;
int new_;
int prev;
int new_;
if (timeout > 0)
{
return --timeout;
}
if (timeout > 0)
{
return --timeout;
}
/* If we want to both show and hide at the same time, prioritize showing */
if (show)
{
new_ = SDL_ENABLE;
}
else if (hide)
{
new_ = SDL_DISABLE;
}
else
{
return timeout;
}
/* If we want to both show and hide at the same time, prioritize showing */
if (show)
{
new_ = SDL_ENABLE;
}
else if (hide)
{
new_ = SDL_DISABLE;
}
else
{
return timeout;
}
prev = SDL_ShowCursor(SDL_QUERY);
prev = SDL_ShowCursor(SDL_QUERY);
if (prev == new_)
{
return timeout;
}
if (prev == new_)
{
return timeout;
}
SDL_ShowCursor(new_);
SDL_ShowCursor(new_);
switch (new_)
{
case SDL_DISABLE:
timeout = 0;
break;
case SDL_ENABLE:
timeout = 30;
break;
}
switch (new_)
{
case SDL_DISABLE:
timeout = 0;
break;
case SDL_ENABLE:
timeout = 30;
break;
}
return timeout;
return timeout;
}
void KeyPoll::Poll(void)
{
static int mousetoggletimeout = 0;
bool showmouse = false;
bool hidemouse = false;
bool altpressed = false;
bool fullscreenkeybind = false;
SDL_Event evt;
while (SDL_PollEvent(&evt))
{
switch (evt.type)
{
/* Keyboard Input */
case SDL_KEYDOWN:
{
keymap[evt.key.keysym.sym] = true;
static int mousetoggletimeout = 0;
bool showmouse = false;
bool hidemouse = false;
bool altpressed = false;
bool fullscreenkeybind = false;
SDL_Event evt;
while (SDL_PollEvent(&evt))
{
switch (evt.type)
{
/* Keyboard Input */
case SDL_KEYDOWN:
{
keymap[evt.key.keysym.sym] = true;
if (evt.key.keysym.sym == SDLK_BACKSPACE)
{
pressedbackspace = true;
}
if (evt.key.keysym.sym == SDLK_BACKSPACE)
{
pressedbackspace = true;
}
#ifdef __APPLE__ /* OSX prefers the command keys over the alt keys. -flibit */
altpressed = keymap[SDLK_LGUI] || keymap[SDLK_RGUI];
altpressed = keymap[SDLK_LGUI] || keymap[SDLK_RGUI];
#else
altpressed = keymap[SDLK_LALT] || keymap[SDLK_RALT];
altpressed = keymap[SDLK_LALT] || keymap[SDLK_RALT];
#endif
bool returnpressed = evt.key.keysym.sym == SDLK_RETURN;
bool fpressed = evt.key.keysym.sym == SDLK_f;
bool f11pressed = evt.key.keysym.sym == SDLK_F11;
if ((altpressed && (returnpressed || fpressed)) || f11pressed)
{
fullscreenkeybind = true;
}
bool returnpressed = evt.key.keysym.sym == SDLK_RETURN;
bool fpressed = evt.key.keysym.sym == SDLK_f;
bool f11pressed = evt.key.keysym.sym == SDLK_F11;
if ((altpressed && (returnpressed || fpressed)) || f11pressed)
{
fullscreenkeybind = true;
}
if (textentry())
{
if (evt.key.keysym.sym == SDLK_BACKSPACE && !keybuffer.empty())
{
std::string::iterator iter = keybuffer.end();
utf8::unchecked::prior(iter);
keybuffer = keybuffer.substr(0, iter - keybuffer.begin());
if (keybuffer.empty())
{
linealreadyemptykludge = true;
}
}
else if ( evt.key.keysym.sym == SDLK_v &&
keymap[SDLK_LCTRL] )
{
char* text = SDL_GetClipboardText();
if (text != NULL)
{
keybuffer += text;
SDL_free(text);
}
}
}
break;
}
case SDL_KEYUP:
keymap[evt.key.keysym.sym] = false;
if (evt.key.keysym.sym == SDLK_BACKSPACE)
{
pressedbackspace = false;
}
break;
case SDL_TEXTINPUT:
if (!altpressed)
{
keybuffer += evt.text.text;
}
break;
if (textentry())
{
if (evt.key.keysym.sym == SDLK_BACKSPACE && !keybuffer.empty())
{
std::string::iterator iter = keybuffer.end();
utf8::unchecked::prior(iter);
keybuffer = keybuffer.substr(0, iter - keybuffer.begin());
if (keybuffer.empty())
{
linealreadyemptykludge = true;
}
}
else if ( evt.key.keysym.sym == SDLK_v &&
keymap[SDLK_LCTRL] )
{
char* text = SDL_GetClipboardText();
if (text != NULL)
{
keybuffer += text;
SDL_free(text);
}
}
}
break;
}
case SDL_KEYUP:
keymap[evt.key.keysym.sym] = false;
if (evt.key.keysym.sym == SDLK_BACKSPACE)
{
pressedbackspace = false;
}
break;
case SDL_TEXTINPUT:
if (!altpressed)
{
keybuffer += evt.text.text;
}
break;
/* Mouse Input */
case SDL_MOUSEMOTION:
mx = evt.motion.x;
my = evt.motion.y;
break;
case SDL_MOUSEBUTTONDOWN:
switch (evt.button.button)
{
case SDL_BUTTON_LEFT:
mx = evt.button.x;
my = evt.button.y;
leftbutton = 1;
break;
case SDL_BUTTON_RIGHT:
mx = evt.button.x;
my = evt.button.y;
rightbutton = 1;
break;
case SDL_BUTTON_MIDDLE:
mx = evt.button.x;
my = evt.button.y;
middlebutton = 1;
break;
}
break;
case SDL_MOUSEBUTTONUP:
switch (evt.button.button)
{
case SDL_BUTTON_LEFT:
mx = evt.button.x;
my = evt.button.y;
leftbutton=0;
break;
case SDL_BUTTON_RIGHT:
mx = evt.button.x;
my = evt.button.y;
rightbutton=0;
break;
case SDL_BUTTON_MIDDLE:
mx = evt.button.x;
my = evt.button.y;
middlebutton=0;
break;
}
break;
/* Mouse Input */
case SDL_MOUSEMOTION:
mx = evt.motion.x;
my = evt.motion.y;
break;
case SDL_MOUSEBUTTONDOWN:
switch (evt.button.button)
{
case SDL_BUTTON_LEFT:
mx = evt.button.x;
my = evt.button.y;
leftbutton = 1;
break;
case SDL_BUTTON_RIGHT:
mx = evt.button.x;
my = evt.button.y;
rightbutton = 1;
break;
case SDL_BUTTON_MIDDLE:
mx = evt.button.x;
my = evt.button.y;
middlebutton = 1;
break;
}
break;
case SDL_MOUSEBUTTONUP:
switch (evt.button.button)
{
case SDL_BUTTON_LEFT:
mx = evt.button.x;
my = evt.button.y;
leftbutton=0;
break;
case SDL_BUTTON_RIGHT:
mx = evt.button.x;
my = evt.button.y;
rightbutton=0;
break;
case SDL_BUTTON_MIDDLE:
mx = evt.button.x;
my = evt.button.y;
middlebutton=0;
break;
}
break;
/* Controller Input */
case SDL_CONTROLLERBUTTONDOWN:
buttonmap[(SDL_GameControllerButton) evt.cbutton.button] = true;
break;
case SDL_CONTROLLERBUTTONUP:
buttonmap[(SDL_GameControllerButton) evt.cbutton.button] = false;
break;
case SDL_CONTROLLERAXISMOTION:
{
const int threshold = getThreshold();
switch (evt.caxis.axis)
{
case SDL_CONTROLLER_AXIS_LEFTX:
if ( evt.caxis.value > -threshold &&
evt.caxis.value < threshold )
{
xVel = 0;
}
else
{
xVel = (evt.caxis.value > 0) ? 1 : -1;
}
break;
case SDL_CONTROLLER_AXIS_LEFTY:
if ( evt.caxis.value > -threshold &&
evt.caxis.value < threshold )
{
yVel = 0;
}
else
{
yVel = (evt.caxis.value > 0) ? 1 : -1;
}
break;
}
break;
}
case SDL_CONTROLLERDEVICEADDED:
{
SDL_GameController *toOpen = SDL_GameControllerOpen(evt.cdevice.which);
vlog_info(
"Opened SDL_GameController ID #%i, %s",
evt.cdevice.which,
SDL_GameControllerName(toOpen)
);
controllers[SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(toOpen))] = toOpen;
break;
}
case SDL_CONTROLLERDEVICEREMOVED:
{
SDL_GameController *toClose = controllers[evt.cdevice.which];
controllers.erase(evt.cdevice.which);
vlog_info("Closing %s", SDL_GameControllerName(toClose));
SDL_GameControllerClose(toClose);
break;
}
/* Controller Input */
case SDL_CONTROLLERBUTTONDOWN:
buttonmap[(SDL_GameControllerButton) evt.cbutton.button] = true;
break;
case SDL_CONTROLLERBUTTONUP:
buttonmap[(SDL_GameControllerButton) evt.cbutton.button] = false;
break;
case SDL_CONTROLLERAXISMOTION:
{
const int threshold = getThreshold();
switch (evt.caxis.axis)
{
case SDL_CONTROLLER_AXIS_LEFTX:
if ( evt.caxis.value > -threshold &&
evt.caxis.value < threshold )
{
xVel = 0;
}
else
{
xVel = (evt.caxis.value > 0) ? 1 : -1;
}
break;
case SDL_CONTROLLER_AXIS_LEFTY:
if ( evt.caxis.value > -threshold &&
evt.caxis.value < threshold )
{
yVel = 0;
}
else
{
yVel = (evt.caxis.value > 0) ? 1 : -1;
}
break;
}
break;
}
case SDL_CONTROLLERDEVICEADDED:
{
SDL_GameController *toOpen = SDL_GameControllerOpen(evt.cdevice.which);
vlog_info(
"Opened SDL_GameController ID #%i, %s",
evt.cdevice.which,
SDL_GameControllerName(toOpen)
);
controllers[SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(toOpen))] = toOpen;
break;
}
case SDL_CONTROLLERDEVICEREMOVED:
{
SDL_GameController *toClose = controllers[evt.cdevice.which];
controllers.erase(evt.cdevice.which);
vlog_info("Closing %s", SDL_GameControllerName(toClose));
SDL_GameControllerClose(toClose);
break;
}
/* Window Events */
case SDL_WINDOWEVENT:
switch (evt.window.event)
{
/* Window Resize */
case SDL_WINDOWEVENT_RESIZED:
if (SDL_GetWindowFlags(
SDL_GetWindowFromID(evt.window.windowID)
) & SDL_WINDOW_INPUT_FOCUS)
{
resetWindow = true;
}
break;
/* Window Events */
case SDL_WINDOWEVENT:
switch (evt.window.event)
{
/* Window Resize */
case SDL_WINDOWEVENT_RESIZED:
if (SDL_GetWindowFlags(
SDL_GetWindowFromID(evt.window.windowID)
) & SDL_WINDOW_INPUT_FOCUS)
{
resetWindow = true;
}
break;
/* Window Focus */
case SDL_WINDOWEVENT_FOCUS_GAINED:
if (!game.disablepause)
{
isActive = true;
if ((!game.disableaudiopause || !game.disabletemporaryaudiopause) && music.currentsong != -1)
{
music.resume();
music.resumeef();
}
}
if (SDL_strcmp(SDL_GetCurrentVideoDriver(), "x11") == 0)
{
if (wasFullscreen)
{
graphics.screenbuffer->isWindowed = false;
SDL_SetWindowFullscreen(
SDL_GetWindowFromID(evt.window.windowID),
SDL_WINDOW_FULLSCREEN_DESKTOP
);
}
}
SDL_DisableScreenSaver();
break;
case SDL_WINDOWEVENT_FOCUS_LOST:
// For some reason, SDL_WINDOWEVENT_FOCUS_GAINED doesn't seem to get sent on Emscripten.
/* Window Focus */
case SDL_WINDOWEVENT_FOCUS_GAINED:
if (!game.disablepause)
{
isActive = true;
if ((!game.disableaudiopause || !game.disabletemporaryaudiopause) && music.currentsong != -1)
{
music.resume();
music.resumeef();
}
}
if (SDL_strcmp(SDL_GetCurrentVideoDriver(), "x11") == 0)
{
if (wasFullscreen)
{
graphics.screenbuffer->isWindowed = false;
SDL_SetWindowFullscreen(
SDL_GetWindowFromID(evt.window.windowID),
SDL_WINDOW_FULLSCREEN_DESKTOP
);
}
}
SDL_DisableScreenSaver();
break;
case SDL_WINDOWEVENT_FOCUS_LOST:
// For some reason, SDL_WINDOWEVENT_FOCUS_GAINED doesn't seem to get sent on Emscripten.
#ifndef __EMSCRIPTEN__
if (!game.disablepause)
{
isActive = false;
if (!game.disableaudiopause || !game.disabletemporaryaudiopause)
{
music.pause();
music.pauseef();
}
}
if (!game.disablepause)
{
isActive = false;
if (!game.disableaudiopause || !game.disabletemporaryaudiopause)
{
music.pause();
music.pauseef();
}
}
#endif
if (SDL_strcmp(SDL_GetCurrentVideoDriver(), "x11") == 0)
{
wasFullscreen = !graphics.screenbuffer->isWindowed;
graphics.screenbuffer->isWindowed = true;
SDL_SetWindowFullscreen(
SDL_GetWindowFromID(evt.window.windowID),
0
);
}
SDL_EnableScreenSaver();
break;
if (SDL_strcmp(SDL_GetCurrentVideoDriver(), "x11") == 0)
{
wasFullscreen = !graphics.screenbuffer->isWindowed;
graphics.screenbuffer->isWindowed = true;
SDL_SetWindowFullscreen(
SDL_GetWindowFromID(evt.window.windowID),
0
);
}
SDL_EnableScreenSaver();
break;
/* Mouse Focus */
case SDL_WINDOWEVENT_ENTER:
SDL_DisableScreenSaver();
break;
case SDL_WINDOWEVENT_LEAVE:
SDL_EnableScreenSaver();
break;
}
break;
/* Mouse Focus */
case SDL_WINDOWEVENT_ENTER:
SDL_DisableScreenSaver();
break;
case SDL_WINDOWEVENT_LEAVE:
SDL_EnableScreenSaver();
break;
}
break;
/* Quit Event */
case SDL_QUIT:
VVV_exit(0);
break;
}
/* Quit Event */
case SDL_QUIT:
VVV_exit(0);
break;
}
switch (evt.type)
{
case SDL_KEYDOWN:
if (evt.key.repeat == 0)
{
hidemouse = true;
}
break;
case SDL_TEXTINPUT:
case SDL_CONTROLLERBUTTONDOWN:
case SDL_CONTROLLERAXISMOTION:
hidemouse = true;
break;
case SDL_MOUSEMOTION:
case SDL_MOUSEBUTTONDOWN:
showmouse = true;
break;
}
}
switch (evt.type)
{
case SDL_KEYDOWN:
if (evt.key.repeat == 0)
{
hidemouse = true;
}
break;
case SDL_TEXTINPUT:
case SDL_CONTROLLERBUTTONDOWN:
case SDL_CONTROLLERAXISMOTION:
hidemouse = true;
break;
case SDL_MOUSEMOTION:
case SDL_MOUSEBUTTONDOWN:
showmouse = true;
break;
}
}
mousetoggletimeout = changemousestate(
mousetoggletimeout,
showmouse,
hidemouse
);
mousetoggletimeout = changemousestate(
mousetoggletimeout,
showmouse,
hidemouse
);
if (fullscreenkeybind)
{
toggleFullscreen();
}
if (fullscreenkeybind)
{
toggleFullscreen();
}
}
bool KeyPoll::isDown(SDL_Keycode key)
{
return keymap[key];
return keymap[key];
}
bool KeyPoll::isDown(std::vector<SDL_GameControllerButton> buttons)
{
for (size_t i = 0; i < buttons.size(); i += 1)
{
if (buttonmap[buttons[i]])
{
return true;
}
}
return false;
for (size_t i = 0; i < buttons.size(); i += 1)
{
if (buttonmap[buttons[i]])
{
return true;
}
}
return false;
}
bool KeyPoll::isDown(SDL_GameControllerButton button)
{
return buttonmap[button];
return buttonmap[button];
}
bool KeyPoll::controllerButtonDown(void)
{
for (
SDL_GameControllerButton button = SDL_CONTROLLER_BUTTON_A;
button < SDL_CONTROLLER_BUTTON_DPAD_UP;
button = (SDL_GameControllerButton) (button + 1)
) {
if (isDown(button))
{
return true;
}
}
return false;
for (
SDL_GameControllerButton button = SDL_CONTROLLER_BUTTON_A;
button < SDL_CONTROLLER_BUTTON_DPAD_UP;
button = (SDL_GameControllerButton) (button + 1)
) {
if (isDown(button))
{
return true;
}
}
return false;
}
bool KeyPoll::controllerWantsLeft(bool includeVert)
{
return ( buttonmap[SDL_CONTROLLER_BUTTON_DPAD_LEFT] ||
xVel < 0 ||
( includeVert &&
( buttonmap[SDL_CONTROLLER_BUTTON_DPAD_UP] ||
yVel < 0 ) ) );
return ( buttonmap[SDL_CONTROLLER_BUTTON_DPAD_LEFT] ||
xVel < 0 ||
( includeVert &&
( buttonmap[SDL_CONTROLLER_BUTTON_DPAD_UP] ||
yVel < 0 ) ) );
}
bool KeyPoll::controllerWantsRight(bool includeVert)
{
return ( buttonmap[SDL_CONTROLLER_BUTTON_DPAD_RIGHT] ||
xVel > 0 ||
( includeVert &&
( buttonmap[SDL_CONTROLLER_BUTTON_DPAD_DOWN] ||
yVel > 0 ) ) );
return ( buttonmap[SDL_CONTROLLER_BUTTON_DPAD_RIGHT] ||
xVel > 0 ||
( includeVert &&
( buttonmap[SDL_CONTROLLER_BUTTON_DPAD_DOWN] ||
yVel > 0 ) ) );
}
+42 -42
View File
@@ -8,72 +8,72 @@
enum Kybrd
{
KEYBOARD_UP = SDLK_UP,
KEYBOARD_DOWN = SDLK_DOWN,
KEYBOARD_LEFT = SDLK_LEFT,
KEYBOARD_RIGHT = SDLK_RIGHT,
KEYBOARD_ENTER = SDLK_RETURN,
KEYBOARD_SPACE = SDLK_SPACE,
KEYBOARD_UP = SDLK_UP,
KEYBOARD_DOWN = SDLK_DOWN,
KEYBOARD_LEFT = SDLK_LEFT,
KEYBOARD_RIGHT = SDLK_RIGHT,
KEYBOARD_ENTER = SDLK_RETURN,
KEYBOARD_SPACE = SDLK_SPACE,
KEYBOARD_w = SDLK_w,
KEYBOARD_s = SDLK_s,
KEYBOARD_a = SDLK_a,
KEYBOARD_d = SDLK_d,
KEYBOARD_e = SDLK_e,
KEYBOARD_m = SDLK_m,
KEYBOARD_n = SDLK_n,
KEYBOARD_w = SDLK_w,
KEYBOARD_s = SDLK_s,
KEYBOARD_a = SDLK_a,
KEYBOARD_d = SDLK_d,
KEYBOARD_e = SDLK_e,
KEYBOARD_m = SDLK_m,
KEYBOARD_n = SDLK_n,
KEYBOARD_v = SDLK_v,
KEYBOARD_z = SDLK_z,
KEYBOARD_v = SDLK_v,
KEYBOARD_z = SDLK_z,
KEYBOARD_BACKSPACE = SDLK_BACKSPACE
KEYBOARD_BACKSPACE = SDLK_BACKSPACE
};
class KeyPoll
{
public:
std::map<SDL_Keycode, bool> keymap;
std::map<SDL_Keycode, bool> keymap;
bool isActive;
bool isActive;
bool resetWindow;
bool resetWindow;
void toggleFullscreen(void);
void toggleFullscreen(void);
int sensitivity;
int sensitivity;
int inline getThreshold(void);
int inline getThreshold(void);
KeyPoll(void);
KeyPoll(void);
void enabletextentry(void);
void enabletextentry(void);
void disabletextentry(void);
void disabletextentry(void);
void Poll(void);
void Poll(void);
bool isDown(SDL_Keycode key);
bool isDown(SDL_Keycode key);
bool isDown(std::vector<SDL_GameControllerButton> buttons);
bool isDown(SDL_GameControllerButton button);
bool controllerButtonDown(void);
bool controllerWantsLeft(bool includeVert);
bool controllerWantsRight(bool includeVert);
bool isDown(std::vector<SDL_GameControllerButton> buttons);
bool isDown(SDL_GameControllerButton button);
bool controllerButtonDown(void);
bool controllerWantsLeft(bool includeVert);
bool controllerWantsRight(bool includeVert);
int leftbutton, rightbutton, middlebutton;
int mx, my;
int leftbutton, rightbutton, middlebutton;
int mx, my;
bool textentry(void);
bool pressedbackspace;
std::string keybuffer;
bool textentry(void);
bool pressedbackspace;
std::string keybuffer;
bool linealreadyemptykludge;
bool linealreadyemptykludge;
private:
std::map<SDL_JoystickID, SDL_GameController*> controllers;
std::map<SDL_GameControllerButton, bool> buttonmap;
int xVel, yVel;
Uint32 wasFullscreen;
std::map<SDL_JoystickID, SDL_GameController*> controllers;
std::map<SDL_GameControllerButton, bool> buttonmap;
int xVel, yVel;
Uint32 wasFullscreen;
};
#ifndef KEY_DEFINITION
File diff suppressed because it is too large Load Diff
+3 -3
View File
@@ -543,7 +543,7 @@ void gamelogic(void)
}
//SWN Minigame Logic
if (game.swnmode) //which game?
if (game.swnmode) //which game?
{
if(game.swngame==0) //intermission, survive 60 seconds game
{
@@ -994,7 +994,7 @@ void gamelogic(void)
obj.customwarpmodevon = false;
int i = obj.getplayer();
if (INBOUNDS_VEC(i, obj.entities) && ((game.door_down > -2 && obj.entities[i].yp >= 226-16) || (game.door_up > -2 && obj.entities[i].yp < -2+16) || (game.door_left > -2 && obj.entities[i].xp < -14+16) || (game.door_right > -2 && obj.entities[i].xp >= 308-16))){
if (INBOUNDS_VEC(i, obj.entities) && ((game.door_down > -2 && obj.entities[i].yp >= 226-16) || (game.door_up > -2 && obj.entities[i].yp < -2+16) || (game.door_left > -2 && obj.entities[i].xp < -14+16) || (game.door_right > -2 && obj.entities[i].xp >= 308-16))){
//Player is leaving room
obj.customwarplinecheck(i);
}
@@ -1503,7 +1503,7 @@ void gamelogic(void)
}
}
}
else if (game.roomy >= 52)
else if (game.roomy >= 52)
{
if (obj.flags[59])
{
+1759 -1759
View File
File diff suppressed because it is too large Load Diff
+370 -370
View File
@@ -14,541 +14,541 @@
musicclass::musicclass(void)
{
safeToProcessMusic= false;
m_doFadeInVol = false;
m_doFadeOutVol = false;
musicVolume = 0;
safeToProcessMusic= false;
m_doFadeInVol = false;
m_doFadeOutVol = false;
musicVolume = 0;
user_music_volume = USER_VOLUME_MAX;
user_sound_volume = USER_VOLUME_MAX;
user_music_volume = USER_VOLUME_MAX;
user_sound_volume = USER_VOLUME_MAX;
currentsong = 0;
nicechange = -1;
nicefade = false;
quick_fade = true;
currentsong = 0;
nicechange = -1;
nicefade = false;
quick_fade = true;
usingmmmmmm = false;
usingmmmmmm = false;
}
void musicclass::init(void)
{
soundTracks.push_back(SoundTrack( "sounds/jump.wav" ));
soundTracks.push_back(SoundTrack( "sounds/jump2.wav" ));
soundTracks.push_back(SoundTrack( "sounds/hurt.wav" ));
soundTracks.push_back(SoundTrack( "sounds/souleyeminijingle.wav" ));
soundTracks.push_back(SoundTrack( "sounds/coin.wav" ));
soundTracks.push_back(SoundTrack( "sounds/save.wav" ));
soundTracks.push_back(SoundTrack( "sounds/crumble.wav" ));
soundTracks.push_back(SoundTrack( "sounds/vanish.wav" ));
soundTracks.push_back(SoundTrack( "sounds/blip.wav" ));
soundTracks.push_back(SoundTrack( "sounds/preteleport.wav" ));
soundTracks.push_back(SoundTrack( "sounds/teleport.wav" ));
soundTracks.push_back(SoundTrack( "sounds/crew1.wav" ));
soundTracks.push_back(SoundTrack( "sounds/crew2.wav" ));
soundTracks.push_back(SoundTrack( "sounds/crew3.wav" ));
soundTracks.push_back(SoundTrack( "sounds/crew4.wav" ));
soundTracks.push_back(SoundTrack( "sounds/crew5.wav" ));
soundTracks.push_back(SoundTrack( "sounds/crew6.wav" ));
soundTracks.push_back(SoundTrack( "sounds/terminal.wav" ));
soundTracks.push_back(SoundTrack( "sounds/gamesaved.wav" ));
soundTracks.push_back(SoundTrack( "sounds/crashing.wav" ));
soundTracks.push_back(SoundTrack( "sounds/blip2.wav" ));
soundTracks.push_back(SoundTrack( "sounds/countdown.wav" ));
soundTracks.push_back(SoundTrack( "sounds/go.wav" ));
soundTracks.push_back(SoundTrack( "sounds/crash.wav" ));
soundTracks.push_back(SoundTrack( "sounds/combine.wav" ));
soundTracks.push_back(SoundTrack( "sounds/newrecord.wav" ));
soundTracks.push_back(SoundTrack( "sounds/trophy.wav" ));
soundTracks.push_back(SoundTrack( "sounds/rescue.wav" ));
soundTracks.push_back(SoundTrack( "sounds/jump.wav" ));
soundTracks.push_back(SoundTrack( "sounds/jump2.wav" ));
soundTracks.push_back(SoundTrack( "sounds/hurt.wav" ));
soundTracks.push_back(SoundTrack( "sounds/souleyeminijingle.wav" ));
soundTracks.push_back(SoundTrack( "sounds/coin.wav" ));
soundTracks.push_back(SoundTrack( "sounds/save.wav" ));
soundTracks.push_back(SoundTrack( "sounds/crumble.wav" ));
soundTracks.push_back(SoundTrack( "sounds/vanish.wav" ));
soundTracks.push_back(SoundTrack( "sounds/blip.wav" ));
soundTracks.push_back(SoundTrack( "sounds/preteleport.wav" ));
soundTracks.push_back(SoundTrack( "sounds/teleport.wav" ));
soundTracks.push_back(SoundTrack( "sounds/crew1.wav" ));
soundTracks.push_back(SoundTrack( "sounds/crew2.wav" ));
soundTracks.push_back(SoundTrack( "sounds/crew3.wav" ));
soundTracks.push_back(SoundTrack( "sounds/crew4.wav" ));
soundTracks.push_back(SoundTrack( "sounds/crew5.wav" ));
soundTracks.push_back(SoundTrack( "sounds/crew6.wav" ));
soundTracks.push_back(SoundTrack( "sounds/terminal.wav" ));
soundTracks.push_back(SoundTrack( "sounds/gamesaved.wav" ));
soundTracks.push_back(SoundTrack( "sounds/crashing.wav" ));
soundTracks.push_back(SoundTrack( "sounds/blip2.wav" ));
soundTracks.push_back(SoundTrack( "sounds/countdown.wav" ));
soundTracks.push_back(SoundTrack( "sounds/go.wav" ));
soundTracks.push_back(SoundTrack( "sounds/crash.wav" ));
soundTracks.push_back(SoundTrack( "sounds/combine.wav" ));
soundTracks.push_back(SoundTrack( "sounds/newrecord.wav" ));
soundTracks.push_back(SoundTrack( "sounds/trophy.wav" ));
soundTracks.push_back(SoundTrack( "sounds/rescue.wav" ));
#ifdef VVV_COMPILEMUSIC
binaryBlob musicWriteBlob;
binaryBlob musicWriteBlob;
#define FOREACH_TRACK(blob, track_name) blob.AddFileToBinaryBlob("data/" track_name);
TRACK_NAMES(musicWriteBlob)
TRACK_NAMES(musicWriteBlob)
#undef FOREACH_TRACK
musicWriteBlob.writeBinaryBlob("data/BinaryMusic.vvv");
musicWriteBlob.clear();
musicWriteBlob.writeBinaryBlob("data/BinaryMusic.vvv");
musicWriteBlob.clear();
#endif
num_mmmmmm_tracks = 0;
num_pppppp_tracks = 0;
num_mmmmmm_tracks = 0;
num_pppppp_tracks = 0;
if (!mmmmmm_blob.unPackBinary("mmmmmm.vvv"))
{
if (pppppp_blob.unPackBinary("vvvvvvmusic.vvv"))
{
vlog_info("Loading music from PPPPPP blob...");
if (!mmmmmm_blob.unPackBinary("mmmmmm.vvv"))
{
if (pppppp_blob.unPackBinary("vvvvvvmusic.vvv"))
{
vlog_info("Loading music from PPPPPP blob...");
mmmmmm = false;
usingmmmmmm=false;
mmmmmm = false;
usingmmmmmm=false;
int index;
SDL_RWops* rw;
int index;
SDL_RWops* rw;
#define FOREACH_TRACK(blob, track_name) \
index = blob.getIndex("data/" track_name); \
rw = SDL_RWFromMem(blob.getAddress(index), blob.getSize(index)); \
musicTracks.push_back(MusicTrack( rw ));
index = blob.getIndex("data/" track_name); \
rw = SDL_RWFromMem(blob.getAddress(index), blob.getSize(index)); \
musicTracks.push_back(MusicTrack( rw ));
TRACK_NAMES(pppppp_blob)
TRACK_NAMES(pppppp_blob)
#undef FOREACH_TRACK
}
else
{
vlog_info("Loading music from loose files...");
}
else
{
vlog_info("Loading music from loose files...");
SDL_RWops* rw;
SDL_RWops* rw;
#define FOREACH_TRACK(_, track_name) \
rw = PHYSFSRWOPS_openRead(track_name); \
musicTracks.push_back(MusicTrack( rw ));
rw = PHYSFSRWOPS_openRead(track_name); \
musicTracks.push_back(MusicTrack( rw ));
TRACK_NAMES(_)
TRACK_NAMES(_)
#undef FOREACH_TRACK
}
}
else
{
vlog_info("Loading PPPPPP and MMMMMM blobs...");
}
}
else
{
vlog_info("Loading PPPPPP and MMMMMM blobs...");
mmmmmm = true;
int index;
SDL_RWops *rw;
mmmmmm = true;
int index;
SDL_RWops *rw;
#define FOREACH_TRACK(blob, track_name) \
index = blob.getIndex("data/" track_name); \
if (index >= 0 && index < blob.max_headers) \
{ \
rw = SDL_RWFromConstMem(blob.getAddress(index), blob.getSize(index)); \
if (rw == NULL) \
{ \
vlog_error("Unable to read music file header: %s", SDL_GetError()); \
} \
else \
{ \
musicTracks.push_back(MusicTrack( rw )); \
} \
}
index = blob.getIndex("data/" track_name); \
if (index >= 0 && index < blob.max_headers) \
{ \
rw = SDL_RWFromConstMem(blob.getAddress(index), blob.getSize(index)); \
if (rw == NULL) \
{ \
vlog_error("Unable to read music file header: %s", SDL_GetError()); \
} \
else \
{ \
musicTracks.push_back(MusicTrack( rw )); \
} \
}
TRACK_NAMES(mmmmmm_blob)
TRACK_NAMES(mmmmmm_blob)
num_mmmmmm_tracks += musicTracks.size();
num_mmmmmm_tracks += musicTracks.size();
size_t index_ = 0;
while (mmmmmm_blob.nextExtra(&index_))
{
rw = SDL_RWFromConstMem(mmmmmm_blob.getAddress(index_), mmmmmm_blob.getSize(index_));
musicTracks.push_back(MusicTrack( rw ));
size_t index_ = 0;
while (mmmmmm_blob.nextExtra(&index_))
{
rw = SDL_RWFromConstMem(mmmmmm_blob.getAddress(index_), mmmmmm_blob.getSize(index_));
musicTracks.push_back(MusicTrack( rw ));
num_mmmmmm_tracks++;
index_++;
}
num_mmmmmm_tracks++;
index_++;
}
bool ohCrap = pppppp_blob.unPackBinary("vvvvvvmusic.vvv");
SDL_assert(ohCrap && "Music not found!");
bool ohCrap = pppppp_blob.unPackBinary("vvvvvvmusic.vvv");
SDL_assert(ohCrap && "Music not found!");
TRACK_NAMES(pppppp_blob)
TRACK_NAMES(pppppp_blob)
#undef FOREACH_TRACK
}
}
num_pppppp_tracks += musicTracks.size() - num_mmmmmm_tracks;
num_pppppp_tracks += musicTracks.size() - num_mmmmmm_tracks;
SDL_RWops* rw;
size_t index_ = 0;
while (pppppp_blob.nextExtra(&index_))
{
rw = SDL_RWFromConstMem(pppppp_blob.getAddress(index_), pppppp_blob.getSize(index_));
musicTracks.push_back(MusicTrack( rw ));
SDL_RWops* rw;
size_t index_ = 0;
while (pppppp_blob.nextExtra(&index_))
{
rw = SDL_RWFromConstMem(pppppp_blob.getAddress(index_), pppppp_blob.getSize(index_));
musicTracks.push_back(MusicTrack( rw ));
num_pppppp_tracks++;
index_++;
}
num_pppppp_tracks++;
index_++;
}
}
void musicclass::destroy(void)
{
for (size_t i = 0; i < soundTracks.size(); ++i)
{
Mix_FreeChunk(soundTracks[i].sound);
}
soundTracks.clear();
for (size_t i = 0; i < soundTracks.size(); ++i)
{
Mix_FreeChunk(soundTracks[i].sound);
}
soundTracks.clear();
// Before we free all the music: stop playing music, else SDL2_mixer
// will call SDL_Delay() if we are fading, resulting in no-draw frames
Mix_HaltMusic();
// Before we free all the music: stop playing music, else SDL2_mixer
// will call SDL_Delay() if we are fading, resulting in no-draw frames
Mix_HaltMusic();
for (size_t i = 0; i < musicTracks.size(); ++i)
{
Mix_FreeMusic(musicTracks[i].m_music);
}
musicTracks.clear();
for (size_t i = 0; i < musicTracks.size(); ++i)
{
Mix_FreeMusic(musicTracks[i].m_music);
}
musicTracks.clear();
pppppp_blob.clear();
mmmmmm_blob.clear();
pppppp_blob.clear();
mmmmmm_blob.clear();
}
void musicclass::play(int t)
{
if (mmmmmm && usingmmmmmm)
{
// Don't conjoin this if-statement with the above one...
if (num_mmmmmm_tracks > 0)
{
t %= num_mmmmmm_tracks;
}
}
else if (num_pppppp_tracks > 0)
{
t %= num_pppppp_tracks;
}
if (mmmmmm && usingmmmmmm)
{
// Don't conjoin this if-statement with the above one...
if (num_mmmmmm_tracks > 0)
{
t %= num_mmmmmm_tracks;
}
}
else if (num_pppppp_tracks > 0)
{
t %= num_pppppp_tracks;
}
if (mmmmmm && !usingmmmmmm)
{
t += num_mmmmmm_tracks;
}
if (mmmmmm && !usingmmmmmm)
{
t += num_mmmmmm_tracks;
}
safeToProcessMusic = true;
safeToProcessMusic = true;
if (currentsong == t && !m_doFadeOutVol)
{
return;
}
if (currentsong == t && !m_doFadeOutVol)
{
return;
}
currentsong = t;
currentsong = t;
if (t == -1)
{
return;
}
if (t == -1)
{
return;
}
if (!INBOUNDS_VEC(t, musicTracks))
{
vlog_error("play() out-of-bounds!");
currentsong = -1;
return;
}
if (!INBOUNDS_VEC(t, musicTracks))
{
vlog_error("play() out-of-bounds!");
currentsong = -1;
return;
}
if (currentsong == 0 || currentsong == 7 || (!map.custommode && (currentsong == 0+num_mmmmmm_tracks || currentsong == 7+num_mmmmmm_tracks)))
{
// Level Complete theme, no fade in or repeat
if (Mix_PlayMusic(musicTracks[t].m_music, 0) == -1)
{
vlog_error("Mix_PlayMusic: %s", Mix_GetError());
}
else
{
m_doFadeInVol = false;
m_doFadeOutVol = false;
musicVolume = MIX_MAX_VOLUME;
Mix_VolumeMusic(musicVolume);
}
}
else
{
if (m_doFadeOutVol)
{
// We're already fading out
nicechange = t;
nicefade = true;
currentsong = -1;
if (currentsong == 0 || currentsong == 7 || (!map.custommode && (currentsong == 0+num_mmmmmm_tracks || currentsong == 7+num_mmmmmm_tracks)))
{
// Level Complete theme, no fade in or repeat
if (Mix_PlayMusic(musicTracks[t].m_music, 0) == -1)
{
vlog_error("Mix_PlayMusic: %s", Mix_GetError());
}
else
{
m_doFadeInVol = false;
m_doFadeOutVol = false;
musicVolume = MIX_MAX_VOLUME;
Mix_VolumeMusic(musicVolume);
}
}
else
{
if (m_doFadeOutVol)
{
// We're already fading out
nicechange = t;
nicefade = true;
currentsong = -1;
if (quick_fade)
{
fadeMusicVolumeOut(500); // fade out quicker
}
else
{
quick_fade = true;
}
}
else if (Mix_PlayMusic(musicTracks[t].m_music, -1) == -1)
{
vlog_error("Mix_PlayMusic: %s", Mix_GetError());
}
else
{
m_doFadeInVol = false;
m_doFadeOutVol = false;
fadeMusicVolumeIn(3000);
}
}
if (quick_fade)
{
fadeMusicVolumeOut(500); // fade out quicker
}
else
{
quick_fade = true;
}
}
else if (Mix_PlayMusic(musicTracks[t].m_music, -1) == -1)
{
vlog_error("Mix_PlayMusic: %s", Mix_GetError());
}
else
{
m_doFadeInVol = false;
m_doFadeOutVol = false;
fadeMusicVolumeIn(3000);
}
}
}
void musicclass::resume()
{
Mix_ResumeMusic();
Mix_ResumeMusic();
}
void musicclass::resumefade(const int fadein_ms)
{
resume();
fadeMusicVolumeIn(fadein_ms);
resume();
fadeMusicVolumeIn(fadein_ms);
}
void musicclass::fadein(void)
{
resumefade(3000); // 3000 ms fadein
resumefade(3000); // 3000 ms fadein
}
void musicclass::pause(void)
{
Mix_PauseMusic();
Mix_PauseMusic();
}
void musicclass::haltdasmusik(void)
{
/* Just pauses music. This is intended. */
pause();
currentsong = -1;
m_doFadeInVol = false;
m_doFadeOutVol = false;
/* Just pauses music. This is intended. */
pause();
currentsong = -1;
m_doFadeInVol = false;
m_doFadeOutVol = false;
}
void musicclass::silencedasmusik(void)
{
musicVolume = 0;
musicVolume = 0;
}
struct FadeState
{
int start_volume;
int end_volume;
int duration_ms;
int step_ms;
int start_volume;
int end_volume;
int duration_ms;
int step_ms;
};
static struct FadeState fade;
enum FadeCode
{
Fade_continue,
Fade_finished
Fade_continue,
Fade_finished
};
static enum FadeCode processmusicfade(struct FadeState* state, int* volume)
{
int range;
int new_volume;
int range;
int new_volume;
if (state->duration_ms == 0 /* Fast path. */
|| state->start_volume == state->end_volume /* Fast path. */
|| state->step_ms >= state->duration_ms /* We're finished. */)
{
*volume = state->end_volume;
state->step_ms = 0;
return Fade_finished;
}
if (state->duration_ms == 0 /* Fast path. */
|| state->start_volume == state->end_volume /* Fast path. */
|| state->step_ms >= state->duration_ms /* We're finished. */)
{
*volume = state->end_volume;
state->step_ms = 0;
return Fade_finished;
}
range = state->end_volume - state->start_volume;
new_volume = range * state->step_ms / state->duration_ms;
new_volume += state->start_volume;
range = state->end_volume - state->start_volume;
new_volume = range * state->step_ms / state->duration_ms;
new_volume += state->start_volume;
*volume = new_volume;
*volume = new_volume;
state->step_ms += game.get_timestep();
state->step_ms += game.get_timestep();
return Fade_continue;
return Fade_continue;
}
void musicclass::fadeMusicVolumeIn(int ms)
{
m_doFadeInVol = true;
m_doFadeOutVol = false;
m_doFadeInVol = true;
m_doFadeOutVol = false;
/* Ensure it starts at 0 */
musicVolume = 0;
/* Ensure it starts at 0 */
musicVolume = 0;
/* Fix 1-frame glitch */
Mix_VolumeMusic(0);
/* Fix 1-frame glitch */
Mix_VolumeMusic(0);
fade.step_ms = 0;
fade.duration_ms = ms;
fade.start_volume = 0;
fade.end_volume = MIX_MAX_VOLUME;
fade.step_ms = 0;
fade.duration_ms = ms;
fade.start_volume = 0;
fade.end_volume = MIX_MAX_VOLUME;
}
void musicclass::fadeMusicVolumeOut(const int fadeout_ms)
{
m_doFadeInVol = false;
m_doFadeOutVol = true;
m_doFadeInVol = false;
m_doFadeOutVol = true;
fade.step_ms = 0;
/* Duration is proportional to current volume. */
fade.duration_ms = fadeout_ms * musicVolume / MIX_MAX_VOLUME;
fade.start_volume = musicVolume;
fade.end_volume = 0;
fade.step_ms = 0;
/* Duration is proportional to current volume. */
fade.duration_ms = fadeout_ms * musicVolume / MIX_MAX_VOLUME;
fade.start_volume = musicVolume;
fade.end_volume = 0;
}
void musicclass::fadeout(const bool quick_fade_ /*= true*/)
{
fadeMusicVolumeOut(quick_fade_ ? 500 : 2000);
quick_fade = quick_fade_;
fadeMusicVolumeOut(quick_fade_ ? 500 : 2000);
quick_fade = quick_fade_;
}
void musicclass::processmusicfadein(void)
{
enum FadeCode fade_code = processmusicfade(&fade, &musicVolume);
if (fade_code == Fade_finished)
{
m_doFadeInVol = false;
}
enum FadeCode fade_code = processmusicfade(&fade, &musicVolume);
if (fade_code == Fade_finished)
{
m_doFadeInVol = false;
}
}
void musicclass::processmusicfadeout(void)
{
enum FadeCode fade_code = processmusicfade(&fade, &musicVolume);
if (fade_code == Fade_finished)
{
musicVolume = 0;
m_doFadeOutVol = false;
haltdasmusik();
}
enum FadeCode fade_code = processmusicfade(&fade, &musicVolume);
if (fade_code == Fade_finished)
{
musicVolume = 0;
m_doFadeOutVol = false;
haltdasmusik();
}
}
void musicclass::processmusic(void)
{
if(!safeToProcessMusic)
{
return;
}
if(!safeToProcessMusic)
{
return;
}
if(m_doFadeInVol)
{
processmusicfadein();
}
if(m_doFadeInVol)
{
processmusicfadein();
}
if (m_doFadeOutVol)
{
processmusicfadeout();
}
if (m_doFadeOutVol)
{
processmusicfadeout();
}
/* This needs to come after processing fades */
if (nicefade && Mix_PausedMusic() == 1)
{
play(nicechange);
nicechange = -1;
nicefade = false;
}
/* This needs to come after processing fades */
if (nicefade && Mix_PausedMusic() == 1)
{
play(nicechange);
nicechange = -1;
nicefade = false;
}
}
void musicclass::niceplay(int t)
{
/* important: do nothing if the correct song is playing! */
if ((!mmmmmm && currentsong != t)
|| (mmmmmm && usingmmmmmm && currentsong != t)
|| (mmmmmm && !usingmmmmmm && currentsong != t + num_mmmmmm_tracks))
{
if (currentsong != -1)
{
fadeout(false);
}
nicefade = true;
}
nicechange = t;
/* important: do nothing if the correct song is playing! */
if ((!mmmmmm && currentsong != t)
|| (mmmmmm && usingmmmmmm && currentsong != t)
|| (mmmmmm && !usingmmmmmm && currentsong != t + num_mmmmmm_tracks))
{
if (currentsong != -1)
{
fadeout(false);
}
nicefade = true;
}
nicechange = t;
}
static const int areamap[] = {
4, 3, 3, 3, 3, 3, 3, 3, 4,-2, 4, 4, 4,12,12,12,12,12,12,12,
4, 3, 3, 3, 3, 3, 3, 4, 4,-2, 4, 4, 4, 4,12,12,12,12,12,12,
4, 4, 4, 4, 3, 4, 4, 4, 4,-2, 4, 4, 4, 4,12,12,12,12,12,12,
4, 4, 4, 4, 3, 4, 4, 4, 4,-2, 4, 4, 1, 1, 1, 1,12,12,12,12,
4, 4, 3, 3, 3, 4, 4, 4, 4,-2,-2,-2, 1, 1, 1, 1, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4,-2, 1, 1, 1, 1, 1, 1,11,11,-1, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4,-2, 1, 1, 1, 1, 1, 1, 1,11,11,11,
4, 4, 4, 4, 4, 4, 4, 4, 4,-2, 1, 1, 1, 1, 1, 1, 1, 1, 1,11,
4, 4, 4, 4, 4, 4, 4, 4, 4,-2, 4, 4, 4, 1, 1, 1, 1, 1, 1, 3,
4, 4, 4, 4, 4, 4, 4, 4,-2,-2, 4, 4, 4, 1, 1, 1, 1, 1, 1, 4,
4, 4,-1,-1,-1, 4, 4, 4, 4,-2, 4, 4, 4, 1, 1, 1, 1, 1, 1, 4,
4, 4,-1,-1,-1, 4, 4, 4, 4,-2, 4, 1, 1, 1, 1, 1, 1, 1, 1, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4,-2, 4, 1, 1, 1, 1, 1, 1, 4, 1, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4,-2, 4, 1, 1, 1, 1, 1, 1, 4, 1, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4,-2, 4,-1,-3, 4, 4, 4, 4, 4, 1, 4,
4, 4, 4, 4, 4, 3, 3, 3, 4,-2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 3, 3, 3, 3, 3, 3, 4,-2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 3, 3, 3, 3, 3, 3, 3, 4,-2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
3, 3, 3, 3, 3, 4, 4, 3, 4,-2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
3, 3, 3, 3, 3, 4, 4, 3, 4,-2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4
4, 3, 3, 3, 3, 3, 3, 3, 4,-2, 4, 4, 4,12,12,12,12,12,12,12,
4, 3, 3, 3, 3, 3, 3, 4, 4,-2, 4, 4, 4, 4,12,12,12,12,12,12,
4, 4, 4, 4, 3, 4, 4, 4, 4,-2, 4, 4, 4, 4,12,12,12,12,12,12,
4, 4, 4, 4, 3, 4, 4, 4, 4,-2, 4, 4, 1, 1, 1, 1,12,12,12,12,
4, 4, 3, 3, 3, 4, 4, 4, 4,-2,-2,-2, 1, 1, 1, 1, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4,-2, 1, 1, 1, 1, 1, 1,11,11,-1, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4,-2, 1, 1, 1, 1, 1, 1, 1,11,11,11,
4, 4, 4, 4, 4, 4, 4, 4, 4,-2, 1, 1, 1, 1, 1, 1, 1, 1, 1,11,
4, 4, 4, 4, 4, 4, 4, 4, 4,-2, 4, 4, 4, 1, 1, 1, 1, 1, 1, 3,
4, 4, 4, 4, 4, 4, 4, 4,-2,-2, 4, 4, 4, 1, 1, 1, 1, 1, 1, 4,
4, 4,-1,-1,-1, 4, 4, 4, 4,-2, 4, 4, 4, 1, 1, 1, 1, 1, 1, 4,
4, 4,-1,-1,-1, 4, 4, 4, 4,-2, 4, 1, 1, 1, 1, 1, 1, 1, 1, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4,-2, 4, 1, 1, 1, 1, 1, 1, 4, 1, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4,-2, 4, 1, 1, 1, 1, 1, 1, 4, 1, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4,-2, 4,-1,-3, 4, 4, 4, 4, 4, 1, 4,
4, 4, 4, 4, 4, 3, 3, 3, 4,-2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 3, 3, 3, 3, 3, 3, 4,-2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 3, 3, 3, 3, 3, 3, 3, 4,-2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
3, 3, 3, 3, 3, 4, 4, 3, 4,-2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
3, 3, 3, 3, 3, 4, 4, 3, 4,-2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4
};
SDL_COMPILE_TIME_ASSERT(areamap, SDL_arraysize(areamap) == 20 * 20);
void musicclass::changemusicarea(int x, int y)
{
int room;
int track;
int room;
int track;
if (script.running)
{
return;
}
if (script.running)
{
return;
}
room = musicroom(x, y);
room = musicroom(x, y);
if (!INBOUNDS_ARR(room, areamap))
{
SDL_assert(0 && "Music map index out-of-bounds!");
return;
}
if (!INBOUNDS_ARR(room, areamap))
{
SDL_assert(0 && "Music map index out-of-bounds!");
return;
}
track = areamap[room];
track = areamap[room];
switch (track)
{
case -1:
/* Don't change music. */
return;
case -2:
/* Special case: Tower music, changes with Flip Mode. */
if (graphics.setflipmode)
{
track = 9; /* ecroF evitisoP */
}
else
{
track = 2; /* Positive Force */
}
break;
case -3:
/* Special case: start of Space Station 2. */
if (game.intimetrial)
{
track = 1; /* Pushing Onwards */
}
else
{
track = 4; /* Passion for Exploring */
}
break;
}
switch (track)
{
case -1:
/* Don't change music. */
return;
case -2:
/* Special case: Tower music, changes with Flip Mode. */
if (graphics.setflipmode)
{
track = 9; /* ecroF evitisoP */
}
else
{
track = 2; /* Positive Force */
}
break;
case -3:
/* Special case: start of Space Station 2. */
if (game.intimetrial)
{
track = 1; /* Pushing Onwards */
}
else
{
track = 4; /* Passion for Exploring */
}
break;
}
niceplay(track);
niceplay(track);
}
void musicclass::playef(int t)
{
if (!INBOUNDS_VEC(t, soundTracks))
{
return;
}
int channel;
if (!INBOUNDS_VEC(t, soundTracks))
{
return;
}
int channel;
channel = Mix_PlayChannel(-1, soundTracks[t].sound, 0);
if(channel == -1)
{
vlog_error("Unable to play WAV file: %s", Mix_GetError());
}
channel = Mix_PlayChannel(-1, soundTracks[t].sound, 0);
if(channel == -1)
{
vlog_error("Unable to play WAV file: %s", Mix_GetError());
}
}
void musicclass::pauseef(void)
{
Mix_Pause(-1);
Mix_Pause(-1);
}
void musicclass::resumeef(void)
{
Mix_Resume(-1);
Mix_Resume(-1);
}
+42 -42
View File
@@ -17,59 +17,59 @@
class musicclass
{
public:
musicclass(void);
void init(void);
void destroy(void);
musicclass(void);
void init(void);
void destroy(void);
void play(int t);
void resume();
void resumefade(const int fadein_ms);
void pause(void);
void haltdasmusik(void);
void silencedasmusik(void);
void fadeMusicVolumeIn(int ms);
void fadeMusicVolumeOut(const int fadeout_ms);
void fadeout(const bool quick_fade_ = true);
void fadein(void);
void processmusicfadein(void);
void processmusicfadeout(void);
void processmusic(void);
void niceplay(int t);
void play(int t);
void resume();
void resumefade(const int fadein_ms);
void pause(void);
void haltdasmusik(void);
void silencedasmusik(void);
void fadeMusicVolumeIn(int ms);
void fadeMusicVolumeOut(const int fadeout_ms);
void fadeout(const bool quick_fade_ = true);
void fadein(void);
void processmusicfadein(void);
void processmusicfadeout(void);
void processmusic(void);
void niceplay(int t);
void changemusicarea(int x, int y);
void changemusicarea(int x, int y);
int currentsong;
int currentsong;
void playef(int t);
void pauseef(void);
void resumeef(void);
void playef(int t);
void pauseef(void);
void resumeef(void);
std::vector<SoundTrack> soundTracks;
std::vector<MusicTrack> musicTracks;
SoundSystem soundSystem;
bool safeToProcessMusic;
std::vector<SoundTrack> soundTracks;
std::vector<MusicTrack> musicTracks;
SoundSystem soundSystem;
bool safeToProcessMusic;
int nicechange; // -1 if no song queued
bool nicefade;
int nicechange; // -1 if no song queued
bool nicefade;
bool m_doFadeInVol;
bool m_doFadeOutVol;
int musicVolume;
bool m_doFadeInVol;
bool m_doFadeOutVol;
int musicVolume;
/* 0..USER_VOLUME_MAX */
int user_music_volume;
int user_sound_volume;
/* 0..USER_VOLUME_MAX */
int user_music_volume;
int user_sound_volume;
bool quick_fade;
bool quick_fade;
// MMMMMM mod settings
bool mmmmmm;
bool usingmmmmmm;
// MMMMMM mod settings
bool mmmmmm;
bool usingmmmmmm;
binaryBlob pppppp_blob;
binaryBlob mmmmmm_blob;
int num_pppppp_tracks;
int num_mmmmmm_tracks;
binaryBlob pppppp_blob;
binaryBlob mmmmmm_blob;
int num_pppppp_tracks;
int num_mmmmmm_tracks;
};
#ifndef MUSIC_DEFINITION
+98 -98
View File
@@ -4,12 +4,12 @@
#include "Unused.h"
#ifdef MAKEANDPLAY
#ifdef STEAM_NETWORK
#undef STEAM_NETWORK
#endif
#ifdef GOG_NETWORK
#undef GOG_NETWORK
#endif
#ifdef STEAM_NETWORK
#undef STEAM_NETWORK
#endif
#ifdef GOG_NETWORK
#undef GOG_NETWORK
#endif
#endif
#ifdef STEAM_NETWORK
@@ -25,12 +25,12 @@
#define NUM_BACKENDS (STEAM_NUM+GOG_NUM)
#define DECLARE_BACKEND(name) \
int32_t name##_init(void); \
void name##_shutdown(void); \
void name##_update(void); \
void name##_unlockAchievement(const char *name); \
int32_t name##_getAchievementProgress(const char *name); \
void name##_setAchievementProgress(const char *name, int32_t stat);
int32_t name##_init(void); \
void name##_shutdown(void); \
void name##_update(void); \
void name##_unlockAchievement(const char *name); \
int32_t name##_getAchievementProgress(const char *name); \
void name##_setAchievementProgress(const char *name, int32_t stat);
#ifdef STEAM_NETWORK
DECLARE_BACKEND(STEAM)
#endif
@@ -41,13 +41,13 @@ DECLARE_BACKEND(GOG)
typedef struct NetworkBackend
{
int32_t IsInit;
int32_t (*Init)(void);
void (*Shutdown)(void);
void (*Update)(void);
void (*UnlockAchievement)(const char*);
int32_t (*GetAchievementProgress)(const char*);
void (*SetAchievementProgress)(const char*, int32_t);
int32_t IsInit;
int32_t (*Init)(void);
void (*Shutdown)(void);
void (*Update)(void);
void (*UnlockAchievement)(const char*);
int32_t (*GetAchievementProgress)(const char*);
void (*SetAchievementProgress)(const char*, int32_t);
} NetworkBackend;
#if NUM_BACKENDS > 0
@@ -56,103 +56,103 @@ static NetworkBackend backends[NUM_BACKENDS];
int NETWORK_init(void)
{
int32_t i, any = 0;
#define ASSIGN_BACKEND(name, index) \
backends[index].Init = name##_init; \
backends[index].Shutdown = name##_shutdown; \
backends[index].Update = name##_update; \
backends[index].UnlockAchievement = name##_unlockAchievement; \
backends[index].GetAchievementProgress = name##_getAchievementProgress; \
backends[index].SetAchievementProgress = name##_setAchievementProgress;
#ifdef STEAM_NETWORK
ASSIGN_BACKEND(STEAM, 0)
#endif
#ifdef GOG_NETWORK
ASSIGN_BACKEND(GOG, STEAM_NUM)
#endif
#undef ASSIGN_BACKEND
#if NUM_BACKENDS > 0
for (i = 0; i < NUM_BACKENDS; i += 1)
{
backends[i].IsInit = backends[i].Init();
any |= backends[i].IsInit;
}
#else
UNUSED(i);
#endif
return any;
int32_t i, any = 0;
#define ASSIGN_BACKEND(name, index) \
backends[index].Init = name##_init; \
backends[index].Shutdown = name##_shutdown; \
backends[index].Update = name##_update; \
backends[index].UnlockAchievement = name##_unlockAchievement; \
backends[index].GetAchievementProgress = name##_getAchievementProgress; \
backends[index].SetAchievementProgress = name##_setAchievementProgress;
#ifdef STEAM_NETWORK
ASSIGN_BACKEND(STEAM, 0)
#endif
#ifdef GOG_NETWORK
ASSIGN_BACKEND(GOG, STEAM_NUM)
#endif
#undef ASSIGN_BACKEND
#if NUM_BACKENDS > 0
for (i = 0; i < NUM_BACKENDS; i += 1)
{
backends[i].IsInit = backends[i].Init();
any |= backends[i].IsInit;
}
#else
UNUSED(i);
#endif
return any;
}
void NETWORK_shutdown(void)
{
#if NUM_BACKENDS > 0
int32_t i;
for (i = 0; i < NUM_BACKENDS; i += 1)
if (backends[i].IsInit)
{
backends[i].Shutdown();
}
#endif
#if NUM_BACKENDS > 0
int32_t i;
for (i = 0; i < NUM_BACKENDS; i += 1)
if (backends[i].IsInit)
{
backends[i].Shutdown();
}
#endif
}
void NETWORK_update(void)
{
#if NUM_BACKENDS > 0
int32_t i;
for (i = 0; i < NUM_BACKENDS; i += 1)
if (backends[i].IsInit)
{
backends[i].Update();
}
#endif
#if NUM_BACKENDS > 0
int32_t i;
for (i = 0; i < NUM_BACKENDS; i += 1)
if (backends[i].IsInit)
{
backends[i].Update();
}
#endif
}
void NETWORK_unlockAchievement(const char *name)
{
#if NUM_BACKENDS > 0
int32_t i;
for (i = 0; i < NUM_BACKENDS; i += 1)
if (backends[i].IsInit)
{
backends[i].UnlockAchievement(name);
}
#else
UNUSED(name);
#endif
#if NUM_BACKENDS > 0
int32_t i;
for (i = 0; i < NUM_BACKENDS; i += 1)
if (backends[i].IsInit)
{
backends[i].UnlockAchievement(name);
}
#else
UNUSED(name);
#endif
}
int32_t NETWORK_getAchievementProgress(const char *name)
{
/* The highest stat gets priority, will eventually pass to the others */
int32_t max = 0;
#if NUM_BACKENDS > 0
int32_t i, stat;
for (i = 0; i < NUM_BACKENDS; i += 1)
if (backends[i].IsInit)
{
stat = backends[i].GetAchievementProgress(name);
if (stat > max)
{
max = stat;
}
}
#else
UNUSED(name);
#endif
return max;
/* The highest stat gets priority, will eventually pass to the others */
int32_t max = 0;
#if NUM_BACKENDS > 0
int32_t i, stat;
for (i = 0; i < NUM_BACKENDS; i += 1)
if (backends[i].IsInit)
{
stat = backends[i].GetAchievementProgress(name);
if (stat > max)
{
max = stat;
}
}
#else
UNUSED(name);
#endif
return max;
}
void NETWORK_setAchievementProgress(const char *name, int32_t stat)
{
#if NUM_BACKENDS > 0
int32_t i;
for (i = 0; i < NUM_BACKENDS; i += 1)
if (backends[i].IsInit)
{
backends[i].SetAchievementProgress(name, stat);
}
#else
UNUSED(name);
UNUSED(stat);
#endif
#if NUM_BACKENDS > 0
int32_t i;
for (i = 0; i < NUM_BACKENDS; i += 1)
if (backends[i].IsInit)
{
backends[i].SetAchievementProgress(name, stat);
}
#else
UNUSED(name);
UNUSED(stat);
#endif
}
File diff suppressed because it is too large Load Diff
+3 -3
View File
@@ -1912,7 +1912,7 @@ void gamerender(void)
graphics.bprint( 240, 190, "Best Time", 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), true);
graphics.bigbrprint( 300, 205, tempstring, 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), true, 2);
}
else if (int(game.swndelay / 10) % 2 == 1)
else if (int(game.swndelay / 10) % 2 == 1)
{
graphics.bigbprint( -1, 20, "SUPER GRAVITRON", 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), true, 2);
graphics.bigbprint( -1, 200, "GO!", 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2), true, 3);
@@ -2307,7 +2307,7 @@ void maprender(void)
{
int temp = 1086;
if (graphics.flipmode) temp += 3;
graphics.drawtile(40 + 3 + (map.shinytrinkets[i].x * 12), 22 + (map.shinytrinkets[i].y * 9), temp);
graphics.drawtile(40 + 3 + (map.shinytrinkets[i].x * 12), 22 + (map.shinytrinkets[i].y * 9), temp);
}
}
}
@@ -2862,7 +2862,7 @@ void teleporterrender(void)
{
temp = 1086;
if (graphics.flipmode) temp += 3;
graphics.drawtile(40 + 3 + (map.shinytrinkets[i].x * 12), 22 + (map.shinytrinkets[i].y * 9), temp);
graphics.drawtile(40 + 3 + (map.shinytrinkets[i].x * 12), 22 + (map.shinytrinkets[i].y * 9), temp);
}
}
}
+313 -313
View File
@@ -10,412 +10,412 @@
// Used to create the window icon
extern "C"
{
extern unsigned lodepng_decode24(
unsigned char** out,
unsigned* w,
unsigned* h,
const unsigned char* in,
size_t insize
);
extern unsigned lodepng_decode24(
unsigned char** out,
unsigned* w,
unsigned* h,
const unsigned char* in,
size_t insize
);
}
ScreenSettings::ScreenSettings(void)
{
windowWidth = 320;
windowHeight = 240;
fullscreen = false;
useVsync = true; // Now that uncapped is the default...
stretch = 0;
linearFilter = false;
badSignal = false;
windowWidth = 320;
windowHeight = 240;
fullscreen = false;
useVsync = true; // Now that uncapped is the default...
stretch = 0;
linearFilter = false;
badSignal = false;
}
void Screen::init(const ScreenSettings& settings)
{
m_window = NULL;
m_renderer = NULL;
m_screenTexture = NULL;
m_screen = NULL;
isWindowed = !settings.fullscreen;
stretchMode = settings.stretch;
isFiltered = settings.linearFilter;
vsync = settings.useVsync;
filterSubrect.x = 1;
filterSubrect.y = 1;
filterSubrect.w = 318;
filterSubrect.h = 238;
m_window = NULL;
m_renderer = NULL;
m_screenTexture = NULL;
m_screen = NULL;
isWindowed = !settings.fullscreen;
stretchMode = settings.stretch;
isFiltered = settings.linearFilter;
vsync = settings.useVsync;
filterSubrect.x = 1;
filterSubrect.y = 1;
filterSubrect.w = 318;
filterSubrect.h = 238;
SDL_SetHintWithPriority(
SDL_HINT_RENDER_SCALE_QUALITY,
isFiltered ? "linear" : "nearest",
SDL_HINT_OVERRIDE
);
SDL_SetHintWithPriority(
SDL_HINT_RENDER_VSYNC,
vsync ? "1" : "0",
SDL_HINT_OVERRIDE
);
SDL_SetHintWithPriority(
SDL_HINT_RENDER_SCALE_QUALITY,
isFiltered ? "linear" : "nearest",
SDL_HINT_OVERRIDE
);
SDL_SetHintWithPriority(
SDL_HINT_RENDER_VSYNC,
vsync ? "1" : "0",
SDL_HINT_OVERRIDE
);
// Uncomment this next line when you need to debug -flibit
// SDL_SetHintWithPriority(SDL_HINT_RENDER_DRIVER, "software", SDL_HINT_OVERRIDE);
// FIXME: m_renderer is also created in resetRendererWorkaround()!
SDL_CreateWindowAndRenderer(
640,
480,
SDL_WINDOW_HIDDEN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI,
&m_window,
&m_renderer
);
SDL_SetWindowTitle(m_window, "VVVVVV");
// Uncomment this next line when you need to debug -flibit
// SDL_SetHintWithPriority(SDL_HINT_RENDER_DRIVER, "software", SDL_HINT_OVERRIDE);
// FIXME: m_renderer is also created in resetRendererWorkaround()!
SDL_CreateWindowAndRenderer(
640,
480,
SDL_WINDOW_HIDDEN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI,
&m_window,
&m_renderer
);
SDL_SetWindowTitle(m_window, "VVVVVV");
LoadIcon();
LoadIcon();
// FIXME: This surface should be the actual backbuffer! -flibit
m_screen = SDL_CreateRGBSurface(
0,
320,
240,
32,
0x00FF0000,
0x0000FF00,
0x000000FF,
0xFF000000
);
// ALSO FIXME: This SDL_CreateTexture() is duplicated twice in this file!
m_screenTexture = SDL_CreateTexture(
m_renderer,
SDL_PIXELFORMAT_ARGB8888,
SDL_TEXTUREACCESS_STREAMING,
320,
240
);
// FIXME: This surface should be the actual backbuffer! -flibit
m_screen = SDL_CreateRGBSurface(
0,
320,
240,
32,
0x00FF0000,
0x0000FF00,
0x000000FF,
0xFF000000
);
// ALSO FIXME: This SDL_CreateTexture() is duplicated twice in this file!
m_screenTexture = SDL_CreateTexture(
m_renderer,
SDL_PIXELFORMAT_ARGB8888,
SDL_TEXTUREACCESS_STREAMING,
320,
240
);
badSignalEffect = settings.badSignal;
badSignalEffect = settings.badSignal;
ResizeScreen(settings.windowWidth, settings.windowHeight);
ResizeScreen(settings.windowWidth, settings.windowHeight);
}
void Screen::destroy(void)
{
#define X(CLEANUP, POINTER) \
CLEANUP(POINTER); \
POINTER = NULL;
CLEANUP(POINTER); \
POINTER = NULL;
/* Order matters! */
X(SDL_DestroyTexture, m_screenTexture);
X(SDL_FreeSurface, m_screen);
X(SDL_DestroyRenderer, m_renderer);
X(SDL_DestroyWindow, m_window);
/* Order matters! */
X(SDL_DestroyTexture, m_screenTexture);
X(SDL_FreeSurface, m_screen);
X(SDL_DestroyRenderer, m_renderer);
X(SDL_DestroyWindow, m_window);
#undef X
}
void Screen::GetSettings(ScreenSettings* settings)
{
int width, height;
GetWindowSize(&width, &height);
int width, height;
GetWindowSize(&width, &height);
settings->windowWidth = width;
settings->windowHeight = height;
settings->windowWidth = width;
settings->windowHeight = height;
settings->fullscreen = !isWindowed;
settings->useVsync = vsync;
settings->stretch = stretchMode;
settings->linearFilter = isFiltered;
settings->badSignal = badSignalEffect;
settings->fullscreen = !isWindowed;
settings->useVsync = vsync;
settings->stretch = stretchMode;
settings->linearFilter = isFiltered;
settings->badSignal = badSignalEffect;
}
void Screen::LoadIcon(void)
{
#ifndef __APPLE__
unsigned char *fileIn;
size_t length;
unsigned char *data;
unsigned int width, height;
FILESYSTEM_loadAssetToMemory("VVVVVV.png", &fileIn, &length, false);
lodepng_decode24(&data, &width, &height, fileIn, length);
FILESYSTEM_freeMemory(&fileIn);
SDL_Surface *icon = SDL_CreateRGBSurfaceFrom(
data,
width,
height,
24,
width * 3,
0x000000FF,
0x0000FF00,
0x00FF0000,
0x00000000
);
SDL_SetWindowIcon(m_window, icon);
SDL_FreeSurface(icon);
SDL_free(data);
unsigned char *fileIn;
size_t length;
unsigned char *data;
unsigned int width, height;
FILESYSTEM_loadAssetToMemory("VVVVVV.png", &fileIn, &length, false);
lodepng_decode24(&data, &width, &height, fileIn, length);
FILESYSTEM_freeMemory(&fileIn);
SDL_Surface *icon = SDL_CreateRGBSurfaceFrom(
data,
width,
height,
24,
width * 3,
0x000000FF,
0x0000FF00,
0x00FF0000,
0x00000000
);
SDL_SetWindowIcon(m_window, icon);
SDL_FreeSurface(icon);
SDL_free(data);
#endif /* __APPLE__ */
}
void Screen::ResizeScreen(int x, int y)
{
static int resX = 320;
static int resY = 240;
if (x != -1 && y != -1)
{
// This is a user resize!
resX = x;
resY = y;
}
static int resX = 320;
static int resY = 240;
if (x != -1 && y != -1)
{
// This is a user resize!
resX = x;
resY = y;
}
if(!isWindowed)
{
int result = SDL_SetWindowFullscreen(m_window, SDL_WINDOW_FULLSCREEN_DESKTOP);
if (result != 0)
{
vlog_error("Error: could not set the game to fullscreen mode: %s", SDL_GetError());
return;
}
}
else
{
int result = SDL_SetWindowFullscreen(m_window, 0);
if (result != 0)
{
vlog_error("Error: could not set the game to windowed mode: %s", SDL_GetError());
return;
}
if (x != -1 && y != -1)
{
SDL_SetWindowSize(m_window, resX, resY);
SDL_SetWindowPosition(m_window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
}
}
if (stretchMode == 1)
{
int winX, winY;
GetWindowSize(&winX, &winY);
int result = SDL_RenderSetLogicalSize(m_renderer, winX, winY);
if (result != 0)
{
vlog_error("Error: could not set logical size: %s", SDL_GetError());
return;
}
result = SDL_RenderSetIntegerScale(m_renderer, SDL_FALSE);
if (result != 0)
{
vlog_error("Error: could not set scale: %s", SDL_GetError());
return;
}
}
else
{
SDL_RenderSetLogicalSize(m_renderer, 320, 240);
int result = SDL_RenderSetIntegerScale(m_renderer, (SDL_bool) (stretchMode == 2));
if (result != 0)
{
vlog_error("Error: could not set scale: %s", SDL_GetError());
return;
}
}
SDL_ShowWindow(m_window);
if(!isWindowed)
{
int result = SDL_SetWindowFullscreen(m_window, SDL_WINDOW_FULLSCREEN_DESKTOP);
if (result != 0)
{
vlog_error("Error: could not set the game to fullscreen mode: %s", SDL_GetError());
return;
}
}
else
{
int result = SDL_SetWindowFullscreen(m_window, 0);
if (result != 0)
{
vlog_error("Error: could not set the game to windowed mode: %s", SDL_GetError());
return;
}
if (x != -1 && y != -1)
{
SDL_SetWindowSize(m_window, resX, resY);
SDL_SetWindowPosition(m_window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
}
}
if (stretchMode == 1)
{
int winX, winY;
GetWindowSize(&winX, &winY);
int result = SDL_RenderSetLogicalSize(m_renderer, winX, winY);
if (result != 0)
{
vlog_error("Error: could not set logical size: %s", SDL_GetError());
return;
}
result = SDL_RenderSetIntegerScale(m_renderer, SDL_FALSE);
if (result != 0)
{
vlog_error("Error: could not set scale: %s", SDL_GetError());
return;
}
}
else
{
SDL_RenderSetLogicalSize(m_renderer, 320, 240);
int result = SDL_RenderSetIntegerScale(m_renderer, (SDL_bool) (stretchMode == 2));
if (result != 0)
{
vlog_error("Error: could not set scale: %s", SDL_GetError());
return;
}
}
SDL_ShowWindow(m_window);
}
void Screen::ResizeToNearestMultiple(void)
{
int w, h;
GetWindowSize(&w, &h);
int w, h;
GetWindowSize(&w, &h);
// Check aspect ratio first
bool using_width;
int usethisdimension, usethisratio;
// Check aspect ratio first
bool using_width;
int usethisdimension, usethisratio;
if ((float) w / (float) h > 4.0 / 3.0)
{
// Width is bigger, so it's limited by height
usethisdimension = h;
usethisratio = 240;
using_width = false;
}
else
{
// Height is bigger, so it's limited by width. Or we're exactly 4:3 already
usethisdimension = w;
usethisratio = 320;
using_width = true;
}
if ((float) w / (float) h > 4.0 / 3.0)
{
// Width is bigger, so it's limited by height
usethisdimension = h;
usethisratio = 240;
using_width = false;
}
else
{
// Height is bigger, so it's limited by width. Or we're exactly 4:3 already
usethisdimension = w;
usethisratio = 320;
using_width = true;
}
int floor = (usethisdimension / usethisratio) * usethisratio;
int ceiling = floor + usethisratio;
int floor = (usethisdimension / usethisratio) * usethisratio;
int ceiling = floor + usethisratio;
int final_dimension;
int final_dimension;
if (usethisdimension - floor < ceiling - usethisdimension)
{
// Floor is nearest
final_dimension = floor;
}
else
{
// Ceiling is nearest. Or we're exactly on a multiple already
final_dimension = ceiling;
}
if (usethisdimension - floor < ceiling - usethisdimension)
{
// Floor is nearest
final_dimension = floor;
}
else
{
// Ceiling is nearest. Or we're exactly on a multiple already
final_dimension = ceiling;
}
if (final_dimension == 0)
{
// We're way too small!
ResizeScreen(320, 240);
return;
}
if (final_dimension == 0)
{
// We're way too small!
ResizeScreen(320, 240);
return;
}
if (using_width)
{
ResizeScreen(final_dimension, final_dimension / 4 * 3);
}
else
{
ResizeScreen(final_dimension * 4 / 3, final_dimension);
}
if (using_width)
{
ResizeScreen(final_dimension, final_dimension / 4 * 3);
}
else
{
ResizeScreen(final_dimension * 4 / 3, final_dimension);
}
}
void Screen::GetWindowSize(int* x, int* y)
{
SDL_GetRendererOutputSize(m_renderer, x, y);
SDL_GetRendererOutputSize(m_renderer, x, y);
}
void Screen::UpdateScreen(SDL_Surface* buffer, SDL_Rect* rect )
{
if((buffer == NULL) && (m_screen == NULL) )
{
return;
}
if((buffer == NULL) && (m_screen == NULL) )
{
return;
}
if(badSignalEffect)
{
buffer = ApplyFilter(buffer);
}
if(badSignalEffect)
{
buffer = ApplyFilter(buffer);
}
ClearSurface(m_screen);
BlitSurfaceStandard(buffer,NULL,m_screen,rect);
ClearSurface(m_screen);
BlitSurfaceStandard(buffer,NULL,m_screen,rect);
if(badSignalEffect)
{
SDL_FreeSurface(buffer);
}
if(badSignalEffect)
{
SDL_FreeSurface(buffer);
}
}
const SDL_PixelFormat* Screen::GetFormat(void)
{
return m_screen->format;
return m_screen->format;
}
void Screen::FlipScreen(const bool flipmode)
{
SDL_RendererFlip flip_flags;
if (flipmode)
{
flip_flags = SDL_FLIP_VERTICAL;
}
else
{
flip_flags = SDL_FLIP_NONE;
}
SDL_RendererFlip flip_flags;
if (flipmode)
{
flip_flags = SDL_FLIP_VERTICAL;
}
else
{
flip_flags = SDL_FLIP_NONE;
}
SDL_UpdateTexture(
m_screenTexture,
NULL,
m_screen->pixels,
m_screen->pitch
);
SDL_RenderCopyEx(
m_renderer,
m_screenTexture,
isFiltered ? &filterSubrect : NULL,
NULL,
0.0,
NULL,
flip_flags
);
SDL_RenderPresent(m_renderer);
SDL_RenderClear(m_renderer);
ClearSurface(m_screen);
SDL_UpdateTexture(
m_screenTexture,
NULL,
m_screen->pixels,
m_screen->pitch
);
SDL_RenderCopyEx(
m_renderer,
m_screenTexture,
isFiltered ? &filterSubrect : NULL,
NULL,
0.0,
NULL,
flip_flags
);
SDL_RenderPresent(m_renderer);
SDL_RenderClear(m_renderer);
ClearSurface(m_screen);
}
void Screen::toggleFullScreen(void)
{
isWindowed = !isWindowed;
ResizeScreen(-1, -1);
isWindowed = !isWindowed;
ResizeScreen(-1, -1);
if (game.currentmenuname == Menu::graphicoptions)
{
/* Recreate menu to update "resize to nearest" */
game.createmenu(game.currentmenuname, true);
}
if (game.currentmenuname == Menu::graphicoptions)
{
/* Recreate menu to update "resize to nearest" */
game.createmenu(game.currentmenuname, true);
}
}
void Screen::toggleStretchMode(void)
{
stretchMode = (stretchMode + 1) % 3;
ResizeScreen(-1, -1);
stretchMode = (stretchMode + 1) % 3;
ResizeScreen(-1, -1);
}
void Screen::toggleLinearFilter(void)
{
isFiltered = !isFiltered;
SDL_SetHintWithPriority(
SDL_HINT_RENDER_SCALE_QUALITY,
isFiltered ? "linear" : "nearest",
SDL_HINT_OVERRIDE
);
SDL_DestroyTexture(m_screenTexture);
m_screenTexture = SDL_CreateTexture(
m_renderer,
SDL_PIXELFORMAT_ARGB8888,
SDL_TEXTUREACCESS_STREAMING,
320,
240
);
isFiltered = !isFiltered;
SDL_SetHintWithPriority(
SDL_HINT_RENDER_SCALE_QUALITY,
isFiltered ? "linear" : "nearest",
SDL_HINT_OVERRIDE
);
SDL_DestroyTexture(m_screenTexture);
m_screenTexture = SDL_CreateTexture(
m_renderer,
SDL_PIXELFORMAT_ARGB8888,
SDL_TEXTUREACCESS_STREAMING,
320,
240
);
}
void Screen::resetRendererWorkaround(void)
{
SDL_SetHintWithPriority(
SDL_HINT_RENDER_VSYNC,
vsync ? "1" : "0",
SDL_HINT_OVERRIDE
);
SDL_SetHintWithPriority(
SDL_HINT_RENDER_VSYNC,
vsync ? "1" : "0",
SDL_HINT_OVERRIDE
);
/* FIXME: This exists because SDL_HINT_RENDER_VSYNC is not dynamic!
* As a result, our only workaround is to tear down the renderer
* and recreate everything so that it can process the variable.
* -flibit
*/
/* FIXME: This exists because SDL_HINT_RENDER_VSYNC is not dynamic!
* As a result, our only workaround is to tear down the renderer
* and recreate everything so that it can process the variable.
* -flibit
*/
if (m_renderer == NULL)
{
/* We haven't made it to init yet, don't worry about it */
return;
}
if (m_renderer == NULL)
{
/* We haven't made it to init yet, don't worry about it */
return;
}
SDL_RendererInfo renderInfo;
SDL_GetRendererInfo(m_renderer, &renderInfo);
bool curVsync = (renderInfo.flags & SDL_RENDERER_PRESENTVSYNC) != 0;
if (vsync == curVsync)
{
return;
}
SDL_RendererInfo renderInfo;
SDL_GetRendererInfo(m_renderer, &renderInfo);
bool curVsync = (renderInfo.flags & SDL_RENDERER_PRESENTVSYNC) != 0;
if (vsync == curVsync)
{
return;
}
SDL_DestroyTexture(m_screenTexture);
SDL_DestroyRenderer(m_renderer);
SDL_DestroyTexture(m_screenTexture);
SDL_DestroyRenderer(m_renderer);
m_renderer = SDL_CreateRenderer(m_window, -1, 0);
m_screenTexture = SDL_CreateTexture(
m_renderer,
SDL_PIXELFORMAT_ARGB8888,
SDL_TEXTUREACCESS_STREAMING,
320,
240
);
m_renderer = SDL_CreateRenderer(m_window, -1, 0);
m_screenTexture = SDL_CreateTexture(
m_renderer,
SDL_PIXELFORMAT_ARGB8888,
SDL_TEXTUREACCESS_STREAMING,
320,
240
);
/* Ugh, have to make sure to re-apply graphics options after doing the
* above, otherwise letterbox/integer won't be applied...
*/
ResizeScreen(-1, -1);
/* Ugh, have to make sure to re-apply graphics options after doing the
* above, otherwise letterbox/integer won't be applied...
*/
ResizeScreen(-1, -1);
}
+24 -24
View File
@@ -8,39 +8,39 @@
class Screen
{
public:
void init(const ScreenSettings& settings);
void destroy(void);
void init(const ScreenSettings& settings);
void destroy(void);
void GetSettings(ScreenSettings* settings);
void GetSettings(ScreenSettings* settings);
void LoadIcon(void);
void LoadIcon(void);
void ResizeScreen(int x, int y);
void ResizeToNearestMultiple(void);
void GetWindowSize(int* x, int* y);
void ResizeScreen(int x, int y);
void ResizeToNearestMultiple(void);
void GetWindowSize(int* x, int* y);
void UpdateScreen(SDL_Surface* buffer, SDL_Rect* rect);
void FlipScreen(bool flipmode);
void UpdateScreen(SDL_Surface* buffer, SDL_Rect* rect);
void FlipScreen(bool flipmode);
const SDL_PixelFormat* GetFormat(void);
const SDL_PixelFormat* GetFormat(void);
void toggleFullScreen(void);
void toggleStretchMode(void);
void toggleLinearFilter(void);
void resetRendererWorkaround(void);
void toggleFullScreen(void);
void toggleStretchMode(void);
void toggleLinearFilter(void);
void resetRendererWorkaround(void);
bool isWindowed;
bool isFiltered;
bool badSignalEffect;
int stretchMode;
bool vsync;
bool isWindowed;
bool isFiltered;
bool badSignalEffect;
int stretchMode;
bool vsync;
SDL_Window *m_window;
SDL_Renderer *m_renderer;
SDL_Texture *m_screenTexture;
SDL_Surface* m_screen;
SDL_Window *m_window;
SDL_Renderer *m_renderer;
SDL_Texture *m_screenTexture;
SDL_Surface* m_screen;
SDL_Rect filterSubrect;
SDL_Rect filterSubrect;
};
#endif /* SCREEN_H */
+8 -8
View File
@@ -3,15 +3,15 @@
struct ScreenSettings
{
ScreenSettings(void);
ScreenSettings(void);
int windowWidth;
int windowHeight;
bool fullscreen;
bool useVsync;
int stretch;
bool linearFilter;
bool badSignal;
int windowWidth;
int windowHeight;
bool fullscreen;
bool useVsync;
int stretch;
bool linearFilter;
bool badSignal;
};
#endif /* SCREENSETTINGS_H */
File diff suppressed because it is too large Load Diff
+40 -40
View File
@@ -7,60 +7,60 @@
MusicTrack::MusicTrack(const char* fileName)
{
m_music = Mix_LoadMUS(fileName);
m_isValid = true;
if(m_music == NULL)
{
vlog_error("Unable to load Ogg Music file: %s", Mix_GetError());
m_isValid = false;
}
m_music = Mix_LoadMUS(fileName);
m_isValid = true;
if(m_music == NULL)
{
vlog_error("Unable to load Ogg Music file: %s", Mix_GetError());
m_isValid = false;
}
}
MusicTrack::MusicTrack(SDL_RWops *rw)
{
m_music = Mix_LoadMUS_RW(rw, 1);
m_isValid = true;
if(m_music == NULL)
{
vlog_error("Unable to load Magic Binary Music file: %s", Mix_GetError());
m_isValid = false;
}
m_music = Mix_LoadMUS_RW(rw, 1);
m_isValid = true;
if(m_music == NULL)
{
vlog_error("Unable to load Magic Binary Music file: %s", Mix_GetError());
m_isValid = false;
}
}
SoundTrack::SoundTrack(const char* fileName)
{
unsigned char *mem;
size_t length;
unsigned char *mem;
size_t length;
sound = NULL;
sound = NULL;
FILESYSTEM_loadAssetToMemory(fileName, &mem, &length, false);
if (mem == NULL)
{
vlog_error("Unable to load WAV file %s", fileName);
SDL_assert(0 && "WAV file missing!");
return;
}
SDL_RWops *fileIn = SDL_RWFromConstMem(mem, length);
sound = Mix_LoadWAV_RW(fileIn, 1);
FILESYSTEM_freeMemory(&mem);
FILESYSTEM_loadAssetToMemory(fileName, &mem, &length, false);
if (mem == NULL)
{
vlog_error("Unable to load WAV file %s", fileName);
SDL_assert(0 && "WAV file missing!");
return;
}
SDL_RWops *fileIn = SDL_RWFromConstMem(mem, length);
sound = Mix_LoadWAV_RW(fileIn, 1);
FILESYSTEM_freeMemory(&mem);
if (sound == NULL)
{
vlog_error("Unable to load WAV file: %s", Mix_GetError());
}
if (sound == NULL)
{
vlog_error("Unable to load WAV file: %s", Mix_GetError());
}
}
SoundSystem::SoundSystem(void)
{
int audio_rate = 44100;
Uint16 audio_format = AUDIO_S16SYS;
int audio_channels = 2;
int audio_buffers = 1024;
int audio_rate = 44100;
Uint16 audio_format = AUDIO_S16SYS;
int audio_channels = 2;
int audio_buffers = 1024;
if (Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers) != 0)
{
vlog_error("Unable to initialize audio: %s", Mix_GetError());
SDL_assert(0 && "Unable to initialize audio!");
}
if (Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers) != 0)
{
vlog_error("Unable to initialize audio: %s", Mix_GetError());
SDL_assert(0 && "Unable to initialize audio!");
}
}
+7 -7
View File
@@ -6,23 +6,23 @@
class MusicTrack
{
public:
MusicTrack(const char* fileName);
MusicTrack(SDL_RWops *rw);
Mix_Music *m_music;
bool m_isValid;
MusicTrack(const char* fileName);
MusicTrack(SDL_RWops *rw);
Mix_Music *m_music;
bool m_isValid;
};
class SoundTrack
{
public:
SoundTrack(const char* fileName);
Mix_Chunk *sound;
SoundTrack(const char* fileName);
Mix_Chunk *sound;
};
class SoundSystem
{
public:
SoundSystem(void);
SoundSystem(void);
};
#endif /* SOUNDSYSTEM_H */
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -6,8 +6,8 @@
class spacestation2class
{
public:
const short* loadlevel(int rx, int ry);
std::string roomname;
const short* loadlevel(int rx, int ry);
std::string roomname;
};
#endif /* SPACESTATION2_H */
+124 -124
View File
@@ -34,26 +34,26 @@ typedef intptr_t (*SteamInternal_CreateInterfaceFunc)(const char*);
typedef int32_t (*SteamAPI_GetHSteamUserFunc)(void);
typedef int32_t (*SteamAPI_GetHSteamPipeFunc)(void);
typedef intptr_t (*SteamAPI_ISteamClient_GetISteamUserStatsFunc)(
intptr_t,
int32_t,
int32_t,
const char*
intptr_t,
int32_t,
int32_t,
const char*
);
typedef uint8_t (*SteamAPI_ISteamUserStats_RequestCurrentStatsFunc)(intptr_t);
typedef uint8_t (*SteamAPI_ISteamUserStats_StoreStatsFunc)(intptr_t);
typedef uint8_t (*SteamAPI_ISteamUserStats_GetStatFunc)(
intptr_t,
const char*,
int32_t*
intptr_t,
const char*,
int32_t*
);
typedef uint8_t (*SteamAPI_ISteamUserStats_SetStatFunc)(
intptr_t,
const char*,
int32_t
intptr_t,
const char*,
int32_t
);
typedef uint8_t (*SteamAPI_ISteamUserStats_SetAchievementFunc)(
intptr_t,
const char*
intptr_t,
const char*
);
/* DLL, Entry Points */
@@ -80,21 +80,21 @@ DEFINE_FUNC(SteamAPI_ISteamUserStats_SetAchievement)
static void ClearPointers(void)
{
SDL_UnloadObject(libHandle);
libHandle = NULL;
steamUserStats = (intptr_t) NULL;
SteamAPI_Init = NULL;
SteamAPI_Shutdown = NULL;
SteamAPI_RunCallbacks = NULL;
SteamInternal_CreateInterface = NULL;
SteamAPI_GetHSteamUser = NULL;
SteamAPI_GetHSteamPipe = NULL;
SteamAPI_ISteamClient_GetISteamUserStats = NULL;
SteamAPI_ISteamUserStats_RequestCurrentStats = NULL;
SteamAPI_ISteamUserStats_StoreStats = NULL;
SteamAPI_ISteamUserStats_GetStat = NULL;
SteamAPI_ISteamUserStats_SetStat = NULL;
SteamAPI_ISteamUserStats_SetAchievement = NULL;
SDL_UnloadObject(libHandle);
libHandle = NULL;
steamUserStats = (intptr_t) NULL;
SteamAPI_Init = NULL;
SteamAPI_Shutdown = NULL;
SteamAPI_RunCallbacks = NULL;
SteamInternal_CreateInterface = NULL;
SteamAPI_GetHSteamUser = NULL;
SteamAPI_GetHSteamPipe = NULL;
SteamAPI_ISteamClient_GetISteamUserStats = NULL;
SteamAPI_ISteamUserStats_RequestCurrentStats = NULL;
SteamAPI_ISteamUserStats_StoreStats = NULL;
SteamAPI_ISteamUserStats_GetStat = NULL;
SteamAPI_ISteamUserStats_SetStat = NULL;
SteamAPI_ISteamUserStats_SetAchievement = NULL;
}
/* NETWORK API Implementation */
@@ -102,127 +102,127 @@ static void ClearPointers(void)
int32_t STEAM_init(void)
{
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__HAIKU__) || defined(__DragonFly__)
return 0;
return 0;
#endif
intptr_t steamClient;
int32_t steamUser, steamPipe;
intptr_t steamClient;
int32_t steamUser, steamPipe;
libHandle = SDL_LoadObject(STEAM_LIBRARY);
if (!libHandle)
{
vlog_info("%s not found!", STEAM_LIBRARY);
return 0;
}
libHandle = SDL_LoadObject(STEAM_LIBRARY);
if (!libHandle)
{
vlog_info("%s not found!", STEAM_LIBRARY);
return 0;
}
#define LOAD_FUNC(name) \
name = (name##Func) SDL_LoadFunction(libHandle, #name); \
if (!name) \
{ \
vlog_error("%s symbol %s not found!", STEAM_LIBRARY, #name); \
ClearPointers(); \
return 0; \
}
LOAD_FUNC(SteamAPI_Init)
LOAD_FUNC(SteamAPI_Shutdown)
LOAD_FUNC(SteamAPI_RunCallbacks)
LOAD_FUNC(SteamInternal_CreateInterface)
LOAD_FUNC(SteamAPI_GetHSteamUser)
LOAD_FUNC(SteamAPI_GetHSteamPipe)
LOAD_FUNC(SteamAPI_ISteamClient_GetISteamUserStats)
LOAD_FUNC(SteamAPI_ISteamUserStats_RequestCurrentStats)
LOAD_FUNC(SteamAPI_ISteamUserStats_StoreStats)
LOAD_FUNC(SteamAPI_ISteamUserStats_GetStat)
LOAD_FUNC(SteamAPI_ISteamUserStats_SetStat)
LOAD_FUNC(SteamAPI_ISteamUserStats_SetAchievement)
#undef LOAD_FUNC
#define LOAD_FUNC(name) \
name = (name##Func) SDL_LoadFunction(libHandle, #name); \
if (!name) \
{ \
vlog_error("%s symbol %s not found!", STEAM_LIBRARY, #name); \
ClearPointers(); \
return 0; \
}
LOAD_FUNC(SteamAPI_Init)
LOAD_FUNC(SteamAPI_Shutdown)
LOAD_FUNC(SteamAPI_RunCallbacks)
LOAD_FUNC(SteamInternal_CreateInterface)
LOAD_FUNC(SteamAPI_GetHSteamUser)
LOAD_FUNC(SteamAPI_GetHSteamPipe)
LOAD_FUNC(SteamAPI_ISteamClient_GetISteamUserStats)
LOAD_FUNC(SteamAPI_ISteamUserStats_RequestCurrentStats)
LOAD_FUNC(SteamAPI_ISteamUserStats_StoreStats)
LOAD_FUNC(SteamAPI_ISteamUserStats_GetStat)
LOAD_FUNC(SteamAPI_ISteamUserStats_SetStat)
LOAD_FUNC(SteamAPI_ISteamUserStats_SetAchievement)
#undef LOAD_FUNC
if (!SteamAPI_Init())
{
vlog_error("Steamworks not initialized!");
ClearPointers();
return 0;
}
steamClient = SteamInternal_CreateInterface(VVVVVV_STEAMCLIENT);
steamUser = SteamAPI_GetHSteamUser();
steamPipe = SteamAPI_GetHSteamPipe();
if (!steamClient || !steamUser || !steamPipe)
{
SteamAPI_Shutdown();
vlog_error(VVVVVV_STEAMCLIENT " not created!");
ClearPointers();
return 0;
}
steamUserStats = SteamAPI_ISteamClient_GetISteamUserStats(
steamClient,
steamUser,
steamPipe,
VVVVVV_STEAMUSERSTATS
);
if (!steamUserStats)
{
SteamAPI_Shutdown();
vlog_error(VVVVVV_STEAMUSERSTATS " not created!");
ClearPointers();
return 0;
}
SteamAPI_ISteamUserStats_RequestCurrentStats(steamUserStats);
return 1;
if (!SteamAPI_Init())
{
vlog_error("Steamworks not initialized!");
ClearPointers();
return 0;
}
steamClient = SteamInternal_CreateInterface(VVVVVV_STEAMCLIENT);
steamUser = SteamAPI_GetHSteamUser();
steamPipe = SteamAPI_GetHSteamPipe();
if (!steamClient || !steamUser || !steamPipe)
{
SteamAPI_Shutdown();
vlog_error(VVVVVV_STEAMCLIENT " not created!");
ClearPointers();
return 0;
}
steamUserStats = SteamAPI_ISteamClient_GetISteamUserStats(
steamClient,
steamUser,
steamPipe,
VVVVVV_STEAMUSERSTATS
);
if (!steamUserStats)
{
SteamAPI_Shutdown();
vlog_error(VVVVVV_STEAMUSERSTATS " not created!");
ClearPointers();
return 0;
}
SteamAPI_ISteamUserStats_RequestCurrentStats(steamUserStats);
return 1;
}
void STEAM_shutdown(void)
{
if (libHandle)
{
SteamAPI_Shutdown();
ClearPointers();
}
if (libHandle)
{
SteamAPI_Shutdown();
ClearPointers();
}
}
void STEAM_update(void)
{
if (libHandle)
{
SteamAPI_RunCallbacks();
}
if (libHandle)
{
SteamAPI_RunCallbacks();
}
}
void STEAM_unlockAchievement(const char *name)
{
if (libHandle)
{
SteamAPI_ISteamUserStats_SetAchievement(
steamUserStats,
name
);
SteamAPI_ISteamUserStats_StoreStats(steamUserStats);
}
if (libHandle)
{
SteamAPI_ISteamUserStats_SetAchievement(
steamUserStats,
name
);
SteamAPI_ISteamUserStats_StoreStats(steamUserStats);
}
}
int32_t STEAM_getAchievementProgress(const char *name)
{
int32_t result = -1;
if (libHandle)
{
SteamAPI_ISteamUserStats_GetStat(
steamUserStats,
name,
&result
);
}
return result;
int32_t result = -1;
if (libHandle)
{
SteamAPI_ISteamUserStats_GetStat(
steamUserStats,
name,
&result
);
}
return result;
}
void STEAM_setAchievementProgress(const char *name, int32_t stat)
{
if (libHandle)
{
SteamAPI_ISteamUserStats_SetStat(
steamUserStats,
name,
stat
);
SteamAPI_ISteamUserStats_StoreStats(steamUserStats);
}
if (libHandle)
{
SteamAPI_ISteamUserStats_SetStat(
steamUserStats,
name,
stat
);
SteamAPI_ISteamUserStats_StoreStats(steamUserStats);
}
}
#endif /* MAKEANDPLAY */
+1 -1
View File
@@ -416,7 +416,7 @@ void scriptclass::loadother(const char* t)
static const char* lines[] = {
//"delay(15)", "flash(5)", "shake(20)", "playef(9)",
//"delay(15)", "flash(5)", "shake(20)", "playef(9)",
"text(gray,0,114,3)",
" -= WARNING =- ",
+1103 -1103
View File
File diff suppressed because it is too large Load Diff
+10 -10
View File
@@ -5,16 +5,16 @@
struct TowerBG
{
SDL_Surface* buffer;
SDL_Surface* buffer_lerp;
bool tdrawback;
int bypos;
int bscroll;
int colstate;
int scrolldir;
int r;
int g;
int b;
SDL_Surface* buffer;
SDL_Surface* buffer_lerp;
bool tdrawback;
int bypos;
int bscroll;
int colstate;
int scrolldir;
int r;
int g;
int b;
};
#endif /* TOWERBG_H */
+256 -256
View File
@@ -8,354 +8,354 @@
static const char* GCChar(const SDL_GameControllerButton button)
{
switch (button)
{
case SDL_CONTROLLER_BUTTON_A:
return "A";
case SDL_CONTROLLER_BUTTON_B:
return "B";
case SDL_CONTROLLER_BUTTON_X:
return "X";
case SDL_CONTROLLER_BUTTON_Y:
return "Y";
case SDL_CONTROLLER_BUTTON_BACK:
return "BACK";
case SDL_CONTROLLER_BUTTON_GUIDE:
return "GUIDE";
case SDL_CONTROLLER_BUTTON_START:
return "START";
case SDL_CONTROLLER_BUTTON_LEFTSTICK:
return "L3";
case SDL_CONTROLLER_BUTTON_RIGHTSTICK:
return "R3";
case SDL_CONTROLLER_BUTTON_LEFTSHOULDER:
return "LB";
case SDL_CONTROLLER_BUTTON_RIGHTSHOULDER:
return "RB";
default:
SDL_assert(0 && "Unhandled button!");
return NULL;
}
switch (button)
{
case SDL_CONTROLLER_BUTTON_A:
return "A";
case SDL_CONTROLLER_BUTTON_B:
return "B";
case SDL_CONTROLLER_BUTTON_X:
return "X";
case SDL_CONTROLLER_BUTTON_Y:
return "Y";
case SDL_CONTROLLER_BUTTON_BACK:
return "BACK";
case SDL_CONTROLLER_BUTTON_GUIDE:
return "GUIDE";
case SDL_CONTROLLER_BUTTON_START:
return "START";
case SDL_CONTROLLER_BUTTON_LEFTSTICK:
return "L3";
case SDL_CONTROLLER_BUTTON_RIGHTSTICK:
return "R3";
case SDL_CONTROLLER_BUTTON_LEFTSHOULDER:
return "LB";
case SDL_CONTROLLER_BUTTON_RIGHTSHOULDER:
return "RB";
default:
SDL_assert(0 && "Unhandled button!");
return NULL;
}
}
int ss_toi(const std::string& str)
{
int retval = 0;
bool negative = false;
static const int radix = 10;
int retval = 0;
bool negative = false;
static const int radix = 10;
for (size_t i = 0; i < str.size(); ++i)
{
const char chr = str[i];
for (size_t i = 0; i < str.size(); ++i)
{
const char chr = str[i];
if (i == 0 && chr == '-')
{
negative = true;
continue;
}
if (i == 0 && chr == '-')
{
negative = true;
continue;
}
if (SDL_isdigit(chr))
{
retval *= radix;
retval += chr - '0';
}
else
{
break;
}
}
if (SDL_isdigit(chr))
{
retval *= radix;
retval += chr - '0';
}
else
{
break;
}
}
if (negative)
{
return -retval;
}
if (negative)
{
return -retval;
}
return retval;
return retval;
}
bool next_split(
size_t* start,
size_t* len,
const char* str,
const char delim
size_t* start,
size_t* len,
const char* str,
const char delim
) {
size_t idx = 0;
*len = 0;
size_t idx = 0;
*len = 0;
if (str[idx] == '\0')
{
return false;
}
if (str[idx] == '\0')
{
return false;
}
while (true)
{
if (str[idx] == delim)
{
*start += 1;
return true;
}
else if (str[idx] == '\0')
{
return true;
}
while (true)
{
if (str[idx] == delim)
{
*start += 1;
return true;
}
else if (str[idx] == '\0')
{
return true;
}
idx += 1;
*start += 1;
*len += 1;
}
idx += 1;
*start += 1;
*len += 1;
}
}
bool next_split_s(
char buffer[],
const size_t buffer_size,
size_t* start,
const char* str,
const char delim
char buffer[],
const size_t buffer_size,
size_t* start,
const char* str,
const char delim
) {
size_t len = 0;
const size_t prev_start = *start;
size_t len = 0;
const size_t prev_start = *start;
const bool retval = next_split(start, &len, &str[*start], delim);
const bool retval = next_split(start, &len, &str[*start], delim);
if (retval)
{
/* Using SDL_strlcpy() here results in calling SDL_strlen() */
/* on the whole string, which results in a visible freeze */
/* if it's a very large string */
const size_t length = VVV_min(buffer_size - 1, len);
SDL_memcpy(buffer, &str[prev_start], length);
buffer[length] = '\0';
}
if (retval)
{
/* Using SDL_strlcpy() here results in calling SDL_strlen() */
/* on the whole string, which results in a visible freeze */
/* if it's a very large string */
const size_t length = VVV_min(buffer_size - 1, len);
SDL_memcpy(buffer, &str[prev_start], length);
buffer[length] = '\0';
}
return retval;
return retval;
}
UtilityClass::UtilityClass(void) :
glow(0),
glowdir(0)
glowdir(0)
{
for (size_t i = 0; i < SDL_arraysize(splitseconds); i++)
{
splitseconds[i] = (i * 100) / 30;
}
for (size_t i = 0; i < SDL_arraysize(splitseconds); i++)
{
splitseconds[i] = (i * 100) / 30;
}
slowsine = 0;
slowsine = 0;
}
std::string UtilityClass::String( int _v )
{
std::ostringstream os;
os << _v;
return(os.str());
std::ostringstream os;
os << _v;
return(os.str());
}
int UtilityClass::Int(const char* str, int fallback /*= 0*/)
{
if (!is_number(str))
{
return fallback;
}
if (!is_number(str))
{
return fallback;
}
return (int) SDL_strtol(str, NULL, 0);
return (int) SDL_strtol(str, NULL, 0);
}
std::string UtilityClass::GCString(const std::vector<SDL_GameControllerButton>& buttons)
{
std::string retval = "";
for (size_t i = 0; i < buttons.size(); i += 1)
{
retval += GCChar(buttons[i]);
if ((i + 1) < buttons.size())
{
retval += ",";
}
}
return retval;
std::string retval = "";
for (size_t i = 0; i < buttons.size(); i += 1)
{
retval += GCChar(buttons[i]);
if ((i + 1) < buttons.size())
{
retval += ",";
}
}
return retval;
}
std::string UtilityClass::twodigits( int t )
{
if (t < 10)
{
return "0" + String(t);
}
if (t >= 100)
{
return "??";
}
return String(t);
if (t < 10)
{
return "0" + String(t);
}
if (t >= 100)
{
return "??";
}
return String(t);
}
std::string UtilityClass::timestring( int t )
{
//given a time t in frames, return a time in seconds
std::string tempstring = "";
int temp = (t - (t % 30)) / 30;
if (temp < 60) //less than one minute
{
t = t % 30;
tempstring = String(temp) + ":" + twodigits(splitseconds[t]);
}
else
{
int temp2 = (temp - (temp % 60)) / 60;
temp = temp % 60;
t = t % 30;
tempstring = String(temp2) + ":" + twodigits(temp) + ":" + twodigits(splitseconds[t]);
}
return tempstring;
//given a time t in frames, return a time in seconds
std::string tempstring = "";
int temp = (t - (t % 30)) / 30;
if (temp < 60) //less than one minute
{
t = t % 30;
tempstring = String(temp) + ":" + twodigits(splitseconds[t]);
}
else
{
int temp2 = (temp - (temp % 60)) / 60;
temp = temp % 60;
t = t % 30;
tempstring = String(temp2) + ":" + twodigits(temp) + ":" + twodigits(splitseconds[t]);
}
return tempstring;
}
std::string UtilityClass::number( int _t )
{
static const std::string ones_place[] = {"One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine"};
static const std::string tens_place[] = {"Ten", "Twenty", "Thirty", "Forty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety"};
static const std::string teens[] = {"Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen"};
static const std::string ones_place[] = {"One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine"};
static const std::string tens_place[] = {"Ten", "Twenty", "Thirty", "Forty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety"};
static const std::string teens[] = {"Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen"};
if (_t < 0)
{
return "???";
}
else if (_t > 100)
{
return "Lots";
}
else if (_t == 0)
{
return "Zero";
}
else if (_t == 100)
{
return "One Hundred";
}
else if (_t >= 1 && _t <= 9)
{
return ones_place[_t-1];
}
else if (_t >= 11 && _t <= 19)
{
return teens[_t-11];
}
else if (_t % 10 == 0)
{
return tens_place[(_t/10)-1];
}
else
{
return tens_place[(_t/10)-1] + " " + ones_place[(_t%10)-1];
}
if (_t < 0)
{
return "???";
}
else if (_t > 100)
{
return "Lots";
}
else if (_t == 0)
{
return "Zero";
}
else if (_t == 100)
{
return "One Hundred";
}
else if (_t >= 1 && _t <= 9)
{
return ones_place[_t-1];
}
else if (_t >= 11 && _t <= 19)
{
return teens[_t-11];
}
else if (_t % 10 == 0)
{
return tens_place[(_t/10)-1];
}
else
{
return tens_place[(_t/10)-1] + " " + ones_place[(_t%10)-1];
}
}
bool UtilityClass::intersects( SDL_Rect A, SDL_Rect B )
{
return (SDL_HasIntersection(&A, &B) == SDL_TRUE);
return (SDL_HasIntersection(&A, &B) == SDL_TRUE);
}
void UtilityClass::updateglow(void)
{
slowsine++;
if (slowsine >= 64) slowsine = 0;
slowsine++;
if (slowsine >= 64) slowsine = 0;
if (glowdir == 0) {
glow+=2;
if (glow >= 62) glowdir = 1;
}else {
glow-=2;
if (glow < 2) glowdir = 0;
}
if (glowdir == 0) {
glow+=2;
if (glow >= 62) glowdir = 1;
}else {
glow-=2;
if (glow < 2) glowdir = 0;
}
}
bool is_number(const char* str)
{
if (!SDL_isdigit(str[0]) && str[0] != '-')
{
return false;
}
if (!SDL_isdigit(str[0]) && str[0] != '-')
{
return false;
}
if (str[0] == '-' && str[1] == '\0')
{
return false;
}
if (str[0] == '-' && str[1] == '\0')
{
return false;
}
for (size_t i = 1; str[i] != '\0'; ++i)
{
if (!SDL_isdigit(str[i]))
{
return false;
}
}
for (size_t i = 1; str[i] != '\0'; ++i)
{
if (!SDL_isdigit(str[i]))
{
return false;
}
}
return true;
return true;
}
static bool VVV_isxdigit(const unsigned char digit)
{
return (digit >= 'a' && digit <= 'f')
|| (digit >= 'A' && digit <= 'F')
|| SDL_isdigit(digit);
return (digit >= 'a' && digit <= 'f')
|| (digit >= 'A' && digit <= 'F')
|| SDL_isdigit(digit);
}
bool is_positive_num(const char* str, const bool hex)
{
if (str[0] == '\0')
{
return false;
}
if (str[0] == '\0')
{
return false;
}
for (size_t i = 0; str[i] != '\0'; ++i)
{
if (hex)
{
if (!VVV_isxdigit(str[i]))
{
return false;
}
}
else
{
if (!SDL_isdigit(str[i]))
{
return false;
}
}
}
for (size_t i = 0; str[i] != '\0'; ++i)
{
if (hex)
{
if (!VVV_isxdigit(str[i]))
{
return false;
}
}
else
{
if (!SDL_isdigit(str[i]))
{
return false;
}
}
}
return true;
return true;
}
bool endsWith(const char* str, const char* suffix)
{
const size_t str_size = SDL_strlen(str);
const size_t suffix_size = SDL_strlen(suffix);
const size_t str_size = SDL_strlen(str);
const size_t suffix_size = SDL_strlen(suffix);
if (str_size < suffix_size)
{
return false;
}
if (str_size < suffix_size)
{
return false;
}
return SDL_strcmp(&str[str_size - suffix_size], suffix) == 0;
return SDL_strcmp(&str[str_size - suffix_size], suffix) == 0;
}
void VVV_fillstring(
char* buffer,
const size_t buffer_size,
const char fillchar
char* buffer,
const size_t buffer_size,
const char fillchar
) {
SDL_memset(buffer, fillchar, buffer_size - 1);
buffer[buffer_size - 1] = '\0';
SDL_memset(buffer, fillchar, buffer_size - 1);
buffer[buffer_size - 1] = '\0';
}
void _VVV_between(
const char* original,
const size_t left_length,
char* middle,
const size_t right_length,
const size_t middle_size
const char* original,
const size_t left_length,
char* middle,
const size_t right_length,
const size_t middle_size
) {
size_t middle_length = SDL_strlen(original);
middle_length -= left_length + right_length;
SDL_strlcpy(
middle,
&original[left_length],
VVV_min(middle_length + 1, middle_size)
);
size_t middle_length = SDL_strlen(original);
middle_length -= left_length + right_length;
SDL_strlcpy(
middle,
&original[left_length],
VVV_min(middle_length + 1, middle_size)
);
}
File diff suppressed because it is too large Load Diff
+4 -4
View File
@@ -6,10 +6,10 @@
class warpclass
{
public:
const short* loadlevel(int rx, int ry);
std::string roomname;
int rcol;
bool warpx, warpy;
const short* loadlevel(int rx, int ry);
std::string roomname;
int rcol;
bool warpx, warpy;
};
#endif /* WARPCLASS_H */
+6 -6
View File
@@ -2,15 +2,15 @@
# Get interim commit and date of commit
EXECUTE_PROCESS(
COMMAND "${GIT_EXECUTABLE}" log -1 --format=%h
OUTPUT_VARIABLE INTERIM_COMMIT
OUTPUT_STRIP_TRAILING_WHITESPACE
COMMAND "${GIT_EXECUTABLE}" log -1 --format=%h
OUTPUT_VARIABLE INTERIM_COMMIT
OUTPUT_STRIP_TRAILING_WHITESPACE
)
EXECUTE_PROCESS(
COMMAND "${GIT_EXECUTABLE}" log -1 --format=%cs
OUTPUT_VARIABLE COMMIT_DATE
OUTPUT_STRIP_TRAILING_WHITESPACE
COMMAND "${GIT_EXECUTABLE}" log -1 --format=%cs
OUTPUT_VARIABLE COMMIT_DATE
OUTPUT_STRIP_TRAILING_WHITESPACE
)
MESSAGE(STATUS "This is interim commit ${INTERIM_COMMIT} (committed ${COMMIT_DATE})")