Skip to content

Commit

Permalink
Add Visual C++ build type. Build and Debug with Visual Studio
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesfmackenzie committed Nov 12, 2019
1 parent 0d68e8b commit 73b6c9b
Show file tree
Hide file tree
Showing 8 changed files with 205 additions and 4 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Expand Up @@ -37,6 +37,15 @@
chocolate-keen

# Visual Studio
.vs
*.suo
*.sdf
*.opendb
packages/
.user
/build/Visual C++/ChocolateKeen.vcxproj.user
/build/Visual C++/bin
/build/Visual C++/obj

# Commander Keen config files
Releases/Windows-x64/chocolate-keen.cfg
Expand Down
13 changes: 12 additions & 1 deletion README.md
Expand Up @@ -52,7 +52,7 @@ To build for WebAssembly, you'll need the <a href="https://github.com/emscripten
2. Navigate to `/build/emscripten`
3. Run `./emscripten/build_emscripten.sh`

### Windows (x86/x64)
### Windows (MinGW)
This is a Makefile project. To build for Windows you'll need something like <a href="https://www.msys2.org/" target="_blank">MSYS2</a> and a gcc toolchain. Find setup instructions <a href="https://www.math.ucla.edu/~wotaoyin/windows_coding.html" target="_blank">here</a>

1. Download and unzip SDL 2.0 development libraries: https://www.libsdl.org/download-2.0.php
Expand All @@ -66,6 +66,17 @@ This is a Makefile project. To build for Windows you'll need something like <a h
* `./mingw-w64/build_mingw-w64.sh /path/to/SDL2`
* e.g. `./build_mingw-w64.sh /d/Development/SDL2-2.0.9/x86_64-w64-mingw32/`

### Windows (Visual Studio)
Build and Debug with Microsoft Visual Studio / Visual C++

1. Navigate to `/build/Visual C++`
2. Open Solution file (`ChocolateKeen.sln`) in Visual Studio
3. Restore NuGet dependencies (Project -> Manage NuGet Dependencies > Restore)
4. Build (Build > Build Solution)
5. Run (Debug > Start Without Debugging) or Debug (Debug > Start Debugging)

Game data is automatically copied to the Target Directory as part of build - so everything should "just run"

## Authors
The original authors of Chocolate Keen are NY00123, QuantumG and Lemm. The project started with a reverse engineering of the original Keen code, and the goal is complete authenticity to the original - bugs and all. For more info see https://pckf.com/viewtopic.php?f=4&t=2536

