├── res └── win │ ├── CatacombGL.ico │ ├── resource.h │ └── CatacombGL.rc ├── src ├── Engine │ ├── DefaultFont.cpp │ ├── IIntroView.cpp │ ├── FadeEffect.h │ ├── AudioPlayer.h │ ├── FileChunk.h │ ├── Console.h │ ├── FileChunk.cpp │ ├── FramesCounter.h │ ├── Logging.h │ ├── Score.h │ ├── Font.cpp │ ├── RenderableOverscanBorder.h │ ├── HelpPages.h │ ├── ConsoleVariable.h │ ├── Huffman.h │ ├── DefaultFont.h │ ├── PictureTable.h │ ├── PCSound.h │ ├── ConsoleVariableString.h │ ├── Font.h │ ├── CommandLineParser.h │ ├── GuiElementHighScores.h │ ├── GuiElementStaticText.h │ ├── ConsoleVariableBool.h │ ├── SavedGamesInDosFormat.h │ ├── IIntroView.h │ ├── ViewPorts.h │ ├── GuiElementStaticText.cpp │ ├── Renderable3DWalls.h │ ├── ISystem.h │ ├── GuiElementButton.h │ ├── RenderableLevelStatistics.h │ ├── GuiElementBoolSelection.h │ ├── GuiElementIntSelection.h │ ├── GuiElementEnumSelection.h │ ├── Renderable3DWalls.cpp │ ├── ManaBar.h │ ├── Decompressor.h │ ├── LevelLocationNames.h │ ├── OverscanBorder.h │ ├── GuiElementBindKey.h │ ├── GuiPage.h │ ├── ISavedGameConverter.h │ ├── GuiCatalog.h │ ├── ConsoleVariable.cpp │ ├── Picture.h │ ├── FramesCounter.cpp │ ├── GuiMenu.h │ ├── ConsoleVariableInt.h │ ├── GameDetection.h │ ├── ConsoleVariableString.cpp │ ├── AdlibSound.h │ ├── Shape.h │ ├── GuiElementEditText.h │ ├── Renderable3DTiles.h │ ├── SavedGameInDosFormatLoader.h │ ├── ConsoleVariableEnum.h │ ├── GuiElementButton.cpp │ ├── GameTimer.h │ ├── Radar.h │ ├── GuiElementList.h │ ├── SpriteTable.h │ ├── GameSelection.h │ ├── Macros.h │ ├── OverscanBorder.cpp │ ├── AudioRepository.h │ ├── Renderable3DTiles.cpp │ ├── PictureTable.cpp │ ├── Picture.cpp │ ├── AudioPlayer.cpp │ ├── GuiElementBoolSelection.cpp │ ├── GuiElementEnumSelection.cpp │ ├── Score.cpp │ ├── ConsoleVariableBool.cpp │ └── HighScores.h ├── System │ ├── CMakeLists.txt │ ├── WindowSDL.h │ ├── OpenGLUtilityLocal.h │ └── Finder.h ├── Abyss │ ├── CMakeLists.txt │ ├── SavedGameInDosFormatConfigAbyss.h │ └── IntroViewAbyss.h ├── Apocalypse │ ├── CMakeLists.txt │ ├── SavedGameInDosFormatConfigApocalypse.h │ ├── GameDetectionApocalypse.h │ └── IntroViewApocalypse.h ├── Armageddon │ ├── CMakeLists.txt │ ├── SavesGameInDosFormatConfigArmageddon.h │ ├── GameDetectionArmageddon.h │ └── IntroViewArmageddon.h ├── Test │ ├── main.cpp │ ├── HelpPages_Test.h │ ├── ViewPorts_Test.h │ ├── ConsoleVariableBool_Test.h │ ├── TextureAtlas_Test.h │ ├── ConsoleVariableEnum_Test.h │ ├── ConsoleVariableInt_Test.h │ ├── GameCatacomb3D_Test.h │ ├── SavedGameInDosFormat_Test.h │ ├── CommandLineParser_Test.h │ ├── ConsoleVariableString_Test.h │ ├── GameAbyss_Test.h │ ├── GameArmageddon_Test.h │ ├── SavedGamesInDosFormat_Test.h │ ├── FramesCounter_Test.h │ ├── GameApocalypse_Test.h │ ├── SavedGameConverterAbyss_Test.h │ ├── SavedGameInDosFormatLoader_Test.h │ ├── LevelLocationNames_Test.h │ ├── SavedGameConverterCatacomb3D_Test.h │ ├── SavedGameConverterApocalypse_Test.h │ ├── SavedGameConverterArmageddon_Test.h │ ├── GuiMenu_Test.h │ ├── GuiElementList_Test.h │ ├── GuiElementEditText_Test.h │ ├── HelpPages_Test.cpp │ ├── FramesCounter_Test.cpp │ └── LevelLocationNames_Test.cpp └── Catacomb3D │ ├── GuiElementSaveSlotStaticCat3D.h │ ├── GuiElementButtonCat3D.h │ ├── GameDetectionCatacomb3D.h │ ├── GuiElementIntSelectionCat3D.h │ ├── GuiElementBindKeyCat3D.h │ ├── GuiElementBoolSelectionCat3D.h │ ├── CMakeLists.txt │ ├── GuiElementEnumSelectionCat3D.h │ ├── GuiElementEnumSelectionCat3DRadio.h │ ├── GuiElementSaveSlotEditableCat3D.h │ ├── GuiElementButtonCat3D.cpp │ ├── IntroViewCatacomb3D.h │ ├── SavedInGameInDosFormatConfigCatacomb3D.h │ ├── GuiElementSaveSlotStaticCat3D.cpp │ ├── GuiElementBoolSelectionCat3D.cpp │ ├── GuiElementEnumSelectionCat3D.cpp │ ├── GuiElementIntSelectionCat3D.cpp │ └── SavedGameConverterCatacomb3D.h ├── ThirdParty ├── ReflectionHLE │ ├── backend │ │ ├── threading │ │ │ ├── be_mutex.h │ │ │ ├── be_atomic.h │ │ │ ├── be_atomic_sdl.h │ │ │ └── be_mutex_sdl.h │ │ ├── audio │ │ │ └── be_audio_main_thread.h │ │ ├── cfg │ │ │ └── be_cfg_sdl.c │ │ └── timing │ │ │ └── be_timing.h │ └── be_sound_device_flags.h └── CMakeLists.txt ├── .gitignore ├── TC-mingw.cmake └── doc └── licenses └── SDL2.txt /res/win/CatacombGL.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArnoAnsems/CatacombGL/HEAD/res/win/CatacombGL.ico -------------------------------------------------------------------------------- /src/Engine/DefaultFont.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArnoAnsems/CatacombGL/HEAD/src/Engine/DefaultFont.cpp -------------------------------------------------------------------------------- /ThirdParty/ReflectionHLE/backend/threading/be_mutex.h: -------------------------------------------------------------------------------- 1 | #ifdef REFKEEN_CONFIG_THREADS 2 | #include "be_mutex_sdl.h" 3 | #endif 4 | -------------------------------------------------------------------------------- /ThirdParty/ReflectionHLE/backend/threading/be_atomic.h: -------------------------------------------------------------------------------- 1 | #ifdef REFKEEN_CONFIG_THREADS 2 | #include "be_atomic_sdl.h" 3 | #endif 4 | -------------------------------------------------------------------------------- /ThirdParty/ReflectionHLE/be_sound_device_flags.h: -------------------------------------------------------------------------------- 1 | enum 2 | { 3 | BE_AUDIO_DEVICE_PCSPKR = 1, 4 | BE_AUDIO_DEVICE_PCSPKR_REQUIRED = 1 | 2, 5 | BE_AUDIO_DEVICE_OPL = 4, 6 | BE_AUDIO_DEVICE_DIGI = 8, 7 | BE_AUDIO_DEVICE_DIGI_REQUIRED = 8 | 16 8 | }; 9 | -------------------------------------------------------------------------------- /ThirdParty/ReflectionHLE/backend/audio/be_audio_main_thread.h: -------------------------------------------------------------------------------- 1 | int BEL_ST_PrepareMainThreadForAudio(int *freq, int *channels, int expectedCallbackBufferLen); 2 | void BEL_ST_ClearMainThreadAudioResources(void); 3 | void BE_ST_PrepareForManualAudioCallbackCall(void); 4 | -------------------------------------------------------------------------------- /src/System/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.16) 2 | project(CatacombGL_Cross LANGUAGES CXX) 3 | 4 | target_sources( CatacombGL 5 | PUBLIC 6 | CatacombGL.cpp 7 | Finder.cpp 8 | RendererOpenGL.cpp 9 | SystemSDL.h 10 | WindowSDL.h 11 | Finder.h 12 | RendererOpenGL.h 13 | SystemSDL.cpp 14 | WindowSDL.cpp 15 | OpenGLUtilityLocal.h 16 | OpenGLUtilityLocal.cpp 17 | ) 18 | 19 | -------------------------------------------------------------------------------- /res/win/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by CatacombGL.rc 4 | // 5 | #define IDI_ICON1 101 6 | 7 | // Next default values for new objects 8 | // 9 | #ifdef APSTUDIO_INVOKED 10 | #ifndef APSTUDIO_READONLY_SYMBOLS 11 | #define _APS_NEXT_RESOURCE_VALUE 103 12 | #define _APS_NEXT_COMMAND_VALUE 40001 13 | #define _APS_NEXT_CONTROL_VALUE 1001 14 | #define _APS_NEXT_SYMED_VALUE 101 15 | #endif 16 | #endif 17 | -------------------------------------------------------------------------------- /ThirdParty/ReflectionHLE/backend/threading/be_atomic_sdl.h: -------------------------------------------------------------------------------- 1 | #ifndef BE_ATOMIC_SDL_H 2 | #define BE_ATOMIC_SDL_H 3 | 4 | #include "SDL_atomic.h" 5 | 6 | typedef SDL_atomic_t BE_ST_AtomicInt_T; 7 | 8 | static int BE_ST_AtomicInt_Set(BE_ST_AtomicInt_T *a, int n) { return SDL_AtomicSet(a, n); } 9 | static int BE_ST_AtomicInt_Get(BE_ST_AtomicInt_T *a) { return SDL_AtomicGet(a); } 10 | static int BE_ST_AtomicInt_PostAdd(BE_ST_AtomicInt_T *a, int n) { return SDL_AtomicAdd(a, n); } 11 | static int BE_ST_AtomicInt_PostInc(BE_ST_AtomicInt_T *a) { return SDL_AtomicAdd(a, 1); } 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /src/Abyss/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.16) 2 | project(CatacombGL_Abyss LANGUAGES CXX) 3 | 4 | add_library( CatacombGL_Abyss OBJECT 5 | AudioRepositoryAbyss.h 6 | DecorateAll.h 7 | DecorateBonus.h 8 | DecorateMisc.h 9 | DecorateMonsters.h 10 | DecorateProjectiles.h 11 | EgaGraphAbyss.h 12 | GameAbyss.cpp 13 | GameAbyss.h 14 | GameDetectionAbyss.h 15 | GameMapsAbyss.h 16 | IntroViewAbyss.cpp 17 | IntroViewAbyss.h 18 | SavedGameConverterAbyss.cpp 19 | SavedGameConverterAbyss.h 20 | SavedGameInDosFormatConfigAbyss.h 21 | ) 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | 18 | # Fortran module files 19 | *.mod 20 | *.smod 21 | 22 | # Compiled Static libraries 23 | *.lai 24 | *.la 25 | *.a 26 | 27 | # Executables 28 | *.exe 29 | *.out 30 | *.app 31 | *.pdb 32 | *.iobj 33 | *.ipdb 34 | *.log 35 | *.tlog 36 | VS2019/.vs 37 | .vs/ 38 | *.db 39 | *.opendb 40 | build/ 41 | bin/ 42 | *.ilk 43 | *.idb 44 | *.tmp 45 | src/Catacomb3D/Catacomb3D.vcxproj.user 46 | *.C3D 47 | -------------------------------------------------------------------------------- /ThirdParty/ReflectionHLE/backend/threading/be_mutex_sdl.h: -------------------------------------------------------------------------------- 1 | #ifndef BE_MUTEX_SDL_H 2 | #define BE_MUTEX_SDL_H 3 | 4 | #include 5 | #include "SDL_mutex.h" 6 | 7 | typedef SDL_mutex BE_ST_Mutex_T; 8 | 9 | static inline BE_ST_Mutex_T *BE_ST_CreateMutex(void) { return SDL_CreateMutex(); } 10 | static inline void BE_ST_FreeMutex(BE_ST_Mutex_T *mutex) { SDL_DestroyMutex(mutex); } 11 | static inline void BE_ST_LockMutexRecursively(BE_ST_Mutex_T *mutex) { assert(!SDL_LockMutex(mutex)); } 12 | static inline void BE_ST_UnlockMutexRecursively(BE_ST_Mutex_T *mutex) { assert(!SDL_UnlockMutex(mutex)); } 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /src/Apocalypse/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.16) 2 | project(CatacombGL_Apocalypse LANGUAGES CXX) 3 | 4 | add_library( CatacombGL_Apocalypse OBJECT 5 | AudioRepositoryApocalypse.h 6 | DecorateAll.h 7 | DecorateBonus.h 8 | DecorateMisc.h 9 | DecorateMonsters.h 10 | DecorateProjectiles.h 11 | EgaGraphApocalypse.h 12 | GameApocalypse.cpp 13 | GameApocalypse.h 14 | GameDetectionApocalypse.h 15 | GameMapsApocalypse.h 16 | IntroViewApocalypse.cpp 17 | IntroViewApocalypse.h 18 | SavedGameConverterApocalypse.cpp 19 | SavedGameConverterApocalypse.h 20 | SavedGameInDosFormatConfigApocalypse.h 21 | ) 22 | -------------------------------------------------------------------------------- /src/Armageddon/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.16) 2 | project(CatacombGL_Armageddon LANGUAGES CXX) 3 | 4 | add_library( CatacombGL_Armageddon OBJECT 5 | AudioRepositoryArmageddon.h 6 | DecorateAll.h 7 | DecorateBonus.h 8 | DecorateMisc.h 9 | DecorateMonsters.h 10 | DecorateProjectiles.h 11 | EgaGraphArmageddon.h 12 | GameArmageddon.cpp 13 | GameArmageddon.h 14 | GameDetectionArmageddon.h 15 | GameMapsArmageddon.h 16 | IntroViewArmageddon.cpp 17 | IntroViewArmageddon.h 18 | SavedGameConverterArmageddon.cpp 19 | SavedGameConverterArmageddon.h 20 | SavesGameInDosFormatConfigArmageddon.h 21 | ) 22 | -------------------------------------------------------------------------------- /TC-mingw.cmake: -------------------------------------------------------------------------------- 1 | # the name of the target operating system 2 | set(CMAKE_SYSTEM_NAME Windows) 3 | 4 | # which compilers to use for C and C++ 5 | set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc) 6 | set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++) 7 | 8 | # where is the target environment located 9 | set(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32/) 10 | 11 | # adjust the default behavior of the FIND_XXX() commands: 12 | # search programs in the host environment 13 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 14 | 15 | # search headers and libraries in the target environment 16 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 17 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 18 | 19 | # run windows tests in wine 20 | set(CMAKE_CROSSCOMPILING_EMULATOR wine) 21 | -------------------------------------------------------------------------------- /src/Engine/IIntroView.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2018 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | #include "IIntroView.h" 17 | 18 | IIntroView::IIntroView(IRenderer& renderer) : 19 | m_renderer(renderer) 20 | { 21 | 22 | } -------------------------------------------------------------------------------- /src/Test/main.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2018 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | #include 17 | 18 | using namespace ::testing; 19 | 20 | int main(int argc, char** argv) 21 | { 22 | ::testing::InitGoogleTest(&argc, argv); 23 | return RUN_ALL_TESTS(); 24 | } 25 | -------------------------------------------------------------------------------- /src/Test/HelpPages_Test.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | #pragma once 17 | 18 | #include 19 | 20 | class HelpPages_Test : public ::testing::Test 21 | { 22 | public: 23 | HelpPages_Test(); 24 | virtual ~HelpPages_Test(); 25 | 26 | protected: 27 | 28 | }; 29 | -------------------------------------------------------------------------------- /src/Test/ViewPorts_Test.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | #pragma once 17 | 18 | #include 19 | 20 | class ViewPorts_Test : public ::testing::Test 21 | { 22 | public: 23 | ViewPorts_Test(); 24 | virtual ~ViewPorts_Test(); 25 | 26 | protected: 27 | 28 | }; 29 | -------------------------------------------------------------------------------- /src/Test/ConsoleVariableBool_Test.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | #pragma once 17 | 18 | #include 19 | 20 | class ConsoleVariableBool_Test : public ::testing::Test 21 | { 22 | public: 23 | ConsoleVariableBool_Test(); 24 | virtual ~ConsoleVariableBool_Test(); 25 | }; 26 | -------------------------------------------------------------------------------- /src/Test/TextureAtlas_Test.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | #pragma once 17 | 18 | #include 19 | 20 | class TextureAtlas_Test : public ::testing::Test 21 | { 22 | public: 23 | TextureAtlas_Test(); 24 | virtual ~TextureAtlas_Test(); 25 | 26 | protected: 27 | 28 | }; 29 | -------------------------------------------------------------------------------- /src/Test/ConsoleVariableEnum_Test.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | #pragma once 17 | 18 | #include 19 | 20 | class ConsoleVariableEnum_Test : public ::testing::Test 21 | { 22 | public: 23 | ConsoleVariableEnum_Test(); 24 | virtual ~ConsoleVariableEnum_Test(); 25 | }; 26 | 27 | -------------------------------------------------------------------------------- /src/Test/ConsoleVariableInt_Test.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | #pragma once 17 | 18 | #include 19 | 20 | class ConsoleVariableInt_Test : public ::testing::Test 21 | { 22 | public: 23 | ConsoleVariableInt_Test(); 24 | virtual ~ConsoleVariableInt_Test(); 25 | }; 26 | 27 | -------------------------------------------------------------------------------- /src/Test/GameCatacomb3D_Test.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | #pragma once 17 | 18 | #include 19 | 20 | class GameCatacomb3D_Test : public ::testing::Test 21 | { 22 | public: 23 | GameCatacomb3D_Test(); 24 | virtual ~GameCatacomb3D_Test(); 25 | 26 | protected: 27 | 28 | }; 29 | -------------------------------------------------------------------------------- /src/Test/SavedGameInDosFormat_Test.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | #pragma once 17 | 18 | #include 19 | 20 | class SavedGameInDosFormat_Test : public ::testing::Test 21 | { 22 | public: 23 | SavedGameInDosFormat_Test(); 24 | virtual ~SavedGameInDosFormat_Test(); 25 | }; 26 | 27 | -------------------------------------------------------------------------------- /doc/licenses/SDL2.txt: -------------------------------------------------------------------------------- 1 | 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2018 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | 21 | -------------------------------------------------------------------------------- /src/Test/CommandLineParser_Test.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2024 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | #pragma once 17 | 18 | #include 19 | 20 | class CommandLineParser_Test : public ::testing::Test 21 | { 22 | public: 23 | CommandLineParser_Test() = default; 24 | virtual ~CommandLineParser_Test() = default; 25 | }; 26 | -------------------------------------------------------------------------------- /src/Test/ConsoleVariableString_Test.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | #pragma once 17 | 18 | #include 19 | 20 | class ConsoleVariableString_Test : public ::testing::Test 21 | { 22 | public: 23 | ConsoleVariableString_Test(); 24 | virtual ~ConsoleVariableString_Test(); 25 | }; 26 | 27 | -------------------------------------------------------------------------------- /src/Test/GameAbyss_Test.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2018 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | #pragma once 17 | 18 | #include 19 | 20 | class GameAbyss_Test : public ::testing::Test 21 | { 22 | public: 23 | GameAbyss_Test(); 24 | virtual ~GameAbyss_Test(); 25 | 26 | protected: 27 | 28 | }; 29 | -------------------------------------------------------------------------------- /src/Test/GameArmageddon_Test.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | #pragma once 17 | 18 | #include 19 | 20 | class GameArmageddon_Test : public ::testing::Test 21 | { 22 | public: 23 | GameArmageddon_Test(); 24 | virtual ~GameArmageddon_Test(); 25 | 26 | protected: 27 | 28 | }; 29 | 30 | -------------------------------------------------------------------------------- /src/Test/SavedGamesInDosFormat_Test.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | #pragma once 17 | 18 | #include 19 | 20 | class SavedGamesInDosFormat_Test : public ::testing::Test 21 | { 22 | public: 23 | SavedGamesInDosFormat_Test(); 24 | virtual ~SavedGamesInDosFormat_Test(); 25 | }; 26 | 27 | -------------------------------------------------------------------------------- /src/Test/FramesCounter_Test.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2018 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | #pragma once 17 | 18 | #include 19 | 20 | class FramesCounter_Test : public ::testing::Test 21 | { 22 | public: 23 | FramesCounter_Test(); 24 | virtual ~FramesCounter_Test(); 25 | 26 | protected: 27 | 28 | }; -------------------------------------------------------------------------------- /src/Test/GameApocalypse_Test.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | #pragma once 17 | 18 | #include 19 | 20 | class GameApocalypse_Test : public ::testing::Test 21 | { 22 | public: 23 | GameApocalypse_Test(); 24 | virtual ~GameApocalypse_Test(); 25 | 26 | protected: 27 | 28 | }; 29 | 30 | #pragma once 31 | -------------------------------------------------------------------------------- /src/Test/SavedGameConverterAbyss_Test.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | #pragma once 17 | 18 | #include 19 | 20 | class SavedGameConverterAbyss_Test : public ::testing::Test 21 | { 22 | public: 23 | SavedGameConverterAbyss_Test(); 24 | virtual ~SavedGameConverterAbyss_Test(); 25 | 26 | protected: 27 | 28 | }; -------------------------------------------------------------------------------- /src/Test/SavedGameInDosFormatLoader_Test.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | #pragma once 17 | 18 | #include 19 | 20 | class SavedGameInDosFormatLoader_Test : public ::testing::Test 21 | { 22 | public: 23 | SavedGameInDosFormatLoader_Test(); 24 | virtual ~SavedGameInDosFormatLoader_Test(); 25 | 26 | protected: 27 | }; -------------------------------------------------------------------------------- /src/Test/LevelLocationNames_Test.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2018 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | #pragma once 17 | 18 | #include 19 | 20 | class LevelLocationNames_Test : public ::testing::Test 21 | { 22 | public: 23 | LevelLocationNames_Test(); 24 | virtual ~LevelLocationNames_Test(); 25 | 26 | protected: 27 | 28 | }; 29 | -------------------------------------------------------------------------------- /src/Test/SavedGameConverterCatacomb3D_Test.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | #pragma once 17 | 18 | #include 19 | 20 | class SavedGameConverterCatacomb3D_Test : public ::testing::Test 21 | { 22 | public: 23 | SavedGameConverterCatacomb3D_Test(); 24 | virtual ~SavedGameConverterCatacomb3D_Test(); 25 | 26 | protected: 27 | 28 | }; -------------------------------------------------------------------------------- /ThirdParty/ReflectionHLE/backend/cfg/be_cfg_sdl.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "SDL_render.h" 3 | 4 | #include "be_cross.h" 5 | #include "be_st.h" 6 | 7 | void BEL_ST_ParseSetting_DisplayNum(int *displayNum, const char *buffer) 8 | { 9 | if (sscanf(buffer, "%d", displayNum) == 1) 10 | if ((*displayNum < 0) || (*displayNum >= SDL_GetNumVideoDisplays())) 11 | *displayNum = 0; 12 | } 13 | 14 | void BEL_ST_ParseSetting_SDLRendererDriver(int *driver, const char *buffer) 15 | { 16 | SDL_RendererInfo info; 17 | for (int i = 0; i < SDL_GetNumRenderDrivers(); ++i) 18 | { 19 | SDL_GetRenderDriverInfo(i, &info); 20 | if (!strcmp(info.name, buffer)) 21 | { 22 | *driver = i; 23 | break; 24 | } 25 | } 26 | } 27 | 28 | void BEL_ST_SaveSDLRendererDriverToConfig(FILE *fp, const char *key, int driver) 29 | { 30 | if (driver < 0) 31 | fprintf(fp, "%s=auto\n", key); 32 | else 33 | { 34 | SDL_RendererInfo info; 35 | SDL_GetRenderDriverInfo(g_refKeenCfg.sdlRendererDriver, &info); // g_refKeenCfg.sdlRendererDriver should be a valid renderer driver index here 36 | fprintf(fp, "%s=%s\n", key, info.name); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Engine/FadeEffect.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | #pragma once 16 | 17 | #include "IRenderer.h" 18 | 19 | class FadeEffect 20 | { 21 | public: 22 | FadeEffect(); 23 | ~FadeEffect(); 24 | 25 | void SetOverlay(IRenderer& renderer); 26 | void DrawOverlay(IRenderer& renderer, const uint32_t milliSec); 27 | bool OverlayActive() const; 28 | 29 | Picture* m_picture; 30 | uint32_t m_pixelsRemoved; 31 | int32_t m_rndval; 32 | }; 33 | 34 | 35 | -------------------------------------------------------------------------------- /src/Engine/AudioPlayer.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2018 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | #pragma once 16 | 17 | #include "AudioRepository.h" 18 | 19 | class AudioPlayer 20 | { 21 | public: 22 | AudioPlayer(AudioRepository* audioRepository); 23 | ~AudioPlayer(); 24 | 25 | void Play(const uint16_t index); 26 | void StartMusic(const uint16_t index); 27 | void StopMusic(); 28 | bool IsPlaying(); 29 | 30 | private: 31 | AudioRepository* m_audioRepository; 32 | }; 33 | -------------------------------------------------------------------------------- /src/Engine/FileChunk.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2018 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | // 17 | // FileChunk 18 | // 19 | // Class for storing a fixed amount of bytes in memory. 20 | #pragma once 21 | 22 | #include 23 | 24 | class FileChunk 25 | { 26 | public: 27 | FileChunk(const uint32_t size); 28 | ~FileChunk(); 29 | 30 | uint32_t GetSize() const; 31 | uint8_t* GetChunk() const; 32 | 33 | private: 34 | uint8_t* m_chunk; 35 | uint32_t m_size; 36 | }; 37 | 38 | -------------------------------------------------------------------------------- /src/Engine/Console.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | #pragma once 16 | 17 | #include "Logging.h" 18 | #include "IRenderer.h" 19 | #include "PlayerInput.h" 20 | 21 | class Console 22 | { 23 | public: 24 | Console(const std::string& label); 25 | ~Console(); 26 | 27 | void Draw(IRenderer& renderer); 28 | void ProcessInput(PlayerInput& playerInput); 29 | 30 | private: 31 | bool m_active; 32 | const std::string m_label; 33 | uint32_t m_openTimestamp; 34 | uint32_t m_closeTimestamp; 35 | }; 36 | -------------------------------------------------------------------------------- /src/Engine/FileChunk.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2018 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | #include "stdlib.h" 17 | #include "FileChunk.h" 18 | 19 | FileChunk::FileChunk(const uint32_t size) 20 | { 21 | m_size = size; 22 | m_chunk = new unsigned char[size]; 23 | } 24 | 25 | FileChunk::~FileChunk() 26 | { 27 | delete[] m_chunk; 28 | m_chunk = nullptr; 29 | } 30 | 31 | uint32_t FileChunk::GetSize() const 32 | { 33 | return m_size; 34 | } 35 | 36 | uint8_t* FileChunk::GetChunk() const 37 | { 38 | return m_chunk; 39 | } -------------------------------------------------------------------------------- /src/Test/SavedGameConverterApocalypse_Test.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | #pragma once 17 | 18 | #include 19 | #include "../Engine/SavedGameInDosFormat.h" 20 | 21 | class SavedGameConverterApocalypse_Test : public ::testing::Test 22 | { 23 | public: 24 | SavedGameConverterApocalypse_Test() = default; 25 | virtual ~SavedGameConverterApocalypse_Test() = default; 26 | 27 | void CheckDosObjectIsConvertible(const SavedGameInDosFormat::ObjectInDosFormat& dosObject); 28 | 29 | static constexpr uint32_t m_farPointerOffset = 0x1A20000; 30 | }; -------------------------------------------------------------------------------- /src/Test/SavedGameConverterArmageddon_Test.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | #pragma once 17 | 18 | #include 19 | #include "../Engine/SavedGameInDosFormat.h" 20 | 21 | class SavedGameConverterArmageddon_Test : public ::testing::Test 22 | { 23 | public: 24 | SavedGameConverterArmageddon_Test() = default; 25 | virtual ~SavedGameConverterArmageddon_Test() = default; 26 | 27 | void CheckDosObjectIsConvertible(const SavedGameInDosFormat::ObjectInDosFormat& dosObject); 28 | 29 | static constexpr uint32_t m_farPointerOffset = 0x1A20000; 30 | }; -------------------------------------------------------------------------------- /src/Engine/FramesCounter.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2018 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | // 17 | // FramesCounter 18 | // 19 | // Keeps track of the amount of frames rendered each second. 20 | // 21 | #pragma once 22 | #include 23 | 24 | class FramesCounter 25 | { 26 | public: 27 | FramesCounter(); 28 | ~FramesCounter(); 29 | 30 | void AddFrame(const uint32_t timeStamp); 31 | uint32_t GetFramesPerSecond() const; 32 | 33 | private: 34 | uint32_t m_startTimestamp; 35 | uint32_t m_frameCount; 36 | uint32_t m_framesPerSecond; 37 | }; 38 | -------------------------------------------------------------------------------- /src/Test/GuiMenu_Test.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | #pragma once 17 | 18 | #include 19 | #include "../Engine/Font.h" 20 | #include "../Engine/RenderableText.h" 21 | #include "../Engine/PlayerInput.h" 22 | 23 | class GuiMenu_Test : public ::testing::Test 24 | { 25 | public: 26 | GuiMenu_Test(); 27 | virtual ~GuiMenu_Test(); 28 | static const Font& GetDefaultFont(); 29 | static const std::string RenderableTextToString(const RenderableText& renderableText); 30 | static void PressKey(PlayerInput& playerInput, const SDL_Keycode key); 31 | }; 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/Catacomb3D/GuiElementSaveSlotStaticCat3D.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | #pragma once 16 | 17 | #include "../Engine/GuiElementButton.h" 18 | 19 | class GuiElementSaveSlotStaticCat3D : public GuiElementButton 20 | { 21 | public: 22 | GuiElementSaveSlotStaticCat3D( 23 | const PlayerInput& playerInput, 24 | const std::string& buttonLabel, 25 | const GuiEvent& guiEventWhenActivated, 26 | RenderableText& renderableText, 27 | bool& flashIcon); 28 | 29 | virtual void Draw(IRenderer& renderer) const override; 30 | 31 | private: 32 | bool& m_flashIcon; 33 | }; 34 | -------------------------------------------------------------------------------- /res/win/CatacombGL.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #include "resource.h" 4 | 5 | ///////////////////////////////////////////////////////////////////////////// 6 | // English (United States) resources 7 | 8 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 9 | 10 | #ifdef APSTUDIO_INVOKED 11 | ///////////////////////////////////////////////////////////////////////////// 12 | // 13 | // TEXTINCLUDE 14 | // 15 | 16 | 1 TEXTINCLUDE 17 | BEGIN 18 | "resource.h\0" 19 | END 20 | 21 | #endif // APSTUDIO_INVOKED 22 | 23 | 24 | ///////////////////////////////////////////////////////////////////////////// 25 | // 26 | // Icon 27 | // 28 | 29 | // Icon with lowest ID value placed first to ensure application icon 30 | // remains consistent on all systems. 31 | IDI_ICON1 ICON "CatacombGL.ico" 32 | #endif // English (United States) resources 33 | ///////////////////////////////////////////////////////////////////////////// 34 | 35 | 36 | 37 | #ifndef APSTUDIO_INVOKED 38 | ///////////////////////////////////////////////////////////////////////////// 39 | // 40 | // Generated from the TEXTINCLUDE 3 resource. 41 | // 42 | 43 | 44 | ///////////////////////////////////////////////////////////////////////////// 45 | #endif // not APSTUDIO_INVOKED 46 | 47 | -------------------------------------------------------------------------------- /src/Test/GuiElementList_Test.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | #pragma once 17 | 18 | #include 19 | #include "../Engine/Font.h" 20 | #include "../Engine/RenderableText.h" 21 | #include "../Engine/PlayerInput.h" 22 | 23 | class GuiElementList_Test : public ::testing::Test 24 | { 25 | public: 26 | GuiElementList_Test(); 27 | virtual ~GuiElementList_Test(); 28 | static const Font& GetDefaultFont(); 29 | static const std::string RenderableTextToString(const RenderableText& renderableText); 30 | static void PressKey(PlayerInput& playerInput, const SDL_Keycode key); 31 | }; 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /src/Test/GuiElementEditText_Test.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | #pragma once 17 | 18 | #include 19 | #include "../Engine/Font.h" 20 | #include "../Engine/RenderableText.h" 21 | #include "../Engine/PlayerInput.h" 22 | 23 | class GuiElementEditText_Test : public ::testing::Test 24 | { 25 | public: 26 | GuiElementEditText_Test(); 27 | virtual ~GuiElementEditText_Test(); 28 | static const Font& GetDefaultFont(); 29 | static const std::string RenderableTextToString(const RenderableText& renderableText); 30 | static void PressKey(PlayerInput& playerInput, const SDL_Keycode key); 31 | }; 32 | 33 | 34 | -------------------------------------------------------------------------------- /src/Engine/Logging.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | #pragma once 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | class Logging 22 | { 23 | public: 24 | static Logging& Instance(); 25 | 26 | void AddLogMessage(const std::string& logline); 27 | const std::vector& GetAllLogMessages() const; 28 | void FatalError(const std::string& message); 29 | void SetLogFile(const std::filesystem::path traceFileName); 30 | 31 | private: 32 | Logging(); 33 | ~Logging(); 34 | 35 | std::vector m_allLogMessages; 36 | std::filesystem::path m_traceFileName; 37 | }; 38 | -------------------------------------------------------------------------------- /src/Engine/Score.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | // 17 | // Score 18 | // 19 | // Keeps track of the score for Catacomb 3D 20 | // 21 | #pragma once 22 | 23 | #include 24 | 25 | class Score 26 | { 27 | public: 28 | Score(); 29 | ~Score(); 30 | 31 | const uint32_t GetPoints() const; 32 | void SetPoints(const uint32_t points); 33 | void AddPoints(const uint32_t points); 34 | bool Update(const uint32_t timestamp); 35 | void UpdateAll(); 36 | 37 | void Reset(); 38 | 39 | private: 40 | uint32_t m_points; 41 | uint32_t m_pointsToAdd; 42 | uint32_t m_pointsAddedTimestamp; 43 | }; 44 | 45 | -------------------------------------------------------------------------------- /src/Engine/Font.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2018 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | #include "Font.h" 17 | #include 18 | 19 | Font::Font(const uint8_t width[256], const TextureAtlas* const textureAtlas) : 20 | m_textureAtlas(textureAtlas) 21 | { 22 | std::memcpy(&m_width[0], &width[0], sizeof(width[0]) * 256); 23 | } 24 | 25 | Font::~Font() 26 | { 27 | delete m_textureAtlas; 28 | } 29 | 30 | const TextureAtlas* const Font::GetTextureAtlas() const 31 | { 32 | return m_textureAtlas; 33 | } 34 | 35 | uint16_t Font::GetCharacterWidth(const uint16_t charIndex) const 36 | { 37 | return m_width[charIndex]; 38 | } 39 | -------------------------------------------------------------------------------- /src/Engine/RenderableOverscanBorder.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | #pragma once 16 | 17 | // 18 | // RenderableOverscanBorder 19 | // 20 | // Class for rendering the overscan border to the screen. 21 | // 22 | 23 | #include "OverscanBorder.h" 24 | #include "IRenderer.h" 25 | 26 | class RenderableOverscanBorder 27 | { 28 | public: 29 | RenderableOverscanBorder(const OverscanBorder& overscanBorder); 30 | ~RenderableOverscanBorder(); 31 | 32 | void Draw(IRenderer& renderer, const uint16_t additionalMargin, const uint32_t timeStamp, const bool helpWindow); 33 | 34 | private: 35 | const OverscanBorder& m_overscanBorder; 36 | }; 37 | 38 | -------------------------------------------------------------------------------- /src/Engine/HelpPages.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | // 17 | // HelpPages 18 | // 19 | // Class for parsing the contents of the HELP.TXT file. 20 | // 21 | #pragma once 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | struct HelpLine 28 | { 29 | std::string line; 30 | bool centered; 31 | }; 32 | 33 | typedef std::vector HelpPage; 34 | 35 | class HelpPages 36 | { 37 | public: 38 | HelpPages(); 39 | HelpPages(const std::string& helpText); 40 | 41 | uint8_t GetNumberOfPages() const; 42 | const HelpPage& GetPage(const uint8_t pageIndex) const; 43 | 44 | private: 45 | std::vector m_pages; 46 | }; 47 | -------------------------------------------------------------------------------- /src/Engine/ConsoleVariable.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | #pragma once 16 | 17 | #include 18 | 19 | class ConsoleVariable 20 | { 21 | public: 22 | ConsoleVariable(); 23 | ConsoleVariable(const std::string& nameInMenu, const std::string& nameInConfigFile); 24 | ~ConsoleVariable(); 25 | 26 | const std::string& GetNameInMenu() const; 27 | const std::string& GetNameInConfigFile() const; 28 | 29 | virtual const std::string Serialize() const; 30 | virtual void Deserialize(const std::string& str); 31 | virtual void SetToDefault(); 32 | 33 | protected: 34 | const std::string m_nameInMenu; 35 | const std::string m_nameInConfigFile; 36 | }; 37 | -------------------------------------------------------------------------------- /src/Engine/Huffman.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2018 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | // 17 | // Huffman 18 | // 19 | // Offers Huffman decompression. 20 | // 21 | #pragma once 22 | 23 | #include "FileChunk.h" 24 | 25 | typedef struct huffmanNode 26 | { 27 | unsigned short bit0,bit1; 28 | } huffmanNode; 29 | 30 | typedef huffmanNode huffmanTable[256]; 31 | 32 | class Huffman 33 | { 34 | public: 35 | Huffman(const huffmanTable table); 36 | ~Huffman(); 37 | 38 | FileChunk* Decompress(unsigned char* compressedChunk, const unsigned long compressedSize, const unsigned long decompressedSize); 39 | 40 | private: 41 | huffmanTable m_table; 42 | }; 43 | 44 | -------------------------------------------------------------------------------- /src/Engine/DefaultFont.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2018 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | // 17 | // DefaultFont 18 | // 19 | // Hard-coded font data, which is used to display text in the game selection dialog, 20 | // even when no game data was found at all. 21 | // 22 | #pragma once 23 | 24 | #include "Font.h" 25 | #include "IRenderer.h" 26 | 27 | static Font* defaultFontHeight7 = nullptr; 28 | static Font* defaultFontHeight10 = nullptr; 29 | 30 | class DefaultFont 31 | { 32 | public: 33 | static const Font* Get(IRenderer& renderer, const uint16_t lineHeight); 34 | private: 35 | static TextureAtlas* CreateTextureAtlasForFont(IRenderer& renderer, const bool* fontPicture, const uint16_t lineHeight); 36 | }; 37 | -------------------------------------------------------------------------------- /src/Engine/PictureTable.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2018 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | // 17 | // PictureTable 18 | // 19 | // Table with the widths and heights of a number of pictures, as read from a chunk of the EGAGRAPH repository file. 20 | // 21 | #pragma once 22 | 23 | #include "FileChunk.h" 24 | 25 | class PictureTable 26 | { 27 | public: 28 | PictureTable(FileChunk* decompressedChunk); 29 | ~PictureTable(); 30 | 31 | uint16_t GetWidth(const uint16_t index); 32 | uint16_t GetHeight(const uint16_t index); 33 | uint16_t GetCount(); 34 | 35 | private: 36 | uint16_t* m_width; 37 | uint16_t* m_height; 38 | uint16_t m_count; 39 | }; 40 | 41 | -------------------------------------------------------------------------------- /src/Engine/PCSound.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2018 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | // 17 | // PCSound 18 | // 19 | // Contains a single PC speaker sound effect, as read from a chunk of the audio repository file. 20 | // 21 | #pragma once 22 | 23 | #include "FileChunk.h" 24 | 25 | class PCSound 26 | { 27 | public: 28 | PCSound(const FileChunk* decompressedChunk); 29 | ~PCSound(); 30 | 31 | uint32_t GetLength() const; 32 | uint16_t GetPriority() const; 33 | uint8_t GetInverseFrequency(const uint32_t index) const; 34 | uint8_t* GetData(); 35 | 36 | private: 37 | uint32_t m_length; 38 | uint16_t m_priority; 39 | uint8_t* m_inverseFrequency; 40 | }; 41 | 42 | -------------------------------------------------------------------------------- /src/Catacomb3D/GuiElementButtonCat3D.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | #pragma once 16 | 17 | #include "../Engine/GuiElementButton.h" 18 | #include "../Engine/RenderableTiles.h" 19 | 20 | class GuiElementButtonCat3D : public GuiElementButton 21 | { 22 | public: 23 | GuiElementButtonCat3D( 24 | const PlayerInput& playerInput, 25 | const std::string& buttonLabel, 26 | const GuiEvent& guiEventWhenActivated, 27 | RenderableText& renderableText, 28 | RenderableTiles& renderableTiles, 29 | bool& flashIcon); 30 | 31 | virtual void Draw(IRenderer& renderer) const override; 32 | 33 | private: 34 | RenderableTiles& m_renderableTiles; 35 | bool& m_flashIcon; 36 | }; 37 | -------------------------------------------------------------------------------- /src/Engine/ConsoleVariableString.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | #pragma once 16 | 17 | #include "ConsoleVariable.h" 18 | 19 | class ConsoleVariableString : public ConsoleVariable 20 | { 21 | public: 22 | ConsoleVariableString(const std::string& nameInMenu, const std::string& nameInConfigFile, const std::string& defaultValue); 23 | ~ConsoleVariableString(); 24 | 25 | const std::string Serialize() const override; 26 | void Deserialize(const std::string& str) override; 27 | void SetToDefault() override; 28 | 29 | const std::string& Get() const; 30 | void Set(const std::string& value); 31 | 32 | private: 33 | std::string m_value; 34 | const std::string m_defaultValue; 35 | }; 36 | 37 | -------------------------------------------------------------------------------- /src/Catacomb3D/GameDetectionCatacomb3D.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | // 17 | // GameDetectionCatacomb3D 18 | // 19 | // Data structures for detecting the Catacomb 3D game files. 20 | // 21 | #pragma once 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | const std::map catacomb3Dv100Files = 28 | { 29 | std::make_pair("AUDIO.C3D", 5062), 30 | std::make_pair("EGAGRAPH.C3D", 258007), 31 | std::make_pair("GAMEMAPS.C3D", 14288) 32 | }; 33 | 34 | const std::map catacomb3Dv122Files = 35 | { 36 | std::make_pair("AUDIO.C3D", 5062), 37 | std::make_pair("EGAGRAPH.C3D", 256899), 38 | std::make_pair("GAMEMAPS.C3D", 14288) 39 | }; 40 | -------------------------------------------------------------------------------- /src/Engine/Font.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2018 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | // 17 | // Font 18 | // 19 | // Contains the font that was read from an EGAGRAPH file. Required for printing text to the screen. 20 | // 21 | #pragma once 22 | 23 | #include "FileChunk.h" 24 | #include "TextureAtlas.h" 25 | 26 | class Font 27 | { 28 | public: 29 | Font(const uint8_t width[256], const TextureAtlas* const textureAtlas); 30 | ~Font(); 31 | 32 | const TextureAtlas* const GetTextureAtlas() const; 33 | uint16_t GetCharacterWidth(const uint16_t charIndex) const; 34 | 35 | private: 36 | static const uint16_t NumChar = 256; 37 | uint8_t m_width[256]; 38 | const TextureAtlas* const m_textureAtlas; 39 | }; 40 | -------------------------------------------------------------------------------- /src/Catacomb3D/GuiElementIntSelectionCat3D.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | #pragma once 16 | 17 | #include "../Engine/GuiElementIntSelection.h" 18 | #include "../Engine/RenderableTiles.h" 19 | 20 | class GuiElementIntSelectionCat3D : public GuiElementIntSelection 21 | { 22 | public: 23 | GuiElementIntSelectionCat3D( 24 | const PlayerInput& playerInput, 25 | ConsoleVariableInt& cvarInt, 26 | const int16_t offsetXValue, 27 | RenderableText& renderableText, 28 | RenderableTiles& renderableTiles, 29 | bool& flashIcon); 30 | 31 | virtual void Draw(IRenderer& renderer) const override; 32 | 33 | private: 34 | RenderableTiles& m_renderableTiles; 35 | bool& m_flashIcon; 36 | }; 37 | -------------------------------------------------------------------------------- /src/Catacomb3D/GuiElementBindKeyCat3D.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | #pragma once 16 | 17 | #include "../Engine/GuiElementBindKey.h" 18 | #include "../Engine/RenderableTiles.h" 19 | 20 | class GuiElementBindKeyCat3D : public GuiElementBindKey 21 | { 22 | public: 23 | GuiElementBindKeyCat3D( 24 | const PlayerInput& playerInput, 25 | ControlsMap& controlsMap, 26 | ControlAction controlAction, 27 | const int16_t offsetXValue, 28 | RenderableText& renderableText, 29 | RenderableTiles& renderableTiles, 30 | bool& flashIcon); 31 | 32 | virtual void Draw(IRenderer& renderer) const override; 33 | 34 | private: 35 | RenderableTiles& m_renderableTiles; 36 | bool& m_flashIcon; 37 | }; 38 | -------------------------------------------------------------------------------- /src/Catacomb3D/GuiElementBoolSelectionCat3D.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | #pragma once 16 | 17 | #include "../Engine/GuiElementBoolSelection.h" 18 | #include "../Engine/RenderableTiles.h" 19 | 20 | class GuiElementBoolSelectionCat3D : public GuiElementBoolSelection 21 | { 22 | public: 23 | GuiElementBoolSelectionCat3D( 24 | const PlayerInput& playerInput, 25 | ConsoleVariableBool& cvarBool, 26 | const int16_t offsetXValue, 27 | RenderableText& renderableText, 28 | RenderableTiles& renderableTiles, 29 | bool& flashIcon); 30 | 31 | virtual void Draw(IRenderer& renderer) const override; 32 | 33 | private: 34 | RenderableTiles& m_renderableTiles; 35 | bool& m_flashIcon; 36 | }; 37 | 38 | -------------------------------------------------------------------------------- /src/Engine/CommandLineParser.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2024 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | #pragma once 17 | 18 | #include 19 | #include "GameId.h" 20 | 21 | class CommandLineParser 22 | { 23 | public: 24 | CommandLineParser(); 25 | ~CommandLineParser() = default; 26 | 27 | void parse(const int argc, char* argv[]); 28 | const std::string& getFilenameIni() const; 29 | const std::string& getFilenameLog() const; 30 | const std::string& getSaveDir() const; 31 | GameId gameIdToStart() const; 32 | 33 | private: 34 | static bool compareStrings(const std::string& str1, const std::string& str2); 35 | 36 | std::string m_filenameIni; 37 | std::string m_filenameLog; 38 | std::string m_saveDir; 39 | GameId m_gameIdToStart; 40 | }; -------------------------------------------------------------------------------- /src/Engine/GuiElementHighScores.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | #pragma once 16 | 17 | #include "GuiElementBase.h" 18 | #include "HighScores.h" 19 | 20 | class GuiElementHighScores : public GuiElementBase 21 | { 22 | public: 23 | GuiElementHighScores( 24 | const PlayerInput& playerInput, 25 | HighScores& highscores, 26 | uint32_t& timestamp 27 | ); 28 | 29 | virtual const GuiEvent& ProcessInput() override; 30 | virtual void Draw(IRenderer& renderer) const override; 31 | 32 | private: 33 | static bool KeyIsSuitableForName(const SDL_Keycode keyCode); 34 | 35 | HighScores& m_highScores; 36 | uint32_t& m_timestamp; 37 | const GuiEvent m_nameFinishedEvent = { GuiActionHighScoreFinished, 0 }; 38 | }; -------------------------------------------------------------------------------- /src/Engine/GuiElementStaticText.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | #pragma once 16 | 17 | #include "GuiElementBase.h" 18 | #include "RenderableText.h" 19 | 20 | class GuiElementStaticText : public GuiElementBase 21 | { 22 | public: 23 | GuiElementStaticText( 24 | const PlayerInput& playerInput, 25 | const std::string& text, 26 | const egaColor color, 27 | RenderableText& renderableText); 28 | ~GuiElementStaticText() override; 29 | 30 | virtual const GuiEvent& ProcessInput() override; 31 | virtual void Draw(IRenderer& renderer) const override; 32 | 33 | private: 34 | const std::string m_text; 35 | const egaColor m_color; 36 | RenderableText& m_renderableText; 37 | }; 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /src/Catacomb3D/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.16) 2 | project(CatacombGL_Catacomb3D LANGUAGES CXX) 3 | 4 | add_library( CatacombGL_Catacomb3D OBJECT 5 | AudioRepositoryCatacomb3D.h 6 | Catacomb3DMenu.cpp 7 | Catacomb3DMenu.h 8 | DecorateAll.h 9 | DecorateBonus.h 10 | DecorateMisc.h 11 | DecorateMonsters.h 12 | DecorateProjectiles.h 13 | EgaGraphCatacomb3D.h 14 | GameCatacomb3D.cpp 15 | GameCatacomb3D.h 16 | GameDetectionCatacomb3D.h 17 | GameMapsCatacomb3D.h 18 | GuiElementBindKeyCat3D.cpp 19 | GuiElementBindKeyCat3D.h 20 | GuiElementBoolSelectionCat3D.cpp 21 | GuiElementBoolSelectionCat3D.h 22 | GuiElementButtonCat3D.cpp 23 | GuiElementButtonCat3D.h 24 | GuiElementEnumSelectionCat3D.cpp 25 | GuiElementEnumSelectionCat3D.h 26 | GuiElementEnumSelectionCat3DRadio.cpp 27 | GuiElementEnumSelectionCat3DRadio.h 28 | GuiElementIntSelectionCat3D.cpp 29 | GuiElementIntSelectionCat3D.h 30 | GuiElementSaveSlotEditableCat3D.cpp 31 | GuiElementSaveSlotEditableCat3D.h 32 | GuiElementSaveSlotStaticCat3D.cpp 33 | GuiElementSaveSlotStaticCat3D.h 34 | GuiPageFrameCat3D.cpp 35 | GuiPageFrameCat3D.h 36 | IntroViewCatacomb3D.cpp 37 | IntroViewCatacomb3D.h 38 | SavedGameConverterCatacomb3D.cpp 39 | SavedGameConverterCatacomb3D.h 40 | SavedInGameInDosFormatConfigCatacomb3D.h 41 | SkullNBones.cpp 42 | SkullNBones.h 43 | ) 44 | -------------------------------------------------------------------------------- /src/Engine/ConsoleVariableBool.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | #pragma once 16 | 17 | #include "ConsoleVariable.h" 18 | 19 | class ConsoleVariableBool : public ConsoleVariable 20 | { 21 | public: 22 | ConsoleVariableBool(const std::string& nameInMenu, const std::string& nameInConfigFile, const bool defaultValue); 23 | ~ConsoleVariableBool(); 24 | 25 | const std::string Serialize() const override; 26 | void Deserialize(const std::string& str) override; 27 | void SetToDefault() override; 28 | 29 | bool IsEnabled() const; 30 | void SetEnabled(bool enabled); 31 | void Toggle(); 32 | 33 | const std::string& GetValueInMenu() const; 34 | 35 | private: 36 | bool m_enabled; 37 | const bool m_defaultValue; 38 | }; 39 | -------------------------------------------------------------------------------- /src/Catacomb3D/GuiElementEnumSelectionCat3D.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | #pragma once 16 | 17 | #include "../Engine/GuiElementEnumSelection.h" 18 | #include "../Engine/RenderableTiles.h" 19 | 20 | class GuiElementEnumSelectionCat3D : public GuiElementEnumSelection 21 | { 22 | public: 23 | GuiElementEnumSelectionCat3D( 24 | const PlayerInput& playerInput, 25 | ConsoleVariableEnum& cvarEnum, 26 | const int16_t offsetXValue, 27 | RenderableText& renderableText, 28 | RenderableTiles& renderableTiles, 29 | bool& flashIcon); 30 | 31 | virtual void Draw(IRenderer& renderer) const override; 32 | 33 | protected: 34 | RenderableTiles& m_renderableTiles; 35 | bool& m_flashIcon; 36 | }; 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/Engine/SavedGamesInDosFormat.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | #pragma once 16 | 17 | #include "SavedGameInDosFormat.h" 18 | #include 19 | 20 | class SavedGamesInDosFormat 21 | { 22 | public: 23 | SavedGamesInDosFormat(const SavedGameInDosFormatConfig& config); 24 | ~SavedGamesInDosFormat(); 25 | 26 | void AddSavedGame(const FileChunk* fileChunk); 27 | void AddSavedGame(const FileChunk* fileChunk, const std::string& name); 28 | 29 | const std::vector& GetSavedGameInDosFormat() const; 30 | const SavedGameInDosFormat* const GetSavedGameInDosFormat(const std::string name) const; 31 | 32 | private: 33 | std::vector m_savedGames; 34 | const SavedGameInDosFormatConfig& m_config; 35 | }; 36 | -------------------------------------------------------------------------------- /src/Catacomb3D/GuiElementEnumSelectionCat3DRadio.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | #pragma once 16 | 17 | #include "GuiElementEnumSelectionCat3D.h" 18 | 19 | class GuiElementEnumSelectionCat3DRadio : public GuiElementEnumSelectionCat3D 20 | { 21 | public: 22 | GuiElementEnumSelectionCat3DRadio( 23 | const PlayerInput& playerInput, 24 | ConsoleVariableEnum& cvarEnum, 25 | RenderableText& renderableText, 26 | RenderableTiles& renderableTiles, 27 | bool& flashIcon, 28 | const std::vector& enumNames); 29 | 30 | virtual const GuiEvent& ProcessInput() override; 31 | virtual void Draw(IRenderer& renderer) const override; 32 | 33 | private: 34 | const std::vector& m_enumNames; 35 | uint8_t m_elementSelected; 36 | }; 37 | -------------------------------------------------------------------------------- /src/Catacomb3D/GuiElementSaveSlotEditableCat3D.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | #pragma once 16 | 17 | #include "../Engine/GuiElementEditText.h" 18 | #include "GuiPageFrameCat3D.h" 19 | 20 | class GuiElementSaveSlotEditableCat3D : public GuiElementEditText 21 | { 22 | public: 23 | GuiElementSaveSlotEditableCat3D( 24 | const PlayerInput& playerInput, 25 | std::string& outputText, 26 | const std::string& initialText, 27 | const uint16_t maxTextLength, 28 | RenderableText& renderableText, 29 | GuiEvent& textCompleteAction, 30 | bool& flashIcon, 31 | GuiPageFrameCat3D* pageFrame); 32 | 33 | virtual void Draw(IRenderer& renderer) const override; 34 | 35 | private: 36 | bool& m_flashIcon; 37 | GuiPageFrameCat3D* m_pageFrame; 38 | }; 39 | 40 | -------------------------------------------------------------------------------- /src/Engine/IIntroView.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2018 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | // 17 | // IIntroView 18 | // 19 | // Abstract interface for drawing the (2D) introduction screens. 20 | // The concrete implementation can differ per game (Abyss, Armageddon, etc). 21 | // 22 | #pragma once 23 | 24 | #include "IRenderer.h" 25 | #include "Logging.h" 26 | 27 | class IIntroView 28 | { 29 | public: 30 | IIntroView(IRenderer& renderer); 31 | virtual ~IIntroView() {}; 32 | virtual void DrawIntroduction(const uint32_t timeStamp) = 0; 33 | virtual void DrawRequestDifficultyLevel() = 0; 34 | virtual void DrawNoviceSelected() = 0; 35 | virtual void DrawWarriorSelected() = 0; 36 | virtual void DrawStandBeforeGate() = 0; 37 | 38 | protected: 39 | IRenderer& m_renderer; 40 | }; 41 | 42 | -------------------------------------------------------------------------------- /src/Engine/ViewPorts.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | // 17 | // ViewPorts 18 | // 19 | #pragma once 20 | 21 | #include 22 | 23 | class ViewPorts 24 | { 25 | public: 26 | typedef struct 27 | { 28 | double left; 29 | double right; 30 | double top; 31 | double bottom; 32 | } ViewPortRect2D; 33 | 34 | typedef struct 35 | { 36 | uint16_t left; 37 | uint16_t bottom; 38 | uint16_t width; 39 | uint16_t height; 40 | } ViewPortRect3D; 41 | 42 | static ViewPortRect2D GetOrtho2D(const uint16_t windowWidth, const uint16_t windowHeight, const bool helpWindow); 43 | static ViewPortRect3D Get3D(const uint16_t windowWidth, const uint16_t windowHeight, const float aspectRatio, const ViewPortRect3D original3DViewArea); 44 | }; 45 | -------------------------------------------------------------------------------- /src/System/WindowSDL.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | #include "../Engine/ConfigurationSettings.h" 17 | #include "../Engine/IRenderer.h" 18 | 19 | #ifdef _WIN32 20 | #include 21 | #endif 22 | 23 | #ifdef __APPLE__ 24 | #include 25 | #else 26 | #include 27 | #endif 28 | #include 29 | 30 | void CreateGLWindow(int width, int height, int /*bits*/, SDL_Window*& window, SDL_GLContext& context ); 31 | GLvoid KillGLWindow(SDL_Window* window, SDL_GLContext& context); 32 | 33 | // Resize And Initialize The GL Window 34 | GLvoid ReSizeGLScene(IRenderer* renderer, GLsizei width, GLsizei height); 35 | void SetScreenMode(const uint8_t screenMode, SDL_Window* window); 36 | [[nodiscard]] bool HandleWindowEvent(const SDL_WindowEvent * event, SDL_Window* window, IRenderer* renderer); 37 | 38 | -------------------------------------------------------------------------------- /src/Engine/GuiElementStaticText.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | #include "GuiElementStaticText.h" 17 | 18 | GuiElementStaticText::GuiElementStaticText( 19 | const PlayerInput& playerInput, 20 | const std::string& text, 21 | const egaColor color, 22 | RenderableText& renderableText) : 23 | GuiElementBase(playerInput), 24 | m_text(text), 25 | m_color(color), 26 | m_renderableText(renderableText) 27 | { 28 | 29 | } 30 | 31 | GuiElementStaticText::~GuiElementStaticText() 32 | { 33 | 34 | } 35 | 36 | const GuiEvent& GuiElementStaticText::ProcessInput() 37 | { 38 | // Just static text; no interaction possible. 39 | return GetEvent(); 40 | } 41 | 42 | void GuiElementStaticText::Draw(IRenderer& renderer) const 43 | { 44 | m_renderableText.Centered(m_text, m_color, m_originX, m_originY); 45 | } -------------------------------------------------------------------------------- /src/Engine/Renderable3DWalls.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | // 16 | // Renderable3DWalls 17 | // 18 | // Contains a list of 3D walls that can be processed by the renderer. 19 | // 20 | #pragma once 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | class Renderable3DWalls 27 | { 28 | public: 29 | typedef struct 30 | { 31 | uint16_t x1; 32 | uint16_t y1; 33 | uint16_t x2; 34 | uint16_t y2; 35 | } wallCoordinate; 36 | 37 | Renderable3DWalls(); 38 | void AddWall(const unsigned int textureId, const wallCoordinate coordinate); 39 | const std::map>& GetTextureToWallsMap() const; 40 | void Reset(); 41 | 42 | private: 43 | std::map> m_textureToWallsMap; 44 | }; 45 | -------------------------------------------------------------------------------- /src/Engine/ISystem.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2018 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | // 17 | // ISystem 18 | // 19 | // Abstract interface towards OS-dependent functionality. 20 | // 21 | #pragma once 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | class ISystem 28 | { 29 | public: 30 | virtual ~ISystem() {}; 31 | virtual const std::filesystem::path& GetConfigurationFilePath() const = 0; 32 | virtual const std::filesystem::path& GetSavedGamesPath() const = 0; 33 | virtual void GetSavedGameNamesFromFolder(const std::filesystem::path& path, std::vector& filesFound) const = 0; 34 | virtual bool CreatePath(const std::filesystem::path& path) const = 0; 35 | virtual std::string GetOSVersion() const = 0; 36 | virtual bool isBuiltIn64Bit() const = 0; 37 | }; 38 | -------------------------------------------------------------------------------- /src/Engine/GuiElementButton.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | #pragma once 16 | 17 | #include "GuiElementBase.h" 18 | 19 | class GuiElementButton : public GuiElementBase 20 | { 21 | public: 22 | GuiElementButton( 23 | const PlayerInput& playerInput, 24 | const std::string& buttonLabel, 25 | const GuiEvent& guiEventWhenActivated, 26 | RenderableText& renderableText); 27 | ~GuiElementButton() override; 28 | 29 | virtual const GuiEvent& ProcessInput() override; 30 | virtual void Draw(IRenderer& renderer) const override; 31 | 32 | void SetLabel(const std::string& buttonLabel); 33 | virtual const std::string& GetLabel() const override; 34 | 35 | protected: 36 | std::string m_buttonLabel; 37 | const GuiEvent m_guiEventWhenActivated; 38 | RenderableText& m_renderableText; 39 | }; 40 | 41 | -------------------------------------------------------------------------------- /src/Engine/RenderableLevelStatistics.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | #pragma once 16 | 17 | // 18 | // RenderableLevelStatistics 19 | // 20 | // Class for rendering the level statistics. 21 | // 22 | 23 | #include "LevelStatistics.h" 24 | #include "IRenderer.h" 25 | #include "Font.h" 26 | 27 | class RenderableLevelStatistics 28 | { 29 | public: 30 | RenderableLevelStatistics(const LevelStatistics& levelStatistics); 31 | ~RenderableLevelStatistics(); 32 | 33 | void Draw(IRenderer& renderer, const Font& font, const uint16_t additionalMargin, const uint32_t timeStamp, const egaColor floorColor); 34 | 35 | private: 36 | static const std::string ConvertTimeStampToString(const uint32_t timeStamp); 37 | static const std::string NumberToTwoDigitString(const uint32_t number); 38 | 39 | const LevelStatistics& m_levelStatistics; 40 | }; -------------------------------------------------------------------------------- /src/Engine/GuiElementBoolSelection.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | #pragma once 16 | 17 | #include "GuiElementBase.h" 18 | #include "ConsoleVariableBool.h" 19 | #include "RenderableText.h" 20 | 21 | class GuiElementBoolSelection : public GuiElementBase 22 | { 23 | public: 24 | GuiElementBoolSelection( 25 | const PlayerInput& playerInput, 26 | ConsoleVariableBool& cvarBool, 27 | const int16_t offsetXValue, 28 | RenderableText& renderableText); 29 | ~GuiElementBoolSelection() override; 30 | 31 | virtual const GuiEvent& ProcessInput() override; 32 | virtual void Draw(IRenderer& renderer) const override; 33 | virtual const std::string& GetLabel() const override; 34 | 35 | protected: 36 | ConsoleVariableBool& m_cvarBool; 37 | const int16_t m_offsetXValue; 38 | RenderableText& m_renderableText; 39 | }; 40 | -------------------------------------------------------------------------------- /src/Engine/GuiElementIntSelection.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | #pragma once 16 | 17 | #include "GuiElementBase.h" 18 | #include "ConsoleVariableInt.h" 19 | #include "RenderableText.h" 20 | 21 | class GuiElementIntSelection : public GuiElementBase 22 | { 23 | public: 24 | GuiElementIntSelection( 25 | const PlayerInput& playerInput, 26 | ConsoleVariableInt& cvarInt, 27 | const int16_t offsetXValue, 28 | RenderableText& renderableText); 29 | ~GuiElementIntSelection() override; 30 | 31 | virtual const GuiEvent& ProcessInput() override; 32 | virtual void Draw(IRenderer& renderer) const override; 33 | virtual const std::string& GetLabel() const override; 34 | 35 | protected: 36 | ConsoleVariableInt& m_cvarInt; 37 | const int16_t m_offsetXValue; 38 | RenderableText& m_renderableText; 39 | }; 40 | 41 | 42 | -------------------------------------------------------------------------------- /src/Engine/GuiElementEnumSelection.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | #pragma once 16 | 17 | #include "GuiElementBase.h" 18 | #include "ConsoleVariableEnum.h" 19 | #include "RenderableText.h" 20 | 21 | class GuiElementEnumSelection : public GuiElementBase 22 | { 23 | public: 24 | GuiElementEnumSelection( 25 | const PlayerInput& playerInput, 26 | ConsoleVariableEnum& cvarEnum, 27 | const int16_t offsetXValue, 28 | RenderableText& renderableText); 29 | ~GuiElementEnumSelection() override; 30 | 31 | virtual const GuiEvent& ProcessInput() override; 32 | virtual void Draw(IRenderer& renderer) const override; 33 | virtual const std::string& GetLabel() const override; 34 | 35 | protected: 36 | ConsoleVariableEnum& m_cvarEnum; 37 | const int16_t m_offsetXValue; 38 | RenderableText& m_renderableText; 39 | }; 40 | 41 | -------------------------------------------------------------------------------- /src/Engine/Renderable3DWalls.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | #include "Renderable3DWalls.h" 17 | 18 | Renderable3DWalls::Renderable3DWalls() 19 | { 20 | m_textureToWallsMap.clear(); 21 | } 22 | 23 | void Renderable3DWalls::AddWall(const unsigned int textureId, const wallCoordinate coordinate) 24 | { 25 | if (m_textureToWallsMap.find(textureId) == m_textureToWallsMap.end()) 26 | { 27 | m_textureToWallsMap.insert(std::make_pair(textureId, std::vector())); 28 | } 29 | m_textureToWallsMap.at(textureId).push_back(coordinate); 30 | } 31 | 32 | const std::map>& Renderable3DWalls::GetTextureToWallsMap() const 33 | { 34 | return m_textureToWallsMap; 35 | } 36 | 37 | void Renderable3DWalls::Reset() 38 | { 39 | m_textureToWallsMap.clear(); 40 | } -------------------------------------------------------------------------------- /src/Engine/ManaBar.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | // 17 | // ManaBar 18 | // 19 | // The mana bar can be enabled to restrict the use of the primary magic missiles. 20 | // 21 | #pragma once 22 | 23 | #include 24 | #include "IRenderer.h" 25 | 26 | class ManaBar 27 | { 28 | public: 29 | struct ManaBarConfig 30 | { 31 | int16_t centerX; 32 | int16_t offsetY; 33 | egaColor frameColor; 34 | egaColor frameShadowColor; 35 | }; 36 | ManaBar(const ManaBarConfig config); 37 | ~ManaBar(); 38 | 39 | void Reset(const bool enabled); 40 | bool IsEnabled(); 41 | bool FireShot(); 42 | void Update(const uint32_t timestamp); 43 | void Draw(IRenderer& renderer); 44 | 45 | private: 46 | const ManaBarConfig m_config; 47 | bool m_enabled; 48 | uint32_t m_mana; 49 | uint32_t m_previousTimestamp; 50 | }; -------------------------------------------------------------------------------- /src/Catacomb3D/GuiElementButtonCat3D.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | #include "GuiElementButtonCat3D.h" 17 | 18 | GuiElementButtonCat3D::GuiElementButtonCat3D( 19 | const PlayerInput& playerInput, 20 | const std::string& buttonLabel, 21 | const GuiEvent& guiEventWhenActivated, 22 | RenderableText& renderableText, 23 | RenderableTiles& renderableTiles, 24 | bool& flashIcon) : 25 | GuiElementButton(playerInput, buttonLabel, guiEventWhenActivated, renderableText), 26 | m_renderableTiles(renderableTiles), 27 | m_flashIcon(flashIcon) 28 | { 29 | 30 | } 31 | 32 | void GuiElementButtonCat3D::Draw(IRenderer& renderer) const 33 | { 34 | m_renderableTiles.DrawListBullet(m_originX, m_originY, m_enabled, m_selected && m_flashIcon); 35 | m_renderableText.LeftAligned(m_buttonLabel, m_selected ? EgaBrightRed : EgaRed, m_originX + 8, m_originY + 1); 36 | } -------------------------------------------------------------------------------- /src/Engine/Decompressor.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2018 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | // 17 | // Decompressor 18 | // 19 | // Provides decompression routines required for interpreting the orginal game data files. 20 | // 21 | #pragma once 22 | 23 | #include "FileChunk.h" 24 | 25 | class Decompressor 26 | { 27 | public: 28 | static uint32_t lzhDecompress(uint8_t* infile, uint8_t* outfile, uint32_t OrginalLength, uint32_t CompressLength); 29 | static FileChunk* RLEW_Decompress(const uint8_t* compressedChunk, const uint16_t rlewtag); 30 | static FileChunk* RLEW_DecompressFromSavedGame( 31 | const uint8_t* compressedChunk, 32 | const uint16_t rlewtag, 33 | const uint16_t maxCompressedSize, 34 | uint16_t& compressedSize); 35 | static FileChunk* CarmackExpand (const uint8_t* compressedChunk); 36 | 37 | private: 38 | 39 | }; 40 | 41 | -------------------------------------------------------------------------------- /src/Engine/LevelLocationNames.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2018 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | // 17 | // LevelLocationNames 18 | // 19 | // The names of locations in a level, as read from a chunk of the EGAGRAPH repository file and 20 | // displayed in the statusbar. 21 | // 22 | #pragma once 23 | 24 | #include "FileChunk.h" 25 | #include 26 | #include 27 | 28 | class LevelLocationNames 29 | { 30 | public: 31 | LevelLocationNames(const FileChunk* decompressedChunk); 32 | ~LevelLocationNames(); 33 | 34 | const std::string& GetLocationName(const uint8_t index) const; 35 | const bool BorderShouldFlash(const uint8_t index) const; 36 | 37 | private: 38 | typedef struct 39 | { 40 | std::string name; 41 | bool borderShouldFlash; 42 | } LocationName; 43 | 44 | std::vector m_LocationNames; 45 | }; 46 | 47 | -------------------------------------------------------------------------------- /src/Engine/OverscanBorder.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | #pragma once 16 | 17 | // 18 | // OverscanBorder 19 | // 20 | // The overscan border is the area that surrounds the pixel space on a CRT monitor. 21 | // It can be assigned a color and is for example used in the original game to flash red 22 | // when the player gets hurt. 23 | // 24 | 25 | #include "EgaColor.h" 26 | 27 | class OverscanBorder 28 | { 29 | public: 30 | OverscanBorder(); 31 | ~OverscanBorder(); 32 | 33 | void SetColor(const uint32_t timeStamp, const uint8_t egaSignal, const uint32_t durationInMs); 34 | egaColor GetActiveColor(const uint32_t timeStamp) const; 35 | static const uint16_t GetBorderWidth(); 36 | static const uint16_t GetBorderHeight(); 37 | 38 | private: 39 | static egaColor ConvertEgaSignalToEgaColor(const uint8_t egaSignal); 40 | 41 | egaColor m_color; 42 | uint32_t m_timeStampWhenColorIsExpired; 43 | }; 44 | -------------------------------------------------------------------------------- /src/Engine/GuiElementBindKey.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | #pragma once 16 | 17 | #include "GuiElementBase.h" 18 | #include "ControlsMap.h" 19 | #include "RenderableText.h" 20 | 21 | class GuiElementBindKey : public GuiElementBase 22 | { 23 | public: 24 | GuiElementBindKey( 25 | const PlayerInput& playerInput, 26 | ControlsMap& controlsMap, 27 | ControlAction controlAction, 28 | const int16_t offsetXValue, 29 | RenderableText& renderableText); 30 | ~GuiElementBindKey() override; 31 | 32 | virtual const GuiEvent& ProcessInput() override; 33 | virtual void Draw(IRenderer& renderer) const override; 34 | virtual const std::string& GetLabel() const override; 35 | 36 | protected: 37 | ControlsMap& m_controlsMap; 38 | ControlAction m_controlAction; 39 | const int16_t m_offsetXValue; 40 | RenderableText& m_renderableText; 41 | bool m_waitingForKey; 42 | }; 43 | -------------------------------------------------------------------------------- /src/Engine/GuiPage.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | #pragma once 16 | 17 | #include "GuiElementBase.h" 18 | #include "RenderableText.h" 19 | 20 | class GuiPage : public GuiElementBase 21 | { 22 | public: 23 | GuiPage( 24 | const PlayerInput& playerInput); 25 | ~GuiPage() override; 26 | 27 | virtual void AddChild(GuiElementBase* child, const int16_t offsetX = 0, const int16_t offsetY = 0, const int16_t parentId = 0) override; 28 | virtual const GuiEvent& ProcessInput() override; 29 | virtual void Draw(IRenderer& renderer) const override; 30 | virtual void SetEnabled(const bool enabled, const int16_t id = 0) override; 31 | 32 | private: 33 | struct PageElement 34 | { 35 | GuiElementBase* element; 36 | int16_t offsetX; 37 | int16_t offsetY; 38 | }; 39 | 40 | std::vector m_elements; 41 | const GuiEvent m_closeEvent = { GuiActionClose, 0 }; 42 | }; 43 | -------------------------------------------------------------------------------- /src/Engine/ISavedGameConverter.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | // 17 | // ISavedGameConverter 18 | // 19 | // Interface for abstracting conversion of saved games from DOS format to CatacombGL format. 20 | // 21 | #pragma once 22 | 23 | #include 24 | #include "SavedGameInDosFormat.h" 25 | #include "Decorate.h" 26 | 27 | class ISavedGameConverter 28 | { 29 | public: 30 | virtual ~ISavedGameConverter() {}; 31 | virtual const uint16_t GetActorId(const SavedGameInDosFormat::ObjectInDosFormat& dosObject) const = 0; 32 | virtual const DecorateStateId GetDecorateStateId(const SavedGameInDosFormat::ObjectInDosFormat& dosObject) const = 0; 33 | virtual const uint16_t GetAnimationFrame(const SavedGameInDosFormat::ObjectInDosFormat& dosObject) const = 0; 34 | virtual const bool IsInertObject(const uint16_t obclass) const = 0; 35 | virtual void SetFarPointerOffset(const uint32_t playerState32) = 0; 36 | }; 37 | -------------------------------------------------------------------------------- /src/Engine/GuiCatalog.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | #pragma once 16 | 17 | #include "GuiElementBase.h" 18 | #include "Shape.h" 19 | #include 20 | 21 | class GuiCatalog : public GuiElementBase 22 | { 23 | public: 24 | GuiCatalog( 25 | PlayerInput& playerInput, 26 | const IRenderer& renderer, 27 | const std::vector& catalogFilenames, 28 | const std::filesystem::path& gameFolder); 29 | ~GuiCatalog(); 30 | virtual const GuiEvent& ProcessInput() override; 31 | virtual void Draw(IRenderer& renderer) const override; 32 | 33 | private: 34 | std::vector m_shapes; 35 | const std::vector& m_catalogFilenames; 36 | const GuiEvent m_closeEvent = { GuiActionClose, 0 }; 37 | uint16_t m_currentPage; 38 | uint16_t m_mostRecentPageWithFullscreenImage; 39 | const IRenderer& m_renderer; 40 | const std::filesystem::path m_gameFolder; 41 | }; 42 | -------------------------------------------------------------------------------- /src/Catacomb3D/IntroViewCatacomb3D.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | // 17 | // IntroViewCatacomb3D 18 | // 19 | // Introduction screens for the Catacomb 3-D 20 | // 21 | #pragma once 22 | 23 | #include "../Engine/IIntroView.h" 24 | #include "../Engine/EgaGraph.h" 25 | #include "../Engine/HighScores.h" 26 | #include "../Engine/FadeEffect.h" 27 | #include 28 | #include 29 | 30 | class IntroViewCatacomb3D : public IIntroView 31 | { 32 | public: 33 | IntroViewCatacomb3D(IRenderer& renderer, EgaGraph* egagraph, const std::filesystem::path& path, HighScores& highScores); 34 | ~IntroViewCatacomb3D(); 35 | void DrawIntroduction(const uint32_t timeStamp); 36 | void DrawRequestDifficultyLevel(); 37 | void DrawNoviceSelected(); 38 | void DrawWarriorSelected(); 39 | void DrawStandBeforeGate(); 40 | 41 | private: 42 | EgaGraph* m_egaGraph; 43 | HighScores& m_highScores; 44 | FadeEffect m_fadeEffect; 45 | }; 46 | -------------------------------------------------------------------------------- /src/Engine/ConsoleVariable.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | #include "ConsoleVariable.h" 17 | 18 | ConsoleVariable::ConsoleVariable(): 19 | m_nameInMenu(""), 20 | m_nameInConfigFile("") 21 | { 22 | 23 | } 24 | ConsoleVariable::ConsoleVariable(const std::string& nameInMenu, const std::string& nameInConfigFile): 25 | m_nameInMenu(nameInMenu), 26 | m_nameInConfigFile(nameInConfigFile) 27 | { 28 | 29 | } 30 | 31 | ConsoleVariable::~ConsoleVariable() 32 | { 33 | 34 | } 35 | 36 | const std::string& ConsoleVariable::GetNameInMenu() const 37 | { 38 | return m_nameInMenu; 39 | } 40 | 41 | const std::string& ConsoleVariable::GetNameInConfigFile() const 42 | { 43 | return m_nameInConfigFile; 44 | } 45 | 46 | const std::string ConsoleVariable::Serialize() const 47 | { 48 | return ""; 49 | } 50 | 51 | void ConsoleVariable::Deserialize(const std::string& str) 52 | { 53 | 54 | } 55 | 56 | void ConsoleVariable::SetToDefault() 57 | { 58 | 59 | } -------------------------------------------------------------------------------- /src/Engine/Picture.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2018 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | // 17 | // Picture 18 | // 19 | // Contains a single picture (wall texture, sprite texture, etc...) 20 | // 21 | #pragma once 22 | 23 | #include "FileChunk.h" 24 | 25 | class Picture 26 | { 27 | public: 28 | Picture(const unsigned int textureId, const uint16_t imageWidth, const uint16_t imageHeight, const uint16_t textureWidth, const uint16_t textureHeight); 29 | ~Picture(); 30 | 31 | unsigned int GetTextureId() const; 32 | uint16_t GetImageWidth() const; 33 | uint16_t GetImageHeight() const; 34 | uint16_t GetTextureWidth() const; 35 | uint16_t GetTextureHeight() const; 36 | static uint16_t GetNearestPowerOfTwo(const uint16_t size); 37 | 38 | private: 39 | uint16_t m_imageWidth; 40 | uint16_t m_imageHeight; 41 | uint16_t m_textureWidth; 42 | uint16_t m_textureHeight; 43 | unsigned int m_textureId; 44 | }; 45 | 46 | -------------------------------------------------------------------------------- /src/Engine/FramesCounter.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2018 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | #include "FramesCounter.h" 17 | 18 | FramesCounter::FramesCounter() : 19 | m_framesPerSecond(0), 20 | m_startTimestamp(0), 21 | m_frameCount(0) 22 | { 23 | } 24 | 25 | FramesCounter::~FramesCounter() 26 | { 27 | 28 | } 29 | 30 | void FramesCounter::AddFrame(const uint32_t timeStamp) 31 | { 32 | if (timeStamp >= m_startTimestamp + 1000) 33 | { 34 | if (m_startTimestamp != 0) 35 | { 36 | const uint32_t deltaTime = (uint32_t)(timeStamp - m_startTimestamp); 37 | m_framesPerSecond = (m_frameCount * 1000) / deltaTime; 38 | } 39 | 40 | m_frameCount = 1; 41 | m_startTimestamp = timeStamp; 42 | } 43 | else 44 | { 45 | m_frameCount++; 46 | } 47 | } 48 | 49 | uint32_t FramesCounter::GetFramesPerSecond() const 50 | { 51 | return m_framesPerSecond; 52 | } -------------------------------------------------------------------------------- /src/Engine/GuiMenu.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | #pragma once 16 | 17 | #include "GuiElementBase.h" 18 | #include "RenderableText.h" 19 | 20 | class GuiMenu : public GuiElementBase 21 | { 22 | public: 23 | GuiMenu( 24 | const PlayerInput& playerInput); 25 | ~GuiMenu() override; 26 | 27 | virtual void AddChild(GuiElementBase* child, const int16_t offsetX = 0, const int16_t offsetY = 0, const int16_t parentId = 0) override; 28 | virtual const GuiEvent& ProcessInput() override; 29 | virtual void Draw(IRenderer& renderer) const override; 30 | virtual void SetEnabled(const bool enabled, const int16_t id = 0) override; 31 | 32 | void Open(const int16_t id); 33 | 34 | private: 35 | size_t GetIndexFromId(const int16_t id) const; 36 | 37 | std::vector m_elements; 38 | size_t m_elementOpenIndex; 39 | std::vector m_previouslyOpen; 40 | const GuiEvent m_noneEvent = { GuiActionNone, 0 }; 41 | }; 42 | 43 | -------------------------------------------------------------------------------- /src/Engine/ConsoleVariableInt.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | #pragma once 16 | 17 | #include "ConsoleVariable.h" 18 | #include 19 | 20 | class ConsoleVariableInt : public ConsoleVariable 21 | { 22 | public: 23 | ConsoleVariableInt( 24 | const std::string& nameInMenu, 25 | const std::string& nameInConfigFile, 26 | const int32_t minValue, 27 | const int32_t maxValue, 28 | const int32_t defaultValue); 29 | ~ConsoleVariableInt(); 30 | 31 | const std::string Serialize() const override; 32 | void Deserialize(const std::string& str) override; 33 | void SetToDefault() override; 34 | 35 | int32_t GetValue() const; 36 | void SetValue(const int32_t value); 37 | void Increase(); 38 | void Decrease(); 39 | 40 | private: 41 | void ClipValueToRange(); 42 | 43 | const int32_t m_minValue; 44 | const int32_t m_maxValue; 45 | int32_t m_value; 46 | const int32_t m_defaultValue; 47 | }; 48 | 49 | -------------------------------------------------------------------------------- /src/Engine/GameDetection.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2018 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | // 17 | // GameDetections 18 | // 19 | // Determines whether a specific game is located in a specific folder, based on 20 | // a list of known filenames and filesizes. 21 | // 22 | #pragma once 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include "GameId.h" 29 | 30 | struct DetectionReport 31 | { 32 | GameId gameId; 33 | std::filesystem::path folder; 34 | uint16_t score; 35 | std::string infoString; 36 | }; 37 | 38 | class GameDetection 39 | { 40 | public: 41 | GameDetection(); 42 | 43 | const DetectionReport& GetBestMatch() const; 44 | const DetectionReport& GetDetectionReport(const GameId gameId, const std::filesystem::path& folder, const std::map& files); 45 | 46 | private: 47 | DetectionReport m_latestReport; 48 | DetectionReport m_bestMatch; 49 | }; 50 | -------------------------------------------------------------------------------- /src/Engine/ConsoleVariableString.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | #include "ConsoleVariableString.h" 17 | 18 | ConsoleVariableString::ConsoleVariableString(const std::string& nameInMenu, const std::string& nameInConfigFile, const std::string& defaultValue) : 19 | ConsoleVariable(nameInMenu, nameInConfigFile), 20 | m_value(defaultValue), 21 | m_defaultValue(defaultValue) 22 | { 23 | 24 | } 25 | 26 | ConsoleVariableString::~ConsoleVariableString() 27 | { 28 | 29 | } 30 | 31 | const std::string ConsoleVariableString::Serialize() const 32 | { 33 | return m_value; 34 | } 35 | 36 | void ConsoleVariableString::Deserialize(const std::string& str) 37 | { 38 | m_value = str; 39 | } 40 | 41 | const std::string& ConsoleVariableString::Get() const 42 | { 43 | return m_value; 44 | } 45 | 46 | void ConsoleVariableString::Set(const std::string& value) 47 | { 48 | m_value = value; 49 | } 50 | 51 | void ConsoleVariableString::SetToDefault() 52 | { 53 | m_value = m_defaultValue; 54 | } -------------------------------------------------------------------------------- /ThirdParty/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.16) 2 | project(CatacombGL_ThirdParty LANGUAGES CXX C) 3 | 4 | include_directories(ReflectionHLE) 5 | 6 | add_library( CatacombGL_ThirdParty OBJECT 7 | ReflectionHLE/backend/audio/be_audio_digi.c 8 | ReflectionHLE/backend/audio/be_audio_init.c 9 | ReflectionHLE/backend/audio/be_audio_main_thread.c 10 | ReflectionHLE/backend/audio/be_audio_main_thread.h 11 | ReflectionHLE/backend/audio/be_audio_mixer.c 12 | ReflectionHLE/backend/audio/be_audio_mixer.h 13 | ReflectionHLE/backend/audio/be_audio_opl.c 14 | ReflectionHLE/backend/audio/be_audio_pcspkr.c 15 | ReflectionHLE/backend/audio/be_audio_private.h 16 | ReflectionHLE/backend/audio/be_audio_resampling.c 17 | ReflectionHLE/backend/audio/be_audio_resampling.h 18 | ReflectionHLE/backend/audio/be_audio_sdl.c 19 | ReflectionHLE/backend/cfg/be_cfg.c 20 | ReflectionHLE/backend/cfg/be_cfg_sdl.c 21 | ReflectionHLE/backend/threading/be_atomic.h 22 | ReflectionHLE/backend/threading/be_atomic_sdl.h 23 | ReflectionHLE/backend/threading/be_mutex.h 24 | ReflectionHLE/backend/threading/be_mutex_sdl.h 25 | ReflectionHLE/backend/timing/be_timing.c 26 | ReflectionHLE/backend/timing/be_timing.h 27 | ReflectionHLE/backend/timing/be_timing_callback.c 28 | ReflectionHLE/nukedopl/opl3.c 29 | ReflectionHLE/nukedopl/opl3.h 30 | ReflectionHLE/be_cross.c 31 | ReflectionHLE/be_cross.h 32 | ReflectionHLE/be_sound_device_flags.h 33 | ReflectionHLE/be_st.h 34 | ReflectionHLE/be_st_cfg.h 35 | ReflectionHLE/be_st_sdl_private.h 36 | ReflectionHLE/id_sd.cpp 37 | ReflectionHLE/id_sd.h 38 | ReflectionHLE/refkeen_config.h 39 | ) 40 | -------------------------------------------------------------------------------- /src/Engine/AdlibSound.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2018 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | #pragma once 16 | 17 | #include "FileChunk.h" 18 | 19 | class AdlibSound 20 | { 21 | public: 22 | AdlibSound(); 23 | AdlibSound(const FileChunk* decompressedChunk); 24 | ~AdlibSound(); 25 | 26 | uint32_t GetLength() const; 27 | uint16_t GetPriority() const; 28 | uint8_t* GetInstruments() const; 29 | uint8_t GetOctave() const; 30 | uint8_t* GetData() const; 31 | 32 | uint8_t GetmChar() const; 33 | uint8_t GetcChar() const; 34 | uint8_t GetmScale() const; 35 | uint8_t GetcScale() const; 36 | uint8_t GetmAttack() const; 37 | uint8_t GetcAttack() const; 38 | uint8_t GetmSus() const; 39 | uint8_t GetcSus() const; 40 | uint8_t GetmWave() const; 41 | uint8_t GetcWave() const; 42 | 43 | private: 44 | uint32_t m_length; 45 | uint16_t m_priority; 46 | uint8_t m_instruments[16]; 47 | uint8_t m_octave; 48 | uint8_t* m_data; 49 | }; 50 | 51 | -------------------------------------------------------------------------------- /src/Abyss/SavedGameInDosFormatConfigAbyss.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | #pragma once 16 | 17 | #include "../Engine/SavedGameInDosFormatConfig.h" 18 | 19 | static const SavedGameInDosFormatConfig savedGameInDosFormatConfigAbyss = 20 | { 21 | "CATACOMB ABYSS 3-D", // gameName 22 | "0.93", // saveVersion 23 | { 24 | HeaderItemFreezeTime, HeaderItemDifficulty, HeaderItemMapOn, HeaderItemBolts, HeaderItemNukes, HeaderItemPotions, 25 | HeaderItemKeys, HeaderItemScrolls, HeaderItemGems, HeaderItemScore, HeaderItemBody, HeaderItemShotpower, 26 | HeaderItemEasyModeOn 27 | }, // headerItems 28 | { 29 | ObjectActive, ObjectTiccount, ObjectObclass, ObjectState16, ObjectFlags, 30 | ObjectDistance, ObjectDir, ObjectX, ObjectY, ObjectTileX, ObjectTileY, ObjectViewX, ObjectViewHeight, 31 | ObjectAngle, ObjectHitpoints, ObjectSpeed, ObjectSize, ObjectXL, ObjectXH, ObjectYL, ObjectYH, 32 | ObjectTemp1, ObjectTemp2, ObjectNext, ObjectPrev 33 | } // objectItems 34 | }; 35 | -------------------------------------------------------------------------------- /src/Test/HelpPages_Test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | #include "HelpPages_Test.h" 17 | #include "../Engine/HelpPages.h" 18 | 19 | HelpPages_Test::HelpPages_Test() 20 | { 21 | 22 | } 23 | 24 | HelpPages_Test::~HelpPages_Test() 25 | { 26 | 27 | } 28 | 29 | TEST(HelpPages_Test, ZeroPagesWhenEmptyString) 30 | { 31 | HelpPages helpPages(""); 32 | EXPECT_EQ(0, helpPages.GetNumberOfPages()); 33 | } 34 | 35 | TEST(HelpPages_Test, TwoRegularPages) 36 | { 37 | HelpPages helpPages("First line\n^Centered second line\n\nFourth and last line\n@First line of second page\nSecond and last line\n@\n@"); 38 | EXPECT_EQ(2, helpPages.GetNumberOfPages()); 39 | 40 | const HelpPage& page0 = helpPages.GetPage(0); 41 | EXPECT_EQ(4, page0.size()); 42 | EXPECT_STREQ("First line", page0.at(0).line.c_str()); 43 | EXPECT_FALSE(page0.at(0).centered); 44 | EXPECT_STREQ("Centered second line", page0.at(1).line.c_str()); 45 | EXPECT_TRUE(page0.at(1).centered); 46 | 47 | const HelpPage& page1 = helpPages.GetPage(1); 48 | EXPECT_EQ(2, page1.size()); 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/Catacomb3D/SavedInGameInDosFormatConfigCatacomb3D.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | #pragma once 16 | 17 | #include "../Engine/SavedGameInDosFormatConfig.h" 18 | 19 | static const SavedGameInDosFormatConfig savedGameInDosFormatConfigCatacomb3D = 20 | { 21 | "", // gameName 22 | "", // saveVersion 23 | { 24 | HeaderItemSignature, HeaderItemOldTest, HeaderItemPresent, HeaderItemName, 25 | HeaderItemDifficulty, HeaderItemMapOn, HeaderItemBolts, HeaderItemNukes, HeaderItemPotions, 26 | HeaderItemKeys, HeaderItemScrolls, HeaderItemScore, HeaderItemBody, HeaderItemShotpower 27 | }, // headerItems 28 | { 29 | ObjectActive, ObjectTiccount, ObjectObclass, ObjectState16, ObjectShootable, ObjectTileObject, 30 | ObjectDistance, ObjectDir, ObjectX, ObjectY, ObjectTileX, ObjectTileY, ObjectViewX, ObjectViewHeight, 31 | ObjectAngle, ObjectHitpoints, ObjectSpeed, ObjectSize, ObjectXL, ObjectXH, ObjectYL, ObjectYH, 32 | ObjectTemp1, ObjectTemp2, ObjectNext, ObjectPrev 33 | } // objectItems 34 | }; 35 | -------------------------------------------------------------------------------- /src/Engine/Shape.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2018 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | // 17 | // Shape 18 | // 19 | // A picture used in the introduction screens, which is read from a SHP??.ABS file. 20 | // 21 | #pragma once 22 | 23 | #include "Picture.h" 24 | #include "IRenderer.h" 25 | #include "Logging.h" 26 | #include 27 | 28 | class Shape 29 | { 30 | public: 31 | Shape(const IRenderer& renderer); 32 | ~Shape(); 33 | bool LoadFromFile(const std::filesystem::path filename); 34 | 35 | uint16_t GetOffsetX() const; 36 | uint16_t GetOffsetY() const; 37 | Picture* GetPicture() const; 38 | 39 | private: 40 | unsigned int LoadFileChunkIntoTexture( 41 | const FileChunk* decompressedChunk, 42 | const uint16_t imageWidth, 43 | const uint16_t imageHeight, 44 | const uint16_t textureWidth, 45 | const uint16_t textureHeight, 46 | const bool transparent); 47 | 48 | uint16_t m_offsetX; 49 | uint16_t m_offsetY; 50 | Picture* m_picture; 51 | const IRenderer& m_renderer; 52 | }; 53 | -------------------------------------------------------------------------------- /src/Catacomb3D/GuiElementSaveSlotStaticCat3D.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | #include "GuiElementSaveSlotStaticCat3D.h" 17 | 18 | GuiElementSaveSlotStaticCat3D::GuiElementSaveSlotStaticCat3D( 19 | const PlayerInput& playerInput, 20 | const std::string& buttonLabel, 21 | const GuiEvent& guiEventWhenActivated, 22 | RenderableText& renderableText, 23 | bool& flashIcon) : 24 | GuiElementButton(playerInput, buttonLabel, guiEventWhenActivated, renderableText), 25 | m_flashIcon(flashIcon) 26 | { 27 | 28 | } 29 | 30 | void GuiElementSaveSlotStaticCat3D::Draw(IRenderer& renderer) const 31 | { 32 | const bool bright = m_selected && m_flashIcon; 33 | const egaColor color = bright ? EgaBrightRed : EgaRed; 34 | m_renderableText.LeftAligned(m_buttonLabel, color, m_originX + 2, m_originY + 2); 35 | renderer.Render2DBar(m_originX, m_originY, 148, 1, color); 36 | renderer.Render2DBar(m_originX, m_originY + 9, 148, 1, color); 37 | renderer.Render2DBar(m_originX, m_originY + 1, 1, 8, color); 38 | renderer.Render2DBar(m_originX + 147, m_originY + 1, 1, 8, color); 39 | } -------------------------------------------------------------------------------- /src/Engine/GuiElementEditText.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | #pragma once 16 | 17 | #include "GuiElementBase.h" 18 | #include "RenderableText.h" 19 | 20 | class GuiElementEditText : public GuiElementBase 21 | { 22 | public: 23 | GuiElementEditText( 24 | const PlayerInput& playerInput, 25 | std::string& outputText, 26 | const std::string& initialText, 27 | const uint16_t maxTextLength, 28 | RenderableText& renderableText, 29 | GuiEvent& textCompleteAction); 30 | ~GuiElementEditText() override; 31 | 32 | virtual const GuiEvent& ProcessInput() override; 33 | virtual void Draw(IRenderer& renderer) const override; 34 | 35 | private: 36 | static bool KeyIsSuitableForText(const SDL_Keycode keyCode); 37 | 38 | protected: 39 | std::string& m_outputText; 40 | const std::string m_initialText; 41 | RenderableText& m_renderableText; 42 | const GuiEvent m_textCompleteAction; 43 | const GuiEvent m_busyAction = { GuiActionBusy, 0 }; 44 | bool m_enteringText; 45 | const uint16_t m_maxTextLength; 46 | }; 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /src/Engine/Renderable3DTiles.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | // 16 | // Renderable3DTiles 17 | // 18 | // Contains a list of 3D tiles that can be processed by the renderer. 19 | // Used for the floor and ceiling in the 3D view. 20 | // 21 | #pragma once 22 | 23 | #include 24 | #include "EgaColor.h" 25 | 26 | class Renderable3DTiles 27 | { 28 | public: 29 | typedef struct 30 | { 31 | int16_t x; 32 | int16_t y; 33 | } tileCoordinate; 34 | 35 | Renderable3DTiles(); 36 | void AddTile(const tileCoordinate coordinate); 37 | egaColor GetFloorColor() const; 38 | egaColor GetCeilingColor() const; 39 | void SetFloorColor(const egaColor color); 40 | void SetCeilingColor(const egaColor color); 41 | bool IsOnlyFloor() const; 42 | void SetOnlyFloor(const bool isOnlyFloor); 43 | const std::vector& GetTileCoordinates() const; 44 | void Reset(); 45 | 46 | private: 47 | egaColor m_floorColor; 48 | egaColor m_ceilingColor; 49 | bool m_onlyFloor; 50 | std::vector m_tileCoordinates; 51 | }; 52 | 53 | 54 | -------------------------------------------------------------------------------- /src/Catacomb3D/GuiElementBoolSelectionCat3D.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | #include "GuiElementBoolSelectionCat3D.h" 17 | 18 | GuiElementBoolSelectionCat3D::GuiElementBoolSelectionCat3D( 19 | const PlayerInput& playerInput, 20 | ConsoleVariableBool& cvarBool, 21 | const int16_t offsetXValue, 22 | RenderableText& renderableText, 23 | RenderableTiles& renderableTiles, 24 | bool& flashIcon) : 25 | GuiElementBoolSelection(playerInput, cvarBool, offsetXValue, renderableText), 26 | m_renderableTiles(renderableTiles), 27 | m_flashIcon(flashIcon) 28 | { 29 | 30 | } 31 | 32 | void GuiElementBoolSelectionCat3D::Draw(IRenderer& renderer) const 33 | { 34 | m_renderableTiles.DrawListBullet(m_originX, m_originY, m_enabled, m_selected && m_flashIcon); 35 | m_renderableText.LeftAligned(m_cvarBool.GetNameInMenu(), m_selected ? EgaBrightRed : EgaRed, m_originX + 8, m_originY + 1); 36 | const std::string& str = (!m_enabled) ? "Not support." : m_cvarBool.GetValueInMenu(); 37 | m_renderableText.LeftAligned(str, m_selected ? EgaLightGray : EgaDarkGray, m_originX + m_offsetXValue, m_originY + 1); 38 | } -------------------------------------------------------------------------------- /src/Catacomb3D/GuiElementEnumSelectionCat3D.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | #include "GuiElementEnumSelectionCat3D.h" 17 | 18 | GuiElementEnumSelectionCat3D::GuiElementEnumSelectionCat3D( 19 | const PlayerInput& playerInput, 20 | ConsoleVariableEnum& cvarEnum, 21 | const int16_t offsetXValue, 22 | RenderableText& renderableText, 23 | RenderableTiles& renderableTiles, 24 | bool& flashIcon) : 25 | GuiElementEnumSelection (playerInput, cvarEnum, offsetXValue, renderableText), 26 | m_renderableTiles(renderableTiles), 27 | m_flashIcon(flashIcon) 28 | { 29 | 30 | } 31 | 32 | void GuiElementEnumSelectionCat3D::Draw(IRenderer& renderer) const 33 | { 34 | m_renderableTiles.DrawListBullet(m_originX, m_originY, m_enabled, m_selected && m_flashIcon); 35 | m_renderableText.LeftAligned(m_cvarEnum.GetNameInMenu(), m_selected ? EgaBrightRed : EgaRed, m_originX + 8, m_originY + 1); 36 | const std::string& str = (!m_enabled) ? "Not support." : m_cvarEnum.GetValueInMenu(); 37 | m_renderableText.LeftAligned(str, m_selected ? EgaLightGray : EgaDarkGray, m_originX + m_offsetXValue, m_originY + 1); 38 | } -------------------------------------------------------------------------------- /src/Catacomb3D/GuiElementIntSelectionCat3D.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | #include "GuiElementIntSelectionCat3D.h" 17 | 18 | GuiElementIntSelectionCat3D::GuiElementIntSelectionCat3D( 19 | const PlayerInput& playerInput, 20 | ConsoleVariableInt& cvarInt, 21 | const int16_t offsetXValue, 22 | RenderableText& renderableText, 23 | RenderableTiles& renderableTiles, 24 | bool& flashIcon) : 25 | GuiElementIntSelection (playerInput, cvarInt, offsetXValue, renderableText), 26 | m_renderableTiles(renderableTiles), 27 | m_flashIcon(flashIcon) 28 | { 29 | 30 | } 31 | 32 | void GuiElementIntSelectionCat3D::Draw(IRenderer& renderer) const 33 | { 34 | m_renderableTiles.DrawListBullet(m_originX, m_originY, m_enabled, m_selected && m_flashIcon); 35 | m_renderableText.LeftAligned(m_cvarInt.GetNameInMenu(), m_selected ? EgaBrightRed : EgaRed, m_originX + 8, m_originY + 1); 36 | const std::string& str = (!m_enabled) ? "Not support." : std::to_string(m_cvarInt.GetValue()); 37 | m_renderableText.LeftAligned(str, m_selected ? EgaLightGray : EgaDarkGray, m_originX + m_offsetXValue, m_originY + 1); 38 | } -------------------------------------------------------------------------------- /src/Abyss/IntroViewAbyss.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2018 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | // 17 | // IntroViewAbyss 18 | // 19 | // Introduction screens for the Catacomb Abyss 20 | // 21 | #pragma once 22 | 23 | #include "../Engine/IIntroView.h" 24 | #include "../Engine/Shape.h" 25 | #include 26 | #include 27 | 28 | class IntroViewAbyss : public IIntroView 29 | { 30 | public: 31 | IntroViewAbyss(IRenderer& renderer, const std::filesystem::path& path); 32 | ~IntroViewAbyss(); 33 | void DrawIntroduction(const uint32_t timeStamp); 34 | void DrawRequestDifficultyLevel(); 35 | void DrawNoviceSelected(); 36 | void DrawWarriorSelected(); 37 | void DrawStandBeforeGate(); 38 | 39 | private: 40 | Shape* m_shapeEntering; 41 | Shape* m_shapePresents; 42 | Shape* m_shapeSoftdisk; 43 | Shape* m_shapeTitle; 44 | Shape* m_shapeCredits; 45 | Shape* m_shapeTrilogy; 46 | Shape* m_shapeSelectDifficulty; 47 | Shape* m_shapeConfirmDifficulty; 48 | Shape* m_shapeNovice; 49 | Shape* m_shapeWarrior; 50 | Shape* m_shapeStandBeforeGate; 51 | }; 52 | 53 | -------------------------------------------------------------------------------- /src/Armageddon/SavesGameInDosFormatConfigArmageddon.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | #pragma once 16 | 17 | #include "../Engine/SavedGameInDosFormatConfig.h" 18 | 19 | static const SavedGameInDosFormatConfig savedGameInDosFormatConfigArmageddon = 20 | { 21 | "CATACOMB ARMAGEDDON 3-D", // gameName 22 | "0.01", // saveVersion 23 | { 24 | HeaderTtemSkyColor, HeaderItemGroundColor, HeaderItemFreezeTime, HeaderItemDifficulty, HeaderItemMapOn, HeaderItemBolts, HeaderItemNukes, HeaderItemPotions, 25 | HeaderItemKeys, HeaderItemScrolls, HeaderItemGems, HeaderItemScore, HeaderItemBody, HeaderItemShotpower, 26 | HeaderItemMapWidth, HeaderItemMapHeight, HeaderItemEasyModeOn 27 | }, // headerItems 28 | { 29 | ObjectTiccount, ObjectState32, 30 | ObjectX, ObjectY, ObjectViewX, ObjectTileX, ObjectTileY, ObjectViewHeight, ObjectSize, 31 | ObjectNext, ObjectPrev, ObjectActive, ObjectObclass, ObjectFlags, ObjectDistance, ObjectDir, 32 | ObjectAngle, ObjectHitpoints, ObjectSpeed, ObjectXL, ObjectXH, ObjectYL, ObjectYH, 33 | ObjectTemp1, ObjectTemp2, 34 | } // objectItems 35 | }; -------------------------------------------------------------------------------- /src/Apocalypse/SavedGameInDosFormatConfigApocalypse.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | #pragma once 16 | 17 | #include "../Engine/SavedGameInDosFormatConfig.h" 18 | 19 | static const SavedGameInDosFormatConfig savedGameInDosFormatConfigApocalypse = 20 | { 21 | "CATACOMB APOCALYPSE 3-D", // gameName 22 | "0.01", // saveVersion 23 | { 24 | HeaderTtemSkyColor, HeaderItemGroundColor, HeaderItemFreezeTime, HeaderItemDifficulty, HeaderItemMapOn, HeaderItemBolts, HeaderItemNukes, HeaderItemPotions, 25 | HeaderItemKeys, HeaderItemScrolls, HeaderItemGems, HeaderItemScore, HeaderItemBody, HeaderItemShotpower, 26 | HeaderItemMapWidth, HeaderItemMapHeight, HeaderItemEasyModeOn 27 | }, // headerItems 28 | { 29 | ObjectTiccount, ObjectState32, 30 | ObjectX, ObjectY, ObjectViewX, ObjectTileX, ObjectTileY, ObjectViewHeight, ObjectSize, 31 | ObjectNext, ObjectPrev, ObjectActive, ObjectObclass, ObjectFlags, ObjectDistance, ObjectDir, 32 | ObjectAngle, ObjectHitpoints, ObjectSpeed, ObjectXL, ObjectXH, ObjectYL, ObjectYH, 33 | ObjectTemp1, ObjectTemp2, 34 | } // objectItems 35 | }; 36 | -------------------------------------------------------------------------------- /src/Apocalypse/GameDetectionApocalypse.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | // 17 | // GameDetectionApocalypse 18 | // 19 | // Data structures for detecting the Catacomb Apocalypse game files. 20 | // 21 | #pragma once 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | const std::map apocalypseFiles = 28 | { 29 | std::make_pair("AUDIO.APC", 7366), 30 | std::make_pair("EGAGRAPH.APC", 382078), 31 | std::make_pair("GAMEMAPS.APC", 18855), 32 | std::make_pair("SHP1.APC", 1376), 33 | std::make_pair("SHP2.APC", 6329), 34 | std::make_pair("SHP3.APC", 13187), 35 | std::make_pair("SHP4.APC", 13592), 36 | std::make_pair("SHP5.APC", 12698), 37 | std::make_pair("SHP6.APC", 11131), 38 | std::make_pair("SHP7.APC", 13266), 39 | std::make_pair("SHP8.APC", 640), 40 | std::make_pair("SHP9.APC", 9182), 41 | std::make_pair("SHP10.APC", 9930), 42 | std::make_pair("SHP11.APC", 398), 43 | std::make_pair("SHP12.APC", 417), 44 | std::make_pair("SHP13.APC", 329), 45 | std::make_pair("SHP14.APC", 1668) 46 | }; 47 | -------------------------------------------------------------------------------- /src/Armageddon/GameDetectionArmageddon.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2018 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | // 17 | // GameDetectionArmageddon 18 | // 19 | // Data structures for detecting the Catacomb Armageddon game files. 20 | // 21 | #pragma once 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | const std::map armageddonFiles = 28 | { 29 | std::make_pair("AUDIO.ARM", 7104), 30 | std::make_pair("EGAGRAPH.ARM", 355832), 31 | std::make_pair("GAMEMAPS.ARM", 17653), 32 | std::make_pair("SHP1.ARM", 1376), 33 | std::make_pair("SHP2.ARM", 3991), 34 | std::make_pair("SHP3.ARM", 15036), 35 | std::make_pair("SHP4.ARM", 15568), 36 | std::make_pair("SHP5.ARM", 13234), 37 | std::make_pair("SHP6.ARM", 10861), 38 | std::make_pair("SHP7.ARM", 9414), 39 | std::make_pair("SHP8.ARM", 749), 40 | std::make_pair("SHP9.ARM", 9182), 41 | std::make_pair("SHP10.ARM", 9930), 42 | std::make_pair("SHP11.ARM", 398), 43 | std::make_pair("SHP12.ARM", 417), 44 | std::make_pair("SHP13.ARM", 329), 45 | std::make_pair("SHP14.ARM", 1688) 46 | }; 47 | -------------------------------------------------------------------------------- /src/Engine/SavedGameInDosFormatLoader.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | #pragma once 17 | 18 | #include 19 | #include 20 | 21 | class SavedGameInDosFormat; 22 | class ISavedGameConverter; 23 | class Actor; 24 | struct DecorateActor; 25 | 26 | class SavedGameInDosFormatLoader 27 | { 28 | public: 29 | SavedGameInDosFormatLoader( 30 | const SavedGameInDosFormat& savedGameInDosFormat, 31 | const ISavedGameConverter& savedGameConverter, 32 | const std::map& decorateActors); 33 | ~SavedGameInDosFormatLoader() = default; 34 | 35 | Actor* LoadPlayerActor() const; 36 | void LoadActors( 37 | Actor** blockingActors, 38 | Actor** nonBlockingActors, 39 | const uint16_t levelWidth, 40 | const uint16_t levelHeight); 41 | uint32_t GetPlayerState32() const; 42 | 43 | private: 44 | static const float DosToGLCoordinate(const int32_t dosCoordinate); 45 | 46 | const SavedGameInDosFormat& m_savedGameInDosFormat; 47 | const ISavedGameConverter& m_savedGameConverter; 48 | const std::map& m_decorateActors; 49 | }; 50 | -------------------------------------------------------------------------------- /src/Engine/ConsoleVariableEnum.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | #pragma once 16 | 17 | #include 18 | #include 19 | #include "ConsoleVariable.h" 20 | 21 | class ConsoleVariableEnum : public ConsoleVariable 22 | { 23 | public: 24 | typedef struct EnumItem 25 | { 26 | const std::string itemNameInMenu; 27 | const std::string itemNameInConfig; 28 | const std::string itemNameInConfigAlt; 29 | } EnumItem; 30 | 31 | ConsoleVariableEnum( 32 | const std::string& nameInMenu, 33 | const std::string& nameInConfigFile, 34 | const std::vector& items, 35 | const uint8_t defaultItemIndex); 36 | ~ConsoleVariableEnum(); 37 | 38 | const std::string Serialize() const override; 39 | void Deserialize(const std::string& str) override; 40 | void SetToDefault() override; 41 | 42 | uint8_t GetItemIndex() const; 43 | void SetItemIndex(const uint8_t index); 44 | void Next(); 45 | 46 | const std::string& GetValueInMenu() const; 47 | 48 | private: 49 | const std::vector m_items; 50 | uint8_t m_itemIndex; 51 | const uint8_t m_defaultItemIndex; 52 | }; 53 | -------------------------------------------------------------------------------- /src/Engine/GuiElementButton.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | #include "GuiElementButton.h" 17 | 18 | GuiElementButton::GuiElementButton( 19 | const PlayerInput& playerInput, 20 | const std::string& buttonLabel, 21 | const GuiEvent& guiEventWhenActivated, 22 | RenderableText& renderableText) : 23 | GuiElementBase(playerInput), 24 | m_buttonLabel(buttonLabel), 25 | m_guiEventWhenActivated(guiEventWhenActivated), 26 | m_renderableText(renderableText) 27 | { 28 | 29 | } 30 | 31 | GuiElementButton::~GuiElementButton() 32 | { 33 | 34 | } 35 | 36 | const GuiEvent& GuiElementButton::ProcessInput() 37 | { 38 | return (m_enabled && m_playerInput.IsKeyJustPressed(SDLK_RETURN)) ? m_guiEventWhenActivated : GetEvent(); 39 | } 40 | 41 | void GuiElementButton::Draw(IRenderer& renderer) const 42 | { 43 | m_renderableText.LeftAligned(m_buttonLabel, GetMenuItemColor(m_selected, m_enabled), m_originX, m_originY); 44 | } 45 | 46 | void GuiElementButton::SetLabel(const std::string& buttonLabel) 47 | { 48 | m_buttonLabel = buttonLabel; 49 | } 50 | 51 | const std::string& GuiElementButton::GetLabel() const 52 | { 53 | return m_buttonLabel; 54 | } -------------------------------------------------------------------------------- /src/Engine/GameTimer.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2018 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | // 17 | // GameTimer 18 | // 19 | // Keeps track of the time. Used for animations, movement, etc. 20 | // 21 | #pragma once 22 | 23 | #include 24 | #include 25 | 26 | class GameTimer 27 | { 28 | public: 29 | GameTimer(); 30 | ~GameTimer(); 31 | 32 | uint32_t GetMillisecondsForPlayer() const; 33 | uint32_t GetTicksForPlayer() const; 34 | uint32_t GetMilliSecondsForWorld(); 35 | uint32_t GetTicksForWorld(); 36 | uint32_t GetActualTime(); 37 | 38 | void Reset(); 39 | void Pause(); 40 | bool IsPaused() const; 41 | void Resume(); 42 | void FreezeTime(); 43 | uint32_t GetRemainingFreezeTime(); 44 | 45 | void StoreToFile(std::ofstream& file) const; 46 | bool LoadFromFile(std::ifstream& file); 47 | 48 | private: 49 | static uint32_t GetCurrentTime(); 50 | static constexpr uint32_t GetStandardFreezePeriod(); 51 | 52 | int64_t m_startTimeForPlayer; 53 | uint32_t m_pauseTime; 54 | uint32_t m_freezeStartTime; 55 | uint32_t m_totalFrozenTime; 56 | bool m_paused; 57 | }; 58 | -------------------------------------------------------------------------------- /src/Engine/Radar.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2018 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | // 17 | // Radar 18 | // 19 | // Visualizes the positions of nearby actors as small blips on the crystal ball. 20 | // 21 | #pragma once 22 | 23 | #include "EgaColor.h" 24 | #include 25 | #include "PlayerInventory.h" 26 | 27 | class Actor; 28 | 29 | typedef struct radarBlipStruct 30 | { 31 | float offsetX; 32 | float offsetY; 33 | egaColor color; 34 | } radarBlip; 35 | 36 | static const uint16_t MaxBlips = 60; 37 | 38 | class Radar 39 | { 40 | 41 | public: 42 | Radar(); 43 | ~Radar(); 44 | 45 | void ResetRadar(const Actor* player, const PlayerInventory& playerInventory, const uint32_t timeStamp); 46 | void AddActors(const Actor** actors, const uint16_t numberOfActors); 47 | radarBlip GetRadarBlip(const uint16_t index) const; 48 | uint16_t GetNumberOfBlips() const; 49 | 50 | private: 51 | radarBlip m_radarBlips[MaxBlips]; 52 | uint16_t m_numberOfBlips; 53 | float m_playerPosX; 54 | float m_playerPosY; 55 | float m_playerAngle; 56 | egaColor m_flickeringColor; 57 | bool m_gemPresent[5]; 58 | }; 59 | -------------------------------------------------------------------------------- /src/Engine/GuiElementList.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | #pragma once 16 | 17 | #include "GuiElementBase.h" 18 | #include "RenderableText.h" 19 | 20 | class GuiElementList : public GuiElementBase 21 | { 22 | public: 23 | GuiElementList( 24 | const PlayerInput& playerInput, 25 | const uint16_t maxElementsDrawn, 26 | const uint16_t elementHeight, 27 | const Picture* cursorPicture, 28 | const uint16_t soundWhenBrowsing); 29 | ~GuiElementList() override; 30 | 31 | virtual void AddChild(GuiElementBase* child, const int16_t offsetX = 0, const int16_t offsetY = 0, const int16_t parentId = 0) override; 32 | virtual const GuiEvent& ProcessInput() override; 33 | virtual void Draw(IRenderer& renderer) const override; 34 | virtual void SetEnabled(const bool enabled, const int16_t id = 0) override; 35 | 36 | private: 37 | std::vector m_elements; 38 | const uint16_t m_elementHeight; 39 | const uint16_t m_maxElementsDrawn; 40 | uint16_t m_elementSelected; 41 | uint16_t m_firstElementDrawn; 42 | const Picture* m_cursorPicture; 43 | const GuiEvent m_guiEventPlayBrowseSound; 44 | }; 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /src/Test/FramesCounter_Test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2018 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | #include "FramesCounter_Test.h" 17 | #include "../Engine/FramesCounter.h" 18 | 19 | FramesCounter_Test::FramesCounter_Test() 20 | { 21 | 22 | } 23 | 24 | FramesCounter_Test::~FramesCounter_Test() 25 | { 26 | 27 | } 28 | 29 | TEST(FramesCounter_Test, ZeroFpsWhenNoFramesAdded) 30 | { 31 | FramesCounter framesCounter; 32 | EXPECT_EQ(0, framesCounter.GetFramesPerSecond()); 33 | } 34 | 35 | TEST(FramesCounter_Test, ZeroFpsWhenNotASingleSecondHasPassed) 36 | { 37 | FramesCounter framesCounter; 38 | framesCounter.AddFrame(1000); 39 | framesCounter.AddFrame(1999); 40 | EXPECT_EQ(0, framesCounter.GetFramesPerSecond()); 41 | } 42 | 43 | TEST(FramesCounter_Test, TwoFpsWhenTwoFramesAddedInPastSecond) 44 | { 45 | FramesCounter framesCounter; 46 | framesCounter.AddFrame(2000); // Counter started and 1 frame added 47 | framesCounter.AddFrame(2500); // 2 frames added 48 | framesCounter.AddFrame(3000); // One second has passed; counter reset and number of frames stored from past second 49 | EXPECT_EQ(2, framesCounter.GetFramesPerSecond()); 50 | } 51 | 52 | -------------------------------------------------------------------------------- /src/Apocalypse/IntroViewApocalypse.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | // 17 | // IntroViewApocalypse 18 | // 19 | // Introduction screens for the Catacomb Apocalypse 20 | // 21 | #pragma once 22 | 23 | #include "../Engine/IIntroView.h" 24 | #include "../Engine/Shape.h" 25 | #include 26 | #include 27 | 28 | class IntroViewApocalypse : public IIntroView 29 | { 30 | public: 31 | IntroViewApocalypse(IRenderer& renderer, const std::filesystem::path& path); 32 | ~IntroViewApocalypse(); 33 | void DrawIntroduction(const uint32_t timeStamp); 34 | void DrawRequestDifficultyLevel(); 35 | void DrawNoviceSelected(); 36 | void DrawWarriorSelected(); 37 | void DrawStandBeforeGate(); 38 | 39 | private: 40 | Shape* m_shapeEntering; 41 | Shape* m_shapePresents; 42 | Shape* m_shapeSoftdisk; 43 | Shape* m_shapeTitle; 44 | Shape* m_shapeCreditsProgramming; 45 | Shape* m_shapeCreditsArt; 46 | Shape* m_shapeCreditsQA; 47 | Shape* m_shapeCreditsDesign; 48 | Shape* m_shapeSelectDifficulty; 49 | Shape* m_shapeConfirmDifficulty; 50 | Shape* m_shapeNovice; 51 | Shape* m_shapeWarrior; 52 | Shape* m_shapeStandBeforeGate; 53 | }; 54 | 55 | -------------------------------------------------------------------------------- /src/Engine/SpriteTable.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2018 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | // 17 | // SpriteTable 18 | // 19 | // Table with the properties of a number of sprites, as read from a chunk of the EGAGRAPH repository file. 20 | // 21 | #pragma once 22 | 23 | #include "FileChunk.h" 24 | 25 | class SpriteTable 26 | { 27 | public: 28 | SpriteTable(FileChunk* decompressedChunk); 29 | ~SpriteTable(); 30 | 31 | uint16_t GetWidth(const uint16_t index); 32 | uint16_t GetHeight(const uint16_t index); 33 | uint16_t GetOffsetX(const uint16_t index); 34 | uint16_t GetOffsetY(const uint16_t index); 35 | uint16_t GetClippingLeft(const uint16_t index); 36 | uint16_t GetClippingTop(const uint16_t index); 37 | uint16_t GetClippingRight(const uint16_t index); 38 | uint16_t GetClippingBottom(const uint16_t index); 39 | uint16_t GetCount(); 40 | 41 | private: 42 | uint16_t* m_width; 43 | uint16_t* m_height; 44 | uint16_t* m_offsetX; 45 | uint16_t* m_offsetY; 46 | uint16_t* m_clippingLeft; 47 | uint16_t* m_clippingTop; 48 | uint16_t* m_clippingRight; 49 | uint16_t* m_clippingBottom; 50 | uint16_t m_count; 51 | }; 52 | 53 | -------------------------------------------------------------------------------- /src/Engine/GameSelection.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | #pragma once 16 | 17 | #include "IRenderer.h" 18 | #include 19 | #include 20 | #include 21 | 22 | enum GameDetectionState 23 | { 24 | Detected, 25 | NotDetected, 26 | NotSupported 27 | }; 28 | 29 | struct GameSelectionPresentation 30 | { 31 | std::vector> gameListCatacombsPack; 32 | std::vector> gameListShareware; 33 | std::vector> gameListCatacomb3DBigBox; 34 | std::filesystem::path searchFolder; 35 | std::vector subFolders; 36 | uint32_t selectedSubFolder = 0u; 37 | uint32_t subFolderOffset = 0u; 38 | }; 39 | 40 | class GameSelection 41 | { 42 | public: 43 | GameSelection(IRenderer& renderer); 44 | ~GameSelection(); 45 | 46 | void Draw(const GameSelectionPresentation& presentation); 47 | 48 | private: 49 | void DrawBox(const uint16_t x, const uint16_t y, const uint16_t width, const uint16_t height, const std::string& title, RenderableText& renderableText); 50 | 51 | IRenderer& m_renderer; 52 | }; 53 | -------------------------------------------------------------------------------- /src/Armageddon/IntroViewArmageddon.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2018 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | // 17 | // IntroViewArmageddon 18 | // 19 | // Introduction screens for the Catacomb Armageddon 20 | // 21 | #pragma once 22 | 23 | #include "../Engine/IIntroView.h" 24 | #include "../Engine/Shape.h" 25 | #include 26 | #include 27 | 28 | class IntroViewArmageddon : public IIntroView 29 | { 30 | public: 31 | IntroViewArmageddon(IRenderer& renderer, const std::filesystem::path& path); 32 | ~IntroViewArmageddon(); 33 | void DrawIntroduction(const uint32_t timeStamp); 34 | void DrawRequestDifficultyLevel(); 35 | void DrawNoviceSelected(); 36 | void DrawWarriorSelected(); 37 | void DrawStandBeforeGate(); 38 | void DrawCatalog(); 39 | bool IsCatalogAvailable(); 40 | 41 | private: 42 | Shape* m_shapeEntering; 43 | Shape* m_shapePresents; 44 | Shape* m_shapeSoftdisk; 45 | Shape* m_shapeTitle; 46 | Shape* m_shapeCreditsProgramming; 47 | Shape* m_shapeCreditsArt; 48 | Shape* m_shapeCreditsQA; 49 | Shape* m_shapeCreditsDesign; 50 | Shape* m_shapeSelectDifficulty; 51 | Shape* m_shapeConfirmDifficulty; 52 | Shape* m_shapeNovice; 53 | Shape* m_shapeWarrior; 54 | Shape* m_shapeStandBeforeGate; 55 | }; 56 | -------------------------------------------------------------------------------- /src/Engine/Macros.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | // Should already be defined in MSVC 16 | 17 | // 18 | // Macros 19 | // 20 | // PreProcessor macros and definitions. 21 | // 22 | #pragma once 23 | 24 | 25 | // Calling conventions are operating system dependent 26 | // thus __stdcall is not defined outside of a Windows environment. 27 | // MSVC defines the CALLBACK macro for this purpose so we define it for mingw 28 | // and non-windows compilers. 29 | 30 | #ifndef CALLBACK 31 | #ifdef _WIN32 32 | #define CALLBACK __stdcall 33 | #else 34 | #define CALLBACK 35 | #endif 36 | #endif 37 | 38 | 39 | // There is no case insensitive comparison function in the C/C++ standards. 40 | // Microsoft and POSIX independently specify such a function tho. 41 | // These functions however have different names but luckily have the same arguments 42 | // so that the name can be inserted via a preprocessor variable. 43 | 44 | // MS compiler 45 | #if defined (_WIN32) 46 | #define STR_CASE_CMP _strcmpi 47 | // POSIX compliant compiler 48 | #elif defined (__unix__) || (defined (__APPLE__) && defined (__MACH__)) 49 | #define STR_CASE_CMP strcasecmp 50 | // This should cover all relevant compilers 51 | // If a compiler is not covered please add an appropriate function here 52 | #endif 53 | 54 | -------------------------------------------------------------------------------- /src/Engine/OverscanBorder.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | #include "OverscanBorder.h" 17 | 18 | OverscanBorder::OverscanBorder() : 19 | m_color(EgaBlack), 20 | m_timeStampWhenColorIsExpired(0) 21 | { 22 | 23 | } 24 | 25 | OverscanBorder::~OverscanBorder() 26 | { 27 | 28 | } 29 | 30 | void OverscanBorder::SetColor(const uint32_t timeStamp, const uint8_t egaSignal, const uint32_t durationInMs) 31 | { 32 | m_color = ConvertEgaSignalToEgaColor(egaSignal); 33 | m_timeStampWhenColorIsExpired = timeStamp + durationInMs; 34 | } 35 | 36 | egaColor OverscanBorder::GetActiveColor(const uint32_t timeStamp) const 37 | { 38 | return (timeStamp > m_timeStampWhenColorIsExpired) ? EgaBlack : m_color; 39 | } 40 | 41 | const uint16_t OverscanBorder::GetBorderWidth() 42 | { 43 | return 4u; 44 | } 45 | 46 | const uint16_t OverscanBorder::GetBorderHeight() 47 | { 48 | return 3u; 49 | } 50 | 51 | // This function is taken from BEL_ST_ConvertEGASignalToEGAEntry in Reflection Keen. 52 | // It gets a value representing a 6 bit EGA signal and converts it into the 53 | // regular "Blue Green Red Intensity" 4 bit format. 54 | egaColor OverscanBorder::ConvertEgaSignalToEgaColor(const uint8_t egaSignal) 55 | { 56 | return (egaColor)((egaSignal & 7) | ((egaSignal & 16) >> 1)); 57 | } -------------------------------------------------------------------------------- /src/Engine/AudioRepository.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2018 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | #pragma once 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include "Huffman.h" 22 | #include "Logging.h" 23 | 24 | class AdlibSound; 25 | class PCSound; 26 | 27 | typedef struct audioRepositoryStaticData 28 | { 29 | const std::string filename; 30 | const std::vector& offsets; 31 | const huffmanTable& table; 32 | const int32_t lastSound; 33 | const bool musicShouldNotInterfereWithFirstChannel; 34 | } audioRepositoryStaticData; 35 | 36 | class AudioRepository 37 | { 38 | public: 39 | AudioRepository(const audioRepositoryStaticData& staticData, const std::filesystem::path& path); 40 | ~AudioRepository(); 41 | 42 | PCSound* GetPCSound(const uint16_t index); 43 | AdlibSound* GetAdlibSound(const uint16_t index); 44 | FileChunk* GetMusicTrack(const uint16_t index); 45 | 46 | private: 47 | uint32_t GetChunkSize(const uint16_t index); 48 | 49 | const audioRepositoryStaticData& m_staticData; 50 | 51 | FileChunk* m_rawData; 52 | PCSound** m_pcSounds; 53 | AdlibSound** m_adlibSounds; 54 | FileChunk** m_musicTracks; 55 | Huffman* m_huffman; 56 | }; 57 | 58 | -------------------------------------------------------------------------------- /src/System/OpenGLUtilityLocal.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2024 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | // 16 | // OpenGLUtilityLocal 17 | // 18 | // Local implementation of three functions from the OpenGL Utility Library (GLU). 19 | // This prevents a dependency on the actual GLU library. 20 | #pragma once 21 | 22 | #ifdef _WIN32 23 | #include 24 | #endif 25 | 26 | #ifdef __APPLE__ 27 | #include 28 | #else 29 | #include 30 | #endif 31 | 32 | class OpenGLUtilityLocal 33 | { 34 | public: 35 | OpenGLUtilityLocal() = default; 36 | ~OpenGLUtilityLocal() = default; 37 | 38 | static void gluPerspective(GLdouble fovY, GLdouble aspect, GLdouble zNear, GLdouble zFar); 39 | static void gluOrtho2D(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top); 40 | static void gluLookAt( 41 | GLdouble eyeX, GLdouble eyeY, GLdouble eyeZ, 42 | GLdouble centerX, GLdouble centerY, GLdouble centerZ, 43 | GLdouble upX, GLdouble upY, GLdouble upZ); 44 | 45 | private: 46 | static void crossProduct( 47 | GLdouble vecAx, GLdouble vecAy, GLdouble vecAz, 48 | GLdouble vecBx, GLdouble vecBy, GLdouble vecBz, 49 | GLdouble& vecPx, GLdouble& vecPy, GLdouble& vecPz); 50 | static void normalize(GLdouble& vecx, GLdouble& vecy, GLdouble& vecz); 51 | }; 52 | 53 | -------------------------------------------------------------------------------- /src/System/Finder.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | #include "../Engine/ConfigurationSettings.h" 17 | #include "../Engine/GameDetection.h" 18 | #include "../Engine/GameId.h" 19 | 20 | #include "../Abyss/GameDetectionAbyss.h" 21 | #include "../Armageddon/GameDetectionArmageddon.h" 22 | #include "../Apocalypse/GameDetectionApocalypse.h" 23 | #include "../Catacomb3D/GameDetectionCatacomb3D.h" 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | class Finder 33 | { 34 | public: 35 | Finder() = default; 36 | Finder(const ConfigurationSettings& config); 37 | 38 | void FindGamesInWorkingPath(); 39 | void FindInPath(const std::filesystem::path& path); 40 | void FindGOGPack(); 41 | void LoadPaths(const ConfigurationSettings& config); 42 | void SafePaths(ConfigurationSettings& config); 43 | 44 | const GameDetection GetGameDetector(GameId Id) const; 45 | const DetectionReport GetGameReport(GameId Id) const; 46 | const std::string GetGameName(GameId Id) const; 47 | uint16_t GetGameScore(GameId Id) const; 48 | const std::filesystem::path GetGameFolder(GameId Id) const; 49 | 50 | private: 51 | std::map m_detector; 52 | 53 | }; 54 | 55 | -------------------------------------------------------------------------------- /src/Engine/Renderable3DTiles.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2020 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | #include "Renderable3DTiles.h" 17 | 18 | Renderable3DTiles::Renderable3DTiles() : 19 | m_floorColor(EgaBlack), 20 | m_ceilingColor(EgaBlack), 21 | m_onlyFloor(false) 22 | { 23 | m_tileCoordinates.clear(); 24 | } 25 | 26 | void Renderable3DTiles::AddTile(const tileCoordinate coordinate) 27 | { 28 | m_tileCoordinates.push_back(coordinate); 29 | } 30 | 31 | egaColor Renderable3DTiles::GetFloorColor() const 32 | { 33 | return m_floorColor; 34 | } 35 | 36 | egaColor Renderable3DTiles::GetCeilingColor() const 37 | { 38 | return m_ceilingColor; 39 | } 40 | 41 | void Renderable3DTiles::SetFloorColor(const egaColor color) 42 | { 43 | m_floorColor = color; 44 | } 45 | 46 | void Renderable3DTiles::SetCeilingColor(const egaColor color) 47 | { 48 | m_ceilingColor = color; 49 | } 50 | 51 | bool Renderable3DTiles::IsOnlyFloor() const 52 | { 53 | return m_onlyFloor; 54 | } 55 | 56 | void Renderable3DTiles::SetOnlyFloor(const bool isOnlyFloor) 57 | { 58 | m_onlyFloor = isOnlyFloor; 59 | } 60 | 61 | const std::vector& Renderable3DTiles::GetTileCoordinates() const 62 | { 63 | return m_tileCoordinates; 64 | } 65 | 66 | void Renderable3DTiles::Reset() 67 | { 68 | m_tileCoordinates.clear(); 69 | } -------------------------------------------------------------------------------- /src/Test/LevelLocationNames_Test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2018 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | #include "LevelLocationNames_Test.h" 17 | #include "../Engine/LevelLocationNames.h" 18 | 19 | LevelLocationNames_Test::LevelLocationNames_Test() 20 | { 21 | 22 | } 23 | 24 | LevelLocationNames_Test::~LevelLocationNames_Test() 25 | { 26 | 27 | } 28 | 29 | TEST(LevelLocationNames_Test, EmptyChunk) 30 | { 31 | FileChunk fileChunk(0); 32 | LevelLocationNames levelLocationNames(&fileChunk); 33 | EXPECT_STREQ("", levelLocationNames.GetLocationName(0).c_str()); 34 | } 35 | 36 | TEST(LevelLocationNames_Test, MultipleLines) 37 | { 38 | const char* names = "\r\nCemetery\r\n\r\nGarden\r\n"; 39 | const uint32_t namesSize = (uint32_t)strlen(names); 40 | FileChunk fileChunk(namesSize); 41 | memcpy(fileChunk.GetChunk(), (void*)names, namesSize); 42 | LevelLocationNames levelLocationNames(&fileChunk); 43 | EXPECT_STREQ("", levelLocationNames.GetLocationName(0).c_str()); 44 | EXPECT_STREQ("Cemetery", levelLocationNames.GetLocationName(1).c_str()); 45 | EXPECT_STREQ("", levelLocationNames.GetLocationName(2).c_str()); 46 | EXPECT_STREQ("Garden", levelLocationNames.GetLocationName(3).c_str()); 47 | EXPECT_STREQ("", levelLocationNames.GetLocationName(4).c_str()); 48 | } 49 | 50 | -------------------------------------------------------------------------------- /src/Engine/PictureTable.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2018 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | #include "PictureTable.h" 17 | 18 | PictureTable::PictureTable(FileChunk* decompressedChunk) : 19 | m_count(0), 20 | m_width(nullptr), 21 | m_height(nullptr) 22 | { 23 | m_count = (uint16_t)decompressedChunk->GetSize() / 4; 24 | 25 | if (m_count > 0) 26 | { 27 | m_width = new uint16_t[m_count]; 28 | m_height = new uint16_t[m_count]; 29 | uint8_t* chunk = decompressedChunk->GetChunk(); 30 | for (uint16_t i = 0; i < m_count; i++) 31 | { 32 | m_width[i] = *(uint16_t*)&chunk[i * 4] * 8; 33 | m_height[i] = *(uint16_t*)&chunk[(i * 4) + 2]; 34 | } 35 | } 36 | } 37 | 38 | PictureTable::~PictureTable() 39 | { 40 | delete[] m_width; 41 | delete[] m_height; 42 | } 43 | 44 | uint16_t PictureTable::GetWidth(const uint16_t index) 45 | { 46 | if (index < m_count) 47 | { 48 | return m_width[index]; 49 | } 50 | 51 | return 0; 52 | } 53 | 54 | uint16_t PictureTable::GetHeight(const uint16_t index) 55 | { 56 | if (index < m_count) 57 | { 58 | return m_height[index]; 59 | } 60 | 61 | return 0; 62 | } 63 | 64 | uint16_t PictureTable::GetCount() 65 | { 66 | return m_count; 67 | } -------------------------------------------------------------------------------- /src/Engine/Picture.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2018 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | #include "Picture.h" 17 | 18 | Picture::Picture(const unsigned int textureId, const uint16_t imageWidth, const uint16_t imageHeight, const uint16_t textureWidth, const uint16_t textureHeight) : 19 | m_textureId(textureId), 20 | m_imageWidth(imageWidth), 21 | m_imageHeight(imageHeight), 22 | m_textureWidth(textureWidth), 23 | m_textureHeight(textureHeight) 24 | { 25 | } 26 | 27 | Picture::~Picture() 28 | { 29 | 30 | } 31 | 32 | unsigned int Picture::GetTextureId() const 33 | { 34 | return m_textureId; 35 | } 36 | 37 | uint16_t Picture::GetImageWidth() const 38 | { 39 | return m_imageWidth; 40 | } 41 | 42 | uint16_t Picture::GetImageHeight() const 43 | { 44 | return m_imageHeight; 45 | } 46 | 47 | uint16_t Picture::GetTextureWidth() const 48 | { 49 | return m_textureWidth; 50 | } 51 | 52 | uint16_t Picture::GetTextureHeight() const 53 | { 54 | return m_textureHeight; 55 | } 56 | 57 | uint16_t Picture::GetNearestPowerOfTwo(const uint16_t size) 58 | { 59 | // In order to support OpenGL 1.4, the texture width and height need to be a power of two. 60 | uint16_t powerOfTwo = 1; 61 | while (powerOfTwo < size) 62 | { 63 | powerOfTwo *= 2; 64 | } 65 | 66 | return powerOfTwo; 67 | } -------------------------------------------------------------------------------- /src/Catacomb3D/SavedGameConverterCatacomb3D.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2022 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | // 17 | // SavedGameConverterCatacomb3D 18 | // 19 | // Conversion of saved games from DOS format to CatacombGL; specifically for Catacomb 3-D 20 | // 21 | #pragma once 22 | 23 | #include "../Engine/ISavedGameConverter.h" 24 | #include "../Engine/GameId.h" 25 | 26 | class SavedGameConverterCatacomb3D : public ISavedGameConverter 27 | { 28 | public: 29 | SavedGameConverterCatacomb3D(const GameId gameId); 30 | ~SavedGameConverterCatacomb3D(); 31 | const uint16_t GetActorId(const SavedGameInDosFormat::ObjectInDosFormat& dosObject) const override; 32 | const DecorateStateId GetDecorateStateId(const SavedGameInDosFormat::ObjectInDosFormat& dosObject) const override; 33 | const uint16_t GetAnimationFrame(const SavedGameInDosFormat::ObjectInDosFormat& dosObject) const override; 34 | const bool IsInertObject(const uint16_t obclass) const override; 35 | void SetFarPointerOffset(const uint32_t playerState32) override; 36 | private: 37 | const uint16_t GetActorIdOfBonus(const uint16_t state16, const int16_t temp1) const; 38 | const uint16_t GetActorIdOfGate(const uint16_t state16, const int16_t temp1) const; 39 | const uint16_t GetActorIdOfInert(const uint16_t state16) const; 40 | const uint8_t GetGameIndex() const; 41 | 42 | const GameId m_gameId; 43 | }; 44 | 45 | -------------------------------------------------------------------------------- /src/Engine/AudioPlayer.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2018 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | #include "AudioPlayer.h" 17 | #include 18 | #include "../../ThirdParty/ReflectionHLE/id_sd.h" 19 | 20 | AudioPlayer::AudioPlayer(AudioRepository* audioRepository) : 21 | m_audioRepository(audioRepository) 22 | { 23 | 24 | } 25 | 26 | AudioPlayer::~AudioPlayer() 27 | { 28 | 29 | } 30 | 31 | void AudioPlayer::Play(const uint16_t index) 32 | { 33 | if (SD_GetSoundMode() == sdm_AdLib) 34 | { 35 | AdlibSound* sound = m_audioRepository->GetAdlibSound(index); 36 | if (sound != nullptr) 37 | { 38 | SDL_ALPlaySound(sound); 39 | } 40 | } 41 | else if (SD_GetSoundMode() == sdm_PC) 42 | { 43 | PCSound* sound = m_audioRepository->GetPCSound(index); 44 | if (sound != nullptr) 45 | { 46 | SDL_PCPlaySound(sound); 47 | } 48 | } 49 | } 50 | 51 | void AudioPlayer::StartMusic(const uint16_t index) 52 | { 53 | FileChunk* musicTrack = m_audioRepository->GetMusicTrack(index); 54 | if (musicTrack != nullptr) 55 | { 56 | SD_StartMusic(musicTrack); 57 | } 58 | } 59 | 60 | void AudioPlayer::StopMusic() 61 | { 62 | SD_MusicOff(); 63 | } 64 | 65 | bool AudioPlayer::IsPlaying() 66 | { 67 | return SD_SoundPlaying(); 68 | } -------------------------------------------------------------------------------- /src/Engine/GuiElementBoolSelection.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | #include "GuiElementBoolSelection.h" 17 | 18 | GuiElementBoolSelection::GuiElementBoolSelection( 19 | const PlayerInput& playerInput, 20 | ConsoleVariableBool& cvarBool, 21 | const int16_t offsetXValue, 22 | RenderableText& renderableText) : 23 | GuiElementBase(playerInput), 24 | m_cvarBool(cvarBool), 25 | m_offsetXValue(offsetXValue), 26 | m_renderableText(renderableText) 27 | { 28 | 29 | } 30 | 31 | GuiElementBoolSelection::~GuiElementBoolSelection() 32 | { 33 | 34 | } 35 | 36 | const GuiEvent& GuiElementBoolSelection::ProcessInput() 37 | { 38 | if (m_enabled && m_playerInput.IsKeyJustPressed(SDLK_RETURN)) 39 | { 40 | m_cvarBool.Toggle(); 41 | } 42 | 43 | return GetEvent(); 44 | } 45 | 46 | void GuiElementBoolSelection::Draw(IRenderer& /*renderer*/) const 47 | { 48 | const egaColor color = GetMenuItemColor(m_selected, m_enabled); 49 | m_renderableText.LeftAligned(m_cvarBool.GetNameInMenu(), color, m_originX, m_originY); 50 | const std::string& valueStr = (!m_enabled) ? "Not supported" : m_cvarBool.GetValueInMenu(); 51 | m_renderableText.LeftAligned(valueStr, color, m_originX + m_offsetXValue, m_originY); 52 | } 53 | 54 | const std::string& GuiElementBoolSelection::GetLabel() const 55 | { 56 | return m_cvarBool.GetNameInMenu(); 57 | } -------------------------------------------------------------------------------- /src/Engine/GuiElementEnumSelection.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | #include "GuiElementEnumSelection.h" 17 | 18 | GuiElementEnumSelection::GuiElementEnumSelection( 19 | const PlayerInput& playerInput, 20 | ConsoleVariableEnum& cvarEnum, 21 | const int16_t offsetXValue, 22 | RenderableText& renderableText) : 23 | GuiElementBase(playerInput), 24 | m_cvarEnum(cvarEnum), 25 | m_offsetXValue(offsetXValue), 26 | m_renderableText(renderableText) 27 | { 28 | 29 | } 30 | 31 | GuiElementEnumSelection::~GuiElementEnumSelection() 32 | { 33 | 34 | } 35 | 36 | const GuiEvent& GuiElementEnumSelection::ProcessInput() 37 | { 38 | if (m_enabled && m_playerInput.IsKeyJustPressed(SDLK_RETURN)) 39 | { 40 | m_cvarEnum.Next(); 41 | } 42 | 43 | return GetEvent(); 44 | } 45 | 46 | void GuiElementEnumSelection::Draw(IRenderer& /*renderer*/) const 47 | { 48 | const egaColor color = GetMenuItemColor(m_selected, m_enabled); 49 | m_renderableText.LeftAligned(m_cvarEnum.GetNameInMenu(), color, m_originX, m_originY); 50 | const std::string& valueStr = (!m_enabled) ? "Not supported" : m_cvarEnum.GetValueInMenu(); 51 | m_renderableText.LeftAligned(valueStr, color, m_originX + m_offsetXValue, m_originY); 52 | } 53 | 54 | const std::string& GuiElementEnumSelection::GetLabel() const 55 | { 56 | return m_cvarEnum.GetNameInMenu(); 57 | } -------------------------------------------------------------------------------- /src/Engine/Score.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | #include "Score.h" 17 | 18 | Score::Score() : 19 | m_points(0), 20 | m_pointsToAdd(0), 21 | m_pointsAddedTimestamp(0) 22 | { 23 | 24 | } 25 | 26 | Score::~Score() 27 | { 28 | 29 | } 30 | 31 | const uint32_t Score::GetPoints() const 32 | { 33 | return m_points; 34 | } 35 | 36 | void Score::SetPoints(const uint32_t points) 37 | { 38 | m_points = points; 39 | m_pointsToAdd = 0; 40 | m_pointsAddedTimestamp = 0; 41 | } 42 | 43 | void Score::AddPoints(const uint32_t points) 44 | { 45 | m_pointsToAdd += points; 46 | } 47 | 48 | bool Score::Update(const uint32_t timestamp) 49 | { 50 | if (m_pointsToAdd > 0 && timestamp - m_pointsAddedTimestamp > 100) 51 | { 52 | const int32_t addedPoints = 53 | (m_pointsToAdd > 1000) ? 1000 : 54 | (m_pointsToAdd > 100) ? 100 : 55 | (m_pointsToAdd < 20) ? m_pointsToAdd : 20; 56 | m_points += addedPoints; 57 | m_pointsToAdd -= addedPoints; 58 | m_pointsAddedTimestamp = timestamp; 59 | return true; 60 | } 61 | 62 | return false; 63 | } 64 | 65 | void Score::UpdateAll() 66 | { 67 | m_points += m_pointsToAdd; 68 | m_pointsToAdd = 0; 69 | } 70 | 71 | void Score::Reset() 72 | { 73 | m_points = 0; 74 | m_pointsToAdd = 0; 75 | m_pointsAddedTimestamp = 0; 76 | } 77 | -------------------------------------------------------------------------------- /ThirdParty/ReflectionHLE/backend/timing/be_timing.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2014-2024 NY00123 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions 5 | * are met: 6 | * 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 3. Neither the name of the copyright holder nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 21 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 22 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 23 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 26 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef BE_TIMING_H 30 | #define BE_TIMING_H 31 | 32 | #include "refkeen_config.h" 33 | 34 | // Replacement for int 8 timer callback 35 | extern void (*g_sdlTimerIntFuncPtr)(void); 36 | 37 | int BE_ST_SET_TIMER_INT_COUNTER_SET(int x); 38 | int BE_ST_SET_TIMER_INT_COUNTER_GET(void); 39 | int BE_ST_SET_TIMER_INT_COUNTER_ADD(int x); 40 | int BE_ST_SET_TIMER_INT_COUNTER_INC(void); 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /src/Engine/ConsoleVariableBool.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2021 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | #include "ConsoleVariableBool.h" 17 | 18 | static const std::string enabledStr = "Enabled"; 19 | static const std::string disabledStr = "Disabled"; 20 | 21 | ConsoleVariableBool::ConsoleVariableBool(const std::string& nameInMenu, const std::string& nameInConfigFile, const bool defaultValue) : 22 | ConsoleVariable(nameInMenu, nameInConfigFile), 23 | m_enabled(defaultValue), 24 | m_defaultValue(defaultValue) 25 | { 26 | 27 | } 28 | 29 | ConsoleVariableBool::~ConsoleVariableBool() 30 | { 31 | 32 | } 33 | 34 | const std::string ConsoleVariableBool::Serialize() const 35 | { 36 | return (m_enabled) ? "Enabled" : "Disabled"; 37 | } 38 | 39 | void ConsoleVariableBool::Deserialize(const std::string& str) 40 | { 41 | m_enabled = (str.compare("true") == 0) || (str.compare("Enabled") == 0); 42 | } 43 | 44 | bool ConsoleVariableBool::IsEnabled() const 45 | { 46 | return m_enabled; 47 | } 48 | 49 | void ConsoleVariableBool::SetEnabled(bool enabled) 50 | { 51 | m_enabled = enabled; 52 | } 53 | 54 | void ConsoleVariableBool::Toggle() 55 | { 56 | m_enabled = !m_enabled; 57 | } 58 | 59 | const std::string& ConsoleVariableBool::GetValueInMenu() const 60 | { 61 | return (m_enabled) ? enabledStr : disabledStr; 62 | } 63 | 64 | void ConsoleVariableBool::SetToDefault() 65 | { 66 | m_enabled = m_defaultValue; 67 | } -------------------------------------------------------------------------------- /src/Engine/HighScores.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2019 Arno Ansems 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see http://www.gnu.org/licenses/ 15 | 16 | // 17 | // Score 18 | // 19 | // Keeps track of the high score list for Catacomb 3D 20 | // 21 | #pragma once 22 | 23 | #include 24 | #include 25 | #include 26 | #include "../Engine/IRenderer.h" 27 | #include "../Engine/EgaGraph.h" 28 | 29 | class HighScores 30 | { 31 | public: 32 | struct HighScore 33 | { 34 | std::string name; 35 | uint32_t score; 36 | uint16_t level; 37 | }; 38 | 39 | HighScores(); 40 | ~HighScores(); 41 | 42 | const std::vector& Get() const; 43 | bool LoadFromFile(const std::filesystem::path& path); 44 | bool StoreToFile(const std::filesystem::path& path); 45 | void LoadGraphics(EgaGraph& egaGraph, const uint16_t backgroundPic); 46 | bool TryToAddNewScore(const uint32_t newScore, const uint16_t newLevel); 47 | void AddCharactersToNameOfNewScore(const std::string& characters); 48 | void RemoveACharacterFromNameOfNewScore(); 49 | void FinishNameOfNewScore(); 50 | void Draw(IRenderer& renderer, const uint32_t timeStamp) const; 51 | 52 | private: 53 | static void ApplyEqualSpacingToNumbers(std::string& str); 54 | 55 | std::vector m_highscores; 56 | char m_remainingConfigData[20]; 57 | uint8_t m_newScorePosition; 58 | Picture* m_backgroundPicture; 59 | Font* m_font; 60 | }; 61 | --------------------------------------------------------------------------------