├── .gitattributes ├── .github └── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── .gitignore ├── .gitmodules ├── .travis.yml ├── BUGS.md ├── CMakeLists.txt ├── CONTRIBUTING.md ├── COPYING ├── COPYING.BSD.txt ├── COPYING.LGPLv2.1.txt ├── COPYING.MIT.txt ├── COPYING.ZLIB.txt ├── IDEAS.md ├── INSTALL.md ├── Projects ├── OpenFodder.aps ├── OpenFodder.rc ├── VS2015 │ ├── OpenFodder.sln │ ├── OpenFodder.vcxproj │ ├── OpenFodder.vcxproj.filters │ ├── OpenFodder.vcxproj.user │ ├── gitver.cmd │ └── packages.config ├── VS2017 │ ├── OpenFodder.sln │ ├── OpenFodder.vcxproj │ ├── OpenFodder.vcxproj.filters │ ├── OpenFodder.vcxproj.user │ ├── gitver.cmd │ ├── openfodder.ini │ └── packages.config ├── WinInstaller │ ├── installer.nsi │ └── openfodder.ini ├── emscripten │ ├── build_emscripten.cmd │ ├── httpd.conf │ └── openfodder.ini ├── openfodder.ico └── resource.h ├── README.OPENFODDER.md ├── README.md ├── Source ├── .gitignore ├── About.cpp ├── About.hpp ├── Amiga │ ├── Graphics_Amiga.cpp │ ├── Graphics_Amiga.hpp │ ├── Graphics_Amiga2.cpp │ ├── Graphics_Amiga2.hpp │ ├── IntroData_Amiga.cpp │ ├── Resource_Amiga_File.cpp │ ├── Resource_Amiga_File.hpp │ ├── Sound_Amiga.cpp │ ├── Sound_Amiga.hpp │ ├── SpriteData_Amiga.hpp │ ├── audiostream.hpp │ ├── dernc.cpp │ ├── dernc.hpp │ ├── paula.cpp │ ├── paula.hpp │ ├── rjp1.cpp │ └── rjp1.hpp ├── Campaign.cpp ├── Campaign.hpp ├── CopyProtection.cpp ├── CopyProtection.hpp ├── Debugger.cpp ├── Debugger.hpp ├── Dimension.hpp ├── Event.cpp ├── Event.hpp ├── Fodder.cpp ├── Fodder.hpp ├── FontData.cpp ├── FontData.hpp ├── GUI_Element.cpp ├── GUI_Element.hpp ├── GameData.cpp ├── GameData.hpp ├── Graphics.cpp ├── Graphics.hpp ├── IntroData.hpp ├── Map │ ├── Map.cpp │ ├── Map.hpp │ ├── Original.cpp │ ├── Original.hpp │ ├── Random.cpp │ └── Random.hpp ├── MapData.cpp ├── PC │ ├── Graphics_PC.cpp │ ├── Graphics_PC.hpp │ ├── IntroData_PC.cpp │ ├── Resource_PC_CD.cpp │ ├── Resource_PC_CD.hpp │ ├── Sound_PC.cpp │ ├── Sound_PC.hpp │ ├── Sound_PC2.cpp │ ├── Sound_PC2.hpp │ ├── SpriteData_PC.hpp │ └── VocTable.hpp ├── Parameters.cpp ├── Parameters.hpp ├── Position.hpp ├── Recruits.cpp ├── Recruits.hpp ├── ResourceMan.cpp ├── ResourceMan.hpp ├── Resources.cpp ├── Resources.hpp ├── ScriptingEngine.cpp ├── ScriptingEngine.hpp ├── Sound.cpp ├── Sound.hpp ├── SpriteSheet.cpp ├── SpriteSheet.hpp ├── Sprites.cpp ├── Sprites.hpp ├── Start.cpp ├── Start_Emscripten.cpp ├── Structures │ ├── Barracks.cpp │ └── Barracks.hpp ├── Surface.cpp ├── Surface.hpp ├── Tiles.cpp ├── Tiles.hpp ├── Types.hpp ├── UnitTesting.cpp ├── UnitTesting.hpp ├── Utils │ ├── SimplexIslands.cpp │ ├── SimplexIslands.hpp │ ├── SimplexNoise.cpp │ ├── SimplexNoise.hpp │ ├── cxxopts.hpp │ ├── diamondsquare.hpp │ ├── duk_config.h │ ├── duk_trans_socket.h │ ├── duk_trans_socket_unix.c │ ├── duk_trans_socket_windows.cpp │ ├── dukglue │ │ ├── detail_class_proto.h │ │ ├── detail_constructor.h │ │ ├── detail_function.h │ │ ├── detail_method.h │ │ ├── detail_primitive_types.h │ │ ├── detail_refs.h │ │ ├── detail_stack.h │ │ ├── detail_traits.h │ │ ├── detail_typeinfo.h │ │ ├── detail_types.h │ │ ├── dukexception.h │ │ ├── dukglue.h │ │ ├── dukvalue.h │ │ ├── public_util.h │ │ ├── register_class.h │ │ ├── register_function.h │ │ └── register_property.h │ ├── duktape.cpp │ ├── duktape.h │ ├── ini.hpp │ ├── json.hpp │ ├── md5.cpp │ ├── md5.hpp │ ├── micropather.cpp │ ├── micropather.h │ ├── pseudorand.hpp │ ├── scandir.cpp │ └── scandir.hpp ├── Version.hpp ├── Versions.cpp ├── Versions.hpp ├── Versions_Files.hpp ├── Window.cpp ├── Window.hpp ├── stdafx.cpp └── stdafx.hpp ├── cmake └── Modules │ ├── FindSDL2.cmake │ └── FindSDL2_mixer.cmake ├── openfodder.ini.example └── sce_sys ├── icon0.png └── livearea └── contents ├── bg.png ├── startup.png └── template.xml /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | 3 | *.cmd text eol=crlf 4 | *.sln text eol=crlf 5 | *.vcxproj text eol=crlf 6 | 7 | *.props text eol=crlf 8 | *.filters text eol=crlf 9 | *.user text eol=crlf -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | 5 | --- 6 | 7 | **Describe the bug** 8 | A clear and concise description of what the bug is. 9 | 10 | **To Reproduce** 11 | Steps to reproduce the behavior: 12 | 1. Go to '...' 13 | 2. Click on '....' 14 | 3. Scroll down to '....' 15 | 4. See error 16 | 17 | **Expected behavior** 18 | A clear and concise description of what you expected to happen. 19 | 20 | **Screenshots** 21 | If applicable, add screenshots to help explain your problem. 22 | 23 | **Desktop (please complete the following information):** 24 | - OS: [e.g. Windows] 25 | - Version [e.g. 10] 26 | 27 | **Additional context** 28 | Add any other context about the problem here. 29 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | 5 | --- 6 | 7 | **Is your feature request related to a problem? Please describe.** 8 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 9 | 10 | **Describe the solution you'd like** 11 | A clear and concise description of what you want to happen. 12 | 13 | **Describe alternatives you've considered** 14 | A clear and concise description of any alternative solutions or features you've considered. 15 | 16 | **Additional context** 17 | Add any other context or screenshots about the feature request here. 18 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "Run"] 2 | path = Run 3 | url = https://github.com/OpenFodder/data 4 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: cpp 2 | 3 | dist: xenial 4 | sudo: required 5 | 6 | compiler: 7 | - clang 8 | 9 | env: 10 | - LLVM_VERSION=3.8.1 11 | 12 | before_install: 13 | - sudo apt-get update 14 | - sudo apt-get install libsdl2-dev libsdl2-mixer-dev libegl1-mesa-dev libgles2-mesa-dev 15 | cache: 16 | directories: 17 | - ${TRAVIS_BUILD_DIR}/deps/llvm-3.8.1 18 | 19 | install: 20 | - DEPS_DIR="${TRAVIS_BUILD_DIR}/deps" 21 | - mkdir -p ${DEPS_DIR} 22 | - | 23 | if [[ "${LLVM_VERSION}" != "" ]]; then 24 | LLVM_DIR=${DEPS_DIR}/llvm-${LLVM_VERSION} 25 | if [[ -z "$(ls -A ${LLVM_DIR})" ]]; then 26 | travis_retry wget --quiet https://cmake.org/files/v3.6/cmake-3.6.1.tar.gz 27 | tar xfz cmake-3.6.1.tar.gz 28 | (cd cmake-3.6.1 && ./configure --prefix=${LLVM_DIR}/cmake && make install) 29 | export PATH="${LLVM_DIR}/cmake/bin:${PATH}" 30 | LLVM_URL="http://llvm.org/releases/${LLVM_VERSION}/llvm-${LLVM_VERSION}.src.tar.xz" 31 | LIBCXX_URL="http://llvm.org/releases/${LLVM_VERSION}/libcxx-${LLVM_VERSION}.src.tar.xz" 32 | LIBCXXABI_URL="http://llvm.org/releases/${LLVM_VERSION}/libcxxabi-${LLVM_VERSION}.src.tar.xz" 33 | CLANG_URL="http://llvm.org/releases/${LLVM_VERSION}/clang+llvm-${LLVM_VERSION}-x86_64-linux-gnu-ubuntu-14.04.tar.xz" 34 | mkdir -p ${LLVM_DIR} ${LLVM_DIR}/build ${LLVM_DIR}/projects/libcxx ${LLVM_DIR}/projects/libcxxabi ${LLVM_DIR}/clang 35 | travis_retry wget --quiet -O - ${LLVM_URL} | tar --strip-components=1 -xJ -C ${LLVM_DIR} 36 | travis_retry wget --quiet -O - ${LIBCXX_URL} | tar --strip-components=1 -xJ -C ${LLVM_DIR}/projects/libcxx 37 | travis_retry wget --quiet -O - ${LIBCXXABI_URL} | tar --strip-components=1 -xJ -C ${LLVM_DIR}/projects/libcxxabi 38 | travis_retry wget --quiet -O - ${CLANG_URL} | tar --strip-components=1 -xJ -C ${LLVM_DIR}/clang 39 | (cd ${LLVM_DIR}/build && cmake .. -DCMAKE_INSTALL_PREFIX=${LLVM_DIR}/install -DCMAKE_CXX_COMPILER=clang++) 40 | (cd ${LLVM_DIR}/build/projects/libcxx && make install -j2) 41 | (cd ${LLVM_DIR}/build/projects/libcxxabi && make install -j2) 42 | fi 43 | export CXXFLAGS="-nostdinc++ -isystem ${LLVM_DIR}/install/include/c++/v1" 44 | export LDFLAGS="-L ${LLVM_DIR}/install/lib -l c++ -l c++abi" 45 | export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${LLVM_DIR}/install/lib" 46 | export PATH="${LLVM_DIR}/clang/bin:${PATH}" 47 | fi 48 | 49 | before_script: mkdir obj 50 | script: 51 | - make 52 | - cd Run 53 | - git clone --depth=50 https://github.com/OpenFodder/tests.git Tests 54 | - ./OpenFodder --unit-test-headless -------------------------------------------------------------------------------- /BUGS.md: -------------------------------------------------------------------------------- 1 | # Cannon Fodder Original Engine Bugs 2 | 3 | Issues in the original engine which have been fixed (unfortunately this list is not complete, as some bugs have been fixed and forgotten) 4 | 5 | * The second and third squad grenade and rocket count did not refresh after using either weapon 6 | 7 | * If the mouse was kept in the sidebar while changing squads, the camera would get stuck in a back and forth pattern 8 | 9 | * Out of bounds memory accesses. Numerous code accessed past either the beginning or end of a few arrays. This was not really a noticable problem on the Amiga or in Dos but is on a modern OS with virtual memory (especially on dynamically allocated memory) 10 | 11 | * Having a grenade explode at the bottom right corner of a map would cause memory corruption after the map array 12 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.6) 2 | 3 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/") 4 | 5 | include("$ENV{DOLCESDK}/share/dolce.toolchain.cmake" REQUIRED) 6 | include("$ENV{DOLCESDK}/share/dolce.cmake" REQUIRED) 7 | set(DOLCE_APP_NAME "OpenFodder") 8 | set(DOLCE_TITLEID "FDDR00001") 9 | set(DOLCE_VERSION "01.00") 10 | set(DOLCE_MKSFOEX_FLAGS "${DOLCE_MKSFOEX_FLAGS} -d PARENTAL_LEVEL=1") 11 | set(DOLCE_ELF_CREATE_FLAGS "${DOLCE_ELF_CREATE_FLAGS} -h 4194304") 12 | 13 | 14 | project(openfodder CXX) 15 | 16 | set (openfodder_VERSION_MAJOR 1) 17 | set (openfodder_VERSION_MINOR 6) 18 | set (openfodder_VERSION_RELEASE 1) 19 | 20 | include(CheckCXXCompilerFlag) 21 | include(GNUInstallDirs) 22 | 23 | 24 | find_package(SDL2 REQUIRED) 25 | find_package(SDL2_mixer REQUIRED) 26 | find_package(PNG REQUIRED) 27 | 28 | include_directories(${SDL2_INCLUDE_DIR}) 29 | include_directories(${SDL_MIXER_INCLUDE_DIR}) 30 | include_directories(${PNG_PNG_INCLUDE_DIR}) 31 | include_directories("${openfodder_SOURCE_DIR}/Source") 32 | 33 | file(GLOB_RECURSE APP_SOURCES "Source/[a-zA-Z]*.cpp") 34 | 35 | include_directories(${openfodder_SOURCE_DIR}) 36 | 37 | set(SOURCES 38 | ${APP_SOURCES} 39 | ) 40 | 41 | IF(CMAKE_BUILD_TYPE MATCHES Debug) 42 | message("debug mode") 43 | add_definitions(-DDEBUG) 44 | ENDIF() 45 | 46 | add_definitions("-Wall") 47 | 48 | add_executable(openfodder ${SOURCES}) 49 | add_definitions("-std=c++14") 50 | add_definitions("-D__VITA__") 51 | target_link_libraries(openfodder ${SDL_MIXER_LIBRARY} ${SDL2_LIBRARY} ${PNG_LIBRARY} 52 | pib 53 | SceDisplay_stub 54 | SceCtrl_stub 55 | SceAppMgr_stub 56 | SceAudio_stub 57 | SceSysmodule_stub 58 | SceSharedFb_stub 59 | SceDisplay_stub 60 | SceDisplayUser_stub 61 | SceCtrl_stub 62 | SceAppMgr_stub 63 | SceAppMgrUser_stub 64 | SceAudio_stub 65 | SceIofilemgr_stub 66 | SceSysmodule_stub 67 | SceGxm_stub 68 | SceGxmInternalForVsh_stub 69 | SceCommonDialog_stub 70 | SceTouch_stub 71 | SceHid_stub 72 | SceMotion_stub 73 | m 74 | z 75 | FLAC 76 | vorbisfile 77 | vorbis 78 | ogg 79 | mikmod 80 | mpg123 81 | ) 82 | 83 | dolce_create_self(${PROJECT_NAME}.self openfodder UNSAFE) 84 | dolce_create_vpk(${PROJECT_NAME}.vpk ${DOLCE_TITLEID} ${PROJECT_NAME}.self 85 | VERSION ${DOLCE_VERSION} 86 | NAME ${DOLCE_APP_NAME} 87 | FILE sce_sys sce_sys 88 | ) 89 | add_custom_command(OUTPUT ${CMAKE_SOURCE_DIR}/release/openfodder-${openfodder_VERSION_MAJOR}.${openfodder_VERSION_MINOR}.${openfodder_VERSION_RELEASE}.vpk 90 | COMMAND cp openfodder.vpk ${CMAKE_SOURCE_DIR}/release/openfodder-${openfodder_VERSION_MAJOR}.${openfodder_VERSION_MINOR}.${openfodder_VERSION_RELEASE}.vpk 91 | DEPENDS openfodder.vpk 92 | COMMENT "Moving vpk to release" 93 | ) 94 | add_custom_target(openfodderbinvpk_ ALL DEPENDS ${CMAKE_SOURCE_DIR}/release/openfodder-${openfodder_VERSION_MAJOR}.${openfodder_VERSION_MINOR}.${openfodder_VERSION_RELEASE}.vpk) 95 | 96 | 97 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Thanks for taking the time to consider contributing! 4 | 5 | Your first step should be to join us in the official [Discord](https://discord.gg/4mX2wFM) channel. 6 | -------------------------------------------------------------------------------- /COPYING.BSD.txt: -------------------------------------------------------------------------------- 1 | NOTE: Only certain parts of OpenFodder are under the BSD license. 2 | The majority of the files are under the GNU GPL3. See the headers of the 3 | individual files to find out the exact license. 4 | 5 | The term "BSD license" refers to any BSD-like license, as they are sometimes 6 | hard to tell apart. No slight against other licenses is intended. 7 | 8 | 9 | DE-RNC use the following license: 10 | 11 | Copyright (c) 2007, Alexander Gitter 12 | 13 | Redistribution and use in source and binary forms, with or without modification, 14 | are permitted provided that the following conditions are met: 15 | 16 | * Redistributions of source code must retain the above copyright notice, 17 | this list of conditions and the following disclaimer. 18 | * Redistributions in binary form must reproduce the above copyright notice, 19 | this list of conditions and the following disclaimer in the documentation 20 | and/or other materials provided with the distribution. 21 | * Neither the name of the author nor the names of the contributors may be 22 | used to endorse or promote products derived from this software without 23 | specific prior written permission. 24 | 25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 26 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 27 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 28 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 29 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 30 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 31 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 32 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /COPYING.ZLIB.txt: -------------------------------------------------------------------------------- 1 | Copyright notice: 2 | 3 | (C) 1995-2004 Jean-loup Gailly and Mark Adler 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 | Jean-loup Gailly Mark Adler 22 | jloup@gzip.org madler@alumni.caltech.edu 23 | 24 | If you use the zlib library in a product, we would appreciate *not* 25 | receiving lengthy legal documents to sign. The sources are provided 26 | for free but without warranty of any kind. The library has been 27 | entirely written by Jean-loup Gailly and Mark Adler; it does not 28 | include third-party code. 29 | 30 | If you redistribute modified sources, we would appreciate that you include 31 | in the file ChangeLog history information documenting your changes. Please 32 | read the FAQ for more information on the distribution of modified source 33 | versions. 34 | -------------------------------------------------------------------------------- /IDEAS.md: -------------------------------------------------------------------------------- 1 | # Open Fodder future ideas 2 | 3 | Just a few ideas for potential future enhancements 4 | 5 | * Multiplayer mode 6 | ** Arena: Large maps with many players in a death match scenario (C&C Sole Survivor style??) 7 | ** Coop: Squads created ecah phase with split troops between each squad, each player controls a squad (upto max of 3 squads -- engine limit) 8 | 9 | * Campaign / Mission centre 10 | ** Download other players campaigns 11 | 12 | -------------------------------------------------------------------------------- /INSTALL.md: -------------------------------------------------------------------------------- 1 | # Open Fodder Installation instructions 2 | 3 | ## About 4 | 5 | Open Fodder requires campaign and mission information, as well as the data files from a retail release of Cannon Fodder. These files must be installed to certain locations depending on your operating system, please see the details below for instructions. 6 | 7 | 8 | ### OS Specific 9 | 10 | #### Windows 11 | 12 | Download the [installer package](https://github.com/OpenFodder/openfodder/releases). 13 | 14 | The Windows version of Open Fodder defaults to using and installing data to the location '%USERPROFILE%/Documents/OpenFodder'. 15 | While the demos will be installed as part of the Windows installer package, you will be required to copy a full retail release into this folder (following the instructions below, or when prompted to select it during the installer) 16 | 17 | 18 | #### Linux / Unix 19 | 20 | Open Fodder will check the environment variable $XDG_DATA_DIRS and iterate each path checking for the data folder "/OpenFodder/". 21 | Failure to locate the folder in these paths, will result in a check of $HOME/.local/share/OpenFodder. 22 | Failure on this path, will fall back to the current working directory. 23 | 24 | 25 | ## Data 26 | 27 | ### Campaign Data 28 | 29 | The campaign information was originally hardcoded in the executable, this is required to play and is downloadable alonside six demos from (https://github.com/OpenFodder/data/releases/download/1.6.0/Data.pack.1.6.0.zip). 30 | 31 | This data is packaged with the Windows Installer, but will be a required download if you're compiling / running on Linux/Unix. 32 | 33 | ### Retail Data 34 | 35 | #### Dos CD Version 36 | 37 | Copy 'CF_ENG.DAT' from the CD (or the GOG install destination) to the OpenFodder/Data/Dos_CD folder 38 | 39 | #### Amiga 40 | 41 | ##### Option1. SOS Unpacker 42 | 43 | Use the [SOS Unpacker](https://github.com/OpenFodder/SOS_Unpacker) to unpack Kyroflux 'CT Raw' images of your Cannon Fodder disks, then copy the contents of 'out' into the OpenFodder/Data/Amiga directory. 44 | 45 | ##### Option2. WHDLoad 46 | 47 | Use the [WHDLoad installer](http://www.whdload.de/games/CannonFodder.html) on an Amiga or an emulator (WinUAE/UAE) to extract the game files from the original floppy disks, then copy the contents of 'cf_data' into the OpenFodder/Data/Amiga directory. 48 | 49 | 50 | #### Amiga CD32 51 | 52 | Copy the files from the 'Fodder' folder on the CD-Rom, to the OpenFodder/Data/Amiga_CD folder. For the final video, Extract Track2 from the CD and name it 'Track2.mpg', placed in the Amiga_CD folder. 53 | 54 | * Please note: The video playback is not yet supported 55 | 56 | -------------------------------------------------------------------------------- /Projects/OpenFodder.aps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isage/openfodder/6601d9f72cf28a36a0fdfc0782db9f6b4189e206/Projects/OpenFodder.aps -------------------------------------------------------------------------------- /Projects/OpenFodder.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isage/openfodder/6601d9f72cf28a36a0fdfc0782db9f6b4189e206/Projects/OpenFodder.rc -------------------------------------------------------------------------------- /Projects/VS2015/OpenFodder.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.24720.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OpenFodder", "OpenFodder.vcxproj", "{37C57A15-FFBF-41E2-9549-4E5CDB50C7D1}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Win32 = Debug|Win32 11 | Debug|x64 = Debug|x64 12 | Release|Win32 = Release|Win32 13 | Release|x64 = Release|x64 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {37C57A15-FFBF-41E2-9549-4E5CDB50C7D1}.Debug|Win32.ActiveCfg = Debug|Win32 17 | {37C57A15-FFBF-41E2-9549-4E5CDB50C7D1}.Debug|Win32.Build.0 = Debug|Win32 18 | {37C57A15-FFBF-41E2-9549-4E5CDB50C7D1}.Debug|x64.ActiveCfg = Debug|x64 19 | {37C57A15-FFBF-41E2-9549-4E5CDB50C7D1}.Debug|x64.Build.0 = Debug|x64 20 | {37C57A15-FFBF-41E2-9549-4E5CDB50C7D1}.Release|Win32.ActiveCfg = Release|Win32 21 | {37C57A15-FFBF-41E2-9549-4E5CDB50C7D1}.Release|Win32.Build.0 = Release|Win32 22 | {37C57A15-FFBF-41E2-9549-4E5CDB50C7D1}.Release|x64.ActiveCfg = Release|x64 23 | {37C57A15-FFBF-41E2-9549-4E5CDB50C7D1}.Release|x64.Build.0 = Release|x64 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /Projects/VS2015/OpenFodder.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | WindowsLocalDebugger 5 | 6 | 7 | 8 | 9 | WindowsLocalDebugger 10 | 11 | 12 | 13 | 14 | WindowsLocalDebugger 15 | 16 | 17 | WindowsLocalDebugger 18 | --window 19 | 20 | -------------------------------------------------------------------------------- /Projects/VS2015/gitver.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | if exist ..\..\.git\ ( 3 | git --version >nul 2>&1 && ( 4 | git log -n 1 --pretty="const char* gitversion=\"%%h\";" > ..\..\Source\gitver.hpp 5 | ) || (echo const char* gitversion="unknown install git";> ..\..\Source\gitver.hpp) 6 | ) else (echo const char* gitversion="unknown no git folder";> ..\..\Source\gitver.hpp) 7 | -------------------------------------------------------------------------------- /Projects/VS2015/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Projects/VS2017/OpenFodder.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26228.9 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OpenFodder", "OpenFodder.vcxproj", "{37C57A15-FFBF-41E2-9549-4E5CDB50C7D1}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Win32 = Debug|Win32 11 | Debug|x64 = Debug|x64 12 | Release_JSDebug|Win32 = Release_JSDebug|Win32 13 | Release_JSDebug|x64 = Release_JSDebug|x64 14 | Release|Win32 = Release|Win32 15 | Release|x64 = Release|x64 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {37C57A15-FFBF-41E2-9549-4E5CDB50C7D1}.Debug|Win32.ActiveCfg = Debug|Win32 19 | {37C57A15-FFBF-41E2-9549-4E5CDB50C7D1}.Debug|Win32.Build.0 = Debug|Win32 20 | {37C57A15-FFBF-41E2-9549-4E5CDB50C7D1}.Debug|x64.ActiveCfg = Debug|x64 21 | {37C57A15-FFBF-41E2-9549-4E5CDB50C7D1}.Debug|x64.Build.0 = Debug|x64 22 | {37C57A15-FFBF-41E2-9549-4E5CDB50C7D1}.Release_JSDebug|Win32.ActiveCfg = Release_JSDebug|Win32 23 | {37C57A15-FFBF-41E2-9549-4E5CDB50C7D1}.Release_JSDebug|Win32.Build.0 = Release_JSDebug|Win32 24 | {37C57A15-FFBF-41E2-9549-4E5CDB50C7D1}.Release_JSDebug|x64.ActiveCfg = Release_JSDebug|x64 25 | {37C57A15-FFBF-41E2-9549-4E5CDB50C7D1}.Release_JSDebug|x64.Build.0 = Release_JSDebug|x64 26 | {37C57A15-FFBF-41E2-9549-4E5CDB50C7D1}.Release|Win32.ActiveCfg = Release|Win32 27 | {37C57A15-FFBF-41E2-9549-4E5CDB50C7D1}.Release|Win32.Build.0 = Release|Win32 28 | {37C57A15-FFBF-41E2-9549-4E5CDB50C7D1}.Release|x64.ActiveCfg = Release|x64 29 | {37C57A15-FFBF-41E2-9549-4E5CDB50C7D1}.Release|x64.Build.0 = Release|x64 30 | EndGlobalSection 31 | GlobalSection(SolutionProperties) = preSolution 32 | HideSolutionNode = FALSE 33 | EndGlobalSection 34 | GlobalSection(ExtensibilityGlobals) = postSolution 35 | SolutionGuid = {FBC3AF8A-23B4-4C4F-9DE2-834346A80AC1} 36 | EndGlobalSection 37 | EndGlobal 38 | -------------------------------------------------------------------------------- /Projects/VS2017/OpenFodder.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | WindowsLocalDebugger 5 | 6 | 7 | 8 | 9 | WindowsLocalDebugger 10 | 11 | 12 | 13 | 14 | WindowsLocalDebugger 15 | 16 | 17 | 18 | WindowsLocalDebugger 19 | --window --window-scale 2 --random --campaign "Cannon Fodder" --skipintro --columns 40 --rows 30 20 | 21 | 22 | WindowsLocalDebugger 23 | --window --window-scale 2 --random --campaign "Cannon Fodder" --skipintro --columns 40 --rows 30 --debugger 24 | 25 | 26 | WindowsLocalDebugger 27 | --window --window-scale 2 --random --campaign "Cannon Fodder" --skipintro --columns 40 --rows 30 --debugger 28 | 29 | -------------------------------------------------------------------------------- /Projects/VS2017/gitver.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | if exist ..\..\.git\ ( 3 | git --version >nul 2>&1 && ( 4 | git log -n 1 --pretty="const char* gitversion=\"%%h\";" > ..\..\Source\gitver.hpp 5 | ) || (echo const char* gitversion="unknown install git";> ..\..\Source\gitver.hpp) 6 | ) else (echo const char* gitversion="unknown no git folder";> ..\..\Source\gitver.hpp) 7 | -------------------------------------------------------------------------------- /Projects/VS2017/openfodder.ini: -------------------------------------------------------------------------------- 1 | ; OpenFodder 2 | ; 3 | ; 4 | 5 | [openfodder] 6 | window=true 7 | cheats=false 8 | scale=auto 9 | ;columns = 50 10 | ;rows = 30 11 | 12 | [paths] 13 | path1=../../Run 14 | ;path2=d:/games/openfodder 15 | 16 | [engine] 17 | platform=amiga 18 | maxsprite=45 19 | maxspawn=10 20 | 21 | [skip] 22 | intro=false 23 | briefing=false 24 | service=false 25 | hill=false -------------------------------------------------------------------------------- /Projects/VS2017/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Projects/WinInstaller/openfodder.ini: -------------------------------------------------------------------------------- 1 | ; OpenFodder 2 | ; 3 | ; Example ini settings are the engine defaults 4 | ; 5 | 6 | [openfodder] 7 | 8 | ; Start the game in a window 9 | window=true 10 | 11 | ; Enable cheat keys 12 | cheats=false 13 | 14 | ; Window size multipler by original game resolution (Amiga 320x225, Dos 320x200) 15 | ; auto finds a size approximately half your screen resolution 16 | ; values such as 1, 2 or 3+ are multiples of the original resolution 17 | scale=auto 18 | 19 | ; Number of map tiles to draw horizontally (0 for platform default) 20 | columns=0 21 | 22 | ; Number of map tiles to draw vertically (0 for platform default) 23 | rows=0 24 | 25 | ; Don't use mouse grab (this alters the behaviour of the in-game camera window) -- Useful for VMs 26 | alternate-mouse=false 27 | 28 | [paths] 29 | ; Paths to data base folder 30 | ; There is no limit to the number paths in this section (eg, path1, path2... path10) 31 | ;path1=c:/games/openfodder 32 | ;path2=d:/games/openfodder 33 | ;path3=d:/games/openfodder 34 | 35 | ; 36 | ; 37 | [engine] 38 | 39 | ; Default platform (amiga/pc) 40 | platform=amiga 41 | 42 | ; Game engine to use in single/random maps (cf1/cf2) 43 | game=cf1 44 | 45 | ; Maximum number of sprites in game (original engine is 45) 46 | maxsprite=45 47 | 48 | ; Maximum number of enemies which can spawn (original engine is 10) 49 | maxspawn=10 50 | 51 | 52 | [skip] 53 | 54 | ; Skip the game introduction screens 55 | intro=false 56 | 57 | ; Skip the briefing screen 58 | briefing=false 59 | 60 | ; Skip the killed in action / promotion screens 61 | service=false 62 | 63 | ; Skip the hill recruit screen 64 | hill=false 65 | -------------------------------------------------------------------------------- /Projects/emscripten/build_emscripten.cmd: -------------------------------------------------------------------------------- 1 | copy openfodder.ini ..\..\Run 2 | docker run --rm -v %cd%\..\..\:/src -t apiaryio/emcc make -f EMakefile 3 | 4 | docker stop openfodder-web 5 | docker run --rm -v %cd%\..\..\RunE:/usr/local/apache2/htdocs/ -v %cd%\httpd.conf:/usr/local/apache2/conf/httpd.conf -dit --name openfodder-web -p 8080:80 httpd:2.4 6 | 7 | @pause -------------------------------------------------------------------------------- /Projects/emscripten/openfodder.ini: -------------------------------------------------------------------------------- 1 | ; OpenFodder 2 | ; 3 | ; 4 | 5 | [openfodder] 6 | window=true 7 | cheats=false 8 | scale=3 9 | 10 | [paths] 11 | ;path1=../../Run 12 | ;path2=d:/games/openfodder 13 | 14 | [engine] 15 | platform=amiga 16 | maxsprite=45 17 | maxspawn=10 18 | 19 | [skip] 20 | intro=false 21 | briefing=false 22 | service=false 23 | hill=false -------------------------------------------------------------------------------- /Projects/openfodder.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isage/openfodder/6601d9f72cf28a36a0fdfc0782db9f6b4189e206/Projects/openfodder.ico -------------------------------------------------------------------------------- /Projects/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by OpenFodder1.rc 4 | 5 | // Next default values for new objects 6 | // 7 | #ifdef APSTUDIO_INVOKED 8 | #ifndef APSTUDIO_READONLY_SYMBOLS 9 | #define _APS_NEXT_RESOURCE_VALUE 101 10 | #define _APS_NEXT_COMMAND_VALUE 40001 11 | #define _APS_NEXT_CONTROL_VALUE 1001 12 | #define _APS_NEXT_SYMED_VALUE 101 13 | #endif 14 | #endif 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Open Fodder Vita 2 | 3 | #### About 4 | 5 | *This is unofficial Vita port, please don't ask for support by the links below* 6 | 7 | Cannon Fodder is an action-strategy shoot 'em up game developed by Sensible Software and published by Virgin Interactive. 8 | 9 | The game is military-themed and based on shooting action but with a strategy game-style 10 | control system. The player directs troops through numerous missions, battling enemy infantry, vehicles and installations. 11 | 12 | Open Fodder is an open source version of the Cannon Fodder engine, for modern operating systems. 13 | 14 | * Website: [http://openfodder.com](http://openfodder.com/) 15 | * Discord: [https://discord.gg/4mX2wFM](https://discord.gg/4mX2wFM) 16 | * Facebook:[https://www.facebook.com/openfodder/](https://www.facebook.com/openfodder/) 17 | * Twitter: [https://twitter.com/segrax](https://twitter.com/segrax) 18 | 19 | 20 | #### Installation 21 | 22 | 1. Install VPK 23 | 2. Copy contents of [Data pack](https://github.com/OpenFodder/data/releases/download/1.6.0/Data.pack.1.6.0.zip) to `ux0:/data/OpenFodder` 24 | 3. Please see [INSTALL.md](https://github.com/OpenFodder/openfodder/blob/master/INSTALL.md#retail-data) for retail data installation 25 | 26 | #### Vita controls 27 | 28 | Left stick: control cursor 29 | ×, L1: Left mouse click 30 | ○, L2: Right mouse click 31 | □: Change weapon 32 | △: Map 33 | Start: pause 34 | Select: give up/quit to menu 35 | 36 | There's also touch support (disabled by default). 37 | To enable it copy `openfodder.ini` to `ux0:/data/OpenFodder` and adjust use-touch setting. 38 | 39 | #### How to play 40 | 41 | Open Fodder supports six demos from the Amiga platform, and three retail releases (See below for supported versions). 42 | 43 | #### Purchasing the retail release 44 | 45 | Cannon Fodder can be purchased from [Good Old Games](http://www.gog.com), directly at [Cannon Fodder](http://www.gog.com/game/cannon_fodder) and [Cannon Fodder 2](http://www.gog.com/game/cannon_fodder_2) 46 | 47 | #### Supported Versions 48 | 49 | ##### Cannon Fodder 50 | 51 | * Amiga 52 | * Amiga CD32 53 | * Dos CD 54 | 55 | ##### Cannon Fodder 2 56 | 57 | * Amiga 58 | * Dos CD 59 | 60 | ##### Demos 61 | 62 | Six Amiga magazine coverdisk demos and one PC demo are included in the data pack. 63 | 64 | * Amiga The One Issue #68: (Jun 1993) 65 | * Amiga Power Issue #31: (Nov 1993) Cannon Fodder Plus 66 | * Amiga Action Issue #51: (Dec 1993) 67 | * Amiga Format Issue #54: (Dec 1993) Christmas Special (Cannon Soccer) 68 | * Amiga Power Issue #45: (Jan 1995) Alien Levels 69 | * Amiga Format Issue #68: (Feb 1995) Not Very Festive Fodder 70 | * PC Format CD-ROM #1: (May 1994) 71 | 72 | #### Thanks To 73 | 74 | Sensible Software, for the original game 75 | Alessandro Petralia, for his valuable testing 76 | ScummVM, for the Amiga sound routines 77 | 78 | 79 | #### License 80 | [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2FOpenFodder%2Fopenfodder.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2FOpenFodder%2Fopenfodder?ref=badge_large) 81 | -------------------------------------------------------------------------------- /Source/.gitignore: -------------------------------------------------------------------------------- 1 | gitver.hpp 2 | -------------------------------------------------------------------------------- /Source/About.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Fodder 3 | * --------------- 4 | * 5 | * Copyright (C) 2008-2018 Open Fodder 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | */ 22 | 23 | #include "stdafx.hpp" 24 | #include "gitver.hpp" 25 | 26 | static std::string compiled = std::string(__DATE__) + " AT " + std::string(__TIME__); 27 | static std::string version = "VERSION " + std::string(gitversion); 28 | 29 | const size_t TEXTPOS_BUILD = 250; 30 | const size_t TEXTPOS_TEAM = 400; 31 | const size_t TEXTPOS_THANKS = 550; 32 | const size_t TEXTPOS_POWERED = 660; 33 | 34 | cAbout::cAbout() { 35 | std::transform(compiled.begin(), compiled.end(), compiled.begin(), ::toupper); 36 | std::transform(version.begin(), version.end(), version.begin(), ::toupper); 37 | std::replace(compiled.begin(), compiled.end(), ':', ' '); 38 | 39 | std::vector AboutText = { 40 | { TEXTPOS_BUILD + 0 , "OPEN FODDER"}, 41 | //{ TEXTPOS_BUILD + 10 , "BUILD VERSION "}, 42 | { TEXTPOS_BUILD + 10, version.c_str()}, 43 | { TEXTPOS_BUILD + 20, compiled.c_str()}, 44 | { TEXTPOS_BUILD + 30, "WWW DOT OPENFODDER DOT COM"}, 45 | 46 | { TEXTPOS_TEAM + 0 , "THE TEAM" }, 47 | { TEXTPOS_TEAM + 20 , "PROJECT LEAD" }, 48 | { TEXTPOS_TEAM + 30, "ROBERT CROSSFIELD" }, 49 | 50 | { TEXTPOS_TEAM + 80, "ENGINE" }, 51 | { TEXTPOS_TEAM + 90, "ALESSANDRO PETRALIA" }, 52 | 53 | { TEXTPOS_TEAM + 110, "SCRIPTING" }, 54 | { TEXTPOS_TEAM + 120, "STARWINDZ" }, 55 | 56 | 57 | { TEXTPOS_THANKS + 0 , "THANKS TO" }, 58 | { TEXTPOS_THANKS + 10, "SENSIBLE SOFTWARE"}, 59 | { TEXTPOS_THANKS + 20, "STOO CAMBRIDGE"}, 60 | { TEXTPOS_THANKS + 30, "CLAIRE CROSSFIELD"}, 61 | { TEXTPOS_THANKS + 40, "LACHIE CROSSFIELD"}, 62 | { TEXTPOS_THANKS + 50, "RILEY ELLETT"}, 63 | { TEXTPOS_THANKS + 60, "SCUMMVM"}, 64 | 65 | { TEXTPOS_POWERED + 0, "POWERED BY"}, 66 | { TEXTPOS_POWERED + 10, "CPP14"}, 67 | { TEXTPOS_POWERED + 20, "SDL2"}, 68 | { TEXTPOS_POWERED + 30, "DUKTAPE"}, 69 | { TEXTPOS_POWERED + 40, "DUKGLUE"}, 70 | 71 | // Just for fun: loc_2B48E 72 | { 1100, "PUSH CX"}, 73 | { 1110, "PUSH SI"}, 74 | { 1120, "PUSH DI"}, 75 | { 1130, "MOV CX 16H"}, 76 | 77 | { 1150, "MOV BX ES SI"}, 78 | { 1160, "AND BX 1FFH"}, 79 | { 1170, "PUSH CS"}, 80 | { 1180, "CALL SUB 2B4B8"}, 81 | { 1190, "ADD SI 2"}, 82 | 83 | { 1500, "W W W DOT O P E N F O D D E R DOT C O M"} 84 | }; 85 | 86 | mSurface = new cSurface(0, 0); 87 | mSurface->LoadBitmap(g_ResourceMan->GetAboutFile()); 88 | g_Fodder->mGraphics->PaletteSet(); 89 | g_Fodder->Phase_EngineReset(); 90 | g_Fodder->mMouseSpriteNew = eSprite_pStuff_Mouse_Target; 91 | g_Fodder->mService_Draw_List.clear(); 92 | 93 | g_Fodder->mGraphics->Load_Service_Data(); 94 | g_Fodder->mGraphics->SetActiveSpriteSheet(eGFX_SERVICE); 95 | g_Fodder->mGraphics->PaletteSet(); 96 | 97 | 98 | for (auto& Text : AboutText) { 99 | g_Fodder->Service_Draw_String(Text.mText, false, Text.mPosition); 100 | } 101 | 102 | g_Fodder->mSound->Music_Play(PLATFORM_BASED(16, CANNON_BASED(16, 20))); 103 | } 104 | 105 | cAbout::~cAbout() { 106 | 107 | delete mSurface; 108 | } 109 | 110 | bool cAbout::Cycle() { 111 | 112 | g_Fodder->GUI_Element_Reset(); 113 | 114 | g_Fodder->mSurface->palette_FadeTowardNew(); 115 | g_Fodder->mSurface->clearBuffer(); 116 | 117 | g_Fodder->mGraphics->SetActiveSpriteSheet(eGFX_BRIEFING); 118 | g_Fodder->Service_Draw_List(); 119 | g_Fodder->Service_ScrollUp_DrawList(); 120 | 121 | { 122 | g_Fodder->mString_GapCharID = 0x25; 123 | g_Fodder->String_Print_Large("Open Fodder", true, 0x01); 124 | g_Fodder->mString_GapCharID = 0x00; 125 | 126 | g_Fodder->GUI_Button_Draw_Small("BACK", 0xB3 + PLATFORM_BASED(0, 25)); 127 | g_Fodder->GUI_Button_Setup_Small(&cFodder::GUI_Button_Load_Exit); 128 | } 129 | 130 | g_Fodder->Mouse_Inputs_Get(); 131 | g_Fodder->Mouse_DrawCursor(); 132 | 133 | if (g_Fodder->mPhase_Aborted) 134 | g_Fodder->GUI_Button_Load_Exit(); 135 | 136 | if (g_Fodder->mMouse_Button_Left_Toggle) { 137 | g_Fodder->GUI_Handle_Element_Mouse_Check(g_Fodder->mGUI_Elements); 138 | 139 | if (g_Fodder->mGUI_SaveLoadAction == 1) { 140 | 141 | g_Fodder->mSurface->paletteNew_SetToBlack(); 142 | g_Fodder->mSurface->palette_FadeTowardNew(); 143 | } 144 | 145 | } 146 | 147 | g_Fodder->mSurface->draw(); 148 | g_Window->RenderShrunk(mSurface); 149 | 150 | if (g_Fodder->mGUI_SaveLoadAction == 1 && !g_Fodder->mSurface->isPaletteAdjusting()) 151 | return false; 152 | 153 | return true; 154 | } 155 | -------------------------------------------------------------------------------- /Source/About.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Fodder 3 | * --------------- 4 | * 5 | * Copyright (C) 2008-2018 Open Fodder 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | */ 22 | 23 | class cAbout { 24 | 25 | cSurface* mSurface; 26 | 27 | public: 28 | cAbout(); 29 | ~cAbout(); 30 | 31 | bool Cycle(); 32 | }; 33 | -------------------------------------------------------------------------------- /Source/Amiga/Graphics_Amiga.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Fodder 3 | * --------------- 4 | * 5 | * Copyright (C) 2008-2018 Open Fodder 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | */ 22 | 23 | const extern sSpriteSheet* mSpriteSheetTypes_InGame_Amiga[]; 24 | const extern sSpriteSheet* mSpriteSheetTypes_InGame_Amiga_TheOne[]; 25 | const extern sSpriteSheet* mSpriteSheetTypes_Font_Amiga[]; 26 | const extern sSpriteSheet* mSpriteSheetTypes_Recruit_Amiga[]; 27 | const extern sSpriteSheet* mSpriteSheetTypes_Hill_Amiga[]; 28 | const extern sSpriteSheet* mSpriteSheetTypes_Briefing_Amiga[]; 29 | const extern sSpriteSheet* mSpriteSheetTypes_Service_Amiga[]; 30 | 31 | 32 | 33 | struct sHillOverlay_Amiga { 34 | int16 mSpriteType; 35 | int16 mFrame; 36 | int16 mX; 37 | int16 mY; 38 | }; 39 | 40 | struct sStruct0_Amiga { 41 | int16 mSpriteSheet; // 0 = mDataHillData : 1 = mSpriteSheet_RankFont 42 | int16 mOffset; 43 | int16 mWidth; 44 | int16 mHeight; 45 | }; 46 | 47 | class cGraphics_Amiga : public cGraphics { 48 | protected: 49 | 50 | tSharedBuffer mBlkData; 51 | 52 | sILBM_BMHD* mBMHD_Current; 53 | uint16 mCursorPalette; 54 | 55 | 56 | virtual void DecodePalette(const uint8* pData, size_t pColorID, const size_t pColors); 57 | virtual sImage DecodeIFF(const std::string& pFilename); 58 | 59 | public: 60 | cGraphics_Amiga(); 61 | virtual ~cGraphics_Amiga(); 62 | 63 | virtual sImage Decode_Image(const std::string& pFilename, const size_t pCount, const size_t pPaletteOffset = 0, const size_t pStartIndex = 0); 64 | 65 | virtual void SetCursorPalette( uint16 pIndex ); 66 | 67 | virtual void DrawPixel(uint8* pSource, uint8* pDestination, uint16 pSourceX, uint16 pSourceY, uint16 pX, uint16 pY); 68 | virtual void DrawPixels_8( uint8* pSource, uint8* pDestination ); 69 | virtual void DrawPixels_16( uint8* pSource, uint8* pDestination, const uint8 pPalleteIndex ); 70 | 71 | virtual void Load_And_Draw_Image( const std::string &pFilename, unsigned int pColors = 0, size_t pBackColor = 0 ); 72 | 73 | virtual uint8* GetSpriteData( uint16 pSegment ); 74 | virtual void Mouse_DrawCursor(); 75 | virtual void Tile_Prepare_Gfx(); 76 | virtual void Load_pStuff(); 77 | virtual void Load_Sprite_Font(); 78 | virtual void Load_Hill_Data(); 79 | virtual void Load_Service_Data(); 80 | 81 | virtual void Map_Load_Resources(); 82 | virtual void Map_Tile_Draw(cSurface *pTarget, uint16 pTile, uint16 pX, uint16 pY, uint16 pOffset); 83 | virtual void MapTiles_Draw(); 84 | virtual void Hill_Prepare_Overlays(); 85 | virtual void MapOverview_Render_Tiles( uint16 pTile, uint16 pDestX, uint16 pDestY ); 86 | 87 | virtual void PaletteSetOverview(); 88 | virtual void PaletteSet(cSurface *pTarget); 89 | virtual void PaletteBriefingSet(); 90 | 91 | virtual void PaletteLoad( const uint8 *pBuffer, uint32 pColors, uint32 pColorID = 0 ); 92 | 93 | virtual void Video_Draw_16_Offset( int16 pCx ); 94 | virtual void Video_Draw_16( const uint8* RowPallete = 0 ); 95 | virtual void Video_Draw_8( cSurface *pTarget = 0, const uint8* RowPallete = 0 ); 96 | virtual void Video_Draw_8_Alt( const uint8* RowPallete = 0 ); 97 | 98 | virtual void SetActiveSpriteSheet(eGFX_Types pSpriteType ); 99 | 100 | virtual void Sidebar_Copy_To_Surface( int16 pStartY ); 101 | virtual void Sidebar_Copy_Sprite_To_ScreenBufPtr( int16 pSpriteType, size_t pX, size_t pY ); 102 | virtual void Sidebar_Copy_ScreenBuffer( uint16 pRow, int16 pRows, int16 pCopyToScreen, uint32*& pBuffer); 103 | 104 | virtual void Recruit_Sprite_Draw(int16 pRows, int16 pColumns, int16 pData8, int16 pData10, int16 pData14, int16 pDataC, uint8* pData20 ); 105 | 106 | virtual bool Sprite_OnScreen_Check( ); 107 | virtual bool Sprite_OnScreen_Check( bool p16bit = false ); 108 | 109 | virtual void Mission_Intro_Play( const bool pShowHelicopter, const eTileTypes pTileset); 110 | virtual void Mission_Intro_Load_Resources(const eTileTypes pTileset); 111 | virtual void Mission_Intro_DrawHelicopter( uint16 pID ); 112 | 113 | virtual void Recruit_Draw_Hill(); 114 | virtual void Recruit_Draw_HomeAway(); 115 | virtual void Service_Draw( int16 pSpriteID, int16 pX, int16 pY); 116 | }; 117 | -------------------------------------------------------------------------------- /Source/Amiga/Graphics_Amiga2.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Fodder 3 | * --------------- 4 | * 5 | * Copyright (C) 2008-2018 Open Fodder 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | */ 22 | 23 | const extern sSpriteSheet* mSpriteSheetTypes_InGame_Amiga_CF2[]; 24 | 25 | class cGraphics_Amiga2 : public cGraphics_Amiga { 26 | 27 | public: 28 | 29 | virtual void Load_pStuff(); 30 | virtual void Load_And_Draw_Image(const std::string &pFilename, unsigned int pColors, size_t pBackColor); 31 | virtual void Load_Service_Data(); 32 | 33 | sImage Decode_Image(const std::string& pFilename, const size_t pCount, const size_t pPaletteOffset, const size_t pStartIndex); 34 | 35 | tSharedBuffer GetPalette(const std::string pFilename); 36 | virtual sImage GetImage(const std::string& pFilename, const size_t pPaletteIndex); 37 | 38 | virtual void Map_Load_Resources(); 39 | virtual void Mission_Intro_Load_Resources(const eTileTypes pTileset); 40 | 41 | virtual void SetActiveSpriteSheet(eGFX_Types pSpriteType); 42 | 43 | void Recruit_Draw_Hill(); 44 | 45 | cGraphics_Amiga2(); 46 | ~cGraphics_Amiga2(); 47 | }; 48 | -------------------------------------------------------------------------------- /Source/Amiga/IntroData_Amiga.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Fodder 3 | * --------------- 4 | * 5 | * Copyright (C) 2008-2018 Open Fodder 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | */ 22 | 23 | #include "Types.hpp" 24 | #include 25 | #include "IntroData.hpp" 26 | 27 | 28 | const sIntroString mIntro_0[] = { 29 | { 0x50, "This game is not in any way" }, 30 | { 0x68, "endorsed by the" }, 31 | { 0x82, "ROYAL BRITISH LEGION" }, 32 | { 0, 0 } 33 | }; 34 | 35 | const sIntroString mIntro_1[] = { 36 | { 0xCC, "A Sensible Software Game" }, 37 | { 0, 0 } 38 | }; 39 | 40 | const sIntroString mIntro_2[] = { 41 | { 0x64, "STARRING" }, 42 | { 0, 0 } 43 | }; 44 | 45 | const sIntroString mIntro_3[] = { 46 | { 0xA4, "JOOLS" }, 47 | { 0xB5, "as" }, 48 | { 0xC8, "James Dean" }, 49 | { 0, 0 } 50 | }; 51 | 52 | const sIntroString mIntro_4[] = { 53 | { 0xA4, "STOO" }, 54 | { 0xB4, "as" }, 55 | { 0xC8, "Elvis" }, 56 | { 0, 0 } 57 | }; 58 | 59 | const sIntroString mIntro_5[] = { 60 | { 0xA4, "RICHARD JOSEPH" }, 61 | { 0xB4, "as" }, 62 | { 0xC8, "Sgt. Bilko" }, 63 | { 0, 0 } 64 | }; 65 | 66 | const sIntroString mIntro_6[] = { 67 | { 0x64, "Co. STARRING" }, 68 | { 0, 0 } 69 | }; 70 | 71 | const sIntroString mIntro_7[] = { 72 | { 0xA4, "CHRIS YATES" }, 73 | { 0xB4, "as" }, 74 | { 0xC8, "JR out of Dallas" }, 75 | { 0, 0 } 76 | }; 77 | 78 | const sIntroString mIntro_8[] = { 79 | { 0xA4, "JON HARE" }, 80 | { 0xB5, "as" }, 81 | { 0xC8, "Vera Lynn" }, 82 | { 0, 0 } 83 | }; 84 | 85 | const sIntroString mIntro_9[] = { 86 | { 0x64, "SPECIAL GUEST STAR" }, 87 | { 0, 0 } 88 | }; 89 | 90 | const sIntroString mIntro_10[] = { 91 | { 0xA4, "CHRIS CHAPMAN" }, 92 | { 0xB4, "as" }, 93 | { 0xC8, "Norman Wisdom" }, 94 | { 0, 0 } 95 | }; 96 | 97 | const sIntroString mIntro_11[] = { 98 | { 0x50, "Jools" }, 99 | { 0x8C, "Stoo" }, 100 | { 0x3C, "Program Design" }, 101 | { 0x78, "Graphic Design" }, 102 | { 0, 0 } 103 | }; 104 | 105 | const sIntroString mIntro_12[] = { 106 | { 0x32, "Richard Joseph" }, 107 | { 0x6E, "Jon Hare" }, 108 | { 0xAA, "David Hindley" }, 109 | { 0x1E, "Sound effects and Music" }, 110 | { 0x5A, "Original Soundtrack"}, 111 | { 0x96, "Cameraman" }, 112 | { 0, 0 } 113 | }; 114 | 115 | const sIntroString mIntro_13[] = { 116 | { 0x28, "Steve Cook" }, 117 | { 0x5A, "Graftgold" }, 118 | { 0x8C, "Hammonds Hire" }, 119 | { 0xBE, "Peter Hickman" }, 120 | { 0x14, "Vehicle and Stunts" }, 121 | { 0x46, "Flatbed Scanning" }, 122 | { 0x78, "Costumes" }, 123 | { 0xAA, "Mr Virgin" }, 124 | { 0, 0 } 125 | }; 126 | 127 | const sIntroString mIntro_14[] = { 128 | { 0xD2, "Sensible Software." }, 129 | { 0xBE, "Designed By" }, 130 | { 0, 0 } 131 | }; 132 | 133 | std::vector< sIntroText > mIntroText_Amiga = { 134 | { 0xFF, mIntro_0 }, 135 | { 0x31, mIntro_1 }, 136 | { 0xFF, mIntro_2 }, 137 | { 0x32, mIntro_3 }, 138 | { 0x33, mIntro_4 }, 139 | { 0x34, mIntro_5 }, 140 | { 0xFF, mIntro_6 }, 141 | { 0x36, mIntro_7 }, 142 | { 0x35, mIntro_8 }, 143 | { 0xFF, mIntro_9 }, 144 | { 0x37, mIntro_10 }, 145 | { 0xFF, mIntro_11 }, 146 | { 0xFF, mIntro_12 }, 147 | { 0xFF, mIntro_13 }, 148 | { 0x38, mIntro_14 }, 149 | { 0, 0 }, 150 | { 0, 0 }, 151 | { 0, 0 } 152 | }; 153 | 154 | std::vector< sIntroText > mIntroText_Amiga2 = { 155 | { 0, 0 }, 156 | { 0x31, 0 }, 157 | { 0x32, 0 }, 158 | { 0x33, 0 }, 159 | { 0x34, 0 }, 160 | { 0x35, 0 }, 161 | { 0x36, 0 }, 162 | { 0x37, 0 }, 163 | { 0x38, 0 }, 164 | { 0x39, 0 }, 165 | { 0x61, 0 }, 166 | { 0x62, 0 }, 167 | { 0x63, 0 }, 168 | { 0x64, 0 }, 169 | { 0, 0 } 170 | }; 171 | -------------------------------------------------------------------------------- /Source/Amiga/Resource_Amiga_File.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Fodder 3 | * --------------- 4 | * 5 | * Copyright (C) 2008-2018 Open Fodder 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | */ 22 | 23 | #include "stdafx.hpp" 24 | #include "Amiga/dernc.hpp" 25 | #include "Amiga/Resource_Amiga_File.hpp" 26 | 27 | cResource_Amiga_File::cResource_Amiga_File( ) : cResources() { 28 | 29 | } 30 | 31 | cResource_Amiga_File::~cResource_Amiga_File() { 32 | 33 | } 34 | 35 | tSharedBuffer cResource_Amiga_File::fileGet( std::string pFilename ) { 36 | 37 | auto File = cResources::fileGet( pFilename ); 38 | if (!File->size()) { 39 | //std::cout << "File " << pFilename << " Not Found!\n"; 40 | //exit( 1 ); 41 | return File; 42 | } 43 | uint32 Header = readBEDWord( File->data() ); 44 | 45 | if (Header != 'RNC\01') 46 | return File; 47 | 48 | uint32 Size = readBEDWord( File->data() + 4 ); 49 | 50 | auto Unpacked = std::make_shared>(); 51 | Unpacked->resize( Size ); 52 | 53 | rnc_unpack (File->data(), Unpacked->data()); 54 | 55 | return Unpacked; 56 | } 57 | -------------------------------------------------------------------------------- /Source/Amiga/Resource_Amiga_File.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Fodder 3 | * --------------- 4 | * 5 | * Copyright (C) 2008-2018 Open Fodder 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | */ 22 | 23 | class cResource_Amiga_File : public cResources { 24 | 25 | uint8* file_Get( cResource_File *pFile, size_t &pFileSize, bool pDecode ); 26 | 27 | public: 28 | 29 | cResource_Amiga_File( ); 30 | virtual ~cResource_Amiga_File(); 31 | 32 | virtual tSharedBuffer fileGet( std::string pFilename ); 33 | }; 34 | -------------------------------------------------------------------------------- /Source/Amiga/Sound_Amiga.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Fodder 3 | * --------------- 4 | * 5 | * Copyright (C) 2008-2018 Open Fodder 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | */ 22 | 23 | struct sSoundData { 24 | const char* mSongData; 25 | const char* mInstrumentData; 26 | }; 27 | 28 | struct sSound { 29 | tSharedBuffer mCurrentMusicSongData; 30 | tSharedBuffer mCurrentMusicInstrumentData; 31 | 32 | const sSoundData* mTrack; 33 | 34 | sSound() { 35 | 36 | mTrack = 0; 37 | } 38 | }; 39 | 40 | class cSound_Amiga : public cSound { 41 | Audio::Rjp1* mCurrentMusic; 42 | sSound mSound_Music; 43 | sSound mSound_Sfx; 44 | 45 | SDL_AudioSpec* mAudioSpec; 46 | int mVal; 47 | SDL_mutex* mLock; 48 | 49 | std::vector mCurrentSfx; 50 | 51 | 52 | private: 53 | 54 | bool devicePrepare(); 55 | 56 | public: 57 | 58 | cSound_Amiga(); 59 | ~cSound_Amiga(); 60 | 61 | void audioBufferFill( short *pBuffer, int pBufferSize ); 62 | 63 | int16 Track_Load( sSound* pSound, int16 pTrack ); 64 | void Sound_Play( int16 pTileset, int16 pSoundEffect, int16 pVolume ); 65 | 66 | void Music_Play( int16 pTrack ); 67 | void Music_Stop(); 68 | void Sound_Stop(); 69 | 70 | 71 | }; 72 | -------------------------------------------------------------------------------- /Source/Amiga/dernc.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * dernc.h define exported routines from dernc.c 3 | */ 4 | 5 | /** 6 | * DERNC From: https://github.com/alexandergitter/THViewer 7 | */ 8 | 9 | #ifndef RNC_DERNC_H 10 | #define RNC_DERNC_H 11 | 12 | /* 13 | * Routines 14 | */ 15 | long rnc_ulen (void *packed); 16 | #ifndef COMPRESSOR 17 | long rnc_unpack (void *packed, void *unpacked); 18 | #else 19 | long rnc_unpack (void *packed, void *unpacked, long *leeway); 20 | #endif 21 | const char *rnc_error (long errcode); 22 | long rnc_crc (void *data, long len); 23 | 24 | /* 25 | * Error returns 26 | */ 27 | #define RNC_FILE_IS_NOT_RNC -1 28 | #define RNC_HUF_DECODE_ERROR -2 29 | #define RNC_FILE_SIZE_MISMATCH -3 30 | #define RNC_PACKED_CRC_ERROR -4 31 | #define RNC_UNPACKED_CRC_ERROR -5 32 | 33 | /* 34 | * The compressor needs this define 35 | */ 36 | #define RNC_SIGNATURE 0x524E4301 /* "RNC\001" */ 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /Source/Amiga/rjp1.hpp: -------------------------------------------------------------------------------- 1 | /* ScummVM - Graphic Adventure Engine 2 | * 3 | * ScummVM is the legal property of its developers, whose names 4 | * are too numerous to list here. Please refer to the COPYRIGHT 5 | * file distributed with this source distribution. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | */ 22 | 23 | /** 24 | * @file 25 | * Sound decoder used in engines: 26 | * - queen 27 | */ 28 | 29 | #ifndef AUDIO_MODS_RJP1_H 30 | #define AUDIO_MODS_RJP1_H 31 | 32 | namespace Audio { 33 | 34 | struct Rjp1Channel { 35 | const int8 *waveData; 36 | const int8 *modulatePeriodData; 37 | const int8 *modulateVolumeData; 38 | const int8 *envelopeData; 39 | uint16 volumeScale; 40 | int16 volume; 41 | uint16 modulatePeriodBase; 42 | uint32 modulatePeriodLimit; 43 | uint32 modulatePeriodIndex; 44 | uint16 modulateVolumeBase; 45 | uint32 modulateVolumeLimit; 46 | uint32 modulateVolumeIndex; 47 | uint8 freqStep; 48 | uint32 freqInc; 49 | uint32 freqInit; 50 | const uint8 *noteData; 51 | const uint8 *sequenceOffsets; 52 | const uint8 *sequenceData; 53 | uint8 loopSeqCount; 54 | uint8 loopSeqCur; 55 | uint8 loopSeq2Count; 56 | uint8 loopSeq2Cur; 57 | bool active; 58 | int16 modulatePeriodInit; 59 | int16 modulatePeriodNext; 60 | bool setupNewNote; 61 | int8 envelopeMode; 62 | int8 envelopeScale; 63 | int8 envelopeEnd1; 64 | int8 envelopeEnd2; 65 | int8 envelopeStart; 66 | int8 envelopeVolume; 67 | uint8 currentInstrument; 68 | const int8 *data; 69 | uint16 pos; 70 | uint16 len; 71 | uint16 repeatPos; 72 | uint16 repeatLen; 73 | bool isSfx; 74 | }; 75 | 76 | class Rjp1 : public Paula { 77 | public: 78 | 79 | struct Vars { 80 | int8 *instData; 81 | uint32 instDataSize; 82 | 83 | uint8 *songData[7]; 84 | uint32 songDataSize[7]; 85 | 86 | uint8 activeChannelsMask; 87 | uint8 currentChannel; 88 | int subsongsCount; 89 | int instrumentsCount; 90 | }; 91 | 92 | Rjp1(int rate, bool stereo); 93 | virtual ~Rjp1(); 94 | 95 | bool load(tSharedBuffer songData, tSharedBuffer instrumentsData); 96 | void unload(); 97 | 98 | void startPattern(int ch, int pat); 99 | void startSong(int song); 100 | 101 | protected: 102 | 103 | void startSequence(uint8 channelNum, uint8 seqNum); 104 | void turnOffChannel(Rjp1Channel *channel); 105 | void playChannel(Rjp1Channel *channel); 106 | void turnOnChannel(Rjp1Channel *channel); 107 | bool executeSfxSequenceOp(Rjp1Channel *channel, uint8 code, const uint8 *&p); 108 | bool executeSongSequenceOp(Rjp1Channel *channel, uint8 code, const uint8 *&p); 109 | void playSongSequence(Rjp1Channel *channel); 110 | void modulateVolume(Rjp1Channel *channel); 111 | void modulatePeriod(Rjp1Channel *channel); 112 | void setupNote(Rjp1Channel *channel, int16 freq); 113 | void setupInstrument(Rjp1Channel *channel, uint8 num); 114 | void setRelease(Rjp1Channel *channel); 115 | void modulateVolumeEnvelope(Rjp1Channel *channel); 116 | void setSustain(Rjp1Channel *channel); 117 | void setDecay(Rjp1Channel *channel); 118 | void modulateVolumeWaveform(Rjp1Channel *channel); 119 | void setVolume(Rjp1Channel *channel); 120 | 121 | void stopPaulaChannel(size_t channel); 122 | void setupPaulaChannel(size_t channel, const int8 *waveData, uint16 offset, uint16 len, uint16 repeatPos, uint16 repeatLen); 123 | 124 | virtual void interrupt(); 125 | 126 | Vars _vars; 127 | Rjp1Channel _channelsTable[4]; 128 | 129 | static const int16 _periodsTable[]; 130 | static const int _periodsCount; 131 | }; 132 | class AudioStream; 133 | 134 | /* 135 | * Factory function for RichardJoseph1 modules. Reads all data from the 136 | * given songData and instrumentsData streams and creates an AudioStream 137 | * from this. No references to these stream objects are kept. 138 | */ 139 | Rjp1 *makeRjp1Stream(tSharedBuffer songData, tSharedBuffer instrumentsData, int num, int rate = 44100, bool stereo = true); 140 | 141 | } // End of namespace Audio 142 | 143 | #endif 144 | -------------------------------------------------------------------------------- /Source/CopyProtection.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Fodder 3 | * --------------- 4 | * 5 | * Copyright (C) 2008-2018 Open Fodder 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | */ 22 | 23 | struct sCopyProtection { 24 | int16 mPage; 25 | int16 mParagraph; 26 | int16 mLine; 27 | int16 mWord; 28 | const uint8* mAnswer; 29 | }; 30 | 31 | //extern const sCopyProtection mCopyProtection_Values[]; 32 | -------------------------------------------------------------------------------- /Source/Debugger.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Fodder 3 | * --------------- 4 | * 5 | * Copyright (C) 2008-2018 Open Fodder 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | */ 22 | 23 | #include "stdafx.hpp" 24 | 25 | #ifdef WIN32 26 | #include 27 | #endif 28 | 29 | cDebugger::cDebugger() { 30 | 31 | } 32 | 33 | bool cDebugger::ConsoleOpen() { 34 | static bool Alloced = false; 35 | 36 | if (Alloced) 37 | return true; 38 | 39 | #ifdef _CONSOLE 40 | return true; 41 | #endif 42 | if (g_Fodder->mParams->mAppVeyor) 43 | return true; 44 | 45 | #ifdef WIN32 46 | static bool attached = AttachConsole(ATTACH_PARENT_PROCESS); 47 | if (!attached) 48 | attached = AllocConsole(); 49 | 50 | FILE *stream, *stream2, *stream3; 51 | 52 | freopen_s(&stream, "CONIN$", "r", stdin); 53 | freopen_s(&stream2, "CONOUT$", "w", stdout); 54 | freopen_s(&stream3, "CONOUT$", "w", stderr); 55 | 56 | Alloced = true; 57 | std::ios::sync_with_stdio(true); 58 | std::wcout.clear(); 59 | std::cout.clear(); 60 | std::wcerr.clear(); 61 | std::cerr.clear(); 62 | std::wcin.clear(); 63 | std::cin.clear(); 64 | #endif 65 | return true; 66 | } 67 | 68 | void cDebugger::ClearConsole() { 69 | 70 | #ifdef WIN32 71 | system("cls"); 72 | #else 73 | system("clear"); 74 | #endif 75 | } 76 | 77 | void cDebugger::Output(const std::string pMessage) { 78 | #ifdef WIN32 79 | OutputDebugStringA(pMessage.c_str()); 80 | #endif 81 | std::cout << pMessage; 82 | } 83 | 84 | void cDebugger::Notice(const std::string& pMessage) { 85 | ConsoleOpen(); 86 | 87 | if (g_Fodder->mParams->mAppVeyor) { 88 | std::string Command = "appveyor AddMessage "; 89 | Command += "\"" + pMessage + "\""; 90 | Command += " -Category Information"; 91 | system(Command.c_str()); 92 | } 93 | else { 94 | Output(pMessage + "\n" ); 95 | } 96 | 97 | } 98 | 99 | void cDebugger::Error(const std::string& pMessage) { 100 | ConsoleOpen(); 101 | if (g_Fodder->mParams->mAppVeyor) { 102 | std::string Command = "appveyor AddMessage "; 103 | Command += "\"" + pMessage + "\""; 104 | Command += " -Category Error"; 105 | system(Command.c_str()); 106 | } 107 | else { 108 | Output(pMessage + "\n"); 109 | } 110 | } 111 | 112 | void cDebugger::TestStart(const std::string& pName, const std::string& pGroup) { 113 | ConsoleOpen(); 114 | if (g_Fodder->mParams->mAppVeyor) { 115 | std::string Command = "appveyor AddTest"; 116 | 117 | Command += " -Name \"" + pName + "\""; 118 | Command += " -Framework NUnit -FileName \"" + pGroup + "\""; 119 | Command += " -Outcome Running"; 120 | system(Command.c_str()); 121 | } 122 | else { 123 | std::cout << "[Test] " << pName << ": starting\n"; 124 | } 125 | } 126 | 127 | void cDebugger::TestComplete(const std::string& pName, const std::string& pGroup, const std::string& pMessage, const size_t pTime, eTestState pTestState) { 128 | ConsoleOpen(); 129 | if (g_Fodder->mParams->mAppVeyor) { 130 | std::string Command = "appveyor UpdateTest"; 131 | Command += " -Name \"" + pName + "\""; 132 | Command += " -Framework NUnit -FileName \"" + pGroup +"\""; 133 | if (pTestState == eTest_Failed) 134 | Command += " -ErrorMessage \"" + pMessage + "\""; 135 | 136 | Command += " -Duration " + std::to_string(pTime); 137 | Command += " -Outcome "; 138 | 139 | switch (pTestState) { 140 | case eTest_Passed: 141 | Command += "Passed"; 142 | break; 143 | case eTest_Failed: 144 | Command += "Failed"; 145 | break; 146 | case eTest_Skipped: 147 | Command += "Skipped"; 148 | break; 149 | case eTest_Running: 150 | Command += "Running"; 151 | break; 152 | } 153 | 154 | system(Command.c_str()); 155 | } 156 | else { 157 | if(pTestState == eTest_Passed) 158 | std::cout << "[Test] " << pName << ": Passed - " << pMessage << "\n"; 159 | else 160 | std::cout << "[Test] " << pName << ": Failed - " << pMessage << "\n"; 161 | } 162 | } 163 | -------------------------------------------------------------------------------- /Source/Debugger.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Fodder 3 | * --------------- 4 | * 5 | * Copyright (C) 2008-2018 Open Fodder 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | */ 22 | 23 | enum eTestState { 24 | eTest_Running, 25 | eTest_Passed, 26 | eTest_Failed, 27 | eTest_Skipped 28 | }; 29 | 30 | class cDebugger { 31 | 32 | protected: 33 | bool ConsoleOpen(); 34 | 35 | void Output(const std::string pMessage); 36 | 37 | public: 38 | cDebugger(); 39 | 40 | void ClearConsole(); 41 | 42 | void Notice(const std::string& pMessage); 43 | void Error(const std::string& pMessage); 44 | 45 | void TestStart( const std::string& pName, const std::string& pGroup ); 46 | void TestComplete(const std::string& pName, const std::string& pGroup, const std::string& pMessage, const size_t pTime, eTestState pTestState); 47 | 48 | }; 49 | -------------------------------------------------------------------------------- /Source/Dimension.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Fodder 3 | * --------------- 4 | * 5 | * Copyright (C) 2008-2018 Open Fodder 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | */ 22 | 23 | class cDimension { 24 | public: 25 | unsigned int mWidth, mHeight; 26 | 27 | public: 28 | cDimension() : mWidth( 0 ), mHeight( 0 ) {} 29 | cDimension( unsigned int pWidth, unsigned int pHeight ) : mWidth( pWidth ), mHeight( pHeight ) {} 30 | 31 | void Set( unsigned int pWidth, unsigned int pHeight ) { mWidth = pWidth; mHeight = pHeight; } 32 | 33 | unsigned int WidthByHeight() { return mWidth * mHeight; } 34 | int getWidth() const { return mWidth; } 35 | int getHeight() const { return mHeight; } 36 | 37 | cPosition getCentre() const { return { mWidth / 2, mHeight / 2 }; }; 38 | 39 | cDimension operator/(const cDimension& pDim) { 40 | return cDimension(mWidth / pDim.mWidth, mHeight / pDim.mHeight); 41 | } 42 | 43 | bool operator==(const cDimension& pRight) { 44 | return mWidth == pRight.mWidth && mHeight == pRight.mHeight; 45 | } 46 | 47 | cDimension operator+(const cDimension& pRight) { 48 | 49 | return cDimension(mWidth + pRight.mWidth, mHeight + pRight.mHeight); 50 | } 51 | }; 52 | -------------------------------------------------------------------------------- /Source/Event.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Fodder 3 | * --------------- 4 | * 5 | * Copyright (C) 2008-2018 Open Fodder 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | */ 22 | 23 | #include "stdafx.hpp" 24 | 25 | cEvent::cEvent( const eEventType& pType ) { 26 | 27 | mType = pType; 28 | mButton = 0; 29 | mButtonCount = 0; 30 | } 31 | 32 | cEvent::~cEvent() { 33 | 34 | } 35 | -------------------------------------------------------------------------------- /Source/Event.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Fodder 3 | * --------------- 4 | * 5 | * Copyright (C) 2008-2018 Open Fodder 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | */ 22 | 23 | enum eEventType { 24 | eEvent_None = 0, 25 | eEvent_KeyDown = 1, 26 | eEvent_KeyUp = 2, 27 | eEvent_MouseMove = 3, 28 | eEvent_MouseLeftDown = 4, 29 | eEvent_MouseLeftUp = 5, 30 | eEvent_MouseRightDown = 6, 31 | eEvent_MouseRightUp = 7, 32 | eEvent_MouseWheel = 8, 33 | eEvent_Quit = 10, 34 | #ifdef __VITA__ 35 | eEvent_TouchFrontDown = 20, 36 | eEvent_TouchBackDown = 21, 37 | eEvent_TouchFrontUp = 22, 38 | eEvent_TouchBackUp = 23, 39 | eEvent_TouchFrontMove = 24, 40 | eEvent_TouchBackMove = 25, 41 | #endif 42 | }; 43 | 44 | class cEvent { 45 | public: 46 | eEventType mType; 47 | 48 | unsigned int mButton; 49 | unsigned int mButtonCount; 50 | 51 | cPosition mPosition; 52 | 53 | public: 54 | cEvent( const eEventType& pType = eEvent_None ); 55 | virtual ~cEvent(); 56 | }; 57 | -------------------------------------------------------------------------------- /Source/FontData.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isage/openfodder/6601d9f72cf28a36a0fdfc0782db9f6b4189e206/Source/FontData.cpp -------------------------------------------------------------------------------- /Source/FontData.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Fodder 3 | * --------------- 4 | * 5 | * Copyright (C) 2008-2018 Open Fodder 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | */ 22 | 23 | const extern uint8 mFont_Briefing_Width[]; 24 | const extern uint8 mFont_Recruit_Width[]; 25 | const extern uint8 mFont_Sidebar_Width[]; 26 | const extern uint8 mFont_Underlined_Width[]; 27 | const extern uint8 mFont_Service_Width[]; 28 | const extern uint8 mFont_Intro_Width[]; 29 | const extern uint8 mFont_Service_PalleteIndex[]; 30 | const extern uint8 mFont_Service_PalleteIndex_Amiga[]; 31 | 32 | const extern uint8 mFont_ServiceName_Width[]; 33 | const extern unsigned char mGUI_Font_SpecialCharacters[]; 34 | -------------------------------------------------------------------------------- /Source/GUI_Element.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Fodder 3 | * --------------- 4 | * 5 | * Copyright (C) 2008-2018 Open Fodder 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | */ 22 | 23 | class cFodder; 24 | 25 | struct sGUI_Element { 26 | int16 (cFodder::*field_0)(); 27 | int16 mX; 28 | int16 mWidth; 29 | int16 mY; 30 | int16 mHeight; 31 | void (cFodder::*mMouseInsideFuncPtr)(); // field_c 32 | }; 33 | 34 | struct sGUI_SquadVehicleIcon { 35 | int16 mVehicleType; 36 | int16 mIconID; 37 | }; 38 | 39 | // Menu Buttons 40 | extern const sGUI_Element mAfx_Buttons[]; 41 | extern const sGUI_Element mPlus_Buttons[]; 42 | extern const sGUI_Element mPlusQuiz_Buttons[]; 43 | extern const sGUI_Element mAmigaAction_Buttons[]; 44 | 45 | // Sidebar Squad Icons 46 | extern const int16 mGUI_Squad_Icons[]; 47 | extern const int16 mGUI_Squad_Active_Icons[]; 48 | extern const int16 mGUI_Squad_Inactive_Icons[]; 49 | extern const int16 mGUI_Squad_Split_Icons[]; 50 | extern const sGUI_SquadVehicleIcon mGUI_Squad_Vehicle_Icons[]; 51 | 52 | extern const int8 mGUI_Sidebar_TroopList_Sprite_Modifier[]; 53 | 54 | -------------------------------------------------------------------------------- /Source/Graphics.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Fodder 3 | * --------------- 4 | * 5 | * Copyright (C) 2008-2018 Open Fodder 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | */ 22 | 23 | #include "stdafx.hpp" 24 | 25 | cGraphics::cGraphics() { 26 | 27 | mFodder = g_Fodder; 28 | mSurface = g_Fodder->mSurface; 29 | mImageOriginal = mSurface; 30 | 31 | mImageTemporary.mData->resize(100000); 32 | } 33 | 34 | void cGraphics::SetImage( cSurface* pImage ) { 35 | mSurface = pImage; 36 | } 37 | 38 | void cGraphics::SetImageOriginal() { 39 | 40 | mSurface = mImageOriginal; 41 | } 42 | -------------------------------------------------------------------------------- /Source/IntroData.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Fodder 3 | * --------------- 4 | * 5 | * Copyright (C) 2008-2018 Open Fodder 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | */ 22 | 23 | struct sIntroString { 24 | uint32 mPosition; 25 | const char* mText; 26 | }; 27 | 28 | struct sIntroText { 29 | uint32 mImageNumber; 30 | const sIntroString* mText; 31 | }; 32 | 33 | extern std::vector< sIntroText > mIntroText_PC; 34 | extern std::vector< sIntroText > mIntroText_PC2; 35 | extern std::vector< sIntroText > mIntroText_Amiga; 36 | extern std::vector< sIntroText > mIntroText_Amiga2; 37 | -------------------------------------------------------------------------------- /Source/Map/Map.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Fodder 3 | * --------------- 4 | * 5 | * Copyright (C) 2008-2018 Open Fodder 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | */ 22 | 23 | #include "stdafx.hpp" 24 | 25 | sMapParams::sMapParams(size_t pWidth, size_t pHeight, eTileTypes pTileType, eTileSub pTileSub) { 26 | mTileType = pTileType; 27 | mTileSub = pTileSub; 28 | mWidth = pWidth; 29 | mHeight = pHeight; 30 | } 31 | 32 | sMapParams::sMapParams(size_t pSeed) { 33 | mTileType = eTileTypes_Jungle; 34 | mTileSub = eTileSub_0; 35 | mWidth = 30; 36 | mHeight = 20; 37 | 38 | if (pSeed) 39 | mRandom.setSeed((int16)pSeed); 40 | } 41 | 42 | cMap::cMap() { 43 | mData = std::make_shared>(); 44 | } 45 | 46 | int32 cMap::Tile_Get(const size_t pTileX, const size_t pTileY) { 47 | if (pTileX > mParams.mWidth || pTileY > mParams.mHeight) 48 | return -1; 49 | 50 | size_t Tile = (((pTileY * mParams.mWidth) + pTileX)) + mParams.mWidth; 51 | 52 | uint8* CurrentMapPtr = mData->data() + mTile_Ptr + (Tile * 2); 53 | if (CurrentMapPtr > mData->data() + mData->size()) 54 | return -1; 55 | 56 | return readLE(CurrentMapPtr); 57 | } 58 | 59 | void cMap::Tile_Set(const size_t pTileX, const size_t pTileY, const size_t pTileID) { 60 | if (pTileX > mParams.mWidth || pTileY > mParams.mHeight) 61 | return; 62 | 63 | size_t Tile = (((pTileY * mParams.mWidth) + pTileX)) + mParams.mWidth; 64 | 65 | uint8* CurrentMapPtr = mData->data() + mTile_Ptr + (Tile * 2); 66 | if (CurrentMapPtr > mData->data() + mData->size()) 67 | return; 68 | 69 | writeLEWord(CurrentMapPtr, (uint16)pTileID); 70 | } 71 | 72 | void cMap::Sprite_Add(size_t pSpriteID, size_t pSpriteX, size_t pSpriteY) { 73 | sSprite First; 74 | 75 | First.field_18 = static_cast(pSpriteID); 76 | First.field_0 = static_cast(pSpriteX); 77 | First.field_4 = static_cast(pSpriteY); 78 | First.field_26 = static_cast(pSpriteX); 79 | First.field_28 = static_cast(pSpriteY); 80 | mSprites.push_back(First); 81 | 82 | switch (pSpriteID) { 83 | case eSprite_BoilingPot: // 1 Null 84 | case eSprite_Tank_Human: 85 | case eSprite_VehicleNoGun_Human: 86 | case eSprite_VehicleGun_Human: 87 | case eSprite_VehicleNoGun_Enemy: 88 | case eSprite_VehicleGun_Enemy: 89 | case eSprite_Vehicle_Unk_Enemy: 90 | First.field_18 = eSprite_Null; 91 | mSprites.push_back(First); 92 | break; 93 | 94 | case eSprite_Helicopter_Grenade_Enemy: // 3 Nulls 95 | case eSprite_Helicopter_Grenade2_Enemy: 96 | case eSprite_Helicopter_Missile_Enemy: 97 | case eSprite_Helicopter_Homing_Enemy: 98 | case eSprite_Helicopter_Homing_Enemy2: 99 | First.field_18 = eSprite_Null; 100 | mSprites.push_back(First); 101 | mSprites.push_back(First); 102 | mSprites.push_back(First); 103 | break; 104 | 105 | // Fall Through 106 | case eSprite_Helicopter_Grenade2_Human: // 2 Nulls 107 | case eSprite_Helicopter_Grenade_Human: 108 | case eSprite_Helicopter_Missile_Human: 109 | case eSprite_Helicopter_Homing_Human: 110 | case eSprite_Helicopter_Grenade2_Human_Called: 111 | case eSprite_Helicopter_Grenade_Human_Called: 112 | case eSprite_Helicopter_Missile_Human_Called: 113 | case eSprite_Helicopter_Homing_Human_Called: 114 | case eSprite_Tank_Enemy: 115 | First.field_18 = eSprite_Null; 116 | mSprites.push_back(First); 117 | mSprites.push_back(First); 118 | break; 119 | } 120 | } 121 | 122 | void cMap::Structure_Add(const sStructure& pStructure, size_t pTileX, size_t pTileY) { 123 | 124 | for (const auto& Piece : pStructure.mTiles) { 125 | Tile_Set(pTileX + Piece.mX, pTileY + Piece.mY, Piece.mTileID); 126 | } 127 | 128 | // Add the sprites 129 | for (const auto& Sprite : pStructure.mSprites) { 130 | auto Sheet = &mSpriteSheetTypes_InGame_Amiga[Sprite.mSpriteID][0]; 131 | 132 | // - 0x40 because no sidebar 133 | Sprite_Add(Sprite.mSpriteID, ((pTileX) * 16) + (Sprite.mX - Sheet->mModX), 134 | ((pTileY) * 16) + (Sprite.mY - Sheet->mModY)); 135 | } 136 | } 137 | 138 | void cMap::ClearTiles(const size_t pTileID) { 139 | 140 | mData->resize(0x60 + ((mParams.mWidth * mParams.mHeight) * 2), (uint8)pTileID); 141 | mTile_Ptr = (int32)((0x60) - (mParams.mWidth * 2)); 142 | } 143 | 144 | tSharedBuffer cMap::getData() const { 145 | return mData; 146 | } 147 | 148 | std::vector cMap::getSprites() const { 149 | return mSprites; 150 | } 151 | -------------------------------------------------------------------------------- /Source/Map/Map.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Fodder 3 | * --------------- 4 | * 5 | * Copyright (C) 2008-2018 Open Fodder 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | */ 22 | 23 | struct sSprite; 24 | 25 | struct sMapParams { 26 | size_t mWidth; 27 | size_t mHeight; 28 | eTileTypes mTileType; 29 | eTileSub mTileSub; 30 | cPseudorand mRandom; 31 | 32 | sMapParams(size_t pWidth, size_t pHeight, eTileTypes pTileType, eTileSub pTileSub = eTileSub::eTileSub_0); 33 | sMapParams(size_t pSeed = 0); 34 | 35 | size_t getWidth() { return mWidth; } 36 | void setWidth(const size_t pWidth) { mWidth = pWidth; } 37 | 38 | size_t getHeight() { return mHeight; } 39 | void setHeight(const size_t pHeight) { mHeight = pHeight; } 40 | 41 | eTileTypes getTiletype() { return mTileType; } 42 | void setTiletype(eTileTypes pTiletypes) { mTileType = pTiletypes; } 43 | 44 | eTileSub getTileSub() { return mTileSub; } 45 | void setTileSub(eTileSub pTileSub) { mTileSub = pTileSub; } 46 | 47 | }; 48 | 49 | class cMap { 50 | 51 | protected: 52 | sMapParams mParams; 53 | tSharedBuffer mData; 54 | 55 | int32 mTile_Ptr; 56 | 57 | std::vector mSprites; 58 | 59 | protected: 60 | 61 | int32 Tile_Get(const size_t pTileX, const size_t pTileY); 62 | void Tile_Set(const size_t pTileX, const size_t pTileY, const size_t pTileID); 63 | void Sprite_Add(size_t pSpriteID, size_t pSpriteX, size_t pSpriteY); 64 | void Structure_Add(const sStructure& pStructure, size_t pTileX, size_t pTileY); 65 | 66 | public: 67 | cMap(); 68 | 69 | void ClearTiles(const size_t pTileID); 70 | 71 | sMapParams *getMapParams() { return &mParams; } 72 | eTileTypes getTileType() const { return mParams.mTileType; } 73 | eTileSub getTileSub() const { return mParams.mTileSub; } 74 | 75 | int32 getArea() const { return mParams.mWidth * mParams.mHeight; } 76 | int32 getWidth() const { return static_cast(mParams.mWidth); } 77 | int32 getHeight() const { return static_cast(mParams.mHeight); } 78 | 79 | int32 getAreaPixels() const { return getWidthPixels() * getHeightPixels(); } 80 | int32 getWidthPixels() const { return static_cast(mParams.mWidth) << 4; } 81 | int32 getHeightPixels() const { return static_cast(mParams.mHeight) << 4; } 82 | 83 | virtual bool load(tSharedBuffer pMapFile, tSharedBuffer pSptFile, const bool pCF2) = 0; 84 | virtual bool save(std::string pFilename, const bool CF1) = 0; 85 | 86 | tSharedBuffer getData() const; 87 | std::vector getSprites() const; 88 | }; 89 | -------------------------------------------------------------------------------- /Source/Map/Original.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Fodder 3 | * --------------- 4 | * 5 | * Copyright (C) 2008-2018 Open Fodder 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | */ 22 | 23 | class cOriginalMap : public cMap { 24 | 25 | private: 26 | 27 | void loadCF1Map(tSharedBuffer pMapData); 28 | void loadCF1Spt(tSharedBuffer pSpriteData, bool pCF2); 29 | 30 | bool saveCF1Map(const std::string& pFilename); 31 | bool saveCF1Sprites(std::string pFilename); 32 | 33 | protected: 34 | 35 | void saveHeader(); 36 | void SetTileTypeFromHeader(); 37 | void SetTileTypeInHeader(); 38 | 39 | public: 40 | cOriginalMap() : cMap() {}; 41 | cOriginalMap(tSharedBuffer pMapFile, tSharedBuffer pSptFile, const bool pCF2); 42 | 43 | virtual bool load(tSharedBuffer pMapFile, tSharedBuffer pSptFile, const bool pCF2) override; 44 | virtual bool save(std::string pFilename, const bool CF1) override; 45 | }; 46 | -------------------------------------------------------------------------------- /Source/Map/Random.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Fodder 3 | * --------------- 4 | * 5 | * Copyright (C) 2008-2018 Open Fodder 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | */ 22 | #include "Utils/micropather.h" 23 | 24 | class cScriptingEngine; 25 | 26 | class cRandomMap : public cOriginalMap, public micropather::Graph { 27 | friend class cScriptingEngine; 28 | private: 29 | 30 | protected: 31 | const int8* mPathTilesNotTouchable; 32 | size_t mPathSearchUnitType; 33 | 34 | int Passable(int nx, int ny); 35 | 36 | virtual float LeastCostEstimate(cPosition* nodeStart, cPosition* nodeEnd); 37 | virtual void AdjacentCost(cPosition* node, std::vector< micropather::StateCost > *neighbors); 38 | virtual void PrintStateInfo(cPosition* node); 39 | 40 | public: 41 | cRandomMap(const sMapParams& pParams); 42 | 43 | bool CheckRadiusTileID(std::vector pTileIDs, cPosition* pPosition, int32 pRadius); 44 | bool CheckRadiusFeatures(const std::vector& pType, cPosition* pPosition, int32 pRadius); 45 | bool CheckRadiusSprites(cPosition* pPosition, int32 pRadius); 46 | 47 | void create(size_t pWidth, size_t pHeight, eTileTypes pTileType, eTileSub pTileSub = eTileSub::eTileSub_0); 48 | 49 | std::vector calculatePath(size_t pSpriteType, cPosition* Pos1, cPosition* Pos2); 50 | int32 getSpriteTypeCount(size_t pSpriteType); 51 | std::vector getSpritesByType(size_t pSpriteType); 52 | float getRandomFloat(float pMin, float pMax); 53 | int32 getRandomInt(int32 pMin = 0, int32 pMax = 0); 54 | int16 getSeed() const; 55 | void setSeed(const int16 pSeed); 56 | 57 | cPosition* getRandomXYByTileID(std::vector pTiles, size_t pRadius); 58 | cPosition* getRandomXYByFeatures(std::vector pFeatures, size_t pRadius, bool pIgnoreSprites); 59 | cPosition* getRandomXYByTerrainType(eTerrainFeature pType, size_t pRadius); 60 | 61 | int32 getDistanceBetweenPositions(cPosition* pPos1, cPosition* pPos2); 62 | 63 | std::vector> createDiamondSquare(); 64 | 65 | std::vector> createSimplexIslands(size_t pOctaves, float pRoughness, float pScale, short pSeed, bool pRadialEnabled, float pEdgeFade); 66 | std::vector> createSimplexNoise(size_t pOctaves, float pFrequency, float pLacunarity, float pPersistence); 67 | }; 68 | 69 | -------------------------------------------------------------------------------- /Source/PC/Graphics_PC.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Fodder 3 | * --------------- 4 | * 5 | * Copyright (C) 2008-2018 Open Fodder 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | */ 22 | 23 | const extern sSpriteSheet* mSpriteSheetTypes_InGame_PC[]; 24 | const extern sSpriteSheet* mSpriteSheetTypes_Font_PC[]; 25 | const extern sSpriteSheet* mSpriteSheetTypes_Recruit_PC[]; 26 | const extern sSpriteSheet* mSpriteSheetTypes_Hill_PC[]; 27 | const extern sSpriteSheet* mSpriteSheetTypes_Briefing_PC[]; 28 | const extern sSpriteSheet* mSpriteSheetTypes_Service_PC[]; 29 | 30 | const extern uint8 mUnkStringModifier_Recruit[]; 31 | 32 | class cGraphics_PC : public cGraphics { 33 | int32 mRecruitDestX; 34 | int32 dword_44A3E; 35 | int32 mRecruitDestY; 36 | 37 | uint8* mTile_Gfx_Ptrs[480]; 38 | 39 | sImage mImageRecruit; 40 | tSharedBuffer mBriefing_ParaHeli; 41 | tSharedBuffer mMission_Intro_Gfx_Clouds1; 42 | tSharedBuffer mMission_Intro_Gfx_Clouds2; 43 | tSharedBuffer mMission_Intro_Gfx_Clouds3; 44 | tSharedBuffer mMission_Intro_Gfx_TreesMain; 45 | 46 | uint16 mMission_Intro_DrawX; 47 | uint16 mMission_Intro_DrawY; 48 | 49 | public: 50 | virtual ~cGraphics_PC(); 51 | 52 | virtual uint8* GetSpriteData( uint16 pSegment ); 53 | virtual void Mouse_DrawCursor(); 54 | 55 | virtual void Tile_Prepare_Gfx(); 56 | virtual void Load_pStuff(); 57 | virtual void Load_Sprite_Font(); 58 | virtual void Load_Hill_Data(); 59 | virtual void Load_Service_Data(); 60 | 61 | virtual void Load_And_Draw_Image( const std::string &pFilename, unsigned int pColors, size_t pBackColor); 62 | virtual sImage Decode_Image(const std::string& pFilename, const size_t pCount, const size_t pPaletteOffset, const size_t pStartIndex); 63 | 64 | virtual void Map_Load_Resources(); 65 | virtual void Map_Tile_Draw(cSurface *pTarget, uint16 pTile, uint16 pX, uint16 pY, uint16 pOffset); 66 | virtual void MapTiles_Draw(); 67 | virtual void MapOverview_Render_Tiles( uint16 pTile, uint16 pDestX, uint16 pDestY ); 68 | 69 | virtual void PaletteSetOverview(); 70 | virtual void PaletteSet(cSurface *pTarget); 71 | virtual void PaletteLoad( const uint8 *pBuffer, uint32 pColors, uint32 pColorID = 0 ); 72 | virtual void SetActiveSpriteSheet(eGFX_Types pSpriteType ); 73 | 74 | uint8 Video_Get_Pixel(uint8* pSi, int16 pX, int16 pY); 75 | void Video_Put_Pixel(uint8* pDi, uint8 pAl); 76 | 77 | virtual void Video_Draw_16(const uint8* RowPallete = 0); 78 | virtual void Video_Draw_8(cSurface *pTarget = 0, const uint8* RowPallete = 0); 79 | 80 | virtual void Sidebar_Copy_To_Surface( int16 pStartY ); 81 | virtual void Sidebar_Copy_Sprite_To_ScreenBufPtr( int16 pSpriteType, size_t pX, size_t pY ); 82 | virtual void Sidebar_Copy_ScreenBuffer( uint16 pRow, int16 pRows, int16 pCopyToScreen, uint32*& Data20 ); 83 | 84 | virtual void Recruit_Sprite_Draw( int16 pColumns, int16 pRows, int16 pData8, int16 pData10, int16 pData14, int16 pDataC, uint8* pGraphics ); 85 | 86 | virtual bool Sprite_OnScreen_Check(); 87 | 88 | virtual void Mission_Intro_Load_Resources(const eTileTypes pTileset); 89 | virtual void Mission_Intro_DrawHelicopter( uint16 ); 90 | 91 | virtual void Mission_Intro_Play( const bool pShowHelicopter,const eTileTypes pTileset); 92 | void Mission_Intro( const std::vector& pPositions, const bool pShowHelicopter ); 93 | 94 | void Mission_Intro_Render_2(tSharedBuffer pDs, int16 pCx); 95 | void Mission_Intro_Render_1(tSharedBuffer pDs, int16 pCx); 96 | 97 | void sub_15B98(tSharedBuffer pDs, int16 pCx); 98 | 99 | virtual void Recruit_Draw_Hill(); 100 | virtual void Recruit_Draw_HomeAway(); 101 | }; 102 | -------------------------------------------------------------------------------- /Source/PC/IntroData_PC.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Fodder 3 | * --------------- 4 | * 5 | * Copyright (C) 2008-2018 Open Fodder 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | */ 22 | 23 | #include "Types.hpp" 24 | #include 25 | #include "IntroData.hpp" 26 | 27 | 28 | // Intro_0 has had +0x19 added to each string 29 | const sIntroString mIntro_0[] = { 30 | { 0x5F, "This game is not in any way" }, 31 | { 0x77, "endorsed by the" }, 32 | { 0x91, "ROYAL BRITISH LEGION" }, 33 | { 0, 0 } 34 | }; 35 | 36 | const sIntroString mIntro_1[] = { 37 | { 0xCC, "A Sensible Software Game" }, 38 | { 0, 0 } 39 | }; 40 | 41 | const sIntroString mIntro_2[] = { 42 | { 0x64, "STARRING" }, 43 | { 0, 0 } 44 | }; 45 | 46 | const sIntroString mIntro_3[] = { 47 | { 0xA4, "JOOLS" }, 48 | { 0xB5, "as" }, 49 | { 0xC8, "James Dean" }, 50 | { 0, 0 } 51 | }; 52 | 53 | const sIntroString mIntro_4[] = { 54 | { 0xA4, "STOO" }, 55 | { 0xB4, "as" }, 56 | { 0xC8, "Elvis" }, 57 | { 0, 0 } 58 | }; 59 | 60 | const sIntroString mIntro_5[] = { 61 | { 0xA4, "RICHARD JOSEPH" }, 62 | { 0xB4, "as" }, 63 | { 0xC8, "Sgt. Bilko" }, 64 | { 0, 0 } 65 | }; 66 | 67 | const sIntroString mIntro_6[] = { 68 | { 0x64, "Co. STARRING" }, 69 | { 0, 0 } 70 | }; 71 | 72 | const sIntroString mIntro_7[] = { 73 | { 0xA4, "CHRIS YATES" }, 74 | { 0xB4, "as" }, 75 | { 0xC8, "JR out of Dallas" }, 76 | { 0, 0 } 77 | }; 78 | 79 | const sIntroString mIntro_8[] = { 80 | { 0xA4, "JON HARE" }, 81 | { 0xB5, "as" }, 82 | { 0xC8, "Vera Lynn" }, 83 | { 0, 0 } 84 | }; 85 | 86 | const sIntroString mIntro_9[] = { 87 | { 0x64, "SPECIAL GUEST STAR" }, 88 | { 0, 0 } 89 | }; 90 | 91 | const sIntroString mIntro_10[] = { 92 | { 0xA4, "CHRIS CHAPMAN" }, 93 | { 0xB4, "as" }, 94 | { 0xC8, "Norman Wisdom" }, 95 | { 0, 0 } 96 | }; 97 | 98 | const sIntroString mIntro_11[] = { 99 | { 0x50, "Jools" }, 100 | { 0x8C, "Stoo" }, 101 | { 0x3C, "Program Design" }, 102 | { 0x78, "Graphic Design" }, 103 | { 0, 0 } 104 | }; 105 | 106 | const sIntroString mIntro_12[] = { 107 | { 0x32, "Richard Joseph" }, 108 | { 0x6E, "Jon Hare" }, 109 | { 0xAA, "David Hindley" }, 110 | { 0x1E, "Sound effects and Music" }, 111 | { 0x5A, "Original Soundtrack"}, 112 | { 0x96, "Cameraman" }, 113 | { 0, 0 } 114 | }; 115 | 116 | const sIntroString mIntro_13[] = { 117 | { 0x28, "Steve Cook" }, 118 | { 0x5A, "Graftgold" }, 119 | { 0x8C, "Hammonds Hire" }, 120 | { 0xBE, "Peter Hickman" }, 121 | { 0x19, "Vehicle and Stunts" }, 122 | { 0x46, "Flatbed Scanning" }, 123 | { 0x78, "Costumes" }, 124 | { 0xAA, "Mr Virgin" }, 125 | { 0, 0 } 126 | }; 127 | 128 | const sIntroString mIntro_14[] = { 129 | { 0x19, "An Audio Visual Magic" }, 130 | { 0x2D, "Entertainment Conversion" }, 131 | { 0x4B, "PC Programming" }, 132 | { 0x5F, "Adrian Youlden" }, 133 | { 0x7D, "PC Graphics" }, 134 | { 0x91, "Mark Smith" }, 135 | { 0xAF, "PC Sound and Music" }, 136 | { 0xC3, "Nigel Taylor" }, 137 | { 0, 0 } 138 | }; 139 | 140 | const sIntroString mIntro_15[] = { 141 | { 0x19, "PC Version Produced" }, 142 | { 0x2D, "by" }, 143 | { 0x4B, "Gavin Wade" }, 144 | { 0x5F, "and" }, 145 | { 0x73, "Scott Walsh" }, 146 | { 0, 0 } 147 | }; 148 | 149 | const sIntroString mIntro_16[] = { 150 | { 0xD2, "Sensible Software." }, 151 | { 0xBE, "Designed By" }, 152 | { 0, 0 } 153 | }; 154 | 155 | std::vector< sIntroText > mIntroText_PC = { 156 | { 0xFF, mIntro_0 }, 157 | { 0x31, mIntro_1 }, 158 | { 0xFF, mIntro_2 }, 159 | { 0x32, mIntro_3 }, 160 | { 0x33, mIntro_4 }, 161 | { 0x34, mIntro_5 }, 162 | { 0xFF, mIntro_6 }, 163 | { 0x36, mIntro_7 }, 164 | { 0x35, mIntro_8 }, 165 | { 0xFF, mIntro_9 }, 166 | { 0x37, mIntro_10 }, 167 | { 0xFF, mIntro_11 }, 168 | { 0xFF, mIntro_12 }, 169 | { 0xFF, mIntro_13 }, 170 | { 0xFF, mIntro_14 }, 171 | { 0xFF, mIntro_15 }, 172 | { 0x38, mIntro_16 }, 173 | { 0, 0 } 174 | }; 175 | 176 | std::vector< sIntroText > mIntroText_PC2 = { 177 | { 0, 0 }, 178 | { 0x31, 0 }, 179 | { 0x32, 0 }, 180 | { 0x33, 0 }, 181 | { 0x34, 0 }, 182 | { 0x35, 0 }, 183 | { 0x36, 0 }, 184 | { 0x37, 0 }, 185 | { 0x38, 0 }, 186 | { 0x39, 0 }, 187 | { 0x61, 0 }, 188 | { 0x62, 0 }, 189 | { 0x63, 0 }, 190 | { 0x64, 0 }, 191 | { 0x65, 0 }, 192 | { 0, 0 } 193 | }; 194 | -------------------------------------------------------------------------------- /Source/PC/Resource_PC_CD.hpp: -------------------------------------------------------------------------------- 1 | 2 | class cResource_PC_CD : public cResources { 3 | 4 | tSharedBuffer mData; 5 | uint8* mDataCurrent; 6 | 7 | std::vector< cResource_File > mFiles; 8 | 9 | uint8* mCurPtr; 10 | 11 | int16 word_26DBE[0x273]; 12 | int16 word_272A4[0x13A]; 13 | int16 word_27518[0x273]; 14 | int16 word_279FE[0x273]; 15 | int16 word_27EE4; 16 | uint8 byte_27EE6[0x1A3B]; 17 | static const uint8 byte_29921[0x100]; 18 | static const uint8 byte_29A21[0x101]; 19 | 20 | uint8 data_Read(); 21 | 22 | void sub_26AA4(); 23 | void sub_26B11(); 24 | uint16 sub_26C06(); 25 | uint16 sub_26CDF(); 26 | 27 | uint8 byte_26DB0; 28 | 29 | int16 mBytesRead, word_26DA8; 30 | int32 word_26DBA; 31 | uint16 word_26DAA, word_26DB4, saveSI, saveBP; 32 | 33 | bool headerLoad(); 34 | tSharedBuffer file_Get( cResource_File *pFile, bool pDecode ); 35 | 36 | 37 | public: 38 | 39 | cResource_PC_CD( const std::string& pDataFile ); 40 | virtual ~cResource_PC_CD(); 41 | 42 | virtual tSharedBuffer fileGet( std::string pFilename ); 43 | 44 | std::vector< cResource_File >* filesGet( ) { return &mFiles; } 45 | 46 | void ExtractFiles(); 47 | }; 48 | -------------------------------------------------------------------------------- /Source/PC/Sound_PC.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Fodder 3 | * --------------- 4 | * 5 | * Copyright (C) 2008-2018 Open Fodder 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | */ 22 | 23 | class cSound_PC : public cSound { 24 | bool mSound; 25 | 26 | Mix_Music* mMusicPlaying; 27 | 28 | std::vector mMixerChunks; 29 | 30 | tSharedBuffer * word_42316[7]; 31 | tSharedBuffer dword_42320[0x3C]; 32 | tSharedBuffer dword_42410[0x3C]; 33 | tSharedBuffer dword_42500[0x3C]; 34 | tSharedBuffer dword_425F0[0x3C]; 35 | tSharedBuffer dword_426E0[0x3C]; 36 | 37 | private: 38 | bool devicePrepare(); 39 | void Sound_Voc_Load(); 40 | 41 | public: 42 | 43 | cSound_PC(); 44 | ~cSound_PC(); 45 | 46 | void Sound_Play( int16 pTileset, int16 pSoundEffect, int16 pVolume ); 47 | 48 | void Music_Play( int16 pTrack ); 49 | void Music_PlayFile( const std::string& pFilename ); 50 | void Music_Stop(); 51 | 52 | void MixerChannelFinished( int32 pChannel ); 53 | }; 54 | -------------------------------------------------------------------------------- /Source/PC/Sound_PC2.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Fodder 3 | * --------------- 4 | * 5 | * Copyright (C) 2008-2018 Open Fodder 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | */ 22 | 23 | struct sSoundMap { 24 | int16 mEffectID; 25 | int16 mUnk; 26 | }; 27 | 28 | class cSound_PC2 : public cSound { 29 | bool mSound; 30 | 31 | Mix_Music* mMusicPlaying; 32 | std::vector mMixerChunks; 33 | std::vector mSoundEffects; 34 | 35 | private: 36 | bool devicePrepare(); 37 | void Sound_Voc_Load(); 38 | 39 | public: 40 | 41 | cSound_PC2(); 42 | ~cSound_PC2(); 43 | 44 | void Sound_Play( int16 pBx, int16 pData4, int16 pData8 ); 45 | 46 | void Music_Play( int16 pTrack ); 47 | void Music_PlayFile( const char* pFilename ); 48 | void Music_Stop(); 49 | 50 | void MixerChannelFinished( int32 pChannel ); 51 | }; 52 | -------------------------------------------------------------------------------- /Source/PC/VocTable.hpp: -------------------------------------------------------------------------------- 1 | struct struct_Voc { 2 | uint8 field_0; 3 | uint8 field_1; 4 | const char mFilename[10]; 5 | }; 6 | 7 | const struct_Voc mVocTable[] = { 8 | { 0x09, 0x02, "ALL02.VOC" }, 9 | { 0x09, 0x03, "ALL03.VOC" }, 10 | { 0x09, 0x04, "ALL04.VOC" }, 11 | { 0x09, 0x05, "ALL05.VOC" }, 12 | { 0x09, 0x06, "ALL06.VOC" }, 13 | { 0x09, 0x07, "ALL07.VOC" }, 14 | { 0x09, 0x08, "ALL08.VOC" }, 15 | { 0x09, 0x09, "ALL09.VOC" }, 16 | { 0x09, 0x0B, "ALL11.VOC" }, 17 | { 0x09, 0x0C, "ALL12.VOC" }, 18 | { 0x09, 0x0D, "ALL13.VOC" }, 19 | { 0x09, 0x0F, "ALL15.VOC" }, 20 | { 0x09, 0x10, "ALL16.VOC" }, 21 | { 0x09, 0x11, "ALL17.VOC" }, 22 | { 0x09, 0x12, "ALL18.VOC" }, 23 | { 0x09, 0x13, "ALL19.VOC" }, 24 | { 0x09, 0x14, "ALL20.VOC" }, 25 | { 0x09, 0x15, "ALL21.VOC" }, 26 | { 0x09, 0x16, "ALL22.VOC" }, 27 | { 0x09, 0x2D, "ALL46.VOC" }, // This sound is missing in the original DOS version 28 | { 0x09, 0x2E, "ALL46.VOC" }, 29 | { 0x09, 0x33, "ALL51.VOC" }, 30 | { 0x09, 0x34, "ALL52.VOC" }, 31 | { 0x09, 0x35, "ALL53.VOC" }, 32 | { 0x09, 0x36, "ALL54.VOC" }, 33 | { 0x09, 0x38, "ALL56.VOC" }, 34 | { 0x09, 0x39, "ALL57.VOC" }, 35 | { 0x09, 0x3A, "ALL58.VOC" }, 36 | { 0x09, 0x3B, "ALL59.VOC" }, 37 | 38 | { 0x00, 0x1A, "JUN26.VOC" }, 39 | { 0x00, 0x1B, "JUN27.VOC" }, 40 | { 0x00, 0x1C, "JUN28.VOC" }, 41 | 42 | { 0x01, 0x1A, "DES26.VOC" }, 43 | { 0x02, 0x1A, "ICE26.VOC" }, 44 | 45 | { 0x02, 0x1E, "ICE30.VOC" }, 46 | { 0x02, 0x1F, "ICE31.VOC" }, 47 | 48 | { 0x03, 0x1A, "MOR26.VOC" }, 49 | { 0x03, 0x1C, "MOR28.VOC" }, 50 | 51 | { 0x04, 0x1A, "INT26.VOC" }, 52 | { 0xFF, 0xFF, "" } 53 | }; 54 | -------------------------------------------------------------------------------- /Source/Parameters.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Fodder 3 | * --------------- 4 | * 5 | * Copyright (C) 2008-2018 Open Fodder 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | */ 22 | 23 | namespace cxxopts { 24 | class Options; 25 | } 26 | 27 | class sFodderParameters { 28 | public: 29 | static cxxopts::Options* mCliOptions; 30 | 31 | bool mAppVeyor; // Running on AppVeyor 32 | bool mShowAbout; // Show the about screen 33 | bool mSkipIntro; // Skip the OpenFodder intro, and the game intro 34 | bool mSkipRecruit; // Skip the recruit screen and go straight into the mission 35 | bool mSkipBriefing; // Skip mission briefing 36 | bool mSkipService; // Skip mission debrief 37 | 38 | bool mMouseAlternative; // Use the alternate mouse behaviour 39 | bool mWindowMode; // Start in a window 40 | size_t mWindowScale; // Start with window scaled at 41 | size_t mWindowRows; 42 | size_t mWindowColumns; 43 | 44 | bool mRandom; // Start a random map 45 | bool mRandomSave; // Create a random map 46 | std::string mRandomFilename;// Name to save random map as 47 | 48 | std::string mScriptRun; // Name of a script to run 49 | 50 | ePlatform mDefaultPlatform; // Default platform to use 51 | eGame mDefaultGame; // Default game to use for single/random 52 | 53 | bool mDemoRecord; // Recording a demo 54 | bool mDemoPlayback; // Playing back a demo 55 | size_t mDemoRecordResumeCycle; // Record a demo, after playing back the event queue up until this cycle 56 | std::string mDemoFile; // The Demo file to save/load to/from 57 | 58 | int64 mSleepDelta; // Engine sleep delta 59 | 60 | std::string mSingleMap; // Name of single map to load 61 | std::string mCampaignName; // Campaign to start 62 | size_t mMissionNumber; // Mission to start on 63 | size_t mPhaseNumber; // Phase to start on 64 | 65 | bool mCheatsEnabled; 66 | bool mUnitTesting; // Execute unit testing 67 | bool mSinglePhase; // Play a single phase 68 | bool mPlayground; // Launch into the sprite playground 69 | 70 | bool mDisableVideo; // Disable all video output 71 | bool mDisableSound; // Disable all sound 72 | 73 | bool mDebugger; 74 | 75 | size_t mSpritesMax; 76 | size_t mSpawnEnemyMax; 77 | 78 | bool mShowHelp; 79 | 80 | #ifdef __VITA__ 81 | bool mTouchFront; 82 | bool mTouchBack; 83 | #endif 84 | 85 | sFodderParameters() { 86 | clear(); 87 | } 88 | 89 | virtual ~sFodderParameters() { 90 | } 91 | 92 | virtual void clear() { 93 | 94 | mDebugger = false; 95 | 96 | mShowHelp = false; 97 | mShowAbout = false; 98 | mPlayground = false; 99 | mDisableSound = false; 100 | mDisableVideo = false; 101 | mSleepDelta = 2; 102 | 103 | mAppVeyor = false; 104 | mSkipService = false; 105 | mSkipBriefing = false; 106 | mSkipIntro = false; 107 | mSkipRecruit = false; 108 | 109 | mMissionNumber = 0; 110 | mPhaseNumber = 0; 111 | mMouseAlternative = false; 112 | mWindowMode = false; 113 | mWindowScale = 0; 114 | 115 | mWindowRows = 0; 116 | mWindowColumns = 0; 117 | 118 | mRandom = false; 119 | mRandomSave = false; 120 | 121 | mDefaultPlatform = ePlatform::Any; 122 | mDefaultGame = eGame::CF1; 123 | 124 | mDemoRecord = false; 125 | mDemoPlayback = false; 126 | mDemoRecordResumeCycle = 0; 127 | 128 | mCheatsEnabled = false; 129 | mUnitTesting = false; 130 | mSinglePhase = false; 131 | mSpritesMax = 45; 132 | mSpawnEnemyMax = 10; 133 | #ifdef __VITA__ 134 | mTouchFront = false; 135 | mTouchBack = false; 136 | #endif 137 | } 138 | 139 | protected: 140 | virtual void PrepareOptions(); 141 | virtual bool ProcessCLI(int argc, char *argv[]); 142 | bool ProcessINI(); 143 | 144 | 145 | public: 146 | std::string ToJson(); 147 | bool FromJson(const std::string& pJson); 148 | 149 | void Process(int argc, char *argv[]) { 150 | ProcessINI(); 151 | ProcessCLI(argc, argv); 152 | } 153 | 154 | bool isOriginalSpriteMax() const { return mSpritesMax == 45; } 155 | }; 156 | -------------------------------------------------------------------------------- /Source/Position.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Fodder 3 | * --------------- 4 | * 5 | * Copyright (C) 2008-2018 Open Fodder 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | */ 22 | 23 | class cPosition { 24 | public: 25 | int32 mX, mY; 26 | 27 | public: 28 | cPosition() : mX( 0 ), mY( 0 ) {} 29 | cPosition( unsigned int pX, unsigned int pY ) : mX( pX ), mY( pY ) {} 30 | 31 | void Set( unsigned int pX, unsigned int pY ) { mX = pX; mY = pY; } 32 | void Clear() { mX = 0; mY = 0; } 33 | 34 | int32 distanceTo(const cPosition& pPosition) const { 35 | 36 | int32 X = mX - pPosition.mX; 37 | int32 Y = mY - pPosition.mY; 38 | 39 | if (X < 0) 40 | X = -X; 41 | if (Y < 0) 42 | Y = -Y; 43 | 44 | return X + Y; 45 | } 46 | 47 | bool operator== (const cPosition& pPosition) const { 48 | 49 | return pPosition.mX == mX && pPosition.mY == mY; 50 | 51 | } 52 | 53 | bool operator!= (const cPosition& pPosition) const { 54 | 55 | return !(*this == pPosition); 56 | 57 | } 58 | cPosition& operator+= (const cPosition& pPosition) { 59 | 60 | mX += pPosition.mX; 61 | mY += pPosition.mY; 62 | 63 | return *this; 64 | } 65 | 66 | cPosition& operator-= (const cPosition& pPosition) { 67 | 68 | mX -= pPosition.mX; 69 | mY -= pPosition.mY; 70 | 71 | return *this; 72 | } 73 | 74 | cPosition operator-(const cPosition& pPosition) const { 75 | 76 | return cPosition( mX - pPosition.mX, mY - pPosition.mY ); 77 | } 78 | 79 | cPosition operator+(const cPosition& pPosition) const { 80 | 81 | return cPosition(mX + pPosition.mX, mY + pPosition.mY); 82 | } 83 | 84 | cPosition* operator*(const size_t pMultiplier) { 85 | mX *= pMultiplier; 86 | mY *= pMultiplier; 87 | 88 | return this; 89 | } 90 | 91 | bool operator<(const cPosition& pRight) const { 92 | 93 | if (mY < pRight.mY) 94 | return true; 95 | 96 | return mX < pRight.mX; 97 | } 98 | int getY() const { return (int) mY; } 99 | void setY(int pY) { mY = pY; } 100 | 101 | int getX() const { return (int) mX; } 102 | void setX(int pX) { mX = pX; } 103 | inline int16 x() const { 104 | return (int16)mX; 105 | } 106 | 107 | inline int16 y() const { 108 | return (int16)mY; 109 | } 110 | }; 111 | -------------------------------------------------------------------------------- /Source/Recruits.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Fodder 3 | * --------------- 4 | * 5 | * Copyright (C) 2008-2018 Open Fodder 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | */ 22 | 23 | struct sRecruit { 24 | char mName[7]; 25 | 26 | uint8 field_6; 27 | int8 field_7; 28 | int8 field_8; 29 | }; 30 | 31 | struct sRecruit_Sprites { 32 | int16 mSpriteType; 33 | int16 mFrame; 34 | int16 field_4; 35 | int16 field_6; 36 | int16* field_8; 37 | }; 38 | 39 | struct sRecruit_Screen_Pos { 40 | int16 mX; 41 | int16 mY; 42 | int16 mFrame; 43 | }; 44 | 45 | struct sRecruitRendered { 46 | uint32* mDataPtr; 47 | int16 mPosition; 48 | 49 | sRecruitRendered(uint32* pDataPtr, int16 pPosition) { 50 | mDataPtr = pDataPtr; 51 | mPosition = pPosition; 52 | } 53 | }; 54 | 55 | struct sGravePosition { 56 | int16 mX; 57 | int16 mY; 58 | }; 59 | 60 | extern const std::vector mGravePositions; 61 | extern const struct sRecruit mRecruits[]; 62 | extern const struct sRecruit_Sprites mRecruitSprite[34]; 63 | extern struct sRecruit_Screen_Pos mRecruit_Screen_Positions[294]; 64 | 65 | extern const int16 mRecruit_Truck_Anim_Welcome[]; 66 | extern const int16 mRecruit_Truck_Anim_SwingArm[]; 67 | extern const int16 mRecruit_Truck_Anim_PassTroop[]; 68 | extern const int16 mRecruit_Truck_Anim_CloseDoor[]; 69 | 70 | extern const int16 mRecruit_Shirt_Colors[]; 71 | extern const int16 mRecruit_Hill_Position_Gaps[]; 72 | -------------------------------------------------------------------------------- /Source/ResourceMan.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Fodder 3 | * --------------- 4 | * 5 | * Copyright (C) 2008-2018 Open Fodder 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | */ 22 | 23 | class cResourceMan { 24 | typedef std::map tStringMap; 25 | 26 | std::vector mAllPaths; 27 | std::vector mValidPaths; 28 | 29 | std::map mReleasePath; 30 | std::map mCampaigns; 31 | 32 | std::map mMaps; 33 | std::map mSaves; 34 | std::map mTests; 35 | 36 | std::multimap mReleaseFiles; 37 | 38 | std::string mCustomMapPath; 39 | 40 | protected: 41 | void addBaseDir(std::string pPath); 42 | void addDefaultDirs(); 43 | void validatePaths(); 44 | 45 | 46 | std::string FileMD5(const std::string& pFile); 47 | 48 | void findCampaigns(); 49 | void findVersions(); 50 | void findSaves(); 51 | void findCustomMaps(); 52 | 53 | public: 54 | 55 | cResourceMan(); 56 | 57 | void addDir(const std::string& pPath); 58 | 59 | void refresh(); 60 | 61 | std::string FindVersionPath(const sGameVersion* pVersion) const; 62 | std::string GetFilePath(const sGameVersion* pVersion, std::string pFile) const; 63 | 64 | tSharedBuffer FileRead(const std::string& pFile); 65 | std::string FileReadStr(const std::string& pFile); 66 | 67 | std::string PathGenerate(const std::string& pFile, eDataType pDataType) const; 68 | 69 | std::string GetAboutFile() const; 70 | std::string GetWavPath(const std::string& pFile) const; 71 | 72 | std::string GetCampaignData(const std::string& pName); 73 | std::string GetMapPath(const std::string& pName) const; 74 | 75 | std::string GetSave(const std::string &pName) const; 76 | std::string GetSaveNewName() const; 77 | 78 | std::string GetTestPath(const sGameVersion* pVersion, const std::string pFile) const; 79 | std::string GetScriptPath(const std::string& pType) const; 80 | 81 | std::vector GetAvailable() const; 82 | std::vector GetCampaigns() const; 83 | std::vector GetSaves() const; 84 | std::vector GetMaps() const; 85 | 86 | bool isCampaignAvailable(std::string pName) const; 87 | bool isDataAvailable() const; 88 | 89 | std::vector getValidPaths() const; 90 | std::vector getAllPaths() const; 91 | 92 | std::string getCustomMapPath() const { return mCustomMapPath; } 93 | 94 | 95 | std::vector DirectoryList(const std::string& pPath, const std::string& pExtension); 96 | bool FileExists(const std::string& pPath) const; 97 | 98 | std::string getcwd(); 99 | 100 | }; -------------------------------------------------------------------------------- /Source/Resources.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Fodder 3 | * --------------- 4 | * 5 | * Copyright (C) 2008-2018 Open Fodder 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | */ 22 | 23 | #include "stdafx.hpp" 24 | #include "Amiga/dernc.hpp" 25 | 26 | cResources::cResources( ) { 27 | 28 | } 29 | 30 | tSharedBuffer cResources::fileGet( std::string pFilename ) { 31 | auto File = g_ResourceMan->FileRead(g_Fodder->mVersionCurrent->getDataFilePath(pFilename)); 32 | 33 | if (File->size()) { 34 | 35 | return fileDeRNC(File); 36 | } 37 | return File; 38 | } 39 | 40 | tSharedBuffer cResources::fileDeRNC(tSharedBuffer pBuffer) { 41 | uint32 Header = readBEDWord(pBuffer->data()); 42 | if (Header != 'RNC\01') 43 | return pBuffer; 44 | 45 | uint32 Size = readBEDWord(pBuffer->data() + 4); 46 | 47 | auto Unpacked = std::make_shared>(); 48 | Unpacked->resize(Size); 49 | rnc_unpack(pBuffer->data(), Unpacked->data()); 50 | return Unpacked; 51 | } 52 | 53 | size_t cResources::fileLoadTo( const std::string& pFilename, uint8* pTarget ) { 54 | 55 | auto File = fileGet( pFilename ); 56 | 57 | if (File->size()) { 58 | std::memcpy( pTarget, File->data(), File->size() ); 59 | return File->size(); 60 | } 61 | 62 | return false; 63 | } 64 | -------------------------------------------------------------------------------- /Source/Resources.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Fodder 3 | * --------------- 4 | * 5 | * Copyright (C) 2008-2018 Open Fodder 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | */ 22 | 23 | class cSurface; 24 | 25 | struct cResource_File { 26 | std::string mName; 27 | uint32 mAddressStart; 28 | uint32 mSize; 29 | 30 | cResource_File( std::string pName, uint32 pStart, uint32 pEnd ) : 31 | mName( pName ), mAddressStart( pStart ), mSize( pEnd ) { } 32 | 33 | }; 34 | 35 | class cResources { 36 | protected: 37 | 38 | tSharedBuffer fileDeRNC(tSharedBuffer pBuffer); 39 | 40 | public: 41 | cResources( ); 42 | virtual ~cResources() { }; 43 | 44 | virtual tSharedBuffer fileGet( std::string pFilename ); 45 | 46 | size_t fileLoadTo( const std::string& pFilename, uint8* pTarget ); 47 | }; 48 | -------------------------------------------------------------------------------- /Source/ScriptingEngine.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Fodder 3 | * --------------- 4 | * 5 | * Copyright (C) 2008-2018 Open Fodder 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | */ 22 | 23 | struct duk_hthread; 24 | class cRandomMap; 25 | 26 | class cScriptFileIO { 27 | std::fstream mStream; 28 | 29 | public: 30 | cScriptFileIO(std::string pFilename, bool pRead = false); 31 | ~cScriptFileIO(); 32 | 33 | bool isOpen(); 34 | void close(); 35 | std::string readLine(); 36 | void writeLine(std::string pStr); 37 | }; 38 | 39 | class cScriptingEngine { 40 | duk_hthread *mContext; 41 | 42 | protected: 43 | 44 | cCampaign* getCampaign(); 45 | std::shared_ptr getMap(); 46 | std::shared_ptr getPhase(); 47 | std::shared_ptr getMission(); 48 | 49 | std::shared_ptr phaseCreate(); 50 | std::shared_ptr missionCreate(); 51 | 52 | void guiPrintString(const std::string& pText, const size_t pX, const size_t pY, const bool pLarge, const bool pUnderline); 53 | 54 | void mapSave(); 55 | 56 | 57 | bool scriptCall(const std::string& pFilename); 58 | bool scriptRun(const std::string& pJS, const std::string& pFilename); 59 | bool scriptsLoadFolder(const std::string& pFolder); 60 | void spritesCreateObject(); 61 | 62 | public: 63 | 64 | cScriptingEngine(); 65 | ~cScriptingEngine(); 66 | 67 | void init(); 68 | void debuggerEnable(); 69 | duk_hthread *getContext() { return mContext; } 70 | 71 | bool Run(const std::string& pScript); 72 | }; -------------------------------------------------------------------------------- /Source/Sound.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Fodder 3 | * --------------- 4 | * 5 | * Copyright (C) 2008-2018 Open Fodder 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | */ 22 | 23 | #include "stdafx.hpp" 24 | 25 | cSound::cSound() { 26 | 27 | } -------------------------------------------------------------------------------- /Source/Sound.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Fodder 3 | * --------------- 4 | * 5 | * Copyright (C) 2008-2018 Open Fodder 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | */ 22 | 23 | enum eSound_Effect { 24 | eSound_Effect_Grenade = 0x0F, 25 | eSound_Effect_BuildingDoor2 = 0x10, 26 | eSound_Effect_DoorCloseDoor = 0x29, 27 | eSound_Effect_Spear = 0x2A, 28 | eSound_Effect_Vehicle_Sinking = 0x2B, 29 | eSound_Effect_Turret_Fire = 0x2C, 30 | eSound_Effect_Missile_Launch = 0x2D, 31 | eSound_Effect_Rocket = 0x2E, 32 | }; 33 | 34 | struct sChunkPlaying { 35 | int32 mChannel; 36 | Mix_Chunk* mCurrentChunk; 37 | }; 38 | 39 | class cSound { 40 | 41 | virtual bool devicePrepare() = 0; 42 | 43 | public: 44 | 45 | cSound(); 46 | virtual ~cSound() { }; 47 | 48 | virtual void Sound_Play( int16 pTileset, int16 pSoundEffect, int16 pVolume ) = 0; 49 | virtual void Sound_Stop() { } 50 | 51 | virtual void Music_Play( int16 pTrack ) = 0; 52 | virtual void Music_Stop() = 0; 53 | 54 | virtual void Stop() { 55 | Music_Stop(); 56 | Sound_Stop(); 57 | } 58 | }; 59 | -------------------------------------------------------------------------------- /Source/SpriteSheet.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Fodder 3 | * --------------- 4 | * 5 | * Copyright (C) 2008-2018 Open Fodder 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | */ 22 | 23 | #include "stdafx.hpp" 24 | 25 | uint8* sSpriteSheet::GetGraphicsPtr() const { 26 | 27 | return g_Fodder->mGraphics->GetSpriteData(mLoadSegment) + mLoadOffset; 28 | } 29 | 30 | uint8* sSpriteSheet_pstuff::GetGraphicsPtr(uint16 pOffset) const { 31 | 32 | return g_Fodder->mGraphics->GetSpriteData( eGFX_PSTUFF ) + pOffset; 33 | } 34 | -------------------------------------------------------------------------------- /Source/SpriteSheet.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Fodder 3 | * --------------- 4 | * 5 | * Copyright (C) 2008-2018 Open Fodder 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | */ 22 | 23 | struct sSpriteSheet { 24 | uint16 mLoadOffset; 25 | uint16 mLoadSegment; 26 | int16 field_4; 27 | int16 field_6; 28 | int16 mColCount; 29 | int16 mRowCount; 30 | int16 mPalleteIndex; 31 | int8 mModX; 32 | int8 mModY; 33 | 34 | uint8* GetGraphicsPtr() const; 35 | }; 36 | 37 | struct sSpriteSheet_pstuff { 38 | int16 mX; 39 | int16 mY; 40 | int16 mColumns; 41 | int16 mRows; 42 | 43 | uint8* GetGraphicsPtr(uint16 pOffset) const; 44 | }; -------------------------------------------------------------------------------- /Source/Start.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Fodder 3 | * --------------- 4 | * 5 | * Copyright (C) 2008-2018 Open Fodder 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | */ 22 | 23 | #include "stdafx.hpp" 24 | 25 | #ifndef _OFED 26 | #ifndef _OFBOT 27 | 28 | int start(int argc, char *argv[]) { 29 | g_Debugger = std::make_shared(); 30 | g_Window = std::make_shared(); 31 | g_ResourceMan = std::make_shared(); 32 | g_Fodder = std::make_shared(g_Window); 33 | 34 | auto Params = std::make_shared(); 35 | Params->Process(argc, argv); 36 | 37 | if (Params->mShowHelp) 38 | return 0; 39 | 40 | g_Fodder->Prepare(Params); 41 | 42 | if (g_Fodder->mStartParams->mUnitTesting) { 43 | cUnitTesting Testing; 44 | return Testing.Start() ? 0 : -1; 45 | } 46 | else if (g_Fodder->mStartParams->mRandomSave) { 47 | g_Fodder->CreateRandom(); 48 | } 49 | else { 50 | g_Fodder->Start(); 51 | g_Fodder->mGame_Data.mDemoRecorded.save(); 52 | } 53 | 54 | return 0; 55 | } 56 | 57 | // Debug stuff 58 | void quickServiceScreen() { 59 | g_Fodder->VersionSwitch(g_Fodder->mVersions->GetRetail(g_Fodder->mParams->mDefaultPlatform, g_Fodder->mParams->mDefaultGame)); 60 | g_Fodder->mGame_Data.mCampaign.Clear(); 61 | g_Fodder->mGame_Data.mCampaign.LoadCampaign("Cannon Fodder", false); 62 | 63 | g_Fodder->Game_Setup(); 64 | g_Fodder->Map_Load(); 65 | g_Fodder->Map_Load_Sprites(); 66 | 67 | //g_Fodder->Phase_Prepare(); 68 | g_Fodder->Phase_Soldiers_Count(); 69 | g_Fodder->mGame_Data.Soldier_Sort(); 70 | g_Fodder->Phase_Soldiers_Prepare(false); 71 | g_Fodder->Phase_Soldiers_AttachToSprites(); 72 | g_Fodder->Service_Show(); 73 | } 74 | 75 | 76 | #endif 77 | #endif 78 | -------------------------------------------------------------------------------- /Source/Start_Emscripten.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Fodder 3 | * --------------- 4 | * 5 | * Copyright (C) 2008-2018 Open Fodder 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | */ 22 | 23 | #ifdef EMSCRIPTEN 24 | #include "stdafx.hpp" 25 | cAbout* About = 0; 26 | 27 | void phase_loop(); 28 | void menu_loop() { 29 | static int16 result = -1; 30 | if (result == -1) { 31 | 32 | g_Fodder->VersionSwitch(g_Fodder->mVersions->GetForCampaign("Amiga Format Christmas Special")); 33 | g_Fodder->mGame_Data.mCampaign.Clear(); 34 | 35 | result = 0; 36 | g_Fodder->Campaign_Select_Setup(); 37 | return; 38 | } 39 | 40 | if (About) { 41 | 42 | if (About->Cycle()) { 43 | g_Fodder->mWindow->RenderAt(g_Fodder->mSurface); 44 | g_Fodder->mWindow->FrameEnd(); 45 | g_Fodder->Cycle_End(); 46 | return; 47 | } 48 | 49 | delete About; 50 | About = 0; 51 | g_Fodder->mGUI_SaveLoadAction = 0; 52 | result = -1; 53 | return; 54 | } 55 | 56 | g_Fodder->Campaign_Select_File_Cycle("OPEN FODDER", "SELECT CAMPAIGN"); 57 | if(g_Fodder->mGUI_SaveLoadAction == 3 || g_Fodder->mGUI_SaveLoadAction == 0) { 58 | return; 59 | } 60 | if (g_Fodder->mGUI_SaveLoadAction == 4) { 61 | g_Fodder->mGUI_SaveLoadAction = 0; 62 | About = new cAbout(); 63 | return; 64 | } 65 | 66 | g_Fodder->mPhase_Aborted = false; 67 | g_Fodder->mPhase_In_Progress = false; 68 | 69 | std::string Campaign = g_Fodder->mCampaignList[g_Fodder->mGUI_Select_File_CurrentIndex + g_Fodder->mGUI_Select_File_SelectedFileIndex]; 70 | if (g_Fodder->mGUI_SaveLoadAction == 1) 71 | Campaign = ""; 72 | 73 | g_Fodder->VersionSwitch(g_Fodder->mVersions->GetForCampaign(Campaign)); 74 | g_Fodder->mGame_Data.mCampaign.LoadCampaign(Campaign, Campaign != g_Fodder->mVersionCurrent->mName); 75 | g_Fodder->Game_Setup(); 76 | 77 | result = -1; 78 | emscripten_cancel_main_loop(); 79 | emscripten_set_main_loop(phase_loop, 24, 1); 80 | } 81 | 82 | void phase_loop() { 83 | static int16 result = -1; 84 | 85 | // No recruits left? 86 | if (result != 1) { 87 | if (!g_Fodder->mGame_Data.mRecruits_Available_Count) { 88 | emscripten_cancel_main_loop(); 89 | emscripten_set_main_loop(menu_loop, 24, 1); 90 | 91 | result = -1; 92 | } 93 | } 94 | 95 | if (result == 0) { 96 | // Game Won? 97 | if (!g_Fodder->mGame_Data.Phase_Next()) { 98 | emscripten_cancel_main_loop(); 99 | emscripten_set_main_loop(menu_loop, 24, 1); 100 | // Break to version screen 101 | return; 102 | } 103 | result = -1; 104 | } 105 | 106 | if (result == -1) { 107 | if (g_Fodder->mPhase_Aborted2) { 108 | g_Fodder->mPhase_Aborted2 = false; 109 | emscripten_cancel_main_loop(); 110 | emscripten_set_main_loop(menu_loop, 24, 1); 111 | return; 112 | } 113 | g_Fodder->Phase_EngineReset(); 114 | g_Fodder->Phase_SquadPrepare(); 115 | g_Fodder->Phase_Prepare(); 116 | } 117 | 118 | // -1 = Phase Try Again 119 | // 0 = Phase Won 120 | // 1 = Phase Running 121 | 122 | result = g_Fodder->Phase_Cycle(); 123 | g_Fodder->Cycle_End(); 124 | } 125 | 126 | int start(int argc, char *argv[]) { 127 | 128 | g_Debugger = std::make_shared(); 129 | g_Window = std::make_shared(); 130 | g_ResourceMan = std::make_shared(); 131 | g_Fodder = std::make_shared(g_Window); 132 | 133 | auto Params = std::make_shared(); 134 | Params->Process(argc, argv); 135 | 136 | if (Params->mShowHelp) 137 | return 0; 138 | 139 | Params->mCheatsEnabled = true; 140 | Params->mMouseAlternative = true; 141 | g_Fodder->Prepare(Params); 142 | g_Fodder->Phase_SquadPrepare(); 143 | 144 | emscripten_set_main_loop(menu_loop, 24, 1); 145 | 146 | //g_Fodder->Service_Show(); 147 | 148 | return 0; 149 | } 150 | 151 | #endif 152 | -------------------------------------------------------------------------------- /Source/Structures/Barracks.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Fodder 3 | * --------------- 4 | * 5 | * Copyright (C) 2008-2018 Open Fodder 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | */ 22 | 23 | #include "stdafx.hpp" 24 | 25 | const std::vector mStructuresBarracksWithSoldier = { 26 | 27 | // Jungle 28 | { 29 | { 30 | { 1, 0, 333 }, 31 | { 2, 0, 334 }, 32 | 33 | { 0, 1, 352 }, 34 | { 1, 1, 353 }, 35 | { 2, 1, 354 }, 36 | 37 | { 0, 2, 372 }, 38 | { 1, 2, 373 }, 39 | { 2, 2, 374 }, 40 | { 3, 2, 375 }, 41 | 42 | { 0, 3, 392 }, 43 | { 1, 3, 393 }, 44 | { 2, 3, 394 }, 45 | }, 46 | 47 | { 48 | { 13, 18, eSprite_BuildingRoof }, 49 | { 9, 50, eSprite_BuildingDoor } 50 | }, 51 | }, 52 | 53 | // Ice 54 | { 55 | { 56 | { 1, 0, 245 }, 57 | { 2, 0, 246 }, 58 | { 3, 0, 247 }, 59 | 60 | { 0, 1, 264 }, 61 | { 1, 1, 265 }, 62 | { 2, 1, 266 }, 63 | { 3, 1, 267 }, 64 | 65 | { 0, 2, 284 }, 66 | { 1, 2, 285 }, 67 | { 2, 2, 286 }, 68 | { 3, 2, 287 }, 69 | }, 70 | { 71 | { 23, 11, eSprite_BuildingRoof }, 72 | { 20, 43, eSprite_BuildingDoor } 73 | }, 74 | }, 75 | 76 | 77 | // Desert 78 | { 79 | { 80 | { 0, 0, 196 }, 81 | { 1, 0, 197 }, 82 | { 2, 0, 198 }, 83 | 84 | { 0, 1, 216 }, 85 | { 1, 1, 217 }, 86 | { 2, 1, 218 }, 87 | 88 | { 0, 2, 236 }, 89 | { 1, 2, 237 }, 90 | { 2, 2, 238 }, 91 | }, 92 | { 93 | { 12, 1, eSprite_BuildingRoof }, 94 | { 7, 32, eSprite_BuildingDoor } 95 | }, 96 | }, 97 | 98 | 99 | // Moors 100 | { 101 | { 102 | { 1, 0, 335 }, 103 | { 2, 0, 336 }, 104 | 105 | { 0, 1, 354 }, 106 | { 1, 1, 355 }, 107 | { 2, 1, 356 }, 108 | 109 | { 0, 2, 374 }, 110 | { 1, 2, 375 }, 111 | { 2, 2, 376 }, 112 | 113 | { 0, 3, 394 }, 114 | { 1, 3, 395 }, 115 | { 2, 3, 396 }, 116 | }, 117 | { 118 | { 15, 17, eSprite_BuildingRoof }, 119 | { 7, 49, eSprite_BuildingDoor } 120 | }, 121 | }, 122 | 123 | 124 | // Int 125 | { 126 | { 127 | { 0, 0, 246 }, 128 | { 0, 1, 266 } 129 | }, 130 | { 131 | { 3, 21, eSprite_BuildingDoor } 132 | }, 133 | }, 134 | 135 | // HID 136 | { 137 | { 138 | { 0, 0, 246 }, 139 | { 0, 1, 266 } 140 | }, 141 | { 142 | { 3, 21, eSprite_BuildingDoor } 143 | }, 144 | }, 145 | 146 | // AFX 147 | { 148 | { 149 | { 0, 0, 371 }, 150 | { 1, 0, 372 }, 151 | { 2, 0, 373 }, 152 | 153 | { 0, 1, 391 }, 154 | { 1, 1, 392 }, 155 | { 2, 1, 393 }, 156 | 157 | { 0, 2, 375 }, 158 | { 1, 2, 376 }, 159 | { 2, 2, 377 }, 160 | 161 | { 0, 3, 395 }, 162 | { 1, 3, 396 }, 163 | { 2, 3, 397 }, 164 | }, 165 | { 166 | { 21, 56, eSprite_BuildingDoor } 167 | }, 168 | }, 169 | }; 170 | -------------------------------------------------------------------------------- /Source/Structures/Barracks.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Fodder 3 | * --------------- 4 | * 5 | * Copyright (C) 2008-2018 Open Fodder 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | */ 22 | 23 | extern const std::vector mStructuresBarracksWithSoldier; 24 | -------------------------------------------------------------------------------- /Source/Surface.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Fodder 3 | * --------------- 4 | * 5 | * Copyright (C) 2008-2018 Open Fodder 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | */ 22 | 23 | const size_t g_MaxColors = 0xFF; 24 | 25 | class cPalette { 26 | public: 27 | uint8 mRed; 28 | uint8 mGreen; 29 | uint8 mBlue; 30 | 31 | cPalette() { mRed = 0; mGreen = 0; mBlue = 0; } 32 | 33 | uint8 getPos( size_t i ) { if (i == 0) return mRed; if (i == 1) return mGreen; if (i == 2) return mBlue; return 0; } 34 | void setPos( size_t i, uint8 pval ) { 35 | if( i == 0 ) 36 | mRed = pval; 37 | if( i == 1 ) 38 | mGreen = pval; 39 | if( i == 2 ) 40 | mBlue = pval; 41 | } 42 | }; 43 | 44 | 45 | class cSurface { 46 | protected: 47 | bool mIsLoadedImage; 48 | cPalette mPalette[ g_MaxColors ]; 49 | cPalette mPaletteNew[ g_MaxColors ]; 50 | 51 | uint32 mPaletteSDL[ g_MaxColors ]; 52 | 53 | uint8* mSurfaceBuffer; // Loaded Image (uses palette indexs) 54 | uint8* mSurfaceBufferSaved; 55 | size_t mSurfaceBufferSize; 56 | 57 | SDL_Surface* mSDLSurface; 58 | SDL_Texture* mTexture; 59 | 60 | size_t mWidth, mHeight; 61 | bool mPaletteAdjusting; 62 | 63 | 64 | void clearSDLSurface(uint32 pColor = 0); // Clear the surface 65 | 66 | void paletteSDLColorSet( size_t id, cPalette *pPalette ); // Set a color in the palette 67 | 68 | 69 | public: 70 | void surfaceSetToPalette(); 71 | void surfaceSetToPaletteNew(); 72 | cSurface( size_t pWidth, size_t pHeight ); 73 | cSurface( const cDimension& pDimension ); 74 | ~cSurface(); 75 | 76 | void clearBuffer(size_t pColor = 0); 77 | 78 | void draw(); // Draw image to SDL Surface 79 | void mergeSurfaceBuffer(const cSurface* pFrom); 80 | 81 | bool LoadBitmap(const std::string& pFile); 82 | 83 | void Save(); 84 | void Restore(); 85 | 86 | void palette_SetToBlack(); 87 | bool palette_FadeTowardNew(); 88 | void palette_SetFromNew(); 89 | 90 | void paletteSet( cPalette* pPalette, uint32 pColorID = 0, uint32 pColors = g_MaxColors, bool pUseNow = false ); 91 | 92 | void paletteNew_SetToBlack(); 93 | 94 | inline SDL_Surface* GetSurface() const { return mSDLSurface; } 95 | inline SDL_Texture* GetTexture() const { return mTexture; }; 96 | inline uint8* GetSurfaceBuffer() const { return mSurfaceBuffer; } 97 | inline size_t GetSurfaceBufferSize() const { return mSurfaceBufferSize; } 98 | 99 | inline size_t GetWidth() const { return mWidth; } 100 | inline size_t GetHeight() const { return mHeight; } 101 | 102 | inline bool isPaletteAdjusting() const { return mPaletteAdjusting; } 103 | inline void resetPaletteAdjusting() { mPaletteAdjusting = false; } 104 | }; 105 | -------------------------------------------------------------------------------- /Source/Tiles.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Fodder 3 | * --------------- 4 | * 5 | * Copyright (C) 2008-2018 Open Fodder 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | */ 22 | 23 | #include "stdafx.hpp" 24 | 25 | const std::vector mTileTypes = { 26 | { eTileTypes_Jungle, "jun", "Jungle" }, 27 | { eTileTypes_Desert, "des", "Desert" }, 28 | { eTileTypes_Ice, "ice", "Ice" }, 29 | { eTileTypes_Moors, "mor", "Moors" }, 30 | { eTileTypes_Int, "int", "Interior" }, 31 | { eTileTypes_Hid, "hid", "Hid" }, // Unknown 32 | { eTileTypes_AFX, "afx", "AmigaFormat" } // Amiga Format Christmas Special 33 | }; 34 | 35 | const int16 TILE_WIDTH_PIXELS = 16; 36 | const int16 TILE_HEIGHT_PIXELS = 16; 37 | 38 | const int16* mTiles_Indestructible[] = { 39 | mTiles_Indestructible_Jungle, // JUN 40 | mTiles_Indestructible_Desert, // DES 41 | mTiles_Indestructible_Ice, // ICE 42 | mTiles_Indestructible_Moors, // MOR 43 | mTiles_Indestructible_Internal, // INT 44 | mTiles_Indestructible_Jungle, // HID 45 | mTiles_Indestructible_Ice // AFX 46 | }; 47 | 48 | const int8 mTiles_NotFlyable[] = { 49 | 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1 50 | }; 51 | 52 | const int8 mTiles_NotDriveable[] = { 53 | 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0 54 | }; 55 | 56 | const int8 mTiles_NotWalkable[] = { 57 | 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 58 | }; 59 | 60 | const int16 mTiles_Indestructible_Jungle[] = { 61 | 267, 268, 269, 287, 288, 289, 307, 308, 309, 98, 62 | 177, 217, -1 63 | }; 64 | 65 | const int16 mTiles_Indestructible_Desert[] = { 66 | 9, 10, 11, 29, 30, 31, 50, -1 67 | }; 68 | 69 | const int16 mTiles_Indestructible_Ice[] = { 70 | 307, 308, 309, 327, 328, 329, 71 | 348, 349, 363, 378, 379, -1 72 | }; 73 | 74 | const int16 mTiles_Indestructible_Moors[] = { 75 | 257, 276, 277, 160, 161, 162, 180, 76 | 181, 182, 201, 306, 384, 398, -1 77 | }; 78 | 79 | const int16 mTiles_Indestructible_Internal[] = { 80 | 23, 40, 41, 42, 63, 103, 50, 51, 70, 81 | 71, 90, 91, 346, 331, 351, -1, 82 | }; 83 | -------------------------------------------------------------------------------- /Source/Tiles.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Fodder 3 | * --------------- 4 | * 5 | * Copyright (C) 2008-2018 Open Fodder 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | */ 22 | 23 | enum eTerrainFeature { 24 | eTerrainFeature_Land = 0, 25 | eTerrainFeature_Rocky = 1, 26 | eTerrainFeature_Rocky2 = 2, 27 | eTerrainFeature_Block = 3, 28 | eTerrainFeature_QuickSand = 4, 29 | eTerrainFeature_WaterEdge = 5, 30 | eTerrainFeature_Water = 6, 31 | eTerrainFeature_Snow = 7, // Reduce unit speed 32 | eTerrainFeature_QuickSandEdge = 8, 33 | eTerrainFeature_Drop = 9, 34 | eTerrainFeature_Drop2 = 0x0A, 35 | eTerrainFeature_Sink = 0x0B, 36 | eTerrainFeature_C = 0x0C, 37 | eTerrainFeature_D = 0x0D, 38 | eTerrainFeature_Jump = 0x0E 39 | }; 40 | 41 | struct sTileType { 42 | eTileTypes mType; 43 | std::string mName; 44 | std::string mFullName; 45 | }; 46 | 47 | struct sStructureTile { 48 | int16 mX; 49 | int16 mY; 50 | uint16 mTileID; 51 | 52 | sStructureTile(int16 pMapX, int16 pMapY, uint16 pID) { 53 | mX = pMapX; 54 | mY = pMapY; 55 | mTileID = pID; 56 | } 57 | 58 | }; 59 | 60 | struct sStructureSprite { 61 | int16 mX; 62 | int16 mY; 63 | uint16 mSpriteID; 64 | 65 | sStructureSprite(int16 pTileX, int16 pTileY, uint16 pSpriteID) { 66 | mX = pTileX; 67 | mY = pTileY; 68 | mSpriteID = pSpriteID; 69 | } 70 | }; 71 | 72 | struct sStructure { 73 | std::vector mTiles; 74 | std::vector mSprites; 75 | 76 | int16 MaxWidth() const { 77 | int16 Width = 0; 78 | 79 | for (auto Tile : mTiles) { 80 | if (Width < Tile.mX) 81 | Width = Tile.mX; 82 | } 83 | return Width; 84 | } 85 | 86 | int16 MaxHeight() const { 87 | int16 Height = 0; 88 | 89 | for (auto Tile : mTiles) { 90 | if (Height < Tile.mY) 91 | Height = Tile.mY; 92 | } 93 | return Height; 94 | } 95 | }; 96 | 97 | extern const int8 mTiles_NotFlyable[]; 98 | extern const int8 mTiles_NotDriveable[]; 99 | extern const int8 mTiles_NotWalkable[]; 100 | 101 | extern const int16 mTiles_Indestructible_Jungle[]; 102 | extern const int16 mTiles_Indestructible_Desert[]; 103 | extern const int16 mTiles_Indestructible_Ice[]; 104 | extern const int16 mTiles_Indestructible_Moors[]; 105 | extern const int16 mTiles_Indestructible_Internal[]; 106 | 107 | extern const int16* mTiles_Indestructible[]; 108 | 109 | extern const std::vector mTileTypes; 110 | 111 | extern const int16 TILE_WIDTH_PIXELS; 112 | extern const int16 TILE_HEIGHT_PIXELS; -------------------------------------------------------------------------------- /Source/Types.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Fodder 3 | * --------------- 4 | * 5 | * Copyright (C) 2008-2018 Open Fodder 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | */ 22 | 23 | #ifdef WIN64 24 | typedef unsigned char uint8; //!< One byte 25 | typedef unsigned short uint16; //!< Two bytes 26 | typedef unsigned int uint32; //!< Four bytes 27 | typedef unsigned long long int uint64; //!< Eight bytes 28 | 29 | typedef signed char int8; //!< One byte 30 | typedef signed short int16; //!< Two bytes 31 | typedef signed int int32; //!< Four bytes 32 | typedef signed long long int int64; //!< Eight bytes 33 | 34 | 35 | #else 36 | typedef unsigned char uint8; //!< One byte 37 | typedef unsigned short uint16; //!< Two bytes 38 | typedef unsigned int uint32; //!< Four bytes 39 | typedef unsigned long uint64; //!< Eight bytes 40 | 41 | typedef signed char int8; //!< One byte 42 | typedef signed short int16; //!< Two bytes 43 | typedef signed int int32; //!< Four bytes 44 | typedef signed long int64; //!< Eight bytes 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /Source/UnitTesting.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Fodder 3 | * --------------- 4 | * 5 | * Copyright (C) 2008-2018 Open Fodder 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | */ 22 | 23 | class cUnitTesting { 24 | 25 | protected: 26 | std::string getCurrentTestFileName(); 27 | std::string getCurrentTestName(); 28 | 29 | void setDemoName(); 30 | 31 | void EngineSetup(); 32 | bool RunTests(const std::string pCampaign); 33 | 34 | public: 35 | 36 | cUnitTesting(); 37 | bool Start(); 38 | }; -------------------------------------------------------------------------------- /Source/Utils/SimplexIslands.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "SimplexIslands.hpp" 3 | 4 | SimplexIslands::SimplexIslands() { 5 | 6 | grad3 = { 7 | {1,1,0},{-1,1,0},{1,-1,0},{-1,-1,0}, 8 | {1,0,1},{-1,0,1},{1,0,-1},{-1,0,-1}, 9 | {0,1,1},{0,-1,1},{0,1,-1},{0,-1,-1} 10 | }; 11 | 12 | grad4 = { 13 | {0,1,1,1},{0,1,1,-1},{0,1,-1,1},{0,1,-1,-1}, 14 | {0,-1,1,1},{0,-1,1,-1},{0,-1,-1,1},{0,-1,-1,-1}, 15 | {1,0,1,1},{1,0,1,-1},{1,0,-1,1},{1,0,-1,-1}, 16 | {-1,0,1,1},{-1,0,1,-1},{-1,0,-1,1},{-1,0,-1,-1}, 17 | {1,1,0,1},{1,1,0,-1},{1,-1,0,1},{1,-1,0,-1}, 18 | {-1,1,0,1},{-1,1,0,-1},{-1,-1,0,1},{-1,-1,0,-1}, 19 | {1,1,1,0},{1,1,-1,0},{1,-1,1,0},{1,-1,-1,0}, 20 | {-1,1,1,0},{-1,1,-1,0},{-1,-1,1,0},{-1,-1,-1,0} }; 21 | 22 | for (int i = 0; i < 512; i++) 23 | { 24 | perm[i] = p[i & 255]; 25 | permMod12[i] = (short)(perm[i] % 12); 26 | } 27 | 28 | // Skewing and unskewing factors for 2, 3, and 4 dimensions 29 | F2 = 0.5*(sqrt(3.0) - 1.0); 30 | G2 = (3.0 - sqrt(3.0)) / 6.0; 31 | F3 = 1.0 / 3.0; 32 | G3 = 1.0 / 6.0; 33 | F4 = (sqrt(5.0) - 1.0) / 4.0; 34 | G4 = (5.0 - sqrt(5.0)) / 20.0; 35 | 36 | 37 | } 38 | 39 | short SimplexIslands::pbak[] = { 151,160,137,91,90,15, 40 | 131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23, 41 | 190, 6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33, 42 | 88,237,149,56,87,174,20,125,136,171,168, 68,175,74,165,71,134,139,48,27,166, 43 | 77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244, 44 | 102,143,54, 65,25,63,161, 1,216,80,73,209,76,132,187,208, 89,18,169,200,196, 45 | 135,130,116,188,159,86,164,100,109,198,173,186, 3,64,52,217,226,250,124,123, 46 | 5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42, 47 | 223,183,170,213,119,248,152, 2,44,154,163, 70,221,153,101,155,167, 43,172,9, 48 | 129,22,39,253, 19,98,108,110,79,113,224,232,178,185, 112,104,218,246,97,228, 49 | 251,34,242,193,238,210,144,12,191,179,162,241, 81,51,145,235,249,14,239,107, 50 | 49,192,214, 31,181,199,106,157,184, 84,204,176,115,121,50,45,127, 4,150,254, 51 | 138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180 }; 52 | 53 | short SimplexIslands::p[] = { 151,160,137,91,90,15, 54 | 131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23, 55 | 190, 6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33, 56 | 88,237,149,56,87,174,20,125,136,171,168, 68,175,74,165,71,134,139,48,27,166, 57 | 77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244, 58 | 102,143,54, 65,25,63,161, 1,216,80,73,209,76,132,187,208, 89,18,169,200,196, 59 | 135,130,116,188,159,86,164,100,109,198,173,186, 3,64,52,217,226,250,124,123, 60 | 5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42, 61 | 223,183,170,213,119,248,152, 2,44,154,163, 70,221,153,101,155,167, 43,172,9, 62 | 129,22,39,253, 19,98,108,110,79,113,224,232,178,185, 112,104,218,246,97,228, 63 | 251,34,242,193,238,210,144,12,191,179,162,241, 81,51,145,235,249,14,239,107, 64 | 49,192,214, 31,181,199,106,157,184, 84,204,176,115,121,50,45,127, 4,150,254, 65 | 138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180 }; -------------------------------------------------------------------------------- /Source/Utils/SimplexNoise.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file SimplexNoise.h 3 | * @brief A Perlin Simplex Noise C++ Implementation (1D, 2D, 3D). 4 | * 5 | * Copyright (c) 2014-2018 Sebastien Rombauts (sebastien.rombauts@gmail.com) 6 | * 7 | * Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt 8 | * or copy at http://opensource.org/licenses/MIT) 9 | */ 10 | #pragma once 11 | 12 | #include // size_t 13 | 14 | /** 15 | * @brief A Perlin Simplex Noise C++ Implementation (1D, 2D, 3D, 4D). 16 | */ 17 | class SimplexNoise { 18 | public: 19 | // 1D Perlin simplex noise 20 | float noiseX(float x); 21 | // 2D Perlin simplex noise 22 | float noiseXY(float x, float y); 23 | // 3D Perlin simplex noise 24 | float noiseXYZ(float x, float y, float z); 25 | 26 | // Fractal/Fractional Brownian Motion (fBm) noise summation 27 | float fractalX(size_t octaves, float x); 28 | float fractalXY(size_t octaves, float x, float y); 29 | float fractalXYZ(size_t octaves, float x, float y, float z); 30 | 31 | 32 | /** 33 | * Constructor of to initialize a fractal noise summation 34 | * 35 | * @param[in] frequency Frequency ("width") of the first octave of noise (default to 1.0) 36 | * @param[in] amplitude Amplitude ("height") of the first octave of noise (default to 1.0) 37 | * @param[in] lacunarity Lacunarity specifies the frequency multiplier between successive octaves (default to 2.0). 38 | * @param[in] persistence Persistence is the loss of amplitude between successive octaves (usually 1/lacunarity) 39 | */ 40 | explicit SimplexNoise(float frequency = 1.0f, 41 | float lacunarity = 2.0f, 42 | float persistence = 0.5f) : 43 | mFrequency(frequency), 44 | mAmplitude(frequency), 45 | mLacunarity(lacunarity), 46 | mPersistence(persistence) { 47 | } 48 | 49 | void normalizeArray(std::vector>& pNoise); 50 | std::vector> create( size_t pWidth, size_t pHeight, size_t pOctaves ); 51 | 52 | private: 53 | // Parameters of Fractional Brownian Motion (fBm) : sum of N "octaves" of noise 54 | float mFrequency; ///< Frequency ("width") of the first octave of noise (default to 1.0) 55 | float mAmplitude; ///< Amplitude ("height") of the first octave of noise (default to 1.0) 56 | float mLacunarity; ///< Lacunarity specifies the frequency multiplier between successive octaves (default to 2.0). 57 | float mPersistence; ///< Persistence is the loss of amplitude between successive octaves (usually 1/lacunarity) 58 | }; 59 | -------------------------------------------------------------------------------- /Source/Utils/duk_trans_socket.h: -------------------------------------------------------------------------------- 1 | #if !defined(DUK_TRANS_SOCKET_H_INCLUDED) 2 | #define DUK_TRANS_SOCKET_H_INCLUDED 3 | 4 | #include "duktape.h" 5 | 6 | void duk_trans_socket_init(void); 7 | void duk_trans_socket_finish(void); 8 | void duk_trans_socket_waitconn(void); 9 | duk_size_t duk_trans_socket_read_cb(void *udata, char *buffer, duk_size_t length); 10 | duk_size_t duk_trans_socket_write_cb(void *udata, const char *buffer, duk_size_t length); 11 | duk_size_t duk_trans_socket_peek_cb(void *udata); 12 | void duk_trans_socket_read_flush_cb(void *udata); 13 | void duk_trans_socket_write_flush_cb(void *udata); 14 | 15 | #endif /* DUK_TRANS_SOCKET_H_INCLUDED */ 16 | -------------------------------------------------------------------------------- /Source/Utils/dukglue/detail_constructor.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "detail_stack.h" 4 | #include "detail_traits.h" 5 | 6 | namespace dukglue { 7 | namespace detail { 8 | 9 | template 10 | static duk_ret_t call_native_constructor(duk_context* ctx) 11 | { 12 | if (!duk_is_constructor_call(ctx)) { 13 | duk_error(ctx, DUK_RET_TYPE_ERROR, "Constructor must be called with new T()."); 14 | return DUK_RET_TYPE_ERROR; 15 | } 16 | 17 | // construct the new instance 18 | auto constructor_args = dukglue::detail::get_stack_values(ctx); 19 | Cls* obj = dukglue::detail::apply_constructor(std::move(constructor_args)); 20 | 21 | duk_push_this(ctx); 22 | 23 | // make the new script object keep the pointer to the new object instance 24 | duk_push_pointer(ctx, obj); 25 | duk_put_prop_string(ctx, -2, "\xFF" "obj_ptr"); 26 | 27 | // register it 28 | if (!managed) 29 | dukglue::detail::RefManager::register_native_object(ctx, obj); 30 | 31 | duk_pop(ctx); // pop this 32 | 33 | return 0; 34 | } 35 | 36 | template 37 | static duk_ret_t managed_finalizer(duk_context* ctx) 38 | { 39 | duk_get_prop_string(ctx, 0, "\xFF" "obj_ptr"); 40 | Cls* obj = (Cls*) duk_require_pointer(ctx, -1); 41 | duk_pop(ctx); // pop obj_ptr 42 | 43 | if (obj != NULL) { 44 | delete obj; 45 | 46 | // for safety, set the pointer to undefined 47 | duk_push_undefined(ctx); 48 | duk_put_prop_string(ctx, 0, "\xFF" "obj_ptr"); 49 | } 50 | 51 | return 0; 52 | } 53 | 54 | template 55 | static duk_ret_t call_native_deleter(duk_context* ctx) 56 | { 57 | duk_push_this(ctx); 58 | duk_get_prop_string(ctx, -1, "\xFF" "obj_ptr"); 59 | 60 | if (!duk_is_pointer(ctx, -1)) { 61 | duk_error(ctx, DUK_RET_REFERENCE_ERROR, "Object has already been invalidated; cannot delete."); 62 | return DUK_RET_REFERENCE_ERROR; 63 | } 64 | 65 | Cls* obj = static_cast(duk_require_pointer(ctx, -1)); 66 | dukglue_invalidate_object(ctx, obj); 67 | delete obj; 68 | 69 | duk_pop_2(ctx); 70 | return 0; 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /Source/Utils/dukglue/detail_function.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "detail_stack.h" 4 | 5 | namespace dukglue 6 | { 7 | namespace detail 8 | { 9 | // This struct can be used to generate a Duktape C function that 10 | // pulls the argument values off the stack (with type checking), 11 | // calls the appropriate function with them, and puts the function's 12 | // return value (if any) onto the stack. 13 | template 14 | struct FuncInfoHolder 15 | { 16 | typedef RetType(*FuncType)(Ts...); 17 | 18 | template 19 | struct FuncCompiletime 20 | { 21 | // The function to call is embedded into call_native_function at 22 | // compile-time through template magic. 23 | // Performance is so similar to run-time function calls that 24 | // this is not recommended due to the ugly syntax it requires. 25 | static duk_ret_t call_native_function(duk_context* ctx) 26 | { 27 | auto bakedArgs = dukglue::detail::get_stack_values(ctx); 28 | actually_call(ctx, bakedArgs); 29 | return std::is_void::value ? 0 : 1; 30 | } 31 | 32 | private: 33 | // this mess is to support functions with void return values 34 | 35 | template 36 | static typename std::enable_if::value>::type actually_call(duk_context* ctx, const std::tuple& args) 37 | { 38 | // ArgStorage has some static_asserts in it that validate value types, 39 | // so we typedef it to force ArgStorage to compile and run the asserts 40 | typedef typename dukglue::types::ArgStorage::type ValidateReturnType; 41 | 42 | RetType return_val = dukglue::detail::apply_fp(funcToCall, args); 43 | 44 | using namespace dukglue::types; 45 | DukType::type>::template push(ctx, std::move(return_val)); 46 | } 47 | 48 | template 49 | static typename std::enable_if::value>::type actually_call(duk_context* ctx, const std::tuple& args) 50 | { 51 | dukglue::detail::apply_fp(funcToCall, args); 52 | } 53 | }; 54 | 55 | struct FuncRuntime 56 | { 57 | // Pull the address of the function to call from the 58 | // Duktape function object at run time. 59 | static duk_ret_t call_native_function(duk_context* ctx) 60 | { 61 | duk_push_current_function(ctx); 62 | duk_get_prop_string(ctx, -1, "\xFF" "func_ptr"); 63 | void* fp_void = duk_require_pointer(ctx, -1); 64 | if (fp_void == NULL) { 65 | duk_error(ctx, DUK_RET_TYPE_ERROR, "what even"); 66 | return DUK_RET_TYPE_ERROR; 67 | } 68 | 69 | duk_pop_2(ctx); 70 | 71 | static_assert(sizeof(RetType(*)(Ts...)) == sizeof(void*), "Function pointer and data pointer are different sizes"); 72 | RetType(*funcToCall)(Ts...) = reinterpret_cast(fp_void); 73 | 74 | actually_call(ctx, funcToCall, dukglue::detail::get_stack_values(ctx)); 75 | return std::is_void::value ? 0 : 1; 76 | } 77 | 78 | // this mess is to support functions with void return values 79 | template 80 | static typename std::enable_if::value>::type actually_call(duk_context* ctx, RetType(*funcToCall)(Ts...), const std::tuple& args) 81 | { 82 | // ArgStorage has some static_asserts in it that validate value types, 83 | // so we typedef it to force ArgStorage to compile and run the asserts 84 | typedef typename dukglue::types::ArgStorage::type ValidateReturnType; 85 | 86 | RetType return_val = dukglue::detail::apply_fp(funcToCall, args); 87 | 88 | using namespace dukglue::types; 89 | DukType::type>::template push(ctx, std::move(return_val)); 90 | } 91 | 92 | template 93 | static typename std::enable_if::value>::type actually_call(duk_context* ctx, RetType(*funcToCall)(Ts...), const std::tuple& args) 94 | { 95 | dukglue::detail::apply_fp(funcToCall, args); 96 | } 97 | }; 98 | }; 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /Source/Utils/dukglue/detail_stack.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "detail_traits.h" 6 | #include "detail_types.h" 7 | 8 | #include 9 | 10 | namespace dukglue 11 | { 12 | namespace detail 13 | { 14 | // Helper to get the argument tuple type, with correct storage types. 15 | template 16 | struct ArgsTuple { 17 | typedef std::tuple::type...> type; 18 | }; 19 | 20 | // Helper to get argument indices. 21 | // Call read for every Ts[i], for matching argument index Index[i]. 22 | // The traits::index_tuple is used for type inference. 23 | // A concrete example: 24 | // get_values(duktape_context) 25 | // get_values_helper<{int, bool}, {0, 1}>(ctx, ignored) 26 | // std::make_tuple(read(ctx, 0), read(ctx, 1)) 27 | template 28 | typename ArgsTuple::type get_stack_values_helper(duk_context* ctx, dukglue::detail::index_tuple) 29 | { 30 | using namespace dukglue::types; 31 | return std::forward_as_tuple(DukType::type>::template read::type>(ctx, Indexes)...); 32 | } 33 | 34 | // Returns an std::tuple of the values asked for in the template parameters. 35 | // Values will remain on the stack. 36 | // Values are indexed from the bottom of the stack up (0, 1, ...). 37 | // If a value does not exist or does not have the expected type, an error is thrown 38 | // through Duktape (with duk_error(...)), and the function does not return 39 | template 40 | typename ArgsTuple::type get_stack_values(duk_context* ctx) 41 | { 42 | // We need the argument indices for read_value, and we need to be able 43 | // to unpack them as a template argument to match Ts. 44 | // So, we use traits::make_indexes, which returns a traits::index_tuple<0, 1, 2, ...> object. 45 | // We pass that into a helper function so we can put a name to that <0, 1, ...> template argument. 46 | // Here, the type of Args isn't important, the length of it is. 47 | auto indices = typename dukglue::detail::make_indexes::type(); 48 | return get_stack_values_helper(ctx, indices); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Source/Utils/dukglue/detail_traits.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace dukglue 6 | { 7 | namespace detail 8 | { 9 | ////////////////////////////////////////////////////////////////////////////////////////////// 10 | 11 | // Credit to LuaState for this code: 12 | // https://github.com/AdUki/LuaState/blob/master/include/Traits.h 13 | 14 | template struct index_tuple {}; 15 | 16 | template 17 | struct make_indexes_impl; 18 | 19 | template 20 | struct make_indexes_impl, T, Types...> 21 | { 22 | typedef typename make_indexes_impl, Types...>::type type; 23 | }; 24 | 25 | template 26 | struct make_indexes_impl > 27 | { 28 | typedef index_tuple type; 29 | }; 30 | 31 | template 32 | struct make_indexes : make_indexes_impl<0, index_tuple<>, Types...> 33 | {}; 34 | 35 | ////////////////////////////////////////////////////////////////////////////////////////////// 36 | 37 | template 38 | struct indexes {}; 39 | 40 | template 41 | struct indexes_builder : indexes_builder {}; 42 | 43 | template 44 | struct indexes_builder<0, Is...> { 45 | typedef indexes index; 46 | }; 47 | 48 | ////////////////////////////////////////////////////////////////////////////////////////////// 49 | 50 | // This mess is used to use function arugments stored in an std::tuple to an 51 | // std::function, function pointer, or method. 52 | 53 | // std::function 54 | template 55 | Ret apply_helper(std::function pf, index_tuple< Indexes... >, std::tuple&& tup) 56 | { 57 | return pf(std::forward(std::get(tup))...); 58 | } 59 | 60 | template 61 | Ret apply(std::function pf, const std::tuple& tup) 62 | { 63 | return apply_helper(pf, typename make_indexes::type(), std::tuple(tup)); 64 | } 65 | 66 | // function pointer 67 | template 68 | Ret apply_fp_helper(Ret(*pf)(Args...), index_tuple< Indexes... >, std::tuple&& tup) 69 | { 70 | return pf(std::forward(std::get(tup))...); 71 | } 72 | 73 | template 74 | Ret apply_fp(Ret(*pf)(Args...), const std::tuple& tup) 75 | { 76 | return apply_fp_helper(pf, typename make_indexes::type(), std::tuple(tup)); 77 | } 78 | 79 | // method pointer 80 | template 81 | Ret apply_method_helper(Ret(Cls::*pf)(Args...), index_tuple< Indexes... >, Cls* obj, std::tuple&& tup) 82 | { 83 | return (*obj.*pf)(std::forward(std::get(tup))...); 84 | } 85 | 86 | template 87 | Ret apply_method(Ret(Cls::*pf)(Args...), Cls* obj, const std::tuple& tup) 88 | { 89 | return apply_method_helper(pf, typename make_indexes::type(), obj, std::tuple(tup)); 90 | } 91 | 92 | // const method pointer 93 | template 94 | Ret apply_method_helper(Ret(Cls::*pf)(Args...) const, index_tuple< Indexes... >, Cls* obj, std::tuple&& tup) 95 | { 96 | return (*obj.*pf)(std::forward(std::get(tup))...); 97 | } 98 | 99 | template 100 | Ret apply_method(Ret(Cls::*pf)(Args...) const, Cls* obj, const std::tuple& tup) 101 | { 102 | return apply_method_helper(pf, typename make_indexes::type(), obj, std::tuple(tup)); 103 | } 104 | 105 | // constructor 106 | template 107 | Cls* apply_constructor_helper(index_tuple< Indexes... >, std::tuple&& tup) 108 | { 109 | return new Cls(std::forward(std::get(tup))...); 110 | } 111 | 112 | template 113 | Cls* apply_constructor(const std::tuple& tup) 114 | { 115 | return apply_constructor_helper(typename make_indexes::type(), std::tuple(tup)); 116 | } 117 | 118 | ////////////////////////////////////////////////////////////////////////////////////////////// 119 | 120 | 121 | } 122 | } -------------------------------------------------------------------------------- /Source/Utils/dukglue/detail_typeinfo.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace dukglue 6 | { 7 | namespace detail 8 | { 9 | // same as duk_get_type_name, which is private for some reason *shakes fist* 10 | static const char* get_type_name(duk_int_t type_idx) { 11 | static const char* names[] = { 12 | "none", 13 | "undefined", 14 | "null", 15 | "boolean", 16 | "number", 17 | "string", 18 | "object", 19 | "buffer", 20 | "pointer", 21 | "lightfunc" 22 | }; 23 | 24 | if (type_idx >= 0 && type_idx < sizeof(names) / sizeof(names[0])) 25 | return names[type_idx]; 26 | else 27 | return "unknown"; 28 | } 29 | 30 | class TypeInfo 31 | { 32 | public: 33 | TypeInfo(std::type_index&& idx) : index_(idx), base_(nullptr) {} 34 | TypeInfo(const TypeInfo& rhs) : index_(rhs.index_), base_(rhs.base_) {} 35 | 36 | inline void set_base(TypeInfo* base) { 37 | base_ = base; 38 | } 39 | 40 | template 41 | bool can_cast() const { 42 | if (index_ == typeid(T)) 43 | return true; 44 | 45 | if (base_) 46 | return base_->can_cast(); 47 | 48 | return false; 49 | } 50 | 51 | inline bool operator<(const TypeInfo& rhs) const { return index_ < rhs.index_; } 52 | inline bool operator<=(const TypeInfo& rhs) const { return index_ <= rhs.index_; } 53 | inline bool operator>(const TypeInfo& rhs) const { return index_ > rhs.index_; } 54 | inline bool operator>=(const TypeInfo& rhs) const { return index_ >= rhs.index_; } 55 | inline bool operator==(const TypeInfo& rhs) const { return index_ == rhs.index_; } 56 | inline bool operator!=(const TypeInfo& rhs) const { return index_ != rhs.index_; } 57 | 58 | private: 59 | std::type_index index_; 60 | TypeInfo* base_; 61 | }; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Source/Utils/dukglue/dukexception.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | class DukException : public std::exception 7 | { 8 | public: 9 | virtual const char* what() const noexcept override 10 | { 11 | return mMsg.c_str(); 12 | } 13 | 14 | template 15 | DukException& operator<<(T rhs) 16 | { 17 | std::stringstream ss; 18 | ss << mMsg << rhs; 19 | mMsg = ss.str(); 20 | return *this; 21 | } 22 | 23 | protected: 24 | std::string mMsg; 25 | }; 26 | 27 | class DukErrorException : public DukException 28 | { 29 | public: 30 | DukErrorException(duk_context* ctx, int return_code, bool pop_error = true) { 31 | if (return_code != 0) { 32 | duk_get_prop_string(ctx, -1, "stack"); 33 | mMsg = duk_safe_to_string(ctx, -1); 34 | duk_pop(ctx); 35 | 36 | if (pop_error) 37 | duk_pop(ctx); 38 | } 39 | } 40 | }; -------------------------------------------------------------------------------- /Source/Utils/dukglue/dukglue.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "register_function.h" 4 | #include "register_class.h" 5 | #include "register_property.h" 6 | #include "public_util.h" 7 | #include "dukvalue.h" -------------------------------------------------------------------------------- /Source/Utils/dukglue/register_function.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "detail_function.h" 4 | 5 | // Register a function, embedding the function address at compile time. 6 | // According to benchmarks, there's really not much reason to do this 7 | // (inconsistent 2-3% performance improvement for a 10,000 function call stress test averaged over 100 runs), 8 | // since it has much uglier syntax and may bloat executable size if you have many functions with identical signatures. 9 | template 10 | void dukglue_register_function_compiletime(duk_context* ctx, RetType(*)(Ts...), const char* name) 11 | { 12 | static_assert(std::is_same::value, 13 | "Mismatching function pointer template parameter and function pointer argument types. " 14 | "Try: dukglue_register_function(ctx, \"funcName\", func)"); 15 | 16 | duk_c_function evalFunc = dukglue::detail::FuncInfoHolder::template FuncActual::call_native_function; 17 | 18 | duk_push_c_function(ctx, evalFunc, sizeof...(Ts)); 19 | duk_put_global_string(ctx, name); 20 | } 21 | 22 | // Register a function. 23 | template 24 | void dukglue_register_function(duk_context* ctx, RetType(*funcToCall)(Ts...), const char* name) 25 | { 26 | duk_c_function evalFunc = dukglue::detail::FuncInfoHolder::FuncRuntime::call_native_function; 27 | 28 | duk_push_c_function(ctx, evalFunc, sizeof...(Ts)); 29 | 30 | static_assert(sizeof(RetType(*)(Ts...)) == sizeof(void*), "Function pointer and data pointer are different sizes"); 31 | duk_push_pointer(ctx, reinterpret_cast(funcToCall)); 32 | duk_put_prop_string(ctx, -2, "\xFF" "func_ptr"); 33 | 34 | duk_put_global_string(ctx, name); 35 | } 36 | -------------------------------------------------------------------------------- /Source/Utils/dukglue/register_property.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "detail_method.h" 4 | 5 | // const getter, setter 6 | template 7 | void dukglue_register_property(duk_context* ctx, 8 | RetT(Cls::*getter)() const, 9 | void(Cls::*setter)(ArgT), 10 | const char* name) 11 | { 12 | dukglue_register_property(ctx, getter, setter, name); 13 | } 14 | 15 | // const getter, no setter 16 | template 17 | void dukglue_register_property(duk_context* ctx, 18 | RetT(Cls::*getter)() const, 19 | std::nullptr_t setter, 20 | const char* name) 21 | { 22 | dukglue_register_property(ctx, getter, setter, name); 23 | } 24 | 25 | // non-const getter, setter 26 | template 27 | void dukglue_register_property(duk_context* ctx, 28 | RetT(Cls::*getter)(), 29 | void(Cls::*setter)(ArgT), 30 | const char* name) 31 | { 32 | dukglue_register_property(ctx, getter, setter, name); 33 | } 34 | 35 | // non-const getter, no setter 36 | template 37 | void dukglue_register_property(duk_context* ctx, 38 | RetT(Cls::*getter)(), 39 | std::nullptr_t setter, 40 | const char* name) 41 | { 42 | dukglue_register_property(ctx, getter, setter, name); 43 | } 44 | 45 | // no getter, setter 46 | template 47 | void dukglue_register_property(duk_context* ctx, 48 | std::nullptr_t getter, 49 | void(Cls::*setter)(ArgT), 50 | const char* name) 51 | { 52 | dukglue_register_property(ctx, getter, setter, name); 53 | } 54 | 55 | // no getter, no setter 56 | template 57 | void dukglue_register_property(duk_context* ctx, std::nullptr_t getter, std::nullptr_t setter, const char* name) 58 | { 59 | // strictly speaking I think duktape can probably handle neither 60 | // (according to the wonderful API docs), but I don't know why you 61 | // would want to do this in the first place 62 | static_assert(std::is_void::value, "Must have getter or setter"); 63 | } 64 | 65 | inline duk_ret_t dukglue_throw_error(duk_context* ctx) 66 | { 67 | duk_error(ctx, DUK_ERR_TYPE_ERROR, "Property does not have getter or setter."); 68 | } 69 | 70 | template 71 | void dukglue_register_property(duk_context* ctx, 72 | typename std::conditional::type getter, 73 | void(Cls::*setter)(ArgT), 74 | const char* name) 75 | { 76 | using namespace dukglue::detail; 77 | typedef MethodInfo GetterMethodInfo; 78 | typedef MethodInfo SetterMethodInfo; 79 | 80 | ProtoManager::push_prototype(ctx); 81 | 82 | // push key 83 | duk_push_string(ctx, name); 84 | 85 | // push getter 86 | if (getter != nullptr) { 87 | duk_c_function method_func = GetterMethodInfo::MethodRuntime::call_native_method; 88 | 89 | duk_push_c_function(ctx, method_func, 0); 90 | 91 | duk_push_pointer(ctx, new typename GetterMethodInfo::MethodHolder{ getter }); 92 | duk_put_prop_string(ctx, -2, "\xFF" "method_holder"); // consumes raw method pointer 93 | 94 | // make sure we free the method_holder when this function is removed 95 | duk_push_c_function(ctx, GetterMethodInfo::MethodRuntime::finalize_method, 1); 96 | duk_set_finalizer(ctx, -2); 97 | } else { 98 | duk_push_c_function(ctx, dukglue_throw_error, 1); 99 | } 100 | 101 | if (setter != nullptr) { 102 | duk_c_function method_func = SetterMethodInfo::MethodRuntime::call_native_method; 103 | 104 | duk_push_c_function(ctx, method_func, 1); 105 | 106 | duk_push_pointer(ctx, new typename SetterMethodInfo::MethodHolder{ setter }); 107 | duk_put_prop_string(ctx, -2, "\xFF" "method_holder"); // consumes raw method pointer 108 | 109 | // make sure we free the method_holder when this function is removed 110 | duk_push_c_function(ctx, SetterMethodInfo::MethodRuntime::finalize_method, 1); 111 | duk_set_finalizer(ctx, -2); 112 | } else { 113 | duk_push_c_function(ctx, dukglue_throw_error, 1); 114 | } 115 | 116 | duk_uint_t flags = DUK_DEFPROP_HAVE_GETTER 117 | | DUK_DEFPROP_HAVE_SETTER 118 | | DUK_DEFPROP_HAVE_CONFIGURABLE /* set not configurable (from JS) */ 119 | | DUK_DEFPROP_FORCE /* allow overriding built-ins and previously defined properties */; 120 | 121 | duk_def_prop(ctx, -4, flags); 122 | duk_pop(ctx); // pop prototype 123 | } 124 | -------------------------------------------------------------------------------- /Source/Utils/md5.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Christophe Devine c.devine@cr0.net 3 | http://www.cr0.net:8040/code/crypto/ 4 | */ 5 | 6 | typedef struct 7 | { 8 | uint32 total[2]; 9 | uint32 state[4]; 10 | uint8 buffer[64]; 11 | } 12 | md5_context; 13 | 14 | void md5_starts( md5_context *ctx ); 15 | void md5_update( md5_context *ctx, uint8 *input, uint32 length ); 16 | void md5_finish( md5_context *ctx, uint8 digest[16] ); 17 | -------------------------------------------------------------------------------- /Source/Utils/pseudorand.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Fodder 3 | * --------------- 4 | * 5 | * Copyright (C) 2008-2018 Open Fodder 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | */ 22 | 23 | class cPseudorand { 24 | private: 25 | int16 mRandom_0; 26 | int16 mRandom_1; 27 | int16 mRandom_2; 28 | int16 mRandom_3; 29 | 30 | int16 mStartingSeed; 31 | public: 32 | 33 | cPseudorand(int16 pSeed = 0) { 34 | if (!pSeed) { 35 | const time_t now = time(0); 36 | tm* ltm; 37 | #ifndef _WIN32 38 | ltm = localtime(&now); 39 | #else 40 | ltm = new tm(); 41 | localtime_s(ltm, &now); 42 | #endif 43 | pSeed = tool_DecimalToBinaryCodedDecimal(ltm->tm_sec); 44 | pSeed |= tool_DecimalToBinaryCodedDecimal(ltm->tm_min) << 8; 45 | pSeed += 0x40B; 46 | #ifdef _WIN32 47 | delete ltm; 48 | #endif 49 | } 50 | setSeed(pSeed); 51 | } 52 | 53 | void setSeed(int16 pSeed) { 54 | mStartingSeed = pSeed; 55 | 56 | mRandom_0 = mStartingSeed; 57 | mRandom_1 = -mStartingSeed; 58 | mRandom_2 = 1; 59 | mRandom_3 = 0; 60 | } 61 | 62 | void setSeed(int16 pSeed0, int16 pSeed1, int16 pSeed2, int16 pSeed3 ) { 63 | mStartingSeed = 0; 64 | 65 | mRandom_0 = pSeed0; 66 | mRandom_1 = pSeed1; 67 | mRandom_2 = pSeed2; 68 | mRandom_3 = pSeed3; 69 | } 70 | 71 | void getSeeds(int16& pSeed0, int16& pSeed1, int16& pSeed2, int16& pSeed3) { 72 | pSeed0 = mRandom_0; 73 | pSeed1 = mRandom_1; 74 | pSeed2 = mRandom_2; 75 | pSeed3 = mRandom_3; 76 | } 77 | 78 | int16 getStartingSeed() const { 79 | return mStartingSeed; 80 | } 81 | 82 | 83 | float getf(float pMin, float pMax) { 84 | 85 | return pMin + static_cast (getu() % RAND_MAX) / (static_cast (RAND_MAX) / (pMax - pMin)); 86 | } 87 | 88 | uint16 getu() { 89 | return (uint16)get(); 90 | } 91 | 92 | uint16 getu(size_t pMin, size_t pMax) { 93 | return (uint16)(pMin + (getu() % static_cast(pMax - pMin + 1))); 94 | } 95 | 96 | int16 get() { 97 | int16 Data0 = mRandom_0; 98 | int16 Data2 = mRandom_1; 99 | int16 Data4 = mRandom_2; 100 | int16 Data6 = mRandom_3; 101 | 102 | uint32 Dat4 = Data4 | (Data6 << 16); 103 | uint8 CF = Data4 & 1; 104 | uint32 Data8 = Data0 | (Data2 << 16); 105 | 106 | uint8 CF2 = Data8 & 1; 107 | Data8 >>= 1; 108 | 109 | if (CF) 110 | Data8 |= 0x80000000; 111 | 112 | Dat4 += CF2; 113 | Data4 = Dat4 & 0xFFFF; 114 | Data6 = Dat4 >> 16; 115 | 116 | for (uint16 cx = 0x0C; cx > 0; --cx) { 117 | CF = 0; 118 | 119 | if (Data0 & 0x8000) 120 | CF = 1; 121 | Data0 <<= 1; 122 | Data2 <<= 1; 123 | if (CF) 124 | Data2 |= 1; 125 | } 126 | 127 | int16 DataA = Data8 >> 16; 128 | 129 | Data0 ^= Data8 & 0xFFFF; 130 | Data2 ^= DataA; 131 | Data8 = Data0; 132 | DataA = Data2; 133 | 134 | int16 ax = Data8; 135 | int16 bx = DataA; 136 | Data8 = bx; 137 | DataA = ax; 138 | 139 | Data8 >>= 4; 140 | Data0 ^= Data8; 141 | 142 | mRandom_0 = Data0; 143 | mRandom_1 = Data2; 144 | mRandom_2 = Data4; 145 | mRandom_3 = Data6; 146 | return Data0; 147 | } 148 | }; -------------------------------------------------------------------------------- /Source/Utils/scandir.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * scandir, alphasort - scan a directory 3 | * 4 | * implementation for systems that do not have it in libc 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | /* 14 | * convenience helper function for scandir's |compar()| function: 15 | * sort directory entries using strcoll(3) 16 | */ 17 | int 18 | alphasort(const void *_a, const void *_b) 19 | { 20 | struct dirent **a = (struct dirent **)_a; 21 | struct dirent **b = (struct dirent **)_b; 22 | return strcoll((*a)->d_name, (*b)->d_name); 23 | } 24 | 25 | 26 | #define strverscmp(a,b) strcoll(a,b) /* for now */ 27 | 28 | /* 29 | * convenience helper function for scandir's |compar()| function: 30 | * sort directory entries using GNU |strverscmp()| 31 | */ 32 | int 33 | versionsort(const void *_a, const void *_b) 34 | { 35 | struct dirent **a = (struct dirent **)_a; 36 | struct dirent **b = (struct dirent **)_b; 37 | return strverscmp((*a)->d_name, (*b)->d_name); 38 | } 39 | 40 | /* 41 | * The scandir() function reads the directory dirname and builds an 42 | * array of pointers to directory entries using malloc(3). It returns 43 | * the number of entries in the array. A pointer to the array of 44 | * directory entries is stored in the location referenced by namelist. 45 | * 46 | * The select parameter is a pointer to a user supplied subroutine 47 | * which is called by scandir() to select which entries are to be 48 | * included in the array. The select routine is passed a pointer to 49 | * a directory entry and should return a non-zero value if the 50 | * directory entry is to be included in the array. If select is null, 51 | * then all the directory entries will be included. 52 | * 53 | * The compar parameter is a pointer to a user supplied subroutine 54 | * which is passed to qsort(3) to sort the completed array. If this 55 | * pointer is null, the array is not sorted. 56 | */ 57 | int 58 | scandir(const char *dirname, 59 | struct dirent ***ret_namelist, 60 | int (*select)(const struct dirent *), 61 | int (*compar)(const struct dirent **, const struct dirent **)) 62 | { 63 | int i, len; 64 | int used, allocated; 65 | DIR *dir; 66 | struct dirent *ent, *ent2; 67 | struct dirent **namelist = NULL; 68 | 69 | if ((dir = opendir(dirname)) == NULL) 70 | return -1; 71 | 72 | used = 0; 73 | allocated = 2; 74 | namelist = (dirent**)malloc(allocated * sizeof(struct dirent *)); 75 | if (!namelist) 76 | goto error; 77 | 78 | while ((ent = readdir(dir)) != NULL) { 79 | 80 | if (select != NULL && !select(ent)) 81 | continue; 82 | 83 | /* duplicate struct direct for this entry */ 84 | len = offsetof(struct dirent, d_name) + strlen(ent->d_name) + 1; 85 | if ((ent2 = (dirent*)malloc(len)) == NULL) 86 | goto error; 87 | 88 | if (used >= allocated) { 89 | allocated *= 2; 90 | namelist = (dirent**)realloc(namelist, allocated * sizeof(struct dirent *)); 91 | if (!namelist) 92 | goto error; 93 | } 94 | memcpy(ent2, ent, len); 95 | namelist[used++] = ent2; 96 | } 97 | closedir(dir); 98 | 99 | if (compar) 100 | qsort(namelist, used, sizeof(struct dirent *), 101 | (int (*)(const void *, const void *)) compar); 102 | 103 | *ret_namelist = namelist; 104 | return used; 105 | 106 | 107 | error: 108 | closedir(dir); 109 | 110 | if (namelist) { 111 | for (i = 0; i < used; i++) 112 | free(namelist[i]); 113 | free(namelist); 114 | } 115 | return -1; 116 | } 117 | -------------------------------------------------------------------------------- /Source/Utils/scandir.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __SCANDIR_HPP__ 2 | #define __SCANDIR_HPP__ 3 | int 4 | scandir(const char *dirname, 5 | struct dirent ***ret_namelist, 6 | int (*select)(const struct dirent *), 7 | int (*compar)(const struct dirent **, const struct dirent **)); 8 | #endif -------------------------------------------------------------------------------- /Source/Version.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Fodder 3 | * --------------- 4 | * 5 | * Copyright (C) 2008-2018 Open Fodder 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | */ 22 | 23 | enum ePlatform { 24 | Any = 0, 25 | PC = 1, 26 | Amiga = 2 27 | }; 28 | 29 | enum eRelease { 30 | Retail = 0, 31 | PCFormat, 32 | AmigaXMAS, 33 | AmigaPower, 34 | AmigaTheOne, 35 | AmigaAction, 36 | AmigaNotVeryFestive, 37 | AmigaAlienLevels, 38 | 39 | Custom 40 | }; 41 | 42 | enum eGame { 43 | CF1 = 0, 44 | CF2 = 1 45 | }; 46 | 47 | enum eCustomMode { 48 | eCustomMode_None = 0, 49 | eCustomMode_Map = 1, 50 | eCustomMode_Set = 2 51 | }; 52 | 53 | enum eGFX_Types { 54 | eGFX_IN_GAME = 0, 55 | eGFX_IN_GAME2 = 1, 56 | eGFX_FONT = 2, 57 | eGFX_HILL = 3, 58 | eGFX_RECRUIT = 4, 59 | eGFX_BRIEFING = 5, 60 | eGFX_SERVICE = 6, 61 | 62 | eGFX_RANKFONT = 7, 63 | eGFX_PSTUFF = 8, 64 | 65 | eGFX_BRIEFING_AMIGA_1 = 9, 66 | eGFX_BRIEFING_AMIGA_2 = 10, 67 | eGFX_BRIEFING_AMIGA_3 = 11 68 | }; 69 | 70 | enum eTileTypes { 71 | eTileTypes_Jungle = 0, 72 | eTileTypes_Desert = 1, 73 | eTileTypes_Ice = 2, 74 | eTileTypes_Moors = 3, 75 | eTileTypes_Int = 4, 76 | eTileTypes_Hid = 5, 77 | eTileTypes_AFX = 6, // Amiga Format Christmas Special 78 | }; 79 | 80 | enum eTileSub { 81 | eTileSub_0 = 0, 82 | eTileSub_1 = 1 83 | }; 84 | 85 | struct sTileset { 86 | eTileTypes Type; 87 | std::vector Subs; 88 | }; 89 | 90 | struct sVersion { 91 | std::string mName; 92 | 93 | eGame mGame; 94 | ePlatform mPlatform; 95 | eRelease mRelease; 96 | 97 | sVersion() { 98 | mName = ""; 99 | mGame = eGame::CF1; 100 | mPlatform = ePlatform::Any; 101 | mRelease = eRelease::Retail; 102 | } 103 | 104 | sVersion(const std::string& pName, eGame pGame, ePlatform pPlatform, eRelease pRelease) { 105 | mName = pName; 106 | mGame = pGame; 107 | mPlatform = pPlatform; 108 | mRelease = pRelease; 109 | } 110 | 111 | bool isCannonFodder1() const { 112 | return mGame == eGame::CF1; 113 | } 114 | 115 | bool isCannonFodder2() const { 116 | return mGame == eGame::CF2; 117 | } 118 | 119 | bool isCustom() const { 120 | return mRelease == eRelease::Custom; 121 | } 122 | 123 | bool isRetail() const { 124 | return mRelease == eRelease::Retail; 125 | } 126 | 127 | bool isPCFormat() const { 128 | return mRelease == eRelease::PCFormat; 129 | } 130 | 131 | bool isAmigaXmas() const { 132 | return mRelease == eRelease::AmigaXMAS; 133 | } 134 | 135 | bool isAmigaPower() const { 136 | return mRelease == eRelease::AmigaPower; 137 | } 138 | 139 | bool isAmigaTheOne() const { 140 | return mRelease == eRelease::AmigaTheOne; 141 | } 142 | 143 | bool isAmigaAction() const { 144 | return mRelease == eRelease::AmigaAction; 145 | } 146 | 147 | bool isAmigaNotVeryFestive() const { 148 | return mRelease == eRelease::AmigaNotVeryFestive; 149 | } 150 | 151 | bool isAmigaAlienLevels() const { 152 | return mRelease == eRelease::AmigaAlienLevels; 153 | } 154 | 155 | bool isAmiga() const { 156 | return mPlatform == ePlatform::Amiga; 157 | } 158 | 159 | bool isPC() const { 160 | return mPlatform == ePlatform::PC; 161 | } 162 | 163 | /** 164 | * Is this version a demo? 165 | * 166 | * NOTE: The PC-Format version is not considered a demo, as it is very close to the dos retail 167 | */ 168 | bool isDemo() const { 169 | return mRelease == eRelease::AmigaXMAS || 170 | mRelease == eRelease::AmigaPower || 171 | mRelease == eRelease::AmigaTheOne || 172 | mRelease == eRelease::AmigaAction || 173 | mRelease == eRelease::AmigaNotVeryFestive || 174 | mRelease == eRelease::AmigaAlienLevels; 175 | } 176 | 177 | bool isCoverDisk() const { 178 | 179 | return (isAmigaPower() || isAmigaAction() || isAmigaTheOne()); 180 | } 181 | }; 182 | -------------------------------------------------------------------------------- /Source/Versions.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Fodder 3 | * --------------- 4 | * 5 | * Copyright (C) 2008-2018 Open Fodder 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | */ 22 | 23 | struct sFile { 24 | const char* mName; 25 | const char* mChecksum; 26 | }; 27 | 28 | class cResources; 29 | class cGraphics; 30 | class cSound; 31 | 32 | struct sGameVersion : public sVersion { 33 | 34 | const std::string mDataPath; 35 | const std::vector mFiles; 36 | 37 | sGameVersion(const std::string& pName, eGame pGame, ePlatform pPlatform, eRelease pRelease, const std::string& pDataPath, const std::vector& pFiles) : 38 | sVersion(pName,pGame,pPlatform,pRelease), mDataPath(pDataPath), mFiles(pFiles) { 39 | 40 | } 41 | 42 | bool hasGfx(eGFX_Types pGfxType) const { 43 | auto gfx = getGfxTypes(); 44 | return std::find(gfx.begin(), gfx.end(), pGfxType) != gfx.end(); 45 | } 46 | 47 | bool hasTileset(eTileTypes pTileType, eTileSub pSub = eTileSub::eTileSub_0 ) const { 48 | auto tiles = getTileTypes(); 49 | 50 | return std::find_if(tiles.begin(), tiles.end(), 51 | [pTileType, pSub](const sTileset& ms) { 52 | if (ms.Type != pTileType) 53 | return false; 54 | 55 | return std::find(ms.Subs.begin(), ms.Subs.end(), pSub) != ms.Subs.end(); 56 | } 57 | ) != tiles.end(); 58 | } 59 | 60 | bool hasBriefingScreen() const { 61 | return hasGfx(eGFX_BRIEFING); 62 | } 63 | 64 | bool hasServiceScreen() const { 65 | return hasGfx(eGFX_SERVICE); 66 | } 67 | 68 | cDimension GetScreenSize() const { 69 | if (isAmiga()) 70 | return { 320,225 }; 71 | 72 | return { 320,200 }; 73 | } 74 | 75 | cDimension GetSecondScreenSize() const { 76 | if (isAmiga()) 77 | return { 320,260 }; 78 | 79 | return { 320,200 }; 80 | } 81 | 82 | std::vector getGfxTypes() const; 83 | std::vector getTileTypes() const; 84 | 85 | std::vector* getIntroData() const; 86 | 87 | std::shared_ptr GetResources() const; 88 | std::shared_ptr GetGraphics() const; 89 | std::shared_ptr GetSound() const; 90 | bool CanUseAmigaSound() const; 91 | 92 | std::string getDataPath() const; 93 | std::string getDataFilePath(std::string pFile) const; 94 | }; 95 | 96 | class cVersions { 97 | 98 | protected: 99 | 100 | public: 101 | 102 | bool isCampaignKnown(const std::string& pName) const; 103 | bool isCampaignAvailable(const std::string& pName) const; 104 | 105 | std::vector GetCampaignNames() const; 106 | 107 | const sGameVersion* GetForCampaign(const std::string& pCampaign) const; 108 | const sGameVersion* GetForCampaign(const std::string& pCampaign, const ePlatform pPlatform) const; 109 | const sGameVersion* GetForTileset(eTileTypes pTileType, eTileSub pSub) const; 110 | const sGameVersion* GetRetail(const ePlatform pPlatform, const eGame pGame) const; 111 | const sGameVersion* GetDemo() const; 112 | }; 113 | 114 | extern const sGameVersion KnownGameVersions[20]; -------------------------------------------------------------------------------- /Source/Window.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Fodder 3 | * --------------- 4 | * 5 | * Copyright (C) 2008-2018 Open Fodder 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | */ 22 | 23 | class cWindow { 24 | 25 | protected: 26 | SDL_Window* mWindow; 27 | SDL_Renderer* mRenderer; 28 | SDL_Joystick* mJoy; 29 | 30 | std::vector mEvents; 31 | 32 | cDimension mOriginalResolution; 33 | 34 | cDimension mScreenSize; 35 | cPosition mMouseGlobal; 36 | 37 | uint8 mScaler, mScalerPrevious; 38 | 39 | bool mWindowMode; 40 | bool mHasFocus; 41 | bool mCursorGrabbed; 42 | bool mResized; 43 | 44 | protected: 45 | 46 | 47 | public: 48 | 49 | cWindow(); 50 | virtual ~cWindow(); 51 | 52 | void CalculateWindowSize(); 53 | int16 CalculateFullscreenSize(); 54 | 55 | bool CanChangeToMultiplier( const int pNewMultiplier ); 56 | 57 | bool Cycle(); 58 | 59 | std::vector* EventGet(); 60 | virtual void EventCheck(); 61 | virtual void FrameEnd(); 62 | 63 | virtual bool InitWindow( const std::string& pWindowTitle ); 64 | 65 | virtual void PositionWindow(); 66 | 67 | virtual void RenderAt( cSurface* pImage ); 68 | virtual void RenderShrunk( cSurface* pImage ); 69 | 70 | void WindowIncrease(); 71 | void WindowDecrease(); 72 | 73 | bool isFullscreen() const; 74 | bool isGrabbed() const; 75 | bool isMouseInside() const; 76 | bool isResized() const; 77 | bool isMouseButtonPressed_Global() const; 78 | 79 | void SetCursor(); 80 | 81 | cPosition GetMousePosition(const bool pRelative = false) const; 82 | void SetMousePosition(const cPosition& pPosition); 83 | void SetMouseWindowPosition( const cPosition& pPosition ); 84 | 85 | void SetScreenSize( const cDimension& pDimension ); 86 | void SetOriginalRes( const cDimension& pDimension ); 87 | 88 | void SetWindowTitle( const std::string& pWindowTitle ); 89 | void SetWindowSize(const int pMultiplier); 90 | 91 | void ToggleFullscreen(); 92 | void ClearResized(); 93 | 94 | SDL_Renderer* GetRenderer() const { return mRenderer; }; 95 | 96 | cPosition GetWindowPosition() const; 97 | int32 GetWindowWidth() const; 98 | int32 GetWindowHeight() const; 99 | 100 | cDimension GetWindowSize() const; 101 | cDimension GetScreenSize() const { return mScreenSize; } 102 | bool GetWindowMode() const { return mWindowMode; } 103 | bool HasFocus(); 104 | bool hasFocusEvent() const { return mHasFocus; } 105 | bool GetMouseGrabbed() const { return mCursorGrabbed; } 106 | cDimension GetScale() const; 107 | }; 108 | 109 | class cWindowNull : public cWindow { 110 | 111 | public: 112 | virtual ~cWindowNull() {} 113 | virtual bool InitWindow(const std::string& pWindowTitle); 114 | }; -------------------------------------------------------------------------------- /Source/stdafx.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Fodder 3 | * --------------- 4 | * 5 | * Copyright (C) 2008-2018 Open Fodder 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | */ 22 | 23 | #include "stdafx.hpp" 24 | 25 | std::shared_ptr g_Resource; 26 | std::shared_ptr g_Window; 27 | std::shared_ptr g_Fodder; 28 | std::shared_ptr g_Debugger; 29 | std::shared_ptr g_ResourceMan; 30 | std::shared_ptr g_ScriptingEngine; 31 | 32 | const char gPathSeperator = '/'; 33 | 34 | int main(int argc, char *argv[]) { 35 | auto result = start(argc, argv); 36 | if (result == -1) { 37 | std::cout << "Press enter to continue\n"; 38 | std::cin.get(); 39 | } 40 | 41 | return result; 42 | } 43 | 44 | /** 45 | * 46 | * @param pBuffer 47 | * @param pSize Number of words 48 | */ 49 | void tool_EndianSwap(uint8 *pBuffer, size_t pSize) { 50 | uint8 *pDest = pBuffer; 51 | 52 | pSize /= 2; 53 | 54 | while (pSize--) { 55 | uint8 al = *pBuffer++; 56 | uint8 ah = *pBuffer++; 57 | 58 | *pDest++ = ah; 59 | *pDest++ = al; 60 | } 61 | } 62 | 63 | std::string tool_StripLeadingZero(const std::string& pValue) { 64 | std::string Final = pValue; 65 | 66 | while (*Final.begin() == 0x30 && Final.length() > 1) { 67 | 68 | Final.erase(Final.begin()); 69 | } 70 | 71 | return Final; 72 | } 73 | 74 | uint16 tool_DecimalToBinaryCodedDecimal(uint16 pDecimal) { 75 | 76 | return ((pDecimal / 10) << 4) + (pDecimal % 10); 77 | } 78 | -------------------------------------------------------------------------------- /Source/stdafx.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Fodder 3 | * --------------- 4 | * 5 | * Copyright (C) 2008-2018 Open Fodder 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | #include 37 | #ifndef EMSCRIPTEN 38 | #include 39 | #else 40 | #include 41 | #include 42 | #endif 43 | 44 | #include "Types.hpp" 45 | 46 | typedef std::shared_ptr> tSharedBuffer; 47 | 48 | enum eDataType { 49 | eData = 0, 50 | eSave, 51 | eCampaign, 52 | eTest, 53 | eRoot, 54 | eScript, 55 | eNone, 56 | }; 57 | 58 | int start(int argc, char *argv[]); 59 | void tool_EndianSwap( uint8* pBuffer, size_t pSize ); 60 | std::string tool_StripLeadingZero( const std::string& pValue ); 61 | uint16 tool_DecimalToBinaryCodedDecimal( uint16 pDecimal ); 62 | 63 | // Read a BE word from the buffer 64 | inline uint16 readBEWord( const void *buffer ) { 65 | const uint8* bytes = (const uint8*) buffer; 66 | 67 | return uint16((bytes[0] << 8) + bytes[1]); 68 | } 69 | 70 | // Write a LE word in BE 71 | inline void writeBEWord( const void *buffer, uint16 pValue ) { 72 | uint8* bytes = (uint8*) buffer; 73 | 74 | bytes[0] = (uint8) (pValue >> 8); 75 | bytes[1] = (uint8) (pValue & 0xFF); 76 | } 77 | 78 | // Read a LE DWord in BE 79 | inline uint32 readBEDWord( const void *buffer ) { 80 | const uint8* bytes = (const uint8*) buffer; 81 | 82 | return uint32((bytes[0] << 24) + (bytes[1] << 16) + (bytes[2] << 8) + (bytes[3])); 83 | } 84 | 85 | // Read little endian from the buffer 86 | template inline tRet readLE(const void *pBuffer) { 87 | const tRet* data = (const tRet*)pBuffer; 88 | return *data; 89 | } 90 | 91 | inline void writeLEWord( const void *buffer, uint16 pValue ) { 92 | uint16* wordBytes = (uint16 *) buffer; 93 | *wordBytes = pValue; 94 | } 95 | 96 | #ifndef _WIN32 97 | #include 98 | #define Sleep( a ) usleep( a * 1000 ); 99 | 100 | #define _stricmp( a, b ) strcmp(a, b) 101 | #endif 102 | 103 | #include "Debugger.hpp" 104 | #include "Utils/pseudorand.hpp" 105 | 106 | #include "Position.hpp" 107 | #include "Dimension.hpp" 108 | #include "Event.hpp" 109 | 110 | #include "Surface.hpp" 111 | #include "Version.hpp" 112 | #include "Resources.hpp" 113 | 114 | #include "Parameters.hpp" 115 | 116 | #include "PC/Resource_PC_CD.hpp" 117 | //#include "Amiga/Resource_Amiga_File.hpp" 118 | 119 | #include "CopyProtection.hpp" 120 | #include "IntroData.hpp" 121 | #include "Tiles.hpp" 122 | 123 | #include "Map/Map.hpp" 124 | #include "Map/Original.hpp" 125 | //#include "Map/Random.hpp" 126 | 127 | #include "Campaign.hpp" 128 | #include "FontData.hpp" 129 | #include "Graphics.hpp" 130 | #include "Recruits.hpp" 131 | #include "Versions.hpp" 132 | #include "ResourceMan.hpp" 133 | 134 | #include "Window.hpp" 135 | #include "Sound.hpp" 136 | #include "GUI_Element.hpp" 137 | #include "SpriteSheet.hpp" 138 | #include "Fodder.hpp" 139 | 140 | #include "Structures/Barracks.hpp" 141 | 142 | #include "PC/Graphics_PC.hpp" 143 | #include "PC/Sound_PC.hpp" 144 | #include "PC/Sound_PC2.hpp" 145 | 146 | #include "Amiga/paula.hpp" 147 | #include "Amiga/rjp1.hpp" 148 | #include "Amiga/Sound_Amiga.hpp" 149 | #include "Amiga/Graphics_Amiga.hpp" 150 | #include "Amiga/Graphics_Amiga2.hpp" 151 | 152 | #include "About.hpp" 153 | #include "UnitTesting.hpp" 154 | 155 | #include "ScriptingEngine.hpp" 156 | 157 | extern std::shared_ptr g_Resource; 158 | extern std::shared_ptr g_Window; 159 | extern std::shared_ptr g_Fodder; 160 | extern std::shared_ptr g_Debugger; 161 | extern std::shared_ptr g_ResourceMan; 162 | extern std::shared_ptr g_ScriptingEngine; 163 | 164 | extern const char gPathSeperator; 165 | 166 | #define CANNON_BASED( pCF1, pCF2 ) (g_Fodder->mVersionCurrent->isCannonFodder1() ? pCF1 : pCF2 ) 167 | #define PLATFORM_BASED( pPC, pAmiga ) (g_Fodder->mVersionCurrent->isAmiga() ? pAmiga : pPC ) 168 | -------------------------------------------------------------------------------- /cmake/Modules/FindSDL2_mixer.cmake: -------------------------------------------------------------------------------- 1 | # - Locate SDL_mixer library 2 | # This module defines: 3 | # SDL_MIXER_LIBRARIES, the name of the library to link against 4 | # SDL_MIXER_INCLUDE_DIRS, where to find the headers 5 | # SDL_MIXER_FOUND, if false, do not try to link against 6 | # SDL_MIXER_VERSION_STRING - human-readable string containing the version of SDL_mixer 7 | # 8 | # For backward compatiblity the following variables are also set: 9 | # SDLMIXER_LIBRARY (same value as SDL_MIXER_LIBRARIES) 10 | # SDLMIXER_INCLUDE_DIR (same value as SDL_MIXER_INCLUDE_DIRS) 11 | # SDLMIXER_FOUND (same value as SDL_MIXER_FOUND) 12 | # 13 | # $SDLDIR is an environment variable that would 14 | # correspond to the ./configure --prefix=$SDLDIR 15 | # used in building SDL. 16 | # 17 | # Created by Eric Wing. This was influenced by the FindSDL.cmake 18 | # module, but with modifications to recognize OS X frameworks and 19 | # additional Unix paths (FreeBSD, etc). 20 | 21 | #============================================================================= 22 | # Copyright 2005-2009 Kitware, Inc. 23 | # Copyright 2012 Benjamin Eikel 24 | # 25 | # Distributed under the OSI-approved BSD License (the "License"); 26 | # see accompanying file Copyright.txt for details. 27 | # 28 | # This software is distributed WITHOUT ANY WARRANTY; without even the 29 | # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 30 | # See the License for more information. 31 | #============================================================================= 32 | # (To distribute this file outside of CMake, substitute the full 33 | # License text for the above reference.) 34 | 35 | if(NOT SDL_MIXER_INCLUDE_DIR AND SDLMIXER_INCLUDE_DIR) 36 | set(SDL_MIXER_INCLUDE_DIR ${SDLMIXER_INCLUDE_DIR} CACHE PATH "directory cache 37 | entry initialized from old variable name") 38 | endif() 39 | find_path(SDL_MIXER_INCLUDE_DIR SDL_mixer.h 40 | HINTS 41 | ENV SDLMIXERDIR 42 | ENV SDLDIR 43 | PATH_SUFFIXES SDL2 include/SDL2 include headers/SDL2 headers/x86/SDL2 44 | PATHS 45 | /boot/system/develop 46 | ${PROJECT_ROOT_DIR}/ext/SDL2 47 | ) 48 | 49 | MESSAGE(${SDL_MIXER_INCLUDE_DIR}) 50 | if(NOT SDL_MIXER_LIBRARY AND SDLMIXER_LIBRARY) 51 | set(SDL_MIXER_LIBRARY ${SDLMIXER_LIBRARY} CACHE FILEPATH "file cache entry 52 | initialized from old variable name") 53 | endif() 54 | find_library(SDL_MIXER_LIBRARY 55 | NAMES SDL2_mixer 56 | HINTS 57 | ENV SDLMIXERDIR 58 | ENV SDLDIR 59 | PATH_SUFFIXES lib lib/x86 60 | PATHS 61 | ${PROJECT_ROOT_DIR}/ext/SDL2 62 | ) 63 | 64 | MESSAGE(${SDL_MIXER_LIBRARY}) 65 | 66 | if(SDL_MIXER_INCLUDE_DIR AND EXISTS "${SDL_MIXER_INCLUDE_DIR}/SDL_mixer.h") 67 | file(STRINGS "${SDL_MIXER_INCLUDE_DIR}/SDL_mixer.h" SDL_MIXER_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_MIXER_MAJOR_VERSION[ \t]+[0-9]+$") 68 | file(STRINGS "${SDL_MIXER_INCLUDE_DIR}/SDL_mixer.h" SDL_MIXER_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_MIXER_MINOR_VERSION[ \t]+[0-9]+$") 69 | file(STRINGS "${SDL_MIXER_INCLUDE_DIR}/SDL_mixer.h" SDL_MIXER_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_MIXER_PATCHLEVEL[ \t]+[0-9]+$") 70 | string(REGEX REPLACE "^#define[ \t]+SDL_MIXER_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_MIXER_VERSION_MAJOR "${SDL_MIXER_VERSION_MAJOR_LINE}") 71 | string(REGEX REPLACE "^#define[ \t]+SDL_MIXER_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_MIXER_VERSION_MINOR "${SDL_MIXER_VERSION_MINOR_LINE}") 72 | string(REGEX REPLACE "^#define[ \t]+SDL_MIXER_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL_MIXER_VERSION_PATCH "${SDL_MIXER_VERSION_PATCH_LINE}") 73 | set(SDL_MIXER_VERSION_STRING ${SDL_MIXER_VERSION_MAJOR}.${SDL_MIXER_VERSION_MINOR}.${SDL_MIXER_VERSION_PATCH}) 74 | unset(SDL_MIXER_VERSION_MAJOR_LINE) 75 | unset(SDL_MIXER_VERSION_MINOR_LINE) 76 | unset(SDL_MIXER_VERSION_PATCH_LINE) 77 | unset(SDL_MIXER_VERSION_MAJOR) 78 | unset(SDL_MIXER_VERSION_MINOR) 79 | unset(SDL_MIXER_VERSION_PATCH) 80 | set(SDL_MIXER_FOUND 1) 81 | endif() 82 | 83 | set(SDL_MIXER_LIBRARIES ${SDL_MIXER_LIBRARY}) 84 | set(SDL_MIXER_INCLUDE_DIRS ${SDL_MIXER_INCLUDE_DIR}) 85 | 86 | #include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) 87 | 88 | #FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL_mixer 89 | # REQUIRED_VARS SDL_MIXER_LIBRARIES SDL_MIXER_INCLUDE_DIRS 90 | # VERSION_VAR SDL_MIXER_VERSION_STRING) 91 | 92 | # for backward compatiblity 93 | set(SDLMIXER_LIBRARY ${SDL_MIXER_LIBRARIES}) 94 | set(SDLMIXER_INCLUDE_DIR ${SDL_MIXER_INCLUDE_DIRS}) 95 | set(SDLMIXER_FOUND ${SDL_MIXER_FOUND}) 96 | 97 | mark_as_advanced(SDL_MIXER_LIBRARY SDL_MIXER_INCLUDE_DIR) 98 | -------------------------------------------------------------------------------- /openfodder.ini.example: -------------------------------------------------------------------------------- 1 | ; OpenFodder 2 | ; 3 | ; Example ini settings are the engine defaults 4 | ; 5 | 6 | [openfodder] 7 | 8 | 9 | ; Use touch input. Possible values: false, front, both 10 | use-touch=false 11 | 12 | [paths] 13 | ; Paths to data base folder 14 | ; There is no limit to the number paths in this section (eg, path1, path2... path10) 15 | ;path1=c:/games/openfodder 16 | ;path2=d:/games/openfodder 17 | ;path3=d:/games/openfodder 18 | 19 | ; 20 | ; 21 | [engine] 22 | 23 | ; Default platform (amiga/pc) 24 | platform=amiga 25 | 26 | ; Game engine to use in single/random maps (cf1/cf2) 27 | game=cf1 28 | 29 | ; Maximum number of sprites in game (original engine is 45) 30 | maxsprite=45 31 | 32 | ; Maximum number of enemies which can spawn (original engine is 10) 33 | maxspawn=10 34 | 35 | 36 | [skip] 37 | 38 | ; Skip the game introduction screens 39 | intro=false 40 | 41 | ; Skip the briefing screen 42 | briefing=false 43 | 44 | ; Skip the killed in action / promotion screens 45 | service=false 46 | 47 | ; Skip the hill recruit screen 48 | hill=false 49 | -------------------------------------------------------------------------------- /sce_sys/icon0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isage/openfodder/6601d9f72cf28a36a0fdfc0782db9f6b4189e206/sce_sys/icon0.png -------------------------------------------------------------------------------- /sce_sys/livearea/contents/bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isage/openfodder/6601d9f72cf28a36a0fdfc0782db9f6b4189e206/sce_sys/livearea/contents/bg.png -------------------------------------------------------------------------------- /sce_sys/livearea/contents/startup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/isage/openfodder/6601d9f72cf28a36a0fdfc0782db9f6b4189e206/sce_sys/livearea/contents/startup.png -------------------------------------------------------------------------------- /sce_sys/livearea/contents/template.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | bg.png 6 | 7 | 8 | 9 | startup.png 10 | 11 | 12 | 13 | 14 | 15 | OpenFodder 16 | 17 | 18 | 19 | 20 | --------------------------------------------------------------------------------