Expand Down
22 changes: 22 additions & 0 deletions build/Visual C++/ChocolateKeen.sln
@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.24720.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ChocolateKeen", "ChocolateKeen.vcxproj", "{E6E1F291-D879-454F-968A-B5B6C0FFFFBE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x86 = Debug|x86
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E6E1F291-D879-454F-968A-B5B6C0FFFFBE}.Debug|x86.ActiveCfg = Debug|Win32
{E6E1F291-D879-454F-968A-B5B6C0FFFFBE}.Debug|x86.Build.0 = Debug|Win32
{E6E1F291-D879-454F-968A-B5B6C0FFFFBE}.Release|x86.ActiveCfg = Release|Win32
{E6E1F291-D879-454F-968A-B5B6C0FFFFBE}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
147 changes: 147 additions & 0 deletions build/Visual C++/ChocolateKeen.vcxproj
@@ -0,0 +1,147 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{E6E1F291-D879-454F-968A-B5B6C0FFFFBE}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)obj\$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)obj\$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;CHOCOLATE_KEEN_IS_EPISODE1_ENABLED;CHOCOLATE_KEEN_IS_EPISODE2_ENABLED;CHOCOLATE_KEEN_IS_EPISODE3_ENABLED;_CHOCOLATE_KEEN_ENABLE_OPENGL_;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<Optimization>Disabled</Optimization>
<BrowseInformation>true</BrowseInformation>
</ClCompile>
<Link>
<TargetMachine>MachineX86</TargetMachine>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
</Link>
<PostBuildEvent>
<Command>xcopy "$(SolutionDir)..\..\data\GAMEDATA" "$(TargetDir)GAMEDATA" /s /e /y /i</Command>
</PostBuildEvent>
<Bscmake>
<PreserveSbr>true</PreserveSbr>
</Bscmake>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;CHOCOLATE_KEEN_IS_EPISODE1_ENABLED;CHOCOLATE_KEEN_IS_EPISODE2_ENABLED;CHOCOLATE_KEEN_IS_EPISODE3_ENABLED;_CHOCOLATE_KEEN_ENABLE_OPENGL_;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<TargetMachine>MachineX86</TargetMachine>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
<PostBuildEvent>
<Command>xcopy $(SolutionDir)..\..\data\GAMEDATA $(TargetDir)GAMEDATA /s /e /y /i</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\src\chocolate-keen.c" />
<ClCompile Include="..\..\src\cvorticons.c" />
<ClCompile Include="..\..\src\cvorticons1.c" />
<ClCompile Include="..\..\src\cvorticons1_engine.c" />
<ClCompile Include="..\..\src\cvorticons1_memdata.c" />
<ClCompile Include="..\..\src\cvorticons2.c" />
<ClCompile Include="..\..\src\cvorticons2_engine.c" />
<ClCompile Include="..\..\src\cvorticons2_memdata.c" />
<ClCompile Include="..\..\src\cvorticons3.c" />
<ClCompile Include="..\..\src\cvorticons3_engine.c" />
<ClCompile Include="..\..\src\cvorticons3_memdata.c" />
<ClCompile Include="..\..\src\cvorticons_engine.c" />
<ClCompile Include="..\..\src\cvorticons_gfx.c" />
<ClCompile Include="..\..\src\cvorticons_gui.c" />
<ClCompile Include="..\..\src\cvorticons_input.c" />
<ClCompile Include="..\..\src\cvorticons_memdata.c" />
<ClCompile Include="..\..\src\decompression\cgenius\fileio\compression\CRLE.c" />
<ClCompile Include="..\..\src\decompression\cgenius\fileio\compression\Cunlzexe.c" />
<ClCompile Include="..\..\src\decompression\cgenius\fileio\lz.c" />
<ClCompile Include="..\..\src\decompression\imageRLE.c" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\packages.config" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\rsrc\chocolate-keen_icon.h" />
<ClInclude Include="..\..\rsrc\chocolate-keen_vga_fonts.h" />
<ClInclude Include="..\..\src\chocolate-keen_config.h" />
<ClInclude Include="..\..\src\cvorticons.h" />
<ClInclude Include="..\..\src\cvorticons1.h" />
<ClInclude Include="..\..\src\cvorticons2.h" />
<ClInclude Include="..\..\src\cvorticons3.h" />
<ClInclude Include="..\..\src\cvorticons_gfx.h" />
<ClInclude Include="..\..\src\cvorticons_input.h" />
<ClInclude Include="..\..\src\decompression\cgenius\fileio\compression\CRLE.h" />
<ClInclude Include="..\..\src\decompression\cgenius\fileio\compression\Cunlzexe.h" />
<ClInclude Include="..\..\src\decompression\cgenius\fileio\lz.h" />
<ClInclude Include="..\..\src\decompression\cgenius\fileio\TypeDefinitions.h" />
<ClInclude Include="..\..\src\decompression\imageRLE.h" />
<ClInclude Include="..\..\windows\include\gl\glext.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\..\rsrc\chocolate-keen.rc" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="packages\sdl2.redist.2.0.5\build\native\sdl2.redist.targets" Condition="Exists('packages\sdl2.redist.2.0.5\build\native\sdl2.redist.targets')" />
<Import Project="packages\sdl2.2.0.5\build\native\sdl2.targets" Condition="Exists('packages\sdl2.2.0.5\build\native\sdl2.targets')" />
</ImportGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('packages\sdl2.redist.2.0.5\build\native\sdl2.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\sdl2.redist.2.0.5\build\native\sdl2.redist.targets'))" />
<Error Condition="!Exists('packages\sdl2.2.0.5\build\native\sdl2.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\sdl2.2.0.5\build\native\sdl2.targets'))" />
</Target>
</Project>
5 changes: 5 additions & 0 deletions build/Visual C++/packages.config
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="sdl2" version="2.0.5" targetFramework="native" />
<package id="sdl2.redist" version="2.0.5" targetFramework="native" />
</packages>
5 changes: 2 additions & 3 deletions src/cvorticons.c
Expand Up @@ -3000,7 +3000,7 @@ void CVort_load_level_data(uint16_t levelnum) {
if (!fp)
return;
uint32_t len = CVort_filelength(fp);
uint8_t compressedMapData[len];
uint8_t *compressedMapData = (uint8_t*)malloc(sizeof(uint8_t) * len);
fread(compressedMapData, len, 1, fp);
fclose(fp);

Expand Down Expand Up @@ -3592,7 +3592,6 @@ uint16_t CVort_draw_level(uint16_t levelnum) {
return 0;
} while ((level_finished == LEVEL_END_DIE) && (sprites[0].type_));

// TODO: comment this out if sound running, otherwise the below will never finish
CVort_engine_finishCurSound();
CVort_fade_out();
for (var_4 = 0; var_4 < 4; var_4++)
Expand Down Expand Up @@ -5074,7 +5073,7 @@ void CVort_think_keen_exit() {
}
if ((time << 12) <= temp_sprite.posX) {
temp_sprite.type_ = 0;
level_finished = LEVEL_END_EXIT;
level_finished = LEVEL_END_EXIT;
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/cvorticons.h
Expand Up @@ -16,8 +16,12 @@
#define NO_SDL_GLEXT
#endif
#include "SDL_opengl.h"
#ifdef WIN32
#include "../windows/include/GL/glext.h"
#else
#include "GL/glext.h"
#endif
#endif

#define PC_PIT_RATE 1193182 // It is actually 1193181.8181...Hz
// The refresh rate is approximately 70.086Hz
Expand Down
4 changes: 4 additions & 0 deletions src/cvorticons_gfx.c
Expand Up @@ -13,8 +13,12 @@
#define NO_SDL_GLEXT
#endif
#include "SDL_opengl.h"
#ifdef WIN32
#include "../windows/include/GL/glext.h"
#else
#include "GL/glext.h"
#endif
#endif

// Set in CVort_engine_resetWindow
struct {
Expand Down

0 comments on commit 73b6c9b

Please sign in to comment.