Windows GDI port
This commit is contained in:
parent
136cc5954b
commit
486ac2b7fd
31
doomgeneric.sln
Normal file
31
doomgeneric.sln
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 15
|
||||||
|
VisualStudioVersion = 15.0.27130.2003
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "doomgeneric", "doomgeneric\doomgeneric.vcxproj", "{95A126D2-CC94-4840-BF05-80305041B5FB}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Debug|x86 = Debug|x86
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
Release|x86 = Release|x86
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{95A126D2-CC94-4840-BF05-80305041B5FB}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{95A126D2-CC94-4840-BF05-80305041B5FB}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{95A126D2-CC94-4840-BF05-80305041B5FB}.Debug|x86.ActiveCfg = Debug|Win32
|
||||||
|
{95A126D2-CC94-4840-BF05-80305041B5FB}.Debug|x86.Build.0 = Debug|Win32
|
||||||
|
{95A126D2-CC94-4840-BF05-80305041B5FB}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{95A126D2-CC94-4840-BF05-80305041B5FB}.Release|x64.Build.0 = Release|x64
|
||||||
|
{95A126D2-CC94-4840-BF05-80305041B5FB}.Release|x86.ActiveCfg = Release|Win32
|
||||||
|
{95A126D2-CC94-4840-BF05-80305041B5FB}.Release|x86.Build.0 = Release|Win32
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {E444537A-F1DB-44A6-8720-C7DC7BB2C74A}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
@ -1,61 +0,0 @@
|
|||||||
################################################################
|
|
||||||
#
|
|
||||||
# $Id:$
|
|
||||||
#
|
|
||||||
# $Log:$
|
|
||||||
#
|
|
||||||
|
|
||||||
CROSS_COMPILE ?= #arm-linux-gnueabihf-
|
|
||||||
|
|
||||||
ifeq ($(V),1)
|
|
||||||
VB=''
|
|
||||||
else
|
|
||||||
VB=@
|
|
||||||
endif
|
|
||||||
|
|
||||||
#LIBS+=-lXext -lX11 -lnsl -lm -lSDL
|
|
||||||
#CFLAGS+=-Wunused-const-variable=0
|
|
||||||
#CFLAGS+=-fsanitize=address
|
|
||||||
OBJS+=$(OBJDIR)/i_video_fbdev.o
|
|
||||||
OBJS+=$(OBJDIR)/i_input_tty.o
|
|
||||||
|
|
||||||
CC=$(CROSS_COMPILE)gcc # gcc or g++
|
|
||||||
CFLAGS+=-ggdb3 -Os
|
|
||||||
LDFLAGS+=-Wl,--gc-sections
|
|
||||||
CFLAGS+=-ggdb3 -Wall -DNORMALUNIX -DLINUX -DSNDSERV # -DUSEASM
|
|
||||||
LIBS+=-lm -lc -lSDL
|
|
||||||
|
|
||||||
# subdirectory for objects
|
|
||||||
OBJDIR=build
|
|
||||||
OUTPUT=fbdoom
|
|
||||||
|
|
||||||
SRC_DOOM = i_main.o dummy.o am_map.o doomdef.o doomstat.o dstrings.o d_event.o d_items.o d_iwad.o d_loop.o d_main.o d_mode.o d_net.o f_finale.o f_wipe.o g_game.o hu_lib.o hu_stuff.o info.o i_cdmus.o i_endoom.o i_joystick.o i_scale.o i_sound.o i_system.o i_timer.o memio.o m_argv.o m_bbox.o m_cheat.o m_config.o m_controls.o m_fixed.o m_menu.o m_misc.o m_random.o p_ceilng.o p_doors.o p_enemy.o p_floor.o p_inter.o p_lights.o p_map.o p_maputl.o p_mobj.o p_plats.o p_pspr.o p_saveg.o p_setup.o p_sight.o p_spec.o p_switch.o p_telept.o p_tick.o p_user.o r_bsp.o r_data.o r_draw.o r_main.o r_plane.o r_segs.o r_sky.o r_things.o sha1.o sounds.o statdump.o st_lib.o st_stuff.o s_sound.o tables.o v_video.o wi_stuff.o w_checksum.o w_file.o w_file_stdc_unbuffered.o w_main.o w_wad.o z_zone.o
|
|
||||||
OBJS += $(addprefix $(OBJDIR)/, $(SRC_DOOM))
|
|
||||||
|
|
||||||
all: $(OUTPUT)
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -rf $(OBJDIR)
|
|
||||||
rm -f $(OUTPUT)
|
|
||||||
rm -f $(OUTPUT).gdb
|
|
||||||
rm -f $(OUTPUT).map
|
|
||||||
|
|
||||||
$(OUTPUT): $(OBJS)
|
|
||||||
@echo [Linking $@]
|
|
||||||
$(VB)$(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) \
|
|
||||||
-o $(OUTPUT) $(LIBS) -Wl,-Map,$(OUTPUT).map
|
|
||||||
@echo [Size]
|
|
||||||
-$(CROSS_COMPILE)size $(OUTPUT)
|
|
||||||
|
|
||||||
$(OBJS): | $(OBJDIR)
|
|
||||||
|
|
||||||
$(OBJDIR):
|
|
||||||
mkdir -p $(OBJDIR)
|
|
||||||
|
|
||||||
$(OBJDIR)/%.o: %.c
|
|
||||||
@echo [Compiling $<]
|
|
||||||
$(VB)$(CC) $(CFLAGS) -c $< -o $@
|
|
||||||
|
|
||||||
print:
|
|
||||||
@echo OBJS: $(OBJS)
|
|
||||||
|
|
@ -70,13 +70,13 @@
|
|||||||
#undef PACKAGE_BUGREPORT
|
#undef PACKAGE_BUGREPORT
|
||||||
|
|
||||||
/* Define to the full name of this package. */
|
/* Define to the full name of this package. */
|
||||||
#define PACKAGE_NAME "FDoom"
|
#define PACKAGE_NAME "Doom Generic"
|
||||||
|
|
||||||
/* Define to the full name and version of this package. */
|
/* Define to the full name and version of this package. */
|
||||||
#define PACKAGE_STRING "FDoom 0.1"
|
#define PACKAGE_STRING "Doom Generic 0.1"
|
||||||
|
|
||||||
/* Define to the one symbol short name of this package. */
|
/* Define to the one symbol short name of this package. */
|
||||||
#define PACKAGE_TARNAME "fdoom.tar"
|
#define PACKAGE_TARNAME "doomgeneric.tar"
|
||||||
|
|
||||||
/* Define to the home page for this package. */
|
/* Define to the home page for this package. */
|
||||||
#define PACKAGE_URL ""
|
#define PACKAGE_URL ""
|
||||||
@ -85,7 +85,7 @@
|
|||||||
#define PACKAGE_VERSION 0.1
|
#define PACKAGE_VERSION 0.1
|
||||||
|
|
||||||
/* Change this when you create your awesome forked version */
|
/* Change this when you create your awesome forked version */
|
||||||
#define PROGRAM_PREFIX "fdoom"
|
#define PROGRAM_PREFIX "doomgeneric"
|
||||||
|
|
||||||
/* Define to 1 if you have the ANSI C header files. */
|
/* Define to 1 if you have the ANSI C header files. */
|
||||||
#define STDC_HEADERS 1
|
#define STDC_HEADERS 1
|
||||||
|
@ -611,6 +611,8 @@ static void BuildIWADDirList(void)
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
|
AddIWADDir(".");
|
||||||
|
|
||||||
AddIWADDir (FILES_DIR);
|
AddIWADDir (FILES_DIR);
|
||||||
|
|
||||||
// Don't run this function again.
|
// Don't run this function again.
|
||||||
|
@ -72,7 +72,6 @@
|
|||||||
#include "r_local.h"
|
#include "r_local.h"
|
||||||
#include "statdump.h"
|
#include "statdump.h"
|
||||||
|
|
||||||
|
|
||||||
#include "d_main.h"
|
#include "d_main.h"
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -1080,6 +1079,8 @@ static void D_Endoom(void)
|
|||||||
endoom = W_CacheLumpName(DEH_String("ENDOOM"), PU_STATIC);
|
endoom = W_CacheLumpName(DEH_String("ENDOOM"), PU_STATIC);
|
||||||
|
|
||||||
I_Endoom(endoom);
|
I_Endoom(endoom);
|
||||||
|
|
||||||
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ORIGCODE
|
#if ORIGCODE
|
||||||
|
12
doomgeneric/doomgeneric.c
Normal file
12
doomgeneric/doomgeneric.c
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#include "doomgeneric.h"
|
||||||
|
|
||||||
|
uint32_t* DG_ScreenBuffer = 0;
|
||||||
|
|
||||||
|
|
||||||
|
void dg_Create()
|
||||||
|
{
|
||||||
|
DG_ScreenBuffer = malloc(DOOMGENERIC_RESX * DOOMGENERIC_RESY * 4);
|
||||||
|
|
||||||
|
DG_Init();
|
||||||
|
}
|
||||||
|
|
20
doomgeneric/doomgeneric.h
Normal file
20
doomgeneric/doomgeneric.h
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#ifndef DOOM_GENERIC
|
||||||
|
#define DOOM_GENERIC
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#define DOOMGENERIC_RESX 640
|
||||||
|
#define DOOMGENERIC_RESY 400
|
||||||
|
|
||||||
|
|
||||||
|
extern uint32_t* DG_ScreenBuffer;
|
||||||
|
|
||||||
|
|
||||||
|
void DG_Init();
|
||||||
|
void DG_DrawFrame();
|
||||||
|
void DG_SleepMs(uint32_t ms);
|
||||||
|
uint32_t DG_GetTicksMs();
|
||||||
|
int DG_GetKey(int* pressed, unsigned char* key);
|
||||||
|
void DG_SetWindowTitle(const char * title);
|
||||||
|
|
||||||
|
#endif //DOOM_GENERIC
|
336
doomgeneric/doomgeneric.vcxproj
Normal file
336
doomgeneric/doomgeneric.vcxproj
Normal file
@ -0,0 +1,336 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="15.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>
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<VCProjectVersion>15.0</VCProjectVersion>
|
||||||
|
<ProjectGuid>{95A126D2-CC94-4840-BF05-80305041B5FB}</ProjectGuid>
|
||||||
|
<Keyword>Win32Proj</Keyword>
|
||||||
|
<RootNamespace>doomgeneric</RootNamespace>
|
||||||
|
<WindowsTargetPlatformVersion>10.0.17763.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>v141</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v141</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v141</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v141</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</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>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<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|x64'">
|
||||||
|
<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>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<SDLCheck>false</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<SDLCheck>false</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="am_map.c" />
|
||||||
|
<ClCompile Include="doomdef.c" />
|
||||||
|
<ClCompile Include="doomgeneric.c" />
|
||||||
|
<ClCompile Include="doomgeneric_win.c" />
|
||||||
|
<ClCompile Include="doomstat.c" />
|
||||||
|
<ClCompile Include="dstrings.c" />
|
||||||
|
<ClCompile Include="dummy.c" />
|
||||||
|
<ClCompile Include="d_event.c" />
|
||||||
|
<ClCompile Include="d_items.c" />
|
||||||
|
<ClCompile Include="d_iwad.c" />
|
||||||
|
<ClCompile Include="d_loop.c" />
|
||||||
|
<ClCompile Include="d_main.c" />
|
||||||
|
<ClCompile Include="d_mode.c" />
|
||||||
|
<ClCompile Include="d_net.c" />
|
||||||
|
<ClCompile Include="f_finale.c" />
|
||||||
|
<ClCompile Include="f_wipe.c" />
|
||||||
|
<ClCompile Include="gusconf.c" />
|
||||||
|
<ClCompile Include="g_game.c" />
|
||||||
|
<ClCompile Include="hu_lib.c" />
|
||||||
|
<ClCompile Include="hu_stuff.c" />
|
||||||
|
<ClCompile Include="icon.c" />
|
||||||
|
<ClCompile Include="info.c" />
|
||||||
|
<ClCompile Include="i_cdmus.c" />
|
||||||
|
<ClCompile Include="i_endoom.c" />
|
||||||
|
<ClCompile Include="i_input.c" />
|
||||||
|
<ClCompile Include="i_joystick.c" />
|
||||||
|
<ClCompile Include="i_main.c" />
|
||||||
|
<ClCompile Include="i_scale.c" />
|
||||||
|
<ClCompile Include="i_sound.c" />
|
||||||
|
<ClCompile Include="i_system.c" />
|
||||||
|
<ClCompile Include="i_timer.c" />
|
||||||
|
<ClCompile Include="i_video.c" />
|
||||||
|
<ClCompile Include="memio.c" />
|
||||||
|
<ClCompile Include="m_argv.c" />
|
||||||
|
<ClCompile Include="m_bbox.c" />
|
||||||
|
<ClCompile Include="m_cheat.c" />
|
||||||
|
<ClCompile Include="m_config.c" />
|
||||||
|
<ClCompile Include="m_controls.c" />
|
||||||
|
<ClCompile Include="m_fixed.c" />
|
||||||
|
<ClCompile Include="m_menu.c" />
|
||||||
|
<ClCompile Include="m_misc.c" />
|
||||||
|
<ClCompile Include="m_random.c" />
|
||||||
|
<ClCompile Include="p_ceilng.c" />
|
||||||
|
<ClCompile Include="p_doors.c" />
|
||||||
|
<ClCompile Include="p_enemy.c" />
|
||||||
|
<ClCompile Include="p_floor.c" />
|
||||||
|
<ClCompile Include="p_inter.c" />
|
||||||
|
<ClCompile Include="p_lights.c" />
|
||||||
|
<ClCompile Include="p_map.c" />
|
||||||
|
<ClCompile Include="p_maputl.c" />
|
||||||
|
<ClCompile Include="p_mobj.c" />
|
||||||
|
<ClCompile Include="p_plats.c" />
|
||||||
|
<ClCompile Include="p_pspr.c" />
|
||||||
|
<ClCompile Include="p_saveg.c" />
|
||||||
|
<ClCompile Include="p_setup.c" />
|
||||||
|
<ClCompile Include="p_sight.c" />
|
||||||
|
<ClCompile Include="p_spec.c" />
|
||||||
|
<ClCompile Include="p_switch.c" />
|
||||||
|
<ClCompile Include="p_telept.c" />
|
||||||
|
<ClCompile Include="p_tick.c" />
|
||||||
|
<ClCompile Include="p_user.c" />
|
||||||
|
<ClCompile Include="r_bsp.c" />
|
||||||
|
<ClCompile Include="r_data.c" />
|
||||||
|
<ClCompile Include="r_draw.c" />
|
||||||
|
<ClCompile Include="r_main.c" />
|
||||||
|
<ClCompile Include="r_plane.c" />
|
||||||
|
<ClCompile Include="r_segs.c" />
|
||||||
|
<ClCompile Include="r_sky.c" />
|
||||||
|
<ClCompile Include="r_things.c" />
|
||||||
|
<ClCompile Include="sha1.c" />
|
||||||
|
<ClCompile Include="sounds.c" />
|
||||||
|
<ClCompile Include="statdump.c" />
|
||||||
|
<ClCompile Include="st_lib.c" />
|
||||||
|
<ClCompile Include="st_stuff.c" />
|
||||||
|
<ClCompile Include="s_sound.c" />
|
||||||
|
<ClCompile Include="tables.c" />
|
||||||
|
<ClCompile Include="v_video.c" />
|
||||||
|
<ClCompile Include="wi_stuff.c" />
|
||||||
|
<ClCompile Include="w_checksum.c" />
|
||||||
|
<ClCompile Include="w_file.c" />
|
||||||
|
<ClCompile Include="w_file_stdc.c" />
|
||||||
|
<ClCompile Include="w_main.c" />
|
||||||
|
<ClCompile Include="w_wad.c" />
|
||||||
|
<ClCompile Include="z_zone.c" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="am_map.h" />
|
||||||
|
<ClInclude Include="config.h" />
|
||||||
|
<ClInclude Include="deh_main.h" />
|
||||||
|
<ClInclude Include="deh_misc.h" />
|
||||||
|
<ClInclude Include="deh_str.h" />
|
||||||
|
<ClInclude Include="doom.h" />
|
||||||
|
<ClInclude Include="doomdata.h" />
|
||||||
|
<ClInclude Include="doomdef.h" />
|
||||||
|
<ClInclude Include="doomfeatures.h" />
|
||||||
|
<ClInclude Include="doomgeneric.h" />
|
||||||
|
<ClInclude Include="doomkeys.h" />
|
||||||
|
<ClInclude Include="doomstat.h" />
|
||||||
|
<ClInclude Include="doomtype.h" />
|
||||||
|
<ClInclude Include="dstrings.h" />
|
||||||
|
<ClInclude Include="d_englsh.h" />
|
||||||
|
<ClInclude Include="d_event.h" />
|
||||||
|
<ClInclude Include="d_items.h" />
|
||||||
|
<ClInclude Include="d_iwad.h" />
|
||||||
|
<ClInclude Include="d_loop.h" />
|
||||||
|
<ClInclude Include="d_main.h" />
|
||||||
|
<ClInclude Include="d_mode.h" />
|
||||||
|
<ClInclude Include="d_player.h" />
|
||||||
|
<ClInclude Include="d_textur.h" />
|
||||||
|
<ClInclude Include="d_think.h" />
|
||||||
|
<ClInclude Include="d_ticcmd.h" />
|
||||||
|
<ClInclude Include="f_finale.h" />
|
||||||
|
<ClInclude Include="f_wipe.h" />
|
||||||
|
<ClInclude Include="gusconf.h" />
|
||||||
|
<ClInclude Include="g_game.h" />
|
||||||
|
<ClInclude Include="hu_lib.h" />
|
||||||
|
<ClInclude Include="hu_stuff.h" />
|
||||||
|
<ClInclude Include="info.h" />
|
||||||
|
<ClInclude Include="i_cdmus.h" />
|
||||||
|
<ClInclude Include="i_endoom.h" />
|
||||||
|
<ClInclude Include="i_joystick.h" />
|
||||||
|
<ClInclude Include="i_scale.h" />
|
||||||
|
<ClInclude Include="i_sound.h" />
|
||||||
|
<ClInclude Include="i_swap.h" />
|
||||||
|
<ClInclude Include="i_system.h" />
|
||||||
|
<ClInclude Include="i_timer.h" />
|
||||||
|
<ClInclude Include="i_video.h" />
|
||||||
|
<ClInclude Include="memio.h" />
|
||||||
|
<ClInclude Include="m_argv.h" />
|
||||||
|
<ClInclude Include="m_bbox.h" />
|
||||||
|
<ClInclude Include="m_cheat.h" />
|
||||||
|
<ClInclude Include="m_config.h" />
|
||||||
|
<ClInclude Include="m_controls.h" />
|
||||||
|
<ClInclude Include="m_fixed.h" />
|
||||||
|
<ClInclude Include="m_menu.h" />
|
||||||
|
<ClInclude Include="m_misc.h" />
|
||||||
|
<ClInclude Include="m_random.h" />
|
||||||
|
<ClInclude Include="net_client.h" />
|
||||||
|
<ClInclude Include="net_dedicated.h" />
|
||||||
|
<ClInclude Include="net_defs.h" />
|
||||||
|
<ClInclude Include="net_gui.h" />
|
||||||
|
<ClInclude Include="net_io.h" />
|
||||||
|
<ClInclude Include="net_loop.h" />
|
||||||
|
<ClInclude Include="net_packet.h" />
|
||||||
|
<ClInclude Include="net_query.h" />
|
||||||
|
<ClInclude Include="net_sdl.h" />
|
||||||
|
<ClInclude Include="net_server.h" />
|
||||||
|
<ClInclude Include="p_inter.h" />
|
||||||
|
<ClInclude Include="p_local.h" />
|
||||||
|
<ClInclude Include="p_mobj.h" />
|
||||||
|
<ClInclude Include="p_pspr.h" />
|
||||||
|
<ClInclude Include="p_saveg.h" />
|
||||||
|
<ClInclude Include="p_setup.h" />
|
||||||
|
<ClInclude Include="p_spec.h" />
|
||||||
|
<ClInclude Include="p_tick.h" />
|
||||||
|
<ClInclude Include="r_bsp.h" />
|
||||||
|
<ClInclude Include="r_data.h" />
|
||||||
|
<ClInclude Include="r_defs.h" />
|
||||||
|
<ClInclude Include="r_draw.h" />
|
||||||
|
<ClInclude Include="r_local.h" />
|
||||||
|
<ClInclude Include="r_main.h" />
|
||||||
|
<ClInclude Include="r_plane.h" />
|
||||||
|
<ClInclude Include="r_segs.h" />
|
||||||
|
<ClInclude Include="r_sky.h" />
|
||||||
|
<ClInclude Include="r_state.h" />
|
||||||
|
<ClInclude Include="r_things.h" />
|
||||||
|
<ClInclude Include="sha1.h" />
|
||||||
|
<ClInclude Include="sounds.h" />
|
||||||
|
<ClInclude Include="statdump.h" />
|
||||||
|
<ClInclude Include="st_lib.h" />
|
||||||
|
<ClInclude Include="st_stuff.h" />
|
||||||
|
<ClInclude Include="s_sound.h" />
|
||||||
|
<ClInclude Include="tables.h" />
|
||||||
|
<ClInclude Include="v_patch.h" />
|
||||||
|
<ClInclude Include="v_video.h" />
|
||||||
|
<ClInclude Include="wi_stuff.h" />
|
||||||
|
<ClInclude Include="w_checksum.h" />
|
||||||
|
<ClInclude Include="w_file.h" />
|
||||||
|
<ClInclude Include="w_main.h" />
|
||||||
|
<ClInclude Include="w_merge.h" />
|
||||||
|
<ClInclude Include="w_wad.h" />
|
||||||
|
<ClInclude Include="z_zone.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
561
doomgeneric/doomgeneric.vcxproj.filters
Normal file
561
doomgeneric/doomgeneric.vcxproj.filters
Normal file
@ -0,0 +1,561 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup>
|
||||||
|
<Filter Include="Source Files">
|
||||||
|
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||||
|
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Header Files">
|
||||||
|
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||||
|
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Resource Files">
|
||||||
|
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||||
|
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||||
|
</Filter>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="am_map.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="d_event.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="d_items.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="d_iwad.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="d_loop.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="d_main.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="d_mode.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="d_net.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="doomdef.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="doomstat.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="dstrings.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="dummy.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="f_finale.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="f_wipe.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="g_game.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="gusconf.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="hu_lib.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="hu_stuff.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="i_cdmus.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="i_endoom.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="i_joystick.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="i_main.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="i_scale.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="i_sound.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="i_system.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="i_timer.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="icon.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="info.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="m_argv.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="m_bbox.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="m_cheat.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="m_config.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="m_controls.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="m_fixed.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="m_menu.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="m_misc.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="m_random.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="memio.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="p_ceilng.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="p_doors.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="p_enemy.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="p_floor.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="p_inter.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="p_lights.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="p_map.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="p_maputl.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="p_mobj.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="p_plats.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="p_pspr.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="p_saveg.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="p_setup.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="p_sight.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="p_spec.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="p_switch.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="p_telept.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="p_tick.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="p_user.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="r_bsp.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="r_data.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="r_draw.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="r_main.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="r_plane.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="r_segs.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="r_sky.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="r_things.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="s_sound.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="sha1.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="sounds.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="st_lib.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="st_stuff.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="statdump.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="tables.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="v_video.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="w_checksum.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="w_file.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="w_file_stdc.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="w_main.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="w_wad.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="wi_stuff.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="z_zone.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="doomgeneric.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="doomgeneric_win.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="i_input.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="i_video.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="am_map.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="config.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="d_englsh.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="d_event.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="d_items.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="d_iwad.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="d_loop.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="d_main.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="d_mode.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="d_player.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="d_textur.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="d_think.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="d_ticcmd.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="deh_main.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="deh_misc.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="deh_str.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="doom.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="doomdata.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="doomdef.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="doomfeatures.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="doomkeys.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="doomstat.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="doomtype.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="dstrings.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="f_finale.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="f_wipe.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="g_game.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="gusconf.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="hu_lib.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="hu_stuff.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="i_cdmus.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="i_endoom.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="i_joystick.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="i_scale.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="i_sound.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="i_swap.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="i_system.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="i_timer.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="i_video.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="info.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="m_argv.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="m_bbox.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="m_cheat.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="m_config.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="m_controls.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="m_fixed.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="m_menu.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="m_misc.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="m_random.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="memio.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="net_client.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="net_dedicated.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="net_defs.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="net_gui.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="net_io.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="net_loop.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="net_packet.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="net_query.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="net_sdl.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="net_server.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="p_inter.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="p_local.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="p_mobj.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="p_pspr.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="p_saveg.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="p_setup.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="p_spec.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="p_tick.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="r_bsp.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="r_data.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="r_defs.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="r_draw.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="r_local.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="r_main.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="r_plane.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="r_segs.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="r_sky.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="r_state.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="r_things.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="s_sound.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="sha1.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="sounds.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="st_lib.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="st_stuff.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="statdump.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="tables.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="v_patch.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="v_video.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="w_checksum.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="w_file.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="w_main.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="w_merge.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="w_wad.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="wi_stuff.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="z_zone.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="doomgeneric.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
197
doomgeneric/doomgeneric_win.c
Normal file
197
doomgeneric/doomgeneric_win.c
Normal file
@ -0,0 +1,197 @@
|
|||||||
|
#include "doomkeys.h"
|
||||||
|
|
||||||
|
#include "doomgeneric.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <Windows.h>
|
||||||
|
|
||||||
|
static BITMAPINFO s_Bmi = { sizeof(BITMAPINFOHEADER), DOOMGENERIC_RESX, -DOOMGENERIC_RESY, 1, 32 };
|
||||||
|
static HWND s_Hwnd = 0;
|
||||||
|
static HDC s_Hdc = 0;
|
||||||
|
|
||||||
|
|
||||||
|
#define KEYQUEUE_SIZE 16
|
||||||
|
|
||||||
|
static unsigned short s_KeyQueue[KEYQUEUE_SIZE];
|
||||||
|
static unsigned int s_KeyQueueWriteIndex = 0;
|
||||||
|
static unsigned int s_KeyQueueReadIndex = 0;
|
||||||
|
|
||||||
|
static unsigned char convertToDoomKey(unsigned char key)
|
||||||
|
{
|
||||||
|
switch (key)
|
||||||
|
{
|
||||||
|
case VK_RETURN:
|
||||||
|
key = KEY_ENTER;
|
||||||
|
break;
|
||||||
|
case VK_ESCAPE:
|
||||||
|
key = KEY_ESCAPE;
|
||||||
|
break;
|
||||||
|
case VK_LEFT:
|
||||||
|
key = KEY_LEFTARROW;
|
||||||
|
break;
|
||||||
|
case VK_RIGHT:
|
||||||
|
key = KEY_RIGHTARROW;
|
||||||
|
break;
|
||||||
|
case VK_UP:
|
||||||
|
key = KEY_UPARROW;
|
||||||
|
break;
|
||||||
|
case VK_DOWN:
|
||||||
|
key = KEY_DOWNARROW;
|
||||||
|
break;
|
||||||
|
case VK_CONTROL:
|
||||||
|
key = KEY_FIRE;
|
||||||
|
break;
|
||||||
|
case VK_SPACE:
|
||||||
|
key = KEY_USE;
|
||||||
|
break;
|
||||||
|
case VK_SHIFT:
|
||||||
|
key = KEY_RSHIFT;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
key = tolower(key);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void addKeyToQueue(int pressed, unsigned char keyCode)
|
||||||
|
{
|
||||||
|
unsigned char key = convertToDoomKey(keyCode);
|
||||||
|
|
||||||
|
unsigned short keyData = (pressed << 8) | key;
|
||||||
|
|
||||||
|
s_KeyQueue[s_KeyQueueWriteIndex] = keyData;
|
||||||
|
s_KeyQueueWriteIndex++;
|
||||||
|
s_KeyQueueWriteIndex %= KEYQUEUE_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static LRESULT CALLBACK wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
switch (msg)
|
||||||
|
{
|
||||||
|
case WM_CLOSE:
|
||||||
|
DestroyWindow(hwnd);
|
||||||
|
break;
|
||||||
|
case WM_DESTROY:
|
||||||
|
PostQuitMessage(0);
|
||||||
|
ExitProcess(0);
|
||||||
|
break;
|
||||||
|
case WM_KEYDOWN:
|
||||||
|
addKeyToQueue(1, wParam);
|
||||||
|
break;
|
||||||
|
case WM_KEYUP:
|
||||||
|
addKeyToQueue(0, wParam);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return DefWindowProcA(hwnd, msg, wParam, lParam);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DG_Init()
|
||||||
|
{
|
||||||
|
// window creation
|
||||||
|
const char windowClassName[] = "DoomWindowClass";
|
||||||
|
const char windowTitle[] = "Doom";
|
||||||
|
WNDCLASSEXA wc;
|
||||||
|
|
||||||
|
wc.cbSize = sizeof(WNDCLASSEXA);
|
||||||
|
wc.style = 0;
|
||||||
|
wc.lpfnWndProc = wndProc;
|
||||||
|
wc.cbClsExtra = 0;
|
||||||
|
wc.cbWndExtra = 0;
|
||||||
|
wc.hInstance = 0;
|
||||||
|
wc.hIcon = 0;
|
||||||
|
wc.hCursor = 0;
|
||||||
|
wc.hbrBackground = 0;
|
||||||
|
wc.lpszMenuName = 0;
|
||||||
|
wc.lpszClassName = windowClassName;
|
||||||
|
wc.hIconSm = 0;
|
||||||
|
|
||||||
|
if (!RegisterClassExA(&wc))
|
||||||
|
{
|
||||||
|
printf("Window Registration Failed!");
|
||||||
|
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
RECT rect;
|
||||||
|
rect.left = rect.top = 0;
|
||||||
|
rect.right = DOOMGENERIC_RESX;
|
||||||
|
rect.bottom = DOOMGENERIC_RESY;
|
||||||
|
AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, FALSE);
|
||||||
|
|
||||||
|
HWND hwnd = CreateWindowExA(0, windowClassName, windowTitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, rect.right - rect.left, rect.bottom - rect.top, 0, 0, 0, 0);
|
||||||
|
if (hwnd)
|
||||||
|
{
|
||||||
|
s_Hwnd = hwnd;
|
||||||
|
|
||||||
|
s_Hdc = GetDC(hwnd);
|
||||||
|
ShowWindow(hwnd, SW_SHOW);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("Window Creation Failed!");
|
||||||
|
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(s_KeyQueue, 0, KEYQUEUE_SIZE * sizeof(unsigned short));
|
||||||
|
}
|
||||||
|
|
||||||
|
void DG_DrawFrame()
|
||||||
|
{
|
||||||
|
MSG msg;
|
||||||
|
memset(&msg, 0, sizeof(msg));
|
||||||
|
|
||||||
|
while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE) > 0)
|
||||||
|
{
|
||||||
|
TranslateMessage(&msg);
|
||||||
|
DispatchMessageA(&msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
StretchDIBits(s_Hdc, 0, 0, DOOMGENERIC_RESX, DOOMGENERIC_RESY, 0, 0, DOOMGENERIC_RESX, DOOMGENERIC_RESY, DG_ScreenBuffer, &s_Bmi, 0, SRCCOPY);
|
||||||
|
|
||||||
|
SwapBuffers(s_Hdc);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DG_SleepMs(uint32_t ms)
|
||||||
|
{
|
||||||
|
Sleep(ms);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t DG_GetTicksMs()
|
||||||
|
{
|
||||||
|
return GetTickCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
int DG_GetKey(int* pressed, unsigned char* doomKey)
|
||||||
|
{
|
||||||
|
if (s_KeyQueueReadIndex == s_KeyQueueWriteIndex)
|
||||||
|
{
|
||||||
|
//key queue is empty
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
unsigned short keyData = s_KeyQueue[s_KeyQueueReadIndex];
|
||||||
|
s_KeyQueueReadIndex++;
|
||||||
|
s_KeyQueueReadIndex %= KEYQUEUE_SIZE;
|
||||||
|
|
||||||
|
*pressed = keyData >> 8;
|
||||||
|
*doomKey = keyData & 0xFF;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DG_SetWindowTitle(const char * title)
|
||||||
|
{
|
||||||
|
if (s_Hwnd)
|
||||||
|
{
|
||||||
|
SetWindowTextA(s_Hwnd, title);
|
||||||
|
}
|
||||||
|
}
|
@ -27,8 +27,8 @@
|
|||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
#define strcasecmp stricmp
|
#define strcasecmp _stricmp
|
||||||
#define strncasecmp strnicmp
|
#define strncasecmp _strnicmp
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
@ -12,22 +12,14 @@
|
|||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
//
|
//
|
||||||
// DESCRIPTION:
|
|
||||||
// DOOM keyboard input via linux tty
|
|
||||||
//
|
|
||||||
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <termios.h>
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
#include <linux/keyboard.h>
|
|
||||||
#include <linux/kd.h>
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "deh_str.h"
|
#include "deh_str.h"
|
||||||
@ -47,6 +39,8 @@
|
|||||||
#include "w_wad.h"
|
#include "w_wad.h"
|
||||||
#include "z_zone.h"
|
#include "z_zone.h"
|
||||||
|
|
||||||
|
#include "doomgeneric.h"
|
||||||
|
|
||||||
int vanilla_keyboard_mapping = 1;
|
int vanilla_keyboard_mapping = 1;
|
||||||
|
|
||||||
// Is the shift key currently down?
|
// Is the shift key currently down?
|
||||||
@ -227,153 +221,17 @@ static const char shiftxform[] =
|
|||||||
'{', '|', '}', '~', 127
|
'{', '|', '}', '~', 127
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Checks whether or not the given file descriptor is associated
|
|
||||||
with a local keyboard.
|
|
||||||
Returns 1 if it is, 0 if not (or if something prevented us from
|
|
||||||
checking). */
|
|
||||||
|
|
||||||
int tty_is_kbd(int fd)
|
|
||||||
{
|
|
||||||
int data = 0;
|
|
||||||
|
|
||||||
if (ioctl(fd, KDGKBTYPE, &data) != 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (data == KB_84) {
|
|
||||||
printf("84-key keyboard found.\n");
|
|
||||||
return 1;
|
|
||||||
} else if (data == KB_101) {
|
|
||||||
printf("101-key keyboard found.\n");
|
|
||||||
return 1;
|
|
||||||
} else {
|
|
||||||
printf("KDGKBTYPE = 0x%x.\n", data);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int old_mode = -1;
|
|
||||||
static struct termios old_term;
|
|
||||||
static int kb = -1; /* keyboard file descriptor */
|
|
||||||
|
|
||||||
void kbd_shutdown(void)
|
|
||||||
{
|
|
||||||
/* Shut down nicely. */
|
|
||||||
|
|
||||||
printf("Cleaning up.\n");
|
|
||||||
fflush(stdout);
|
|
||||||
|
|
||||||
printf("Exiting normally.\n");
|
|
||||||
if (old_mode != -1) {
|
|
||||||
ioctl(kb, KDSKBMODE, old_mode);
|
|
||||||
tcsetattr(kb, 0, &old_term);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (kb > 3)
|
|
||||||
close(kb);
|
|
||||||
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int kbd_init(void)
|
|
||||||
{
|
|
||||||
struct termios new_term;
|
|
||||||
char *files_to_try[] = {"/dev/tty", "/dev/console", NULL};
|
|
||||||
int i;
|
|
||||||
int flags;
|
|
||||||
|
|
||||||
/* First we need to find a file descriptor that represents the
|
|
||||||
system's keyboard. This should be /dev/tty, /dev/console,
|
|
||||||
stdin, stdout, or stderr. We'll try them in that order.
|
|
||||||
If none are acceptable, we're probably not being run
|
|
||||||
from a VT. */
|
|
||||||
for (i = 0; files_to_try[i] != NULL; i++) {
|
|
||||||
/* Try to open the file. */
|
|
||||||
kb = open(files_to_try[i], O_RDONLY);
|
|
||||||
if (kb < 0) continue;
|
|
||||||
/* See if this is valid for our purposes. */
|
|
||||||
if (tty_is_kbd(kb)) {
|
|
||||||
printf("Using keyboard on %s.\n", files_to_try[i]);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
close(kb);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If those didn't work, not all is lost. We can try the
|
|
||||||
3 standard file descriptors, in hopes that one of them
|
|
||||||
might point to a console. This is not especially likely. */
|
|
||||||
if (files_to_try[i] == NULL) {
|
|
||||||
for (kb = 0; kb < 3; kb++) {
|
|
||||||
if (tty_is_kbd(i)) break;
|
|
||||||
}
|
|
||||||
printf("Unable to find a file descriptor associated with "\
|
|
||||||
"the keyboard.\n" \
|
|
||||||
"Perhaps you're not using a virtual terminal?\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Find the keyboard's mode so we can restore it later. */
|
|
||||||
if (ioctl(kb, KDGKBMODE, &old_mode) != 0) {
|
|
||||||
printf("Unable to query keyboard mode.\n");
|
|
||||||
kbd_shutdown();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Adjust the terminal's settings. In particular, disable
|
|
||||||
echoing, signal generation, and line buffering. Any of
|
|
||||||
these could cause trouble. Save the old settings first. */
|
|
||||||
if (tcgetattr(kb, &old_term) != 0) {
|
|
||||||
printf("Unable to query terminal settings.\n");
|
|
||||||
kbd_shutdown();
|
|
||||||
}
|
|
||||||
|
|
||||||
new_term = old_term;
|
|
||||||
new_term.c_iflag = 0;
|
|
||||||
new_term.c_lflag &= ~(ECHO | ICANON | ISIG);
|
|
||||||
|
|
||||||
/* TCSAFLUSH discards unread input before making the change.
|
|
||||||
A good idea. */
|
|
||||||
if (tcsetattr(kb, TCSAFLUSH, &new_term) != 0) {
|
|
||||||
printf("Unable to change terminal settings.\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Put the keyboard in mediumraw mode. */
|
|
||||||
if (ioctl(kb, KDSKBMODE, K_MEDIUMRAW) != 0) {
|
|
||||||
printf("Unable to set mediumraw mode.\n");
|
|
||||||
kbd_shutdown();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Put in non-blocking mode */
|
|
||||||
flags = fcntl(kb, F_GETFL, 0);
|
|
||||||
fcntl(kb, F_SETFL, flags | O_NONBLOCK);
|
|
||||||
|
|
||||||
printf("Ready to read keycodes. Press Backspace to exit.\n");
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int kbd_read(int *pressed, unsigned char *key)
|
|
||||||
{
|
|
||||||
unsigned char data;
|
|
||||||
|
|
||||||
if (read(kb, &data, 1) < 1) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
*pressed = (data & 0x80) == 0x80;
|
|
||||||
*key = data & 0x7F;
|
|
||||||
|
|
||||||
/* Print the keycode. The top bit is the pressed/released
|
|
||||||
flag, and the lower seven are the keycode. */
|
|
||||||
//printf("%s: 0x%2X (%i)\n", *pressed ? "Released" : " Pressed", (unsigned int)*key, (unsigned int)*key);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static unsigned char TranslateKey(unsigned char key)
|
static unsigned char TranslateKey(unsigned char key)
|
||||||
{
|
{
|
||||||
|
return key;
|
||||||
|
|
||||||
|
/*
|
||||||
if (key < sizeof(at_to_doom))
|
if (key < sizeof(at_to_doom))
|
||||||
return at_to_doom[key];
|
return at_to_doom[key];
|
||||||
else
|
else
|
||||||
return 0x0;
|
return 0x0;
|
||||||
|
*/
|
||||||
|
|
||||||
//default:
|
//default:
|
||||||
// return tolower(key);
|
// return tolower(key);
|
||||||
@ -412,7 +270,7 @@ static void UpdateShiftStatus(int pressed, unsigned char key)
|
|||||||
change = -1;
|
change = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key == 0x2a || key == 0x36) {
|
if (key == KEY_RSHIFT) {
|
||||||
shiftdown += change;
|
shiftdown += change;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -424,20 +282,14 @@ void I_GetEvent(void)
|
|||||||
int pressed;
|
int pressed;
|
||||||
unsigned char key;
|
unsigned char key;
|
||||||
|
|
||||||
// put event-grabbing stuff in here
|
|
||||||
|
|
||||||
while (kbd_read(&pressed, &key))
|
while (DG_GetKey(&pressed, &key))
|
||||||
{
|
{
|
||||||
if (key == 0x0E) {
|
|
||||||
kbd_shutdown();
|
|
||||||
I_Quit();
|
|
||||||
}
|
|
||||||
|
|
||||||
UpdateShiftStatus(pressed, key);
|
UpdateShiftStatus(pressed, key);
|
||||||
|
|
||||||
// process event
|
// process event
|
||||||
|
|
||||||
if (!pressed)
|
if (pressed)
|
||||||
{
|
{
|
||||||
// data1 has the key pressed, data2 has the character
|
// data1 has the key pressed, data2 has the character
|
||||||
// (shift-translated, etc)
|
// (shift-translated, etc)
|
||||||
@ -485,8 +337,5 @@ void I_GetEvent(void)
|
|||||||
|
|
||||||
void I_InitInput(void)
|
void I_InitInput(void)
|
||||||
{
|
{
|
||||||
kbd_init();
|
|
||||||
|
|
||||||
//UpdateFocus();
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,407 +0,0 @@
|
|||||||
//
|
|
||||||
// Copyright(C) 1993-1996 Id Software, Inc.
|
|
||||||
// Copyright(C) 2005-2014 Simon Howard
|
|
||||||
//
|
|
||||||
// This program is free software; you can redistribute it and/or
|
|
||||||
// modify it under the terms of the GNU General Public License
|
|
||||||
// as published by the Free Software Foundation; either version 2
|
|
||||||
// of the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// This program is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU General Public License for more details.
|
|
||||||
//
|
|
||||||
// DESCRIPTION:
|
|
||||||
// DOOM graphics stuff for SDL.
|
|
||||||
//
|
|
||||||
|
|
||||||
|
|
||||||
#include "SDL/SDL.h"
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <math.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
#include "deh_str.h"
|
|
||||||
#include "doomtype.h"
|
|
||||||
#include "doomkeys.h"
|
|
||||||
#include "i_joystick.h"
|
|
||||||
#include "i_system.h"
|
|
||||||
#include "i_swap.h"
|
|
||||||
#include "i_timer.h"
|
|
||||||
#include "i_video.h"
|
|
||||||
#include "i_scale.h"
|
|
||||||
#include "m_argv.h"
|
|
||||||
#include "m_config.h"
|
|
||||||
#include "m_misc.h"
|
|
||||||
#include "tables.h"
|
|
||||||
#include "v_video.h"
|
|
||||||
#include "w_wad.h"
|
|
||||||
#include "z_zone.h"
|
|
||||||
|
|
||||||
// SDL surface for the screen.
|
|
||||||
|
|
||||||
static SDL_Surface *screen;
|
|
||||||
|
|
||||||
// If true, keyboard mapping is ignored, like in Vanilla Doom.
|
|
||||||
// The sensible thing to do is to disable this if you have a non-US
|
|
||||||
// keyboard.
|
|
||||||
|
|
||||||
int vanilla_keyboard_mapping = true;
|
|
||||||
|
|
||||||
// Is the shift key currently down?
|
|
||||||
|
|
||||||
static int shiftdown = 0;
|
|
||||||
// Lookup table for mapping ASCII characters to their equivalent when
|
|
||||||
// shift is pressed on an American layout keyboard:
|
|
||||||
|
|
||||||
static const char shiftxform[] =
|
|
||||||
{
|
|
||||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
|
|
||||||
11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
|
|
||||||
21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
|
|
||||||
31, ' ', '!', '"', '#', '$', '%', '&',
|
|
||||||
'"', // shift-'
|
|
||||||
'(', ')', '*', '+',
|
|
||||||
'<', // shift-,
|
|
||||||
'_', // shift--
|
|
||||||
'>', // shift-.
|
|
||||||
'?', // shift-/
|
|
||||||
')', // shift-0
|
|
||||||
'!', // shift-1
|
|
||||||
'@', // shift-2
|
|
||||||
'#', // shift-3
|
|
||||||
'$', // shift-4
|
|
||||||
'%', // shift-5
|
|
||||||
'^', // shift-6
|
|
||||||
'&', // shift-7
|
|
||||||
'*', // shift-8
|
|
||||||
'(', // shift-9
|
|
||||||
':',
|
|
||||||
':', // shift-;
|
|
||||||
'<',
|
|
||||||
'+', // shift-=
|
|
||||||
'>', '?', '@',
|
|
||||||
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
|
|
||||||
'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
|
|
||||||
'[', // shift-[
|
|
||||||
'!', // shift-backslash - OH MY GOD DOES WATCOM SUCK
|
|
||||||
']', // shift-]
|
|
||||||
'"', '_',
|
|
||||||
'\'', // shift-`
|
|
||||||
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
|
|
||||||
'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
|
|
||||||
'{', '|', '}', '~', 127
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// Translates the SDL key
|
|
||||||
//
|
|
||||||
|
|
||||||
static int TranslateKey(SDL_keysym *sym)
|
|
||||||
{
|
|
||||||
switch(sym->sym)
|
|
||||||
{
|
|
||||||
case SDLK_LEFT: return KEY_LEFTARROW;
|
|
||||||
case SDLK_RIGHT: return KEY_RIGHTARROW;
|
|
||||||
case SDLK_DOWN: return KEY_DOWNARROW;
|
|
||||||
case SDLK_UP: return KEY_UPARROW;
|
|
||||||
case SDLK_ESCAPE: return KEY_ESCAPE;
|
|
||||||
case SDLK_RETURN: return KEY_ENTER;
|
|
||||||
case SDLK_TAB: return KEY_TAB;
|
|
||||||
case SDLK_F1: return KEY_F1;
|
|
||||||
case SDLK_F2: return KEY_F2;
|
|
||||||
case SDLK_F3: return KEY_F3;
|
|
||||||
case SDLK_F4: return KEY_F4;
|
|
||||||
case SDLK_F5: return KEY_F5;
|
|
||||||
case SDLK_F6: return KEY_F6;
|
|
||||||
case SDLK_F7: return KEY_F7;
|
|
||||||
case SDLK_F8: return KEY_F8;
|
|
||||||
case SDLK_F9: return KEY_F9;
|
|
||||||
case SDLK_F10: return KEY_F10;
|
|
||||||
case SDLK_F11: return KEY_F11;
|
|
||||||
case SDLK_F12: return KEY_F12;
|
|
||||||
case SDLK_PRINT: return KEY_PRTSCR;
|
|
||||||
|
|
||||||
case SDLK_BACKSPACE: return KEY_BACKSPACE;
|
|
||||||
case SDLK_DELETE: return KEY_DEL;
|
|
||||||
|
|
||||||
case SDLK_PAUSE: return KEY_PAUSE;
|
|
||||||
|
|
||||||
#if !SDL_VERSION_ATLEAST(1, 3, 0)
|
|
||||||
case SDLK_EQUALS: return KEY_EQUALS;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
case SDLK_MINUS: return KEY_MINUS;
|
|
||||||
|
|
||||||
case SDLK_LSHIFT:
|
|
||||||
case SDLK_RSHIFT:
|
|
||||||
return KEY_RSHIFT;
|
|
||||||
|
|
||||||
case SDLK_LCTRL:
|
|
||||||
case SDLK_RCTRL:
|
|
||||||
return KEY_RCTRL;
|
|
||||||
|
|
||||||
case SDLK_LALT:
|
|
||||||
case SDLK_RALT:
|
|
||||||
#if !SDL_VERSION_ATLEAST(1, 3, 0)
|
|
||||||
case SDLK_LMETA:
|
|
||||||
case SDLK_RMETA:
|
|
||||||
#endif
|
|
||||||
return KEY_RALT;
|
|
||||||
|
|
||||||
case SDLK_CAPSLOCK: return KEY_CAPSLOCK;
|
|
||||||
case SDLK_SCROLLOCK: return KEY_SCRLCK;
|
|
||||||
case SDLK_NUMLOCK: return KEY_NUMLOCK;
|
|
||||||
|
|
||||||
case SDLK_KP0: return KEYP_0;
|
|
||||||
case SDLK_KP1: return KEYP_1;
|
|
||||||
case SDLK_KP2: return KEYP_2;
|
|
||||||
case SDLK_KP3: return KEYP_3;
|
|
||||||
case SDLK_KP4: return KEYP_4;
|
|
||||||
case SDLK_KP5: return KEYP_5;
|
|
||||||
case SDLK_KP6: return KEYP_6;
|
|
||||||
case SDLK_KP7: return KEYP_7;
|
|
||||||
case SDLK_KP8: return KEYP_8;
|
|
||||||
case SDLK_KP9: return KEYP_9;
|
|
||||||
|
|
||||||
case SDLK_KP_PERIOD: return KEYP_PERIOD;
|
|
||||||
case SDLK_KP_MULTIPLY: return KEYP_MULTIPLY;
|
|
||||||
case SDLK_KP_PLUS: return KEYP_PLUS;
|
|
||||||
case SDLK_KP_MINUS: return KEYP_MINUS;
|
|
||||||
case SDLK_KP_DIVIDE: return KEYP_DIVIDE;
|
|
||||||
case SDLK_KP_EQUALS: return KEYP_EQUALS;
|
|
||||||
case SDLK_KP_ENTER: return KEYP_ENTER;
|
|
||||||
|
|
||||||
case SDLK_HOME: return KEY_HOME;
|
|
||||||
case SDLK_INSERT: return KEY_INS;
|
|
||||||
case SDLK_END: return KEY_END;
|
|
||||||
case SDLK_PAGEUP: return KEY_PGUP;
|
|
||||||
case SDLK_PAGEDOWN: return KEY_PGDN;
|
|
||||||
|
|
||||||
#ifdef SDL_HAVE_APP_KEYS
|
|
||||||
case SDLK_APP1: return KEY_F1;
|
|
||||||
case SDLK_APP2: return KEY_F2;
|
|
||||||
case SDLK_APP3: return KEY_F3;
|
|
||||||
case SDLK_APP4: return KEY_F4;
|
|
||||||
case SDLK_APP5: return KEY_F5;
|
|
||||||
case SDLK_APP6: return KEY_F6;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
default:
|
|
||||||
return tolower(sym->sym);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the equivalent ASCII (Unicode?) character for a keypress.
|
|
||||||
|
|
||||||
static int GetTypedChar(SDL_Event *event)
|
|
||||||
{
|
|
||||||
int key;
|
|
||||||
|
|
||||||
// If Vanilla keyboard mapping enabled, the keyboard
|
|
||||||
// scan code is used to give the character typed.
|
|
||||||
// This does not change depending on keyboard layout.
|
|
||||||
// If you have a German keyboard, pressing 'z' will
|
|
||||||
// give 'y', for example. It is desirable to be able
|
|
||||||
// to fix this so that people with non-standard
|
|
||||||
// keyboard mappings can type properly. If vanilla
|
|
||||||
// mode is disabled, use the properly translated
|
|
||||||
// version.
|
|
||||||
|
|
||||||
if (vanilla_keyboard_mapping)
|
|
||||||
{
|
|
||||||
key = TranslateKey(&event->key.keysym);
|
|
||||||
|
|
||||||
// Is shift held down? If so, perform a translation.
|
|
||||||
|
|
||||||
if (shiftdown > 0)
|
|
||||||
{
|
|
||||||
if (key >= 0 && key < arrlen(shiftxform))
|
|
||||||
{
|
|
||||||
key = shiftxform[key];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
key = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return key;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Unicode value, from key layout.
|
|
||||||
|
|
||||||
return tolower(event->key.keysym.unicode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void UpdateShiftStatus(SDL_Event *event)
|
|
||||||
{
|
|
||||||
int change;
|
|
||||||
|
|
||||||
if (event->type == SDL_KEYDOWN)
|
|
||||||
{
|
|
||||||
change = 1;
|
|
||||||
}
|
|
||||||
else if (event->type == SDL_KEYUP)
|
|
||||||
{
|
|
||||||
change = -1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (event->key.keysym.sym == SDLK_LSHIFT
|
|
||||||
|| event->key.keysym.sym == SDLK_RSHIFT)
|
|
||||||
{
|
|
||||||
shiftdown += change;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void I_GetEvent(void)
|
|
||||||
{
|
|
||||||
SDL_Event sdlevent;
|
|
||||||
event_t event;
|
|
||||||
|
|
||||||
// possibly not needed
|
|
||||||
|
|
||||||
SDL_PumpEvents();
|
|
||||||
|
|
||||||
// put event-grabbing stuff in here
|
|
||||||
|
|
||||||
while (SDL_PollEvent(&sdlevent))
|
|
||||||
{
|
|
||||||
if (sdlevent.type == SDL_QUIT)
|
|
||||||
{
|
|
||||||
I_Quit();
|
|
||||||
}
|
|
||||||
|
|
||||||
UpdateShiftStatus(&sdlevent);
|
|
||||||
|
|
||||||
// process event
|
|
||||||
|
|
||||||
switch (sdlevent.type)
|
|
||||||
{
|
|
||||||
case SDL_KEYDOWN:
|
|
||||||
// data1 has the key pressed, data2 has the character
|
|
||||||
// (shift-translated, etc)
|
|
||||||
event.type = ev_keydown;
|
|
||||||
event.data1 = TranslateKey(&sdlevent.key.keysym);
|
|
||||||
event.data2 = GetTypedChar(&sdlevent);
|
|
||||||
|
|
||||||
if (event.data1 != 0)
|
|
||||||
{
|
|
||||||
D_PostEvent(&event);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_KEYUP:
|
|
||||||
event.type = ev_keyup;
|
|
||||||
event.data1 = TranslateKey(&sdlevent.key.keysym);
|
|
||||||
|
|
||||||
// data2 is just initialized to zero for ev_keyup.
|
|
||||||
// For ev_keydown it's the shifted Unicode character
|
|
||||||
// that was typed, but if something wants to detect
|
|
||||||
// key releases it should do so based on data1
|
|
||||||
// (key ID), not the printable char.
|
|
||||||
|
|
||||||
event.data2 = 0;
|
|
||||||
|
|
||||||
if (event.data1 != 0)
|
|
||||||
{
|
|
||||||
D_PostEvent(&event);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
/*
|
|
||||||
case SDL_MOUSEMOTION:
|
|
||||||
event.type = ev_mouse;
|
|
||||||
event.data1 = mouse_button_state;
|
|
||||||
event.data2 = AccelerateMouse(sdlevent.motion.xrel);
|
|
||||||
event.data3 = -AccelerateMouse(sdlevent.motion.yrel);
|
|
||||||
D_PostEvent(&event);
|
|
||||||
break;
|
|
||||||
*/
|
|
||||||
|
|
||||||
case SDL_QUIT:
|
|
||||||
event.type = ev_quit;
|
|
||||||
D_PostEvent(&event);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_ACTIVEEVENT:
|
|
||||||
// need to update our focus state
|
|
||||||
//UpdateFocus();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//void I_ShutdownGraphics(void)
|
|
||||||
//{
|
|
||||||
// //SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
|
||||||
//}
|
|
||||||
|
|
||||||
//
|
|
||||||
// I_StartTic
|
|
||||||
//
|
|
||||||
void I_StartTic (void)
|
|
||||||
{
|
|
||||||
I_GetEvent();
|
|
||||||
}
|
|
||||||
|
|
||||||
void I_InitInput(void)
|
|
||||||
{
|
|
||||||
SDL_Event dummy;
|
|
||||||
byte *doompal;
|
|
||||||
char *env;
|
|
||||||
|
|
||||||
// Pass through the XSCREENSAVER_WINDOW environment variable to
|
|
||||||
// SDL_WINDOWID, to embed the SDL window into the Xscreensaver
|
|
||||||
// window.
|
|
||||||
|
|
||||||
env = getenv("XSCREENSAVER_WINDOW");
|
|
||||||
|
|
||||||
if (env != NULL)
|
|
||||||
{
|
|
||||||
char winenv[30];
|
|
||||||
int winid;
|
|
||||||
|
|
||||||
sscanf(env, "0x%x", &winid);
|
|
||||||
M_snprintf(winenv, sizeof(winenv), "SDL_WINDOWID=%i", winid);
|
|
||||||
|
|
||||||
putenv(winenv);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (SDL_Init(SDL_INIT_VIDEO) < 0)
|
|
||||||
{
|
|
||||||
I_Error("Failed to initialize video: %s", SDL_GetError());
|
|
||||||
}
|
|
||||||
|
|
||||||
//UpdateFocus();
|
|
||||||
|
|
||||||
// We need SDL to give us translated versions of keys as well
|
|
||||||
|
|
||||||
SDL_EnableUNICODE(1);
|
|
||||||
|
|
||||||
// Repeat key presses - this is what Vanilla Doom does
|
|
||||||
// Not sure about repeat rate - probably dependent on which DOS
|
|
||||||
// driver is used. This is good enough though.
|
|
||||||
|
|
||||||
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
|
|
||||||
|
|
||||||
// clear out any events waiting at the start and center the mouse
|
|
||||||
|
|
||||||
while (SDL_PollEvent(&dummy));
|
|
||||||
}
|
|
||||||
|
|
@ -16,12 +16,12 @@
|
|||||||
// Main program, simply calls D_DoomMain high level loop.
|
// Main program, simply calls D_DoomMain high level loop.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "config.h"
|
//#include "config.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "doomtype.h"
|
//#include "doomtype.h"
|
||||||
#include "i_system.h"
|
//#include "i_system.h"
|
||||||
#include "m_argv.h"
|
#include "m_argv.h"
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -32,6 +32,11 @@
|
|||||||
|
|
||||||
void D_DoomMain (void);
|
void D_DoomMain (void);
|
||||||
|
|
||||||
|
void M_FindResponseFile(void);
|
||||||
|
|
||||||
|
void dg_Create();
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
// save arguments
|
// save arguments
|
||||||
@ -43,7 +48,10 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
// start doom
|
// start doom
|
||||||
printf("Starting D_DoomMain\r\n");
|
printf("Starting D_DoomMain\r\n");
|
||||||
D_DoomMain ();
|
|
||||||
|
dg_Create();
|
||||||
|
|
||||||
|
D_DoomMain ();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,330 +0,0 @@
|
|||||||
//
|
|
||||||
// Copyright(C) 2005-2014 Simon Howard
|
|
||||||
//
|
|
||||||
// This program is free software; you can redistribute it and/or
|
|
||||||
// modify it under the terms of the GNU General Public License
|
|
||||||
// as published by the Free Software Foundation; either version 2
|
|
||||||
// of the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// This program is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU General Public License for more details.
|
|
||||||
//
|
|
||||||
// DESCRIPTION:
|
|
||||||
// System interface for PC speaker sound.
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "SDL.h"
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "doomtype.h"
|
|
||||||
|
|
||||||
#include "deh_str.h"
|
|
||||||
#include "i_sound.h"
|
|
||||||
#include "m_misc.h"
|
|
||||||
#include "w_wad.h"
|
|
||||||
#include "z_zone.h"
|
|
||||||
|
|
||||||
#include "pcsound.h"
|
|
||||||
|
|
||||||
#define TIMER_FREQ 1193181 /* hz */
|
|
||||||
|
|
||||||
static boolean pcs_initialized = false;
|
|
||||||
|
|
||||||
static SDL_mutex *sound_lock;
|
|
||||||
static boolean use_sfx_prefix;
|
|
||||||
|
|
||||||
static uint8_t *current_sound_lump = NULL;
|
|
||||||
static uint8_t *current_sound_pos = NULL;
|
|
||||||
static unsigned int current_sound_remaining = 0;
|
|
||||||
static int current_sound_handle = 0;
|
|
||||||
static int current_sound_lump_num = -1;
|
|
||||||
|
|
||||||
static const uint16_t divisors[] = {
|
|
||||||
0,
|
|
||||||
6818, 6628, 6449, 6279, 6087, 5906, 5736, 5575,
|
|
||||||
5423, 5279, 5120, 4971, 4830, 4697, 4554, 4435,
|
|
||||||
4307, 4186, 4058, 3950, 3836, 3728, 3615, 3519,
|
|
||||||
3418, 3323, 3224, 3131, 3043, 2960, 2875, 2794,
|
|
||||||
2711, 2633, 2560, 2485, 2415, 2348, 2281, 2213,
|
|
||||||
2153, 2089, 2032, 1975, 1918, 1864, 1810, 1757,
|
|
||||||
1709, 1659, 1612, 1565, 1521, 1478, 1435, 1395,
|
|
||||||
1355, 1316, 1280, 1242, 1207, 1173, 1140, 1107,
|
|
||||||
1075, 1045, 1015, 986, 959, 931, 905, 879,
|
|
||||||
854, 829, 806, 783, 760, 739, 718, 697,
|
|
||||||
677, 658, 640, 621, 604, 586, 570, 553,
|
|
||||||
538, 522, 507, 493, 479, 465, 452, 439,
|
|
||||||
427, 415, 403, 391, 380, 369, 359, 348,
|
|
||||||
339, 329, 319, 310, 302, 293, 285, 276,
|
|
||||||
269, 261, 253, 246, 239, 232, 226, 219,
|
|
||||||
213, 207, 201, 195, 190, 184, 179,
|
|
||||||
};
|
|
||||||
|
|
||||||
static void PCSCallbackFunc(int *duration, int *freq)
|
|
||||||
{
|
|
||||||
unsigned int tone;
|
|
||||||
|
|
||||||
*duration = 1000 / 140;
|
|
||||||
|
|
||||||
if (SDL_LockMutex(sound_lock) < 0)
|
|
||||||
{
|
|
||||||
*freq = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (current_sound_lump != NULL && current_sound_remaining > 0)
|
|
||||||
{
|
|
||||||
// Read the next tone
|
|
||||||
|
|
||||||
tone = *current_sound_pos;
|
|
||||||
|
|
||||||
// Use the tone -> frequency lookup table. See pcspkr10.zip
|
|
||||||
// for a full discussion of this.
|
|
||||||
// Check we don't overflow the frequency table.
|
|
||||||
|
|
||||||
if (tone < arrlen(divisors) && divisors[tone] != 0)
|
|
||||||
{
|
|
||||||
*freq = (int) (TIMER_FREQ / divisors[tone]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
*freq = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
++current_sound_pos;
|
|
||||||
--current_sound_remaining;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
*freq = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
SDL_UnlockMutex(sound_lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
static boolean CachePCSLump(sfxinfo_t *sfxinfo)
|
|
||||||
{
|
|
||||||
int lumplen;
|
|
||||||
int headerlen;
|
|
||||||
|
|
||||||
// Free the current sound lump back to the cache
|
|
||||||
|
|
||||||
if (current_sound_lump != NULL)
|
|
||||||
{
|
|
||||||
W_ReleaseLumpNum(current_sound_lump_num);
|
|
||||||
current_sound_lump = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load from WAD
|
|
||||||
|
|
||||||
current_sound_lump = W_CacheLumpNum(sfxinfo->lumpnum, PU_STATIC);
|
|
||||||
lumplen = W_LumpLength(sfxinfo->lumpnum);
|
|
||||||
|
|
||||||
// Read header
|
|
||||||
|
|
||||||
if (current_sound_lump[0] != 0x00 || current_sound_lump[1] != 0x00)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
headerlen = (current_sound_lump[3] << 8) | current_sound_lump[2];
|
|
||||||
|
|
||||||
if (headerlen > lumplen - 4)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Header checks out ok
|
|
||||||
|
|
||||||
current_sound_remaining = headerlen;
|
|
||||||
current_sound_pos = current_sound_lump + 4;
|
|
||||||
current_sound_lump_num = sfxinfo->lumpnum;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// These Doom PC speaker sounds are not played - this can be seen in the
|
|
||||||
// Heretic source code, where there are remnants of this left over
|
|
||||||
// from Doom.
|
|
||||||
|
|
||||||
static boolean IsDisabledSound(sfxinfo_t *sfxinfo)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
const char *disabled_sounds[] = {
|
|
||||||
"posact",
|
|
||||||
"bgact",
|
|
||||||
"dmact",
|
|
||||||
"dmpain",
|
|
||||||
"popain",
|
|
||||||
"sawidl",
|
|
||||||
};
|
|
||||||
|
|
||||||
for (i=0; i<arrlen(disabled_sounds); ++i)
|
|
||||||
{
|
|
||||||
if (!strcmp(sfxinfo->name, disabled_sounds[i]))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int I_PCS_StartSound(sfxinfo_t *sfxinfo,
|
|
||||||
int channel,
|
|
||||||
int vol,
|
|
||||||
int sep)
|
|
||||||
{
|
|
||||||
int result;
|
|
||||||
|
|
||||||
if (!pcs_initialized)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IsDisabledSound(sfxinfo))
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (SDL_LockMutex(sound_lock) < 0)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
result = CachePCSLump(sfxinfo);
|
|
||||||
|
|
||||||
if (result)
|
|
||||||
{
|
|
||||||
current_sound_handle = channel;
|
|
||||||
}
|
|
||||||
|
|
||||||
SDL_UnlockMutex(sound_lock);
|
|
||||||
|
|
||||||
if (result)
|
|
||||||
{
|
|
||||||
return channel;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void I_PCS_StopSound(int handle)
|
|
||||||
{
|
|
||||||
if (!pcs_initialized)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (SDL_LockMutex(sound_lock) < 0)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If this is the channel currently playing, immediately end it.
|
|
||||||
|
|
||||||
if (current_sound_handle == handle)
|
|
||||||
{
|
|
||||||
current_sound_remaining = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
SDL_UnlockMutex(sound_lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Retrieve the raw data lump index
|
|
||||||
// for a given SFX name.
|
|
||||||
//
|
|
||||||
|
|
||||||
static int I_PCS_GetSfxLumpNum(sfxinfo_t* sfx)
|
|
||||||
{
|
|
||||||
char namebuf[9];
|
|
||||||
|
|
||||||
if (use_sfx_prefix)
|
|
||||||
{
|
|
||||||
M_snprintf(namebuf, sizeof(namebuf), "dp%s", DEH_String(sfx->name));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
M_StringCopy(namebuf, DEH_String(sfx->name), sizeof(namebuf));
|
|
||||||
}
|
|
||||||
|
|
||||||
return W_GetNumForName(namebuf);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static boolean I_PCS_SoundIsPlaying(int handle)
|
|
||||||
{
|
|
||||||
if (!pcs_initialized)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (handle != current_sound_handle)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return current_sound_lump != NULL && current_sound_remaining > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static boolean I_PCS_InitSound(boolean _use_sfx_prefix)
|
|
||||||
{
|
|
||||||
use_sfx_prefix = _use_sfx_prefix;
|
|
||||||
|
|
||||||
// Use the sample rate from the configuration file
|
|
||||||
|
|
||||||
PCSound_SetSampleRate(snd_samplerate);
|
|
||||||
|
|
||||||
// Initialize the PC speaker subsystem.
|
|
||||||
|
|
||||||
pcs_initialized = PCSound_Init(PCSCallbackFunc);
|
|
||||||
|
|
||||||
if (pcs_initialized)
|
|
||||||
{
|
|
||||||
sound_lock = SDL_CreateMutex();
|
|
||||||
}
|
|
||||||
|
|
||||||
return pcs_initialized;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void I_PCS_ShutdownSound(void)
|
|
||||||
{
|
|
||||||
if (pcs_initialized)
|
|
||||||
{
|
|
||||||
PCSound_Shutdown();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void I_PCS_UpdateSound(void)
|
|
||||||
{
|
|
||||||
// no-op.
|
|
||||||
}
|
|
||||||
|
|
||||||
void I_PCS_UpdateSoundParams(int channel, int vol, int sep)
|
|
||||||
{
|
|
||||||
// no-op.
|
|
||||||
}
|
|
||||||
|
|
||||||
static snddevice_t sound_pcsound_devices[] =
|
|
||||||
{
|
|
||||||
SNDDEVICE_PCSPEAKER,
|
|
||||||
};
|
|
||||||
|
|
||||||
sound_module_t sound_pcsound_module =
|
|
||||||
{
|
|
||||||
sound_pcsound_devices,
|
|
||||||
arrlen(sound_pcsound_devices),
|
|
||||||
I_PCS_InitSound,
|
|
||||||
I_PCS_ShutdownSound,
|
|
||||||
I_PCS_GetSfxLumpNum,
|
|
||||||
I_PCS_UpdateSound,
|
|
||||||
I_PCS_UpdateSoundParams,
|
|
||||||
I_PCS_StartSound,
|
|
||||||
I_PCS_StopSound,
|
|
||||||
I_PCS_SoundIsPlaying,
|
|
||||||
};
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,947 +0,0 @@
|
|||||||
// Emacs style mode select -*- C++ -*-
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// $Id:$
|
|
||||||
//
|
|
||||||
// Copyright (C) 1993-1996 by id Software, Inc.
|
|
||||||
//
|
|
||||||
// This source is available for distribution and/or modification
|
|
||||||
// only under the terms of the DOOM Source Code License as
|
|
||||||
// published by id Software. All rights reserved.
|
|
||||||
//
|
|
||||||
// The source is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
|
|
||||||
// for more details.
|
|
||||||
//
|
|
||||||
// $Log:$
|
|
||||||
//
|
|
||||||
// DESCRIPTION:
|
|
||||||
// System interface for sound.
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
static const char
|
|
||||||
rcsid[] = "$Id: i_unix.c,v 1.5 1997/02/03 22:45:10 b1 Exp $";
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
|
|
||||||
#include <math.h>
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
#include <sys/time.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#ifndef LINUX
|
|
||||||
#include <sys/filio.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
|
|
||||||
// Timer stuff. Experimental.
|
|
||||||
#include <time.h>
|
|
||||||
#include <signal.h>
|
|
||||||
|
|
||||||
#include "z_zone.h"
|
|
||||||
|
|
||||||
#include "i_system.h"
|
|
||||||
#include "i_sound.h"
|
|
||||||
#include "m_argv.h"
|
|
||||||
#include "m_misc.h"
|
|
||||||
#include "w_wad.h"
|
|
||||||
|
|
||||||
#include "doomdef.h"
|
|
||||||
|
|
||||||
// UNIX hack, to be removed.
|
|
||||||
#ifdef SNDSERV
|
|
||||||
// Separate sound server process.
|
|
||||||
FILE* sndserver=0;
|
|
||||||
char* sndserver_filename = "./sndserver ";
|
|
||||||
#elif SNDINTR
|
|
||||||
|
|
||||||
// Update all 30 millisecs, approx. 30fps synchronized.
|
|
||||||
// Linux resolution is allegedly 10 millisecs,
|
|
||||||
// scale is microseconds.
|
|
||||||
#define SOUND_INTERVAL 500
|
|
||||||
|
|
||||||
// Get the interrupt. Set duration in millisecs.
|
|
||||||
int I_SoundSetTimer( int duration_of_tick );
|
|
||||||
void I_SoundDelTimer( void );
|
|
||||||
#else
|
|
||||||
// None?
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
// A quick hack to establish a protocol between
|
|
||||||
// synchronous mix buffer updates and asynchronous
|
|
||||||
// audio writes. Probably redundant with gametic.
|
|
||||||
static int flag = 0;
|
|
||||||
|
|
||||||
// The number of internal mixing channels,
|
|
||||||
// the samples calculated for each mixing step,
|
|
||||||
// the size of the 16bit, 2 hardware channel (stereo)
|
|
||||||
// mixing buffer, and the samplerate of the raw data.
|
|
||||||
|
|
||||||
|
|
||||||
// Needed for calling the actual sound output.
|
|
||||||
#define SAMPLECOUNT 512
|
|
||||||
#define NUM_CHANNELS 8
|
|
||||||
// It is 2 for 16bit, and 2 for two channels.
|
|
||||||
#define BUFMUL 4
|
|
||||||
#define MIXBUFFERSIZE (SAMPLECOUNT*BUFMUL)
|
|
||||||
|
|
||||||
#define SAMPLERATE 11025 // Hz
|
|
||||||
#define SAMPLESIZE 2 // 16bit
|
|
||||||
|
|
||||||
// The actual lengths of all sound effects.
|
|
||||||
int lengths[NUMSFX];
|
|
||||||
|
|
||||||
// The actual output device.
|
|
||||||
int audio_fd;
|
|
||||||
|
|
||||||
// The global mixing buffer.
|
|
||||||
// Basically, samples from all active internal channels
|
|
||||||
// are modifed and added, and stored in the buffer
|
|
||||||
// that is submitted to the audio device.
|
|
||||||
signed short mixbuffer[MIXBUFFERSIZE];
|
|
||||||
|
|
||||||
|
|
||||||
// The channel step amount...
|
|
||||||
unsigned int channelstep[NUM_CHANNELS];
|
|
||||||
// ... and a 0.16 bit remainder of last step.
|
|
||||||
unsigned int channelstepremainder[NUM_CHANNELS];
|
|
||||||
|
|
||||||
|
|
||||||
// The channel data pointers, start and end.
|
|
||||||
unsigned char* channels[NUM_CHANNELS];
|
|
||||||
unsigned char* channelsend[NUM_CHANNELS];
|
|
||||||
|
|
||||||
|
|
||||||
// Time/gametic that the channel started playing,
|
|
||||||
// used to determine oldest, which automatically
|
|
||||||
// has lowest priority.
|
|
||||||
// In case number of active sounds exceeds
|
|
||||||
// available channels.
|
|
||||||
int channelstart[NUM_CHANNELS];
|
|
||||||
|
|
||||||
// The sound in channel handles,
|
|
||||||
// determined on registration,
|
|
||||||
// might be used to unregister/stop/modify,
|
|
||||||
// currently unused.
|
|
||||||
int channelhandles[NUM_CHANNELS];
|
|
||||||
|
|
||||||
// SFX id of the playing sound effect.
|
|
||||||
// Used to catch duplicates (like chainsaw).
|
|
||||||
int channelids[NUM_CHANNELS];
|
|
||||||
|
|
||||||
// Pitch to stepping lookup, unused.
|
|
||||||
int steptable[256];
|
|
||||||
|
|
||||||
// Volume lookups.
|
|
||||||
int vol_lookup[128*256];
|
|
||||||
|
|
||||||
// Hardware left and right channel volume lookup.
|
|
||||||
int* channelleftvol_lookup[NUM_CHANNELS];
|
|
||||||
int* channelrightvol_lookup[NUM_CHANNELS];
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// Safe ioctl, convenience.
|
|
||||||
//
|
|
||||||
void
|
|
||||||
myioctl
|
|
||||||
( int fd,
|
|
||||||
int command,
|
|
||||||
int* arg )
|
|
||||||
{
|
|
||||||
int rc;
|
|
||||||
|
|
||||||
rc = ioctl(fd, command, arg);
|
|
||||||
if (rc < 0)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "ioctl(dsp,%d,arg) failed\n", command);
|
|
||||||
fprintf(stderr, "errno=%d\n", errno);
|
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// This function loads the sound data from the WAD lump,
|
|
||||||
// for single sound.
|
|
||||||
//
|
|
||||||
void*
|
|
||||||
getsfx
|
|
||||||
( char* sfxname,
|
|
||||||
int* len )
|
|
||||||
{
|
|
||||||
unsigned char* sfx;
|
|
||||||
unsigned char* paddedsfx;
|
|
||||||
int i;
|
|
||||||
int size;
|
|
||||||
int paddedsize;
|
|
||||||
char name[20];
|
|
||||||
int sfxlump;
|
|
||||||
|
|
||||||
|
|
||||||
// Get the sound data from the WAD, allocate lump
|
|
||||||
// in zone memory.
|
|
||||||
sprintf(name, "ds%s", sfxname);
|
|
||||||
|
|
||||||
// Now, there is a severe problem with the
|
|
||||||
// sound handling, in it is not (yet/anymore)
|
|
||||||
// gamemode aware. That means, sounds from
|
|
||||||
// DOOM II will be requested even with DOOM
|
|
||||||
// shareware.
|
|
||||||
// The sound list is wired into sounds.c,
|
|
||||||
// which sets the external variable.
|
|
||||||
// I do not do runtime patches to that
|
|
||||||
// variable. Instead, we will use a
|
|
||||||
// default sound for replacement.
|
|
||||||
if ( W_CheckNumForName(name) == -1 )
|
|
||||||
sfxlump = W_GetNumForName("dspistol");
|
|
||||||
else
|
|
||||||
sfxlump = W_GetNumForName(name);
|
|
||||||
|
|
||||||
size = W_LumpLength( sfxlump );
|
|
||||||
|
|
||||||
// Debug.
|
|
||||||
// fprintf( stderr, "." );
|
|
||||||
//fprintf( stderr, " -loading %s (lump %d, %d bytes)\n",
|
|
||||||
// sfxname, sfxlump, size );
|
|
||||||
//fflush( stderr );
|
|
||||||
|
|
||||||
sfx = (unsigned char*)W_CacheLumpNum( sfxlump, PU_STATIC );
|
|
||||||
|
|
||||||
// Pads the sound effect out to the mixing buffer size.
|
|
||||||
// The original realloc would interfere with zone memory.
|
|
||||||
paddedsize = ((size-8 + (SAMPLECOUNT-1)) / SAMPLECOUNT) * SAMPLECOUNT;
|
|
||||||
|
|
||||||
// Allocate from zone memory.
|
|
||||||
paddedsfx = (unsigned char*)Z_Malloc( paddedsize+8, PU_STATIC, 0 );
|
|
||||||
// ddt: (unsigned char *) realloc(sfx, paddedsize+8);
|
|
||||||
// This should interfere with zone memory handling,
|
|
||||||
// which does not kick in in the soundserver.
|
|
||||||
|
|
||||||
// Now copy and pad.
|
|
||||||
memcpy( paddedsfx, sfx, size );
|
|
||||||
for (i=size ; i<paddedsize+8 ; i++)
|
|
||||||
paddedsfx[i] = 128;
|
|
||||||
|
|
||||||
// Remove the cached lump.
|
|
||||||
Z_Free( sfx );
|
|
||||||
|
|
||||||
// Preserve padded length.
|
|
||||||
*len = paddedsize;
|
|
||||||
|
|
||||||
// Return allocated padded data.
|
|
||||||
return (void *) (paddedsfx + 8);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// This function adds a sound to the
|
|
||||||
// list of currently active sounds,
|
|
||||||
// which is maintained as a given number
|
|
||||||
// (eight, usually) of internal channels.
|
|
||||||
// Returns a handle.
|
|
||||||
//
|
|
||||||
int
|
|
||||||
addsfx
|
|
||||||
( int sfxid,
|
|
||||||
int volume,
|
|
||||||
int step,
|
|
||||||
int seperation )
|
|
||||||
{
|
|
||||||
static unsigned short handlenums = 0;
|
|
||||||
|
|
||||||
int i;
|
|
||||||
int rc = -1;
|
|
||||||
|
|
||||||
int oldest = gametic;
|
|
||||||
int oldestnum = 0;
|
|
||||||
int slot;
|
|
||||||
|
|
||||||
int rightvol;
|
|
||||||
int leftvol;
|
|
||||||
|
|
||||||
// Chainsaw troubles.
|
|
||||||
// Play these sound effects only one at a time.
|
|
||||||
if ( sfxid == sfx_sawup
|
|
||||||
|| sfxid == sfx_sawidl
|
|
||||||
|| sfxid == sfx_sawful
|
|
||||||
|| sfxid == sfx_sawhit
|
|
||||||
|| sfxid == sfx_stnmov
|
|
||||||
|| sfxid == sfx_pistol )
|
|
||||||
{
|
|
||||||
// Loop all channels, check.
|
|
||||||
for (i=0 ; i<NUM_CHANNELS ; i++)
|
|
||||||
{
|
|
||||||
// Active, and using the same SFX?
|
|
||||||
if ( (channels[i])
|
|
||||||
&& (channelids[i] == sfxid) )
|
|
||||||
{
|
|
||||||
// Reset.
|
|
||||||
channels[i] = 0;
|
|
||||||
// We are sure that iff,
|
|
||||||
// there will only be one.
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Loop all channels to find oldest SFX.
|
|
||||||
for (i=0; (i<NUM_CHANNELS) && (channels[i]); i++)
|
|
||||||
{
|
|
||||||
if (channelstart[i] < oldest)
|
|
||||||
{
|
|
||||||
oldestnum = i;
|
|
||||||
oldest = channelstart[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Tales from the cryptic.
|
|
||||||
// If we found a channel, fine.
|
|
||||||
// If not, we simply overwrite the first one, 0.
|
|
||||||
// Probably only happens at startup.
|
|
||||||
if (i == NUM_CHANNELS)
|
|
||||||
slot = oldestnum;
|
|
||||||
else
|
|
||||||
slot = i;
|
|
||||||
|
|
||||||
// Okay, in the less recent channel,
|
|
||||||
// we will handle the new SFX.
|
|
||||||
// Set pointer to raw data.
|
|
||||||
channels[slot] = (unsigned char *) S_sfx[sfxid].data;
|
|
||||||
// Set pointer to end of raw data.
|
|
||||||
channelsend[slot] = channels[slot] + lengths[sfxid];
|
|
||||||
|
|
||||||
// Reset current handle number, limited to 0..100.
|
|
||||||
if (!handlenums)
|
|
||||||
handlenums = 100;
|
|
||||||
|
|
||||||
// Assign current handle number.
|
|
||||||
// Preserved so sounds could be stopped (unused).
|
|
||||||
channelhandles[slot] = rc = handlenums++;
|
|
||||||
|
|
||||||
// Set stepping???
|
|
||||||
// Kinda getting the impression this is never used.
|
|
||||||
channelstep[slot] = step;
|
|
||||||
// ???
|
|
||||||
channelstepremainder[slot] = 0;
|
|
||||||
// Should be gametic, I presume.
|
|
||||||
channelstart[slot] = gametic;
|
|
||||||
|
|
||||||
// Separation, that is, orientation/stereo.
|
|
||||||
// range is: 1 - 256
|
|
||||||
seperation += 1;
|
|
||||||
|
|
||||||
// Per left/right channel.
|
|
||||||
// x^2 seperation,
|
|
||||||
// adjust volume properly.
|
|
||||||
leftvol =
|
|
||||||
volume - ((volume*seperation*seperation) >> 16); ///(256*256);
|
|
||||||
seperation = seperation - 257;
|
|
||||||
rightvol =
|
|
||||||
volume - ((volume*seperation*seperation) >> 16);
|
|
||||||
|
|
||||||
// Sanity check, clamp volume.
|
|
||||||
if (rightvol < 0 || rightvol > 127)
|
|
||||||
I_Error("rightvol out of bounds");
|
|
||||||
|
|
||||||
if (leftvol < 0 || leftvol > 127)
|
|
||||||
I_Error("leftvol out of bounds");
|
|
||||||
|
|
||||||
// Get the proper lookup table piece
|
|
||||||
// for this volume level???
|
|
||||||
channelleftvol_lookup[slot] = &vol_lookup[leftvol*256];
|
|
||||||
channelrightvol_lookup[slot] = &vol_lookup[rightvol*256];
|
|
||||||
|
|
||||||
// Preserve sound SFX id,
|
|
||||||
// e.g. for avoiding duplicates of chainsaw.
|
|
||||||
channelids[slot] = sfxid;
|
|
||||||
|
|
||||||
// You tell me.
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// SFX API
|
|
||||||
// Note: this was called by S_Init.
|
|
||||||
// However, whatever they did in the
|
|
||||||
// old DPMS based DOS version, this
|
|
||||||
// were simply dummies in the Linux
|
|
||||||
// version.
|
|
||||||
// See soundserver initdata().
|
|
||||||
//
|
|
||||||
void I_SetChannels()
|
|
||||||
{
|
|
||||||
// Init internal lookups (raw data, mixing buffer, channels).
|
|
||||||
// This function sets up internal lookups used during
|
|
||||||
// the mixing process.
|
|
||||||
int i;
|
|
||||||
int j;
|
|
||||||
|
|
||||||
int* steptablemid = steptable + 128;
|
|
||||||
|
|
||||||
// Okay, reset internal mixing channels to zero.
|
|
||||||
/*for (i=0; i<NUM_CHANNELS; i++)
|
|
||||||
{
|
|
||||||
channels[i] = 0;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
// This table provides step widths for pitch parameters.
|
|
||||||
// I fail to see that this is currently used.
|
|
||||||
for (i=-128 ; i<128 ; i++)
|
|
||||||
steptablemid[i] = (int)(pow(2.0, (i/64.0))*65536.0);
|
|
||||||
|
|
||||||
|
|
||||||
// Generates volume lookup tables
|
|
||||||
// which also turn the unsigned samples
|
|
||||||
// into signed samples.
|
|
||||||
for (i=0 ; i<128 ; i++)
|
|
||||||
for (j=0 ; j<256 ; j++)
|
|
||||||
vol_lookup[i*256+j] = (i*(j-128)*256)/127;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void I_SetSfxVolume(int volume)
|
|
||||||
{
|
|
||||||
// Identical to DOS.
|
|
||||||
// Basically, this should propagate
|
|
||||||
// the menu/config file setting
|
|
||||||
// to the state variable used in
|
|
||||||
// the mixing.
|
|
||||||
snd_SfxVolume = volume;
|
|
||||||
}
|
|
||||||
|
|
||||||
// MUSIC API - dummy. Some code from DOS version.
|
|
||||||
void I_SetMusicVolume(int volume)
|
|
||||||
{
|
|
||||||
// Internal state variable.
|
|
||||||
snd_MusicVolume = volume;
|
|
||||||
// Now set volume on output device.
|
|
||||||
// Whatever( snd_MusciVolume );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// Retrieve the raw data lump index
|
|
||||||
// for a given SFX name.
|
|
||||||
//
|
|
||||||
int I_GetSfxLumpNum(sfxinfo_t* sfx)
|
|
||||||
{
|
|
||||||
char namebuf[9];
|
|
||||||
sprintf(namebuf, "ds%s", sfx->name);
|
|
||||||
return W_GetNumForName(namebuf);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Starting a sound means adding it
|
|
||||||
// to the current list of active sounds
|
|
||||||
// in the internal channels.
|
|
||||||
// As the SFX info struct contains
|
|
||||||
// e.g. a pointer to the raw data,
|
|
||||||
// it is ignored.
|
|
||||||
// As our sound handling does not handle
|
|
||||||
// priority, it is ignored.
|
|
||||||
// Pitching (that is, increased speed of playback)
|
|
||||||
// is set, but currently not used by mixing.
|
|
||||||
//
|
|
||||||
int
|
|
||||||
I_StartSound
|
|
||||||
( int id,
|
|
||||||
int vol,
|
|
||||||
int sep,
|
|
||||||
int pitch,
|
|
||||||
int priority )
|
|
||||||
{
|
|
||||||
|
|
||||||
// UNUSED
|
|
||||||
priority = 0;
|
|
||||||
|
|
||||||
#ifdef SNDSERV
|
|
||||||
if (sndserver)
|
|
||||||
{
|
|
||||||
fprintf(sndserver, "p%2.2x%2.2x%2.2x%2.2x\n", id, pitch, vol, sep);
|
|
||||||
fflush(sndserver);
|
|
||||||
}
|
|
||||||
// warning: control reaches end of non-void function.
|
|
||||||
return id;
|
|
||||||
#else
|
|
||||||
// Debug.
|
|
||||||
//fprintf( stderr, "starting sound %d", id );
|
|
||||||
|
|
||||||
// Returns a handle (not used).
|
|
||||||
id = addsfx( id, vol, steptable[pitch], sep );
|
|
||||||
|
|
||||||
// fprintf( stderr, "/handle is %d\n", id );
|
|
||||||
|
|
||||||
return id;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void I_StopSound (int handle)
|
|
||||||
{
|
|
||||||
// You need the handle returned by StartSound.
|
|
||||||
// Would be looping all channels,
|
|
||||||
// tracking down the handle,
|
|
||||||
// an setting the channel to zero.
|
|
||||||
|
|
||||||
// UNUSED.
|
|
||||||
handle = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int I_SoundIsPlaying(int handle)
|
|
||||||
{
|
|
||||||
// Ouch.
|
|
||||||
return gametic < handle;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// This function loops all active (internal) sound
|
|
||||||
// channels, retrieves a given number of samples
|
|
||||||
// from the raw sound data, modifies it according
|
|
||||||
// to the current (internal) channel parameters,
|
|
||||||
// mixes the per channel samples into the global
|
|
||||||
// mixbuffer, clamping it to the allowed range,
|
|
||||||
// and sets up everything for transferring the
|
|
||||||
// contents of the mixbuffer to the (two)
|
|
||||||
// hardware channels (left and right, that is).
|
|
||||||
//
|
|
||||||
// This function currently supports only 16bit.
|
|
||||||
//
|
|
||||||
void I_UpdateSound( void )
|
|
||||||
{
|
|
||||||
#ifdef SNDINTR
|
|
||||||
// Debug. Count buffer misses with interrupt.
|
|
||||||
static int misses = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
// Mix current sound data.
|
|
||||||
// Data, from raw sound, for right and left.
|
|
||||||
register unsigned int sample;
|
|
||||||
register int dl;
|
|
||||||
register int dr;
|
|
||||||
|
|
||||||
// Pointers in global mixbuffer, left, right, end.
|
|
||||||
signed short* leftout;
|
|
||||||
signed short* rightout;
|
|
||||||
signed short* leftend;
|
|
||||||
// Step in mixbuffer, left and right, thus two.
|
|
||||||
int step;
|
|
||||||
|
|
||||||
// Mixing channel index.
|
|
||||||
int chan;
|
|
||||||
|
|
||||||
// Left and right channel
|
|
||||||
// are in global mixbuffer, alternating.
|
|
||||||
leftout = mixbuffer;
|
|
||||||
rightout = mixbuffer+1;
|
|
||||||
step = 2;
|
|
||||||
|
|
||||||
// Determine end, for left channel only
|
|
||||||
// (right channel is implicit).
|
|
||||||
leftend = mixbuffer + SAMPLECOUNT*step;
|
|
||||||
|
|
||||||
// Mix sounds into the mixing buffer.
|
|
||||||
// Loop over step*SAMPLECOUNT,
|
|
||||||
// that is 512 values for two channels.
|
|
||||||
while (leftout != leftend)
|
|
||||||
{
|
|
||||||
// Reset left/right value.
|
|
||||||
dl = 0;
|
|
||||||
dr = 0;
|
|
||||||
|
|
||||||
// Love thy L2 chache - made this a loop.
|
|
||||||
// Now more channels could be set at compile time
|
|
||||||
// as well. Thus loop those channels.
|
|
||||||
for ( chan = 0; chan < NUM_CHANNELS; chan++ )
|
|
||||||
{
|
|
||||||
// Check channel, if active.
|
|
||||||
if (channels[ chan ])
|
|
||||||
{
|
|
||||||
// Get the raw data from the channel.
|
|
||||||
sample = *channels[ chan ];
|
|
||||||
// Add left and right part
|
|
||||||
// for this channel (sound)
|
|
||||||
// to the current data.
|
|
||||||
// Adjust volume accordingly.
|
|
||||||
dl += channelleftvol_lookup[ chan ][sample];
|
|
||||||
dr += channelrightvol_lookup[ chan ][sample];
|
|
||||||
// Increment index ???
|
|
||||||
channelstepremainder[ chan ] += channelstep[ chan ];
|
|
||||||
// MSB is next sample???
|
|
||||||
channels[ chan ] += channelstepremainder[ chan ] >> 16;
|
|
||||||
// Limit to LSB???
|
|
||||||
channelstepremainder[ chan ] &= 65536-1;
|
|
||||||
|
|
||||||
// Check whether we are done.
|
|
||||||
if (channels[ chan ] >= channelsend[ chan ])
|
|
||||||
channels[ chan ] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clamp to range. Left hardware channel.
|
|
||||||
// Has been char instead of short.
|
|
||||||
// if (dl > 127) *leftout = 127;
|
|
||||||
// else if (dl < -128) *leftout = -128;
|
|
||||||
// else *leftout = dl;
|
|
||||||
|
|
||||||
if (dl > 0x7fff)
|
|
||||||
*leftout = 0x7fff;
|
|
||||||
else if (dl < -0x8000)
|
|
||||||
*leftout = -0x8000;
|
|
||||||
else
|
|
||||||
*leftout = dl;
|
|
||||||
|
|
||||||
// Same for right hardware channel.
|
|
||||||
if (dr > 0x7fff)
|
|
||||||
*rightout = 0x7fff;
|
|
||||||
else if (dr < -0x8000)
|
|
||||||
*rightout = -0x8000;
|
|
||||||
else
|
|
||||||
*rightout = dr;
|
|
||||||
|
|
||||||
// Increment current pointers in mixbuffer.
|
|
||||||
leftout += step;
|
|
||||||
rightout += step;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef SNDINTR
|
|
||||||
// Debug check.
|
|
||||||
if ( flag )
|
|
||||||
{
|
|
||||||
misses += flag;
|
|
||||||
flag = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( misses > 10 )
|
|
||||||
{
|
|
||||||
fprintf( stderr, "I_SoundUpdate: missed 10 buffer writes\n");
|
|
||||||
misses = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Increment flag for update.
|
|
||||||
flag++;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// This would be used to write out the mixbuffer
|
|
||||||
// during each game loop update.
|
|
||||||
// Updates sound buffer and audio device at runtime.
|
|
||||||
// It is called during Timer interrupt with SNDINTR.
|
|
||||||
// Mixing now done synchronous, and
|
|
||||||
// only output be done asynchronous?
|
|
||||||
//
|
|
||||||
void
|
|
||||||
I_SubmitSound(void)
|
|
||||||
{
|
|
||||||
// Write it to DSP device.
|
|
||||||
write(audio_fd, mixbuffer, SAMPLECOUNT*BUFMUL);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
I_UpdateSoundParams
|
|
||||||
( int handle,
|
|
||||||
int vol,
|
|
||||||
int sep,
|
|
||||||
int pitch)
|
|
||||||
{
|
|
||||||
// I fail too see that this is used.
|
|
||||||
// Would be using the handle to identify
|
|
||||||
// on which channel the sound might be active,
|
|
||||||
// and resetting the channel parameters.
|
|
||||||
|
|
||||||
// UNUSED.
|
|
||||||
handle = vol = sep = pitch = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void I_ShutdownSound(void)
|
|
||||||
{
|
|
||||||
#ifdef SNDSERV
|
|
||||||
if (sndserver)
|
|
||||||
{
|
|
||||||
// Send a "quit" command.
|
|
||||||
fprintf(sndserver, "q\n");
|
|
||||||
fflush(sndserver);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
// Wait till all pending sounds are finished.
|
|
||||||
int done = 0;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
|
|
||||||
// FIXME (below).
|
|
||||||
fprintf( stderr, "I_ShutdownSound: NOT finishing pending sounds\n");
|
|
||||||
fflush( stderr );
|
|
||||||
|
|
||||||
while ( !done )
|
|
||||||
{
|
|
||||||
for( i=0 ; i<8 && !channels[i] ; i++);
|
|
||||||
|
|
||||||
// FIXME. No proper channel output.
|
|
||||||
//if (i==8)
|
|
||||||
done=1;
|
|
||||||
}
|
|
||||||
#ifdef SNDINTR
|
|
||||||
I_SoundDelTimer();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Cleaning up -releasing the DSP device.
|
|
||||||
close ( audio_fd );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Done.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
I_InitSound()
|
|
||||||
{
|
|
||||||
#ifdef SNDSERV
|
|
||||||
char buffer[256];
|
|
||||||
|
|
||||||
if (getenv("DOOMWADDIR"))
|
|
||||||
sprintf(buffer, "%s/%s",
|
|
||||||
getenv("DOOMWADDIR"),
|
|
||||||
sndserver_filename);
|
|
||||||
else
|
|
||||||
sprintf(buffer, "%s", sndserver_filename);
|
|
||||||
|
|
||||||
// start sound process
|
|
||||||
if ( !access(buffer, X_OK) )
|
|
||||||
{
|
|
||||||
strcat(buffer, " -quiet");
|
|
||||||
sndserver = NULL; //popen(buffer, "w");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
fprintf(stderr, "Could not start sound server [%s]\n", buffer);
|
|
||||||
#else
|
|
||||||
|
|
||||||
int i;
|
|
||||||
|
|
||||||
#ifdef SNDINTR
|
|
||||||
fprintf( stderr, "I_SoundSetTimer: %d microsecs\n", SOUND_INTERVAL );
|
|
||||||
I_SoundSetTimer( SOUND_INTERVAL );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Secure and configure sound device first.
|
|
||||||
fprintf( stderr, "I_InitSound: ");
|
|
||||||
|
|
||||||
audio_fd = open("/dev/dsp", O_WRONLY);
|
|
||||||
if (audio_fd<0)
|
|
||||||
fprintf(stderr, "Could not open /dev/dsp\n");
|
|
||||||
|
|
||||||
|
|
||||||
i = 11 | (2<<16);
|
|
||||||
myioctl(audio_fd, SNDCTL_DSP_SETFRAGMENT, &i);
|
|
||||||
myioctl(audio_fd, SNDCTL_DSP_RESET, 0);
|
|
||||||
|
|
||||||
i=SAMPLERATE;
|
|
||||||
|
|
||||||
myioctl(audio_fd, SNDCTL_DSP_SPEED, &i);
|
|
||||||
|
|
||||||
i=1;
|
|
||||||
myioctl(audio_fd, SNDCTL_DSP_STEREO, &i);
|
|
||||||
|
|
||||||
myioctl(audio_fd, SNDCTL_DSP_GETFMTS, &i);
|
|
||||||
|
|
||||||
if (i&=AFMT_S16_LE)
|
|
||||||
myioctl(audio_fd, SNDCTL_DSP_SETFMT, &i);
|
|
||||||
else
|
|
||||||
fprintf(stderr, "Could not play signed 16 data\n");
|
|
||||||
|
|
||||||
fprintf(stderr, " configured audio device\n" );
|
|
||||||
|
|
||||||
|
|
||||||
// Initialize external data (all sounds) at start, keep static.
|
|
||||||
fprintf( stderr, "I_InitSound: ");
|
|
||||||
|
|
||||||
for (i=1 ; i<NUMSFX ; i++)
|
|
||||||
{
|
|
||||||
// Alias? Example is the chaingun sound linked to pistol.
|
|
||||||
if (!S_sfx[i].link)
|
|
||||||
{
|
|
||||||
// Load data from WAD file.
|
|
||||||
S_sfx[i].data = getsfx( S_sfx[i].name, &lengths[i] );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Previously loaded already?
|
|
||||||
S_sfx[i].data = S_sfx[i].link->data;
|
|
||||||
lengths[i] = lengths[(S_sfx[i].link - S_sfx)/sizeof(sfxinfo_t)];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf( stderr, " pre-cached all sound data\n");
|
|
||||||
|
|
||||||
// Now initialize mixbuffer with zero.
|
|
||||||
for ( i = 0; i< MIXBUFFERSIZE; i++ )
|
|
||||||
mixbuffer[i] = 0;
|
|
||||||
|
|
||||||
// Finished initialization.
|
|
||||||
fprintf(stderr, "I_InitSound: sound module ready\n");
|
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// MUSIC API.
|
|
||||||
// Still no music done.
|
|
||||||
// Remains. Dummies.
|
|
||||||
//
|
|
||||||
void I_InitMusic(void) { }
|
|
||||||
void I_ShutdownMusic(void) { }
|
|
||||||
|
|
||||||
static int looping=0;
|
|
||||||
static int musicdies=-1;
|
|
||||||
|
|
||||||
void I_PlaySong(int handle, int looping)
|
|
||||||
{
|
|
||||||
// UNUSED.
|
|
||||||
handle = looping = 0;
|
|
||||||
musicdies = gametic + TICRATE*30;
|
|
||||||
}
|
|
||||||
|
|
||||||
void I_PauseSong (int handle)
|
|
||||||
{
|
|
||||||
// UNUSED.
|
|
||||||
handle = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void I_ResumeSong (int handle)
|
|
||||||
{
|
|
||||||
// UNUSED.
|
|
||||||
handle = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void I_StopSong(int handle)
|
|
||||||
{
|
|
||||||
// UNUSED.
|
|
||||||
handle = 0;
|
|
||||||
|
|
||||||
looping = 0;
|
|
||||||
musicdies = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void I_UnRegisterSong(int handle)
|
|
||||||
{
|
|
||||||
// UNUSED.
|
|
||||||
handle = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int I_RegisterSong(void* data)
|
|
||||||
{
|
|
||||||
// UNUSED.
|
|
||||||
data = NULL;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Is the song playing?
|
|
||||||
int I_QrySongPlaying(int handle)
|
|
||||||
{
|
|
||||||
// UNUSED.
|
|
||||||
handle = 0;
|
|
||||||
return looping || musicdies > gametic;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// Experimental stuff.
|
|
||||||
// A Linux timer interrupt, for asynchronous
|
|
||||||
// sound output.
|
|
||||||
// I ripped this out of the Timer class in
|
|
||||||
// our Difference Engine, including a few
|
|
||||||
// SUN remains...
|
|
||||||
//
|
|
||||||
#ifdef sun
|
|
||||||
typedef sigset_t tSigSet;
|
|
||||||
#else
|
|
||||||
typedef int tSigSet;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
// We might use SIGVTALRM and ITIMER_VIRTUAL, if the process
|
|
||||||
// time independend timer happens to get lost due to heavy load.
|
|
||||||
// SIGALRM and ITIMER_REAL doesn't really work well.
|
|
||||||
// There are issues with profiling as well.
|
|
||||||
|
|
||||||
// Interrupt handler.
|
|
||||||
void I_HandleSoundTimer( int ignore )
|
|
||||||
{
|
|
||||||
// Debug.
|
|
||||||
//fprintf( stderr, "%c", '+' ); fflush( stderr );
|
|
||||||
|
|
||||||
// Feed sound device if necesary.
|
|
||||||
if ( flag )
|
|
||||||
{
|
|
||||||
// See I_SubmitSound().
|
|
||||||
// Write it to DSP device.
|
|
||||||
write(audio_fd, mixbuffer, SAMPLECOUNT*BUFMUL);
|
|
||||||
|
|
||||||
// Reset flag counter.
|
|
||||||
flag = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return;
|
|
||||||
|
|
||||||
// UNUSED, but required.
|
|
||||||
ignore = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the interrupt. Set duration in millisecs.
|
|
||||||
int I_SoundSetTimer( int duration_of_tick )
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Remove the interrupt. Set duration to zero.
|
|
||||||
void I_SoundDelTimer()
|
|
||||||
{
|
|
||||||
// Debug.
|
|
||||||
if ( I_SoundSetTimer( 0 ) == -1)
|
|
||||||
fprintf( stderr, "I_SoundDelTimer: failed to remove interrupt. Doh!\n");
|
|
||||||
}
|
|
@ -19,9 +19,12 @@
|
|||||||
#include "i_timer.h"
|
#include "i_timer.h"
|
||||||
#include "doomtype.h"
|
#include "doomtype.h"
|
||||||
|
|
||||||
|
#include "doomgeneric.h"
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <sys/time.h>
|
//#include <sys/time.h>
|
||||||
#include <unistd.h>
|
//#include <unistd.h>
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// I_GetTime
|
// I_GetTime
|
||||||
@ -30,13 +33,10 @@
|
|||||||
|
|
||||||
static uint32_t basetime = 0;
|
static uint32_t basetime = 0;
|
||||||
|
|
||||||
|
|
||||||
int I_GetTicks(void)
|
int I_GetTicks(void)
|
||||||
{
|
{
|
||||||
struct timeval tp;
|
return DG_GetTicksMs();
|
||||||
struct timezone tzp;
|
|
||||||
|
|
||||||
gettimeofday(&tp, &tzp);
|
|
||||||
return (tp.tv_sec * 1000) + (tp.tv_usec / 1000); /* return milliseconds */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int I_GetTime (void)
|
int I_GetTime (void)
|
||||||
@ -75,7 +75,9 @@ int I_GetTimeMS(void)
|
|||||||
void I_Sleep(int ms)
|
void I_Sleep(int ms)
|
||||||
{
|
{
|
||||||
//SDL_Delay(ms);
|
//SDL_Delay(ms);
|
||||||
usleep (ms * 1000);
|
//usleep (ms * 1000);
|
||||||
|
|
||||||
|
DG_SleepMs(ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
void I_WaitVBL(int count)
|
void I_WaitVBL(int count)
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,568 +0,0 @@
|
|||||||
// Emacs style mode select -*- C++ -*-
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// $Id:$
|
|
||||||
//
|
|
||||||
// Copyright (C) 1993-1996 by id Software, Inc.
|
|
||||||
//
|
|
||||||
// This program is free software; you can redistribute it and/or
|
|
||||||
// modify it under the terms of the GNU General Public License
|
|
||||||
// as published by the Free Software Foundation; either version 2
|
|
||||||
// of the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// This program is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU General Public License for more details.
|
|
||||||
//
|
|
||||||
// $Log:$
|
|
||||||
//
|
|
||||||
// DESCRIPTION:
|
|
||||||
// DOOM graphics stuff for X11, UNIX.
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
static const char
|
|
||||||
rcsid[] = "$Id: i_x.c,v 1.6 1997/02/03 22:45:10 b1 Exp $";
|
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
#include "v_video.h"
|
|
||||||
#include "m_argv.h"
|
|
||||||
#include "d_event.h"
|
|
||||||
#include "d_main.h"
|
|
||||||
#include "i_video.h"
|
|
||||||
#include "z_zone.h"
|
|
||||||
|
|
||||||
#include "tables.h"
|
|
||||||
#include "doomkeys.h"
|
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <sys/time.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <linux/fb.h>
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
|
|
||||||
//#define CMAP256
|
|
||||||
|
|
||||||
struct fb_var_screeninfo fb = {};
|
|
||||||
int fb_scaling = 1;
|
|
||||||
int usemouse = 0;
|
|
||||||
|
|
||||||
struct color {
|
|
||||||
uint32_t b:8;
|
|
||||||
uint32_t g:8;
|
|
||||||
uint32_t r:8;
|
|
||||||
uint32_t a:8;
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct color colors[256];
|
|
||||||
|
|
||||||
// The screen buffer; this is modified to draw things to the screen
|
|
||||||
|
|
||||||
byte *I_VideoBuffer = NULL;
|
|
||||||
byte *I_VideoBuffer_FB = NULL;
|
|
||||||
|
|
||||||
/* framebuffer file descriptor */
|
|
||||||
int fd_fb = 0;
|
|
||||||
|
|
||||||
int X_width;
|
|
||||||
int X_height;
|
|
||||||
|
|
||||||
// If true, game is running as a screensaver
|
|
||||||
|
|
||||||
boolean screensaver_mode = false;
|
|
||||||
|
|
||||||
// Flag indicating whether the screen is currently visible:
|
|
||||||
// when the screen isnt visible, don't render the screen
|
|
||||||
|
|
||||||
boolean screenvisible;
|
|
||||||
|
|
||||||
// Mouse acceleration
|
|
||||||
//
|
|
||||||
// This emulates some of the behavior of DOS mouse drivers by increasing
|
|
||||||
// the speed when the mouse is moved fast.
|
|
||||||
//
|
|
||||||
// The mouse input values are input directly to the game, but when
|
|
||||||
// the values exceed the value of mouse_threshold, they are multiplied
|
|
||||||
// by mouse_acceleration to increase the speed.
|
|
||||||
|
|
||||||
float mouse_acceleration = 2.0;
|
|
||||||
int mouse_threshold = 10;
|
|
||||||
|
|
||||||
// Gamma correction level to use
|
|
||||||
|
|
||||||
int usegamma = 0;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
byte r;
|
|
||||||
byte g;
|
|
||||||
byte b;
|
|
||||||
} col_t;
|
|
||||||
|
|
||||||
// Palette converted to RGB565
|
|
||||||
|
|
||||||
static uint16_t rgb565_palette[256];
|
|
||||||
|
|
||||||
void cmap_to_rgb565(uint16_t * out, uint8_t * in, int in_pixels)
|
|
||||||
{
|
|
||||||
int i, j;
|
|
||||||
struct color c;
|
|
||||||
uint16_t r, g, b;
|
|
||||||
|
|
||||||
for (i = 0; i < in_pixels; i++)
|
|
||||||
{
|
|
||||||
c = colors[*in];
|
|
||||||
r = ((uint16_t)(c.r >> 3)) << 11;
|
|
||||||
g = ((uint16_t)(c.g >> 2)) << 5;
|
|
||||||
b = ((uint16_t)(c.b >> 3)) << 0;
|
|
||||||
*out = (r | g | b);
|
|
||||||
|
|
||||||
in++;
|
|
||||||
for (j = 0; j < fb_scaling; j++) {
|
|
||||||
out++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmap_to_fb(uint8_t * out, uint8_t * in, int in_pixels)
|
|
||||||
{
|
|
||||||
int i, j, k;
|
|
||||||
struct color c;
|
|
||||||
uint32_t pix;
|
|
||||||
uint16_t r, g, b;
|
|
||||||
|
|
||||||
for (i = 0; i < in_pixels; i++)
|
|
||||||
{
|
|
||||||
c = colors[*in]; /* R:8 G:8 B:8 format! */
|
|
||||||
r = (uint16_t)(c.r >> (8 - fb.red.length));
|
|
||||||
g = (uint16_t)(c.g >> (8 - fb.green.length));
|
|
||||||
b = (uint16_t)(c.b >> (8 - fb.blue.length));
|
|
||||||
pix = r << fb.red.offset;
|
|
||||||
pix |= g << fb.green.offset;
|
|
||||||
pix |= b << fb.blue.offset;
|
|
||||||
|
|
||||||
for (k = 0; k < fb_scaling; k++) {
|
|
||||||
for (j = 0; j < fb.bits_per_pixel/8; j++) {
|
|
||||||
*out = (pix >> (j*8));
|
|
||||||
out++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
in++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void I_InitGraphics (void)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
/* Open fbdev file descriptor */
|
|
||||||
fd_fb = open("/dev/fb0", O_RDWR);
|
|
||||||
if (fd_fb < 0)
|
|
||||||
{
|
|
||||||
printf("Could not open /dev/fb0");
|
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* fetch framebuffer info */
|
|
||||||
ioctl(fd_fb, FBIOGET_VSCREENINFO, &fb);
|
|
||||||
/* change params if needed */
|
|
||||||
//ioctl(fd_fb, FBIOPUT_VSCREENINFO, &fb);
|
|
||||||
printf("I_InitGraphics: framebuffer: x_res: %d, y_res: %d, x_virtual: %d, y_virtual: %d, bpp: %d, grayscale: %d\n",
|
|
||||||
fb.xres, fb.yres, fb.xres_virtual, fb.yres_virtual, fb.bits_per_pixel, fb.grayscale);
|
|
||||||
|
|
||||||
printf("I_InitGraphics: framebuffer: RGBA: %d%d%d%d, red_off: %d, green_off: %d, blue_off: %d, transp_off: %d\n",
|
|
||||||
fb.red.length, fb.green.length, fb.blue.length, fb.transp.length, fb.red.offset, fb.green.offset, fb.blue.offset, fb.transp.offset);
|
|
||||||
|
|
||||||
printf("I_InitGraphics: DOOM screen size: w x h: %d x %d\n", SCREENWIDTH, SCREENHEIGHT);
|
|
||||||
|
|
||||||
|
|
||||||
i = M_CheckParmWithArgs("-scaling", 1);
|
|
||||||
if (i > 0) {
|
|
||||||
i = atoi(myargv[i + 1]);
|
|
||||||
fb_scaling = i;
|
|
||||||
printf("I_InitGraphics: Scaling factor: %d\n", fb_scaling);
|
|
||||||
} else {
|
|
||||||
fb_scaling = fb.xres / SCREENWIDTH;
|
|
||||||
if (fb.yres / SCREENHEIGHT < fb_scaling)
|
|
||||||
fb_scaling = fb.yres / SCREENHEIGHT;
|
|
||||||
printf("I_InitGraphics: Auto-scaling factor: %d\n", fb_scaling);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Allocate screen to draw to */
|
|
||||||
I_VideoBuffer = (byte*)Z_Malloc (SCREENWIDTH * SCREENHEIGHT, PU_STATIC, NULL); // For DOOM to draw on
|
|
||||||
I_VideoBuffer_FB = (byte*)malloc(fb.xres * fb.yres * (fb.bits_per_pixel/8)); // For a single write() syscall to fbdev
|
|
||||||
|
|
||||||
screenvisible = true;
|
|
||||||
|
|
||||||
extern int I_InitInput(void);
|
|
||||||
I_InitInput();
|
|
||||||
}
|
|
||||||
|
|
||||||
void I_ShutdownGraphics (void)
|
|
||||||
{
|
|
||||||
Z_Free (I_VideoBuffer);
|
|
||||||
free(I_VideoBuffer_FB);
|
|
||||||
}
|
|
||||||
|
|
||||||
void I_StartFrame (void)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
__attribute__ ((weak)) void I_GetEvent (void)
|
|
||||||
{
|
|
||||||
// event_t event;
|
|
||||||
// bool button_state;
|
|
||||||
//
|
|
||||||
// button_state = button_read ();
|
|
||||||
//
|
|
||||||
// if (last_button_state != button_state)
|
|
||||||
// {
|
|
||||||
// last_button_state = button_state;
|
|
||||||
//
|
|
||||||
// event.type = last_button_state ? ev_keydown : ev_keyup;
|
|
||||||
// event.data1 = KEY_FIRE;
|
|
||||||
// event.data2 = -1;
|
|
||||||
// event.data3 = -1;
|
|
||||||
//
|
|
||||||
// D_PostEvent (&event);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// touch_main ();
|
|
||||||
//
|
|
||||||
// if ((touch_state.x != last_touch_state.x) || (touch_state.y != last_touch_state.y) || (touch_state.status != last_touch_state.status))
|
|
||||||
// {
|
|
||||||
// last_touch_state = touch_state;
|
|
||||||
//
|
|
||||||
// event.type = (touch_state.status == TOUCH_PRESSED) ? ev_keydown : ev_keyup;
|
|
||||||
// event.data1 = -1;
|
|
||||||
// event.data2 = -1;
|
|
||||||
// event.data3 = -1;
|
|
||||||
//
|
|
||||||
// if ((touch_state.x > 49)
|
|
||||||
// && (touch_state.x < 72)
|
|
||||||
// && (touch_state.y > 104)
|
|
||||||
// && (touch_state.y < 143))
|
|
||||||
// {
|
|
||||||
// // select weapon
|
|
||||||
// if (touch_state.x < 60)
|
|
||||||
// {
|
|
||||||
// // lower row (5-7)
|
|
||||||
// if (touch_state.y < 119)
|
|
||||||
// {
|
|
||||||
// event.data1 = '5';
|
|
||||||
// }
|
|
||||||
// else if (touch_state.y < 131)
|
|
||||||
// {
|
|
||||||
// event.data1 = '6';
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// event.data1 = '1';
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// // upper row (2-4)
|
|
||||||
// if (touch_state.y < 119)
|
|
||||||
// {
|
|
||||||
// event.data1 = '2';
|
|
||||||
// }
|
|
||||||
// else if (touch_state.y < 131)
|
|
||||||
// {
|
|
||||||
// event.data1 = '3';
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// event.data1 = '4';
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// else if (touch_state.x < 40)
|
|
||||||
// {
|
|
||||||
// // button bar at bottom screen
|
|
||||||
// if (touch_state.y < 40)
|
|
||||||
// {
|
|
||||||
// // enter
|
|
||||||
// event.data1 = KEY_ENTER;
|
|
||||||
// }
|
|
||||||
// else if (touch_state.y < 80)
|
|
||||||
// {
|
|
||||||
// // escape
|
|
||||||
// event.data1 = KEY_ESCAPE;
|
|
||||||
// }
|
|
||||||
// else if (touch_state.y < 120)
|
|
||||||
// {
|
|
||||||
// // use
|
|
||||||
// event.data1 = KEY_USE;
|
|
||||||
// }
|
|
||||||
// else if (touch_state.y < 160)
|
|
||||||
// {
|
|
||||||
// // map
|
|
||||||
// event.data1 = KEY_TAB;
|
|
||||||
// }
|
|
||||||
// else if (touch_state.y < 200)
|
|
||||||
// {
|
|
||||||
// // pause
|
|
||||||
// event.data1 = KEY_PAUSE;
|
|
||||||
// }
|
|
||||||
// else if (touch_state.y < 240)
|
|
||||||
// {
|
|
||||||
// // toggle run
|
|
||||||
// if (touch_state.status == TOUCH_PRESSED)
|
|
||||||
// {
|
|
||||||
// run = !run;
|
|
||||||
//
|
|
||||||
// event.data1 = KEY_RSHIFT;
|
|
||||||
//
|
|
||||||
// if (run)
|
|
||||||
// {
|
|
||||||
// event.type = ev_keydown;
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// event.type = ev_keyup;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// else if (touch_state.y < 280)
|
|
||||||
// {
|
|
||||||
// // save
|
|
||||||
// event.data1 = KEY_F2;
|
|
||||||
// }
|
|
||||||
// else if (touch_state.y < 320)
|
|
||||||
// {
|
|
||||||
// // load
|
|
||||||
// event.data1 = KEY_F3;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// // movement/menu navigation
|
|
||||||
// if (touch_state.x < 100)
|
|
||||||
// {
|
|
||||||
// if (touch_state.y < 100)
|
|
||||||
// {
|
|
||||||
// event.data1 = KEY_STRAFE_L;
|
|
||||||
// }
|
|
||||||
// else if (touch_state.y < 220)
|
|
||||||
// {
|
|
||||||
// event.data1 = KEY_DOWNARROW;
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// event.data1 = KEY_STRAFE_R;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// else if (touch_state.x < 180)
|
|
||||||
// {
|
|
||||||
// if (touch_state.y < 160)
|
|
||||||
// {
|
|
||||||
// event.data1 = KEY_LEFTARROW;
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// event.data1 = KEY_RIGHTARROW;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// event.data1 = KEY_UPARROW;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// D_PostEvent (&event);
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
__attribute__ ((weak)) void I_StartTic (void)
|
|
||||||
{
|
|
||||||
I_GetEvent();
|
|
||||||
}
|
|
||||||
|
|
||||||
void I_UpdateNoBlit (void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// I_FinishUpdate
|
|
||||||
//
|
|
||||||
|
|
||||||
void I_FinishUpdate (void)
|
|
||||||
{
|
|
||||||
int y;
|
|
||||||
int x_offset, y_offset, x_offset_end;
|
|
||||||
unsigned char *line_in, *line_out;
|
|
||||||
|
|
||||||
/* Offsets in case FB is bigger than DOOM */
|
|
||||||
/* 600 = fb heigt, 200 screenheight */
|
|
||||||
/* 600 = fb heigt, 200 screenheight */
|
|
||||||
/* 2048 =fb width, 320 screenwidth */
|
|
||||||
y_offset = (((fb.yres - (SCREENHEIGHT * fb_scaling)) * fb.bits_per_pixel/8)) / 2;
|
|
||||||
x_offset = (((fb.xres - (SCREENWIDTH * fb_scaling)) * fb.bits_per_pixel/8)) / 2; // XXX: siglent FB hack: /4 instead of /2, since it seems to handle the resolution in a funny way
|
|
||||||
//x_offset = 0;
|
|
||||||
x_offset_end = ((fb.xres - (SCREENWIDTH * fb_scaling)) * fb.bits_per_pixel/8) - x_offset;
|
|
||||||
|
|
||||||
/* DRAW SCREEN */
|
|
||||||
line_in = (unsigned char *) I_VideoBuffer;
|
|
||||||
line_out = (unsigned char *) I_VideoBuffer_FB;
|
|
||||||
|
|
||||||
y = SCREENHEIGHT;
|
|
||||||
|
|
||||||
while (y--)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
for (i = 0; i < fb_scaling; i++) {
|
|
||||||
line_out += x_offset;
|
|
||||||
#ifdef CMAP256
|
|
||||||
for (fb_scaling == 1) {
|
|
||||||
memcpy(line_out, line_in, SCREENWIDTH); /* fb_width is bigger than Doom SCREENWIDTH... */
|
|
||||||
} else {
|
|
||||||
//XXX FIXME fb_scaling support!
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
//cmap_to_rgb565((void*)line_out, (void*)line_in, SCREENWIDTH);
|
|
||||||
cmap_to_fb((void*)line_out, (void*)line_in, SCREENWIDTH);
|
|
||||||
#endif
|
|
||||||
line_out += (SCREENWIDTH * fb_scaling * (fb.bits_per_pixel/8)) + x_offset_end;
|
|
||||||
}
|
|
||||||
line_in += SCREENWIDTH;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Start drawing from y-offset */
|
|
||||||
lseek(fd_fb, y_offset * fb.xres, SEEK_SET);
|
|
||||||
write(fd_fb, I_VideoBuffer_FB, (SCREENHEIGHT * fb_scaling * (fb.bits_per_pixel/8)) * fb.xres); /* draw only portion used by doom + x-offsets */
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// I_ReadScreen
|
|
||||||
//
|
|
||||||
void I_ReadScreen (byte* scr)
|
|
||||||
{
|
|
||||||
memcpy (scr, I_VideoBuffer, SCREENWIDTH * SCREENHEIGHT);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// I_SetPalette
|
|
||||||
//
|
|
||||||
#define GFX_RGB565(r, g, b) ((((r & 0xF8) >> 3) << 11) | (((g & 0xFC) >> 2) << 5) | ((b & 0xF8) >> 3))
|
|
||||||
#define GFX_RGB565_R(color) ((0xF800 & color) >> 11)
|
|
||||||
#define GFX_RGB565_G(color) ((0x07E0 & color) >> 5)
|
|
||||||
#define GFX_RGB565_B(color) (0x001F & color)
|
|
||||||
|
|
||||||
void I_SetPalette (byte* palette)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
//col_t* c;
|
|
||||||
|
|
||||||
//for (i = 0; i < 256; i++)
|
|
||||||
//{
|
|
||||||
// c = (col_t*)palette;
|
|
||||||
|
|
||||||
// rgb565_palette[i] = GFX_RGB565(gammatable[usegamma][c->r],
|
|
||||||
// gammatable[usegamma][c->g],
|
|
||||||
// gammatable[usegamma][c->b]);
|
|
||||||
|
|
||||||
// palette += 3;
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
/* performance boost:
|
|
||||||
* map to the right pixel format over here! */
|
|
||||||
|
|
||||||
for (i=0; i<256; ++i ) {
|
|
||||||
colors[i].a = 0;
|
|
||||||
colors[i].r = gammatable[usegamma][*palette++];
|
|
||||||
colors[i].g = gammatable[usegamma][*palette++];
|
|
||||||
colors[i].b = gammatable[usegamma][*palette++];
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set new color map in kernel framebuffer driver */
|
|
||||||
//XXX FIXME ioctl(fd_fb, IOCTL_FB_PUTCMAP, colors);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Given an RGB value, find the closest matching palette index.
|
|
||||||
|
|
||||||
int I_GetPaletteIndex (int r, int g, int b)
|
|
||||||
{
|
|
||||||
int best, best_diff, diff;
|
|
||||||
int i;
|
|
||||||
col_t color;
|
|
||||||
|
|
||||||
printf("I_GetPaletteIndex\n");
|
|
||||||
|
|
||||||
best = 0;
|
|
||||||
best_diff = INT_MAX;
|
|
||||||
|
|
||||||
for (i = 0; i < 256; ++i)
|
|
||||||
{
|
|
||||||
color.r = GFX_RGB565_R(rgb565_palette[i]);
|
|
||||||
color.g = GFX_RGB565_G(rgb565_palette[i]);
|
|
||||||
color.b = GFX_RGB565_B(rgb565_palette[i]);
|
|
||||||
|
|
||||||
diff = (r - color.r) * (r - color.r)
|
|
||||||
+ (g - color.g) * (g - color.g)
|
|
||||||
+ (b - color.b) * (b - color.b);
|
|
||||||
|
|
||||||
if (diff < best_diff)
|
|
||||||
{
|
|
||||||
best = i;
|
|
||||||
best_diff = diff;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (diff == 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return best;
|
|
||||||
}
|
|
||||||
|
|
||||||
void I_BeginRead (void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void I_EndRead (void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void I_SetWindowTitle (char *title)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void I_GraphicsCheckCommandLine (void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void I_SetGrabMouseCallback (grabmouse_callback_t func)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void I_EnableLoadingDisk(void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void I_BindVideoVariables (void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void I_DisplayFPSDots (boolean dots_on)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void I_CheckIsScreensaver (void)
|
|
||||||
{
|
|
||||||
}
|
|
@ -75,7 +75,7 @@ int showMessages = 1;
|
|||||||
|
|
||||||
// Blocky mode, has default, 0 = high, 1 = normal
|
// Blocky mode, has default, 0 = high, 1 = normal
|
||||||
int detailLevel = 0;
|
int detailLevel = 0;
|
||||||
int screenblocks = 9;
|
int screenblocks = 10;
|
||||||
|
|
||||||
// temp for screenblocks (0-9)
|
// temp for screenblocks (0-9)
|
||||||
int screenSize;
|
int screenSize;
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <arpa/inet.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
//XXX FIXME
|
|
||||||
in_addr_t inet_addr(const char *cp)
|
|
||||||
{
|
|
||||||
return (in_addr_t)NULL;
|
|
||||||
}
|
|
||||||
|
|
@ -27,9 +27,11 @@
|
|||||||
|
|
||||||
extern wad_file_class_t stdc_wad_file;
|
extern wad_file_class_t stdc_wad_file;
|
||||||
|
|
||||||
|
/*
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
extern wad_file_class_t win32_wad_file;
|
extern wad_file_class_t win32_wad_file;
|
||||||
#endif
|
#endif
|
||||||
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_MMAP
|
#ifdef HAVE_MMAP
|
||||||
extern wad_file_class_t posix_wad_file;
|
extern wad_file_class_t posix_wad_file;
|
||||||
@ -37,9 +39,11 @@ extern wad_file_class_t posix_wad_file;
|
|||||||
|
|
||||||
static wad_file_class_t *wad_file_classes[] =
|
static wad_file_class_t *wad_file_classes[] =
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
&win32_wad_file,
|
&win32_wad_file,
|
||||||
#endif
|
#endif
|
||||||
|
*/
|
||||||
#ifdef HAVE_MMAP
|
#ifdef HAVE_MMAP
|
||||||
&posix_wad_file,
|
&posix_wad_file,
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,118 +0,0 @@
|
|||||||
//
|
|
||||||
// Copyright(C) 1993-1996 Id Software, Inc.
|
|
||||||
// Copyright(C) 2005-2014 Simon Howard
|
|
||||||
//
|
|
||||||
// This program is free software; you can redistribute it and/or
|
|
||||||
// modify it under the terms of the GNU General Public License
|
|
||||||
// as published by the Free Software Foundation; either version 2
|
|
||||||
// of the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// This program is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU General Public License for more details.
|
|
||||||
//
|
|
||||||
// DESCRIPTION:
|
|
||||||
// WAD I/O functions.
|
|
||||||
//
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include "m_misc.h"
|
|
||||||
#include "w_file.h"
|
|
||||||
#include "z_zone.h"
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
wad_file_t wad;
|
|
||||||
int fd;
|
|
||||||
} stdc_wad_file_t;
|
|
||||||
|
|
||||||
extern wad_file_class_t stdc_wad_file;
|
|
||||||
|
|
||||||
static unsigned int W_StdC_FileLength(int fd)
|
|
||||||
{
|
|
||||||
long savedpos;
|
|
||||||
long length;
|
|
||||||
|
|
||||||
// save the current position in the file
|
|
||||||
savedpos = lseek(fd, 0, SEEK_CUR);
|
|
||||||
|
|
||||||
// jump to the end and find the length
|
|
||||||
length = lseek(fd, 0, SEEK_END);
|
|
||||||
|
|
||||||
// go back to the old location
|
|
||||||
lseek(fd, savedpos, SEEK_SET);
|
|
||||||
|
|
||||||
return length;
|
|
||||||
}
|
|
||||||
|
|
||||||
static wad_file_t *W_StdC_OpenFile(char *path)
|
|
||||||
{
|
|
||||||
stdc_wad_file_t *result;
|
|
||||||
int fd;
|
|
||||||
|
|
||||||
fd = open(path, O_RDONLY);
|
|
||||||
|
|
||||||
if (fd <= 0)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a new stdc_wad_file_t to hold the file handle.
|
|
||||||
|
|
||||||
result = Z_Malloc(sizeof(stdc_wad_file_t), PU_STATIC, 0);
|
|
||||||
result->wad.file_class = &stdc_wad_file;
|
|
||||||
result->wad.mapped = NULL;
|
|
||||||
result->wad.length = W_StdC_FileLength(fd);
|
|
||||||
result->fd = fd;
|
|
||||||
|
|
||||||
return &result->wad;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void W_StdC_CloseFile(wad_file_t *wad)
|
|
||||||
{
|
|
||||||
stdc_wad_file_t *stdc_wad;
|
|
||||||
|
|
||||||
stdc_wad = (stdc_wad_file_t *) wad;
|
|
||||||
|
|
||||||
close(stdc_wad->fd);
|
|
||||||
Z_Free(stdc_wad);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read data from the specified position in the file into the
|
|
||||||
// provided buffer. Returns the number of bytes read.
|
|
||||||
|
|
||||||
size_t W_StdC_Read(wad_file_t *wad, unsigned int offset,
|
|
||||||
void *buffer, size_t buffer_len)
|
|
||||||
{
|
|
||||||
stdc_wad_file_t *stdc_wad;
|
|
||||||
size_t result;
|
|
||||||
|
|
||||||
stdc_wad = (stdc_wad_file_t *) wad;
|
|
||||||
|
|
||||||
// Jump to the specified position in the file.
|
|
||||||
|
|
||||||
lseek(stdc_wad->fd, offset, SEEK_SET);
|
|
||||||
|
|
||||||
// Read into the buffer.
|
|
||||||
|
|
||||||
result = read(stdc_wad->fd, buffer, buffer_len);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
wad_file_class_t stdc_wad_file =
|
|
||||||
{
|
|
||||||
W_StdC_OpenFile,
|
|
||||||
W_StdC_CloseFile,
|
|
||||||
W_StdC_Read,
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user